spec(phase-4): Cave surfaces data contract (threads-986.17.1)#1
Merged
Conversation
…shness, fail-closed rendering Written first per threads-986.17.1, before any UI code. OpenTrust MEMORY-API-CONTRACT shape (contract-first, freshness everywhere, evidence over summaries), coven-cave stack. Covers: read models (TensionView with UI-only unknown/stale fail-closed states, Weave/ Thread/Strand views, ward_audit row, PendingProposal), eight API routes (approve/reject as thin daemon-forwarders), response envelope (observedAt/staleAfter/sourceCursor), R1-R11 fail-closed rendering enumeration, metaphor-referent UI glossary. Co-authored-by: Sage <sage@opencoven.local> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
BunsDev
marked this pull request as ready for review
July 17, 2026 14:35
There was a problem hiding this comment.
Pull request overview
Adds the Phase 4 “Cave surfaces” contract spec that defines the read models, API routes, response envelope freshness metadata, and fail-closed rendering rules for the Coven Cave UI to consume daemon memory state (fixtures-first until daemon integration lands).
Changes:
- Introduces a new contract document (
PHASE-4-CAVE-SURFACES.md) describing sources of truth, adapters, and normalized UI-facing JSON read models. - Specifies the Phase 4 API surface (8 routes) and a uniform response envelope with freshness/verification metadata.
- Enumerates fail-closed rendering rules (R1–R11) and a glossary binding metaphor terms to referents for UI copy.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+108
to
+112
| { | ||
| "id": "weave-uuid", | ||
| "familiarId": "sage", // human-readable id, as ward_audit stores it | ||
| "threadCount": 4, | ||
| "tensionRollup": { "state": "frayed", "…": "worst contained thread state; §4.R1" }, |
Comment on lines
+187
to
+191
| "eventType": "proposal_submitted|proposal_approved|proposal_rejected|proposal_vetoed|ward_updated|validation_verdict|compaction_ledger", | ||
| "proposalId": "uuid | null", | ||
| "familiarId": "sage", | ||
| "wardVersion": "string | null", | ||
| "wardHash": "hex", // weave_hash at decision time — binds decision to authority state |
|
|
||
| | # | Route | Method | Returns | | ||
| |---|---|---|---| | ||
| | 1 | `/api/weaves` | GET | `WeaveSummary[]` — optional `?familiar=<id>` filter | |
BunsDev
added a commit
that referenced
this pull request
Jul 18, 2026
…uqx) Add substantive annotations from Sage and Echo review (2026-07-18): Decision #1: rationale callback — ApprovalPath is authoritative, Channel is derived; if enforcement rule shifts, revisit all eight decisions. Decision #2: audit implication — close event needs reason field (applied|vetoed|expired|superseded); delayed-apply without it is a post-hoc audit black hole. Decision #3: forward-only promotion — retroactive region projection corrupts authority trail with apparently-authored writes from before promotion. Decision #4: fail-closed on extraction ambiguity — not silent LLM fallback; ambiguity is an explicit ignored/blocked state. Decision #5: RFC provenance pointer added. Decision #6: Cave ProposalView labeled [DESIGNED, NOT SHIPPED] from the start. Decision #7: label-variant round-trip is daemon wire contract (load-time reject on drift); Cave has zero policy freedom over label strings. Decision #8: proposal_window_opened paired with close event; window is a first-class audit interval. threads-uqx.3 design constraints (Sage): evidence_replay_hash on ProposalClassification; VetoWindow.min_visible: Duration; label mapping as daemon wire contract. Co-authored-by: Sage <sage@opencoven.dev> Co-authored-by: Echo <echo@opencoven.dev> Co-authored-by: Nova <nova@opencoven.dev>
BunsDev
added a commit
that referenced
this pull request
Jul 21, 2026
* spec(proposal): draft Phase 5 approval semantics
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* spec(phase-4): align route-1 Returns with WeaveListView shape (threads-k9s)
Cave implementation wraps route-1 data as { weaves, degraded } rather than
overloading a WeaveSummary[] with degraded entries — the wrapped shape avoids
any fabricated health fields on degraded familiars. Same-day alignment of the
2026-07-18 §2.7/R12 amendment.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* spec(phase-5): record Val+Nova decisions, open Phase 5 (threads-uqx)
All 8 open questions resolved on Sage's recommended defaults:
- ApprovalPath separate from Channel (load axis preserved)
- Delayed apply only for veto windows (fail-closed posture)
- Classify-first for harness regions
- Deterministic + probe for invariants (not LLM-judge-only)
- RFC #3/#4 blocker resolved (familiar-contract@2a5bb98)
- Daemon contract before Cave ProposalView extension
- Display labels preserved, typed variants internal
- proposal_window_opened audit event lands with delayed apply
Rename PHASE-5-PROPOSAL -> PHASE-5-APPROVAL-SEMANTICS to reflect open status.
Co-authored-by: Nova <nova@opencoven.dev>
* spec(phase-5): fold Sage + Echo review into decision record (threads-uqx)
Add substantive annotations from Sage and Echo review (2026-07-18):
Decision #1: rationale callback — ApprovalPath is authoritative, Channel is
derived; if enforcement rule shifts, revisit all eight decisions.
Decision #2: audit implication — close event needs reason field
(applied|vetoed|expired|superseded); delayed-apply without it is a post-hoc
audit black hole.
Decision #3: forward-only promotion — retroactive region projection corrupts
authority trail with apparently-authored writes from before promotion.
Decision #4: fail-closed on extraction ambiguity — not silent LLM fallback;
ambiguity is an explicit ignored/blocked state.
Decision #5: RFC provenance pointer added.
Decision #6: Cave ProposalView labeled [DESIGNED, NOT SHIPPED] from the start.
Decision #7: label-variant round-trip is daemon wire contract (load-time reject
on drift); Cave has zero policy freedom over label strings.
Decision #8: proposal_window_opened paired with close event; window is a
first-class audit interval.
threads-uqx.3 design constraints (Sage): evidence_replay_hash on
ProposalClassification; VetoWindow.min_visible: Duration; label mapping as
daemon wire contract.
Co-authored-by: Sage <sage@opencoven.dev>
Co-authored-by: Echo <echo@opencoven.dev>
Co-authored-by: Nova <nova@opencoven.dev>
* feat(audit): add ApplyAudit event type, detail column, migration SQL (v0.1.4)
Closes coven-threads#5. Unblocks coven#414.
Changes:
- AuditEventType::ApplyAudit variant + apply_audit CHECK tag
- WardAuditRecord.detail: nullable JSON column for event-specific payload
- WardAuditRecord::for_apply() constructor
- apply_prev_sha256_hex() / apply_bytes_written() decode helpers
- WARD_AUDIT_MIGRATION_V014_SQL: transaction rebuild for v0.1.3 stores
- APPLY_AUDIT_DETAIL_KEY_PREV / _BYTES stable constants
- Exhaustiveness test extended; 3 new tests (shape, roundtrip, migration)
- Workspace version bumped 0.1.3 -> 0.1.4
- CHANGELOG.md created
Design: prev_sha256+bytes_written ride in detail JSON (Option A);
migration exports SQL constant, no rusqlite dep added (Option B-lite).
Bead: threads-3ym
* review(audit): add user_version ladder + explicit detail invariant doc
Addresses two Sage review notes (neither was blocking):
1. WARD_AUDIT_MIGRATION_V014_SQL now stamps PRAGMA user_version = 14
inside the transaction. Future migrations gate on 'user_version < N'
instead of substring-sniffing sqlite_master DDL. Migration doc-comment
updated to name the gate rule and explain the intentional non-idempotence
of the CREATE step (double-run fails loudly, not silently).
2. WardAuditRecord::detail doc-comment now names the full invariant for
ApplyAudit rows (prev_sha256 hex 64 chars + bytes_written u64) and
explicitly states other event types MAY leave it None or use their
own documented shape. Turns the implicit decoder contract into a
searchable spec.
CHANGELOG updated. Tests still green, clippy clean.
* feat(phase-5): core approval types — ApprovalPath, VetoWindow, ProposalClassification (threads-uqx.3)
Adds crates/coven-threads-core/src/approval.rs with the Phase-5 core type
sketch from specs/PHASE-5-APPROVAL-SEMANTICS.md §3, decisions 1/2/7/8.
Types introduced:
- ApprovalPath (AutoRegression | FamiliarCoherence | HumanApproval |
HumanApprovalWithRationale) — promotion ceremony, separate from Channel
- ApprovalPathKind — variant without inner fields for label round-trip
- VetoWindow — delayed-apply only; min_visible + duration; deadline helpers
- ProposalClassification — channel, regions, tier floor, approval_path,
evidence_replay_hash (WARD-C7 generalised)
- SurfaceRegionId — opaque region ref, full predicate in uqx.5
- WindowCloseReason — applied | vetoed | expired | superseded (decision 2+8)
- ProposalWindowAuditDetail / ProposalWindowCloseAuditDetail — detail payloads
for proposal_window_opened and close events
- ApprovalPathWireEnvelope — daemon wire format {variant, label, veto_deadline}
Key constraints enforced:
- ApprovalPath != Channel (decision 1); highest ceremony wins
- VetoWindow is delayed-apply only; min_visible <= duration (decision 2)
- display_label() + from_display_label() round-trip is exhaustive; unknown
labels return None so daemon rejects at load (decision 7)
- evidence_replay_hash on ProposalClassification (WARD-C7)
Tests: 15 passing (all approval tests green; full suite 90 passing)
Closes #8
* feat(phase-5): identity invariant predicates + advisory probes (threads-uqx.4)
Adds crates/coven-threads-core/src/identity_invariants.rs.
Types / implementations:
- FamiliarNameInvariant: PatternPredicate over Blake3 content hash of an
identity surface (e.g. IDENTITY.md). Fails closed on mismatch, snapped
thread, or missing thread (decision 4: ambiguity → reject, not fallback).
- ManifestAnchoredInvariant: PatternPredicate over manifest entry hash;
holds under Forced channel (WARD-C1..C6: must survive compaction).
- CompositeIdentityInvariant: all-components-must-hold composite predicate;
identity invariant is a unit — no partial pass.
- AdvisoryProbeResult: Gate-3 supplementary evidence shape; is_authoritative
always false; confidence validated in [0.0, 1.0].
- AdvisoryProbes: the advisory_probes block (Q4 decision) — separate from
deterministic probes block; empty means 'no advisory signals ran'.
Key constraints enforced:
- Predicate-first; no new strand kind (decision 3/4)
- Fail-closed on ambiguity (decision 4)
- advisory_probes structurally separate from probes; never sole authority
- descriptor is derived, never enforced on (§2.3)
Tests: 16 new (identity_invariants::tests), all passing.
Full suite: 106 tests, 0 failures.
Closes #9
* feat(phase-5): SurfaceRegionPredicate + Gate-4 replay (threads-uqx.5)
Adds crates/coven-threads-core/src/surface_regions.rs.
Types introduced:
- MaterializedDiff / SurfaceDiff: pure diff input; predicates are pure
functions of this (Gate-4 replay constraint — no Cave state, no stale
metadata, no agent self-report)
- RegionEvidence: predicate output; feeds ProposalClassification.affected_regions
and evidence_replay_hash; includes replay_bytes for Gate-4 deadline check
- SurfaceRegionDescriptor: derived, Cave-renderable, never enforced on
- SurfaceRegionPredicate trait: materialize (authoritative) + describe (derived)
- ExecutionPromptRegion: SOUL.md / AGENTS.md, tier-0 floor, human review
- ToolDefaultsRegion: TOOLS.md, tier-1 floor, familiar review
- HeartbeatBehaviorRegion: HEARTBEAT.md, tier-1 floor
- SurfaceRegionRegistry: classify_all + descriptors + path_tier_floor helper
Key constraints enforced:
- Classify-first; threads stay source-bound (decision 3)
- materialize is pure over MaterializedDiff — daemon-replayable at Gate-4
- replay_bytes are deterministic (sorted surface order)
- path_tier_floor = min across evidence (most protective wins)
- SurfaceRegionDescriptor never enforced on
Tests: 12 new (surface_regions::tests), all passing.
Full suite: 118 tests, 0 failures.
Closes #10
* spec(phase-5): resolve coherence review findings
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* feat(phase-5): harden authority-boundary core
Bind semantic identity evidence into Gate-4 validation, commit replay to the complete materialized diff, validate wire contracts, and make proposal audit lifecycle persistence fail closed while preserving legacy history.
Bump the breaking public API to 0.2.0 and cover the retired invariant corpus, delayed approval semantics, schema migration paths, and append-only terminal behavior.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Document Phase 5 and harden approval contracts
Updates docs and status pages to reflect Phase 4 freeze and active Phase 5 approval semantics, including a new delayed-apply scheduler diagram and expanded architecture/FAQ/glossary guidance.
In `coven-threads-core`, tightens fail-closed behavior by requiring the `auto_regression.veto` wire key, preserving stronger veto windows across path promotion, validating `ApplyAudit` detail shape and event-type accessors, enforcing advisory probe validation at deserialization, adding `#[must_use]` on key APIs, and expanding tests around these contracts.
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Nova <nova@opencoven.dev>
Co-authored-by: Sage <sage@opencoven.dev>
Co-authored-by: Echo <echo@opencoven.dev>
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.
Phase 4 opening deliverable per bead threads-986.17.1 — the written contract between coven daemon memory state (weaves, tension,
ward_audit,~/.coven/pending/staged writes) and the Cave UI, written before any UI code.OpenTrust
MEMORY-API-CONTRACT.mdshape (contract-first, freshness metadata everywhere, evidence over summaries) — coven-cave stack, nothing vendored.Covers:
TensionView(crate's 3 states + UI-onlyunknown/stalefail-closed states),WeaveSummary/WeaveDetail,ThreadView,StrandView(+ Frayed current-vs-expected diff),AuditEntryView,ProposalViewobservedAt/staleAfter/sourceCursor/adapter/verifiedon every responseEpic: threads-986.17 · Phase 3 freeze verified (
.14,.11closed) · fixtures-first until.19merges.