You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is tested at which seam? Which behaviour is covered by tests of the pure derivation step, which by the indexer's interface ("work the queue") against real Postgres and OpenSearch, and which by crate-to-HTTP tests in test/ (placement fixed in #77)? How are the hard cases covered: a child crate indexed before its parent crate exists, a second crate claiming a collection, a shared entity losing its owning crate, a dead worker's job, a damaged crate? What test data replaces sub_col_2.txt?
Decided by grilling with the maintainer. No ADR and no glossary changes.
1. Which seam carries which behaviour
Derivation (derive.ts), no database: every rule about one crate. Which entities get a row and document, parent choice, id prefixing, licence fallback, the access control label, files not held, what the crate adds to aggregates, warnings.
"Work the queue", against real Postgres, OpenSearch and a temporary OCFL repository: everything that depends on stored state or more than one crate. Incremental skip by head version, reindex, delete, shared entities, clashes, failed jobs, dead workers, damaged crates. Tests assert on rows, documents and index state.
Crate-to-HTTP tests in test/: a thin layer, one or two tests per thing arocapi or Oni serves (search, root collection, access by licence, aggregates, file content). It proves the wiring, not the rules.
Index queue: its own small tests beside it (one waiting and one running job per crate, how index state is derived).
The three writers (rows, documents, aggregates) get no tests of their own.
2. The hard cases
All through "work the queue" on crates built by the test, unless noted.
Child crate before its parent: index a child whose parent crate isn't in the repository, then add the parent and reindex the child; assert rootCollection each time.
Second crate claiming a collection: the first crate keeps the row, the rest of the second is indexed, the clash is reported naming both crates.
Shared entity losing its owning crate: delete the winning crate and assert the row becomes the next crate's copy. Also index the crates in both orders and assert the same rows.
Damaged crate: corrupt its inventory in the temporary repository; its job fails with the error and the other crates index. One crate-to-HTTP test shows the API still serves the rest.
Dead worker: the test writes the state directly (a worker row with an old heartbeat and a running job naming it), then works the queue. The third return is the same test with the attempt count preset. No fake timers anywhere in the indexer tests.
Two workers at once: one test runs "work the queue" twice concurrently over several crates and asserts each crate was indexed once.
A worker wrongly judged dead: tested at the indexer's internal job seam (jobs.ts): claim, have the test take the claim away, assert the result write is refused. This is the one test that reaches inside the indexer.
Failure part-way: pass a search client that throws on write. Assert the job failed with the error, the crate has no indexed version, and asking again succeeds.
Outage ("the worker pauses and reconnects"): no automated test. Checked by hand once; the spec lists it as a known gap.
3. Test data
A small crate builder in test/; derivation and hard-case tests state the crate they need inline.
test-data/ shrinks to the few realistic crates the Import and bootstrap tests need.
sub_col_2.txt (a File entity in test-data/bundled with no bytes behind it, named by no test) is replaced by a named inline case: "a file described but not held".
4. Set-up
As today: one database and search index per run, files one at a time. New: an "empty everything" helper run before each test.
One pnpm test and one CI job. No split into fast and full runs.
Rejected: a database and index per test file so files can run in parallel (a migrate per file; revisit only if the suite gets slow).
5. Today's tests
src/indexer/indexer.test.ts, search.test.ts and database.test.ts are thrown away and written fresh against the new seams, not ported.
The crate-to-HTTP files move to test/ (as "Layout of src/ after the redesign", Layout of src/ after the redesign #77, decided) and keep their assertions.
test/bootstrap.test.ts stays as the one test that runs the real CLI end to end.
6. Coverage
A threshold over src/, starting at today's measured numbers and raised automatically by Vitest (autoUpdate) whenever a run beats it. The aim is 100%.
Measured on main at ec91b82 over src/ and scripts/: 89.11% lines, 85.65% branches, 92.6% functions, 89.37% statements.
src/indexer/ and src/index-queue/ are held at 100% from their first commit.
Entry points (scripts/*.ts, src/index.ts, later src/worker.ts) are not counted: tests run them as separate node processes, which the coverage tool can't see into. The condition is that each only parses arguments and calls code in src/. The logic in scripts/crates-import.ts moves into src/.
That rule is written in CLAUDE.md and in a comment beside the exclusion in vitest.config.ts. No ADR: cheap to undo, no real alternative.
Coverage shows a line ran, not that a rule was asserted, so the spec also lists the derivation rules by name and each implementation issue names the tests it owes.
Rejected: a threshold on derive.ts only; no threshold; counting the entry points; running the scripts in-process (the tests would stop proving the real command works).
The hard case "Second crate claiming a collection" changed: the first crate keeps the row, and the second crate's job fails with an error naming both crates. The rest of the second crate is not indexed. See the follow-up on "How shared entities are stored and deleted" (#72) and ADR 0006 in #93.
Activity
johnf commentedon Nov 17, 2026
Resolution
Decided by grilling with the maintainer. No ADR and no glossary changes.
1. Which seam carries which behaviour
derive.ts), no database: every rule about one crate. Which entities get a row and document, parent choice, id prefixing, licence fallback, the access control label, files not held, what the crate adds to aggregates, warnings.test/: a thin layer, one or two tests per thing arocapi or Oni serves (search, root collection, access by licence, aggregates, file content). It proves the wiring, not the rules.2. The hard cases
All through "work the queue" on crates built by the test, unless noted.
rootCollectioneach time.jobs.ts): claim, have the test take the claim away, assert the result write is refused. This is the one test that reaches inside the indexer.3. Test data
test/; derivation and hard-case tests state the crate they need inline.test-data/shrinks to the few realistic crates the Import and bootstrap tests need.sub_col_2.txt(aFileentity intest-data/bundledwith no bytes behind it, named by no test) is replaced by a named inline case: "a file described but not held".4. Set-up
pnpm testand one CI job. No split into fast and full runs.5. Today's tests
src/indexer/indexer.test.ts,search.test.tsanddatabase.test.tsare thrown away and written fresh against the new seams, not ported.test/(as "Layout of src/ after the redesign", Layout of src/ after the redesign #77, decided) and keep their assertions.test/bootstrap.test.tsstays as the one test that runs the real CLI end to end.6. Coverage
src/, starting at today's measured numbers and raised automatically by Vitest (autoUpdate) whenever a run beats it. The aim is 100%.mainat ec91b82 oversrc/andscripts/: 89.11% lines, 85.65% branches, 92.6% functions, 89.37% statements.src/indexer/andsrc/index-queue/are held at 100% from their first commit.scripts/*.ts,src/index.ts, latersrc/worker.ts) are not counted: tests run them as separatenodeprocesses, which the coverage tool can't see into. The condition is that each only parses arguments and calls code insrc/. The logic inscripts/crates-import.tsmoves intosrc/.CLAUDE.mdand in a comment beside the exclusion invitest.config.ts. No ADR: cheap to undo, no real alternative.derive.tsonly; no threshold; counting the entry points; running the scripts in-process (the tests would stop proving the real command works).For the spec
Outside the map
johnf commentedon Nov 17, 2026
The hard case "Second crate claiming a collection" changed: the first crate keeps the row, and the second crate's job fails with an error naming both crates. The rest of the second crate is not indexed. See the follow-up on "How shared entities are stored and deleted" (#72) and ADR 0006 in #93.