Repository navigation
Return use guidance with retrieved knowledge - #1510
krishnadobhal wants to merge 18 commits into
Conversation
Signed-off-by: Krishna Dobhal <[email protected]>
Signed-off-by: Krishna Dobhal <[email protected]>
Signed-off-by: Krishna Dobhal <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Signed-off-by: Krishna Dobhal <[email protected]>
cd4010a to
e78e001
Compare
Signed-off-by: Krishna Dobhal <[email protected]>
Signed-off-by: Krishna Dobhal <[email protected]>
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 <[email protected]>
|
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 <[email protected]>
Signed-off-by: Krishna Dobhal <[email protected]>
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 |
Signed-off-by: Krishna Dobhal <[email protected]>
zlareb1
left a comment
There was a problem hiding this comment.
The expiry and hashless-touch fixes are present. The search verdict can still describe a hit the response discarded, and the generated Python and TypeScript clients change existing code-lesson types. The decision pack and Recall Lab threads still apply. The format job failed on a document whose contents and formatter inputs are unchanged.
A head recheck can remove evidence after the verdict is computed. Recompute confidence and abstention from retained hits. Verify that a single-key touch reads live embeddings with the full identity in the batch query. Signed-off-by: Krishna Dobhal <[email protected]>
Recount support for the surviving evidence when the verdict pool shrinks. Keep the same fallback when the support lookup fails. Signed-off-by: Krishna Dobhal <[email protected]>
Bind namespace and memory key as a pair so a dropped hit cannot contribute support through two surviving hits in different namespaces. Signed-off-by: Krishna Dobhal <[email protected]>
zlareb1
left a comment
There was a problem hiding this comment.
Search can lose an extended TTL or drop guidance from a matching result, and code.symbol drops an existing lesson field. The decision-pack finding also remains. It compares the clipped search excerpt to the full statement and drops the structured decision fields when they differ. The Python and TypeScript lesson migrations are documented at this head.
Signed-off-by: Krishna Dobhal <[email protected]>
Carry authoritative expiry through verification, keep guidance on matching tier bodies, and preserve structured decisions and linked symbols in serialized results. Signed-off-by: Krishna Dobhal <[email protected]>
Match the full served text when a guided hit has no content digest. A clipped excerpt still needs a matching hash before structured fields are attached. Signed-off-by: Krishna Dobhal <[email protected]>
zlareb1
left a comment
There was a problem hiding this comment.
Guidance still loses current review evidence after a metadata-only write, and recall reads entire bodies to classify matches. Recall Lab still opens a different memory for same-key hits. The decision-pack digest fix is present.
| denied.add(i) | ||
| continue | ||
| digest = hash_text(row.get("content_sha256")) | ||
| if int(row.get("version") or 0) == version or ( |
There was a problem hiding this comment.
P2 — memory.lock and memory.unlock advance the authoritative row version without changing the body, review, or vector. A dense search then sees the older vector version and drops the review, while memory.for_file still shows it. Bind review to verified content identity across metadata-only revisions and extend the parity test through lock and unlock.
There was a problem hiding this comment.
Fixed in 43a91ac4. Search keeps the review through lock and unlock as long as the content hash still matches. The parity test passed against local ClickHouse and confirmed that editing the body makes the review stale.
| SELECT | ||
| memory_key, memory_type, | ||
| if({{full_values:UInt8}}, value, substring(value, 1, {_READ_BYTES})) AS value, | ||
| {PROCEDURE_GUIDANCE_VALUE}, |
There was a problem hiding this comment.
P2 — The procedural projection transfers full JSON despite the 600-byte limit on the display projection. A file recall can read up to 50 large values to classify a handful of fields. Project the fields the classifier needs and retain the display bound.
Bind review to matching content across metadata writes. Project source and procedure evidence for recall and keep Recall Lab results tied to their writer. Signed-off-by: Krishna Dobhal <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 43a91ac. Configure here.
| valid_at=_iso_date(str(r.get("valid_at", ""))), | ||
| status=str(r.get("status") or ""), | ||
| version=int(r.get("version") or 0), | ||
| content_sha256=str(r.get("content_sha256") or ""), |
There was a problem hiding this comment.
Vector digest uses str not hash_text
High Severity
Search records the embedding content_sha256 with str() instead of hash_text(). On the native client a FixedString(64) arrives as bytes, so the stored digest becomes a Python repr and is not a content hash. Live guidance then treats a version match as unbound content, and a lock or unlock that only bumps the head version cannot match the older vector, so dense search drops a still-valid review.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 43a91ac. Configure here.
Require the closing citation bracket in the rendered pack. Cover cutoffs inside a citation at both budget limits. Signed-off-by: Krishna Dobhal <[email protected]>
|
still making changes don't review it now |
zlareb1
left a comment
There was a problem hiding this comment.
The digest finding is confirmed on this head. The native driver returns FixedString as bytes, so str() leaves the b'…' wrapper and review drops after a metadata-only lock revision. Decode the digest consistently across retrieval legs. The current head also needs to preserve page inclusion and bind dashboard guidance to the selected row.
| def _status_kept( | ||
| status: str, hit: _MemorySearchHit, input: MemorySearchInput, *, parked: bool | ||
| ) -> bool: | ||
| if parked and hit.status and hit.status == status: |
There was a problem hiding this comment.
P2 — An anchor hit selected with include_superseded=true is parked without its status because the anchor SQL does not select it. Continuing with only the returned page handle then drops the unchanged hit. Carry the selected status or original diagnostic options into the parked page and cover a handle-only continuation.
| # requested, so the key is dropped. | ||
| data: dict[str, Any] = handler(self) | ||
| if self._row_identity is not None: | ||
| data["agent"], data["user_id"], data["session_id"] = self._row_identity |
There was a problem hiding this comment.
P2 — user_id is injected during serialization but has no field on _MemorySearchHit. The response schema and generated SDKs therefore omit the field that the dashboard uses to identify the row. Declare the optional output field and regenerate the contracts.
There was a problem hiding this comment.
test_writer_serialization_honors_projection fails on this head too. A hit requested with only memory_key still serializes agent, user_id, and session_id because this serializer adds them after projection. Keep the writer fields subject to the same projection as other hit fields. Failed unit job
| <div className="flex min-w-0 flex-wrap items-center gap-1.5"> | ||
| <button | ||
| type="button" | ||
| disabled={!hasWriter(row.writer)} |
There was a problem hiding this comment.
P2 — This disables inspection of ranked-only results from an older replica during a rolling upgrade, since its search hits omit user_id. Keep inspection available when the returned identity and key resolve to one verified row, and keep ambiguous namesakes unselectable. Cover both cases.
| {hit.use_guidance && ( | ||
| <> | ||
| <p>Matched text: {hit.content_excerpt}</p> | ||
| <GuidanceLabel hit={hit} reasons /> |
There was a problem hiding this comment.
P2 — Memories stores ranked hits by memory_key, so two visible same-key rows from different sessions receive the same guidance even if only one was ranked. Header search also opens the selected hit by key and agent without its session. Carry the selected row's identity through both paths and test two same-key rows with one ranked match.


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
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.unknown. Context packs attach guidance to the citations they render.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.Tests
git diff --check. The Windows unit run used temporary stand-ins for two Unix-only imports.AI assistance in the code
Checklist
Note
Medium Risk
Touches core retrieval, context assembly, and attestation/revision checks across many ops; incorrect precedence or revision binding could mislead agents, but changes are additive and backward compatible.
Overview
Adds
use_guidanceon maintained retrieval results: a deterministicnext_step(e.g.follow_if_applicable,recheck_source,validate_lead) plus orderedreasons, derived from lifecycle, review, attestation, source/code freshness, and dispute evidence for the served revision after authorization.The field is wired through memory search, unified search, knowledge search, file recall, procedure match, memory stack, context.pack (per citation), and code lessons on code ops. API references and generated Python/TypeScript/Rust clients introduce
UseGuidance,CodeLesson, and related types; lessons move from loose dicts toCodeLesson.Dashboard search and Recall Lab show suggested use via
GuidanceLabel; opening a hit uses exact writer identity (verifyWriter/inspectedScope) so namesake keys do not load the wrong row. Docs add “Using retrieved guidance” with the precedence table and cross-links from search docs.Compatibility: guidance is optional on the wire; older servers and clients without the field keep working.
Reviewed by Cursor Bugbot for commit acf18cc. Bugbot is set up for automated code reviews on this repo. Configure here.