Repository navigation
refactor: make agent mistakes fail CI or the model checker, not code review - #12
Merged
Merged
Conversation
…LA+ model When an agent gets something wrong, fix it at the cheapest layer that can hold the fix: the code's shape, then static checks, then runtime and formal verification, and prose only for what code cannot express. - Branded ids, a pending/leased job union, typed routes, and a config schema make the common wrong shapes unrepresentable. - turbo lint rules confine the clock, JSON parsing, and env vars to one owning module each. Fixtures test the rules, and RULE_OWNERS fails the build if .oxlintrc.json silences a rule anywhere else. - invariantViolation checks every queue loaded from R2 and every commit before it is written. - spec/QueueBroker.tla model-checks the compare-and-set commit protocol. A second config without compare-and-set must fail, so the spec still catches the bug it exists for. CI runs both. - AGENTS.md states the order and keeps only rules code cannot enforce. The PR template asks which layer now prevents a corrected mistake. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
…ope the spec The Worker test that expects two concurrent pushes to share one commit failed on the first GitHub Actions run: a loaded runner can miss the 5 ms batch window. Tests now use a 100 ms window. Config parsing used z.coerce.number, which read a blank batch window as 0 and "0x800" as 2048. It now uses Number.parseInt(value, 10) as before the refactor. The TLA+ spec now says it does not model batches answered from the cached snapshot without an R2 write. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 20, 2026
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.
When an agent made a mistake here, the only fix was to tell it again, and a correction like that doesn't survive into the next session. This PR puts each rule in the cheapest place that can enforce it, in this order:
JobIdcan't be passed as aLeaseToken. Only a leased job can carry a lease. Handlers can only read route params their path pattern has. Env vars are parsed once into a typedConfig.turbolint rules allow the clock,JSON.parse, and raw env vars only in the module that owns each one. Fixtures test the rules, andRULE_OWNERSfails the build if.oxlintrc.jsonturns a rule off for any other file.test/types.test.tslists mistakes that must not compile, and property tests check each guarantee in the readme.invariantViolationruns on every queue loaded from R2 and before every write, so a model bug fails the request instead of saving a corrupt queue.spec/QueueBroker.tlamodel-checks the R2 compare-and-set protocol with two brokers racing. A second config turns compare-and-set off and must fail (NoLostJob), which shows the spec catches the bug it exists for. CI runs both in a newmodel-checkjob.AGENTS.mdlays out this order and keeps only the three rules code can't enforce yet, each with the reason.Proof:
npm run check,npm test(27 passing), andnpm run verify:tlapass locally on the rebased commit. I also broke three things on purpose: an unowned lint override and a fixture line the rule doesn't flag both turnedlint:rulesred, and removing idempotency-key dedupe failed 6 tests through the runtime invariant.The first CI run failed on a Worker test that expects two concurrent pushes to share one commit. That assertion was already on main and depends on both requests landing inside the 5 ms batch window, which a loaded runner can miss. I reproduced it locally under full CPU load (2 of 25 runs failed) and gave tests a 100 ms window (0 of 30 failed under the same load). Sol review also found that config parsing had drifted from the old
parseIntbehavior, so it is restored with a test, and the spec now says it doesn't model replies served from the cached snapshot.Proof for the follow-up commit: the same stress runs, a config test that fails on the old parser, and
npm run check,npm test(28 passing), andnpm run verify:tlapassing locally.Reviewed with sol-loop: 2 rounds with gpt-6.2-sol. Sol verdict: approved
Created with Claude Opus 5.5 in Claude Code.