Skip to content

The open-visit guard holds under the run lock, and the specifications link their tests - #144

Merged
gedaiu merged 1 commit into
mainfrom
followups/tests-links-lock
Nov 24, 2026
Merged

gedaiu merged 1 commit into
mainfrom
followups/tests-links-lock

Conversation

@gedaiu

@gedaiu gedaiu commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Three follow-ups left open by the review-notes work (#134 to #139).

The race in the open-visit guard. The guard from #137 reads a node's visits and refuses a start for another iteration while one is open. That read ran before, and outside, the transaction that inserts the visit. Two starts for two iterations of one node, handled at the same instant, both passed it and left two open visits. A test now starts iterations 2 and 3 together and expects one open visit; before the fix it failed five runs out of five. A walk's start now takes the run's lock inside the inserting transaction and checks again there. The early check stays on purpose. Without it, a stray start on a node that also lacks a need would be refused for the need first, and that kind of refusal fails the whole run, where the guard's own refusal leaves it open. A start by hand is unchanged: it returns the node's open visit.

Tests for what nothing proved. Two were named in earlier reviews: the function that picks the visits since a person last acted, tested only through the database, and the rule that a produce takes from: output only as a file with no path, tested nowhere. Linking the specifications turned up five more statements with no test, now each with one:

  • a run keeps the version of the line it started with after a newer one is put
  • a missing agent definition refuses the visit and ends the run as error
  • a missing file fails a silent visit even when a REVIEW_RESULT: line is there
  • that failure does not apply to a produce taken from the output
  • a run's repository can come from the payload's repository field

All of these pin behaviour that already held. None needed a code change, so the specification sentences were right as written.

Test links in the specifications. Reviews of #135 and #137 asked eleven times for the agent-file and run-semantics pages to link the tests behind their statements. Sixteen statements now carry twenty links, in the form ([validated by file.test.ts:39](…#L39)). The links are absolute GitHub URLs to main, because the website validates internal links when it builds and a relative path to a file outside the docs would fail it. Each line number was read from the test file by the test's exact name, and matches the files in this change. Line numbers will drift as those test files change.

One thing I could not check: whether the reviewer's own coverage check accepts an absolute URL where its format shows a repo-relative path.

Checked in one run: every package's tests (store 424, API 417, pipeline 272, assembly-lines 207, and the rest unchanged), the typecheck, ESLint on the whole repo, the docs check, and the docs site build, which reports all internal links valid. The race test passed all nine runs made after the fix.

🤖 Generated with Claude Code

… link their tests

Two starts for two iterations of one node, handled at the same instant,
both passed the guard's check and left two open visits. A walk's start
now takes the run's lock inside the transaction that inserts the visit
and checks again there. The early check stays, so a stray start is still
refused as VisitAlreadyOpen before it can be refused for a need it lacks,
which would fail the run.

Tests for what nothing proved: the visits since a person last acted, the
from: output rule of a produce, a run keeping the line version it started
with, a missing agent definition ending the run as error, a missing file
failing a visit even with a REVIEW_RESULT line and not for a produce from
the output, and the payload's repository field.

The agent-file and run-semantics specifications link sixteen statements
to the twenty tests that prove them.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@lore-agent

lore-agent Bot commented Nov 24, 2026

Copy link
Copy Markdown

Lore is reviewing this PR — 94a737db-565f-416c-84f8-42c56bfde05d.

Submit a review that requests changes to have Lore push a fix for it. Comment @lore review to re-run the review.

@lore-agent

lore-agent Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Lore code review

Reviewed revision 1273b8172c44ec426acdb7d2eebf43f35448ef8a · Incomplete · 0 gaps

The story the tests tell

The change makes the assembly-line engine fail more clearly and stay consistent. A run now fails with a clear error when its agent station names a missing agent definition, and a run keeps walking the line version it started with. Station definitions are checked more strictly, and a few store lookups are tightened.

The full story, with its tests

The change makes failures clearer. A run whose agent station names an agent definition that was never stored ends with an error that says no agent definition "ghost" exists. A visit whose agent ends without a LORE_NODE_RESULT line, and whose last reply only carries a REVIEW_RESULT line, fails with an error naming the missing file (review_findings, findings.md). A station that produces only a file taken from the agent's output is not failed for a missing file. The same agent ending with no result line still succeeds.

Tests: apps/api/src/engine/dispatcher.test.ts (63), apps/api/src/routes/sink.test.ts (270, 279)

Station definitions are checked more strictly. A station's produce that takes its value from the output is refused when it is a value, with the message that from: output is for a file. A file produce from the output that also names a path is refused with the same message. A file produce from the output with no path is accepted.

Tests: packages/pipeline/src/definition-schemas.test.ts (33, 39, 45)

The run store gets two consistency guarantees. When iterations 2 and 3 of the same node are opened at the same time, only one open visit of that node results. A run keeps walking the version of the line it started with, so putting a newer version that routes review straight to the exit does not finish an open run when review succeeds.

Tests: packages/store/src/assembly-run-store-hand.test.ts (83), packages/store/src/assembly-run-store-report.test.ts (98)

Two smaller lookups are covered. When an event's payload has no repo but carries a repository, that repository is used. A new helper, visitIdsSincePersonActed, returns nothing when no visit belongs to a human node or was started by hand. Otherwise it returns the ids of the first human-node or hand-started visit and every visit after it.

Tests: packages/store/src/event-match.test.ts (87), packages/store/src/resolve.test.ts (86, 92, 98)

What the checks read

The only production change is the open-visit check in assembly-run-store.ts. The story's concurrent-open test (assembly-run-store-hand.test.ts:83) covers it, and an existing test still checks the early 'already has an open visit' refusal, so the story holds with no gaps.

The story covers every requirement in the pull request description: the open-visit race, the seven previously untested behaviours, and the spec test links, with no gaps beyond what the implementation check reported.

Incomplete — Documents check

Lore reviews this revision from its whole diff instead.

@lore-agent lore-agent Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lore review — Approved

The open-visit guard runs both before resolution and under the run advisory lock inside the insert transaction, and all changed spec statements link accurate tests.

Must fix (0) · Consider (0) · Nits (0)

Reviewed by gemini-4-argon

Submit a review that requests changes to have Lore push a fix for it. Comment @lore review to re-run the review.

Posted by floor, visit bd375f6a-78fa-4d29-b852-68adc22e782c.

@gedaiu
gedaiu merged commit 7353aef into main Nov 24, 2026
22 checks passed
@gedaiu
gedaiu deleted the followups/tests-links-lock branch November 24, 2026 14:51
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