Repository navigation
fix(import): a producer's event_id is the identity of a fleet row (E0-11) - #1165
Conversation
…-11) When a fleet row carries an event_id, the import uses it as the identity of the row (fleet_import_id) and stores it as the row's event_id with event_id_source "producer", so the receipt names the producer's id. A row with no event_id keeps the provisional locator of its line, so old logs give the same ids as before. A row whose event_id is present and not a valid ADR-008 version 8 id is not imported: it is logged with its line number and the rows after it still are. A record with "kind":"start" is skipped before classification, so it is not stored, does not count as imported, and cannot make the outcome row with the same event_id look like a replay (design of E0-08, section 5.2). Tests: seven new tests in test/learning_scheduler_test.exs (the five of the work order, a replay check and the receipt). Ids are generated, never written as literals, because the estate UUID gate refuses a non-v8 literal. Co-Authored-By: Claude <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. Summary
Merge Risk:
|
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…ced verified receipt (E0-29) (#1170) ## What `Receipt.write/3` now refuses what the Idris2 model of E0-10 refuses. These are the two differences that I reported on #1164, closed by your rulings of 2026-11-15: **1A** (a duplicate receipt write is an error) and **2A** (add the guard in `Receipt.write`). Work order: **E0-29**, added here with its index row (`docs/operations/e0-closeout/`). ## The change * `Receipt.write/3` returns `{:error, :duplicate_event_id}` for an `event_id` that already has a receipt, and writes nothing (the model's `Left DuplicateEventId`). It used to return `:ok`. * `Receipt.check/1`: a `verified` receipt must have at least one observation and a 64-hex row digest, else `{:error, :verified_without_evidence}`. `write/3` calls it. `build/2` is unchanged and still not a smart constructor; `check/1` is what refuses. * A refusal is logged as `receipt_refused event_id=... reason=...` (the row is stored, no receipt is written), through one helper, `Receipt.report_failure/2`, used by `OutcomeTracker`, `Receipt.repair/2` and the neural path. Any other failure stays `receipt_pending`. * The mirror test, the header comment of `Receipt.idr` and the trust boundary of the P1 and P2 ledger rows now say that the two differences are gone. ## Evidence * Before: 8 tests fail (the work order's (a) to (d) and the 4 tests that pinned the old behaviour). After: `mix test` 3544 tests, 0 failures (246 excluded). * `check-verdicts.sh` (11 / 21), `proof-ledger.sh check`, `render --check` and `claims`: pass. Only the 2 intended ledger rows changed; every other row is byte-identical. `mix format --check-formatted`, `check-readme-claims.sh`, strict UUID gate on a clean export: pass. * Mutations (each restored): duplicate no longer refused (5 fail); guard removed from `write/3` (2); `check/1` never refuses (4); observations not required (4); refusals logged as pending (2). **My first attempt at the last one did nothing**: `mix format` had re-wrapped the line that my pattern matched, so it reported 0 failures. I noticed, checked that the mutation had not applied, and reran it properly. ## Stop-and-ask findings (please read) 1. **A test of E0-09 drove a path that the guard refuses.** "A verified update on the neural path" wrote a `verified` receipt with no observation, because the neural evidence is a bare claim. Under ruling 2A that receipt is refused. I changed the test to say so: the update still reaches the coordinator, its receipt is refused and logged. I did not invent an observation for it. **It is not reachable in production today**, because `FleetDispatcher.trusted_verification/1` returns `nil`, so no neural outcome is qualified. But when a trusted source exists it must bring an observation, or its receipts stay refused. 2. **The id-collision case is now loud.** A fleet row whose producer `event_id` equals an existing receipt's id (flagged on #1165) is stored, and its receipt is now refused with `receipt_refused ... duplicate_event_id`, instead of silently getting none. Test (d) covers it. 3. **A refused `verified` row is retried every cycle.** `Receipt.repair/2` skips ids that have a receipt, but a row whose receipt the guard refuses has none, so each learning cycle tries it again and logs `receipt_refused` again. That is loud on purpose (the row is a data defect), but it is noise until the row is fixed. No production path makes such a row. 4. **The caller that relied on `:ok`?** None: `persist_outcome` mints a fresh id for each row, the import skips by its seen set before it writes, and `repair/2` checks first. ## Not done * The Nickel contract tests still skip in CI where `nickel` is absent (the CI step is a separate PR). * `build/2` is not a smart constructor. Making it one would change its return type for every caller; I did not. ## Process notes * `scripts/api-agents/run-work-order.sh E0-29 --dry-run` exits 0 (Sonnet, medium effort, cap USD 8). This session was switched to Opus 5.5 at high effort; I did not choose that. * **Cost: unknown to me**; please read it in the Anthropic Console. * Draft. Not merged, approved or marked ready by me. Co-authored-by: Claude <noreply@anthropic.com>



What
When a fleet row carries an
event_id, the import uses it as the identity of the row.A row with no
event_idkeeps the provisional identity, so old logs give the sameresult as today.
Work order: E0-11 (depends on E0-08, ruled; E0-09 merged). Authority: issue 984, steps
6 and 8;
docs/design/e0-receipt.adocsections 4 and 5.2.The change (
lib/learning_scheduler.exonly)fleet_identity/3: a valid producerevent_idis thefleet_import_idand is passedto
record_fleet_outcome, which stores it as the row'sevent_idwithevent_id_source: "producer"; the receipt then names the producer's id. Noevent_idfield: the old
fleet_source_id(line, n)locator.event_idthat is present and not a valid ADR-008 v8 id (a string that is not one,a v7 id, uppercase,
null, a number) is not imported. It is logged with its linenumber and the later rows are imported.
"kind":"start"is skipped before classification. Without that, a startrecord would be classified as an audit row and stored.
lib/outcome_tracker.exneeded no change: E0-09 already lets only the fleet importbring a producer id, and only a valid one.
Evidence
45 tests, 6 failures); the replay test and the"no event_id" test pass, as regression guards should. After:
45 tests, 0 failures.mix test: 3495 tests, 0 failures (246 excluded). The older replay andidentical-attempt tests pass unchanged.
mix format --check-formatted: clean.check-uuid-v8.sh --stricton a clean export: exit 0.records -> 2 fail; fall back to the provisional id on an invalid one -> 1 fails.
Not done, and limits
check were added). The test for "same ids as before" is a guard, not a failing test.
event_idyet. The producer side is E0-12 (gitbot-fleet), whichalso has to find out whether the runner has
uuid-v8or Bun. Until then every real rowtakes the provisional path. This PR is inert against today's fleet logs, which is the
intended compatibility.
fix-attempts.jsonlis never read as outcomes, as the design says; only a stray startrecord in the outcome file is handled.
imported is treated as a replay and dropped, so a producer could suppress an event by
repeating its id. A producer id equal to a Hypatia-minted local
event_idwould alsocollide in the receipt log (P1 holds, but that row would get no receipt of its own).
The ids are 128-bit and minted by trusted fleet bots, so I did not add a check, but it
is not covered. Say if you want a follow-up.
design rule here, not something this change proves.
Process notes
scripts/api-agents/run-work-order.sh E0-11 --dry-runexits 0 (Sonnet, medium effort,cap USD 6). This session was switched to Opus 5.5 at high effort, above what the work
order names; I did not choose that.