Skip to content

namespace.audit tells the deployment's state from the writer's: missing telemetry, an indexing backlog, procedure reads - #183

Merged
zlareb1 merged 26 commits into
mainfrom
feat/i160-rules
Nov 3, 2026
Merged

zlareb1 merged 26 commits into
mainfrom
feat/i160-rules

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Related: #160

Changelog category (leave one):

  • Improvement

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.audit tells the deployment's state apart from the writer's: telemetry_unavailable (the window's writes left no ledger rows, so the ledger checks are skipped rather than reported clean) and index_backlog (rows the embedding worker has not reached) are findings of the new kind system_state, and exact-key reads of procedures are intentional_exact_key_reads, left out of the object-store gauge. version_churn leaves out a version that keeps both the value and the reinforcement count of the one before it (a status change, a tags edit by id, a lock), so it counts what the writer rewrote or restated. unembedded_rows (and the context.pack health block) counts only rows the embedding worker gave up on with an error of their own; a row still being retried (a provider error, an outage) or whose model call was held or unbilled is the deployment's backlog, and get_search_ratio leaves out procedure reads.

Why

Issue 160 asks that a finding say whether the writer did something, and that a missing signal read as missing, not as clean. Four cases graded the writer for something it did not do:

  • No telemetry. With the ledger empty for the window (retention shorter than the window, a ledger that is not written), exact_key_store and coordination_as_memory counted 0 reads and passed, and the namespace read as healthy.
  • Delayed indexing. A row the embedding worker had not reached yet had no vector and no error, so no check named it, though search cannot find it.
  • Procedures read by key. A procedure is read back whole by memory.get by design. Those reads counted toward exact_key_store and toward the read-count arm of coordination_as_memory, so a namespace of runbooks read as an object store.
  • Status-only versions. Conflict marking and supersession write a version row that copies the value. version_churn counted each as a rewrite.

What changes

  • server/identity/api/models_findings.py: FindingKind gains system_state, a finding about the deployment rather than the writer. The assistant toolset's primer says a system_state finding is never a change to draft for the writer. The CLI table labels it system, the dashboard panel "The deployment's state, not the writer's doing".
  • server/identity/app/namespace_audit.py:
    • telemetry_unavailable (system_state, runs first among the checks): a warning when live rows were created in the window and the ledger holds no call for the namespace in it apart from reports on it (namespace.audit, validate, summary, inventory, mentor.brief) and the dashboard's or the assistant's calls that change no data (reads, page-view vitals): only an inspector's call that changes stored state (an op a writer calls or the server audits: a memory write, a setting, a grant) counts, and a worker's own ledger row (kind = 'worker', an extractor's spend on the rows) never does. The audit's own row is one of those reports, so a second audit still sees the gap; a write through any op closes it, a person's profile.set in the dashboard included. Rows are judged by created_at: a worker's revision of an old row (a sensitivity relabel) keeps it and may leave no ledger row, so a window of revisions only is not judged; nor are copied rows (cross_promoted_from_namespace set), since a copy's call names a source and a target and is ledgered under no namespace. A recent namespace.restore (ledgered the same way), in-process writes, and a ledger that keeps less than the window (it holds some calls, so it is not a gap, and the ledger checks then count only the part it kept) are named in the rule's uncertainty. While it warns, exact_key_store and intentional_exact_key_reads are skipped with the reason telemetry_unavailable, so coverage.complete is false, and coordination_as_memory runs only its key-segment arm: the statement then reads loom.memory alone, with no join to the ledger, and reports samples_complete: false. A write of the last TELEMETRY_LAG_SECONDS (60) is not judged, since the ledger is flushed in batches and a fresh namespace's rows may not have landed. It is skipped when either summary read it needs failed, and for a window no longer than the lag, which holds no row old enough to judge. The inspector ops that close a gap are state_change_ops(), shared with namespace.summary (which keeps its memory.* subset).
    • intentional_exact_key_reads (usage_heuristic, info): exact-key reads of live rows whose type is structured by design (STRUCTURED_TYPES, procedures), counted in the ledger summary as typed_gets.
    • exact_key_store v2 leaves those reads out of the gauge and of its hot-key samples, and summary.get_search_ratio leaves them out too. A ledger read's key is the memory_key column over HTTP and args['memory_key'] over MCP (whose rows leave the column empty), so a procedure read through the coding-agent plugins is matched too; a memory.bulk_get names no single key and is not.
    • index_backlog (system_state): searchable, non-high-sensitivity, non-empty live rows with no vector that the worker has not given up on (embed_failed_at unset, or set for a model call the deployment held or could not bill: EMBED_HOLDS, the worker's markers, pinned by a test). A row still being retried (a provider error, an outage) and a held or unbilled one are the deployment's: they count here, and unembedded_rows v2 counts only a row the worker gave up on with an error of its own. Info within INDEX_GRACE_SECONDS (600, namespace.validate's default grace), a warning once one is older. Samples carry key, id and age.
    • coordination_as_memory v2 does not count a structured row on its reads (its key-segment arm is unchanged).
    • version_churn v2 leaves out a version that keeps the value and the reinforcement_count of the one before it of the same row (agent, user, session, key): a status change (conflict marking, supersession), a tags or confidence edit through memory.update_by_id, a lock or an unpin, and the server's own copies of a write (a fresh memory.set leaves more than one such row). A new value counts, as does a restatement of the same value (a memory.set or memory.pin of it bumps reinforcement_count), a delete and a set of the same value after it (the tombstoned state changes), a value that flips back and forth and a version with no recorded hash. A row whose tags are edited over and over is therefore not counted; the rule's uncertainty says so. Judging by status instead was tried and rejected: the labeled clean namespaces then read as churn.
  • NamespaceAuditSummary gains typed_gets, written_in_window and ledger_calls.
  • The loom-optimize skill (both plugins) gets a row for the three codes, the corrected version_churn text and a Step 1 line that a system_state finding is never a rework; both manifests go to 1.2.4.
  • Docs: the finding kinds in docs/features/namespaces-and-sharing.md, and in docs/guides/optimize-namespace.md what a system_state finding means for a rework (nothing for the writer) and the row for the three codes.

Scope and risk

  • Measured locally (system.query_log, a namespace of 200,000 live rows, 200,000 embedding rows, 600,000 version rows and 200,000 ledger rows): index_backlog reads 415,032 rows and 18.6 MiB (it tests value_len, not the value), 55–78 MiB peak, 122–201 ms; version_churn 605,324 rows, 157 MiB, 81 ms (on 3,000,000 version rows of one namespace it reads 3,007,938 rows in about 300 ms and peaks at 450 MiB, against 200 MiB for v1's plain GROUP BY: the window reads in the table's order, optimize_read_in_window_order, which halves the 900 MiB it took otherwise); the ledger summary with the procedure-key read, now taking an MCP read's key from args, 404,676 rows, 11.7 MiB read, 9.8 MiB peak, 57 ms at the median, and exact_key_store 404,676 rows, 11.6 MiB, 19.4 MiB, 58 ms (200,000 ledger rows whose args carry a hash, a key and an agent, against 200,000 live rows); the whole audit answers in 661–800 ms once warm.
  • Read-only. Three statements gain conditions (summary_live, summary_ledger, and summary_embeddings through unembedded_rows' given-up rule), one new statement (index_backlog, an anti-join of the namespace's live searchable rows against its embedding rows, both on the (org, namespace) prefix), and exact_key_store, coordination_as_memory, unembedded_rows and version_churn change their predicates.
  • context.pack's namespace_health block runs its own subset of checks and summary reads, and does not run telemetry_unavailable; its exact_key_store and coordination_as_memory read as before apart from the procedure reads they now leave out, and its unembedded_rows no longer counts a held or unbilled model call (v2).
  • Grades change for four codes (rule versions raised: exact_key_store, coordination_as_memory, version_churn, unembedded_rows): a namespace whose gets were mostly procedure reads no longer reads as an object store, and one whose history was mostly status changes no longer churns.

Compatibility, rollout and rollback

  • Wire: kind may now be system_state; three finding codes added (telemetry_unavailable, intentional_exact_key_reads, index_backlog); NamespaceAuditSummary.typed_gets, written_in_window, ledger_calls added; exact_key_store, coordination_as_memory, version_churn and unembedded_rows go to rule_version 2. Nothing removed.
  • A dashboard one release older shows a system_state finding with no kind label.
  • Out of scope: namespace.validate's unembedded check keeps its v1 predicate and kind (contract_violation, every live row with no vector past its grace, held or unbilled model calls included); the docs say so beside the system_state kind.
  • NamespaceAuditSummary.get_search_ratio now leaves out procedure reads ((gets - typed_gets) / searches), so a namespace of runbooks no longer reads as a key-value store; gets still counts them.
  • NamespaceAuditSummary.unembedded_rows (and the context.pack health block's unembedded_rows) now counts only rows the worker gave up on (embed_failed_at set) with an error of their own; a row still being retried, or whose model call was held or unbilled, counts in index_backlog instead.
  • NamespaceAuditSummary.version_rows and version_bytes now leave out a copy that keeps the row's value and reinforcement count (a status change, a tags edit by id, a lock, the server's own copies), where they counted every version row: a namespace's figures drop across the upgrade with no change to the namespace.
  • Operator steps: none.
  • Rollback: revert; nothing is stored.

Tests

  • Labeled cases (tests/integration/test_findings_labeled_cases.py, private ClickHouse and server): nine namespaces built through the API (each audited once its rows are embedded, but for the delayed-indexing case, whose row carries a held embedding stub the worker leaves alone), each labeled with the findings it must raise and every other rule required to stay quiet — clean, double-encoded values, an oversized claim blob, hash keys, valid typed records and a procedure, a procedure read 220 times by key over HTTP, stale verification and an ended valid_to, a row whose model call was held (delayed indexing), and writes whose ledger rows were removed (missing telemetry). The missing-telemetry case rewrites its rows as created two minutes earlier, so it does not wait out the 60-second lag. Across both reports, every rule with a label or a hit (the table leaves out a rule that stayed quiet on every case). No labeled case raises the four rules this PR moves to rule_version 2; their evidence is the clickhouse-local unit tests below, and the labeled run shows they stay quiet on the cases they should:

    rule                           tp  fp  fn  precision  recall
    double_encoded_values            1   0   0       1.00    1.00
    hash_keys                        1   0   0       1.00    1.00
    index_backlog                    1   0   0       1.00    1.00
    intentional_exact_key_reads      1   0   0       1.00    1.00
    oversized_values                 1   0   0       1.00    1.00
    stale_valid_to                   1   0   0       1.00    1.00
    stale_verification               1   0   0       1.00    1.00
    telemetry_unavailable            1   0   0       1.00    1.00
    all rules                        8   0   0       1.00    1.00
    
  • Unit (tests/unit/test_namespace_audit.py): writes with no ledger rows skip the ledger checks and say why, while a ledger with the window's calls and a quiet namespace read clean; reads of structured rows leave the gauge (and its hot keys) and are reported apart; an indexing backlog is the system's state and warns only past the grace; a failed summary read leaves the telemetry check skipped; the threshold pins for the new constants and raised versions.

  • Integration (private ClickHouse and server): the labeled cases above, the findings-contract and audit-summary suites and the assistant toolset suite (11 passed); the findings-contract suite is what showed a fresh namespace's writes, not yet ledgered, reading as missing telemetry, hence the 60-second lag.

  • Unit, clickhouse-local (real SQL on the production tables): the ledger summary counts a dashboard write and no inspector read; an audit run twice over writes the ledger never recorded (its own row, a summary and a dashboard read in the ledger) still warns, and a procedure.add call closes the gap, as does a person's profile.set in the dashboard (ledger_calls counts an agent's get and a dashboard set, not the dashboard's or the assistant's reads); a worker's revision of a row created two days earlier is not judged, a dashboard page view (ui.vitals) or a worker's own row does not close a gap, and a settings save (namespace.register) does; a copied row into an empty ledger is not judged; version_churn counts a row's status-only versions once, another user's row with the same content as its own, a status flipping A→B→A→B four times, versions with no recorded hash each, and a writer's three restatements of one value three times, a delete and a re-set of the same value as two more, and copies that keep both once; a hot short procedure is not coordination state while a hot short status row is, and during a gap only the key-segment arm (a lease) is sampled; a procedure read over MCP (its key in args) is left out of the gauge and the plain fact read beside it is sampled from args; a held model call and a provider error still being retried are a backlog and not an unembedded row, a row given up on with an error of its own the reverse, and an empty, an episodic or a high-sensitivity row neither. The held markers equal the embedding worker's.

  • Frontend: a panel case shows the system_state kind label and the procedure-reads note on the ratio; the tests and npm --prefix frontend run build pass.

  • Plugins: agent_plugin_sync --check is clean and the two loom-optimize copies are identical. The plugin evals (integrations/claude-code-plugin/evals) grade the loom-memory skill only, so none covers this text.

  • make format-check lint typecheck, the unit tests above and the generator checks.

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 each predicate against the tables it reads and the labeled cases against a live server.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • make format-check, make lint, make typecheck and make test-unit pass; the integration suite passes if server behaviour changed.
  • Generated files are regenerated in this PR, not by hand.
  • A new migration is additive and numbered after the latest on main; no merged migration is edited. (No migration.)
  • A behaviour change to any file a plugin ships bumps both plugin manifests' version, and no other open PR uses that version. (loom-optimize changes; both manifests go to 1.2.4, past the 1.2.3 the release PR uses.)
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ changed.
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers.
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

🤖 Generated with Claude Code

zlareb1 and others added 9 commits November 3, 2026 00:17
…ng telemetry, an indexing backlog, procedure reads

telemetry_unavailable and index_backlog are findings of the new kind system_state;
exact-key reads of procedures are intentional_exact_key_reads, left out of the
object-store gauge; version_churn counts one version per distinct content.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… a backlog; the optimize skill knows the new codes

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ds; churn drops only repeated content

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…how a given-up row is queued again

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… inspector's read; the ratio leaves procedure reads out

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ule says it covers settings and grants

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…the ledger lag skips the telemetry check

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…elayed case holds its stub; the panel names procedure reads

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
zlareb1 and others added 17 commits November 3, 2026 00:27
…ks the worker's fill

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… order; the audit's docs name the system findings

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…e telemetry case backdates instead of sleeping; pins cover the structured types

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…'s stalled column is stripped with the aggregates

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ested on a non-lease row; the primer names system_state

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ded remedy and comments say what they count

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…etail names worker rows

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…he rules count

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…nd label and procedure-reads note are tested

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…alidate's unembedded check apart

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… real SQL

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…l and docs say which checks a gap skips

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…the CLI names procedure reads

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ds leave the gauge too

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 merged commit a43cee0 into main Nov 3, 2026
20 of 22 checks passed
@zlareb1
zlareb1 deleted the feat/i160-rules branch November 3, 2026 03:43
@pufit pufit mentioned this pull request Nov 4, 2026
9 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant