@dsh-enhanced/assistant-evolution 0.1.7 → 0.1.14
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/README.md +58 -19
- package/cordis.patch.yml +3 -1
- package/lib/guidance.d.ts +2 -0
- package/lib/guidance.d.ts.map +1 -1
- package/lib/guidance.js +7 -1
- package/lib/guidance.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/review.d.ts +1 -1
- package/lib/review.d.ts.map +1 -1
- package/lib/review.js +22 -0
- package/lib/review.js.map +1 -1
- package/lib/service.d.ts +188 -6
- package/lib/service.d.ts.map +1 -1
- package/lib/service.js +903 -45
- package/lib/service.js.map +1 -1
- package/lib/sqlite.d.ts +1 -1
- package/lib/sqlite.d.ts.map +1 -1
- package/lib/sqlite.js +449 -7
- package/lib/sqlite.js.map +1 -1
- package/lib/store.d.ts +98 -3
- package/lib/store.d.ts.map +1 -1
- package/lib/store.js +1493 -107
- package/lib/store.js.map +1 -1
- package/lib/tools.d.ts.map +1 -1
- package/lib/tools.js +133 -2
- package/lib/tools.js.map +1 -1
- package/lib/types.d.ts +192 -11
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +2 -0
- package/lib/types.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.d.ts.map +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +14 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @dsh-enhanced/assistant-evolution
|
|
2
2
|
|
|
3
|
-
审批门控的行为自演化。助理观察自己在重复情境下的结果,当证据足够时提出一条行为规则,**经 owner
|
|
3
|
+
审批门控的行为自演化。助理观察自己在重复情境下的结果,当证据足够时提出一条行为规则,**经 owner 批准后**该规则才作为顾问性上下文影响后续会话。owner 可随时通过二次审批撤销 exact rule;可选的低风险自治通道也只能撤回一条已证实无效的 exact rule,二者都不能创建、修改或扩权。
|
|
4
4
|
|
|
5
5
|
这不是"让模型自己改自己"。它的价值在于把"经验"变成**可审计、可撤销、可解释**的持久对象:每条规则都能回答"依据哪些结果、谁批准的、有没有真的变好"。
|
|
6
6
|
|
|
@@ -14,26 +14,45 @@
|
|
|
14
14
|
dsh plugin --profile <name> add @dsh-enhanced/assistant-evolution
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
依赖 `@dsh-enhanced/assistant-policy`。未组合
|
|
17
|
+
依赖 `@dsh-enhanced/assistant-policy` 与 `@dsh-enhanced/assistant-evaluation`。未组合 Policy 或权威
|
|
18
|
+
Evaluation 账本时**拒绝加载**,而不是降级为无治理运行。
|
|
18
19
|
`@dsh-enhanced/assistant-delivery` 是可选 peer:存在时,插件从当前 Agent 的 authenticated owner route
|
|
19
20
|
派生 principal,并让 Policy 在创建提案的同一事务中保存 dispatch;不存在时只允许可信 headless 调用方
|
|
20
21
|
通过 Service API 显式传 principal。模型工具永远不能选择 principal 或审批期限。
|
|
22
|
+
独立 supervised-growth analyst 必须有 Delivery owner route,因此不使用 headless 降级。规则结算时生成的
|
|
23
|
+
application receipt 即使 Delivery 暂时不可用也会留在 Evolution 自己的 durable outbox,恢复后原位更新原审批卡。
|
|
24
|
+
该 presentation 不是公开 Delivery service 方法:Delivery 只向当前 Evolution producer generation 签发私有、
|
|
25
|
+
可撤销的进程内 capability。registration 不进入 Agent、tool schema、proposal payload 或 read API;服务替换、
|
|
26
|
+
卸载或 disposer 后旧 capability 立即失效,durable outbox 只会等待有效的新 registration 重试。
|
|
27
|
+
`@dsh-enhanced/assistant-automations` 也是可选 peer:仅当 Evaluation receipt 引用 automation run 时,
|
|
28
|
+
Evolution 才要求它提供并重新验证 exact production-run proof。普通非自动化 Evaluation 投影不依赖它。
|
|
29
|
+
默认 Cordis patch 会为完整 supervised-growth 组合声明该顺序依赖。
|
|
21
30
|
|
|
22
31
|
## 闭环
|
|
23
32
|
|
|
24
33
|
```text
|
|
25
|
-
|
|
34
|
+
Evaluation 客观/验证结果 → 计算候选 → 提案 → owner 批准 → 提交规则 → 注入为顾问上下文
|
|
26
35
|
↑ │
|
|
27
|
-
└──── 后续可信结果继续被观察 ──→
|
|
36
|
+
└──── 后续可信结果继续被观察 ──→ evidence retire / owner undo / 自动 rollback ┘
|
|
28
37
|
```
|
|
29
38
|
|
|
30
|
-
|
|
39
|
+
关键阶段都有独立边界:
|
|
31
40
|
|
|
32
|
-
1. **观察**:`evolution_observe
|
|
33
|
-
2. **推断**:`evolution_review` 只使用同一 workspace + Agent preset
|
|
34
|
-
3.
|
|
35
|
-
4.
|
|
36
|
-
5.
|
|
41
|
+
1. **观察**:`evolution_observe`(前台自报)和 `recordAutomationOutcome`(后台执行状态)都只写 operational audit,不能驱动学习。可信 Host 只能调用 `projectEvaluationOutcome({ scope, evaluationId })`:服务按 exact branded scope 从 `assistant-evaluation` 读取 frozen trusted receipt,并从 receipt 自己派生 situation、objective outcome、时间与证据类型。调用方不能提交或覆盖这些质量字段。当前只有明确的 `achieved / not-achieved` objective 可投影;`unknown` 拒绝,`partial` 明确返回 ignored/non-learning,绝不偷映射为一次完整失败。verification 在 Evaluation 增加 typed schema 前保持关闭。旧自由输入 `recordEvaluationOutcome` 永久 fail closed。非 Automation objective 的 `learningSubjectRef` 是 immutable Evaluation outcome;Automation objective 则从已验证 production proof 派生为 exact immutable run ID,`evidenceRef` 仍保持独立的 Evaluation ledger identity。一个 run 即使被多条 Evaluation outcome 重复评估,也最多形成一个 learning-eligible episode:相同结论返回原 row,矛盾结论 fail closed。
|
|
42
|
+
2. **推断**:`evolution_review` 只使用同一 workspace + Agent preset 下明确 learning-eligible、未归因的客观/验证结果计算 adopt 候选,**只到候选为止**。样本不足时保持沉默。每个候选还返回同一精确窗口中 newest-first 的有界 episode 样本(ID、Evaluation reference、证据类别、结果、有界 detail、时间)和整个窗口的 SHA-256 digest;detail 始终按不可信结果数据呈现,不能当作指令。
|
|
43
|
+
3. **独立 analyst**:`evolution_adoption_review` 与 `evolution_adoption_propose` 只接受 immutable `assistantAutomationExecution`,且必须是 production 模式、Automation ID 精确等于 `heartbeat:supervised-growth-analyst`、已绑定 authenticated Delivery owner route。review 按确定性优先级最多冻结一个 adopt 候选,返回随机 opaque token、完整窗口 digest/total/window、样本 ID 与有界 evidence。propose 只接受 `review_token + guidance`,在 SQLite writer lock 内重新验证 token、scope、occurrence、阈值和完整窗口。持久提案身份只绑定 `scope + situation + evidenceDigest + evidenceTotal + contractVersion`,不绑定 guidance、执行 ID 或措辞;并发、重启、不同措辞只生成一张卡,首个已提交 guidance 胜出。前台、preview、别的 Automation、无 owner route、旧 token 或证据变化全部 fail closed。
|
|
44
|
+
4. **提案**:`evolution_propose` 创建 `assistant-policy` 提案。adopt 与 retire 的基线都**从已记录证据读取**;retire 还必须在服务端重新找到同 scope、exact active rule ID + generation、至少 `minSample` 条 post-adoption 可信归因结果的当前候选。服务通过唯一的 canonical review renderer,把 op、exact scopeKey、situation、当前 guidance、generation、rule/version、reason、baseline/evaluation/evidence 和 server rule identity 全部冻结为 Policy diff;owner-undo 也冻结同一份当前规则快照,而不是只显示 UUID。这些字段始终是 plain untrusted review data,不会作为系统指令执行。adopt rule ID 由完整稳定 mutation(含 generation)确定性派生,精确重放不会换身份。principal 从可信 Delivery route 派生,因此直接调用 Service 也无法绕过 review、虚报依据或审批人。批准后的 audit 可通过不可变 rule ID 回溯该冻结 evidence reference。
|
|
45
|
+
5. **提交与真实终态**:owner 在审批面(如飞书卡片)决定后,`reconcileProposals()` 用 Policy 共享 validator 校验 proposal/requester/principal/action/resource/summary/diff/expiry/version/decision actor 的完整冻结 tuple;同一 SQLite writer transaction 还会重新规范化本地 mutation、强制 retire 的 evaluation/baseline/evidence snapshot 完整、重算 `mutation_hash`,并用同一个 renderer 重建 action/resource/summary/diff,与刚通过 Policy validator 的 expectation 及库内 expectation 精确重绑定。即使 Policy 已批准,legacy 无证据行、JSON 字段剥离、同步改写 JSON+hash,或 retire/adopt 换 op 都会持久化为 `conflicted`,绝不应用规则。该事务同时生成 domain-authoritative `applied / rejected / expired / conflicted` receipt,冻结 local/policy proposal、operation、exact rule/version/status、terminalAt 与 SHA-256 digest。独立 application outbox 通过 Delivery 的 `approval-application:<policyProposalId>` presentation 原位更新 `approval-card:<policyProposalId>`;Delivery 失败不回滚规则,崩溃后重放同 revision/digest,且从不把 Policy `approved` 自己显示成已应用。
|
|
46
|
+
6. **owner 即时撤销**:`evolution_undo` 只接收 `rule_id + expected_version + operation_id`,不接收 principal、reason、guidance 或权限字段。当前 Agent 提供 exact workspace + preset,Delivery 的 authenticated owner route 提供 principal;工具只创建独立 `evolution.owner-undo` Policy 审批,不能自行决定。owner 批准后,`reconcileProposals()` 对冻结 scope/rule/version 做 CAS 并立即 retire;无需回归样本,因为这是 owner 撤回自己的既有批准。错误 owner、跨 scope、旧 version、被另一张卡抢先结算的旧卡都拒绝或落为 `conflicted`。精确 operation replay 返回同一 durable proposal/rule receipt,重启后也可继续结算。
|
|
47
|
+
7. **低风险回滚(默认关闭)**:`evolution_rollback` 只接收 `rule_id + expected_version`。启用 `autonomousRollback` 且 Policy 对 exact `{action: rollback, resource: evolution/rule:<id>}` 放行后,Host 在 `BEGIN IMMEDIATE` 内重新读取同 scope、exact rule ID + generation 的可信 post-exposure 证据;只有样本达到 `minSample`、失败率达到 `retireFailureRate`,并且没有优于 adoption baseline 时才 retire。reason、risk=`low`、完整窗口 digest 和有界 episode ID 均由 Host 生成并与规则 compare-and-set、audit 在同一事务提交。它不能 adopt、改 guidance、改 Policy、选择证据或降低门槛。
|
|
48
|
+
|
|
49
|
+
`supervised-growth/v2` 的固定 Host 控制面无需伪造 Agent,也不读取 session header:Host 先用
|
|
50
|
+
`canonicalEvolutionHostScope({ workspace, preset })` 创建冻结 branded scope,再调用
|
|
51
|
+
`hostCandidates`、`hostListRules` 或 singular `hostRollbackOne`。每次调用必须携带 authenticated owner
|
|
52
|
+
`principal + operationId`,服务会用固定 background Policy subject
|
|
53
|
+
`dsh-enhanced-assistant-recovery` 对 exact workspace/action/resource 授权。复制/序列化 scope 会移除 brand
|
|
54
|
+
并 fail closed。Host rollback 与模型入口复用同一事务门,因此只有 exact exposure receipt 归因的
|
|
55
|
+
quality-eligible Evaluation evidence 可触发;`recordAutomationOutcome` 的 operational 行永远不算。
|
|
37
56
|
|
|
38
57
|
## 三条结构性安全边界
|
|
39
58
|
|
|
@@ -50,7 +69,7 @@ adopt 不会复用旧 ID;重新积累基线时也只看 retirement timestamp
|
|
|
50
69
|
|
|
51
70
|
## 规则要凭业绩留下
|
|
52
71
|
|
|
53
|
-
adopt 时会记录当时的**基线失败率**。只有 adopt 之后、同 scope
|
|
72
|
+
adopt 时会记录当时的**基线失败率**。只有 adopt 之后、同 scope、明确 learning-eligible 且归因到该 exact rule ID 与 generation 的客观/验证结果才参与 retire 判断;execution failed/succeeded、cross-scope、自报/claim、旧 generation,以及不足 `minSample` 的结果都不算,且会在任何 Policy proposal/dispatch 创建前 fail closed。该规则的表现必须**优于自己的基线**,否则成为 retire 候选。owner 审批的是冻结证据快照;结算仍以 exact rule version 做 compare-and-set,并复核冻结 adoption baseline 与样本归因结构,后续新 episode 不会悄悄改写已审批 diff。
|
|
54
73
|
|
|
55
74
|
## 工具
|
|
56
75
|
|
|
@@ -58,10 +77,13 @@ adopt 时会记录当时的**基线失败率**。只有 adopt 之后、同 scope
|
|
|
58
77
|
|---|---|---|
|
|
59
78
|
| `evolution_observe` | 记录一条前台自报结果 | 仅 append 审计证据,不驱动候选 |
|
|
60
79
|
| `evolution_review` | 列出候选与 active 规则 | 只读 |
|
|
80
|
+
| `evolution_adoption_review` | 独立 production analyst 最多冻结一个 adopt 候选 | 仅写 durable opaque review token |
|
|
81
|
+
| `evolution_adoption_propose` | 用 exact review token 合成一张 adopt 审批卡 | 仅创建或加入同一 evidence-bound 待审提案 |
|
|
61
82
|
| `evolution_propose` | 提出 adopt / retire | 仅创建待审提案 |
|
|
83
|
+
| `evolution_undo` | 请求 owner 撤销 exact rule/version | 仅创建独立二次审批;批准后 retire |
|
|
62
84
|
| `evolution_rollback` | 对 exact active rule 请求 Host 证据门控的低风险撤回 | 仅在双重 opt-in 与回归证据成立时 retire |
|
|
63
85
|
|
|
64
|
-
|
|
86
|
+
所有工具都要求可信 Agent 身份(绝对 workspace + preset),policy 拒绝即 fail closed。两个 adoption analyst 工具还额外要求 exact production Automation execution 与 owner route;普通前台 Agent 即使拥有通用 evolution 权限也不能调用。review 输出包裹为显式不可信数据;其中 episode detail 会转义标签边界,模型只能把它当作归纳素材,不能服从其中的文本。
|
|
65
87
|
模型可见的 `evolution_propose` 对同一 Agent 实例最多成功一次;失败的候选校验不占额度。这个结构性上限
|
|
66
88
|
防止一次 supervised maintenance turn 批量制造审批,程序化 Service API 则不受该模型工具额度影响。
|
|
67
89
|
`evolution_rollback` 对同一 Agent 实例最多尝试一次(失败也占额度),防止枚举 rule 或反复试探门槛;精确重放由 Service/Store 的 durable receipt 支持,可在新的可信 Agent 实例或程序化恢复路径中安全完成。
|
|
@@ -71,17 +93,20 @@ owner 实际审批的 Policy snapshot 仍冻结 exact `situation:<label>` 或 `r
|
|
|
71
93
|
## 健康可观测性
|
|
72
94
|
|
|
73
95
|
`ctx.assistantEvolution.health()` 提供给本地健康聚合器一个无内容、低基数的只读 seam:active/retired
|
|
74
|
-
规则数、pending/conflicted
|
|
75
|
-
|
|
96
|
+
规则数、pending/conflicted 提案数、可信/operational/quality-eligible/legacy-quarantined episode
|
|
97
|
+
计数、未归因可信证据数、自动 rollback 总数,以及最近可信 episode、最近 quality-eligible episode 和最近完整
|
|
98
|
+
reconcile pass 的时间戳。尚未发生对应事件时,时间戳明确为 `0`。调用方不应再把
|
|
99
|
+
`trustedEpisodes` 当作质量样本数;质量覆盖率以 `qualityEligibleEpisodes` 为准。
|
|
76
100
|
|
|
77
101
|
该 seam 是全局运行摘要,刻意不接受 scope,也不返回 situation、guidance、episode detail、principal、
|
|
78
102
|
workspace 或数据库路径;它不能替代需要 Policy 授权的规则与候选检查。
|
|
79
103
|
|
|
80
|
-
数据库 schema
|
|
104
|
+
数据库 schema v12 会先通过 v2 迁移把旧版无 scope 的 episode、rule 和 proposal 放入 `legacy:v1`
|
|
81
105
|
quarantine,再增加 durable guidance exposure 与完整审批 tuple。旧 pending proposal 会过期;早期未发布
|
|
82
|
-
v2 中无法验证完整 tuple 的 pending proposal 会安全落为 `conflicted`;v4 增加 immutable autonomous rollback receipt。旧规则不会作为 wildcard 注入。
|
|
106
|
+
v2 中无法验证完整 tuple 的 pending proposal 会安全落为 `conflicted`;v4 增加 immutable autonomous rollback receipt;v5 把所有旧 episode 标为 `legacy-unknown` 且 `learning_eligible=0`,并把所有基于旧证据尚未结算的 pending Evolution proposal 标为 `conflicted`。v6 先以 `(scope, immutable Evaluation ref)` 建立唯一身份;v7 重建 episode CHECK,使权威投影具有独立的 `evaluation` provenance。v8 新增独立 `learning_subject_ref` 和数据库唯一约束 `(scope, learning_subject_ref)`,从结构上阻止同一 Automation run 被多条 Evaluation outcome 放大样本数,同时不偷换 `evidence_ref` 的 Evaluation 语义。v7 旧 learning row 无法事后证明其 Automation run identity,因此迁移时一律保守降为 `legacy-unknown + learning_eligible=0`,并把受影响 scope 的 pending proposal 标为 `conflicted`;operational audit 不受影响。旧版 binary automation failure 或重复 Evaluation 结果都不能污染候选、adoption、延迟激活或 rollback。旧规则不会作为 wildcard 注入。
|
|
83
107
|
迁移和 episode/proposal settlement 使用 SQLite writer transaction;多进程同时打开、重放或提交时只有一个
|
|
84
108
|
winner,其余读取 winner 并做精确幂等比较。
|
|
109
|
+
v9 开始只接受 Evaluation 的 versioned task projection;v10 增加按 production occurrence 冻结的 analyst review ledger;v11 增加与 proposal settlement 同事务提交的 application receipt 和独立 presentation outbox。v12 为 task projection、analyst review 和候选证据加入 authoritative scope watermark 与完整 task-revision tuple:所有依赖证据的创建或结算都必须在 Evaluation 的 trusted writer fence 内重新证明;缺少这组冻结证据的旧 pending proposal 一律转为 `conflicted`,不会在稍后被批准时应用。旧终态在启动时会补投 outbox,新终态不会依赖 pending-proposal 扫描。
|
|
85
110
|
跨 Evolution/Policy 数据库创建审批时,Evolution 先持久化本地 intent,再调用 Policy 的原子
|
|
86
111
|
`recoverOrCreateProposal(notAfter)`:同一 writer transaction 内只会恢复 exact proposal、在绝对截止时间前创建,
|
|
87
112
|
或在截止后永久 tombstone 该 idempotency key。这样 lookup/create 竞争和重启都不会续期或留下 orphan approval card。
|
|
@@ -107,7 +132,7 @@ winner,其余读取 winner 并做精确幂等比较。
|
|
|
107
132
|
|
|
108
133
|
## 与 assistant-automations 的可选联动
|
|
109
134
|
|
|
110
|
-
若同时安装 `@dsh-enhanced/assistant-automations
|
|
135
|
+
若同时安装 `@dsh-enhanced/assistant-automations`,后台运行结束会成为可信的**运行审计**,但不会自动成为质量证据。Evolution 只在
|
|
111
136
|
`agent/session-start` guidance 注入成功**之后**,持久化 exact
|
|
112
137
|
`sessionId + workspace + Agent preset + situation + ruleId + generation` receipt。Automations 必须在 runner
|
|
113
138
|
返回 actual session ID 后调用 `captureAutomationExposure(...)`;缺 receipt、错 session/scope、未实际注入,
|
|
@@ -115,15 +140,28 @@ winner,其余读取 winner 并做精确幂等比较。
|
|
|
115
140
|
|
|
116
141
|
该绑定是**单向、可选、结构化**的:automations 不依赖本插件,没有 recorder 或 recorder 抛错时运行完全不受影响。`cancelled` 不计入——它不说明方法好坏,计入会污染失败率。
|
|
117
142
|
|
|
118
|
-
后台入口 `recordAutomationOutcome`
|
|
143
|
+
后台入口 `recordAutomationOutcome` 刻意最小:**只能追加 operational audit**。只有 payload 的
|
|
119
144
|
`automationId/sessionId/ruleId/guidanceVersion` 与 durable receipt 完整一致时才写入可信规则归因;否则
|
|
120
|
-
`ruleId` 仅作为 claim
|
|
145
|
+
`ruleId` 仅作为 claim 留档。无论 execution 是 succeeded 还是 failed,该入口都固定
|
|
146
|
+
`learningEligible=false`。权威 Evaluation 必须经独立的 `projectEvaluationOutcome` 入口,由服务读取
|
|
147
|
+
exact trusted receipt 并派生 objective evidence,才能参与统计。若 receipt 引用 automation run,Evolution 还会直接向
|
|
148
|
+
Automations 校验 production-only immutable proof,并把 exact immutable run ID 写成独立学习主体;多条 Evaluation row 不会把一个 run 重复计数。Recovery 或其他 caller 的转述不算。它不能 adopt / retire / 读取规则。因此 automation 依然无法在没有 owner
|
|
121
149
|
决定的情况下改变自己的行为。
|
|
122
150
|
|
|
151
|
+
Automation Agent 的 Host execution context 若明确为 `preview`,Evolution 在 `agent/session-start` 不注入
|
|
152
|
+
active guidance,也不写 exposure receipt;只有明确 `production` 或缺失 automation context 的普通前台会话
|
|
153
|
+
可进入注入路径。未知/畸形的未来 mode 按非 production fail closed。
|
|
154
|
+
|
|
123
155
|
成功注入的 receipt 也让同一 session 在正常重启/resume 后不重复注入同一 immutable generation。新代规则
|
|
124
156
|
可作为增量 guidance 注入;若旧规则已经进入该 session 的 LLM 历史,插件无法从上游不可变历史中物理删除
|
|
125
157
|
它,但 retired guidance 不会再次注入,也不会再为新 outcome 生成可信归因。
|
|
126
158
|
|
|
159
|
+
生产 Automation 注入时,exact `automation:<id>` 规则会在 `maxInjectedRules` 的全局切片**之前**置顶;即使
|
|
160
|
+
scope 内已有超过 12 条 active rule,目标规则仍会进入有界 guidance block 并写入 exposure receipt。普通
|
|
161
|
+
foreground 会话继续按 situation 稳定排序并受相同 rule-count/byte 上限约束。若 session-start 早于
|
|
162
|
+
Automation execution context 安装,post-setup `injectAutomationGuidance` 会依据 durable exposure 优先补入尚未
|
|
163
|
+
注入的 exact rule,不会因一次较早的全局切片而永久失去归因。
|
|
164
|
+
|
|
127
165
|
## 权限与非目标
|
|
128
166
|
|
|
129
167
|
- 文件系统:只读写配置的 SQLite 数据库及其 WAL/SHM 辅助文件。
|
|
@@ -132,3 +170,4 @@ winner,其余读取 winner 并做精确幂等比较。
|
|
|
132
170
|
- 不做向量检索、自动遗忘、跨设备同步、多用户 ACL。
|
|
133
171
|
- guidance 会进入模型上下文:不要在 guidance 中写入密钥或敏感数据。
|
|
134
172
|
- 自动 rollback 是收缩行为能力的安全阀,不是通用“AI 自批”入口;部署若启用,Policy 只应授予 `rollback`,不要把它复用为 adopt、权限或外部副作用授权。
|
|
173
|
+
- Host 控制面还需 Policy 明确允许 background subject `dsh-enhanced-assistant-recovery` 的 `inspect` 和按需 `rollback`;仅拿到 Cordis service 引用不等于获得权限。
|
package/cordis.patch.yml
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
name: '@dsh-enhanced/assistant-evolution'
|
|
4
4
|
inject:
|
|
5
5
|
- assistantPolicy
|
|
6
|
-
|
|
6
|
+
- assistantEvaluation
|
|
7
|
+
- assistantAutomations
|
|
8
|
+
# assistantDelivery remains optional and is discovered dynamically for owner routes.
|
|
7
9
|
config:
|
|
8
10
|
databasePath: !!js dshHomePath('assistant-evolution/evolution.sqlite')
|
|
9
11
|
evaluationWindow: 20
|
package/lib/guidance.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import type { StoredRule } from './types.js';
|
|
|
2
2
|
export interface GuidanceOptions {
|
|
3
3
|
maxBytes: number;
|
|
4
4
|
maxRules: number;
|
|
5
|
+
/** Exact production Automation situation that must survive the rule-count slice. */
|
|
6
|
+
prioritySituation?: string;
|
|
5
7
|
}
|
|
6
8
|
export interface GuidanceSnapshot {
|
|
7
9
|
text: string;
|
package/lib/guidance.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guidance.d.ts","sourceRoot":"","sources":["../src/guidance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"guidance.d.ts","sourceRoot":"","sources":["../src/guidance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,oFAAoF;IACpF,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,SAAS,UAAU,EAAE,CAAA;CAC7B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,EAAE,OAAO,EAAE,eAAe,GAAG,MAAM,CAE5F;AAED,kFAAkF;AAClF,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,SAAS,UAAU,EAAE,EAC5B,OAAO,EAAE,eAAe,GACvB,gBAAgB,CAoClB"}
|
package/lib/guidance.js
CHANGED
|
@@ -30,7 +30,13 @@ export function buildGuidanceSnapshot(rules, options) {
|
|
|
30
30
|
'still authorized independently. Each rule ID and generation is immutable.',
|
|
31
31
|
];
|
|
32
32
|
const footer = '</learned_guidance>';
|
|
33
|
-
const ordered = [...active].sort((left, right) =>
|
|
33
|
+
const ordered = [...active].sort((left, right) => {
|
|
34
|
+
const leftPriority = left.situation === options.prioritySituation;
|
|
35
|
+
const rightPriority = right.situation === options.prioritySituation;
|
|
36
|
+
if (leftPriority !== rightPriority)
|
|
37
|
+
return leftPriority ? -1 : 1;
|
|
38
|
+
return left.situation.localeCompare(right.situation);
|
|
39
|
+
});
|
|
34
40
|
const lines = [];
|
|
35
41
|
const included = [];
|
|
36
42
|
let total = Buffer.byteLength([...header, footer].join('\n'), 'utf8');
|
package/lib/guidance.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guidance.js","sourceRoot":"","sources":["../src/guidance.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"guidance.js","sourceRoot":"","sources":["../src/guidance.ts"],"names":[],"mappings":"AAcA;;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C,GAAG,EAAE,OAAO,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;AACvF,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ export declare const name = "dsh-enhanced-assistant-evolution";
|
|
|
6
6
|
export declare const inject: string[];
|
|
7
7
|
export { AssistantEvolutionService, version };
|
|
8
8
|
export type { Config };
|
|
9
|
-
export { AssistantEvolutionError } from './service.js';
|
|
10
|
-
export type { AssistantEvolutionHealth, EvolutionProposalResult, EvolutionRollbackResult, } from './service.js';
|
|
9
|
+
export { HOST_RECOVERY_BACKGROUND_ID, SUPERVISED_GROWTH_ANALYST_AUTOMATION_ID, AssistantEvolutionError, canonicalEvolutionHostScope, } from './service.js';
|
|
10
|
+
export type { AssistantEvolutionHealth, EvaluationOutcomeInput, EvaluationProjectionInput, EvolutionHostOperation, EvolutionHostScope, EvolutionOwnerUndoInput, EvolutionProposalResult, EvolutionRollbackResult, } from './service.js';
|
|
11
11
|
export * from './types.js';
|
|
12
12
|
export declare function apply(ctx: Context, config: Config): void;
|
|
13
13
|
export default AssistantEvolutionService;
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,eAAO,MAAM,IAAI,qCAAqC,CAAA;AACtD,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,eAAO,MAAM,IAAI,qCAAqC,CAAA;AACtD,eAAO,MAAM,MAAM,UAA6C,CAAA;AAChE,OAAO,EAAE,yBAAyB,EAAE,OAAO,EAAE,CAAA;AAC7C,YAAY,EAAE,MAAM,EAAE,CAAA;AACtB,OAAO,EACL,2BAA2B,EAC3B,uCAAuC,EACvC,uBAAuB,EACvB,2BAA2B,GAC5B,MAAM,cAAc,CAAA;AACrB,YAAY,EACV,wBAAwB,EACxB,sBAAsB,EACtB,yBAAyB,EACzB,sBAAsB,EACtB,kBAAkB,EAClB,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,cAAc,CAAA;AACrB,cAAc,YAAY,CAAA;AAE1B,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAExD;AAED,eAAe,yBAAyB,CAAA"}
|
package/lib/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AssistantEvolutionService } from './service.js';
|
|
2
2
|
import { version } from './version.js';
|
|
3
3
|
export const name = 'dsh-enhanced-assistant-evolution';
|
|
4
|
-
export const inject = ['assistantPolicy'];
|
|
4
|
+
export const inject = ['assistantPolicy', 'assistantEvaluation'];
|
|
5
5
|
export { AssistantEvolutionService, version };
|
|
6
|
-
export { AssistantEvolutionError } from './service.js';
|
|
6
|
+
export { HOST_RECOVERY_BACKGROUND_ID, SUPERVISED_GROWTH_ANALYST_AUTOMATION_ID, AssistantEvolutionError, canonicalEvolutionHostScope, } from './service.js';
|
|
7
7
|
export * from './types.js';
|
|
8
8
|
export function apply(ctx, config) {
|
|
9
9
|
new AssistantEvolutionService(ctx, config);
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAExD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,MAAM,CAAC,MAAM,IAAI,GAAG,kCAAkC,CAAA;AACtD,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,iBAAiB,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAExD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,MAAM,CAAC,MAAM,IAAI,GAAG,kCAAkC,CAAA;AACtD,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,iBAAiB,EAAE,qBAAqB,CAAC,CAAA;AAChE,OAAO,EAAE,yBAAyB,EAAE,OAAO,EAAE,CAAA;AAE7C,OAAO,EACL,2BAA2B,EAC3B,uCAAuC,EACvC,uBAAuB,EACvB,2BAA2B,GAC5B,MAAM,cAAc,CAAA;AAWrB,cAAc,YAAY,CAAA;AAE1B,MAAM,UAAU,KAAK,CAAC,GAAY,EAAE,MAAc;IAChD,IAAI,yBAAyB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;AAC5C,CAAC;AAED,eAAe,yBAAyB,CAAA"}
|
package/lib/review.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EvolutionMutation } from './types.js';
|
|
2
2
|
export interface EvolutionMutationReview {
|
|
3
|
-
action: 'evolution.adopt' | 'evolution.retire';
|
|
3
|
+
action: 'evolution.adopt' | 'evolution.retire' | 'evolution.owner-undo';
|
|
4
4
|
resource: Readonly<{
|
|
5
5
|
kind: 'evolution';
|
|
6
6
|
id: string;
|
package/lib/review.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"review.d.ts","sourceRoot":"","sources":["../src/review.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,iBAAiB,GAAG,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"review.d.ts","sourceRoot":"","sources":["../src/review.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,iBAAiB,GAAG,kBAAkB,GAAG,sBAAsB,CAAA;IACvE,QAAQ,EAAE,QAAQ,CAAC;QAAE,IAAI,EAAE,WAAW,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACrD,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;CACb;AAYD,iFAAiF;AACjF,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,uBAAuB,CAuD5F"}
|
package/lib/review.js
CHANGED
|
@@ -28,9 +28,31 @@ export function evolutionMutationReview(mutation) {
|
|
|
28
28
|
diff: JSON.stringify(projection),
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
+
if (mutation.op === 'owner-undo') {
|
|
32
|
+
const projection = {
|
|
33
|
+
op: mutation.op,
|
|
34
|
+
scopeKey: mutation.scopeKey,
|
|
35
|
+
ruleId: mutation.ruleId,
|
|
36
|
+
situation: mutation.situation,
|
|
37
|
+
guidance: mutation.guidance,
|
|
38
|
+
generation: mutation.generation,
|
|
39
|
+
expectedVersion: mutation.expectedVersion,
|
|
40
|
+
reason: mutation.reason,
|
|
41
|
+
};
|
|
42
|
+
return Object.freeze({
|
|
43
|
+
action: 'evolution.owner-undo',
|
|
44
|
+
resource: Object.freeze({ kind: 'evolution', id: `rule:${mutation.ruleId}` }),
|
|
45
|
+
summary: boundedSummary(`Undo learned guidance rule ${mutation.ruleId}`),
|
|
46
|
+
diff: JSON.stringify(projection),
|
|
47
|
+
});
|
|
48
|
+
}
|
|
31
49
|
const projection = {
|
|
32
50
|
op: mutation.op,
|
|
51
|
+
scopeKey: mutation.scopeKey,
|
|
33
52
|
ruleId: mutation.ruleId,
|
|
53
|
+
situation: mutation.situation,
|
|
54
|
+
guidance: mutation.guidance,
|
|
55
|
+
generation: mutation.generation,
|
|
34
56
|
expectedVersion: mutation.expectedVersion,
|
|
35
57
|
reason: mutation.reason,
|
|
36
58
|
evaluation: mutation.evaluation,
|
package/lib/review.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"review.js","sourceRoot":"","sources":["../src/review.ts"],"names":[],"mappings":"AASA,SAAS,cAAc,CAAC,KAAa;IACnC,IAAI,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,GAAG;QAAE,OAAO,KAAK,CAAA;IACzD,IAAI,OAAO,GAAG,EAAE,CAAA;IAChB,KAAK,MAAM,SAAS,IAAI,KAAK,EAAE,CAAC;QAC9B,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,OAAO,GAAG,SAAS,KAAK,EAAE,MAAM,CAAC,GAAG,GAAG;YAAE,MAAK;QACvE,OAAO,IAAI,SAAS,CAAA;IACtB,CAAC;IACD,OAAO,GAAG,OAAO,KAAK,CAAA;AACxB,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,uBAAuB,CAAC,QAA2B;IACjE,IAAI,QAAQ,CAAC,EAAE,KAAK,OAAO,EAAE,CAAC;QAC5B,MAAM,UAAU,GAAG;YACjB,EAAE,EAAE,QAAQ,CAAC,EAAE;YACf,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ;YACjC,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,SAAS;YACnC,QAAQ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AC;QACnB,MAAM,EAAE,kBAAkB;QAC1B,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,QAAQ,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;QAC7E,OAAO,EAAE,cAAc,CAAC,gCAAgC,QAAQ,CAAC,MAAM,EAAE,CAAC;QAC1E,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;KACjC,CAAC,CAAA;AACJ,CAAC"}
|
package/lib/service.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Context, Service } from '@deepseek-ai/cordis';
|
|
2
2
|
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
3
3
|
import Schema from '@deepseek-ai/schemastery';
|
|
4
|
+
import type { TrustedDeliveryPresentationProducer, TrustedDeliveryPresentationRegistration } from '@dsh-enhanced/assistant-delivery';
|
|
4
5
|
import type { ApprovalProposalResult } from '@dsh-enhanced/assistant-policy';
|
|
5
|
-
import type { EvolutionProposalMutation, RuleCandidate, StoredAutonomousRollback, StoredEpisode, StoredProposal, StoredRule } from './types.js';
|
|
6
|
+
import type { EvolutionProposalMutation, QualityEvidenceKind, RuleCandidate, StoredAutonomousRollback, StoredEpisode, StoredProposal, StoredRule, SupervisedGrowthAnalystProposalInput, SupervisedGrowthAnalystReview } from './types.js';
|
|
6
7
|
export interface Config {
|
|
7
8
|
databasePath: string;
|
|
8
9
|
/** Recent episodes per situation considered when judging a rule. */
|
|
@@ -36,6 +37,29 @@ export declare class AssistantEvolutionError extends Error {
|
|
|
36
37
|
readonly code: AssistantEvolutionErrorCode;
|
|
37
38
|
constructor(code: AssistantEvolutionErrorCode, message: string);
|
|
38
39
|
}
|
|
40
|
+
/** Fixed Policy subject used by the non-model supervised-growth runbook. */
|
|
41
|
+
export declare const HOST_RECOVERY_BACKGROUND_ID = "dsh-enhanced-assistant-recovery";
|
|
42
|
+
/** The only Automation allowed to use the model-visible analyst capability. */
|
|
43
|
+
export declare const SUPERVISED_GROWTH_ANALYST_AUTOMATION_ID: "heartbeat:supervised-growth-analyst";
|
|
44
|
+
declare const evolutionHostScopeBrand: unique symbol;
|
|
45
|
+
export interface EvolutionHostScope extends Readonly<{
|
|
46
|
+
workspace: string;
|
|
47
|
+
preset: string;
|
|
48
|
+
}> {
|
|
49
|
+
readonly [evolutionHostScopeBrand]: true;
|
|
50
|
+
}
|
|
51
|
+
/** Canonical, immutable and intentionally non-serializable Host scope token. */
|
|
52
|
+
export declare function canonicalEvolutionHostScope(input: {
|
|
53
|
+
workspace: string;
|
|
54
|
+
preset: string;
|
|
55
|
+
}): EvolutionHostScope;
|
|
56
|
+
export interface EvolutionHostOperation {
|
|
57
|
+
scope: EvolutionHostScope;
|
|
58
|
+
/** Authenticated owner identity supplied by the Host route. */
|
|
59
|
+
principal: string;
|
|
60
|
+
/** Exact fixed-run receipt/run identifier used for Policy budget idempotency. */
|
|
61
|
+
operationId: string;
|
|
62
|
+
}
|
|
39
63
|
export interface EvolutionProposalResult {
|
|
40
64
|
proposalId: string;
|
|
41
65
|
policyProposalId: string;
|
|
@@ -49,6 +73,13 @@ export interface EvolutionRollbackResult {
|
|
|
49
73
|
rule: StoredRule;
|
|
50
74
|
replayed: boolean;
|
|
51
75
|
}
|
|
76
|
+
export interface EvolutionOwnerUndoInput {
|
|
77
|
+
ruleId: string;
|
|
78
|
+
expectedVersion: number;
|
|
79
|
+
/** Host-generated stable identity for exact request replay. */
|
|
80
|
+
operationId: string;
|
|
81
|
+
ttlMs?: number;
|
|
82
|
+
}
|
|
52
83
|
/** Content-free, global operational summary for local health aggregation. */
|
|
53
84
|
export interface AssistantEvolutionHealth {
|
|
54
85
|
activeRules: number;
|
|
@@ -56,11 +87,20 @@ export interface AssistantEvolutionHealth {
|
|
|
56
87
|
pendingProposals: number;
|
|
57
88
|
conflictedProposals: number;
|
|
58
89
|
trustedEpisodes: number;
|
|
90
|
+
qualityEligibleEpisodes: number;
|
|
91
|
+
operationalEpisodes: number;
|
|
92
|
+
legacyQuarantinedEpisodes: number;
|
|
59
93
|
unattributedTrustedEpisodes: number;
|
|
94
|
+
unattributedQualityEligibleEpisodes: number;
|
|
60
95
|
lastTrustedEpisodeAt: number;
|
|
96
|
+
lastQualityEligibleEpisodeAt: number;
|
|
61
97
|
/** Last fully completed reconciliation pass; zero means none has completed. */
|
|
62
98
|
lastReconciledAt: number;
|
|
63
99
|
autonomousRollbacks: number;
|
|
100
|
+
taskLearningProjections: number;
|
|
101
|
+
retractedTaskLearningProjections: number;
|
|
102
|
+
taskLearningProjectionRevisions: number;
|
|
103
|
+
taskLearningProjectionIntegrityErrors: number;
|
|
64
104
|
}
|
|
65
105
|
export interface ForegroundEpisodeInput {
|
|
66
106
|
situation: string;
|
|
@@ -72,6 +112,30 @@ export interface ForegroundEpisodeInput {
|
|
|
72
112
|
occurredAt: number;
|
|
73
113
|
idempotencyKey: string;
|
|
74
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Deprecated pre-v7 free-form shape, retained only as a source-compatibility
|
|
117
|
+
* type. recordEvaluationOutcome() always rejects it and never writes evidence.
|
|
118
|
+
*/
|
|
119
|
+
export interface EvaluationOutcomeInput {
|
|
120
|
+
situation: string;
|
|
121
|
+
outcome: 'succeeded' | 'failed';
|
|
122
|
+
detail: string;
|
|
123
|
+
evidenceKind: QualityEvidenceKind;
|
|
124
|
+
evaluationId: string;
|
|
125
|
+
idempotencyKey: string;
|
|
126
|
+
occurredAt: number;
|
|
127
|
+
workspace: string;
|
|
128
|
+
agentPreset: string;
|
|
129
|
+
automationId?: string;
|
|
130
|
+
sessionId?: string;
|
|
131
|
+
ruleId?: string;
|
|
132
|
+
guidanceVersion?: number;
|
|
133
|
+
}
|
|
134
|
+
/** The only input accepted by the authoritative quality projection seam. */
|
|
135
|
+
export interface EvaluationProjectionInput {
|
|
136
|
+
scope: EvolutionHostScope;
|
|
137
|
+
evaluationId: string;
|
|
138
|
+
}
|
|
75
139
|
export declare function canonicalEvolutionScope(workspace: string, preset: string): string;
|
|
76
140
|
declare module '@deepseek-ai/cordis' {
|
|
77
141
|
interface Context {
|
|
@@ -95,15 +159,17 @@ declare module '@deepseek-ai/cordis' {
|
|
|
95
159
|
* may remove the old rule, but the replacement still needs its own approval,
|
|
96
160
|
* so an old decision can never silently cover new guidance.
|
|
97
161
|
*/
|
|
98
|
-
export declare class AssistantEvolutionService extends Service {
|
|
162
|
+
export declare class AssistantEvolutionService extends Service implements TrustedDeliveryPresentationProducer {
|
|
99
163
|
static Config: Schema<Config>;
|
|
100
164
|
static inject: string[];
|
|
101
165
|
private readonly store;
|
|
102
166
|
private readonly policy;
|
|
167
|
+
private readonly context;
|
|
103
168
|
private readonly config;
|
|
104
|
-
private readonly injected;
|
|
105
169
|
private readonly now;
|
|
106
170
|
private delivery;
|
|
171
|
+
private readonly presentationProducerGeneration;
|
|
172
|
+
private presentationSink;
|
|
107
173
|
private active;
|
|
108
174
|
private lastReconciledAt;
|
|
109
175
|
constructor(ctx: Context, input: Config, options?: {
|
|
@@ -111,11 +177,20 @@ export declare class AssistantEvolutionService extends Service {
|
|
|
111
177
|
});
|
|
112
178
|
/** Aggregate health seam. It never returns content, identities, scopes, or paths. */
|
|
113
179
|
health(): Readonly<AssistantEvolutionHealth>;
|
|
114
|
-
|
|
180
|
+
trustedDeliveryPresentationProducerGeneration(): string;
|
|
181
|
+
/**
|
|
182
|
+
* Accept only the publisher minted by the exact live Delivery instance.
|
|
183
|
+
* The registration is held privately; it is never surfaced to an Agent,
|
|
184
|
+
* tool schema, proposal payload, or Evolution read API.
|
|
185
|
+
*/
|
|
186
|
+
registerTrustedDeliveryPresentationSink(registration: Readonly<TrustedDeliveryPresentationRegistration>): () => void;
|
|
187
|
+
/** Record one model-reported outcome as learning-ineligible operational audit. */
|
|
115
188
|
recordEpisode(agent: Agent | undefined, input: ForegroundEpisodeInput): StoredEpisode;
|
|
116
189
|
/**
|
|
117
|
-
* Record an outcome observed by trusted local infrastructure rather
|
|
118
|
-
* turn, for example a finished background automation run.
|
|
190
|
+
* Record an execution outcome observed by trusted local infrastructure rather
|
|
191
|
+
* than a model turn, for example a finished background automation run. It is
|
|
192
|
+
* deliberately operational and learning-ineligible: execution success/failure
|
|
193
|
+
* does not establish objective task quality.
|
|
119
194
|
*
|
|
120
195
|
* There is no Agent to authorize here, so this is deliberately narrow: it can
|
|
121
196
|
* only append evidence. It cannot adopt, retire, or read rules, so an automation
|
|
@@ -135,6 +210,55 @@ export declare class AssistantEvolutionService extends Service {
|
|
|
135
210
|
ruleId?: string;
|
|
136
211
|
guidanceVersion?: number;
|
|
137
212
|
}): StoredEpisode;
|
|
213
|
+
/**
|
|
214
|
+
* Deprecated unsafe v5 shape. Free caller-supplied quality fields can never
|
|
215
|
+
* produce learning-eligible evidence again; use projectEvaluationOutcome().
|
|
216
|
+
*/
|
|
217
|
+
recordEvaluationOutcome(input: EvaluationOutcomeInput): StoredEpisode;
|
|
218
|
+
/**
|
|
219
|
+
* Project one exact trusted Evaluation row into the learning ledger. The
|
|
220
|
+
* caller cannot supply outcome, detail, kind, time, situation or attribution.
|
|
221
|
+
*/
|
|
222
|
+
projectEvaluationOutcome(input: EvaluationProjectionInput): StoredEpisode;
|
|
223
|
+
/**
|
|
224
|
+
* Narrow structural seam used only by Evaluation's durable outbox. The raw
|
|
225
|
+
* scope is canonicalized here; quality fields are still fetched exclusively
|
|
226
|
+
* from the trusted Evaluation ledger.
|
|
227
|
+
*/
|
|
228
|
+
projectTrustedEvaluationOutcome(_input: {
|
|
229
|
+
scope: Readonly<{
|
|
230
|
+
workspace: string;
|
|
231
|
+
preset: string;
|
|
232
|
+
}>;
|
|
233
|
+
evaluationId: string;
|
|
234
|
+
}): never;
|
|
235
|
+
/** Evaluation protocol v2 sink. Every success echoes the exact applied revision. */
|
|
236
|
+
projectTrustedEvaluationTaskRevision(input: {
|
|
237
|
+
scope: Readonly<{
|
|
238
|
+
workspace: string;
|
|
239
|
+
preset: string;
|
|
240
|
+
}>;
|
|
241
|
+
evaluationId: string;
|
|
242
|
+
}): Readonly<{
|
|
243
|
+
triggerOutcomeId: string;
|
|
244
|
+
subjectKind: 'automation-run' | 'outcome';
|
|
245
|
+
subjectRef: string;
|
|
246
|
+
version: number;
|
|
247
|
+
digest: string;
|
|
248
|
+
scopeWatermark: number;
|
|
249
|
+
disposition: 'upsert' | 'retract';
|
|
250
|
+
status: 'applied' | 'replayed';
|
|
251
|
+
}>;
|
|
252
|
+
/**
|
|
253
|
+
* Called by Assistant Automations only after it installed the immutable
|
|
254
|
+
* production execution context and bound the Policy initiator. This closes
|
|
255
|
+
* the session-start ordering gap without weakening background Policy.
|
|
256
|
+
*/
|
|
257
|
+
injectAutomationGuidance(agent: Agent, execution: Readonly<{
|
|
258
|
+
mode: 'preview' | 'production';
|
|
259
|
+
automationId: string;
|
|
260
|
+
occurrenceId: string;
|
|
261
|
+
}>): void;
|
|
138
262
|
/** Query an exact post-injection receipt for trusted automation attribution. */
|
|
139
263
|
captureAutomationExposure(input: {
|
|
140
264
|
workspace: string;
|
|
@@ -147,7 +271,25 @@ export declare class AssistantEvolutionService extends Service {
|
|
|
147
271
|
} | undefined>;
|
|
148
272
|
/** Candidate rule changes implied by current evidence. Never auto-applied. */
|
|
149
273
|
candidates(agent: Agent | undefined): RuleCandidate[];
|
|
274
|
+
/** Agent-free, exact-scope candidate inspection for the fixed Host runbook. */
|
|
275
|
+
hostCandidates(input: EvolutionHostOperation): RuleCandidate[];
|
|
276
|
+
/**
|
|
277
|
+
* Review exactly one adoption candidate from the dedicated production
|
|
278
|
+
* analyst. The random review token is durable and bound to this occurrence;
|
|
279
|
+
* no foreground or preview session can obtain one.
|
|
280
|
+
*/
|
|
281
|
+
reviewSupervisedGrowthAdoption(agent: Agent | undefined): Readonly<SupervisedGrowthAnalystReview>;
|
|
282
|
+
/**
|
|
283
|
+
* Turn one frozen analyst review into the normal owner approval. Identity is
|
|
284
|
+
* evidence-derived; wording changes and concurrent executions join the first
|
|
285
|
+
* durable proposal instead of producing several cards.
|
|
286
|
+
*/
|
|
287
|
+
proposeSupervisedGrowthAdoption(agent: Agent | undefined, input: SupervisedGrowthAnalystProposalInput): EvolutionProposalResult;
|
|
150
288
|
listRules(agent: Agent | undefined, status?: 'active' | 'retired'): StoredRule[];
|
|
289
|
+
/** Agent-free, exact-scope rule inspection for the fixed Host runbook. */
|
|
290
|
+
hostListRules(input: EvolutionHostOperation & {
|
|
291
|
+
status?: 'active' | 'retired';
|
|
292
|
+
}): StoredRule[];
|
|
151
293
|
/**
|
|
152
294
|
* Remove one exact active guidance generation through the opt-in low-risk lane.
|
|
153
295
|
*
|
|
@@ -159,6 +301,26 @@ export declare class AssistantEvolutionService extends Service {
|
|
|
159
301
|
ruleId: string;
|
|
160
302
|
expectedVersion: number;
|
|
161
303
|
}): EvolutionRollbackResult;
|
|
304
|
+
/**
|
|
305
|
+
* Retire one exact active rule by CAS. The Store admits only quality-eligible
|
|
306
|
+
* objective/verification evidence attributed to an exact exposure receipt;
|
|
307
|
+
* operational automation outcomes cannot satisfy this lane.
|
|
308
|
+
*/
|
|
309
|
+
hostRollbackOne(input: EvolutionHostOperation & {
|
|
310
|
+
ruleId: string;
|
|
311
|
+
expectedVersion: number;
|
|
312
|
+
}): EvolutionRollbackResult;
|
|
313
|
+
/**
|
|
314
|
+
* Ask the authenticated owner to remove one exact active guidance version.
|
|
315
|
+
*
|
|
316
|
+
* This is intentionally a proposal, not a direct rollback: the current Agent
|
|
317
|
+
* supplies the exact workspace/preset scope, Delivery supplies the owner
|
|
318
|
+
* principal, and Policy freezes a distinct `evolution.owner-undo` review
|
|
319
|
+
* tuple. Approval can only retire the rule; it cannot revise its guidance or
|
|
320
|
+
* grant authority. No regression sample is required because the owner is the
|
|
321
|
+
* authority withdrawing their own earlier approval.
|
|
322
|
+
*/
|
|
323
|
+
requestOwnerUndo(agent: Agent | undefined, input: EvolutionOwnerUndoInput): EvolutionProposalResult;
|
|
162
324
|
/**
|
|
163
325
|
* Propose adopting or retiring a rule. Returns a pending proposal; the owner
|
|
164
326
|
* decides through the normal approval surface.
|
|
@@ -175,10 +337,30 @@ export declare class AssistantEvolutionService extends Service {
|
|
|
175
337
|
* pending forever. Safe to call repeatedly.
|
|
176
338
|
*/
|
|
177
339
|
reconcileProposals(limit?: number): EvolutionProposalResult[];
|
|
340
|
+
/**
|
|
341
|
+
* Publish domain terminal receipts independently from proposal polling. A
|
|
342
|
+
* crash after Delivery accepts but before the local ack simply republishes the
|
|
343
|
+
* same revision and digest on restart.
|
|
344
|
+
*/
|
|
345
|
+
reconcileApplicationPresentations(limit?: number): number;
|
|
346
|
+
private applicationPresentation;
|
|
178
347
|
private submitLocalProposal;
|
|
179
348
|
private attachPolicySnapshot;
|
|
180
349
|
private settleAttached;
|
|
181
350
|
private approvalRoute;
|
|
351
|
+
/**
|
|
352
|
+
* Acquire Evaluation first and Evolution only inside its synchronous callback.
|
|
353
|
+
* No code holding an Evolution writer lock is allowed to call this method.
|
|
354
|
+
*/
|
|
355
|
+
private withLearningWriterFence;
|
|
356
|
+
private candidatesForScope;
|
|
357
|
+
private trustedTaskLearningReceipt;
|
|
358
|
+
private applyTrustedTaskLearningReceipt;
|
|
359
|
+
private verifiedAutomationAttribution;
|
|
360
|
+
private normalizedRollbackInput;
|
|
361
|
+
private rollbackForScope;
|
|
362
|
+
private authorizeHost;
|
|
363
|
+
private authorizeSupervisedGrowthAnalyst;
|
|
182
364
|
/** Guidance block for the current active rules, as injected into a session. */
|
|
183
365
|
guidance(agent?: Agent): string;
|
|
184
366
|
private guidanceForScope;
|