@dsh-ray/assistant-growth-experiments 0.0.0-stage → 0.2.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dsh-ray contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,127 @@
1
- # Temporary Holding Version
1
+ # @dsh-ray/assistant-growth-experiments
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > **显式启用的受监督能力,非默认能力。** 默认个人助理安装不会加载本包。启用时它只组合
4
+ > `@dsh-ray/assistant-growth-contract`、Delivery 和 Automations 的当前 Host 协议;没有这些
5
+ > 精确边界会拒绝启动,绝不降级为接受任意 trace 或模型自报。
6
+
7
+ 这是基于可信、版本化工作流证据的持久成长实验控制器:只接受 Delivery 的结构化 trace
8
+ projection,不让原始工具参数离开其 Host 边界;候选经 owner 审批后,**默认(`promotionMode:
9
+ 'propose-only'`)停在终态 `approved-paused`**——只沉淀 paused artifact 供 owner 处置,不再继续
10
+ 后续阶段。把 `promotionMode` 显式置为 `'full'` 才恢复受监督序列:依次执行 replay、阻断
11
+ 全部外部副作用的 shadow、至多一次 production canary,并且只有收到 `trusted + achieved` 评估后
12
+ 才使用 Automation CAS 提升。其余路径一律回滚。
13
+
14
+ ## 开发者显式安装
15
+
16
+ ```sh
17
+ dsh plugin --profile web add @dsh-ray/assistant-growth-experiments
18
+ dsh --profile web --dump-config
19
+ ```
20
+
21
+ ## 配置
22
+
23
+ ```yaml
24
+ - id: dsh-ray-assistant-growth-experiments
25
+ name: '@dsh-ray/assistant-growth-experiments'
26
+ inject:
27
+ - assistantAutomations
28
+ - assistantDelivery
29
+ config:
30
+ databasePath: !!js dshHomePath('assistant-growth-experiments/growth.sqlite')
31
+ tickIntervalMs: 5000
32
+ minRepeatedSuccesses: 3
33
+ maxBatchSize: 10
34
+ maxExperimentDurationMs: 604800000
35
+ maxOperationAttempts: 8
36
+ retryBaseMs: 1000
37
+ retryMaxMs: 60000
38
+ # propose-only(默认):owner approved-paused 后即进入终态,绝不 replay/canary/promote。
39
+ # 显式置为 full 才恢复受监督实验序列。
40
+ promotionMode: propose-only
41
+ ```
42
+
43
+ ## 证据入口与私有 capability
44
+
45
+ Delivery 是唯一的 workflow trace producer。Growth 启动时调用
46
+ `registerWorkflowTraceSink({ contractVersion: 1, sink })`,取得固定
47
+ `sourceId: assistantDelivery`、持久 generation、authority digest 和 disposer。该 sink 是只交给
48
+ 当前注入实例的进程内 capability:Growth 没有 `projectWorkflowTraceRevision` 公共 service 方法,
49
+ 也不会把 sink、registration 或 source attestation 暴露为模型工具。Delivery 或 Growth 卸载、替换
50
+ 或调用 disposer 时会撤权;旧 sink 和旧 generation 不能继续写入。
51
+
52
+ Delivery 先把 revision 写进自己的 durable trace outbox,随后才异步投影并严格校验回执。暂时的
53
+ sink 失败保留原 revision、按退避重试;重载后的有效 registration 会重放当前 revision。每条
54
+ `WorkflowTraceRevision` 都必须携带与该 registration 完全相同的 source attestation,版本允许跳号,
55
+ 但旧版本、同版本不同内容或 digest 不一致都会拒绝。
56
+
57
+ 自动学习只有一个封闭来源:当前 active owner 必须直接回复一条已取得 provider message id 的普通
58
+ Agent reply,发送精确的 `/feedback achieved`;该 reply 的原始入站正文还必须逐字命中 Delivery
59
+ 审查过的静态 catalog selector。selector 不做 trim、大小写折叠、参数解析或实体提取,生成的模板
60
+ 也完全是静态内容。只有这一组合会原子生成 content-free 的 `verified-repetition` trace;`partial`、
61
+ `not-achieved`、未命中 catalog、preview/失败运行、手写 background intent 或无法由 durable
62
+ Inbox/Outbox 重新证明的 reply 只会得到不可改写的本地 no-trace 回执。
63
+
64
+ `/workflow save` 仍是单独的 owner-explicit 路径:它只产生带
65
+ `owner-explicit / deidentification-unproven` attestation 的候选,绝不直接启用 Automation。一个
66
+ owner-explicit trace 可以使候选 ready;自动路径则必须累积至少 `minRepeatedSuccesses` 个不同、当前
67
+ 有效的 `trusted + achieved` taskRef。重复投影同一 taskRef 不会抬高计数。
68
+
69
+ 第三种信号是 `owner-anchored`(2026-09-18 起,由 `assistant-growth-driver` 的独立开关
70
+ `workflowOwnerAnchored.enabled` opt-in,默认关):driver 不起模型,只把 locator 交给 Delivery 的
71
+ Host-only `commitOwnerAnchoredWorkflowTrace`;Delivery 自己再调 goals
72
+ `inspectOwnerVerifiedWorkflowSource` 独立重取证据,只接受可归约为单步零工具 agent-turn 的真实
73
+ owner-root 成功 goal,产出 `owner-anchored / deidentification-unproven / provenance
74
+ owner-goal-success` attestation。自由 objective 的 templateDigest 天然互不相同,结构上聚不齐重复
75
+ 门,故该信号**单条即让 candidate ready**(不要求 `minRepeatedSuccesses`),后续同样走
76
+ `initialState: paused` 的 owner 批准链;paused artifact 冻结占位 cron `0 0 29 2 *` UTC,Automations
77
+ store 层禁止它在 owner 显式换真 schedule 前转 active(owner 批准 resume 会落 `conflicted`、行保持
78
+ paused)。这是工程层本地证据,不是真实外部平台证据。
79
+
80
+ trace source 使用导出的 `workflowArgumentShapeDigest(value)`:它只编码 JSON 类型、对象字段和数组
81
+ 成员类型集合,标量值、数组长度和顺序不会进入 fingerprint。Delivery 将可复用模板内容保留在私有
82
+ registry,只向 Growth 投影 `templateRef/templateDigest/privacyAttestation`;Growth 不保存 raw prompt。
83
+ 这里的可信根是持有私有 sink capability 的 Host 注入 Delivery,而不是 revision 中可伪造的字符串。
84
+
85
+ ## 受监督实验序列
86
+
87
+ Automations 实现导出的 `GrowthAutomationPort`。每个跨库动作先持久化 operation intent,再以固定
88
+ `operationId` 调用;同一 operation 必须精确重放同一 receipt,payload 变化即拒绝。审批只能创建
89
+ `initialState: paused` 的 Automation。在 `propose-only`(默认)下,owner 批准 paused 后实验进入
90
+ 终态 `approved-paused`:replay/shadow/canary/promotion 代码保留但不会被调用,后续 tick 也不会
91
+ 再唤醒它,批准不产生任何生产暴露。仅当显式配置 `promotionMode: 'full'` 时,批准后才按固定顺序
92
+ replay → effect-blocked shadow → 单次 production canary → trusted `achieved` 检查 → CAS
93
+ promotion。`full` 模式下,canary 启动与查询是两个接口:
94
+ `canaryWorkflowAutomation` 只允许一个固定 exposure operation,pending 状态只能由
95
+ `inspectWorkflowCanary` 查询,不能重新暴露。任一拒绝、过期、证据变化、失败或恢复预算耗尽都会走
96
+ durable rollback,而不是把 paused artifact 留作已启用。
97
+
98
+ Automations 在真正创建 artifact 时才向 Delivery 的私有 resolver 解析 template reference;Growth
99
+ 始终只携带 content-free reference,不能读取或改写 owner prompt、principal 或 delivery binding。
100
+
101
+ ## schema v2 边界
102
+
103
+ 当前账本为 schema v2。v1 是曾保存 prompt-bearing template 的未发布原型,无法在保留该数据的同时
104
+ 满足 content-free 边界,因此**不做就地迁移**:启动会 fail closed。升级者必须先归档或显式删除旧
105
+ v1 数据库,再创建新的 v2 私有账本;不得把旧模板复制进 v2 或伪造 trace 来绕过该边界。
106
+
107
+ 服务名为 `assistantGrowthExperiments`。`health()` 只暴露固定计数和可选错误码,不返回
108
+ workspace、身份、证据内容或数据库路径。
109
+
110
+ ## 权限与数据
111
+
112
+ - 文件系统:在 `databasePath` 创建 mode `0600` 的 SQLite/WAL 账本;父目录为私有目录。
113
+ - 网络:无直接网络访问;跨系统调用只经注入的 Automation/Delivery Host service。
114
+ - 子进程:无。
115
+ - 凭据:不读取、不保存。
116
+ - 浏览器:无。
117
+ - 安装脚本:无。
118
+
119
+ 账本只保存工具 catalog id 和“已脱敏参数结构”的 SHA-256,不接受原始参数值。deadline
120
+ 或尝试预算耗尽后不会提升;已存在 paused/canary artifact 的失败路径进入持久 rollback
121
+ intent。rollback 暂时不可达时保持 fail-closed 并在 health 中报告,而不是伪造终态。
122
+
123
+ ## 兼容性
124
+
125
+ See the repository [compatibility baseline](../../docs/compatibility.md).
126
+
127
+ Promoted experiments can enter `rollback-pending` when their exact canary's canonical objective is corrected or withdrawn. Automations sends the exact artifact version it paused; Growth persists that version and replays the rollback receipt after restart. Ordinary foreground workflow revisions continue through the existing trace/candidate invalidation path. Historical outcomes and unrelated deployments are preserved.
@@ -0,0 +1,15 @@
1
+ - insert:
2
+ - id: dsh-ray-assistant-growth-experiments
3
+ name: '@dsh-ray/assistant-growth-experiments'
4
+ inject:
5
+ - assistantAutomations
6
+ - assistantDelivery
7
+ config:
8
+ databasePath: !!js dshHomePath('assistant-growth-experiments/growth.sqlite')
9
+ tickIntervalMs: 5000
10
+ minRepeatedSuccesses: 3
11
+ maxBatchSize: 10
12
+ maxExperimentDurationMs: 604800000
13
+ maxOperationAttempts: 8
14
+ retryBaseMs: 1000
15
+ retryMaxMs: 60000
package/lib/index.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import { AssistantGrowthExperimentsService, Config, type AssistantGrowthExperimentsConfig } from './service.js';
3
+ import { version } from './version.js';
4
+ export declare const name = "dsh-ray-assistant-growth-experiments";
5
+ export declare const inject: string[];
6
+ export { AssistantGrowthExperimentsService, Config, version };
7
+ export type { AssistantGrowthExperimentsConfig };
8
+ export * from './store.js';
9
+ export * from './types.js';
10
+ export declare function apply(ctx: Context, config: AssistantGrowthExperimentsConfig): void;
11
+ export default AssistantGrowthExperimentsService;
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,EACL,iCAAiC,EACjC,MAAM,EACN,KAAK,gCAAgC,EACtC,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,eAAO,MAAM,IAAI,yCAAyC,CAAA;AAC1D,eAAO,MAAM,MAAM,UAAgD,CAAA;AACnE,OAAO,EAAE,iCAAiC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAA;AAC7D,YAAY,EAAE,gCAAgC,EAAE,CAAA;AAChD,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAE1B,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,gCAAgC,GAAG,IAAI,CAElF;AAED,eAAe,iCAAiC,CAAA"}
package/lib/index.js ADDED
@@ -0,0 +1,12 @@
1
+ import { AssistantGrowthExperimentsService, Config, } from './service.js';
2
+ import { version } from './version.js';
3
+ export const name = 'dsh-ray-assistant-growth-experiments';
4
+ export const inject = ['assistantAutomations', 'assistantDelivery'];
5
+ export { AssistantGrowthExperimentsService, Config, version };
6
+ export * from './store.js';
7
+ export * from './types.js';
8
+ export function apply(ctx, config) {
9
+ new AssistantGrowthExperimentsService(ctx, config);
10
+ }
11
+ export default AssistantGrowthExperimentsService;
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iCAAiC,EACjC,MAAM,GAEP,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,MAAM,CAAC,MAAM,IAAI,GAAG,sCAAsC,CAAA;AAC1D,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,sBAAsB,EAAE,mBAAmB,CAAC,CAAA;AACnE,OAAO,EAAE,iCAAiC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAA;AAE7D,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAE1B,MAAM,UAAU,KAAK,CAAC,GAAY,EAAE,MAAwC;IAC1E,IAAI,iCAAiC,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;AACpD,CAAC;AAED,eAAe,iCAAiC,CAAA"}
@@ -0,0 +1,53 @@
1
+ import { Context, Service } from '@deepseek-ai/cordis';
2
+ import Schema from '@deepseek-ai/schemastery';
3
+ import { growthPortReceiptDigest } from '@dsh-ray/assistant-growth-contract';
4
+ import type { GrowthExperiment, GrowthExperimentConfig, GrowthExperimentHealth, WorkflowCandidate } from './types.js';
5
+ export type AssistantGrowthExperimentsConfig = GrowthExperimentConfig;
6
+ export declare const Config: Schema<GrowthExperimentConfig>;
7
+ export type AssistantGrowthExperimentsErrorCode = 'disposed' | 'invalid-input' | 'service-unavailable';
8
+ export declare class AssistantGrowthExperimentsError extends Error {
9
+ readonly code: AssistantGrowthExperimentsErrorCode;
10
+ constructor(code: AssistantGrowthExperimentsErrorCode, message: string);
11
+ }
12
+ declare module '@deepseek-ai/cordis' {
13
+ interface Context {
14
+ assistantGrowthExperiments: AssistantGrowthExperimentsService;
15
+ }
16
+ }
17
+ export { growthPortReceiptDigest };
18
+ export declare class AssistantGrowthExperimentsService extends Service {
19
+ static Config: Schema<GrowthExperimentConfig>;
20
+ static inject: string[];
21
+ private readonly config;
22
+ private readonly store;
23
+ private readonly automations;
24
+ private readonly now;
25
+ private unregisterTraceSource;
26
+ private timer;
27
+ private flight;
28
+ private rerunRequested;
29
+ private active;
30
+ constructor(ctx: Context, input: GrowthExperimentConfig, options?: {
31
+ now?: () => number;
32
+ });
33
+ health(): GrowthExperimentHealth;
34
+ getCandidate(id: string): WorkflowCandidate | undefined;
35
+ getExperiment(id: string): GrowthExperiment | undefined;
36
+ beginCandidateExperiment(candidateId: string): GrowthExperiment;
37
+ tick(): Promise<void>;
38
+ whenIdle(): Promise<void>;
39
+ private drain;
40
+ private process;
41
+ private candidateFor;
42
+ private artifactRequest;
43
+ private approval;
44
+ private replay;
45
+ private shadow;
46
+ private canary;
47
+ private promotion;
48
+ private rollback;
49
+ private defer;
50
+ private scheduleTick;
51
+ private assertActive;
52
+ }
53
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,MAAM,MAAM,0BAA0B,CAAA;AAC7C,OAAO,EACL,uBAAuB,EAUxB,MAAM,oCAAoC,CAAA;AAE3C,OAAO,KAAK,EAIV,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,EAItB,iBAAiB,EAElB,MAAM,YAAY,CAAA;AAEnB,MAAM,MAAM,gCAAgC,GAAG,sBAAsB,CAAA;AAErE,eAAO,MAAM,MAAM,EAUb,MAAM,CAAC,sBAAsB,CAAC,CAAA;AAIpC,MAAM,MAAM,mCAAmC,GAC3C,UAAU,GACV,eAAe,GACf,qBAAqB,CAAA;AAEzB,qBAAa,+BAAgC,SAAQ,KAAK;IAC5C,QAAQ,CAAC,IAAI,EAAE,mCAAmC;gBAAzC,IAAI,EAAE,mCAAmC,EAAE,OAAO,EAAE,MAAM;CAIhF;AAED,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,OAAO;QAAG,0BAA0B,EAAE,i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