For agentic workers: REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
Goal: Repair V1 so duplicate boot reads can fan out only when the leader result is current, complete, non-truncated, schema-valid, and no scheduler-visible Brain mutation would execute before the follower.
Architecture: Keep the V1 closed read-only command grammar and conservative pre-lease duplicate boundary. Add defense-in-depth result-envelope validation directly inside the follower UPDATE, and a correlated scheduler-order barrier that blocks any follower whose next execution would be preceded by a non-read-only Brain job. Preserve the existing resultSql-first integration path as the lease/expiry authority; add only bounded helper logic needed by the independent expiry test.
Tech Stack: TypeScript, Val Town std/sqlite, SQLite JSON1.
Spec: valblob:mosadek/project-brain-live-v1-durable/diagnostics/brain_bridge/readonly_coalesce/e72c_second_party_v2.json
Files:
brain_bridge_readonly_coalesce_v1_candidate.tsbrain_bridge_readonly_coalesce_v1_test.tscoalesce_e72c_adv_test.tscoalesce_e72c_boundary_test.tscoalesce_e72c_order_test.tsInterfaces:
Consumes: reviewed V1 candidate and independent tests.
Produces: fresh RED evidence for expiry, truncated/null result, and mutation ordering defects.
Run original 14-assertion source suite and confirm PASS.
Run independent adversarial suite and confirm the reviewed failures.
Run boundary suite and confirm truncated/null failures.
Run ordering suite and confirm intervening mutation violation.
Files:
brain_bridge_readonly_coalesce_v2_test.tscoalesce_v2_regression_test.tsInterfaces:
Consumes: wished-for V2 exports matching V1 names.
Produces: RED tests for closed result envelopes, priority/recover-stale ordering, stale replay, and read-only non-barriers.
Copy the 14 logical source assertions to V2, using a complete valid result envelope.
Add failing tests for extra/missing result keys, nonzero returncode, both truncation flags, and null/malformed envelopes.
Add failing tests for same-priority mutation, higher-priority later mutation, recover-stale rank-0 mutation, same-timestamp ID ordering, and lower-priority mutation that should not block.
Add stale resultSql replay test proving a second result update cannot fan out.
Run V2 tests and verify RED because the V2 module is absent.
Files:
brain_bridge_readonly_coalesce_v2_candidate.tsInterfaces:
Produces: readonlyBrainCommand, coalesceFollowersSql, mayCoalesceSuccessfulLeader, and result-envelope validation helpers.
Port V1 read-only recognition unchanged.
Add exact closed result-envelope validator.
Make follower UPDATE validate ?1 result bytes before changing any follower.
Add correlated NOT EXISTS mutation barrier using recovery-first + capped-priority + created_at,id scheduler ordering.
Add optional lease-expiry rejection when lease_expires_at is present.
Run V2 source/regression tests until GREEN.
Files:
Create V2-import copies of the three e72c suites; preserve scenarios/assertions.
Run adversarial suite; require all checks PASS.
Run boundary suite; require all checks PASS.
Run ordering suite; require PASS.
Re-run original V1 14/14 as baseline and V2 14/14 parity.
Files:
Preserve exact candidate and test bytes/hashes in project-scoped Val Town blobs.
Preserve one JSON receipt with commands/results/hashes/classification.
Compute SHA-256 for candidate/tests.
Store candidate/tests and receipt under evidence/readonly_coalesce_v2/a19c/.
Verify blob readback hashes.
Reconcile current Brain generation.
Commit task result through Brain with evidence URIs/hashes.
Claim next causally ready task.