feat(threads): render daemon-owned Phase 5 proposal lifecycle#3581
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Phase 5 (“daemon-owned”) proposal lifecycle support to the threads proposal surface by binding staged proposals to daemon-supplied authority summaries (revision + identity + lifecycle), and by rendering lifecycle-driven decision actions (Approve/Reject/Veto) with freshness-aware gating.
Changes:
- Introduces Phase 5 authority normalization + canonical revision hashing, and threads adapter joining of staged proposals to daemon lifecycle summaries.
- Updates proposal decision UX to render authority-derived actions, require rationale where mandated, forward expectedRevision, and re-disable actions once the held response becomes stale.
- Adds Phase 5 fixtures plus extensive unit/adapter/route/UI contract tests, including a browser bundle boundary check.
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib/weave-rail.test.ts | Adds an esbuild browser-bundle boundary test to ensure weave rail can bundle without Node built-ins. |
| src/lib/threads-read.ts | Extends proposal view types to include optional authority and exports isRecord for shared normalization helpers. |
| src/lib/threads-read.test.ts | Adds broad Phase 5 authority and canonical-revision behavior coverage plus legacy/Phase 5 interop cases. |
| src/lib/threads-adapters.ts | Joins staged proposals with daemon proposal summaries, adds proposals endpoint constant, and forwards expectedRevision in decisions. |
| src/lib/threads-adapters.test.ts | Expands adapter tests for Phase 5 joins, decision payload shapes, and checked-in Phase 5 fixtures. |
| src/lib/response-envelope-freshness.ts | Adds client-side freshness timer/hook to mark held responses stale at meta.staleAfter without refetching. |
| src/lib/proposal-normalize.ts | Extracts proposal normalization into a shared helper and attaches authority normalization results. |
| src/lib/proposal-flow.ts | Changes decision availability into authority-driven action lists (Approve/Reject/Veto) with optional rationale gating and expectedRevision propagation. |
| src/lib/proposal-flow.test.ts | Updates decision availability tests and adds freshness-timer behavior coverage. |
| src/lib/proposal-authority.ts | Implements Phase 5 authority envelope validation, canonical JSON hashing for revisions, and lifecycle/path mapping with fail-closed semantics. |
| src/components/proposal-approval.tsx | Renders daemon authority trace, authority-derived decision actions, rationale-required note UX, expectedRevision forwarding, and held-response staleness updates. |
| src/components/proposal-approval.test.ts | Updates static/UI contract assertions to enforce action derivation, revision forwarding, and freshness scheduling invariants. |
| src/app/api/proposals/[id]/approve/route.ts | Accepts optional JSON body, validates expectedRevision format, and forwards expectedRevision + note to the adapter. |
| src/app/api/proposals/[id]/reject/route.ts | Accepts optional JSON body, validates expectedRevision format, and forwards expectedRevision + note to the adapter. |
| src/app/api/proposals-flow-e2e.test.ts | Updates route-level tests to cover optional bodies, revision validation, and Phase 5 fixtures presence in proposals listing. |
| src/app/api/api-contracts.test.ts | Extends API route contracts to model “optional JSON body” parsing patterns for proposal decision routes. |
| fixtures/phase-5/awaiting-human-approval.staged-envelope.json | Adds Phase 5 staged envelope fixture for awaiting-human-approval lifecycle. |
| fixtures/phase-5/awaiting-human-approval.daemon-summary.json | Adds corresponding daemon summary fixture for awaiting-human-approval lifecycle. |
| fixtures/phase-5/veto-window-open.staged-envelope.json | Adds Phase 5 staged envelope fixture for veto-window-open lifecycle. |
| fixtures/phase-5/veto-window-open.daemon-summary.json | Adds corresponding daemon summary fixture for veto-window-open lifecycle. |
| fixtures/phase-5/ready-for-replay.staged-envelope.json | Adds Phase 5 staged envelope fixture for ready-for-replay lifecycle. |
| fixtures/phase-5/ready-for-replay.daemon-summary.json | Adds corresponding daemon summary fixture for ready-for-replay lifecycle. |
| fixtures/phase-5/blocked.staged-envelope.json | Adds Phase 5 staged envelope fixture for blocked lifecycle. |
| fixtures/phase-5/blocked.daemon-summary.json | Adds corresponding daemon summary fixture for blocked lifecycle. |
| fixtures/phase-5/unavailable.staged-envelope.json | Adds Phase 5 staged envelope fixture used to represent daemon-unavailable metadata. |
| fixtures/phase-5/unavailable.daemon-summary.json | Adds daemon summary fixture (null) for unavailable metadata case. |
| fixtures/phase-5/mismatched.staged-envelope.json | Adds Phase 5 staged envelope fixture used to exercise daemon mismatch handling. |
| fixtures/phase-5/mismatched.daemon-summary.json | Adds daemon summary fixture used to exercise daemon mismatch handling. |
| fixtures/phase-5/unknown.staged-envelope.json | Adds Phase 5 staged envelope fixture used to exercise unknown lifecycle handling. |
| fixtures/phase-5/unknown.daemon-summary.json | Adds daemon summary fixture with unknown lifecycle value to verify fail-closed behavior. |
| fixtures/phase-5/proposals.json | Adds a combined proposals envelope fixture for adapter join testing and cursor sensitivity. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Member
|
Review complete: no actionable defects found. Focused Phase 5 tests passed (203 tests) and typecheck completed. |
BunsDev
added a commit
that referenced
this pull request
Jul 21, 2026
…, 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>
BunsDev
added a commit
that referenced
this pull request
Jul 21, 2026
…, TOCTOU-safe summaries, strict decision routes (cave-v4ep) (#3628) 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>
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.
Summary
Validation
pnpm typecheckorigin/mainpnpm test:app/pnpm test:apiaggregate suites currently stop at the pre-existingsrc/lib/server/issue-worktree-provision.test.tsexpectation mismatch tracked ascave-s2l8; the same failure reproduces onmainRelated
threads-uqx.7