Repository navigation
Return use guidance with retrieved knowledge - #1510
krishnadobhal wants to merge 171 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 |
|
Merged upstream/main into this branch (d41d0d7). The migration is now 121_memory_code_link_covered.sql, because upstream took 120. Regenerated: the Go, Rust, Python, TypeScript and Ruby SDK wire and client files, the Rust fixtures, tests/analyzer/shapes.txt, and tests/unit/test_schema_baseline.py for the migration list. The sender pin for sdk/python/loom/memory.py is renewed for the merged file. schemas/schema.sql is left as staged; its only diff against the local dump comes from a ClickHouse version that is not the CI-pinned one. |
zlareb1
left a comment
There was a problem hiding this comment.
Migration 121 is free on main and the schema baseline names it. The Forward navigation finding still applies. Forward skips the thread when the history entry belongs to a different namespace, then strips the thread from the URL. Restore the conversation with its own namespace when reopening that entry.
GitHub reports merge conflicts in the generated Go and Rust wire models. Please resolve the conflicts against main and regenerate the models.
Signed-off-by: Krishna Dobhal <krishnadobhal234@gmail.com>
Signed-off-by: Krishna Dobhal <krishnadobhal234@gmail.com>
|
Merged upstream/main into this branch (e3a6953). The merge conflicted only in the two generated wire models, sdk/go/wire/models.gen.go and sdk/rust/src/wire_models.rs. Both were regenerated with scripts/codegen/sdk_go_gen.py and scripts/codegen/sdk_rust_gen.py in b6b6d4c, so the branch carries the regenerated output. No other generated output changed. All generator --check modes pass. |
Signed-off-by: Krishna Dobhal <krishnadobhal234@gmail.com>
Signed-off-by: Krishna Dobhal <krishnadobhal234@gmail.com>
|
@zlareb1 both threads from your last review are fixed and answered: the chunk excerpt in 0bf63ab and the placeholder-writer identity in d264ac3. Main has been merged in again. Could you approve the workflow runs for this fork, re-review, and merge once CI is green? Each upstream merge has needed regenerated files, so merging soon avoids another round of conflicts. |
zlareb1
left a comment
There was a problem hiding this comment.
The current head still loses a cross-namespace conversation on Forward navigation. Update the existing migration reference in the PR description to 121. The Go map interface is restored and the head combines cleanly with main.
| if hit.get("supersedes_key"): | ||
| lesson["supersedes_key"] = str(hit["supersedes_key"]) | ||
| guidance = hit.get("use_guidance") | ||
| if guidance and _guidance_matches_code(guidance, lesson["code_state"]): |
There was a problem hiding this comment.
P2 — A search on a non-trunk branch can return follow_if_applicable for a file lesson whose linked definition changed on that branch. The file lesson copies guidance checked against trunk, and code.search supplies no source revision for this path. Withhold positive guidance until the link is checked against the requested branch. Cover a fresh trunk link whose definition changed on a second branch.
There was a problem hiding this comment.
Fixed in 279e3a3. A search on a non-trunk branch now reads file lessons as unchecked, because their links were checked against trunk. The code state is unknown and no lesson gets follow_if_applicable. A test covers a lesson that is fresh on trunk and changed on a second branch: trunk follows it, the branch returns validate_lead.
| ): Promise<(MemoryListEntry & { namespace: string }) | null> { | ||
| // A chunk has no row of its own to list: its excerpt is the preview, with no writer, so | ||
| // nothing acts on it. | ||
| if (hit.memory_key.startsWith("chunk:")) |
There was a problem hiding this comment.
P2 — A writer can select this chunk preview through its checkbox or Select All in Recent. The preview has no writer or revision, so Pin and Delete count it as a failed action before sending a request. Exclude read-only chunk previews from the selection and extend the chunk-only search test to cover the controls.
There was a problem hiding this comment.
Fixed in c7eed4b. A chunk preview gets no checkbox and is left out of Select All, so Pin and Delete never count it. The chunk-only search test now checks both controls, and a second test checks Select All beside a writable hit.
| if identity is not None: | ||
| for name, value in zip(("agent", "user_id", "session_id"), identity, strict=True): | ||
| if name in data: | ||
| data[name] = value |
There was a problem hiding this comment.
P3 — The loom_search snapshot fails in summaries_served_short. All three memory hits now include user_id set to the placeholder writer, and the recorded response omits it. If the added field is the intended MCP contract, regenerate the fixture and verify the explicit writer tuple. Unit job
…inks File lessons copy guidance checked against trunk. A search on another branch now reads them as unchecked, so the code state is unknown and no lesson is followed on that evidence. Signed-off-by: Krishna Dobhal <krishnadobhal234@gmail.com>
A chunk preview has no writer or revision, so Pin and Delete could only fail on it. It gets no checkbox and no place in Select All. Signed-off-by: Krishna Dobhal <krishnadobhal234@gmail.com>
| ) | ||
| ): | ||
| kept.append(row | head | {"status_text": head["status"]}) | ||
| return kept |
There was a problem hiding this comment.
Live file rows dropped on lag
High Severity
current_file_rows keeps a ClickHouse row only when its version, id, and content hash equal the Postgres head, and it never substitutes that head. A newer live revision therefore disappears from memory.for_file and code lessons until ClickHouse catches up. If the dropped row superseded another, that older claim is left looking current.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit c7eed4b. Configure here.
There was a problem hiding this comment.
Not a bug as stated, so no code change; fb7d5fa pins it. A ClickHouse row behind its Postgres head carries the old text and links, so serving it under the newer revision would state a claim the head no longer holds. The row waits until ClickHouse catches up, and the older claim is not shown as current because the dropped row is never served in its place.
Generated wire models and shapes.txt keep this branch's side and are regenerated separately. Signed-off-by: Krishna Dobhal <krishnadobhal234@gmail.com>
| lesson["supersedes_key"] = str(hit["supersedes_key"]) | ||
| guidance = hit.get("use_guidance") | ||
| if guidance and _guidance_matches_code(guidance, lesson["code_state"]): | ||
| lesson["use_guidance"] = guidance |
There was a problem hiding this comment.
Branch lessons still look fresh
Medium Severity
A non-trunk search passes unchecked into listing_rows, which only forces guidance freshness to unknown. _lesson still copies the trunk link code_state, often fresh, and _guidance_matches_code keeps that pair because fresh is not demoted. The lesson says the code is fresh while use_guidance says it was not checked on this branch.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit f05692c. Configure here.
There was a problem hiding this comment.
Fixed in 659b851. A branch search now sets the lesson's code_state to unknown when the links were checked against trunk, and the test asserts both the state and the guidance.
Signed-off-by: Krishna Dobhal <krishnadobhal234@gmail.com>
|
This PR is too large for Bugbot to review. It changes 11,050 lines and 1,329,746 characters. Split the change into smaller pull requests to get a review. |
zlareb1
left a comment
There was a problem hiding this comment.
Browser Forward still drops the thread after opening a conversation in another namespace. The current base also has a migration numbered 121. Existing navigation finding
| @@ -0,0 +1,3 @@ | |||
| -- A link a recheck pass covered, or that a writer inserted under the repository's lease at | |||
There was a problem hiding this comment.
P2 — Main already contains 121_code_repo_base_namespace.sql. Merging this file with number 121 would fail test_migration_numbers_are_unique. Take the next free migration number, update the references, and regenerate the schema. Migration on main
Signed-off-by: Krishna Dobhal <krishnadobhal234@gmail.com>
Signed-off-by: Krishna Dobhal <krishnadobhal234@gmail.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
There are 27 total unresolved issues (including 26 from previous reviews).
Reviewed by Cursor Bugbot for commit fb7d5fa. Configure here.
| for lesson in out if unchecked else (): | ||
| # the links were checked against trunk: no code state of theirs describes this branch | ||
| if lesson["code_state"] not in code_change.DEMOTED: | ||
| lesson["code_state"] = "unknown" |
There was a problem hiding this comment.
Branch lessons keep trunk code facts
Medium Severity
On a non-trunk search, lessons whose links were checked only against trunk still keep changed, unresolved, and missing, and still carry code_moved, changed_since, and rev. Those fields describe trunk, not the requested branch. A moved lesson is marked unknown while its relocation list remains. unlinked and empty states, which are not trunk verdicts, are rewritten to unknown as well.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit fb7d5fa. Configure here.
Signed-off-by: Krishna Dobhal <krishnadobhal234@gmail.com>
…guidance Signed-off-by: Krishna Dobhal <krishnadobhal234@gmail.com> # Conflicts: # scripts/codegen/sdk_rust_gen.py # sdk/rust/src/wire_models.rs # server/memory/app/code_link_reads.py # tests/analyzer/shapes.txt # tests/unit/test_schema_baseline.py
Signed-off-by: Krishna Dobhal <krishnadobhal234@gmail.com>
Signed-off-by: Krishna Dobhal <krishnadobhal234@gmail.com>
Signed-off-by: Krishna Dobhal <krishnadobhal234@gmail.com>
zlareb1
left a comment
There was a problem hiding this comment.
Browser Forward still drops a conversation opened from another namespace. The new test stops after checking the initial URL. The inspector can also open a foreign chunk in the current namespace. Existing Forward finding
| namespace: e.namespace || identity.namespace, | ||
| exact: true, | ||
| } | ||
| : { agent: e.agent }, |
There was a problem hiding this comment.
P2 — A raw chunk hit from another namespace opens the inspector in the picker’s namespace. The preview has no writer tuple, so this fallback drops the hit’s namespace. If both namespaces have the same session and chunk index, the drawer can show the wrong passage. Keep raw chunk previews read-only until the inspector can carry their verified scope.
zlareb1
left a comment
There was a problem hiding this comment.
The read-scope isolation test cannot build the worker approval and enrollment requests on this run or on the earlier main run. #2156 adds those request fields and keeps the refusal assertion. The failed run still blocks this head. PR job · Main job · Merged fix


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
Rolling-upgrade semantics for code-memory links and stricter writer-exact reads can surface "unknown" guidance or "not found" until recheck passes complete; dashboard paging depends on the new
rows_readcontract.Overview
Documents use guidance (
use_guidance.next_stepand precedence-orderedreasons) for maintained retrieval results, including a new Using retrieved guidance section and cross-links from search, unified search, and procedures docs. Architecture and rolling-upgrade notes explain howmemory_code_links.coveredand recheck leases keep code-linked memory guidance trustworthy during rolling deploys (late inserts from older builds read as unknown until catch-up).API reference updates type several wire shapes (
CodeLesson,SearchSection,ContextUseGuidance) and documentsmemory.list→rows_readfor correct paging when the server drops rows.Dashboard changes treat memories as writer-scoped revisions: search and Recall Lab resolve agent/user/session (and foreign namespace) before opening; hits without a unique writer stay preview-only with guidance labels.
MemoryInspectorcan verify the writer somemory.getcannot show a namesake; navigation/history restore full inspect scope; focus restore usesdata-focus-keywhen list rows remount. Client API code splits lazy memory reads and admin helpers; list requests addversion_text(14 fields). Adds migration122_memory_code_link_covered.sql(covered UInt8onmemory_code_links).Reviewed by Cursor Bugbot for commit 87bf57c. Bugbot is set up for automated code reviews on this repo. Configure here.