Skip to content

The tests behind main's red unit and integration jobs follow the code they exercise - #116

Merged
zlareb1 merged 8 commits into
mainfrom
pufit/main-green-after-93
Oct 21, 2026
Merged

zlareb1 merged 8 commits into
mainfrom
pufit/main-green-after-93

Conversation

@pufit

@pufit pufit commented Oct 21, 2026

Copy link
Copy Markdown
Member

Related: #93
Related: #89

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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):

Not required: tests only.

Why

main has been red since the profile-schema and sensitivity-sweep changes landed: the pytest unit + coverage job fails 15 tests and pytest integration fails one, and both were already red on those pull requests' own heads. Every failure is a test that did not follow the code it exercises; the server code is right in each case, so this changes tests only.

  • Profile prompt test: system_prompt now names each property's bounds, so the expected line reads (array of string, at most 20 characters).
  • Profile fold tests (two): the stub rows lacked the memory_id that user_facts always returns, and the tests stubbed the replaced handle_profile_set instead of write_folded_section; the fold crashed after the model call, run_pass swallowed it, and nothing was written (assert 0 == 1 in CI, KeyError: 'memory_id' locally).
  • Redact handler cache test: the handler now also asks profile_keys_built_from; the test did not stub it and reached the unconnected client. The handler stays strict: skipping that lookup would report a redact as done while profile versions still hold the text.
  • Profile redaction tests (six): the tables come from schemas/schema.sql replayed through clickhouse_local.ddl(); two of them use the Quantized codec, which the CI server refuses without SET enable_quantized_codec = 1, as the sibling SQL tests already do. Behind that, one test inserted empty vectors into the coded columns, which need 3072-wide zero vectors.
  • Read-scope integration test: profile_schema.set is correctly refused for a token pinned to one user, as memory_schema.register is; the assertion listed the ops the walk could not build a body for, because it never filled json_schema. The walk now fills it, so the refusal is actually checked (403), and the extraction-policy ops pass the same walk.
  • Sensitivity sweep tests (three): the fixture wrote every row in one INSERT, and the default optimize_on_insert keeps only each key's newest version, so the "old versions waiting for a merge" the tests rely on never existed. SET optimize_on_insert = 0 keeps them, as separate writes would until a merge.
  • Sweep across two agents: its "not truncated" expectation went stale when truncated was made to cover the whole scan; the sibling test added at the same time already asserts truncated for the same situation.
  • CLI sweep paging test: _read_page adds the FINAL read's bounds to the params dict it already handed to the key read; the test kept references and counted one key read. It records a copy. Production is unaffected.

Scope and risk

Six test files, 34 insertions, 15 deletions; no server code, no schema, no generated file. The five profile hunks are identical to the ones carried on pufit/admin-revocation, so whichever lands first merges cleanly with the other. Nothing here touches concurrency, stored data, auth or tenant isolation.

Compatibility, rollout and rollback

  • Wire: none.
  • Operator steps: none.
  • Rollback: reverting leaves nothing behind.

Tests

  • CI's unit command (pytest tests/unit -q -p randomly --randomly-seed=<seed> --cov … --cov-fail-under=40) on ClickHouse 26.9.19.9 (the release CI tests), TZ=UTC, two seeds (395652978721, 395537825001): 21983 passed, 74 skipped, 1 xfailed, 0 failed, coverage 89.98% both times. The coverage floors exit 0 for both seeds; pytest bench 191 passed; integrations/generic/test.sh passes.
  • Integration against a private server set up as CI's (migrations through 062, control plane via scripts/serve.sh): tests/integration/test_read_scope_isolation.py 20 passed with auth off and 20 with auth on; the nine auth-on gate files 95 passed; pytest tests/analyzer 12 passed. The full integration directory was not re-run locally; main's own run had only the one failure fixed here.
  • ruff check, ruff format --check ., mypy --strict sdk/python/loom, the mypy gate (0 errors), the function-length and secrets gates and every generator --check exit 0.
  • Noticed, not changed: the prompt never states maxItems although extra array items are dropped silently; tests/unit/cross_replica_fake.py answers now() in host-local time, so two test_cross_replica_auth tests fail on a non-UTC machine (CI runs in UTC).

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): a Claude agent run by Nerve. Checked: each failure reproduced on a clean main, the root cause read against the commit that introduced it, and the suites above run with CI's ClickHouse release and commands.

  • 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 (no server behaviour changed; the fixed integration file and the auth-on gates pass).
  • Generated files are regenerated in this PR, not by hand (none changed; every generator's --check passes).
  • (no migration) A new migration is additive and numbered after the latest on main; no merged migration is edited.
  • (no plugin file changed) A behaviour change to any file a plugin ships bumps both plugin manifests' version, and no other open PR uses that version.
  • (frontend not changed) The frontend builds and its tests pass, if frontend/ changed.
  • Docs under docs/ describe the system as it now is (unchanged), and this description names any operator steps and wire changes (none).
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description.
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

Generated by Nerve

pufit added 8 commits October 21, 2026 04:34
system_prompt appends each property's constraints to its line, and an array
property carries its items' constraints, so the test's languages property
(items maxLength 20) reads "(array of string, at most 20 characters)". The
test expected the line without the bound and failed on every run.

Signed-off-by: pufit <[email protected]>
The fold reads its facts through user_facts, which selects memory_id, and
hands their ids to write_folded_section, which names them in the section's
trace (profile.fold:<label>:<memory ids>) so memory.redact can reach the
section. StubCH returned rows with no memory_id, so the fold raised KeyError
after the model call: two tests failed on profiles_written, and the high-row
test passed with the error logged. StubCH now gives each row a memory_id,
and the tests replace write_folded_section, so they record what the fold
hands its write.

Signed-off-by: pufit <[email protected]>
memory.redact looks up the profile keys built from the memory
(profile_keys_built_from) before it scrubs anything, so a lock on one refuses
the redact and their versions are scrubbed with the named one. The handler
must not skip that lookup when it fails: the redact would report success with
the memory's text still in a profile. The CH-free test stubbed every other
repository call and reached the unconnected client through this one; it now
stubs it with no profile built from the memory, and its expectations are
unchanged.

Signed-off-by: pufit <[email protected]>
schemas/schema.sql declares the vector columns of memory_embeddings and
memory_chunks with CODEC(Quantized(...)). On the ClickHouse release CI runs,
clickhouse-local refuses that CREATE without enable_quantized_codec, so all
six tests that build these tables failed before the redact ran; the other
clickhouse-local tests set it first. With the setting on, the retried-redact
test then failed on its embedding rows: a coded column takes vectors of its
declared width (3072), not the empty default. Its rows now carry zero
vectors of that width in both coded columns.

Signed-off-by: pufit <[email protected]>
…efusal

profile_schema.set is refused for a token bounded to one user, as
memory_schema.register is: a profile schema is namespace-wide, so it is in
neither SCOPED_OPS nor NARROW_SAFE_OPS. The walk of refused ops could not
build its required json_schema field and listed the op as unbuildable, which
fails the test unless _UNBUILDABLE names it. The walk now fills json_schema,
so the op's refusal is checked like the others': the gate answers a pinned
token 403 before the schema is read, and any other answer fails the walk.

Signed-off-by: pufit <[email protected]>
_local_memory writes a test's rows in one INSERT. ClickHouse merges an
inserted block by default (optimize_on_insert), so ReplacingMergeTree kept
only each key's newest version, and the older unlabelled versions the sweep
pages past before a merge were never written. Three tests built on them
failed: the key read saw current versions only, and the first pass labelled
the row the tests expect a later pass to reach. The fixture turns
optimize_on_insert off, so each listed version stays a row, as separate
writes leave them until a merge.

Signed-off-by: pufit <[email protected]>
… truncated

A pass reads the rest of each agent it moved past with the pages it has left,
and reports truncated when it could not, as
test_a_pass_that_cannot_reread_every_agent_it_moved_past_says_it_was_truncated
pins and docs/architecture/security.md states. In
test_one_pass_crosses_several_agents_it_finds_nothing_to_label_in the three
pages go to `a`, `b` and the PIN row in `c`, so the rest of `a` and `b` is
not read and the pass is truncated. The test still expected not truncated,
from before truncated covered the whole scan.

Signed-off-by: pufit <[email protected]>
…rameters

_read_page sends its key read a parameter dict and then adds the FINAL read's
upto_* bounds to that same dict. The test kept a reference to each dict, so
every key read followed by a FINAL read later held upto_org and was not
counted: only the last, empty key read was, and the test failed on
len(key_reads) > 1. It now keeps a copy taken when the read is made.

Signed-off-by: pufit <[email protected]>
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.

2 participants