Skip to content

feat(threads): render daemon-owned Phase 5 proposal lifecycle#3581

Merged
BunsDev merged 9 commits into
mainfrom
feat/phase5-veto-contract
Jul 21, 2026
Merged

feat(threads): render daemon-owned Phase 5 proposal lifecycle#3581
BunsDev merged 9 commits into
mainfrom
feat/phase5-veto-contract

Conversation

@BunsDev

@BunsDev BunsDev commented Jul 20, 2026

Copy link
Copy Markdown
Member

Summary

  • join staged proposals to daemon-owned lifecycle summaries with canonical revision, identity, timestamp, and target binding
  • fail closed on unavailable, mismatched, unknown, corrupt, and stale authority while preserving Phase 4 legacy review behavior
  • forward inspected proposal revisions and render lifecycle-specific Approve, Reject, and Veto actions with rationale requirements
  • add checked-in Phase 5 lifecycle fixtures and adapter, route, flow, component, and freshness coverage

Validation

  • focused proposal/read/adapter/flow/component/API suites
  • pnpm typecheck
  • fresh-context contract and code review
  • rebased onto current origin/main
  • pnpm test:app / pnpm test:api aggregate suites currently stop at the pre-existing src/lib/server/issue-worktree-provision.test.ts expectation mismatch tracked as cave-s2l8; the same failure reproduces on main

Related

BunsDev and others added 9 commits July 20, 2026 06:15
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>
Copilot AI review requested due to automatic review settings July 20, 2026 11:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@CompleteDotTech

Copy link
Copy Markdown
Member

Review complete: no actionable defects found. Focused Phase 5 tests passed (203 tests) and typecheck completed.

@BunsDev
BunsDev merged commit 1a494fa into main Jul 21, 2026
16 checks passed
@BunsDev
BunsDev deleted the feat/phase5-veto-contract branch July 21, 2026 12:08
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants