Skip to content

Commit cf0fa32

Browse files
committed
feat: add notification-threshold rollback preview
1 parent 7159b1c commit cf0fa32

8 files changed

Lines changed: 360 additions & 48 deletions

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

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ Deliverables:
721721
- The main remaining gap is not another new route family.
722722
The next high-leverage gap is operator safety around rollback preview and drift visibility before applying or resetting thresholds.
723723

724-
### M7.23 (Next): Notification-Threshold Rollback Preview and Drift-Diff Governance (Lane Ops Bridge)
724+
### M7.23 (Now): Notification-Threshold Rollback Preview and Drift-Diff Governance (Lane Ops Bridge)
725725

726726
Deliverables:
727727

@@ -756,6 +756,58 @@ Suggested verification slice:
756756
- `npm run docs:diataxis:check`
757757
- `npm run docs:site:build`
758758

759+
#### M7.23 Progress Note (2026-04-16)
760+
761+
- [Done] expanded `src/server.ts` with preview route:
762+
- `GET /api/knowledge/operator/agent-workspace-diagnostics/triage/remediation/escalation/notification-thresholds/preview`.
763+
- [Done] added deterministic rollback-preview helper stack:
764+
- `buildAgentWorkspaceDiagnosticsRemediationEscalationNotificationThresholdPreview(...)`,
765+
- `areAgentWorkspaceDiagnosticsRemediationEscalationNotificationThresholdPoliciesEquivalent(...)`.
766+
- [Done] preview payload now exposes bounded operator review surfaces:
767+
- `activeThresholds`,
768+
- `defaultThresholds`,
769+
- `driftDiff.activeVsDefault`,
770+
- `driftDiff.activeVsLatestAuditPrevious`,
771+
- `preview.resetToDefault`,
772+
- `preview.rollbackToPrevious`.
773+
- [Done] latest-audit-linked rollback semantics are now explicit:
774+
- rollback-to-previous preview is only marked available when current active thresholds still match the latest audited `nextThresholds`,
775+
- otherwise the surface remains read-only and deterministic without auto-rollback behavior.
776+
- [Done] expanded evidence coverage:
777+
- `src/server.migration.test.ts` now validates preview route semantics, default-vs-active drift deltas, latest-audit rollback preview deltas, and reset-preview deltas.
778+
- `src/knowledge.api.contract.test.ts`, `src/agent_workspace.verification.contract.test.ts`, and `scripts/verify-agent-workspace-runtime.js` now fail fast on preview-route and helper drift.
779+
- [Done] verification evidence:
780+
- `npm test -- src/server.migration.test.ts --runInBand --testNamePattern "escalation notification threshold rollback preview and drift-diff governance stay deterministic"`
781+
- `npm run test:agent-workspace:contracts`
782+
- `npm run verify:agent-workspace:runtime`
783+
- `npm run docs:diataxis:check`
784+
- `npm run docs:site:build`
785+
786+
### Post-M7.23 Architecture Judgment
787+
788+
- L5 governance now has enough visibility for safe operator inspection of notification threshold state transitions.
789+
- Current weak point shifts from visibility to controlled execution:
790+
- operators can preview reset/rollback consequences,
791+
- operators still cannot apply a bounded rollback target with explicit preview fingerprinting.
792+
- Best next increment is not broader governance expansion.
793+
Best next increment is explicit rollback execution guardrails on top of the preview surface.
794+
795+
### M7.24 (Next): Notification-Threshold Rollback Apply Guardrails (Lane Ops Bridge)
796+
797+
Deliverables:
798+
799+
- add explicit operator apply route for rollback-to-default or rollback-to-previous-preview targets.
800+
- require preview fingerprint or audit-linked target metadata so apply semantics cannot drift from what operators reviewed.
801+
- keep scope limited to notification-threshold governance; do not reopen wider remediation or UI work.
802+
803+
Suggested verification slice:
804+
805+
- `npm test -- src/server.migration.test.ts --runInBand --testNamePattern "notification threshold rollback apply guardrails"`
806+
- `npm run test:agent-workspace:contracts`
807+
- `npm run verify:agent-workspace:runtime`
808+
- `npm run docs:diataxis:check`
809+
- `npm run docs:site:build`
810+
759811
## Success Criteria
760812

761813
- CI failure mode that previously blocked the three agent-workspace suites is eliminated on mainline.
@@ -765,4 +817,4 @@ Suggested verification slice:
765817

766818
## Next Step
767819

768-
Proceed to `/prompts:ce-plan` using this document as the source for `M7.23` decomposition (notification-threshold rollback preview and drift-diff governance), while preserving M7 lane boundary constraints.
820+
Proceed to `/prompts:ce-plan` using this document as the source for `M7.24` decomposition (notification-threshold rollback apply guardrails), while preserving M7 lane boundary constraints.

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

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -599,34 +599,29 @@ Execution anchor:
599599
- `npm run test:agent-workspace:contracts`
600600
- `npm run verify:agent-workspace:runtime`
601601

602-
## Latest Mainline Increment (2026-04-16 M7.22 Notification Threshold Overrides and Audit-Trail Governance Lane)
603-
604-
- Expanded `src/server.ts` with notification-threshold governance routes:
605-
- `GET /api/knowledge/operator/agent-workspace-diagnostics/triage/remediation/escalation/notification-thresholds`,
606-
- `POST /api/knowledge/operator/agent-workspace-diagnostics/triage/remediation/escalation/notification-thresholds`,
607-
- `GET /api/knowledge/operator/agent-workspace-diagnostics/triage/remediation/escalation/notification-thresholds/audit?limit=...`.
608-
- Added file-backed override governance artifacts:
609-
- `runtime_data/agent_workspace_diagnostics/triage_remediation_escalation_notification_thresholds.v1.json`,
610-
- `runtime_data/agent_workspace_diagnostics/triage_remediation_escalation_notification_thresholds_audit.v1.json`.
611-
- Hardened notification governance hydration:
612-
- `/triage/remediation/escalation/notification-policy` now returns override-backed `anomalyThresholdPolicy`,
613-
- `/triage/remediation/escalation/notification-slo` now evaluates breach thresholds from persisted overrides.
614-
- Added bounded audit-trail semantics:
615-
- previous/next threshold snapshots,
616-
- reset-to-default flag,
617-
- operator `source` / `reason`,
618-
- per-field delta summaries for suppression count, throttled digest count, and suppressed-to-emitted ratio.
602+
## Latest Mainline Increment (2026-04-16 M7.23 Notification-Threshold Rollback Preview and Drift-Diff Governance Lane)
603+
604+
- Expanded `src/server.ts` with preview route:
605+
- `GET /api/knowledge/operator/agent-workspace-diagnostics/triage/remediation/escalation/notification-thresholds/preview`.
606+
- Added deterministic rollback-preview helper stack:
607+
- `buildAgentWorkspaceDiagnosticsRemediationEscalationNotificationThresholdPreview(...)`,
608+
- `areAgentWorkspaceDiagnosticsRemediationEscalationNotificationThresholdPoliciesEquivalent(...)`.
609+
- Hardened operator visibility without widening scope:
610+
- preview payload now exposes `activeThresholds`, `defaultThresholds`, `driftDiff.activeVsDefault`, `driftDiff.activeVsLatestAuditPrevious`, `preview.resetToDefault`, and `preview.rollbackToPrevious`.
611+
- Added latest-audit-linked rollback semantics:
612+
- rollback-to-previous preview is only marked available when current active thresholds still match the latest audited `nextThresholds`,
613+
- drift remains read-only when preview and active state no longer align.
619614
- Expanded executable evidence:
620-
- `src/server.migration.test.ts` now validates override POST/GET/reset semantics, SLO behavior under override, audit-route payloads, and persisted file contents.
615+
- `src/server.migration.test.ts` now validates preview-route payloads, default-vs-active drift deltas, latest-audit rollback deltas, and reset-preview deltas.
621616
- Hardened runtime verification gate:
622-
- `src/knowledge.api.contract.test.ts`, `src/agent_workspace.verification.contract.test.ts`, and `scripts/verify-agent-workspace-runtime.js` now fail fast on notification-threshold route and helper drift.
617+
- `src/knowledge.api.contract.test.ts`, `src/agent_workspace.verification.contract.test.ts`, and `scripts/verify-agent-workspace-runtime.js` now fail fast on notification-threshold preview route and helper drift.
623618
- Verification evidence:
624-
- `npm test -- src/server.migration.test.ts --runInBand --testNamePattern \"escalation notification threshold overrides and audit-trail governance stay deterministic\"`
619+
- `npm test -- src/server.migration.test.ts --runInBand --testNamePattern \"escalation notification threshold rollback preview and drift-diff governance stay deterministic\"`
625620
- `npm run test:agent-workspace:contracts`
626621
- `npm run verify:agent-workspace:runtime`
627622
- Next direction judgment:
628-
- current bottleneck is rollback visibility, not another broad governance subsystem,
629-
- M7.23 should stay bounded to notification-threshold rollback preview and drift-diff governance on top of existing file-backed policy/audit artifacts.
623+
- current bottleneck shifts from visibility to controlled rollback execution,
624+
- M7.24 should stay bounded to rollback-apply guardrails with preview fingerprinting, not broader governance expansion.
630625

631626
## Mainline vs Working-Branch Snapshot (2026-04-14)
632627

@@ -676,7 +671,7 @@ This dashboard aligns against the following requirement chain:
676671
| 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 |
677672
| L3 Learning | mastery diagnostics + path/session loop | Expanded in branch | Partially integrated | Contract and integration parity |
678673
| L4 Interaction | agent conversation + focus/path pane runtime | Implemented in branch | M1-M4 baseline integrated on mainline | Expand capability surface via typed contract only |
679-
| L5 Governance | runbook, diagnostics, replay/autonomy controls | Expanded in branch | Operator diagnostics persistence/triage/history/threshold governance + runbook automation/audit + adaptive simulation/remediation + remediation backtest/approval-gate + approval-policy hardening/regression-alarms + approval-policy drift/escalation + escalation acknowledgement lifecycle/audit + escalation SLA/reminder baseline + notification digest/suppression baseline + delivery-log observability + stale-cleanup health auditing + anomaly/retention governance + notification SLO governance + notification-threshold override/audit governance integrated | M7.23: notification-threshold rollback preview and drift-diff governance |
674+
| L5 Governance | runbook, diagnostics, replay/autonomy controls | Expanded in branch | Operator diagnostics persistence/triage/history/threshold governance + runbook automation/audit + adaptive simulation/remediation + remediation backtest/approval-gate + approval-policy hardening/regression-alarms + approval-policy drift/escalation + escalation acknowledgement lifecycle/audit + escalation SLA/reminder baseline + notification digest/suppression baseline + delivery-log observability + stale-cleanup health auditing + anomaly/retention governance + notification SLO governance + notification-threshold override/audit governance + rollback preview/drift-diff governance integrated | M7.24: notification-threshold rollback apply guardrails |
680675

681676
## Verification Baseline
682677

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

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -601,34 +601,29 @@
601601
- `npm run test:agent-workspace:contracts`
602602
- `npm run verify:agent-workspace:runtime`
603603

604-
## 主线最新增量(2026-04-16 M7.22 通知阈值覆盖与审计轨迹治理链路)
605-
606-
- 已在 `src/server.ts` 增加通知阈值治理路由:
607-
- `GET /api/knowledge/operator/agent-workspace-diagnostics/triage/remediation/escalation/notification-thresholds`
608-
- `POST /api/knowledge/operator/agent-workspace-diagnostics/triage/remediation/escalation/notification-thresholds`
609-
- `GET /api/knowledge/operator/agent-workspace-diagnostics/triage/remediation/escalation/notification-thresholds/audit?limit=...`
610-
- 已补 file-backed 覆盖治理产物:
611-
- `runtime_data/agent_workspace_diagnostics/triage_remediation_escalation_notification_thresholds.v1.json`
612-
- `runtime_data/agent_workspace_diagnostics/triage_remediation_escalation_notification_thresholds_audit.v1.json`
613-
- 已加固通知治理链路的覆盖态读取:
614-
- `/triage/remediation/escalation/notification-policy` 现在返回基于持久化覆盖的 `anomalyThresholdPolicy`
615-
- `/triage/remediation/escalation/notification-slo` 现在基于持久化覆盖阈值计算 breach。
616-
- 已增加有界审计轨迹语义:
617-
- `previousThresholds` / `nextThresholds` 快照,
618-
- `resetToDefault` 标记,
619-
- operator `source` / `reason`
620-
- suppression count、throttled digest count 与 suppressed-to-emitted ratio 的逐字段 delta 摘要。
604+
## 主线最新增量(2026-04-16 M7.23 通知阈值回滚预览与 drift-diff 治理链路)
605+
606+
- 已在 `src/server.ts` 增加预览路由:
607+
- `GET /api/knowledge/operator/agent-workspace-diagnostics/triage/remediation/escalation/notification-thresholds/preview`
608+
- 已增加确定性回滚预览 helper 栈:
609+
- `buildAgentWorkspaceDiagnosticsRemediationEscalationNotificationThresholdPreview(...)`
610+
- `areAgentWorkspaceDiagnosticsRemediationEscalationNotificationThresholdPoliciesEquivalent(...)`
611+
- 已在不扩 scope 前提下补足 operator 可见性:
612+
- 预览载荷现在输出 `activeThresholds``defaultThresholds``driftDiff.activeVsDefault``driftDiff.activeVsLatestAuditPrevious``preview.resetToDefault``preview.rollbackToPrevious`
613+
- 已增加 latest-audit-linked rollback 语义:
614+
- 仅当当前 active thresholds 仍与最新审计记录的 `nextThresholds` 对齐时,rollback-to-previous preview 才标记为可用,
615+
- 否则只暴露只读 drift 信息,不做隐式回滚。
621616
- 已补可执行证据:
622-
- `src/server.migration.test.ts` 新增 override POST/GET/reset、覆盖后 SLO 行为、audit 路由语义与持久化文件内容断言
617+
- `src/server.migration.test.ts` 新增 preview 路由载荷、default-vs-active drift delta、latest-audit rollback delta 与 reset preview delta 断言
623618
- 已加固 runtime 门禁:
624-
- `src/knowledge.api.contract.test.ts``src/agent_workspace.verification.contract.test.ts``scripts/verify-agent-workspace-runtime.js` 新增 notification-threshold 路由与 helper 的 fail-fast 断言。
619+
- `src/knowledge.api.contract.test.ts``src/agent_workspace.verification.contract.test.ts``scripts/verify-agent-workspace-runtime.js` 新增 notification-threshold preview 路由与 helper 的 fail-fast 断言。
625620
- 验证证据:
626-
- `npm test -- src/server.migration.test.ts --runInBand --testNamePattern \"escalation notification threshold overrides and audit-trail governance stay deterministic\"`
621+
- `npm test -- src/server.migration.test.ts --runInBand --testNamePattern \"escalation notification threshold rollback preview and drift-diff governance stay deterministic\"`
627622
- `npm run test:agent-workspace:contracts`
628623
- `npm run verify:agent-workspace:runtime`
629624
- 后续方向判断:
630-
- 当前瓶颈是回滚可见性,不是继续扩一个更大的治理子系统
631-
- M7.23 应继续收敛在 notification-threshold rollback preview 与 drift-diff 治理,复用现有 file-backed policy/audit 产物
625+
- 当前瓶颈从可见性转向受控执行
626+
- M7.24 应继续收敛在 rollback apply guardrails 与 preview fingerprinting,不要扩成更大的治理子系统
632627

633628
## 主线 vs 工作分支快照(2026-04-14)
634629

@@ -678,7 +673,7 @@
678673
| L2 检索层 | 可解释混合/向量检索 + 治理 | 分支规划增强中 | 主线当前为 file-backed 基线(`src/learning/store.ts`| 待主线出现对应模块证据后再收敛 |
679674
| L3 学习层 | 掌握诊断 + 路径/会话闭环 | 分支增强中 | 主线部分集成 | 契约与集成一致性 |
680675
| L4 交互层 | agent 对话 + focus/path pane 运行时 | 分支已实现 | 主线 M1-M4 已落入基线 | 继续通过 typed contract 扩展动作面 |
681-
| L5 治理层 | runbook/诊断/回放与自动化 | 分支增强中 | 主线已集成运维诊断持久化/分级/趋势历史/阈值治理 + runbook 自动化/阈值审计 + 自适应模拟/自动修复 + 回测/批准门禁 + 批准策略硬化/回归告警 + 批准策略漂移/升级 + 升级确认生命周期/审计 + 升级 SLA/提醒基线 + 通知摘要/抑制基线 + 交付日志可观测性 + 陈旧通知健康审计 + 异常/retention 治理 + 通知 SLO 治理 + 通知阈值覆盖/审计治理 | M7.23:通知阈值回滚预览与 drift-diff 治理 |
676+
| L5 治理层 | runbook/诊断/回放与自动化 | 分支增强中 | 主线已集成运维诊断持久化/分级/趋势历史/阈值治理 + runbook 自动化/阈值审计 + 自适应模拟/自动修复 + 回测/批准门禁 + 批准策略硬化/回归告警 + 批准策略漂移/升级 + 升级确认生命周期/审计 + 升级 SLA/提醒基线 + 通知摘要/抑制基线 + 交付日志可观测性 + 陈旧通知健康审计 + 异常/retention 治理 + 通知 SLO 治理 + 通知阈值覆盖/审计治理 + 回滚预览/drift-diff 治理 | M7.24:通知阈值回滚 apply guardrails |
682677

683678
## 验证基线
684679

scripts/verify-agent-workspace-runtime.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ function verifyAgentWorkspaceRuntime(repoRoot = path.resolve(__dirname, '..')) {
160160
serverSource.includes('/api/knowledge/operator/agent-workspace-diagnostics/triage/remediation/escalation/notification-thresholds'),
161161
'Missing diagnostics remediation escalation notification-threshold route in src/server.ts'
162162
);
163+
assert(
164+
serverSource.includes('/api/knowledge/operator/agent-workspace-diagnostics/triage/remediation/escalation/notification-thresholds/preview'),
165+
'Missing diagnostics remediation escalation notification-threshold preview route in src/server.ts'
166+
);
163167
assert(
164168
serverSource.includes('/api/knowledge/operator/agent-workspace-diagnostics/triage/remediation/escalation/notification-thresholds/audit'),
165169
'Missing diagnostics remediation escalation notification-threshold audit route in src/server.ts'
@@ -340,6 +344,10 @@ function verifyAgentWorkspaceRuntime(repoRoot = path.resolve(__dirname, '..')) {
340344
serverSource.includes('appendAgentWorkspaceDiagnosticsRemediationEscalationNotificationThresholdAuditEntry'),
341345
'Missing remediation escalation notification threshold audit writer in src/server.ts'
342346
);
347+
assert(
348+
serverSource.includes('buildAgentWorkspaceDiagnosticsRemediationEscalationNotificationThresholdPreview'),
349+
'Missing remediation escalation notification threshold preview helper in src/server.ts'
350+
);
343351
assert(
344352
serverSource.includes('buildAgentWorkspaceDiagnosticsRemediationEscalationNotificationAnomalyReport'),
345353
'Missing remediation escalation notification anomaly report helper in src/server.ts'

src/agent_workspace.verification.contract.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ describe('agent workspace verification script contracts', () => {
6363
expect(runtimeSource).toContain('/api/knowledge/operator/agent-workspace-diagnostics/triage/remediation/escalation/sla');
6464
expect(runtimeSource).toContain('/api/knowledge/operator/agent-workspace-diagnostics/triage/remediation/escalation/reminders');
6565
expect(runtimeSource).toContain('/api/knowledge/operator/agent-workspace-diagnostics/triage/remediation/escalation/notification-thresholds');
66+
expect(runtimeSource).toContain('/api/knowledge/operator/agent-workspace-diagnostics/triage/remediation/escalation/notification-thresholds/preview');
6667
expect(runtimeSource).toContain('/api/knowledge/operator/agent-workspace-diagnostics/triage/remediation/escalation/notification-thresholds/audit');
6768
expect(runtimeSource).toContain('/api/knowledge/operator/agent-workspace-diagnostics/triage/remediation/escalation/notification-policy');
6869
expect(runtimeSource).toContain('/api/knowledge/operator/agent-workspace-diagnostics/triage/remediation/escalation/notifications');
@@ -107,6 +108,7 @@ describe('agent workspace verification script contracts', () => {
107108
expect(runtimeSource).toContain('persistAgentWorkspaceDiagnosticsRemediationEscalationNotificationThresholdPolicy');
108109
expect(runtimeSource).toContain('readAgentWorkspaceDiagnosticsRemediationEscalationNotificationThresholdAuditTrail');
109110
expect(runtimeSource).toContain('appendAgentWorkspaceDiagnosticsRemediationEscalationNotificationThresholdAuditEntry');
111+
expect(runtimeSource).toContain('buildAgentWorkspaceDiagnosticsRemediationEscalationNotificationThresholdPreview');
110112
expect(runtimeSource).toContain('buildAgentWorkspaceDiagnosticsRemediationEscalationNotificationSloReport');
111113
expect(runtimeSource).toContain('applyAgentWorkspaceDiagnosticsRemediationEscalationReminderSuppressionPolicy');
112114
expect(runtimeSource).toContain('buildAgentWorkspaceDiagnosticsRemediationEscalationGovernanceContext');

0 commit comments

Comments
 (0)