agentic-orchestrator 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +6 -1
- package/README.md +81 -54
- package/agentic/orchestrator/defaults/policy.defaults.yaml +212 -0
- package/agentic/orchestrator/schemas/adapters.schema.json +17 -4
- package/agentic/orchestrator/schemas/agents.schema.json +58 -13
- package/agentic/orchestrator/schemas/gates.schema.json +88 -17
- package/agentic/orchestrator/schemas/index.schema.json +172 -37
- package/agentic/orchestrator/schemas/multi-project.schema.json +85 -17
- package/agentic/orchestrator/schemas/plan.schema.json +135 -30
- package/agentic/orchestrator/schemas/policy.schema.json +198 -69
- package/agentic/orchestrator/schemas/policy.user.schema.json +165 -0
- package/agentic/orchestrator/schemas/qa_test_index.schema.json +71 -14
- package/agentic/orchestrator/schemas/state.schema.json +196 -39
- package/apps/control-plane/scripts/validate-architecture-rules.mjs +5 -3
- package/apps/control-plane/scripts/validate-docker-mcp-contract.mjs +0 -3
- package/apps/control-plane/scripts/validate-mcp-contracts.ts +2 -6
- package/apps/control-plane/src/application/services/policy-loader-service.ts +115 -0
- package/apps/control-plane/src/cli/aop.ts +35 -1
- package/apps/control-plane/src/cli/cli-argument-parser.ts +4 -0
- package/apps/control-plane/src/cli/help-command-handler.ts +2 -1
- package/apps/control-plane/src/cli/init-command-handler.ts +136 -27
- package/apps/control-plane/src/cli/retry-command-handler.ts +3 -6
- package/apps/control-plane/src/cli/types.ts +1 -0
- package/apps/control-plane/src/core/git.ts +1 -3
- package/apps/control-plane/src/core/kernel.ts +3 -6
- package/apps/control-plane/src/core/schemas.ts +36 -1
- package/apps/control-plane/src/interfaces/cli/bootstrap.ts +1 -1
- package/apps/control-plane/src/mcp/tool-registry-loader.ts +37 -1
- package/apps/control-plane/src/supervisor/qa-wave-executor.ts +1 -1
- package/apps/control-plane/test/aop.spec.ts +37 -0
- package/apps/control-plane/test/batch-operations.spec.ts +5 -3
- package/apps/control-plane/test/bootstrap-attach.spec.ts +28 -18
- package/apps/control-plane/test/bootstrap-edge-cases.spec.ts +25 -15
- package/apps/control-plane/test/bootstrap.spec.ts +30 -22
- package/apps/control-plane/test/cli.unit.spec.ts +55 -10
- package/apps/control-plane/test/core-utils.spec.ts +12 -3
- package/apps/control-plane/test/feature-deletion-service.spec.ts +2 -1
- package/apps/control-plane/test/feature-lifecycle.spec.ts +1 -1
- package/apps/control-plane/test/helpers.ts +22 -2
- package/apps/control-plane/test/init-wizard.spec.ts +160 -7
- package/apps/control-plane/test/issue-tracker.spec.ts +3 -3
- package/apps/control-plane/test/kernel.spec.ts +62 -0
- package/apps/control-plane/test/lock-service.spec.ts +4 -4
- package/apps/control-plane/test/policy-loader-service.spec.ts +346 -0
- package/apps/control-plane/test/reactions.spec.ts +8 -6
- package/apps/control-plane/test/resume-command.spec.ts +31 -15
- package/apps/control-plane/test/supervisor.unit.spec.ts +2 -2
- package/apps/control-plane/test/tool-registry-loader.spec.ts +12 -0
- package/apps/control-plane/vitest.config.ts +1 -1
- package/dist/apps/control-plane/application/services/policy-loader-service.d.ts +24 -0
- package/dist/apps/control-plane/application/services/policy-loader-service.js +90 -0
- package/dist/apps/control-plane/application/services/policy-loader-service.js.map +1 -0
- package/dist/apps/control-plane/application/tools/tool-metadata.js +1 -0
- package/dist/apps/control-plane/application/tools/tool-metadata.js.map +1 -1
- package/dist/apps/control-plane/cli/aop.js +33 -1
- package/dist/apps/control-plane/cli/aop.js.map +1 -1
- package/dist/apps/control-plane/cli/cli-argument-parser.js +4 -0
- package/dist/apps/control-plane/cli/cli-argument-parser.js.map +1 -1
- package/dist/apps/control-plane/cli/dashboard-command-handler.js +11 -5
- package/dist/apps/control-plane/cli/dashboard-command-handler.js.map +1 -1
- package/dist/apps/control-plane/cli/help-command-handler.js +5 -4
- package/dist/apps/control-plane/cli/help-command-handler.js.map +1 -1
- package/dist/apps/control-plane/cli/init-command-handler.d.ts +1 -0
- package/dist/apps/control-plane/cli/init-command-handler.js +110 -26
- package/dist/apps/control-plane/cli/init-command-handler.js.map +1 -1
- package/dist/apps/control-plane/cli/retry-command-handler.js +3 -6
- package/dist/apps/control-plane/cli/retry-command-handler.js.map +1 -1
- package/dist/apps/control-plane/cli/types.d.ts +1 -0
- package/dist/apps/control-plane/core/git.js +1 -3
- package/dist/apps/control-plane/core/git.js.map +1 -1
- package/dist/apps/control-plane/core/kernel.js +3 -5
- package/dist/apps/control-plane/core/kernel.js.map +1 -1
- package/dist/apps/control-plane/core/schemas.d.ts +2 -0
- package/dist/apps/control-plane/core/schemas.js +31 -1
- package/dist/apps/control-plane/core/schemas.js.map +1 -1
- package/dist/apps/control-plane/interfaces/cli/bootstrap.js +1 -1
- package/dist/apps/control-plane/interfaces/cli/bootstrap.js.map +1 -1
- package/dist/apps/control-plane/mcp/tool-registry-loader.d.ts +2 -0
- package/dist/apps/control-plane/mcp/tool-registry-loader.js +31 -1
- package/dist/apps/control-plane/mcp/tool-registry-loader.js.map +1 -1
- package/dist/apps/control-plane/supervisor/build-wave-executor.js +1 -1
- package/dist/apps/control-plane/supervisor/build-wave-executor.js.map +1 -1
- package/dist/apps/control-plane/supervisor/qa-wave-executor.js +1 -1
- package/dist/apps/control-plane/supervisor/qa-wave-executor.js.map +1 -1
- package/package.json +18 -17
- package/packages/web-dashboard/package.json +1 -1
- package/packages/web-dashboard/src/app/api/actions/route.ts +2 -2
- package/packages/web-dashboard/src/app/api/events/route.ts +1 -1
- package/packages/web-dashboard/src/app/api/features/[id]/checkout/route.ts +1 -1
- package/packages/web-dashboard/src/app/api/features/[id]/diff/route.ts +1 -1
- package/packages/web-dashboard/src/app/api/features/[id]/evidence/[artifact]/route.ts +1 -1
- package/packages/web-dashboard/src/app/api/features/[id]/review/route.ts +2 -2
- package/packages/web-dashboard/src/app/api/features/[id]/route.ts +1 -1
- package/packages/web-dashboard/src/app/api/projects/route.ts +2 -2
- package/packages/web-dashboard/src/app/api/status/route.ts +1 -1
- package/packages/web-dashboard/src/app/page.tsx +1 -1
- package/packages/web-dashboard/src/lib/aop-client.ts +1 -1
- package/packages/web-dashboard/src/lib/orchestrator-tools.ts +1 -1
- package/packages/web-dashboard/tsconfig.json +1 -0
- package/spec-files/completed/agentic_orchestrator_init_policy_ux_simplification_spec.md +481 -0
- package/spec-files/outstanding/agentic_orchestrator_artifact_database_publishing_spec.md +500 -0
- package/spec-files/outstanding/agentic_orchestrator_observability_integrity_diagnostics_spec.md +500 -195
- package/spec-files/outstanding/agentic_orchestrator_performance_improvements_spec.md +471 -162
- package/spec-files/outstanding/agentic_orchestrator_planning_review_quality_spec.md +532 -268
- package/spec-files/outstanding/agentic_orchestrator_productization_commercial_spec.md +645 -0
- package/spec-files/progress.md +99 -2
- package/tsconfig.base.json +4 -0
- /package/spec-files/{outstanding → completed}/agentic_orchestrator_validator_hardening_spec.md +0 -0
package/spec-files/outstanding/agentic_orchestrator_observability_integrity_diagnostics_spec.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Feature Spec: Observability, Evidence Integrity, and Operational Diagnostics (AOP)
|
|
2
2
|
|
|
3
|
-
> **Purpose of this document**:
|
|
3
|
+
> **Purpose of this document**: Provide implementation-ready delivery for Q3, Q4, and Q11 with an explicit architectural critique of the prior draft and a corrected execution plan aligned to the current control-plane/runtime architecture.
|
|
4
4
|
|
|
5
|
-
**Version:**
|
|
6
|
-
**Date:** 2026-03-
|
|
7
|
-
**Status:** Draft
|
|
5
|
+
**Version:** 2.0
|
|
6
|
+
**Date:** 2026-03-04
|
|
7
|
+
**Status:** Draft (Architecture-Corrected)
|
|
8
8
|
**Roadmap Mapping:** M33
|
|
9
9
|
|
|
10
10
|
---
|
|
@@ -14,80 +14,176 @@
|
|
|
14
14
|
### 0.1 Required Standards
|
|
15
15
|
|
|
16
16
|
All implementation MUST preserve:
|
|
17
|
-
- deterministic tool
|
|
18
|
-
- MCP/in-process parity for new
|
|
19
|
-
-
|
|
17
|
+
- deterministic tool behavior and normalized error envelopes
|
|
18
|
+
- MCP/in-process transport parity for all new tools
|
|
19
|
+
- strict contract validation (`validate:mcp-contracts`) and architecture boundaries (`validate:architecture`)
|
|
20
20
|
- runtime artifact ownership under `.aop/**`
|
|
21
|
+
- existing idempotency semantics (`operation_id` replay/mismatch) for mutating tools
|
|
21
22
|
|
|
22
|
-
### 0.2 Upstream Inputs
|
|
23
|
+
### 0.2 Required Upstream Inputs
|
|
23
24
|
|
|
24
25
|
Implementing agents MUST read:
|
|
25
|
-
- `spec-files/
|
|
26
|
-
- `
|
|
27
|
-
- `
|
|
26
|
+
- `spec-files/outstanding/agentic_orchestrator_quality_adoption_execution_spec.md`
|
|
27
|
+
- `apps/control-plane/src/mcp/tool-runtime.ts`
|
|
28
|
+
- `apps/control-plane/src/mcp/operation-ledger.ts`
|
|
29
|
+
- `apps/control-plane/src/core/kernel.ts`
|
|
30
|
+
- `apps/control-plane/src/core/path-layout.ts`
|
|
31
|
+
- `apps/control-plane/src/core/constants.ts`
|
|
32
|
+
- `apps/control-plane/src/core/error-codes.ts`
|
|
33
|
+
- `apps/control-plane/src/application/services/gate-service.ts`
|
|
34
|
+
- `apps/control-plane/src/core/gates.ts`
|
|
35
|
+
- `apps/control-plane/src/application/services/reporting-service.ts`
|
|
36
|
+
- `apps/control-plane/src/cli/types.ts`
|
|
37
|
+
- `apps/control-plane/src/cli/cli-argument-parser.ts`
|
|
38
|
+
- `apps/control-plane/src/cli/help-command-handler.ts`
|
|
39
|
+
- `apps/control-plane/src/interfaces/cli/bootstrap.ts`
|
|
40
|
+
- `apps/control-plane/src/application/tools/tool-metadata.ts`
|
|
41
|
+
- `agentic/orchestrator/defaults/policy.defaults.yaml`
|
|
42
|
+
- `agentic/orchestrator/schemas/policy.schema.json`
|
|
43
|
+
- `agentic/orchestrator/schemas/policy.user.schema.json`
|
|
44
|
+
- `agentic/orchestrator/tools/catalog.json`
|
|
45
|
+
- `apps/control-plane/scripts/validate-mcp-contracts.ts`
|
|
28
46
|
|
|
29
47
|
### 0.3 Feature Scope
|
|
30
48
|
|
|
31
49
|
This spec implements:
|
|
32
|
-
- **Q3** Deterministic Replay + Time-Travel
|
|
33
|
-
- **Q4** Tamper-Evident Evidence Chain
|
|
34
|
-
- **Q11** `aop doctor` Readiness + Drift
|
|
50
|
+
- **Q3** Deterministic Replay + Time-Travel Diagnostics
|
|
51
|
+
- **Q4** Tamper-Evident Evidence Integrity Chain
|
|
52
|
+
- **Q11** `aop doctor` Readiness + Drift Diagnostics
|
|
53
|
+
|
|
54
|
+
Out of scope:
|
|
55
|
+
- autonomous RCA narrative generation
|
|
56
|
+
- external KMS/HSM signing
|
|
57
|
+
- remote telemetry backends
|
|
58
|
+
- background daemonized doctor scans
|
|
35
59
|
|
|
36
60
|
---
|
|
37
61
|
|
|
38
|
-
## 1.
|
|
62
|
+
## 1. Architectural Critique of Prior Draft (v1.0)
|
|
39
63
|
|
|
40
|
-
|
|
64
|
+
The prior draft was directionally correct but not implementation-safe against the current architecture.
|
|
41
65
|
|
|
42
|
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
66
|
+
1. **Replay design ignored existing idempotency ledger semantics**
|
|
67
|
+
- Problem: timeline design treated every call as `ok/error` and did not model `operation_id` replay/mismatch outcomes.
|
|
68
|
+
- Impact: operators cannot distinguish a real execution from a deterministic replay path.
|
|
69
|
+
- Correction: timeline entries must include `idempotency_status` (`new|replay|mismatch|none`) and optionally `request_hash`.
|
|
46
70
|
|
|
47
|
-
|
|
71
|
+
2. **Tool and CLI wiring was incomplete**
|
|
72
|
+
- Problem: draft listed service files only, but current runtime requires full wiring through constants, kernel handlers, tool metadata, catalog, RBAC, docs generation, CLI enum/parser/help/bootstrap.
|
|
73
|
+
- Impact: contract drift and startup/runtime failures.
|
|
74
|
+
- Correction: include full tool/CLI lifecycle wiring as normative work.
|
|
48
75
|
|
|
49
|
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
76
|
+
3. **Evidence chain placement would break `evidence.latest`**
|
|
77
|
+
- Problem: `GateService.evidenceLatest()` currently scans all `*.json` files by mtime in evidence dir.
|
|
78
|
+
- Impact: adding `chain.json` or `manifest.json` can cause `evidence.latest` to return chain metadata instead of latest gate evidence.
|
|
79
|
+
- Correction: constrain `evidenceLatest` to `gate-*.json` and `latest-*.json` only.
|
|
52
80
|
|
|
53
|
-
|
|
81
|
+
4. **Evidence chain algorithm was insufficiently deterministic**
|
|
82
|
+
- Problem: hash contract depended on ad hoc concatenation with timestamps and no algorithm versioning/canonical object format.
|
|
83
|
+
- Impact: brittle verification and future incompatibility.
|
|
84
|
+
- Correction: define canonical hash payload with explicit `algorithm_version` and stable field ordering.
|
|
54
85
|
|
|
55
|
-
|
|
86
|
+
5. **Concurrency guarantees were underspecified**
|
|
87
|
+
- Problem: replay sequence allocation and chain append were specified without lock strategy.
|
|
88
|
+
- Impact: sequence collisions/interleaving corruption under concurrent tool calls and parallel gates.
|
|
89
|
+
- Correction: require per-run replay lock and per-feature evidence-chain lock using existing file-lock primitives.
|
|
56
90
|
|
|
57
|
-
|
|
91
|
+
6. **Doctor checks were too vague for deterministic implementation**
|
|
92
|
+
- Problem: checks were listed by category but not by stable check IDs, severity rules, or deterministic ordering.
|
|
93
|
+
- Impact: non-repeatable output and fragile tests.
|
|
94
|
+
- Correction: define fixed check IDs, output ordering, and strict severity semantics.
|
|
58
95
|
|
|
59
|
-
|
|
96
|
+
7. **Feature gating model was missing from policy schema**
|
|
97
|
+
- Problem: draft said “feature-flagged where needed” but provided no schema/default additions.
|
|
98
|
+
- Impact: policy validation failure if teams add unmodeled fields.
|
|
99
|
+
- Correction: add policy/default/schema contracts for observability and diagnostics toggles.
|
|
100
|
+
|
|
101
|
+
8. **Rollout and retention interactions were not addressed**
|
|
102
|
+
- Problem: no plan for replay file growth, no compatibility plan with evidence retention/pruning.
|
|
103
|
+
- Impact: unbounded artifacts or false integrity failures.
|
|
104
|
+
- Correction: add retention policy and explicit integrity-vs-pruning rules.
|
|
105
|
+
|
|
106
|
+
---
|
|
60
107
|
|
|
61
|
-
|
|
108
|
+
## 2. Revised Architecture Fit
|
|
62
109
|
|
|
63
|
-
|
|
110
|
+
### 2.1 Existing Runtime Touchpoints
|
|
64
111
|
|
|
65
|
-
|
|
112
|
+
- **Tool execution boundary**: `ToolRuntime.callTool()` is the authoritative event point for replay timeline instrumentation (covers in-process and MCP equally).
|
|
113
|
+
- **Idempotency source of truth**: `OperationLedger` already determines `new|replay|mismatch` for mutating operations.
|
|
114
|
+
- **Evidence write path**: `GateService.gatesRun()` + `core/gates.ts` is the authoritative source for gate evidence artifacts.
|
|
115
|
+
- **Read/report path**: `ReportingService` remains the read aggregation surface; integrity checks should not bypass service boundaries.
|
|
116
|
+
- **CLI composition path**: command enum/parser/help/bootstrap require explicit updates for new command surfaces.
|
|
66
117
|
|
|
67
|
-
|
|
118
|
+
### 2.2 Boundary Rules (Normative)
|
|
119
|
+
|
|
120
|
+
- `core/*` remains pure infrastructure/domain helpers; orchestration/policy decisions live in `application/services/*`.
|
|
121
|
+
- replay timeline emission belongs in MCP runtime layer (`tool-runtime`) to guarantee transport parity.
|
|
122
|
+
- evidence chain append/verify belongs in `application/services/*` and is invoked from `GateService` write path.
|
|
123
|
+
- doctor scans are deterministic local checks only (file/config/runtime state), no network dependency.
|
|
124
|
+
- all behavior toggles must be schema-backed and default-safe.
|
|
68
125
|
|
|
69
126
|
---
|
|
70
127
|
|
|
71
|
-
## 3.
|
|
128
|
+
## 3. Contracts and Schema Deltas
|
|
129
|
+
|
|
130
|
+
## 3.1 Policy Extensions (Defaults + Schema + User Schema)
|
|
131
|
+
|
|
132
|
+
Add policy sections:
|
|
133
|
+
|
|
134
|
+
```yaml
|
|
135
|
+
innovation:
|
|
136
|
+
replay_debugger: true
|
|
137
|
+
tamper_evident_evidence: false
|
|
138
|
+
|
|
139
|
+
observability:
|
|
140
|
+
replay:
|
|
141
|
+
enabled: true
|
|
142
|
+
write_mode: best_effort # best_effort | required
|
|
143
|
+
retention:
|
|
144
|
+
max_runs: 100
|
|
145
|
+
max_entries_per_run: 50000
|
|
146
|
+
evidence_integrity:
|
|
147
|
+
enabled: false
|
|
148
|
+
verify_on_read: false
|
|
149
|
+
algorithm_version: 1
|
|
150
|
+
|
|
151
|
+
diagnostics:
|
|
152
|
+
doctor:
|
|
153
|
+
enabled: true
|
|
154
|
+
strict_fails_on: critical # critical | warning
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Normative behavior:
|
|
158
|
+
- `innovation.replay_debugger` and `observability.replay.enabled` must both be true for timeline writes.
|
|
159
|
+
- `innovation.tamper_evident_evidence` and `observability.evidence_integrity.enabled` must both be true for chain writes.
|
|
160
|
+
- `write_mode=best_effort` logs failures but never fails tool execution; `required` fails the parent tool call.
|
|
161
|
+
- doctor command remains callable; if `diagnostics.doctor.enabled=false`, it returns a report with a deterministic `doctor_disabled` info finding.
|
|
72
162
|
|
|
73
|
-
|
|
163
|
+
## 3.2 Replay Artifact Contracts
|
|
164
|
+
|
|
165
|
+
Path:
|
|
74
166
|
|
|
75
167
|
```text
|
|
76
168
|
.aop/runtime/replay/<run_id>.timeline.jsonl
|
|
169
|
+
.aop/runtime/replay/<run_id>.meta.json
|
|
77
170
|
```
|
|
78
171
|
|
|
79
|
-
Entry contract:
|
|
172
|
+
Entry contract (`timeline.jsonl` line):
|
|
80
173
|
|
|
81
174
|
```json
|
|
82
175
|
{
|
|
83
|
-
"ts": "2026-03-
|
|
176
|
+
"ts": "2026-03-04T00:00:00.000Z",
|
|
84
177
|
"sequence": 42,
|
|
85
178
|
"run_id": "run-123",
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
179
|
+
"session_id": "session-abc",
|
|
180
|
+
"actor_type": "builder",
|
|
181
|
+
"feature_id": "feature_x",
|
|
182
|
+
"tool_name": "repo.apply_patch",
|
|
183
|
+
"mutating": true,
|
|
184
|
+
"operation_id": "repo_apply_patch__feature_x__uuid",
|
|
185
|
+
"idempotency_status": "new",
|
|
186
|
+
"request_hash": "sha256:...",
|
|
91
187
|
"result": "ok",
|
|
92
188
|
"error_code": null,
|
|
93
189
|
"latency_ms": 317
|
|
@@ -95,280 +191,489 @@ Entry contract:
|
|
|
95
191
|
```
|
|
96
192
|
|
|
97
193
|
Rules:
|
|
98
|
-
- `sequence`
|
|
99
|
-
-
|
|
100
|
-
-
|
|
194
|
+
- `sequence` strictly increases per `run_id`.
|
|
195
|
+
- write path is append-only JSONL; no in-place mutation of prior lines.
|
|
196
|
+
- `idempotency_status` must be one of `none|new|replay|mismatch`.
|
|
197
|
+
- ordering for reads is by `sequence` ascending, never filesystem mtime.
|
|
198
|
+
|
|
199
|
+
## 3.3 Evidence Integrity Contracts
|
|
101
200
|
|
|
102
|
-
|
|
201
|
+
Paths:
|
|
103
202
|
|
|
104
203
|
```text
|
|
105
|
-
.aop/features/<feature_id>/evidence/chain.
|
|
106
|
-
.aop/features/<feature_id>/evidence/manifest.json
|
|
204
|
+
.aop/features/<feature_id>/evidence/chain.jsonl
|
|
205
|
+
.aop/features/<feature_id>/evidence/manifest.integrity.json
|
|
107
206
|
```
|
|
108
207
|
|
|
109
208
|
Chain entry contract:
|
|
110
209
|
|
|
111
210
|
```json
|
|
112
211
|
{
|
|
113
|
-
"
|
|
212
|
+
"algorithm_version": 1,
|
|
213
|
+
"sequence": 7,
|
|
214
|
+
"feature_id": "feature_x",
|
|
215
|
+
"artifact_rel_path": "evidence/gate-full-1741050000.json",
|
|
114
216
|
"artifact_hash": "sha256:...",
|
|
115
217
|
"prev_chain_hash": "sha256:...",
|
|
116
218
|
"chain_hash": "sha256:...",
|
|
117
|
-
"created_at": "2026-03-
|
|
219
|
+
"created_at": "2026-03-04T10:15:01.000Z"
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Hash payload (canonical JSON, stable key order):
|
|
224
|
+
|
|
225
|
+
```json
|
|
226
|
+
{
|
|
227
|
+
"algorithm_version": 1,
|
|
228
|
+
"sequence": 7,
|
|
229
|
+
"feature_id": "feature_x",
|
|
230
|
+
"artifact_rel_path": "evidence/gate-full-1741050000.json",
|
|
231
|
+
"artifact_hash": "sha256:...",
|
|
232
|
+
"prev_chain_hash": "sha256:..."
|
|
118
233
|
}
|
|
119
234
|
```
|
|
120
235
|
|
|
121
236
|
Rules:
|
|
122
|
-
-
|
|
123
|
-
-
|
|
237
|
+
- `chain_hash = sha256(canonical_json(hash_payload))`.
|
|
238
|
+
- `manifest.integrity.json` stores `entry_count`, `head_hash`, `last_verified_at`, `last_verified_result`.
|
|
239
|
+
- verification fails closed on missing artifact, hash mismatch, or chain discontinuity.
|
|
240
|
+
- tracked artifacts in v1 scope: `gate-*.json`, `latest-*.json` only.
|
|
124
241
|
|
|
125
|
-
|
|
242
|
+
## 3.4 Doctor Report Contract
|
|
243
|
+
|
|
244
|
+
Path:
|
|
126
245
|
|
|
127
246
|
```text
|
|
128
247
|
.aop/runtime/doctor/last_report.json
|
|
248
|
+
.aop/runtime/doctor/history/<timestamp>.json
|
|
129
249
|
```
|
|
130
250
|
|
|
131
|
-
|
|
251
|
+
Report contract:
|
|
132
252
|
|
|
133
253
|
```json
|
|
134
254
|
{
|
|
135
255
|
"ok": true,
|
|
136
|
-
"generated_at": "2026-03-
|
|
256
|
+
"generated_at": "2026-03-04T10:30:00.000Z",
|
|
137
257
|
"summary": {
|
|
138
258
|
"critical": 0,
|
|
139
|
-
"warning":
|
|
140
|
-
"info":
|
|
259
|
+
"warning": 1,
|
|
260
|
+
"info": 3
|
|
141
261
|
},
|
|
142
262
|
"findings": [
|
|
143
263
|
{
|
|
144
|
-
"id": "
|
|
264
|
+
"id": "DRIFT_004_STALE_RUN_LEASE",
|
|
145
265
|
"severity": "warning",
|
|
146
|
-
"message": "
|
|
147
|
-
"remediation": "
|
|
148
|
-
"refs": ["
|
|
266
|
+
"message": "Run lease appears stale and still populated",
|
|
267
|
+
"remediation": "Run `aop run --takeover-stale-run` or clear stale lease after verification",
|
|
268
|
+
"refs": [".aop/runtime/default/run-lease.json"]
|
|
149
269
|
}
|
|
150
270
|
]
|
|
151
271
|
}
|
|
152
272
|
```
|
|
153
273
|
|
|
154
|
-
|
|
274
|
+
Rules:
|
|
275
|
+
- findings sorted lexically by `id`.
|
|
276
|
+
- summary counts derived strictly from findings array.
|
|
277
|
+
- `ok = (critical===0)` in normal mode.
|
|
155
278
|
|
|
156
|
-
##
|
|
279
|
+
## 3.5 Tool Surface Changes
|
|
157
280
|
|
|
158
|
-
###
|
|
281
|
+
### New Tools
|
|
159
282
|
|
|
160
|
-
1. `replay.timeline_get`
|
|
161
|
-
-
|
|
162
|
-
- Mutating: no.
|
|
283
|
+
1. `replay.timeline_get` (read-only)
|
|
284
|
+
- query timeline by `run_id` with optional `from_sequence`, `limit`, `feature_id`, `tool_name` filters.
|
|
163
285
|
|
|
164
|
-
2. `evidence.verify_chain`
|
|
165
|
-
-
|
|
166
|
-
- Mutating: no.
|
|
286
|
+
2. `evidence.verify_chain` (read-only)
|
|
287
|
+
- verify integrity chain for a feature and return validity summary + first failure details.
|
|
167
288
|
|
|
168
|
-
3. `doctor.run`
|
|
169
|
-
-
|
|
170
|
-
- Mutating: yes (writes report).
|
|
289
|
+
3. `doctor.run` (mutating)
|
|
290
|
+
- execute deterministic checks and persist doctor report artifacts.
|
|
171
291
|
|
|
172
|
-
###
|
|
292
|
+
### Required Wiring for Every New Tool
|
|
173
293
|
|
|
174
|
-
- `
|
|
175
|
-
- `
|
|
294
|
+
- `apps/control-plane/src/core/constants.ts`
|
|
295
|
+
- `apps/control-plane/src/core/kernel.ts`
|
|
296
|
+
- `apps/control-plane/src/application/tools/tool-metadata.ts`
|
|
297
|
+
- `agentic/orchestrator/tools/catalog.json`
|
|
298
|
+
- `agentic/orchestrator/tools/schemas/input/*.json`
|
|
299
|
+
- `agentic/orchestrator/tools/schemas/output/*.json`
|
|
300
|
+
- `agentic/orchestrator/defaults/policy.defaults.yaml` RBAC lists
|
|
301
|
+
- generated `agentic/orchestrator/tools.md`
|
|
302
|
+
|
|
303
|
+
## 3.6 CLI Surface Changes
|
|
304
|
+
|
|
305
|
+
Add commands:
|
|
306
|
+
- `aop replay --run-id <id> [--from-sequence N] [--limit N] [--feature-id <id>] [--tool <name>] [--json]`
|
|
307
|
+
- `aop evidence verify --feature-id <id> [--json]`
|
|
176
308
|
- `aop doctor [--strict] [--json]`
|
|
177
309
|
|
|
178
|
-
|
|
179
|
-
-
|
|
310
|
+
Required CLI wiring:
|
|
311
|
+
- `apps/control-plane/src/cli/types.ts` (`CliCommand` additions + option fields)
|
|
312
|
+
- `apps/control-plane/src/cli/cli-argument-parser.ts`
|
|
313
|
+
- `apps/control-plane/src/cli/help-command-handler.ts`
|
|
314
|
+
- `apps/control-plane/src/interfaces/cli/bootstrap.ts`
|
|
315
|
+
- new handlers under `apps/control-plane/src/cli/*-command-handler.ts`
|
|
316
|
+
|
|
317
|
+
## 3.7 Error Code Additions
|
|
318
|
+
|
|
319
|
+
Add to `apps/control-plane/src/core/error-codes.ts`:
|
|
320
|
+
- `replay_run_not_found`
|
|
321
|
+
- `replay_timeline_corrupt`
|
|
322
|
+
- `replay_timeline_write_failed`
|
|
323
|
+
- `evidence_chain_missing`
|
|
324
|
+
- `evidence_chain_artifact_missing`
|
|
325
|
+
- `evidence_chain_hash_mismatch`
|
|
326
|
+
- `evidence_chain_discontinuity`
|
|
327
|
+
- `evidence_integrity_write_failed`
|
|
328
|
+
- `doctor_check_failed`
|
|
329
|
+
- `doctor_report_write_failed`
|
|
180
330
|
|
|
181
331
|
---
|
|
182
332
|
|
|
183
|
-
##
|
|
333
|
+
## 4. Detailed Implementation Plan (Normative)
|
|
184
334
|
|
|
185
|
-
##
|
|
335
|
+
## OID0: Contract Scaffolding and Policy Wiring
|
|
186
336
|
|
|
187
|
-
###
|
|
337
|
+
### Goals
|
|
338
|
+
- land schema/default/tool scaffolding first to prevent runtime/config drift
|
|
188
339
|
|
|
189
|
-
|
|
190
|
-
- `
|
|
191
|
-
- `
|
|
192
|
-
- `
|
|
340
|
+
### File Targets
|
|
341
|
+
- `agentic/orchestrator/defaults/policy.defaults.yaml`
|
|
342
|
+
- `agentic/orchestrator/schemas/policy.schema.json`
|
|
343
|
+
- `agentic/orchestrator/schemas/policy.user.schema.json`
|
|
344
|
+
- `apps/control-plane/src/cli/init-command-handler.ts` (advanced policy template alignment)
|
|
345
|
+
- `apps/control-plane/src/core/constants.ts`
|
|
346
|
+
- `apps/control-plane/src/core/error-codes.ts`
|
|
347
|
+
- `agentic/orchestrator/tools/catalog.json`
|
|
193
348
|
- `agentic/orchestrator/tools/schemas/input/replay.timeline_get.input.schema.json` (new)
|
|
194
349
|
- `agentic/orchestrator/tools/schemas/output/replay.timeline_get.output.schema.json` (new)
|
|
350
|
+
- `agentic/orchestrator/tools/schemas/input/evidence.verify_chain.input.schema.json` (new)
|
|
351
|
+
- `agentic/orchestrator/tools/schemas/output/evidence.verify_chain.output.schema.json` (new)
|
|
352
|
+
- `agentic/orchestrator/tools/schemas/input/doctor.run.input.schema.json` (new)
|
|
353
|
+
- `agentic/orchestrator/tools/schemas/output/doctor.run.output.schema.json` (new)
|
|
354
|
+
- `agentic/orchestrator/tools.md`
|
|
355
|
+
|
|
356
|
+
### Mandatory Checks
|
|
357
|
+
- `npm run validate:mcp-contracts`
|
|
358
|
+
- `npm run validate:architecture`
|
|
359
|
+
|
|
360
|
+
Exit criteria:
|
|
361
|
+
- policy composition validates with new fields
|
|
362
|
+
- no contract validator drift
|
|
363
|
+
|
|
364
|
+
---
|
|
365
|
+
|
|
366
|
+
## OID1: Q3 Replay Timeline Foundation
|
|
367
|
+
|
|
368
|
+
### Design
|
|
369
|
+
|
|
370
|
+
Instrument `ToolRuntime` finalization path with deterministic timeline writes using a dedicated replay service.
|
|
371
|
+
|
|
372
|
+
### Algorithm
|
|
373
|
+
|
|
374
|
+
1. `ToolRuntime.callTool()` computes idempotency resolution.
|
|
375
|
+
2. Construct replay event envelope after response is finalized (includes latency and result).
|
|
376
|
+
3. `ReplayTimelineService.append(run_id, event)` acquires per-run lock.
|
|
377
|
+
4. Service increments `sequence` from `<run_id>.meta.json`.
|
|
378
|
+
5. Service appends JSONL line atomically and updates meta.
|
|
379
|
+
6. `replay.timeline_get` reads JSONL, validates line shape, filters deterministically, sorts by sequence.
|
|
380
|
+
|
|
381
|
+
### Implementation Targets
|
|
382
|
+
|
|
383
|
+
- `apps/control-plane/src/application/services/replay-timeline-service.ts` (new)
|
|
384
|
+
- `apps/control-plane/src/mcp/tool-runtime.ts`
|
|
385
|
+
- `apps/control-plane/src/core/path-layout.ts` (new helpers for replay paths)
|
|
386
|
+
- `apps/control-plane/src/core/kernel.ts` (tool handler registration and wrapper)
|
|
387
|
+
|
|
388
|
+
### Behavioral Rules
|
|
195
389
|
|
|
196
|
-
|
|
390
|
+
- replay emission is best-effort by default; respects `observability.replay.write_mode`.
|
|
391
|
+
- replay entries must be emitted for both success and failure responses.
|
|
392
|
+
- `idempotency_status=replay` entries must still be written (diagnostic visibility).
|
|
197
393
|
|
|
198
|
-
|
|
199
|
-
2. Replay service computes canonical `input_hash`.
|
|
200
|
-
3. Replay service obtains next `sequence` atomically.
|
|
201
|
-
4. Entry appended to JSONL.
|
|
202
|
-
5. `replay.timeline_get` reads, filters, and returns ordered entries.
|
|
394
|
+
### Test Plan
|
|
203
395
|
|
|
204
|
-
|
|
396
|
+
- `apps/control-plane/test/replay-timeline-service.spec.ts` (new)
|
|
397
|
+
- extend `apps/control-plane/test/tool-runtime.spec.ts` (idempotency status propagation)
|
|
398
|
+
- extend `apps/control-plane/test/mcp.spec.ts` for `replay.timeline_get` parity
|
|
205
399
|
|
|
206
|
-
|
|
207
|
-
-
|
|
208
|
-
-
|
|
400
|
+
Exit criteria:
|
|
401
|
+
- identical tool call sequence produces byte-identical timeline lines (except timestamps)
|
|
402
|
+
- sequence strictly monotonic under concurrent writes
|
|
209
403
|
|
|
210
404
|
---
|
|
211
405
|
|
|
212
|
-
##
|
|
406
|
+
## OID2: Q4 Evidence Integrity Chain
|
|
213
407
|
|
|
214
|
-
###
|
|
408
|
+
### Design
|
|
215
409
|
|
|
216
|
-
|
|
217
|
-
- `apps/control-plane/src/application/services/gate-service.ts`
|
|
218
|
-
- `apps/control-plane/src/cli/evidence-verify-command-handler.ts` (new)
|
|
219
|
-
- `agentic/orchestrator/tools/schemas/input/evidence.verify_chain.input.schema.json` (new)
|
|
220
|
-
- `agentic/orchestrator/tools/schemas/output/evidence.verify_chain.output.schema.json` (new)
|
|
410
|
+
Add chain writer/validator service and integrate into gate evidence write path after final evidence JSON mutation.
|
|
221
411
|
|
|
222
|
-
###
|
|
412
|
+
### Critical Integration Correction
|
|
223
413
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
3. compute new chain hash
|
|
228
|
-
4. append chain entry
|
|
229
|
-
5. update manifest metadata (entry count, head hash)
|
|
414
|
+
Before chain integration, change `GateService.evidenceLatest()` selection logic:
|
|
415
|
+
- include only files matching `gate-*.json` and `latest-*.json`
|
|
416
|
+
- exclude `chain.jsonl`, `manifest.integrity.json`, and any non-gate evidence metadata
|
|
230
417
|
|
|
231
|
-
###
|
|
418
|
+
### Write Path Algorithm
|
|
232
419
|
|
|
233
|
-
1.
|
|
234
|
-
2.
|
|
235
|
-
3.
|
|
236
|
-
4.
|
|
420
|
+
1. Gate run writes evidence files (`core/gates.ts`).
|
|
421
|
+
2. `GateService` applies incremental skipped-info rewrite if applicable.
|
|
422
|
+
3. If evidence integrity enabled, `EvidenceIntegrityService.append(feature_id, artifact_path)` runs for each tracked artifact.
|
|
423
|
+
4. Service computes artifact hash, reads head hash/sequence, computes next chain entry, appends to `chain.jsonl`, updates manifest.
|
|
237
424
|
|
|
238
|
-
###
|
|
425
|
+
### Verify Algorithm
|
|
239
426
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
427
|
+
1. Load chain entries in sequence order.
|
|
428
|
+
2. For each entry, recompute artifact hash and chain hash from canonical payload.
|
|
429
|
+
3. Check `prev_chain_hash` continuity.
|
|
430
|
+
4. Return deterministic summary with first failing `sequence` and reason.
|
|
431
|
+
|
|
432
|
+
### Implementation Targets
|
|
433
|
+
|
|
434
|
+
- `apps/control-plane/src/application/services/evidence-integrity-service.ts` (new)
|
|
435
|
+
- `apps/control-plane/src/application/services/gate-service.ts`
|
|
436
|
+
- `apps/control-plane/src/core/path-layout.ts` (chain/manifest helpers)
|
|
437
|
+
- `apps/control-plane/src/core/kernel.ts` (tool handler wiring)
|
|
438
|
+
|
|
439
|
+
### Behavioral Rules
|
|
440
|
+
|
|
441
|
+
- integrity chain is opt-in via policy toggles.
|
|
442
|
+
- verification fails closed when artifacts are missing or corrupted.
|
|
443
|
+
- chain verification is read-only and never mutates evidence artifacts.
|
|
444
|
+
|
|
445
|
+
### Test Plan
|
|
446
|
+
|
|
447
|
+
- `apps/control-plane/test/evidence-integrity-service.spec.ts` (new)
|
|
448
|
+
- extend `apps/control-plane/test/gates.spec.ts`
|
|
449
|
+
- add regression in `apps/control-plane/test/kernel.spec.ts` ensuring `evidence.latest` still returns gate evidence
|
|
450
|
+
- extend `apps/control-plane/test/mcp.spec.ts` for `evidence.verify_chain` parity
|
|
451
|
+
|
|
452
|
+
Exit criteria:
|
|
453
|
+
- tampered artifact triggers deterministic failure reason
|
|
454
|
+
- untampered chain verifies successfully
|
|
243
455
|
|
|
244
456
|
---
|
|
245
457
|
|
|
246
|
-
##
|
|
458
|
+
## OID3: Q11 Doctor Diagnostics
|
|
247
459
|
|
|
248
|
-
###
|
|
460
|
+
### Design
|
|
461
|
+
|
|
462
|
+
Implement deterministic scanner with fixed check IDs and explicit severity mapping.
|
|
463
|
+
|
|
464
|
+
### Required Checks (v1)
|
|
465
|
+
|
|
466
|
+
- `DRIFT_001_POLICY_SCHEMA_INVALID` (critical)
|
|
467
|
+
- `DRIFT_002_GATES_SCHEMA_INVALID` (critical)
|
|
468
|
+
- `DRIFT_003_TOOL_CONTRACT_DRIFT` (warning)
|
|
469
|
+
- `DRIFT_004_STALE_RUN_LEASE` (warning)
|
|
470
|
+
- `DRIFT_005_RUNTIME_SESSION_ORPHANS` (warning)
|
|
471
|
+
- `DRIFT_006_TIMELINE_CORRUPTION` (warning)
|
|
472
|
+
- `DRIFT_007_EVIDENCE_CHAIN_INVALID` (warning when enabled)
|
|
473
|
+
- `DRIFT_008_INDEX_STATE_INCONSISTENCY` (critical)
|
|
474
|
+
|
|
475
|
+
### Deterministic Output Rules
|
|
476
|
+
|
|
477
|
+
- check execution order fixed lexically by check ID
|
|
478
|
+
- findings sorted by check ID
|
|
479
|
+
- same repo state yields identical findings (except timestamp fields)
|
|
480
|
+
|
|
481
|
+
### Implementation Targets
|
|
249
482
|
|
|
250
483
|
- `apps/control-plane/src/application/services/doctor-service.ts` (new)
|
|
251
|
-
- `apps/control-plane/src/cli/doctor-command-handler.ts` (new)
|
|
252
484
|
- `agentic/orchestrator/schemas/doctor_report.schema.json` (new)
|
|
253
|
-
- `
|
|
254
|
-
- `
|
|
485
|
+
- `apps/control-plane/src/core/path-layout.ts` (doctor report/history helpers)
|
|
486
|
+
- `apps/control-plane/src/core/kernel.ts` (`doctor.run` handler)
|
|
255
487
|
|
|
256
|
-
###
|
|
488
|
+
### CLI Semantics
|
|
257
489
|
|
|
258
|
-
|
|
259
|
-
-
|
|
260
|
-
- minimal tool versions
|
|
490
|
+
- `aop doctor --strict`: non-zero exit when findings include severity at or above configured strict threshold.
|
|
491
|
+
- `aop doctor --json`: emit raw report payload.
|
|
261
492
|
|
|
262
|
-
|
|
263
|
-
- policy/gates/agents schema-valid
|
|
264
|
-
- MCP contract catalog consistency
|
|
493
|
+
### Test Plan
|
|
265
494
|
|
|
266
|
-
|
|
267
|
-
-
|
|
268
|
-
-
|
|
269
|
-
- corrupt/partial artifact detection
|
|
495
|
+
- `apps/control-plane/test/doctor-service.spec.ts` (new)
|
|
496
|
+
- extend `apps/control-plane/test/cli.unit.spec.ts` for parser/help/strict behavior
|
|
497
|
+
- extend `apps/control-plane/test/mcp.spec.ts` for `doctor.run` parity
|
|
270
498
|
|
|
271
|
-
|
|
272
|
-
-
|
|
273
|
-
-
|
|
499
|
+
Exit criteria:
|
|
500
|
+
- report artifact is schema-valid
|
|
501
|
+
- strict mode exit behavior is deterministic and tested
|
|
274
502
|
|
|
275
|
-
|
|
503
|
+
---
|
|
276
504
|
|
|
277
|
-
|
|
278
|
-
- `warning`: correctness/performance risk
|
|
279
|
-
- `info`: advisory
|
|
505
|
+
## OID4: Full Tool + CLI Surface Integration
|
|
280
506
|
|
|
281
|
-
###
|
|
507
|
+
### Goals
|
|
508
|
+
- complete all runtime and CLI wiring for new commands/tools
|
|
282
509
|
|
|
283
|
-
|
|
284
|
-
|
|
510
|
+
### Tool Integration Targets
|
|
511
|
+
|
|
512
|
+
- `apps/control-plane/src/core/constants.ts`
|
|
513
|
+
- `apps/control-plane/src/core/kernel.ts`
|
|
514
|
+
- `apps/control-plane/src/application/tools/tool-metadata.ts`
|
|
515
|
+
- `agentic/orchestrator/tools/catalog.json`
|
|
516
|
+
- `agentic/orchestrator/defaults/policy.defaults.yaml` RBAC sections
|
|
517
|
+
- `agentic/orchestrator/tools.md`
|
|
518
|
+
|
|
519
|
+
### CLI Integration Targets
|
|
520
|
+
|
|
521
|
+
- `apps/control-plane/src/cli/types.ts`
|
|
522
|
+
- `apps/control-plane/src/cli/cli-argument-parser.ts`
|
|
523
|
+
- `apps/control-plane/src/cli/help-command-handler.ts`
|
|
524
|
+
- `apps/control-plane/src/interfaces/cli/bootstrap.ts`
|
|
525
|
+
- `apps/control-plane/src/cli/replay-command-handler.ts` (new)
|
|
526
|
+
- `apps/control-plane/src/cli/evidence-command-handler.ts` (new)
|
|
527
|
+
- `apps/control-plane/src/cli/doctor-command-handler.ts` (new)
|
|
528
|
+
|
|
529
|
+
### Mandatory Checks
|
|
530
|
+
|
|
531
|
+
- `npm run validate:mcp-contracts`
|
|
532
|
+
- `npm run typecheck`
|
|
533
|
+
|
|
534
|
+
Exit criteria:
|
|
535
|
+
- tools callable via both in-process and MCP clients
|
|
536
|
+
- CLI commands documented and discoverable via `aop help`
|
|
285
537
|
|
|
286
538
|
---
|
|
287
539
|
|
|
288
|
-
##
|
|
540
|
+
## OID5: Hardening, Performance, and Retention
|
|
541
|
+
|
|
542
|
+
### Replay Retention
|
|
543
|
+
|
|
544
|
+
Implement deterministic cleanup:
|
|
545
|
+
- keep newest `max_runs` timeline files
|
|
546
|
+
- cap each run by `max_entries_per_run` with rollover file strategy or truncation policy (must be deterministic and documented)
|
|
547
|
+
|
|
548
|
+
### Evidence Integrity vs Retention Rule
|
|
549
|
+
|
|
550
|
+
If a separate evidence pruning policy exists, integrity-tracked files must not be pruned silently.
|
|
551
|
+
Required v1 behavior:
|
|
552
|
+
- doctor emits `DRIFT_007_EVIDENCE_CHAIN_INVALID` if chain references missing files.
|
|
553
|
+
- documentation explicitly states integrity verification requires preserving tracked artifacts.
|
|
289
554
|
|
|
290
|
-
###
|
|
555
|
+
### Implementation Targets
|
|
291
556
|
|
|
292
|
-
- timeline
|
|
293
|
-
-
|
|
557
|
+
- `apps/control-plane/src/application/services/replay-timeline-service.ts`
|
|
558
|
+
- `apps/control-plane/src/application/services/doctor-service.ts`
|
|
559
|
+
- `README.md` (operational caveats)
|
|
294
560
|
|
|
295
|
-
|
|
296
|
-
- deterministic ordering and stable hashes verified in tests
|
|
561
|
+
### Test Plan
|
|
297
562
|
|
|
298
|
-
|
|
563
|
+
- retention behavior tests in replay service suite
|
|
564
|
+
- doctor drift test for missing chained artifact
|
|
299
565
|
|
|
300
|
-
|
|
301
|
-
-
|
|
566
|
+
Exit criteria:
|
|
567
|
+
- replay growth bounded by policy
|
|
568
|
+
- integrity failures are diagnosable, not silent
|
|
302
569
|
|
|
303
|
-
|
|
304
|
-
|
|
570
|
+
---
|
|
571
|
+
|
|
572
|
+
## OID6: Rollout Strategy
|
|
573
|
+
|
|
574
|
+
### Rollout Order
|
|
305
575
|
|
|
306
|
-
|
|
576
|
+
1. Ship OID0 scaffolding; all new toggles at safe defaults.
|
|
577
|
+
2. Enable replay in best-effort mode in internal repos.
|
|
578
|
+
3. Enable doctor reporting in warning mode.
|
|
579
|
+
4. Enable evidence integrity for pilot repos with stable evidence retention.
|
|
580
|
+
5. Optionally switch replay write mode to `required` for high-audit repos.
|
|
307
581
|
|
|
308
|
-
|
|
309
|
-
- strict exit mode added
|
|
582
|
+
### Rollback Rules
|
|
310
583
|
|
|
311
|
-
|
|
312
|
-
-
|
|
584
|
+
- Any critical runtime regression: disable feature toggles without schema rollback.
|
|
585
|
+
- Keep artifacts backward-compatible; do not delete existing replay/chain files on disable.
|
|
313
586
|
|
|
314
587
|
---
|
|
315
588
|
|
|
316
|
-
##
|
|
589
|
+
## 5. Test Strategy (Normative)
|
|
317
590
|
|
|
318
|
-
###
|
|
591
|
+
### 5.1 Unit Tests
|
|
319
592
|
|
|
320
|
-
- replay sequence
|
|
321
|
-
-
|
|
322
|
-
-
|
|
593
|
+
- replay sequence allocation and line validation
|
|
594
|
+
- idempotency status mapping (`new|replay|mismatch|none`)
|
|
595
|
+
- chain hash recomputation and discontinuity detection
|
|
596
|
+
- doctor check ID ordering and severity aggregation
|
|
323
597
|
|
|
324
|
-
###
|
|
598
|
+
### 5.2 Integration Tests
|
|
325
599
|
|
|
326
|
-
-
|
|
327
|
-
-
|
|
328
|
-
- doctor
|
|
600
|
+
- end-to-end run emits replay timeline entries for core tool path
|
|
601
|
+
- evidence tamper triggers `evidence.verify_chain` failure
|
|
602
|
+
- doctor identifies intentionally broken policy/schema/runtime artifacts
|
|
329
603
|
|
|
330
|
-
###
|
|
604
|
+
### 5.3 Transport Parity
|
|
331
605
|
|
|
332
|
-
- `replay.timeline_get` parity
|
|
333
|
-
- `evidence.verify_chain` parity
|
|
334
|
-
- `doctor.run` parity
|
|
606
|
+
- `replay.timeline_get` parity (in-process vs MCP)
|
|
607
|
+
- `evidence.verify_chain` parity (in-process vs MCP)
|
|
608
|
+
- `doctor.run` parity (in-process vs MCP)
|
|
335
609
|
|
|
336
|
-
###
|
|
610
|
+
### 5.4 CLI Tests
|
|
337
611
|
|
|
338
|
-
- parser
|
|
339
|
-
- strict
|
|
612
|
+
- parser/help/bootstrap coverage for `replay`, `evidence verify`, `doctor`
|
|
613
|
+
- strict-mode exit behavior for doctor
|
|
614
|
+
- JSON output mode correctness
|
|
615
|
+
|
|
616
|
+
### 5.5 Regression Tests
|
|
617
|
+
|
|
618
|
+
- `evidence.latest` unaffected by integrity metadata files
|
|
619
|
+
- existing idempotency and gate behavior preserved
|
|
340
620
|
|
|
341
621
|
---
|
|
342
622
|
|
|
343
|
-
##
|
|
623
|
+
## 6. Acceptance Criteria
|
|
344
624
|
|
|
345
|
-
1. Replay timeline
|
|
346
|
-
2.
|
|
347
|
-
3.
|
|
348
|
-
4.
|
|
349
|
-
5.
|
|
625
|
+
1. Replay timeline is persisted under `.aop/runtime/replay` and queryable by `run_id` with deterministic ordering.
|
|
626
|
+
2. Replay entries include idempotency status and distinguish replayed mutations from fresh execution.
|
|
627
|
+
3. Evidence integrity chain detects tampering and discontinuities deterministically.
|
|
628
|
+
4. `evidence.latest` remains stable and returns gate evidence (not integrity metadata).
|
|
629
|
+
5. `aop doctor` produces deterministic, schema-valid findings with actionable remediations.
|
|
630
|
+
6. New tools are fully wired (constants/kernel/metadata/catalog/schemas/RBAC/tools.md).
|
|
631
|
+
7. CLI commands are fully wired (types/parser/help/bootstrap/handlers).
|
|
632
|
+
8. Quality gates pass: `lint`, `typecheck`, `test`, `validate:mcp-contracts`, `validate:architecture`.
|
|
350
633
|
|
|
351
634
|
---
|
|
352
635
|
|
|
353
|
-
##
|
|
636
|
+
## 7. Core Tradeoffs
|
|
637
|
+
|
|
638
|
+
1. **Replay coverage vs overhead**
|
|
639
|
+
- More per-call fields increase diagnostic value but add write overhead.
|
|
640
|
+
- Chosen tradeoff: lightweight JSONL entries with optional `request_hash`, default best-effort writes.
|
|
354
641
|
|
|
355
|
-
|
|
356
|
-
|
|
642
|
+
2. **Integrity strictness vs operational flexibility**
|
|
643
|
+
- Fail-closed verification improves audit trust but can break workflows under artifact pruning.
|
|
644
|
+
- Chosen tradeoff: integrity is opt-in, with explicit doctor findings for retention drift.
|
|
357
645
|
|
|
358
|
-
|
|
359
|
-
|
|
646
|
+
3. **Doctor breadth vs determinism**
|
|
647
|
+
- Broad checks can produce noisy, environment-dependent output.
|
|
648
|
+
- Chosen tradeoff: fixed local checks with stable IDs/severities, no external network probes.
|
|
360
649
|
|
|
361
|
-
|
|
362
|
-
|
|
650
|
+
4. **Command ergonomics vs parser simplicity**
|
|
651
|
+
- Nested command (`aop evidence verify`) is user-friendly but requires explicit parser subcommand logic.
|
|
652
|
+
- Chosen tradeoff: implement subcommand support explicitly rather than introducing ambiguous top-level aliases.
|
|
363
653
|
|
|
364
654
|
---
|
|
365
655
|
|
|
366
|
-
##
|
|
656
|
+
## 8. Risks and Mitigations
|
|
657
|
+
|
|
658
|
+
- Risk: timeline/chain file corruption due to concurrent writes.
|
|
659
|
+
- Mitigation: per-run and per-feature file-locking around append operations.
|
|
660
|
+
|
|
661
|
+
- Risk: performance regression from per-call writes.
|
|
662
|
+
- Mitigation: append-only JSONL, bounded retention, best-effort mode by default.
|
|
663
|
+
|
|
664
|
+
- Risk: false confidence from disabled/partial checks.
|
|
665
|
+
- Mitigation: doctor always reports explicit disabled-state finding IDs.
|
|
666
|
+
|
|
667
|
+
- Risk: schema drift between defaults/user/schema/catalog.
|
|
668
|
+
- Mitigation: OID0-first delivery with mandatory `validate:mcp-contracts` and policy schema updates.
|
|
669
|
+
|
|
670
|
+
---
|
|
367
671
|
|
|
368
|
-
|
|
369
|
-
- changed files and rationale
|
|
370
|
-
- schema/tool catalog deltas
|
|
371
|
-
- test coverage additions
|
|
372
|
-
- verification command results
|
|
373
|
-
- `spec-files/progress.md` updates with next actionable tasks
|
|
672
|
+
## 9. Definition of Done
|
|
374
673
|
|
|
674
|
+
A completed implementation session MUST provide:
|
|
675
|
+
- changed files and rationale by phase (OID0-OID6)
|
|
676
|
+
- schema/catalog/RBAC deltas and regenerated `tools.md`
|
|
677
|
+
- test additions and executed command results
|
|
678
|
+
- rollback notes for toggles and operational caveats
|
|
679
|
+
- `spec-files/progress.md` update entry with completed OID milestones and residual tasks
|