fix(proposals): PR #3581 fresh-review findings — authority invariants, TOCTOU summaries, strict decision routes (cave-v4ep)#3628
Merged
Conversation
…, TOCTOU-safe summaries, strict decision routes (cave-v4ep) Proposal authority invariants bind daemon stagedAt/vetoDeadline/ earliestClose by exact RFC3339 instant at nanosecond precision (null presence must match); TOCTOU-safe proposal summaries; strict decision- route note validation with a shared pure decision-body parser (proposal-decision-body.ts) and exact route forwarding source pins. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens Phase 5 proposal lifecycle handling by enforcing stricter daemon/staged authority invariants, preventing TOCTOU issues when joining staged proposals to daemon summaries, and centralizing decision-route body parsing/validation so approve/reject handlers can’t drift.
Changes:
- Enforce exact-instant (nanosecond) binding for
stagedAt,vetoDeadline, andearliestClose(including null-presence requirements) when verifying daemon authority. - Make daemon proposal summaries TOCTOU-safe by certifying a stable pending snapshot before and after the daemon summary request (fail closed if it changes).
- Introduce a shared pure request-body parser for approve/reject routes and update tests/fixtures to match stricter label + timing contracts.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib/threads-read.test.ts | Expands Phase 5 authority-binding tests (offset-equivalence, nanos precision, strict label/deadline contracts). |
| src/lib/threads-adapters.ts | Adds readPendingSnapshot hashing + stable-snapshot verification to fail closed on pending TOCTOU during summary fetch. |
| src/lib/threads-adapters.test.ts | Adds coverage for TOCTOU-fail-closed behavior and updates expected canonical labels. |
| src/lib/proposal-decision-body.ts | New shared pure parser for decision route bodies (expectedRevision + note validation). |
| src/lib/proposal-authority.ts | Implements instant-based binding (epoch nanos) and stricter approvalPath label/deadline validation + staged veto metadata consistency checks. |
| src/app/api/proposals/[id]/approve/route.ts | Switches to shared parser and forwards parsed values exactly. |
| src/app/api/proposals/[id]/reject/route.ts | Switches to shared parser and forwards parsed values exactly. |
| src/app/api/proposals-flow-e2e.test.ts | Pins route composition to shared parser and adds parser-specific + route-level note validation coverage. |
| src/app/api/api-contracts.test.ts | Extends “effective source” to include the shared parser when validating route contracts. |
| scripts/run-tests.mjs | Adds proposals-flow-e2e test to ALIAS_LOADER wiring. |
| fixtures/phase-5/*.daemon-summary.json | Updates Phase 5 daemon summary fixtures to canonical labels required by the stricter contract. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Follow-up to merged PR #3581, bead cave-v4ep — implements all three fresh-review findings (TDD, verified-but-uncommitted WIP from prior sessions; committed and rebuilt onto current
mainthis session).What changed
stagedAt,vetoDeadline, andearliestClosebind by exact RFC3339 instant at nanosecond precision;earliestClosealso requires matching null presence (src/lib/proposal-authority.ts, threads adapters/read).src/lib/proposal-decision-body.tsused by approve/reject routes, with exact route-forwarding source pins; removed the false-positive 503 note-forwarding claim.Verification (after rebuild onto main 94dbf95)
pnpm test:app— 862 test files greenpnpm typecheckclean;pnpm check:tests-wired— 1164 wired