Skip to content

Commit 7e0c7f7

Browse files
committed
feat: add notification-threshold rollback apply guardrails
1 parent cf0fa32 commit 7e0c7f7

8 files changed

Lines changed: 621 additions & 77 deletions

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

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ Suggested verification slice:
792792
- Best next increment is not broader governance expansion.
793793
Best next increment is explicit rollback execution guardrails on top of the preview surface.
794794

795-
### M7.24 (Next): Notification-Threshold Rollback Apply Guardrails (Lane Ops Bridge)
795+
### M7.24 (Now): Notification-Threshold Rollback Apply Guardrails (Lane Ops Bridge)
796796

797797
Deliverables:
798798

@@ -808,6 +808,62 @@ Suggested verification slice:
808808
- `npm run docs:diataxis:check`
809809
- `npm run docs:site:build`
810810

811+
#### M7.24 Progress Note (2026-04-16)
812+
813+
- [Done] expanded `src/server.ts` with explicit rollback-apply route:
814+
- `POST /api/knowledge/operator/agent-workspace-diagnostics/triage/remediation/escalation/notification-thresholds/apply`.
815+
- [Done] added deterministic preview-to-apply guardrails:
816+
- `buildAgentWorkspaceDiagnosticsRemediationEscalationNotificationThresholdPreviewFingerprint(...)`,
817+
- `applyAgentWorkspaceDiagnosticsRemediationEscalationNotificationThresholdPreview(...)`,
818+
- `normalizeAgentWorkspaceDiagnosticsRemediationEscalationNotificationThresholdPreviewMode(...)`.
819+
- [Done] preview payloads now carry explicit execution fingerprints:
820+
- `preview.resetToDefault.previewFingerprint`,
821+
- `preview.rollbackToPrevious.previewFingerprint`.
822+
- [Done] apply semantics are now compare-and-swap style instead of blind mutation:
823+
- reset/apply requests must send the reviewed preview fingerprint,
824+
- rollback-to-previous requests must also send the reviewed `auditId`,
825+
- stale preview fingerprints, unavailable rollback previews, and mismatched audit ids are blocked with deterministic `409` responses,
826+
- no-op applies against already-active targets are blocked instead of silently writing redundant audit entries.
827+
- [Done] apply response now returns bounded execution evidence:
828+
- `appliedMode`,
829+
- `previewFingerprint`,
830+
- `matchedPreview`,
831+
- `appliedAuditEntry`.
832+
- [Done] expanded evidence coverage:
833+
- `src/server.migration.test.ts` now validates audit-id mismatch blocking, stale fingerprint blocking, rollback apply success, reset apply success, and audit-trail ordering after both mutations.
834+
- `src/knowledge.api.contract.test.ts`, `src/agent_workspace.verification.contract.test.ts`, and `scripts/verify-agent-workspace-runtime.js` now fail fast on apply-route and fingerprint/apply helper drift.
835+
- [Done] verification evidence:
836+
- `npm test -- src/server.migration.test.ts --runInBand --testNamePattern "notification threshold rollback apply guardrails stay deterministic"`
837+
- `npm run test:agent-workspace:contracts`
838+
- `npm run verify:agent-workspace:runtime`
839+
- `npm run docs:diataxis:check`
840+
- `npm run docs:site:build`
841+
842+
### Post-M7.24 Architecture Judgment
843+
844+
- L5 governance now supports bounded preview-to-apply execution for notification threshold rollback and reset.
845+
- Current weak point shifts from mutation safety to post-apply reconciliation:
846+
- operators can now preview and apply deterministic targets,
847+
- operators still lack a dedicated readback surface that says whether the latest applied preview remains current or has already been superseded by later threshold changes.
848+
- Best next increment is not broader remediation scope.
849+
Best next increment is a narrow apply-outcome reconciliation surface on top of existing audit artifacts.
850+
851+
### M7.25 (Next): Notification-Threshold Apply Outcome Reconciliation (Lane Ops Bridge)
852+
853+
Deliverables:
854+
855+
- add read-only reconciliation surface for the latest notification-threshold apply outcome.
856+
- compare latest applied preview fingerprint, latest audit entry, and current active thresholds so operators can see whether the reviewed/applyed state is still current or has drifted.
857+
- keep scope limited to notification-threshold governance; do not reopen UI, broader remediation, or unrelated memory/retrieval lanes.
858+
859+
Suggested verification slice:
860+
861+
- `npm test -- src/server.migration.test.ts --runInBand --testNamePattern "notification threshold apply outcome reconciliation"`
862+
- `npm run test:agent-workspace:contracts`
863+
- `npm run verify:agent-workspace:runtime`
864+
- `npm run docs:diataxis:check`
865+
- `npm run docs:site:build`
866+
811867
## Success Criteria
812868

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

818874
## Next Step
819875

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.
876+
Proceed to `/prompts:ce-plan` using this document as the source for `M7.25` decomposition (notification-threshold apply outcome reconciliation), while preserving M7 lane boundary constraints.

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

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -599,29 +599,32 @@ 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.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.
602+
## Latest Mainline Increment (2026-04-16 M7.24 Notification-Threshold Rollback Apply Guardrails Lane)
603+
604+
- Expanded `src/server.ts` with explicit apply route:
605+
- `POST /api/knowledge/operator/agent-workspace-diagnostics/triage/remediation/escalation/notification-thresholds/apply`.
606+
- Added deterministic preview-to-apply helper stack:
607+
- `buildAgentWorkspaceDiagnosticsRemediationEscalationNotificationThresholdPreviewFingerprint(...)`,
608+
- `applyAgentWorkspaceDiagnosticsRemediationEscalationNotificationThresholdPreview(...)`,
609+
- `normalizeAgentWorkspaceDiagnosticsRemediationEscalationNotificationThresholdPreviewMode(...)`.
610+
- Hardened mutation safety without widening scope:
611+
- preview payloads now expose `preview.resetToDefault.previewFingerprint` and `preview.rollbackToPrevious.previewFingerprint`,
612+
- apply requests must match the reviewed fingerprint,
613+
- rollback-to-previous apply requests must also match the reviewed `auditId`,
614+
- stale fingerprints, unavailable rollback previews, mismatched audit ids, and no-op targets are rejected deterministically.
615+
- Added bounded execution receipts:
616+
- apply responses now return `appliedMode`, `previewFingerprint`, `matchedPreview`, and `appliedAuditEntry`.
614617
- Expanded executable evidence:
615-
- `src/server.migration.test.ts` now validates preview-route payloads, default-vs-active drift deltas, latest-audit rollback deltas, and reset-preview deltas.
618+
- `src/server.migration.test.ts` now validates audit-id mismatch blocking, stale fingerprint blocking, rollback apply success, reset apply success, and persisted audit ordering.
616619
- Hardened runtime verification gate:
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.
620+
- `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 apply route and fingerprint/apply helper drift.
618621
- Verification evidence:
619-
- `npm test -- src/server.migration.test.ts --runInBand --testNamePattern \"escalation notification threshold rollback preview and drift-diff governance stay deterministic\"`
622+
- `npm test -- src/server.migration.test.ts --runInBand --testNamePattern \"notification threshold rollback apply guardrails stay deterministic\"`
620623
- `npm run test:agent-workspace:contracts`
621624
- `npm run verify:agent-workspace:runtime`
622625
- Next direction judgment:
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.
626+
- current bottleneck shifts from guarded execution to post-apply reconciliation,
627+
- M7.25 should stay bounded to apply-outcome reconciliation, not broader remediation or UI expansion.
625628

626629
## Mainline vs Working-Branch Snapshot (2026-04-14)
627630

@@ -671,7 +674,7 @@ This dashboard aligns against the following requirement chain:
671674
| 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 |
672675
| L3 Learning | mastery diagnostics + path/session loop | Expanded in branch | Partially integrated | Contract and integration parity |
673676
| L4 Interaction | agent conversation + focus/path pane runtime | Implemented in branch | M1-M4 baseline integrated on mainline | Expand capability surface via typed contract only |
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 |
677+
| 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 + rollback apply guardrails integrated | M7.25: notification-threshold apply outcome reconciliation |
675678

676679
## Verification Baseline
677680

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

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

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 信息,不做隐式回滚。
604+
## 主线最新增量(2026-04-16 M7.24 通知阈值回滚 apply guardrails 链路)
605+
606+
- 已在 `src/server.ts` 增加显式 apply 路由:
607+
- `POST /api/knowledge/operator/agent-workspace-diagnostics/triage/remediation/escalation/notification-thresholds/apply`
608+
- 已增加确定性 preview-to-apply helper 栈:
609+
- `buildAgentWorkspaceDiagnosticsRemediationEscalationNotificationThresholdPreviewFingerprint(...)`
610+
- `applyAgentWorkspaceDiagnosticsRemediationEscalationNotificationThresholdPreview(...)`
611+
- `normalizeAgentWorkspaceDiagnosticsRemediationEscalationNotificationThresholdPreviewMode(...)`
612+
- 已在不扩 scope 前提下加固 mutation 安全:
613+
- 预览载荷现在输出 `preview.resetToDefault.previewFingerprint``preview.rollbackToPrevious.previewFingerprint`
614+
- apply 请求必须匹配已审阅的 preview fingerprint,
615+
- rollback-to-previous apply 请求还必须匹配已审阅的 `auditId`
616+
- stale fingerprint、不可用 rollback preview、auditId 不匹配与 no-op target 都会被确定性拒绝。
617+
- 已增加有界执行回执:
618+
- apply 响应现在返回 `appliedMode``previewFingerprint``matchedPreview``appliedAuditEntry`
616619
- 已补可执行证据:
617-
- `src/server.migration.test.ts` 新增 preview 路由载荷、default-vs-active drift delta、latest-audit rollback delta 与 reset preview delta 断言
620+
- `src/server.migration.test.ts` 现在覆盖 auditId mismatch 阻断、stale fingerprint 阻断、rollback apply 成功、reset apply 成功与持久化 audit 顺序断言
618621
- 已加固 runtime 门禁:
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 断言。
622+
- `src/knowledge.api.contract.test.ts``src/agent_workspace.verification.contract.test.ts``scripts/verify-agent-workspace-runtime.js` 现在对 notification-threshold apply 路由与 fingerprint/apply helper fail-fast 断言。
620623
- 验证证据:
621-
- `npm test -- src/server.migration.test.ts --runInBand --testNamePattern \"escalation notification threshold rollback preview and drift-diff governance stay deterministic\"`
624+
- `npm test -- src/server.migration.test.ts --runInBand --testNamePattern \"notification threshold rollback apply guardrails stay deterministic\"`
622625
- `npm run test:agent-workspace:contracts`
623626
- `npm run verify:agent-workspace:runtime`
624627
- 后续方向判断:
625-
- 当前瓶颈从可见性转向受控执行
626-
- M7.24 应继续收敛在 rollback apply guardrails 与 preview fingerprinting,不要扩成更大的治理子系统
628+
- 当前瓶颈从受控执行转向 post-apply reconciliation
629+
- M7.25 应继续收敛在 apply 结果对账,不要扩成更大的 remediation 或 UI 子系统
627630

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

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

678681
## 验证基线
679682

scripts/verify-agent-workspace-runtime.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ function verifyAgentWorkspaceRuntime(repoRoot = path.resolve(__dirname, '..')) {
164164
serverSource.includes('/api/knowledge/operator/agent-workspace-diagnostics/triage/remediation/escalation/notification-thresholds/preview'),
165165
'Missing diagnostics remediation escalation notification-threshold preview route in src/server.ts'
166166
);
167+
assert(
168+
serverSource.includes('/api/knowledge/operator/agent-workspace-diagnostics/triage/remediation/escalation/notification-thresholds/apply'),
169+
'Missing diagnostics remediation escalation notification-threshold apply route in src/server.ts'
170+
);
167171
assert(
168172
serverSource.includes('/api/knowledge/operator/agent-workspace-diagnostics/triage/remediation/escalation/notification-thresholds/audit'),
169173
'Missing diagnostics remediation escalation notification-threshold audit route in src/server.ts'
@@ -348,6 +352,14 @@ function verifyAgentWorkspaceRuntime(repoRoot = path.resolve(__dirname, '..')) {
348352
serverSource.includes('buildAgentWorkspaceDiagnosticsRemediationEscalationNotificationThresholdPreview'),
349353
'Missing remediation escalation notification threshold preview helper in src/server.ts'
350354
);
355+
assert(
356+
serverSource.includes('buildAgentWorkspaceDiagnosticsRemediationEscalationNotificationThresholdPreviewFingerprint'),
357+
'Missing remediation escalation notification threshold preview fingerprint helper in src/server.ts'
358+
);
359+
assert(
360+
serverSource.includes('applyAgentWorkspaceDiagnosticsRemediationEscalationNotificationThresholdPreview'),
361+
'Missing remediation escalation notification threshold apply helper in src/server.ts'
362+
);
351363
assert(
352364
serverSource.includes('buildAgentWorkspaceDiagnosticsRemediationEscalationNotificationAnomalyReport'),
353365
'Missing remediation escalation notification anomaly report helper in src/server.ts'

0 commit comments

Comments
 (0)