Skip to content

feat(memory): ICM slice 2 — feedback record/search/stats#579

Merged
NagyVikt merged 1 commit into
mainfrom
agent/claude/icm-feedback-slice-2
May 18, 2026
Merged

feat(memory): ICM slice 2 — feedback record/search/stats#579
NagyVikt merged 1 commit into
mainfrom
agent/claude/icm-feedback-slice-2

Conversation

@NagyVikt
Copy link
Copy Markdown
Collaborator

Summary

ICM slice 2 (see docs/icm-integration-plan.md) — adds a cross-agent "AI predicted X, real answer was Y" feedback lane so a future agent can search prior corrections by topic before repeating a known mistake. Mirrors the observation surface: feedback_record (compressed write), feedback_search (compact FTS5 hits), feedback_stats (per-topic counts).

  • Storage — migration 015 introduces feedback + a porter-unicode61 feedback_fts virtual table with the standard ai/ad/au triggers, plus indexes on topic and created_at. Importance is a four-level CHECK enum (critical|high|medium|low, default medium).
  • CoreMemoryStore.recordFeedback routes prediction/correction/context through the same prepareMemoryText pipeline observations use, so the compression invariant holds at the write boundary. getFeedback honors settings.compression.expandForModel (and an explicit expand opt).
  • MCP — three new tools wrap the facade with progressive-disclosure return shapes. docs/mcp.md documents the contract.

Verification

Run from this worktree:

  • pnpm --filter @colony/storage typecheck — pass
  • pnpm --filter @colony/storage test — pass (174/174, including new feedback.test.ts)
  • pnpm --filter @colony/core typecheck — pass
  • pnpm --filter @colony/core test — 254/255; the one failure (test/savings-reference.test.ts > does not attribute structured-output savings_report calls to the at-rest compression row) is pre-existing on main — reproduces with my changes stashed.
  • pnpm --filter @colony/mcp-server typecheck — pass
  • pnpm --filter @colony/mcp-server test — pass (302/302, including new feedback.test.ts and the updated server.test.ts tool-list expectation)
  • pnpm exec biome check on touched files — clean; the lone diagnostic that remains is the pre-existing packages/storage/src/storage.ts::mcpMetricsMinTs formatter quirk that is unrelated to this change.

Test plan

  • CI green across all packages
  • Spot-check the new tools through the MCP inspector once merged
  • Verify migration 015 applies forward-only against an existing dev DB

Follow-up (out of scope)

  • Pre-tool-use hook that auto-surfaces prior corrections on inbound prompts. Tracking that as a separate PR so this slice can ship behind a manual query surface first.

References

  • docs/icm-integration-plan.md — slice 2 spec (not authored in this PR; this implements it as written).

Adds the cross-agent "AI predicted X, real answer was Y" feedback lane
specified in docs/icm-integration-plan.md slice 2 so a future agent can
search prior corrections by topic before repeating a known mistake.

- packages/storage migration 015 introduces `feedback` + a porter-
  unicode61 `feedback_fts` virtual table with the standard ai/ad/au
  triggers, plus indexes on `topic` and `created_at`. Importance is a
  four-level CHECK enum defaulting to `medium`.
- packages/core MemoryStore exposes `recordFeedback`, `searchFeedback`,
  `getFeedback`, and `feedbackStats`. All three prose fields
  (prediction/correction/context) route through `prepareMemoryText`,
  the same redact-then-compress path observations use, so the
  compression invariant holds at the write boundary.
- apps/mcp-server registers `feedback_record`, `feedback_search`, and
  `feedback_stats` with progressive-disclosure return shapes (id,
  topic, importance, FTS5 score, snippet, created_at). docs/mcp.md
  carries the contract.

Follow-up out of scope here: a pre-tool-use hook that auto-surfaces
prior corrections on inbound prompts. Tracking separately so this
slice can ship behind a manual query surface first.
@NagyVikt NagyVikt merged commit 7dcece2 into main May 18, 2026
2 of 4 checks passed
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.

1 participant