Repository navigation
Return use guidance with retrieved knowledge - #1510
krishnadobhal wants to merge 144 commits into
Conversation
Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com>
Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com>
Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com>
cd4010a to
e78e001
Compare
Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com>
Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com>
zlareb1
left a comment
There was a problem hiding this comment.
The current head drops eligible historical results from continuation pages and can give search and file recall different review states for the same attested content. The inline findings cover these regressions and other read and client paths. The existing source-freshness thread also still applies. Source freshness discussion
Verified against the exact head by tracing the read paths and checking the existing regression assertions. Full integration results are pending.
… content Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com>
|
plz fix merge conflicts |
zlareb1
left a comment
There was a problem hiding this comment.
The current head returns expired facts on as_of continuation pages. The history lookup failure and Postgres history metadata also need changes before this can merge.
Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com>
Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com>
zlareb1
left a comment
There was a problem hiding this comment.
The head fixes the live-row expiry check. An edited historical revision can still pass after its own expiry, and memory.touch skips the expiry mirror for rows written before content hashes. Both cases were reproduced against this head.
The format job also fails on docs/features/memory/history-and-provenance.md. Format job
|
The tunable-constant check reports the same five constants on this PR and on clean main. The check passes with the tracked repair. Failed job · Repair #1503 |
zlareb1
left a comment
There was a problem hiding this comment.
Both stack queries now exclude ended validity intervals, and foreign ranked previews use their own conflict status. All 18 focused stack and analyzer tests passed. The dashboard adds a regression for a local conflict and a foreign result with the same key.
zlareb1
left a comment
There was a problem hiding this comment.
GitHub reports conflicts with main in sdk/go/wire/models.gen.go and tests/analyzer/shapes.txt. Reconcile the combined wire schema and regenerate the model and analyzer corpus.
Regenerate sdk/go/wire/models.gen.go with sdk_go_gen.py and tests/analyzer/shapes.txt with tests.analyzer.corpus --write, taking upstream's copies of both first. The shapes regeneration ran without a ClickHouse server; --check was not run. Signed-off-by: Krishna Dobhal <krishnadobhal234@gmail.com>
|
Merged upstream/main (b84b355) into this branch in a44e835. Two generated files conflicted: sdk/go/wire/models.gen.go and tests/analyzer/shapes.txt. I took upstream's copy of each and regenerated it. The Go wire file now matches sdk_go_gen.py --check. The analyzer shapes file came from tests.analyzer.corpus --write, which ran without a ClickHouse server, so the EXPLAIN check was not run. |
zlareb1
left a comment
There was a problem hiding this comment.
The combined Go models and analyzer corpus match their generators. All 66 focused guidance, stack, and analyzer tests passed. GitHub reports a new conflict in the generated Go and Rust wire models. Reconcile the schema with main and regenerate both models.
Take upstream's generated Go and Rust wire models and regenerate them with sdk_go_gen.py and sdk_rust_gen.py so they match the merged operation registry. Signed-off-by: Krishna Dobhal <krishnadobhal234@gmail.com>
|
Merged upstream/main (3251ba1) into this branch in 7c39cdd. The only conflicts were the generated wire models, sdk/go/wire/models.gen.go and sdk/rust/src/wire_models.rs. Both took upstream's copy and were regenerated with scripts/codegen/sdk_go_gen.py and scripts/codegen/sdk_rust_gen.py, so they match the merged operation registry. The generated Go client and Rust operation files changed with them. The schema source had no conflict. Every codegen --check passes. |
Signed-off-by: Krishna Dobhal <krishnadobhal234@gmail.com>
zlareb1
left a comment
There was a problem hiding this comment.
The same-key shortcut leaves a ranked hit in preview even when its revision identifies one keyword row. GitHub reports conflicts with main in the context pack, the for-file handler, and the evidence pack.
|
Merged upstream/main twice: 3b0af47 (upstream #2026, which conflicted) and 959dc4d (up to #2030, no conflicts). #2026 conflicted in server/memory/app/context_pack.py, server/memory/app/for_file.py and server/memory/domain/evidence_pack.py. I took its label changes ( In The focused unit tests, ruff, mypy and all codegen |
…guidance Signed-off-by: Krishna Dobhal <krishnadobhal234@gmail.com>
959dc4d to
33b581b
Compare
| # does not attest the shared copy and may not be readable here. | ||
| evidence[i] = {"status": "active", "source_class": hits[i].source_class} | ||
| return denied, evidence | ||
|
|
There was a problem hiding this comment.
Shared parked hits skip validity checks
Medium Severity
_shared_evidence treats a shared parked hit as authorized when the live version number still matches. It does not apply the expiry, valid_to, or content-hash checks that _memory_evidence uses before serving a parked fact. An expired, ended, or same-version replacement of a shared row can therefore stay on a parked page and keep its body, instead of being dropped or stripped of inherited guidance.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 33b581b. Configure here.
There was a problem hiding this comment.
Fixed in a5b30e1. _shared_evidence now uses the same expiry check (_current) and the same served-body check (_digest_diverges) as _memory_evidence. The shared head reads the body and hashes it as the promotion source does. Tests cover an expired row, an ended valid_to and a same-version body change, on both a fresh and a parked page.
There was a problem hiding this comment.
Fixed in 9e9d84f. The shared lookup now records the served digest on the live pass, so a parked shared hit comes back with it and a same-version replacement is dropped. The test now gets its digest from a real live pass and a page round trip.
I dropped the expiry and valid_to cases: loom.shared has neither column, so they only passed because the test put them in the head.
…ld at two revisions merges into the row at the hit's revision Signed-off-by: Krishna Dobhal <krishnadobhal234@gmail.com>
… and holds the body it served Signed-off-by: Krishna Dobhal <krishnadobhal234@gmail.com>
…a same-version replacement is caught Signed-off-by: Krishna Dobhal <krishnadobhal234@gmail.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
There are 23 total unresolved issues (including 21 from previous reviews).
Reviewed by Cursor Bugbot for commit 9e9d84f. Configure here.
| hash_text(row.get("content_sha256")), _served_digest(hits[i], parked) | ||
| ) | ||
| ): | ||
| denied.add(i) |
There was a problem hiding this comment.
Shared digest mismatch drops live hits
Medium Severity
_shared_evidence treats any body-hash mismatch as an immediate deny, before it checks whether the head is still that hit’s revision. _memory_evidence only uses _digest_diverges after the version or body already matched, so a newer head with different content still serves the live hit without that head’s review. A re-promoted shared row can therefore vanish from live search while a private memory in the same situation stays visible.
Reviewed by Cursor Bugbot for commit 9e9d84f. Configure here.
There was a problem hiding this comment.
Fixed in b482833. _shared_evidence now shares _head_holds_hit with _memory_evidence: the digest check applies only when the head is the served revision, so a newer head with other content keeps a live hit served without that head's guidance. A parked page still drops it, as it does for a private row.
| "content_sha256": sha256_value(served_row_value(r)), | ||
| } | ||
| for r in rows | ||
| } |
There was a problem hiding this comment.
Falsy shared values fail digest check
Medium Severity
guidance_heads hashes shared rows with served_row_value, which returns None for any falsy value ({}, [], "", 0, false) because those rows have no value_json. Embeddings store sha256_value of the real body, so the new _digest_diverges check treats those hits as replaced and omits them from search even when the promoted row is unchanged.
Reviewed by Cursor Bugbot for commit 9e9d84f. Configure here.
There was a problem hiding this comment.
No change needed. shared.value is a String column that always holds json.dumps of the promoted value, and served_row_value parses that text, so {}, [], "", 0 and false hash to the same digest the embedding stores. A new test in b482833 covers all five and passes on the existing code.
zlareb1
left a comment
There was a problem hiding this comment.
Recall Lab now matches a ranked hit to the keyword row at its exact writer and revision. The Memories list still gives a same-key preview another writer’s conflict badge.
…head holds other content A shared hit follows the private-row order: the digest check applies only when the head is the served revision. Signed-off-by: Krishna Dobhal <krishnadobhal234@gmail.com>
…espace The badge now matches the Conflicted filter, so another writer's conflict on the same key does not mark it. Signed-off-by: Krishna Dobhal <krishnadobhal234@gmail.com>
zlareb1
left a comment
There was a problem hiding this comment.
Ranked previews use their own conflict status, and parked shared hits keep evidence only for the body served. On the merge tree, 57 dashboard and 254 Python tests pass.
zlareb1
left a comment
There was a problem hiding this comment.
GitHub reports a merge conflict with main in the generated Go and Rust wire models and tests/analyzer/shapes.txt. Reconcile the wire changes and regenerate the models and statement shapes so CI can test the combined tree.
…guidance Signed-off-by: Krishna Dobhal <krishnadobhal234@gmail.com> # Conflicts: # sdk/go/wire/models.gen.go # sdk/rust/src/wire_models.rs # tests/analyzer/shapes.txt
|
Merged upstream The generators' |


Closes: #1230
Changelog category
Changelog entry
Loom suggests how to use retrieved memories, documents, procedures, and code lessons. Dashboard search shows the suggested step and the reasons behind it.
Why
A relevant result can still be out of date, disputed, or waiting for review. Loom now uses the lifecycle, review, freshness, and dispute evidence available to the caller to recommend what to do with the result.
Scope and risk
Search checks the current revision and caller access before serving parked hits. A replacement with the same version and different content cannot inherit the parked hit’s guidance. Older cursors without a content hash cannot inherit review approval.
If search replaces a hit’s text with a source passage, it drops the original guidance. An expanded memory body keeps guidance only when its version and content hash match.
memory.verifynow mirrors the exact attestation version to embeddings that still match the reviewed content. The mirror runs asynchronously, and search still requires matching revisions before attaching review evidence.Postgres-backed stacks check the authoritative head before serving pinned or recent entries from ClickHouse. File recall, code lessons, and stacks account for procedure status, including quarantine.
Source freshness respects caller access. A readable citation without a recorded source revision stays
unknown. Context packs attach guidance to the citations they render.Guidance on a code lesson is positive only when its memory-code link was checked at the repository's checked head, or covered by a recheck pass. A link checked at an older commit counts only when that commit is an ancestor of the checked head, so a branch rewind or force push reads
unknown. Each request checks at most 8 distinct commits, 4 at a time, within 0.1 seconds. Search keeps its own 0.2 second limit. A commit over the cap or past the deadline readsunknown, and only memories that could still earn positive guidance spend a check.After the checked head moves, guidance on links the pass has not yet covered reads
unknownuntil the next recheck pass covers them.The dashboard treats each memory as a writer-scoped revision. Search, list and Recall Lab resolve the agent, user, session and namespace before opening a memory, and the inspector rejects a namesake returned by
memory.get.memory.listreportsrows_readfor paging, and the dashboard list requests 14 fields, withversion_textreplacing the numericversion.Compatibility, rollout and rollback
memory.search,memory.for_file,knowledge.search,procedure.match, andmemory.stackadd optionaluse_guidance.search.querytypes its memory and knowledge sections and preserves guidance in compact MCP responses. Reader blocks can include the suggested step.context.packreturns guidance keyed by section, citation, and item index. Code lessons add optional guidance incode.callees,code.callers,code.context_pack,code.enclosing,code.grep,code.impact,code.outline,code.read,code.search, andcode.symbol.CodeLessonrows in the Python and TypeScript SDKs. In Python, passdict(row)to helpers that requiredict[str, Any], or change read-only helpers to acceptMapping[str, Any]. In TypeScript, userow[key]with a key typed askeyof CodeLesson. For an arbitrary string key, copy the row intoconst fields: Record<string, unknown> = { ...row }, then narrowfields[key]before using it. Rust lesson rows remain maps.118_memory_code_link_covered.sqladdsmemory_code_links.covered(UInt8, default 0). It needs no operator step and adds no setting. Existing rows start uncovered, and the next recheck pass covers them. During a rolling upgrade, a previous-build writer inserts links without the column and without the repository's recheck lease. Guidance on those links readsunknownuntil a pass covers them (rolling upgrades).coveredcolumn can stay; older builds ignore it.Tests
mypy --stricton the Python SDK and every codegen--checkscript. The Python tests ran in WSL.test_no_new_tunable_constantfails on a constant inserver/code/domain/index/test_gate.py, a file this PR does not touch. The sender-census test fails only because of CRLF line endings in the Windows checkout. CI covers both.AI assistance in the code
Checklist
Note
Medium Risk
Changes how memories are opened and trusted in the UI (exact writer/revision matching); incorrect resolution could block opens or show wrong rows, while the
coveredlink flag affects guidance correctness during rolling upgrades.Overview
This PR documents and surfaces
use_guidanceon maintained search and context results: docs define the next-step rules (inspect, recheck, review, validate, follow), and the dashboard shows suggested use in header search, Recall Lab, and the “Why this result” popover viaGuidanceLabel.Writer-exact memory opening is the other major theme: search hits that lack a full agent / user / session /
version_textidentity are resolved withmemory.listprefix paging (rows_read, namespace version stability) or stay preview-only;MemoryInspectorwithverifyWriterrejectsmemory.getnamesakes. Navigation history keepsinspectedScope(namespace + exact flag) for reload/Back.Ops/docs add memory–code link
coveredsemantics for recheck passes and rolling upgrades (migration120_memory_code_link_covered.sql). API reference types are tightened (CodeLesson,SearchSection,ContextUseGuidance,rows_read). The frontend splits lazy API helpers (memoryReads.ts, admin grants) and addsdeleteMemoryVersion; e2e mocks gainversion_textand writer fields.Reviewed by Cursor Bugbot for commit 788cece. Bugbot is set up for automated code reviews on this repo. Configure here.