Repository navigation
fix(memory-wiki): reject out-of-range claim confidence at the mutation boundary - #125656
Conversation
…n boundary The top-level mutation confidence is strictly clamped to [0, 1], but nested claims[].confidence passed through with only a finite-number check, so a value like 999 was persisted into page frontmatter and skewed wiki_search ranking (score += Math.round(confidence * 10)) for every later query. Fail closed with the same range contract as the top-level field.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: blocked before merge. Reviewed September 3, 2026, 7:17 AM ET / 11:17 UTC. ClawSweeper reviewWhat this changesThis PR rejects numeric nested Memory Wiki claim-confidence values outside 0–1 before a wiki mutation can persist them. Merge readiness⛔ Blocked before merge - 5 items remain Keep open: the range guard is a sound owner-boundary repair, but the branch conflicts with current main and still describes rejection as clamping. Rebase the guard onto the current mutation normalizer without undoing validation-before-sync ordering. Priority: P2 Review scores
Verification
How this fits togetherMemory Wiki validates agent mutation requests before writing claims into vault-page frontmatter. Wiki search later reads those claims and uses confidence as part of result ranking. flowchart LR
A[Agent wiki_apply request] --> B[Mutation validation]
B --> C[Claim normalization]
C --> D[Vault page frontmatter]
D --> E[Wiki search]
E --> F[Ranked results]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +22, Tests +30. Total +52 across 2 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Rebase the narrow range guard into the current mutation normalizer, retain current validation-before-source-sync behavior, and correct the comment to say values are rejected rather than clamped. Do we have a high-confidence way to reproduce the issue? Yes. The current shared claim normalizer retains finite values without a range check, and the query scorer directly converts confidence into ranking points; the PR body also supplies before/after terminal output against the real normalizer. Is this the best way to solve the issue? Yes, after rebase. Validating only on the mutation path protects future writes while leaving the shared frontmatter reader able to open legacy pages with out-of-range values. Full review comments:
Overall correctness: patch is correct AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f5673e904299. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
# Conflicts: # extensions/memory-wiki/src/apply.ts
|
Thanks @wanyongstar! Proof: An authenticated
Landed as c1a24b7fa9b7dfc818c37c361bad422e010731b5 from source 067d61afbc4b3deb74e8fbbb9cffe487423f6177. |
* commit '13b1f71c7010baaf2394555198e2fc04bef03586': (283 commits) fix(ui): retire stale MCP feedback across context changes (#128490) fix(agents): clarify set-identity workspace output (#126320) fix(auth): preserve OAuth metadata during session SDK refresh (#127988) fix(agents): recover catalog worker after generation mismatch (#127712) fix(memory-wiki): reject out-of-range claim confidence (#125656) ci: remove redundant contract runs and costly test work (#137220) fix(release): assert the Codex CLI pin the candidate declares (#137136) test(voice-call): reuse shared guards and deferred gates (#137262) fix(cron): isolate scheduler-disabled shared-store writes (#131733) fix(telegram): surface allowed custom reactions in react guidance (#129817) test(infra): reuse the shared npm call presence guard (#137254) fix: generated images disappear after failed tool calls (#131226) fix(docs): match source anchor checks to published sections (#137157) fix(backup): preserve audit capture across slow snapshots (#130962) fix(release): preserve legacy gh log reads (#137016) fix(memory-core): make forget rewrites atomic (#131383) fix(agents): write settings atomically (#131431) fix(plugins): keep the memory indexing runtime with the selected slot owner (#131779) fix(ci): pin iOS screenshot evidence to workflow revision (#136334) test(logging): remove redundant stderr spy casts (#137238) ... # Conflicts: # scripts/e2e/lib/codex-release-package-assertions.mjs
## Summary - Reject new `claims[].confidence` values outside `0..1` at the shared Memory Wiki mutation validator. - Keep legacy or hand-written pages readable by leaving the Markdown read normalizer tolerant. - Preserve validation before source synchronization and vault writes for both tool and Gateway mutations. ## What Problem This Solves `wiki_apply` declared claim confidence as a `0..1` value, but its runtime mutation validator accepted every finite number. The write path persisted values such as `999`, and claim ranking later added `confidence * 10` to the score. ## Root cause `normalizeMemoryWikiMutationInput` reused the tolerant frontmatter reader for untrusted mutations without enforcing the mutation schema's confidence range. ## Fix Normalize claims once at the canonical mutation boundary, then reject an out-of-range claim confidence before either caller can synchronize sources or write the vault. The read path remains unchanged for existing data. ## Evidence - Baseline `af8828dded4761a9d4c31bf7f6434f13e78e0289`: an authenticated client called the shipped `wiki.apply` Gateway route with claim confidence `999`; the route accepted it and created the page. - Head `067d61afbc4b3deb74e8fbbb9cffe487423f6177`: the same Gateway call rejects `999` with the range error and creates no page. - Direct `wiki_apply` tool mutation proof also rejects `999` and `-0.5` before creating a page; `0.8` still persists. - Compatibility: a manually stored legacy claim with confidence `999` remains readable through `wiki_search`. ## Validation - `node scripts/run-vitest.mjs extensions/memory-wiki/src/tool.test.ts --testNamePattern 'keeps wiki pages unchanged for out-of-range claim confidence'` - `node scripts/run-vitest.mjs extensions/memory-wiki/src/apply.test.ts extensions/memory-wiki/src/tool.test.ts extensions/memory-wiki/src/gateway.test.ts` - `OPENCLAW_E2E_SKIP_BUILD=1 PROOF_EXPECT=<accepted|rejected> vitest run --config test/vitest/vitest.e2e.config.ts memory-wiki-confidence.product-proof.e2e.test.ts` - `node scripts/run-oxlint.mjs --deny-warnings extensions/memory-wiki/src/apply.ts extensions/memory-wiki/src/tool.test.ts` - `oxfmt --check extensions/memory-wiki/src/apply.ts extensions/memory-wiki/src/tool.test.ts` Production LOC: +17/-2. Tests: +18/-0. Co-authored-by: Ayaan Zaidi <[email protected]>
Summary
claims[].confidencevalues outside0..1at the shared Memory Wiki mutation validator.What Problem This Solves
wiki_applydeclared claim confidence as a0..1value, but its runtime mutation validator accepted every finite number. The write path persisted values such as999, and claim ranking later addedconfidence * 10to the score.Root cause
normalizeMemoryWikiMutationInputreused the tolerant frontmatter reader for untrusted mutations without enforcing the mutation schema's confidence range.Fix
Normalize claims once at the canonical mutation boundary, then reject an out-of-range claim confidence before either caller can synchronize sources or write the vault. The read path remains unchanged for existing data.
Evidence
88be1b80f58df698fe730b4f3f34934ecae92e21: an authenticated client called the shippedwiki.applyGateway route with claim confidence999; the route accepted it and created the page.067d61afbc4b3deb74e8fbbb9cffe487423f6177: the same Gateway call rejects999with the range error and creates no page.wiki_applytool mutation proof also rejects999and-0.5before creating a page;0.8still persists.999remains readable throughwiki_search.Validation
node scripts/run-vitest.mjs extensions/memory-wiki/src/tool.test.ts --testNamePattern 'keeps wiki pages unchanged for out-of-range claim confidence'node scripts/run-vitest.mjs extensions/memory-wiki/src/apply.test.ts extensions/memory-wiki/src/tool.test.ts extensions/memory-wiki/src/gateway.test.tsOPENCLAW_E2E_SKIP_BUILD=1 PROOF_EXPECT=<accepted|rejected> vitest run --config test/vitest/vitest.e2e.config.ts memory-wiki-confidence.product-proof.e2e.test.tsnode scripts/run-oxlint.mjs --deny-warnings extensions/memory-wiki/src/apply.ts extensions/memory-wiki/src/tool.test.tsoxfmt --check extensions/memory-wiki/src/apply.ts extensions/memory-wiki/src/tool.test.tsProduction LOC: +17/-2. Tests: +18/-0.