Skip to content

feat: add opt-in LCM task suggestion tools (6/10)#539

Closed
100yenadmin wants to merge 37 commits into
Martian-Engineering:mainfrom
electricsheephq:feat/lcm-task-suggestion-tools
Closed

feat: add opt-in LCM task suggestion tools (6/10)#539
100yenadmin wants to merge 37 commits into
Martian-Engineering:mainfrom
electricsheephq:feat/lcm-task-suggestion-tools

Conversation

@100yenadmin

@100yenadmin 100yenadmin commented Apr 29, 2026

Copy link
Copy Markdown
Collaborator

PR #539: Opt-in task suggestion tools over the inert ledger

Maintainer Quick Read

Field Value
Stack position 6/10
Logical parent for review #518
Current head 74da88b9f720554a17c368f280348081a0f992c7
Current PR state Ready after #518
Merge note Can merge after the ledger; independent of #537/#538.
Last body refresh 2026-05-02

Why Maintainers Should Care

This adds optional tools for previewing, recording, and reviewing task suggestions, but only behind an explicit config gate. It keeps the bridge review-led and prevents LCM from becoming a background task writer.

Stack Map

flowchart LR
  P516["#516 Temporal spine"] --> P517["#517 Observed work read model"]
  P517 --> P518["#518 Suggestion ledger"]
  P518 --> P537["#537 Deterministic extraction"]
  P537 --> P538["#538 Event observations"]
  P518 --> P539["#539 Opt-in suggestion tools"]
  P538 --> P540["#540 Maintenance wiring"]
  P540 --> P530["#530 Tracker/open state"]
  P538 --> P531["#531 Event episodes"]
  P530 --> P532["#532 Topic/vocabulary"]
  P526["#526 Draft reference"] -. "not the merge path" .-> P516
Loading

How It Works

flowchart TD
  A["taskBridgeToolsEnabled?" ] --> B{"enabled"}
  B -- "no" --> C["tools are not registered"]
  B -- "yes" --> D["preview suggestion"]
  D --> E{"record?"}
  E -- "no" --> F["dry-run output only"]
  E -- "yes" --> G["write suggestion ledger"]
  G --> H["review/dismiss/update ledger state"]
  H -. "never" .-> I["direct task write"]
Loading

What Ships In This PR

  • config-gated task suggestion tools
  • preview behavior that can stay dry-run
  • record/review operations that only touch the suggestion ledger
  • source/confidence/rationale validation
  • tests proving no external task writes

What This PR Intentionally Does Not Do

  • no default-on tools
  • no automatic task creation/closure
  • no reminders, wakes, or Cortex sync
  • no direct OpenClaw task mutation

How An Agent Uses It

  • A user asks "show me possible tasks from blockers" -> preview suggestions if tools are enabled.
  • A reviewer chooses to record a suggestion -> ledger row is created, not an OpenClaw task.
  • A reviewer rejects or dismisses -> only suggestion review state changes.

Engineering Boundaries

  • LCM is an evidence layer. It does not become Cortex, GBrain, OpenClaw Tasks, or a fuzzy semantic authority.
  • Recaps and observed states are entry points for investigation, not proof of exact commands, SHAs, paths, timestamps, root cause, or task completion.
  • Exact claims still require source drilldown through lcm_describe, lcm_expand, lcm_expand_query, raw messages, GitHub, logs, tickets, or the relevant authority.
  • Source identifiers stay hidden by default unless a tool has an explicit includeSources or debug affordance.
  • Reads stay read-only. Writes happen through explicit storage, maintenance, extraction, or review-ledger paths for the slice that owns them.

Primary Review Files

  • src/tools/lcm-task-suggestion-tools.ts
  • src/plugin/index.ts
  • src/store/task-bridge-suggestion-store.ts
  • test/task-bridge-suggestion-store.test.ts

Size And Review Surface

These are intentionally large LCM changes, so the body separates the GitHub-visible diff from the intended logical review slice. Later PRs target main, which makes the GitHub Files tab include parent-stack code; reviewers should use the logical parent listed above when judging the slice.

View Compare base Files Additions Deletions
GitHub-visible PR page main 34 10928 51
Intended reviewer slice #518 10 534 12

Logical slice breakdown:

Category Files Additions Deletions
runtime code 5 352 8
tests 1 168 4
docs/release notes 3 7 0
metadata/package 1 7 0

Review Concerns Already Folded Into The Code

  • Fallback message timestamp scans keep mixed-format julianday() correctness and now use matching expression indexes for indexed range/order plans.
  • Tool registration is disabled by default.
  • Preview and record paths are separate.
  • Review actions mutate only the suggestion ledger.
  • Negative tests cover no task-table/API writes.

Validation Evidence

  • npm test -- --run test/task-bridge-suggestion-store.test.ts test/observed-work-store.test.ts
  • npm test
  • npm run build
  • git diff --check
  • GitHub test check: success

Suggested Maintainer Review Path

  1. Start with the Why Maintainers Should Care and How It Works sections.
  2. Use Primary Review Files for the logical slice; the GitHub Files tab can look much larger because the public PRs target main while the series is logically stacked.
  3. Check the non-goals before asking whether LCM should create tasks, close tasks, write Cortex memory, or make authoritative project claims.
  4. Review and merge in the order shown in the stack diagram. feat: implement LCM architecture follow-up (draft) #526 stays draft/reference unless maintainers explicitly choose a single large integration branch.

Copilot AI review requested due to automatic review settings April 29, 2026 09:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a disabled-by-default “task bridge” suggestion tool layer on top of the LCM observed-work and suggestion-ledger storage, plus the supporting temporal rollup/recall surfaces and documentation/config wiring needed to safely preview/record/review suggestions without external task mutation.

Changes:

  • Introduces observed-work density storage + lcm_work_density, and temporal rollups + lcm_recent (+ optional lcm_rollup_debug).
  • Adds opt-in lcm_task_suggestions (preview/record) and lcm_task_suggestion_review (review-state updates) gated by taskBridgeToolsEnabled / LCM_TASK_BRIDGE_TOOLS_ENABLED.
  • Wires migrations, engine accessors, plugin tool registration, tests, and skill/docs updates.

Reviewed changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
test/task-bridge-suggestion-store.test.ts Adds coverage for suggestion ledger + tool preview/record/review behavior and “no external task writes” contract.
test/plugin-prompt-hook.test.ts Updates prompt-hook expectations for revised recall-tool routing guidance.
test/observed-work-store.test.ts Adds tests for observed-work storage, source redaction, state tracking, and lcm_work_density behavior.
src/tools/lcm-work-density-tool.ts New lcm_work_density tool with period bounds, filtering, and source redaction.
src/tools/lcm-task-suggestions-tool.ts New opt-in suggestion preview/record tool + review tool wrapper.
src/tools/lcm-rollup-debug-tool.ts New operator-facing rollup inspection tool (config-gated).
src/tools/lcm-recent-tool.ts New lcm_recent temporal recall tool with rollup-first + bounded SQL fallback retrieval.
src/timezone-windows.ts Adds/extends timezone helpers used for deterministic day/window resolution.
src/store/task-bridge-suggestion-store.ts Implements inert suggestion ledger storage + review-state updates.
src/store/rollup-store.ts Implements rollup persistence/state/source APIs used by builder + tools.
src/store/observed-work-store.ts Implements observed-work items/sources/state and density query.
src/rollup-builder.ts Implements daily + weekly/monthly rollup building and provenance tracking.
src/plugin/index.ts Registers new tools and gates opt-in ones via config flags.
src/engine.ts Adds rollup/observed-work/suggestion stores + rollup maintenance integration and engine accessors.
src/db/migration.ts Adds migrations for rollups, observed-work tables, and suggestion ledger (+ indexes/views).
src/db/config.ts Adds rollupDebugEnabled and taskBridgeToolsEnabled config + env var wiring.
specs/lcm-temporal-memory-plan.md Documents the temporal-memory stack plan and rollout map.
specs/lcm-task-bridge-option-c-experimental.md Documents Option C task-bridge goals/guardrails and ledger schema/tool surface.
specs/lcm-observed-work-density-option-b.md Documents Option B observed-work density model and tool contract.
skills/lossless-claw/references/recall-tools.md Updates recall-tool guidance to include availability-gated lcm_recent / debug usage and proof-safety.
skills/lossless-claw/SKILL.md Updates skill overview and operating guidance for temporal recall + proof workflow.
openclaw.plugin.json Exposes new config keys for rollup debug and task bridge tools.
docs/configuration.md Documents new config flags and corresponding env vars.
README.md Adds env var documentation for rollup debug enablement.
.changeset/lcm-temporal-skill-docs.md Changeset for documentation/skill guidance updates.
.changeset/lcm-temporal-rollups.md Changeset for temporal rollups + lcm_recent / debug tools.
.changeset/lcm-task-suggestion-tools.md Changeset for opt-in suggestion tools.
.changeset/lcm-task-bridge-suggestions.md Changeset for inert suggestion ledger storage.
.changeset/lcm-observed-work-density.md Changeset for observed-work density model + tool.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/store/task-bridge-suggestion-store.ts
Comment thread src/tools/lcm-task-suggestions-tool.ts Outdated
Comment thread src/tools/lcm-work-density-tool.ts
Comment thread src/store/observed-work-store.ts Outdated
Comment thread README.md
Comment thread src/store/task-bridge-suggestion-store.ts Outdated
@100yenadmin

Copy link
Copy Markdown
Collaborator Author

Review-thread triage at current head 7206b9c:

  • Fixed: suggestion upsert preserves existing task_id when the caller omits taskId.
  • Fixed: reviewSuggestion() preserves existing reviewed_by when the reviewer is omitted.
  • Fixed: task suggestion topic schema now says exact topic_key filter, matching implementation.
  • Fixed/inherited: allConversations=true is rejected by lcm_work_density, and density queries are bounded with SQL limits.
  • Fixed: README documents LCM_TASK_BRIDGE_TOOLS_ENABLED.

Local focused gates passed: test/task-bridge-suggestion-store.test.ts, test/plugin-config-registration.test.ts, test/rollup-store-builder.test.ts, npm run build, and git diff --check. GitHub CI was restarted for 7206b9c.

@100yenadmin

Copy link
Copy Markdown
Collaborator Author

Final adversarial pass - merge order 6/10, after #518

Score: mergeability 9.4/10, functionality 8.7/10, description 9.5/10.

Functionality audit: Works as opt-in task-suggestion preview/review tooling. Tools are behind taskBridgeToolsEnabled, reject all-conversation scans, hide source IDs by default, never write external task tables/APIs, and now report preserved reviewed suggestions separately instead of overcounting writes.

Scenario coverage: Supports “should we create tasks from unfinished things?” as preview/ledger review only. It does not create or close tasks.

Final state: MERGEABLE, GitHub test pass, GraphQL review threads: 0 unresolved. Local focused suite, full npm test, npm run build, and git diff --check passed on head 07213f8.

Residual caveat: Must stay opt-in; no external task authority.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 34 out of 34 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/tools/lcm-task-suggestions-tool.ts
Comment thread src/tools/lcm-task-suggestions-tool.ts Outdated
Comment thread src/db/migration.ts
Comment thread src/store/task-bridge-suggestion-store.ts
Comment thread src/tools/lcm-task-suggestions-tool.ts
@100yenadmin

Copy link
Copy Markdown
Collaborator Author

Final May 1 hardening/status update:

  • Merge order: 6/10 — Opt-in task suggestion tools
  • Head: 4b16458
  • Review state: 0 unresolved GraphQL review threads after the latest push
  • GitHub state: MERGEABLE / CLEAN, test check green
  • Validation: 57 focused tests; build; diff-check
  • Score: Functionality 10/10, mergeability 10/10, description 10/10
  • Note: Ready after feat: add experimental LCM task bridge suggestions (3/10) #518. Tools stay disabled by default and ledger-only; preview does not write, record/review writes only LCM suggestion rows.

The PR description top note has been refreshed with current head SHA, visible-vs-logical LOC breakdown, scope, caveats, and validation status. LCM remains an evidence layer: recaps, observed work, events, episodes, and suggestions are entry points, not proof or task authority.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 35 out of 35 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +283 to +287
const reviewedBy = input.reviewedBy?.trim() || null;
const result = this.db.prepare(
`UPDATE lcm_task_bridge_suggestions
SET status = ?,
reviewed_by = COALESCE(?, reviewed_by),
Comment on lines +242 to +246
accounting.maxOutputTokens = budget;
accounting.itemsReturned = countReturnedItems(next);
accounting.budgetTruncated = budgetTruncated;
accounting.truncated = Boolean(accounting.truncated) || budgetTruncated;
next.accounting = accounting;
description: "Reserved for a future bounded admin mode; currently rejected so density reads stay conversation-scoped.",
})
),
period: Type.Optional(Type.String({ description: 'Observed work period: "today", "yesterday", "7d", "30d", "week", "month", or "date:YYYY-MM-DD". Explicit since/before wins when provided.' })),

const LcmTaskSuggestionsSchema = Type.Object({
conversationId: Type.Optional(Type.Number({ description: "Conversation ID to inspect. Defaults to the current session conversation." })),
allConversations: Type.Optional(Type.Boolean({ description: "Explicitly inspect all conversations. Defaults to false." })),
@100yenadmin 100yenadmin changed the title feat: add opt-in LCM task suggestion tools feat: add opt-in LCM task suggestion tools (6/10) May 3, 2026
@100yenadmin 100yenadmin closed this May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants