fix(ctx_memory): honor category in update - #438
Conversation
|
Fixed the Greptile P1 on Duplicate detection now uses the row's actual stored Added two regression tests for the legacy raw-path case (duplicate rejected; recategorize succeeds when no same-content row exists). |
There was a problem hiding this comment.
Thanks, G0-0000, for implementing category retargeting and for the follow-up that aligns the legacy raw-path duplicate lookup with the stored uniqueness key. The main update behavior, the mutation-log category, the targeted ctx-memory suite, the full plugin suite, typecheck, and the light-preset budget (1822/1825) all check out on your current head merged onto master.
Three merge blockers, each from an executed probe:
-
Please move the target-category duplicate lookup inside the same
BEGIN IMMEDIATEtransaction as the update/log write, and keep a friendly unique-constraint fallback. A race probe currently rejects with the rawUNIQUE constraint failed: memories.project_path, memories.category, memories.normalized_hash. The same hole applies to legacy rows stored under a rawproject_path(the lookup uses the normalized identity while the row keeps the raw path), which greptile also flagged. -
Please make
<memory-updates>carry the new category. The log recordsCONSTRAINTS, but aCONFIG_VALUES → CONSTRAINTSprobe renders only<updated id="1">new category fact</updated>, so an agent reading the delta never learns the memory moved. We will carry the Pi and Rust renderer twins on our side after merge. -
Please rerun
export-agent-surface.tsand commit its complete output: the golden heading still says ctx_memory params~201/ total~435, while the generator emits~216/~450.
Hygiene: the branch now has two commits authored g0 <g0@localhost> with no trailer. We squash-merge, so this is not blocking; add your intended identity if you want it on the merge commit.
Once these land we run one more adversarial review pass on the PR and merge. Thanks again — the scoped implementation is close.
…llback, category in memory-updates
|
Addressing the three merge blockers:
Hygiene: squash-merge is fine as-is. Identity remains Landed on |
There was a problem hiding this comment.
All reported issues were addressed across 8 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
|
Addressed the three cubic-dev-ai notes on 60956fd:
Gates: |
There was a problem hiding this comment.
All reported issues were addressed across 5 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
|
Layered unique-constraint detection: exact |
Co-authored-by: Alfonso <alfonso-magic-context@users.noreply.github.com>
Fixes #436
Summary
ctx_memoryupdateacceptedcategoryin the tool schema but never wrote it. The UPDATE statement only setcontent/normalized_hash/updated_at, and three follow-up sites still used the stored category.Root cause:
updateMemoryContentInCurrentTransactionnever received a target category, so duplicate hashing,queueMemoryMutation, and the success echo all stayed onmemory.category.Fix (TS path):
PROJECT_RULES/ARCHITECTURE/CONSTRAINTS/CONFIG_VALUES/NAMING) retargets the row.Updated memory [ID: …] in ${…}all use the target category.updatemay recategorize; omit to keep.Tests
Four new cases in
packages/plugin/src/tools/ctx-memory/tools.test.ts:Local gates:
bun run typecheckpassedbun run lintpassed (pre-existing pi-plugin warning only)bun run buildpassedpackages/pluginctx-memorysuite: 76/76 passedScope
TypeScript
packages/pluginpath only. WhenauthorityState === "MODULE",updatestill delegates to the private Rust module; that path is unchanged and should be followed up separately for parity.Prompt-surface A1 golden and
docs/specs/prompt-surface/budget-fixture.jsonwere updated only because the category parameter description changed (serialized schema 840/201 → 912/216 tokens).Live validation
Against pi-magic-context 0.41.4 with the same semantics locally:
update→ persisted category changesupdate→ content rewrittenResidual / Note
Local full
bun run test(plugin--parallel --timeout 30000, same as CIcheck-plugin) twice hit two unrelated timeouts under parallel load:AFT warm inventory sends only boundary-owned seeds with one raw batch(~43s vs 7.8s alone)createTransform > hydrates only dropped rows for visible-target replay with 98% active tags(~37s vs 11.9s alone)This change does not touch those tests. Isolated reruns passed. typecheck / lint / build and the ctx-memory 76/76 suite all passed.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by cubic
Makes
ctx_memoryupdatehonor thecategoryargument so a valid v2 category recategorizes the row, and surfaces that category in memory-updates deltas.<updated>elements carry acategoryattribute in the TypeScript, pi-plugin, and Rust renderers.updatemay recategorize; omitcategoryto keep the current one.Written for commit b8a8648. Summary will update on new commits.
Greptile Summary
This PR makes TypeScript
ctx_memory updatepersist valid category changes and consistently use the resulting category for duplicate detection, mutation logging, rendering, and the success response.Confidence Score: 5/5
The PR appears safe to merge; no actionable regression remains in the changes since the previous review.
The previously reported legacy-path duplicate failure and adapter-specific uniqueness fallback findings are resolved, and the latest fallback recognizes remapped or absent SQLite codes without swallowing unrelated current transaction errors.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[ctx_memory update] --> B[Load active memory] B --> C{Valid v2 category supplied?} C -->|Yes| D[Use supplied category] C -->|No| E[Keep stored category] D --> F[BEGIN IMMEDIATE] E --> F F --> G{Duplicate on stored path/category/hash?} G -->|Yes| H[Return friendly duplicate error] G -->|No| I[Update content, category, and hash] I --> J[Queue categorized mutation] J --> K[Commit] K --> L[Render updated element with category]Reviews (5): Last reviewed commit: "fix(ctx_memory): recognize constraint er..." | Re-trigger Greptile