Skip to content

Commit dc1e0f3

Browse files
committed
feat(agent-workspace): add runbook automation and threshold audit trail
1 parent 0cac0c2 commit dc1e0f3

8 files changed

Lines changed: 542 additions & 18 deletions

docs/brainstorms/2026-04-16-mainline-ci-stabilization-and-m7-direction-requirements.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,33 @@ Deliverables:
333333
- `npm run test:agent-workspace:contracts`
334334
- `npm run verify:agent-workspace:runtime`
335335

336+
### M7.10 (Now): Operator Runbook Automation and Threshold-Change Audit Trail (Lane Ops Bridge)
337+
338+
Deliverables:
339+
340+
- add operator runbook automation output surface based on triage and trend-history signals.
341+
- add threshold-change audit trail persistence and bounded query route for governance traceability.
342+
- ensure triage, history, and runbook routes expose deterministic linkage to active threshold policy.
343+
344+
#### M7.10 Progress Note (2026-04-16)
345+
346+
- [Done] expanded `src/server.ts` with runbook automation route:
347+
- `GET /api/knowledge/operator/agent-workspace-diagnostics/triage/runbook?window=...`.
348+
- [Done] expanded threshold-governance audit route:
349+
- `GET /api/knowledge/operator/agent-workspace-diagnostics/triage/thresholds/audit?limit=...`.
350+
- [Done] landed bounded audit persistence under runtime data:
351+
- `agent_workspace_diagnostics/triage_policy_audit.v1.json` now captures threshold-change source/reason, before/after values, and computed change deltas.
352+
- [Done] strengthened triage payload semantics:
353+
- `/triage` and `/triage/history` now include automated runbook actions derived from risk buckets and replay trend direction.
354+
- [Done] expanded evidence coverage:
355+
- `src/server.migration.test.ts` now validates runbook automation payloads, threshold-audit query semantics, and audit-file persistence,
356+
- `src/knowledge.api.contract.test.ts` now fail-fast checks runbook/audit route contracts,
357+
- `src/agent_workspace.verification.contract.test.ts` + `scripts/verify-agent-workspace-runtime.js` now fail fast on audit helper/route drift.
358+
- [Done] verification evidence:
359+
- `npm test -- src/server.migration.test.ts --runInBand --testNamePattern "triage route summarizes replay risk|triage history and alert-threshold governance"`
360+
- `npm run test:agent-workspace:contracts`
361+
- `npm run verify:agent-workspace:runtime`
362+
336363
## Success Criteria
337364

338365
- CI failure mode that previously blocked the three agent-workspace suites is eliminated on mainline.
@@ -342,4 +369,4 @@ Deliverables:
342369

343370
## Next Step
344371

345-
Proceed to `/prompts:ce-plan` using this document as the source for `M7.10` decomposition (operator runbook automation and threshold-change audit trail), while preserving M7 lane boundary constraints.
372+
Proceed to `/prompts:ce-plan` using this document as the source for `M7.11` decomposition (adaptive threshold-policy simulation and auto-remediation guardrails), while preserving M7 lane boundary constraints.

docs/diataxis/en/explanation/development-progress-dashboard.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,25 @@ Execution anchor:
386386
- `npm run test:agent-workspace:contracts`
387387
- `npm run verify:agent-workspace:runtime`
388388

389+
## Latest Mainline Increment (2026-04-16 M7.10 Operator Runbook Automation and Threshold-Audit Governance Lane)
390+
391+
- Expanded `src/server.ts` with operator runbook automation surface:
392+
- `GET /api/knowledge/operator/agent-workspace-diagnostics/triage/runbook?window=...`.
393+
- Expanded threshold-governance audit surface:
394+
- `GET /api/knowledge/operator/agent-workspace-diagnostics/triage/thresholds/audit?limit=...`.
395+
- Added persisted audit artifact:
396+
- `runtime_data/agent_workspace_diagnostics/triage_policy_audit.v1.json` now stores threshold-change source/reason, before/after snapshots, and computed delta summary.
397+
- Extended triage/history semantics:
398+
- `/triage` and `/triage/history` now expose deterministic `runbookActions` derived from risk-bucket and replay-trend signals.
399+
- Expanded executable evidence:
400+
- `src/server.migration.test.ts` now validates runbook payloads, audit query semantics, and audit-file persistence.
401+
- Hardened runtime verification gate:
402+
- `src/knowledge.api.contract.test.ts`, `src/agent_workspace.verification.contract.test.ts`, and `scripts/verify-agent-workspace-runtime.js` now fail fast on runbook/audit route and helper drift.
403+
- Verification evidence:
404+
- `npm test -- src/server.migration.test.ts --runInBand --testNamePattern \"triage route summarizes replay risk|triage history and alert-threshold governance\"`
405+
- `npm run test:agent-workspace:contracts`
406+
- `npm run verify:agent-workspace:runtime`
407+
389408
## Mainline vs Working-Branch Snapshot (2026-04-14)
390409

391410
| Capability Slice | Working Branch (`feat/learning-multi-tutor-adapter`) | Mainline (`origin/main`) | Integration Status |
@@ -394,7 +413,7 @@ Execution anchor:
394413
| Focus + learning-path side-by-side pane model | Implemented in branch UI/runtime | Dock coexistence baseline integrated (`styles.css`, `path_styles.css`, `path_app.js`) | Partially integrated |
395414
| Agent workspace contract parity suite | Implemented (`src/agent_workspace.contract.parity.test.ts`, `src/agent_workspace.frontend.test.ts`, `src/agent_workspace.locale.contract.test.ts`, `src/agent_workspace.tauri.contract.test.ts`) | Baseline parity suite integrated (`src/agent_workspace.contract.parity.test.ts`, `src/agent_workspace.frontend.test.ts`, `src/agent_workspace.runtime.integration.test.ts`) | Partially integrated |
396415
| Result-presentation allowlist/override fail-fast governance | Implemented in branch execution registry and parity tests | Integrated in M1 (`src/frontend/agent_workspace.js` + parity tests) | Baseline integrated |
397-
| Conversation turn stream/replay/operator diagnostics expansion | Implemented in branch routes/tests | Mainline has runtime snapshot+trend/index/export plus sidecar persistence+triage+history+threshold governance (`src/frontend/agent_workspace_runtime.js`, `src/server.ts`) | Partially integrated |
416+
| Conversation turn stream/replay/operator diagnostics expansion | Implemented in branch routes/tests | Mainline has runtime snapshot+trend/index/export plus sidecar persistence+triage+history+threshold governance+runbook automation+threshold audit trail (`src/frontend/agent_workspace_runtime.js`, `src/server.ts`) | Partially integrated |
398417
| Graphdb/ANN foundation hardening lane | Branch-oriented lane claims exist in prior docs | Mainline currently exposes file-backed store baseline (`src/learning/store.ts`) | Not integrated on mainline |
399418
| Markdown reader governance refactor lane | Planned and partially implemented in branch | Mainline baseline only | Partially integrated |
400419

@@ -434,7 +453,7 @@ This dashboard aligns against the following requirement chain:
434453
| L2 Retrieval | explainable hybrid/vector retrieval + governance | Expanded in branch-oriented plans | Mainline file-backed baseline only (`src/learning/store.ts`) | Re-enter lane after concrete module evidence lands on mainline |
435454
| L3 Learning | mastery diagnostics + path/session loop | Expanded in branch | Partially integrated | Contract and integration parity |
436455
| L4 Interaction | agent conversation + focus/path pane runtime | Implemented in branch | M1-M4 baseline integrated on mainline | Expand capability surface via typed contract only |
437-
| L5 Governance | runbook, diagnostics, replay/autonomy controls | Expanded in branch | Operator diagnostics persistence/triage/history/threshold governance baseline integrated | Expand operator runbook automation and CI evidence depth |
456+
| L5 Governance | runbook, diagnostics, replay/autonomy controls | Expanded in branch | Operator diagnostics persistence/triage/history/threshold governance + runbook automation/audit baseline integrated | Expand adaptive policy simulation and CI evidence depth |
438457

439458
## Verification Baseline
440459

docs/diataxis/zh/explanation/development-progress-dashboard.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,25 @@
388388
- `npm run test:agent-workspace:contracts`
389389
- `npm run verify:agent-workspace:runtime`
390390

391+
## 主线最新增量(2026-04-16 M7.10 运维 runbook 自动化与阈值审计治理链路)
392+
393+
- 已在 `src/server.ts` 增加运维 runbook 自动化路由面:
394+
- `GET /api/knowledge/operator/agent-workspace-diagnostics/triage/runbook?window=...`
395+
- 已扩展阈值治理审计路由面:
396+
- `GET /api/knowledge/operator/agent-workspace-diagnostics/triage/thresholds/audit?limit=...`
397+
- 已新增阈值变更审计持久化工件:
398+
- `runtime_data/agent_workspace_diagnostics/triage_policy_audit.v1.json` 持久化阈值变更 source/reason、前后快照与 delta 摘要。
399+
- 已扩展 triage/history 输出语义:
400+
- `/triage``/triage/history` 现输出基于风险分桶与 replay 趋势的 `runbookActions` 自动化建议。
401+
- 已补可执行证据:
402+
- `src/server.migration.test.ts` 新增 runbook 输出、audit 查询语义与 audit 文件落盘断言。
403+
- 已加固 runtime 门禁:
404+
- `src/knowledge.api.contract.test.ts``src/agent_workspace.verification.contract.test.ts``scripts/verify-agent-workspace-runtime.js` 新增 runbook/audit 路由与 helper 的 fail-fast 断言。
405+
- 验证证据:
406+
- `npm test -- src/server.migration.test.ts --runInBand --testNamePattern \"triage route summarizes replay risk|triage history and alert-threshold governance\"`
407+
- `npm run test:agent-workspace:contracts`
408+
- `npm run verify:agent-workspace:runtime`
409+
391410
## 主线 vs 工作分支快照(2026-04-14)
392411

393412
| 能力切片 | 工作分支(`feat/learning-multi-tutor-adapter`| 主线(`origin/main`| 集成状态 |
@@ -396,7 +415,7 @@
396415
| Focus + learning-path 并排 pane 模型 | 分支已实现 | 已落入 dock 并排基线(`styles.css``path_styles.css``path_app.js`| 部分集成 |
397416
| Agent workspace 合同门禁测试 | 已实现(`src/agent_workspace.contract.parity.test.ts``src/agent_workspace.frontend.test.ts``src/agent_workspace.locale.contract.test.ts``src/agent_workspace.tauri.contract.test.ts`| 已落入基线门禁(`src/agent_workspace.contract.parity.test.ts``src/agent_workspace.frontend.test.ts``src/agent_workspace.runtime.integration.test.ts`| 部分集成 |
398417
| 结果呈现 allowlist/override fail-fast 治理 | 分支已实现 | M1 已集成(`src/frontend/agent_workspace.js` + parity tests) | 基线已集成 |
399-
| conversation turn 流式/重放/诊断扩展 | 分支已扩展 | 主线已落入 runtime snapshot+trend/index/export + sidecar 持久化/分级/趋势历史/阈值治理基线`src/frontend/agent_workspace_runtime.js``src/server.ts`| 部分集成 |
418+
| conversation turn 流式/重放/诊断扩展 | 分支已扩展 | 主线已落入 runtime snapshot+trend/index/export + sidecar 持久化/分级/趋势历史/阈值治理 + runbook 自动化 + 阈值审计治理基线`src/frontend/agent_workspace_runtime.js``src/server.ts`| 部分集成 |
400419
| graphdb/ANN 底座收敛 | 先前文档存在分支导向结论 | 主线当前为 file-backed store 基线(`src/learning/store.ts`| 主线未集成 |
401420
| Markdown 阅读器治理升级 | 分支已有规划与部分实现 | 主线为旧基线 | 部分集成 |
402421

@@ -436,7 +455,7 @@
436455
| L2 检索层 | 可解释混合/向量检索 + 治理 | 分支规划增强中 | 主线当前为 file-backed 基线(`src/learning/store.ts`| 待主线出现对应模块证据后再收敛 |
437456
| L3 学习层 | 掌握诊断 + 路径/会话闭环 | 分支增强中 | 主线部分集成 | 契约与集成一致性 |
438457
| L4 交互层 | agent 对话 + focus/path pane 运行时 | 分支已实现 | 主线 M1-M4 已落入基线 | 继续通过 typed contract 扩展动作面 |
439-
| L5 治理层 | runbook/诊断/回放与自动化 | 分支增强中 | 主线已集成运维诊断持久化/分级/趋势历史/阈值治理基线 | 扩展 runbook 自动化与 CI 证据深度 |
458+
| L5 治理层 | runbook/诊断/回放与自动化 | 分支增强中 | 主线已集成运维诊断持久化/分级/趋势历史/阈值治理 + runbook 自动化/阈值审计基线 | 扩展自适应策略模拟与 CI 证据深度 |
440459

441460
## 验证基线
442461

scripts/verify-agent-workspace-runtime.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,18 @@ function verifyAgentWorkspaceRuntime(repoRoot = path.resolve(__dirname, '..')) {
112112
serverSource.includes('/api/knowledge/operator/agent-workspace-diagnostics/triage/history'),
113113
'Missing diagnostics triage history route in src/server.ts'
114114
);
115+
assert(
116+
serverSource.includes('/api/knowledge/operator/agent-workspace-diagnostics/triage/runbook'),
117+
'Missing diagnostics triage runbook route in src/server.ts'
118+
);
115119
assert(
116120
serverSource.includes('/api/knowledge/operator/agent-workspace-diagnostics/triage/thresholds'),
117121
'Missing diagnostics triage thresholds route in src/server.ts'
118122
);
123+
assert(
124+
serverSource.includes('/api/knowledge/operator/agent-workspace-diagnostics/triage/thresholds/audit'),
125+
'Missing diagnostics triage thresholds audit route in src/server.ts'
126+
);
119127
assert(
120128
serverSource.includes('cleanupStaleAgentWorkspaceDiagnosticsReports'),
121129
'Missing diagnostics retention cleanup helper in src/server.ts'
@@ -132,6 +140,14 @@ function verifyAgentWorkspaceRuntime(repoRoot = path.resolve(__dirname, '..')) {
132140
serverSource.includes('persistAgentWorkspaceDiagnosticsAlertThresholds'),
133141
'Missing diagnostics triage threshold writer in src/server.ts'
134142
);
143+
assert(
144+
serverSource.includes('readAgentWorkspaceDiagnosticsThresholdAuditTrail'),
145+
'Missing diagnostics threshold audit reader in src/server.ts'
146+
);
147+
assert(
148+
serverSource.includes('appendAgentWorkspaceDiagnosticsThresholdAuditEntry'),
149+
'Missing diagnostics threshold audit writer in src/server.ts'
150+
);
135151
assert(
136152
runtimeSource.includes('persistDiagnosticsReport'),
137153
'Missing persistDiagnosticsReport runtime surface in src/frontend/agent_workspace_runtime.js'
@@ -149,9 +165,12 @@ function verifyAgentWorkspaceRuntime(repoRoot = path.resolve(__dirname, '..')) {
149165
'diagnostics report persistence routes exist',
150166
'diagnostics triage route exists',
151167
'diagnostics triage history route exists',
168+
'diagnostics triage runbook route exists',
152169
'diagnostics triage threshold governance routes exist',
170+
'diagnostics triage threshold audit route exists',
153171
'diagnostics retention governance exists',
154172
'diagnostics alert-threshold governance helpers exist',
173+
'diagnostics threshold audit helpers exist',
155174
'runtime diagnostics persistence surface exists',
156175
'agent workspace contract test suite passes',
157176
],

src/agent_workspace.verification.contract.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,15 @@ describe('agent workspace verification script contracts', () => {
4949
expect(runtimeSource).toContain('/api/knowledge/operator/agent-workspace-diagnostics/latest');
5050
expect(runtimeSource).toContain('/api/knowledge/operator/agent-workspace-diagnostics/triage');
5151
expect(runtimeSource).toContain('/api/knowledge/operator/agent-workspace-diagnostics/triage/history');
52+
expect(runtimeSource).toContain('/api/knowledge/operator/agent-workspace-diagnostics/triage/runbook');
5253
expect(runtimeSource).toContain('/api/knowledge/operator/agent-workspace-diagnostics/triage/thresholds');
54+
expect(runtimeSource).toContain('/api/knowledge/operator/agent-workspace-diagnostics/triage/thresholds/audit');
5355
expect(runtimeSource).toContain('cleanupStaleAgentWorkspaceDiagnosticsReports');
5456
expect(runtimeSource).toContain('AGENT_WORKSPACE_DIAGNOSTICS_MAX_ENTRIES');
5557
expect(runtimeSource).toContain('readAgentWorkspaceDiagnosticsAlertThresholds');
5658
expect(runtimeSource).toContain('persistAgentWorkspaceDiagnosticsAlertThresholds');
59+
expect(runtimeSource).toContain('readAgentWorkspaceDiagnosticsThresholdAuditTrail');
60+
expect(runtimeSource).toContain('appendAgentWorkspaceDiagnosticsThresholdAuditEntry');
5761
expect(runtimeSource).toContain('persistDiagnosticsReport');
5862
expect(browserSource).toContain('verifyAgentWorkspaceBrowser');
5963
expect(tauriSource).toContain('verifyAgentWorkspaceTauri');

src/knowledge.api.contract.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ describe('Knowledge mastery API contract wiring', () => {
1313
'/api/knowledge/operator/agent-workspace-diagnostics/latest',
1414
'/api/knowledge/operator/agent-workspace-diagnostics/triage',
1515
'/api/knowledge/operator/agent-workspace-diagnostics/triage/history',
16+
'/api/knowledge/operator/agent-workspace-diagnostics/triage/runbook',
1617
'/api/knowledge/operator/agent-workspace-diagnostics/triage/thresholds',
18+
'/api/knowledge/operator/agent-workspace-diagnostics/triage/thresholds/audit',
1719
'/api/knowledge/operator/agent-workspace-diagnostics/report',
1820
'/api/knowledge/store/reload',
1921
'/api/knowledge/ingest',

0 commit comments

Comments
 (0)