Repository navigation
Audit and validate findings carry their kind, rule version, coverage and cited revisions - #168
Merged
Merged
Conversation
zlareb1
force-pushed
the
feat/i160-findings
branch
4 times, most recently
from
November 2, 2026 12:35
a53a108 to
a20a202
Compare
…and cited revisions Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
feat/i160-findings
branch
from
November 2, 2026 14:55
6f91f0d to
7fe6950
Compare
…und fits UInt32 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…e helper Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…onKey names the versioned key Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… says Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: #160
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
namespace.auditandnamespace.validatefindings say whether each is a contract violation or a usage heuristic, which rule version and operation computed it, what it was measured against, whether its samples are complete, and which live revisions (memory id, version, content hash) back each sampled row. Each report lists the rules it ran and skipped incoverage, its summary reads and the evidence read among them.Why
Issue 160 asks for findings that the CLI, the dashboard, MCP clients and a chat client can share, and that keep three kinds of result apart: a broken stored contract, a usage heuristic that a legitimate design can match, and a recommendation that needs review. Today a finding is a code, a severity, a count and key samples. A reader cannot tell a heuristic warning from a broken invariant, whether the samples are all the matches, what population the count was measured against, or which stored revision a sample referred to when the report ran. An explanation built on top of the report (in a chat, say) would have to restate that from prose.
This adds one shared contract (
server/identity/api/models_findings.py) to both reports. Codes, severities,healthyand the existing fields are unchanged; the contract fields come first in each finding. A cited row'scontent_sha256is the hashmemory.getserves: the hash of the value it serves, computed the same way (the stored column can differ for an object, whose JSON column drops a null field); a high-sensitivity row is cited without it, asmemory.listserves it, because these reports are unaudited reads and a short secret's hash can be guessed.Each sample names the row that matched: by its
memory_id, or by its full identity (agent, user_id, session_id, memory_key) when it comes fromloom.memory_embeddings, which has no id. One extra read per report (server/memory/store/reads.py::live_revisions) fetches the live head of every named row, identifiers only; a second read keyed by each cited row's whole sorting key reads the valuememory.getserves, to hash it, and returns no value. A row whose value is longer thanLOOM_NAMESPACE_REPORT_HASH_MAX_BYTES(new, live, 64 KiB) is cited with no hash and its value is not read, so a report over the largest values (oversized_values,episodic_blobs) reads at most that much per cited row. A key held under several identities cites only the identity that matched. A sample that names no single row (a hot key from the ledger, a key's version history) and an orphan vector are not cited. A failed citation read leaves the findings uncited, addsevidence: <error>toskipped, and markscoverage.completefalse; it never fails the report.populationis the denominator of the finding'sshare(audit); validate's checks report a count with no denominator and leave it null, and so does an audit finding whose summary read was skipped.namespace.auditlists its summary reads incoverage.rules_run, since most findings are measured against one of them.Scope and risk
loom.memory FINALread per report, over identifier columns only (plus one read of the cited rows' values keyed by their whole sorting key and bounded bynamespace_report_hash_max_bytesper row, so no read scans the namespace's values), filtered on(org, namespace)and the sampled rows'memory_idor identity tuple, capped at the number of rows named and taking the request's read scope, as every reader of memory rows does; like the audit's other reads it scans the namespace's live rows: at most 14 findings ×sample_limit(50).memory_idcolumn (andunembedded_rowssamples their identity columns), which joins each sample to itsevidenceentry; the samples main already returned keep every column. The CLI table and the dashboard do not printmemory_id; they do print theunembedded_rowssample's identity columns (agent, user_id, session_id), as they print every other sample column. Both ops read the whole namespace and a token narrowed below it is refused before either runs (pinned by a test).exact_key_storeandversion_churnread one sample row past the cap, so a full page is told from a cut one.kind,exceptionsanduncertaintyfor each rule are written next to its existing detail and remedy text. Every error-severity validate check is acontract_violation. The thresholds-based checks (conflicted_aging,unsourced_low_confidence,unanchored_time_cue,unresolved_evidence,code_links_stale) and every audit code exceptunembedded_rowsareusage_heuristic.exact_key_storegroups every get of the window by key in one scan, so the window's gets and the hot keys' reads are counts of one snapshot (the hot-key grouping costs that scan on its own). On 300,000 gets over 5,000 keys in one namespace, both forms read 300,238 rows; the median of five runs was 12 ms against 11 ms, and memory 6.07 MB against 5.68 MB (system.query_log).stale_of_servedcode-link read gainsmemory_id;tests/integration/test_memory_code_links.pyruns it on the live store.kindcolumn.Compatibility, rollout and rollback
computed_at(audit) andchecked_at(validate) are now when the report started, in whole seconds, not when it finished, so a cited revision'supdated_atcan be compared with it. One behaviour fix:namespace.validatewithsample_limit: 0counted every finding as 0 (each count rode its sample rows underLIMIT 0); it now counts and lists none, asnamespace.auditalready did.NamespaceAuditFindingand the validate finding gainkind,rule_version,source_op,window_seconds,population,sample_limit,samples_complete,evidence[],exceptions,uncertainty.NamespaceAuditOutputandNamespaceValidateOutputgaincoverage(rules_run,rules_skipped,complete). No input changes.LOOM_NAMESPACE_REPORT_HASH_MAX_BYTES(live, default 65536; 0 cites no hash). Operator steps: none.Tests
memory.gethashes it (an object and a raw string value), one revised between the two reads is cited with no hash, and a high-sensitivity row is cited with no hash and no value read; a key under two identities cites only the row that matched, for a value check and for an index row judged per identity;exact_key_storesamples are complete only when the hot keys account for every get, both counted by one statement, and never when the ledger summary failed; each code's built-in thresholds and validate's time-cue pattern are pinned beside their rule version; hot keys under a failed ledger summary are not a complete listing; ledger and version-history samples are not cited;version_churn's population is its version rows; hot-keysamples_completeat and below the limit; a row behind two samples is cited once; a row stored without a hash is cited with the hashmemory.getcomputes from its value; validate withsample_limit: 0still counts and is not a complete listing; a failed citation read is reported inskippedandcoverage; a population whose summary read was skipped is null; a value over the hash bound is cited with no hash and never read; the analyzer corpus renders both citation statements; a skipped check or summary read is named incoverage.tests/integration/test_namespace_findings_contract.py, against a private ClickHouse and server): the citation read resolves a row by id and by identity tuple with an empty id list, an identity that holds nothing, and nothing under another user's read scope; a key read past the hot threshold beside a key read once is sampled alone and not a complete listing; a double-encoded value'sdouble_encoded_valuesfinding cites thememory_idandcontent_sha256thatmemory.getserves, and the report does not carry the value; both reports'coveragelists no skipped rule, so every check's SQL, the join projections that now selectmemory_idincluded, ran on the live store; a row whosecontent_sha256column holds the default'0'is cited with the hashmemory.getserves, for a string value and for an object value served from the JSON column, and so is a hashed object with a null field (whose stored hash differs frommemory.get's); a high-sensitivity row is cited with no hash; with a second agent holding the same key unverified, the stale attestation'sstale_verificationfinding cites only the stale row's agent and hash.test_memory_verify.py,test_memory_code_links.pyandtest_read_ops_never_5xx.pypass against the same server (230 passed, withtest_memory_precondition.pyandtest_read_scope_isolation.py, since every write-pathif_match_sha256hash now goes through the same helper).Recent.audit.test.tsxchecks the kind line with its separators, the incomplete-samples note, and that a finding from a server one release older (no evidence fields) shows neither.make format lint typecheck,npm --prefix frontend run buildandRecent.audit.test.tsxpass. The wholetests/unitpasses except three repository-wide checks thatmainfails too, ondecision_extractcode this PR does not touch:test_tunable_constants.py::test_no_new_tunable_constant,test_llm_max_tokens.py::test_no_call_site_caps_its_output_with_a_literalandtest_tests_patch_only_real_settings.py::test_every_patched_settings_name_is_a_settings_field(25039 passed).AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code. Checked the rule classification against each check's SQL, the citation read's projection, and the integration run.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed.main; no merged migration is edited. (No migration.)npm --prefix frontend run build) and its tests pass, iffrontend/changed.docs/describe the system as it now is, and this description names any operator steps and wire changes.git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code