Skip to content

Commit 8a5deaa

Browse files
docs: complete Codex hook redesign plan
1 parent 2a32c98 commit 8a5deaa

14 files changed

Lines changed: 241 additions & 59 deletions

docs/plans/tracedecay-v2/00-plan-set-index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Core product surfaces:
3939
| [`11-dashboard-frontend.md`](11-dashboard-frontend.md) | Concept-led Evidence Cartography product; stable profile atlas, linked Atlas/Trace/Compare/Lab/Triage compositions, complete memory/skill/automation navigation in Brain and Explorer, Loom replay player, composable lenses, hermetic experiment cockpit, visual ontology/renderers/charts, accessibility/mobile/export, perceptual and comprehension gates. |
4040
| [`12-root-compatibility-migration.md`](12-root-compatibility-migration.md) | Root binary/daemon/CLI/MCP composition and deployment/probe/config/service effect adapters; application-owned integration lifecycle execution; V1 data migration, cutover/rollback/retirement. |
4141
| [`13-research-provenance-and-context-anchors.md`](13-research-provenance-and-context-anchors.md) | Research manifest, durable retrieval anchors, subagent context, corpus hashes/cutoff, source recovery, future implementation handoff. |
42-
| [`14-historical-failure-regression-matrix.md`](14-historical-failure-regression-matrix.md) | Historical problem -> prevention owner -> visible detection/recovery -> cutover regression gate; 146 stable rows (`FM-001` through `FM-146`) with no gaps. |
42+
| [`14-historical-failure-regression-matrix.md`](14-historical-failure-regression-matrix.md) | Historical problem -> prevention owner -> visible detection/recovery -> cutover regression gate; 148 stable rows (`FM-001` through `FM-148`) with no gaps. |
4343
| [`15-search-quality-evaluation-and-retrieval-research.md`](15-search-quality-evaluation-and-retrieval-research.md) | Real local precision corpus, primary retrieval research, hybrid pipeline, qrels/metrics/holdouts, shadow/online evaluation, Search Quality Lab. |
4444
| [`16-cross-project-repository-worktree-scope.md`](16-cross-project-repository-worktree-scope.md) | Exceptional multi-repo/project/worktree/ref/store behavior, `ScopeSelectorV2`, routed retrieval, graph federation, CLI/MCP UX, Rspack/Rsbuild/React Router corpus. |
4545
| [`17-official-public-api-and-sdks.md`](17-official-public-api-and-sdks.md) | Official direct-agent/public API, contract IR/OpenAPI/JSON Schema, stable IDs/errors/cursors/batch/SSE, Rust/TS/Python SDKs, docs/sandbox/conformance. |

docs/plans/tracedecay-v2/01-domain-crate.md

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,8 @@ pub struct PredicateId(String); // private, grammar-validated predicate registry
339339
pub struct HintCategoryId(String); // private, grammar-validated policy category token
340340
pub struct LanguageId(String); // private, grammar-validated language registry token
341341
pub struct BindingId(String); // private, grammar-validated generated catalog binding token
342+
pub struct HostHookBindingId(String); // private, release-manifest-bound catalog hook-binding token
343+
pub struct CodexHookTrustHash(String); // opaque host-owned trust hash; distinct from TraceDecay content digests
342344
pub struct McpLogicalRegistrationId(String); // private, grammar-validated opaque registration identity; semantics owned by plan 08
343345
pub struct McpSurfaceProfileId(String); // private, grammar-validated opaque profile identity; membership/budgets owned by plan 08
344346
pub struct HostSurfaceKindV1(String); // private, grammar-validated opaque host surface identity; registry/evidence owned by plans 08/27
@@ -479,6 +481,60 @@ pub struct HostCapabilitySnapshotV1 {
479481
pub fresh_until: UtcMicros,
480482
pub snapshot_digest: ManifestDigest, // canonical subject/capabilities/times only; excludes this field
481483
}
484+
pub enum HookInvocationScopeV1 { ThreadStart, SubagentStart, Turn }
485+
pub enum HookDefinitionRepresentationV1 { JsonFile, InlineToml, PluginDefaultFile, PluginManifestPath, PluginManifestPathArray, PluginManifestInline, PluginManifestInlineArray, ManagedInline }
486+
pub enum HostConfigLayerV1 { System, Cloud, Mdm, ManagedRequirements, User, Project, Session, Plugin }
487+
pub struct HostConfigSourceV1 {
488+
pub source_id: EntityId,
489+
pub layer: HostConfigLayerV1,
490+
pub representation: HookDefinitionRepresentationV1,
491+
pub managed: bool,
492+
pub project_layer_trusted: Option<bool>,
493+
pub source_digest: ManifestDigest,
494+
}
495+
pub enum HookDefinitionProvenanceV1 {
496+
Resolved(HostConfigSourceV1),
497+
Ambiguous { candidate_source_ids: BoundedVec<EntityId, 16>, coverage: CoverageReportV1 },
498+
GeneratedBindingOnly { binding: HostHookBindingId, coverage: CoverageReportV1 },
499+
}
500+
pub struct HookDefinitionRefV1 {
501+
pub provenance: HookDefinitionProvenanceV1,
502+
pub content_digest: ManifestDigest,
503+
pub host_trust_hash: Option<CodexHookTrustHash>,
504+
pub catalog_binding: Option<HostHookBindingId>,
505+
pub matcher_group_ordinal: u16,
506+
pub handler_ordinal: u16,
507+
pub managed: bool,
508+
pub bundle_digest: Option<ManifestDigest>,
509+
}
510+
pub struct HookHandlerRunRefV1 { pub run_id: EntityId, pub definition: HookDefinitionRefV1, pub attempt: u16 }
511+
pub struct HookInvocationGroupRefV1 { pub group_id: EntityId, pub host_event_identity_digest: ManifestDigest }
512+
pub enum PermissionBehaviorV1 { Allow, Deny, NoDecision }
513+
pub enum HookContinuationTargetV1 { Turn, Subagent }
514+
pub enum HookHandlerResultV1 { Succeeded, TimedOut, Exited { code: i32 }, InvalidOutput { reason: RegistryEntryId }, SkippedUnsupported, SkippedTrust }
515+
pub enum HostHookTrustStateV1 { NeedsReview, Trusted, ManagedTrusted, Unknown }
516+
pub enum HostHookEligibilityStateV1 { Eligible, DisabledByUser, SkippedUntrustedProject, SkippedManagedOnly, SkippedFeatureDisabled }
517+
pub enum HostHookHandlerSupportV1 { SupportedCommand, UnsupportedPrompt, UnsupportedAgent, UnsupportedAsync }
518+
pub enum HostHookDefinitionFreshnessV1 { Current, ChangedSinceReview }
519+
pub enum HostHookTrustRequirementV1 { ExactHashUserReview, ManagedPolicy }
520+
pub enum HostHookRunVisibilityV1 { TraceDecayOwned, HostObserved, Unobservable }
521+
pub struct HostHookTrustReceiptRefV1 {
522+
pub receipt_id: EntityId,
523+
pub host_trust_hash: CodexHookTrustHash,
524+
pub content_digest: ManifestDigest,
525+
pub codex_version: ComponentVersion,
526+
pub source_id: EntityId,
527+
pub managed_generation: Option<u64>,
528+
}
529+
pub struct HostHookDefinitionObservationV1 {
530+
pub definition: HookDefinitionRefV1,
531+
pub trust: HostHookTrustStateV1,
532+
pub eligibility: HostHookEligibilityStateV1,
533+
pub handler_support: HostHookHandlerSupportV1,
534+
pub freshness: HostHookDefinitionFreshnessV1,
535+
pub trust_receipt: Option<HostHookTrustReceiptRefV1>,
536+
pub run_visibility: HostHookRunVisibilityV1,
537+
}
482538
pub struct SkillVersionRef {
483539
pub skill_id: SkillId,
484540
pub version: EntityVersionId,
@@ -3022,14 +3078,15 @@ git commit -m "feat(domain): define stable v2 identity"
30223078
- Create: `crates/tracedecay-domain/src/replay.rs`
30233079
- Create: `crates/tracedecay-domain/src/protocol.rs`
30243080
- Create: `crates/tracedecay-domain/src/payload.rs`
3081+
- Create: `crates/tracedecay-domain/src/hooks_v1.rs`
30253082
- Create: `crates/tracedecay-domain/tests/ownership_contract.rs`
30263083
- Create: `crates/tracedecay-domain/tests/retention_contract.rs`
30273084
- Create: `crates/tracedecay-domain/tests/replay_contract.rs`
30283085
- Create: `crates/tracedecay-domain/tests/protocol_contract.rs`
30293086

30303087
- [ ] **Step 1: Write failing boundary tests**
30313088

3032-
Assert activity ownership for canonical messages and experiments; project ownership for Git/code; activity ownership for profile-scoped facts/skills/policy/automation; project ownership for project-scoped equivalents; rejection of missing/ambiguous declared scope; catalog rejection of literal strings; blob-domain inequality across privacy/key/retention domains; the exact Plan 18 `SanitizationReceiptV1` field set, findings-total invariant, expiry/revocation/supersession validation, canonical-schema round trip, and rejection of receipt cycles or cross-observation supersession; half-open time behavior; exact-cutoff retention; hold precedence; the seven content-horizon defaults; requested/actual replay invariants; one baseline/at-most-six variants; sole acyclic experiment branch ancestry; explicit sweep values, checked full-coordinate expansion, hard total-cell rejection, and unique run-cell coordinates; anchors for experiment/run/cell/stage/comparison/comparison-cell/reduction; running trace without and terminal trace with sealed receipt; complete resource budgets; a side-effect receipt whose production effect count is zero; automation invariants for all trigger frontiers, typed field selectors, sorted per-shard current/considered/consumed/included frontiers, fresh writer snapshot/quiescence, unknown/partial deferral, semantic-versus-evaluation digests, admitted-only identical-input fencing, pre-admission considered transitions, terminal consumed-cursor advancement, coalesced input-bound skip episodes, and exactly-once effect reconciliation; and host-integration invariants for one source-manifest digest, at most four unique components, exact install receipt/generation, typed capability dispositions, probe freshness/digest, no secret/path fields, and handshake failure on stale or mismatched component/catalog/probe identity.
3089+
Assert activity ownership for canonical messages and experiments; project ownership for Git/code; activity ownership for profile-scoped facts/skills/policy/automation; project ownership for project-scoped equivalents; rejection of missing/ambiguous declared scope; catalog rejection of literal strings; blob-domain inequality across privacy/key/retention domains; the exact Plan 18 `SanitizationReceiptV1` field set, findings-total invariant, expiry/revocation/supersession validation, canonical-schema round trip, and rejection of receipt cycles or cross-observation supersession; half-open time behavior; exact-cutoff retention; hold precedence; the seven content-horizon defaults; requested/actual replay invariants; one baseline/at-most-six variants; sole acyclic experiment branch ancestry; explicit sweep values, checked full-coordinate expansion, hard total-cell rejection, and unique run-cell coordinates; anchors for experiment/run/cell/stage/comparison/comparison-cell/reduction; running trace without and terminal trace with sealed receipt; complete resource budgets; a side-effect receipt whose production effect count is zero; automation invariants for all trigger frontiers, typed field selectors, sorted per-shard current/considered/consumed/included frontiers, fresh writer snapshot/quiescence, unknown/partial deferral, semantic-versus-evaluation digests, admitted-only identical-input fencing, pre-admission considered transitions, terminal consumed-cursor advancement, coalesced input-bound skip episodes, and exactly-once effect reconciliation; host-integration invariants for one source-manifest digest, at most four unique components, exact install receipt/generation, typed capability dispositions, probe freshness/digest, no secret/path fields, and handshake failure on stale or mismatched component/catalog/probe identity; and hook-contract round trips for resolved/ambiguous/generated-only provenance, orthogonal trust/eligibility/support/freshness/visibility, exact host-trust-hash/content-digest separation, and no fabricated source/run identity.
30333090

30343091
- [ ] **Step 2: Verify failure**
30353092

@@ -3039,7 +3096,7 @@ Expected: FAIL with unresolved ownership and retention types.
30393096

30403097
- [ ] **Step 3: Implement the ownership and retention matrices**
30413098

3042-
Implement `ShardKind`, `ShardRef`, `DeclaredScope`, `BlobDomainId`, `CatalogValue`, `UtcMicros`, `TimeInterval`, the Plan 18 `DataSensitivity`/receipt/taint/sink-eligibility types, `RetentionClass`, `RetentionPolicyV1`, `EvidenceRetentionWatermark`, the complete replay manifest/fidelity/branch/experiment/variant/run/cell/stage/comparison/comparison-cell/reduction/resource-budget/receipt family, the automation input-contract/manifest/frontier/quiescence/admission/skip-episode family, `SurfaceKind`, opaque `HostSurfaceKindV1`/`McpLogicalRegistrationId`/`McpSurfaceProfileId`, `HostInstallScopeV1`, `HostCapabilityDispositionV1`, `HostBundleComponentRefV1`, `HostIntegrationRuntimeRefV1`, `HostCapabilitySubjectV1`, `HostCapabilitySnapshotV1`, `RuntimeHandshakeV1`, `PayloadRef`, and reasoning format/visibility. Put kind-plus-declared-scope ownership in one exhaustive match so a new kind or scope class causes a compile error.
3099+
Implement `ShardKind`, `ShardRef`, `DeclaredScope`, `BlobDomainId`, `CatalogValue`, `UtcMicros`, `TimeInterval`, the Plan 18 `DataSensitivity`/receipt/taint/sink-eligibility types, `RetentionClass`, `RetentionPolicyV1`, `EvidenceRetentionWatermark`, the complete replay manifest/fidelity/branch/experiment/variant/run/cell/stage/comparison/comparison-cell/reduction/resource-budget/receipt family, the automation input-contract/manifest/frontier/quiescence/admission/skip-episode family, `SurfaceKind`, opaque `HostSurfaceKindV1`/`McpLogicalRegistrationId`/`McpSurfaceProfileId`, `HostInstallScopeV1`, `HostCapabilityDispositionV1`, `HostBundleComponentRefV1`, `HostIntegrationRuntimeRefV1`, `HostCapabilitySubjectV1`, `HostCapabilitySnapshotV1`, the complete hook binding/source/provenance/definition/run/group/trust/eligibility/support/freshness/visibility/permission/continuation/result family above in `crates/tracedecay-domain/src/hooks_v1.rs`, `RuntimeHandshakeV1`, `PayloadRef`, and reasoning format/visibility. Hook provenance must round-trip resolved, ambiguous candidate-set, and generated-binding-only cases without fabricating a source; Codex trust hash never compares as a TraceDecay content digest. Put kind-plus-declared-scope ownership in one exhaustive match so a new kind or scope class causes a compile error.
30433100

30443101
- [ ] **Step 4: Verify pass and schema serialization**
30453102

@@ -3050,7 +3107,7 @@ Expected: PASS.
30503107
- [ ] **Step 5: Commit**
30513108

30523109
```bash
3053-
git add crates/tracedecay-domain/src/ownership.rs crates/tracedecay-domain/src/time.rs crates/tracedecay-domain/src/privacy.rs crates/tracedecay-domain/src/retention.rs crates/tracedecay-domain/src/replay.rs crates/tracedecay-domain/src/protocol.rs crates/tracedecay-domain/src/payload.rs crates/tracedecay-domain/tests/ownership_contract.rs crates/tracedecay-domain/tests/retention_contract.rs crates/tracedecay-domain/tests/replay_contract.rs crates/tracedecay-domain/tests/protocol_contract.rs
3110+
git add crates/tracedecay-domain/src/ownership.rs crates/tracedecay-domain/src/time.rs crates/tracedecay-domain/src/privacy.rs crates/tracedecay-domain/src/retention.rs crates/tracedecay-domain/src/replay.rs crates/tracedecay-domain/src/protocol.rs crates/tracedecay-domain/src/payload.rs crates/tracedecay-domain/src/hooks_v1.rs crates/tracedecay-domain/tests/ownership_contract.rs crates/tracedecay-domain/tests/retention_contract.rs crates/tracedecay-domain/tests/replay_contract.rs crates/tracedecay-domain/tests/protocol_contract.rs
30543111
git commit -m "feat(domain): lock ownership and retention semantics"
30553112
```
30563113

0 commit comments

Comments
 (0)