@dsh-enhanced/assistant-growth-driver 0.1.67 → 0.1.68
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 +10 -6
- package/lib/config.d.ts +4 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +21 -3
- package/lib/config.js.map +1 -1
- package/lib/growth-agent.d.ts +18 -0
- package/lib/growth-agent.d.ts.map +1 -1
- package/lib/growth-agent.js +73 -12
- package/lib/growth-agent.js.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +44 -4
- package/lib/index.js.map +1 -1
- package/lib/revision-target-matcher.d.ts +23 -0
- package/lib/revision-target-matcher.d.ts.map +1 -0
- package/lib/revision-target-matcher.js +51 -0
- package/lib/revision-target-matcher.js.map +1 -0
- package/lib/source-port.d.ts +7 -5
- package/lib/source-port.d.ts.map +1 -1
- package/lib/source-port.js +4 -18
- package/lib/source-port.js.map +1 -1
- package/lib/usage-runtime.d.ts +20 -3
- package/lib/usage-runtime.d.ts.map +1 -1
- package/lib/usage-runtime.js +131 -29
- package/lib/usage-runtime.js.map +1 -1
- package/lib/usage-store.d.ts +21 -4
- package/lib/usage-store.d.ts.map +1 -1
- package/lib/usage-store.js +2 -0
- package/lib/usage-store.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/work-item-source.d.ts +13 -1
- package/lib/work-item-source.d.ts.map +1 -1
- package/lib/work-item-source.js +22 -1
- package/lib/work-item-source.js.map +1 -1
- package/package.json +14 -14
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic matching of a failed WorkItem's objective against the adopted
|
|
3
|
+
* capabilities that are eligible for revision. Never uses a model: the corridor
|
|
4
|
+
* must not infer a repair target from prose, so matching is exact word-boundary
|
|
5
|
+
* against capability names only, and ambiguity (zero or multiple targets) fails
|
|
6
|
+
* closed by returning undefined.
|
|
7
|
+
*/
|
|
8
|
+
const MAX_OBJECTIVE_BYTES = 16_384;
|
|
9
|
+
const MAX_TARGETS = 64;
|
|
10
|
+
const NAME_PATTERN = /^[a-z][a-z0-9-]{1,63}$/u;
|
|
11
|
+
function escapeRegExp(value) {
|
|
12
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A capability name is a run of [a-z0-9-] surrounded by a non-name boundary
|
|
16
|
+
* (start/end or any other character), so it appears as a distinct token.
|
|
17
|
+
*/
|
|
18
|
+
function containsNameAsToken(objective, name) {
|
|
19
|
+
return new RegExp(`(?:^|[^a-z0-9-])${escapeRegExp(name)}(?:[^a-z0-9-]|$)`, 'u').test(objective);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Returns the single adopted capability whose name appears as a distinct token
|
|
23
|
+
* in the objective. Undefined when there is no match or more than one match,
|
|
24
|
+
* when the objective is out of bounds, or when the candidate list is empty.
|
|
25
|
+
*/
|
|
26
|
+
export function matchRevisionTarget(objective, targets) {
|
|
27
|
+
if (typeof objective !== 'string' || objective.length === 0
|
|
28
|
+
|| Buffer.byteLength(objective, 'utf8') > MAX_OBJECTIVE_BYTES
|
|
29
|
+
|| !Array.isArray(targets) || targets.length === 0 || targets.length > MAX_TARGETS) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
const matches = [];
|
|
33
|
+
const seenNames = new Map();
|
|
34
|
+
for (const target of targets) {
|
|
35
|
+
if (!target || typeof target.name !== 'string' || !NAME_PATTERN.test(target.name)
|
|
36
|
+
|| typeof target.parentPlanId !== 'string' || !target.parentPlanId)
|
|
37
|
+
continue;
|
|
38
|
+
// The same capability name behind two parent plans is an ambiguous target: fail closed.
|
|
39
|
+
if (seenNames.has(target.name)) {
|
|
40
|
+
if (seenNames.get(target.name) !== target.parentPlanId)
|
|
41
|
+
return undefined;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
seenNames.set(target.name, target.parentPlanId);
|
|
45
|
+
if (containsNameAsToken(objective, target.name)) {
|
|
46
|
+
matches.push({ parentPlanId: target.parentPlanId, name: target.name });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return matches.length === 1 ? matches[0] : undefined;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=revision-target-matcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revision-target-matcher.js","sourceRoot":"","sources":["../src/revision-target-matcher.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAaH,MAAM,mBAAmB,GAAG,MAAM,CAAA;AAClC,MAAM,WAAW,GAAG,EAAE,CAAA;AACtB,MAAM,YAAY,GAAG,yBAAyB,CAAA;AAE9C,SAAS,YAAY,CAAC,KAAa;IACjC,OAAO,KAAK,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAA;AACrD,CAAC;AAED;;;GAGG;AACH,SAAS,mBAAmB,CAAC,SAAiB,EAAE,IAAY;IAC1D,OAAO,IAAI,MAAM,CAAC,mBAAmB,YAAY,CAAC,IAAI,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;AACjG,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAiB,EAAE,OAA2C;IAChG,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;WACtD,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,MAAM,CAAC,GAAG,mBAAmB;WAC1D,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,WAAW,EAAE,CAAC;QACrF,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,MAAM,OAAO,GAA0B,EAAE,CAAA;IACzC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAA;IAC3C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;eAC5E,OAAO,MAAM,CAAC,YAAY,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,YAAY;YAAE,SAAQ;QAC9E,wFAAwF;QACxF,IAAI,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YAC/B,IAAI,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,YAAY;gBAAE,OAAO,SAAS,CAAA;YACxE,SAAQ;QACV,CAAC;QACD,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,YAAY,CAAC,CAAA;QAC/C,IAAI,mBAAmB,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YAChD,OAAO,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;QACxE,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;AACtD,CAAC"}
|
package/lib/source-port.d.ts
CHANGED
|
@@ -14,12 +14,11 @@ import type { WorkItemCreationReadiness } from './work-item-source.js';
|
|
|
14
14
|
import type { CreationAcceptanceAuthorityRef, RevisionAcceptanceAuthorityRef, RevisionRegressionAcceptanceAuthorityRef, AnySourceGrowthRunBinding } from '@dsh-enhanced/assistant-growth-contract';
|
|
15
15
|
/**
|
|
16
16
|
* Local mirror of the control-plane protected-plugin denylist
|
|
17
|
-
* (
|
|
18
|
-
* It is the growth-side SECOND layer of defence; the
|
|
19
|
-
* the identical set inside prepareModifySourcePlan.
|
|
20
|
-
* a growth proposal may never retarget a T3 safety-root plugin.
|
|
17
|
+
* (see @dsh-enhanced/assistant-growth-contract, the single source of truth consumed by
|
|
18
|
+
* both defence layers). It is the growth-side SECOND layer of defence; the
|
|
19
|
+
* control plane re-checks the identical set inside prepareModifySourcePlan.
|
|
21
20
|
*/
|
|
22
|
-
export
|
|
21
|
+
export { MODEL_PROPOSAL_PROTECTED_PLUGINS as GROWTH_PROTECTED_PLUGIN_DENYLIST, assertProtectedSetsConsistent as assertGrowthProtectedSetsConsistent } from '@dsh-enhanced/assistant-growth-contract';
|
|
23
22
|
/** Projection of an pre-existing control-plane capability gap safe to surface to the model. */
|
|
24
23
|
export interface GrowthSourceGap {
|
|
25
24
|
readonly id: string;
|
|
@@ -118,6 +117,9 @@ export interface GrowthSourcePlanePort {
|
|
|
118
117
|
inspectWorkItemCreationReadiness?(input: {
|
|
119
118
|
owner: OwnerForegroundLearningTask['owner'];
|
|
120
119
|
}): WorkItemCreationReadiness | undefined;
|
|
120
|
+
inspectWorkItemRevisionReadiness?(input: {
|
|
121
|
+
owner: OwnerForegroundLearningTask['owner'];
|
|
122
|
+
}): import('./work-item-source.js').WorkItemRevisionReadiness | undefined;
|
|
121
123
|
/** Optional read-only repository inventory; the Host owns the repository and baseline. */
|
|
122
124
|
inspectSourceTargets?(input: {
|
|
123
125
|
repository: string;
|
package/lib/source-port.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-port.d.ts","sourceRoot":"","sources":["../src/source-port.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAA;AACnF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,KAAK,EAAE,8BAA8B,EAAE,8BAA8B,EAAE,wCAAwC,EACpH,yBAAyB,EAAE,MAAM,yCAA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,OAAO,CAAA;QAChB,KAAK,CAAC,EAAE,oBAAoB,CAAA;QAC5B,MAAM,EAAE,WAAW,CAAA;QACnB,aAAa,EAAE,MAAM,IAAI,CAAA;KAC1B,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAA;IACrC,wEAAwE;IACxE,gBAAgB,CAAC,KAAK,EAAE;QACtB,kFAAkF;QAClF,IAAI,CAAC,EAAE,QAAQ,GAAG,gBAAgB,CAAA;QAClC,YAAY,CAAC,EAAE,MAAM,CAAA;QACrB,KAAK,EAAE,MAAM,CAAA;QACb,IAAI,EAAE,MAAM,CAAA;QACZ,UAAU,EAAE,MAAM,CAAA;QAClB,KAAK,EAAE,SAAS,wBAAwB,EAAE,CAAA;QAC1C,cAAc,EAAE,MAAM,CAAA;QACtB,kBAAkB,EAAE,MAAM,CAAA;QAC1B,KAAK,EAAE,MAAM,CAAA;QACb,KAAK,EAAE,oBAAoB,CAAA;QAC3B,oEAAoE;QACpE,SAAS,CAAC,EAAE,yBAAyB,CAAA;QACrC,MAAM,EAAE,WAAW,CAAA;QACnB,aAAa,EAAE,MAAM,IAAI,CAAA;KAC1B,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAA;IAChC,0EAA0E;IAC1E,gBAAgB,CAAC,KAAK,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,oBAAoB,CAAA;KAAE,GAAG,mBAAmB,CAAA;CAC1F;AAED,6EAA6E;AAC7E,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;CACjB"}
|
package/lib/source-port.js
CHANGED
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Local mirror of the control-plane protected-plugin denylist
|
|
3
|
-
* (
|
|
4
|
-
* It is the growth-side SECOND layer of defence; the
|
|
5
|
-
* the identical set inside prepareModifySourcePlan.
|
|
6
|
-
* a growth proposal may never retarget a T3 safety-root plugin.
|
|
3
|
+
* (see @dsh-enhanced/assistant-growth-contract, the single source of truth consumed by
|
|
4
|
+
* both defence layers). It is the growth-side SECOND layer of defence; the
|
|
5
|
+
* control plane re-checks the identical set inside prepareModifySourcePlan.
|
|
7
6
|
*/
|
|
8
|
-
export
|
|
9
|
-
'assistant-delivery', // authenticated task and feedback evidence
|
|
10
|
-
'lark-channel', // authenticated external-channel ingress
|
|
11
|
-
'assistant-automations', // qualification observation and rollback scheduling
|
|
12
|
-
'assistant-policy', // 策略规则、授权寿命、急停根
|
|
13
|
-
'credentials-keychain', // 凭据根
|
|
14
|
-
'assistant-evaluation', // 评测答案根
|
|
15
|
-
'assistant-verifier', // 验证/私钥评测根
|
|
16
|
-
'assistant-deepseek-budget', // 预算上限根
|
|
17
|
-
'assistant-skills', // sealed holdout 私钥与 holdout 数据集
|
|
18
|
-
'assistant-isolation', // 隔离沙箱机制本身
|
|
19
|
-
'assistant-web-owner', // owner 安全控制台
|
|
20
|
-
'plugin-control-plane', // 审批/激活控制面本身(自举提权面)
|
|
21
|
-
]);
|
|
7
|
+
export { MODEL_PROPOSAL_PROTECTED_PLUGINS as GROWTH_PROTECTED_PLUGIN_DENYLIST, assertProtectedSetsConsistent as assertGrowthProtectedSetsConsistent } from '@dsh-enhanced/assistant-growth-contract';
|
|
22
8
|
//# sourceMappingURL=source-port.js.map
|
package/lib/source-port.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-port.js","sourceRoot":"","sources":["../src/source-port.ts"],"names":[],"mappings":"AAgBA
|
|
1
|
+
{"version":3,"file":"source-port.js","sourceRoot":"","sources":["../src/source-port.ts"],"names":[],"mappings":"AAgBA;;;;;GAKG;AACH,OAAO,EAAE,gCAAgC,IAAI,gCAAgC,EAC3E,6BAA6B,IAAI,mCAAmC,EAAE,MAAM,yCAAyC,CAAA"}
|
package/lib/usage-runtime.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { AssistantAutomationsService } from '@dsh-enhanced/assistant-automations';
|
|
2
2
|
import type { AssistantEvaluationService } from '@dsh-enhanced/assistant-evaluation';
|
|
3
3
|
import type { AssistantDeliveryService, OwnerForegroundLearningTask } from '@dsh-enhanced/assistant-delivery';
|
|
4
|
-
import { type CreationAcceptanceAuthorityRef, type RevisionAcceptanceAuthorityRef, type RevisionRegressionAcceptanceAuthorityRef, type AnySourceGrowthRunBinding, type WorkItemSourceGrowthRunBinding, type SourceGrowthRunBinding, type SourceGrowthRunRequest } from '@dsh-enhanced/assistant-growth-contract';
|
|
4
|
+
import { type CreationAcceptanceAuthorityRef, type RevisionAcceptanceAuthorityRef, type RevisionRegressionAcceptanceAuthorityRef, type AnySourceGrowthRunBinding, type WorkItemSourceGrowthRunBinding, type WorkItemRevisionSourceGrowthRunBinding, type SourceGrowthRunBinding, type SourceGrowthRunRequest } from '@dsh-enhanced/assistant-growth-contract';
|
|
5
5
|
import type { NormalizedGrowthDriverConfig } from './config.js';
|
|
6
6
|
import { type UsageModel } from './usage-store.js';
|
|
7
7
|
import { type WorkItemCreationReadiness, type WorkItemUsageSource } from './work-item-source.js';
|
|
8
|
+
import { type RevisionTargetCandidate } from './revision-target-matcher.js';
|
|
8
9
|
type Evaluation = Pick<AssistantEvaluationService, 'canonicalHostScope' | 'listTrustedTaskLearningProjections' | 'withTrustedCanonicalTaskWriterFence' | 'onTrustedTaskChange'> & Partial<Pick<AssistantEvaluationService, 'getTrustedWorkItemLearningProjection'>>;
|
|
9
10
|
type Delivery = Pick<AssistantDeliveryService, 'validateOwnerRoute' | 'inspectOwnerRouteState' | 'inspectOwnerForegroundLearningTask'> & Partial<Pick<AssistantDeliveryService, 'inspectOwnerWorkItemEngineeringContext' | 'readOwnerWorkItemEngineeringContext' | 'withOwnerWorkItemEngineeringContextFence'>>;
|
|
10
11
|
type Automations = Pick<AssistantAutomationsService, 'inspectSystemOwnedRetirement' | 'retireSystemOwned' | 'onSchedulerWake' | 'registerHostExecutor' | 'reconcileSystem' | 'inspectSystemOwnedActivation' | 'inspectSystemOwned'>;
|
|
@@ -22,9 +23,11 @@ export interface UsageReviewInput {
|
|
|
22
23
|
}
|
|
23
24
|
export interface WorkItemUsageReviewInput extends Omit<UsageReviewInput, 'source' | 'bindSourceRun'> {
|
|
24
25
|
sourceKind: 'work-item';
|
|
26
|
+
/** Frozen when the job left the pending queue; the wake never changes it. */
|
|
27
|
+
corridor: 'create' | 'revise-created';
|
|
25
28
|
assertFirstModelAdmission(): void;
|
|
26
29
|
source: WorkItemUsageSource;
|
|
27
|
-
bindSourceRun(input: Parameters<UsageReviewInput['bindSourceRun']>[0]): WorkItemSourceGrowthRunBinding;
|
|
30
|
+
bindSourceRun(input: Parameters<UsageReviewInput['bindSourceRun']>[0]): WorkItemSourceGrowthRunBinding | WorkItemRevisionSourceGrowthRunBinding;
|
|
28
31
|
}
|
|
29
32
|
export type AnyUsageReviewInput = UsageReviewInput | WorkItemUsageReviewInput;
|
|
30
33
|
export type UsageReviewResult = 'reviewed' | 'failed' | 'unknown';
|
|
@@ -57,6 +60,10 @@ export declare class UsageLearningRuntime {
|
|
|
57
60
|
inspectWorkItemCreationReadiness?(input: {
|
|
58
61
|
owner: WorkItemUsageSource['task']['owner'];
|
|
59
62
|
}): WorkItemCreationReadiness | undefined;
|
|
63
|
+
inspectWorkItemRevisionReadiness?(input: {
|
|
64
|
+
owner: WorkItemUsageSource['task']['owner'];
|
|
65
|
+
}): import('./work-item-source.js').WorkItemRevisionReadiness | undefined;
|
|
66
|
+
inspectWorkItemRevisionTargets?(): readonly RevisionTargetCandidate[];
|
|
60
67
|
review(input: UsageReviewInput): Promise<UsageReviewResult>;
|
|
61
68
|
inspectCreationAcceptanceAuthority?(): CreationAcceptanceAuthorityRef | undefined;
|
|
62
69
|
inspectRevisionAcceptanceAuthority?(): RevisionAcceptanceAuthorityRef | undefined;
|
|
@@ -77,6 +84,14 @@ export declare class UsageLearningRuntime {
|
|
|
77
84
|
inspectSourceGrowthRun: (request: SourceGrowthRunRequest) => SourceGrowthRunBinding | undefined;
|
|
78
85
|
private workItemScope;
|
|
79
86
|
private assertWorkItemReadiness;
|
|
87
|
+
private assertWorkItemRevisionReadiness;
|
|
88
|
+
/**
|
|
89
|
+
* Freeze the corridor when the WorkItem leaves the pending queue. The
|
|
90
|
+
* revise-created corridor wins only when every revision peer is live AND the
|
|
91
|
+
* deterministic target matcher finds exactly one adopted capability named in
|
|
92
|
+
* the objective; otherwise the job keeps the fail-closed create-only corridor.
|
|
93
|
+
*/
|
|
94
|
+
private resolveWorkItemCorridor;
|
|
80
95
|
private currentWorkItem;
|
|
81
96
|
private expectation;
|
|
82
97
|
private locatorFor;
|
|
@@ -86,9 +101,11 @@ export declare class UsageLearningRuntime {
|
|
|
86
101
|
inspectAnySourceGrowthRun: (request: SourceGrowthRunRequest) => AnySourceGrowthRunBinding | undefined;
|
|
87
102
|
withWorkItemRunFence: <T>(input: SourceGrowthRunRequest & {
|
|
88
103
|
expectedGrowthRunDigest: string;
|
|
89
|
-
}, callback: (binding: Readonly<WorkItemSourceGrowthRunBinding>) => T) => T;
|
|
104
|
+
}, callback: (binding: Readonly<WorkItemSourceGrowthRunBinding | WorkItemRevisionSourceGrowthRunBinding>) => T) => T;
|
|
90
105
|
private assertWorkItemBinding;
|
|
91
106
|
private executeWorkItem;
|
|
107
|
+
private bindWorkItemCreationRun;
|
|
108
|
+
private bindWorkItemRevisionRun;
|
|
92
109
|
/** Synchronous nudge, bounded to 1000 heads. Native scan resumes the cursor. */
|
|
93
110
|
scan: () => void;
|
|
94
111
|
private definition;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage-runtime.d.ts","sourceRoot":"","sources":["../src/usage-runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,2BAA2B,EAAuF,MAAM,qCAAqC,CAAA;AAC3K,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAA;AACpF,OAAO,KAA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uBAAuB;IAqB/B,gFAAgF;IAChF,IAAI,QAAO,IAAI,CAyDd;IAED,OAAO,CAAC,UAAU;IAclB,OAAO,CAAC,QAAQ;YAwBF,OAAO;CA2FtB"}
|
package/lib/usage-runtime.js
CHANGED
|
@@ -2,7 +2,8 @@ import { ScannerOwnerGuard, ScannerOwnerUnavailable, drainScannerFlights } from
|
|
|
2
2
|
import { acceptanceDigest } from '@dsh-enhanced/task-acceptance-contract';
|
|
3
3
|
import { SourceGrowthRunUnavailableError, isSourceOwnerContinuation, sourceGrowthEvidenceDigest, sourceGrowthRunDigest, validateSourceGrowthRunBinding, validateAnySourceGrowthRunBinding, anySourceGrowthRunDigest } from '@dsh-enhanced/assistant-growth-contract';
|
|
4
4
|
import { UsageStore, isWorkItemUsageIntent } from './usage-store.js';
|
|
5
|
-
import { freezeWorkItemData, ownData, isWorkItemCreationReady, workItemAuthorityDeadline, workItemTextDigest, workItemRunSource, workItemStableOwner } from './work-item-source.js';
|
|
5
|
+
import { freezeWorkItemData, ownData, isWorkItemCreationReady, isWorkItemRevisionReady, workItemAuthorityDeadline, workItemRevisionAuthorityDeadline, workItemTextDigest, workItemRunSource, workItemStableOwner } from './work-item-source.js';
|
|
6
|
+
import { matchRevisionTarget } from './revision-target-matcher.js';
|
|
6
7
|
class WorkItemSourcePending extends Error {
|
|
7
8
|
}
|
|
8
9
|
class WorkItemSourceObsolete extends Error {
|
|
@@ -228,6 +229,45 @@ export class UsageLearningRuntime {
|
|
|
228
229
|
throw new WorkItemSourcePending('work item engineering peers or authorizations unavailable');
|
|
229
230
|
}
|
|
230
231
|
}
|
|
232
|
+
assertWorkItemRevisionReadiness(owner, pins, admission) {
|
|
233
|
+
const currentOwner = this.owner();
|
|
234
|
+
if (!isSourceOwnerContinuation(currentOwner, owner))
|
|
235
|
+
throw new WorkItemSourceObsolete('work item source owner changed');
|
|
236
|
+
if (this.ports.inspectWorkItemToolPreauthorization?.() !== true
|
|
237
|
+
|| !isWorkItemRevisionReady(this.ports.inspectWorkItemRevisionReadiness?.({ owner: currentOwner }), pins, Date.now(), admission)) {
|
|
238
|
+
throw new WorkItemSourcePending('work item revision peers or authorizations unavailable');
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Freeze the corridor when the WorkItem leaves the pending queue. The
|
|
243
|
+
* revise-created corridor wins only when every revision peer is live AND the
|
|
244
|
+
* deterministic target matcher finds exactly one adopted capability named in
|
|
245
|
+
* the objective; otherwise the job keeps the fail-closed create-only corridor.
|
|
246
|
+
*/
|
|
247
|
+
resolveWorkItemCorridor(source) {
|
|
248
|
+
const owner = this.owner();
|
|
249
|
+
if (!isSourceOwnerContinuation(owner, source.task.owner))
|
|
250
|
+
throw new WorkItemSourceObsolete('work item source owner changed');
|
|
251
|
+
if (this.ports.inspectWorkItemToolPreauthorization?.() !== true) {
|
|
252
|
+
throw new WorkItemSourcePending('work item tool preauthorization unavailable');
|
|
253
|
+
}
|
|
254
|
+
const revisionPins = this.config.usageLearning.workItemRevisionAuthorities;
|
|
255
|
+
if (revisionPins !== undefined
|
|
256
|
+
&& isWorkItemRevisionReady(this.ports.inspectWorkItemRevisionReadiness?.({ owner }), revisionPins, Date.now(), true)) {
|
|
257
|
+
const targets = this.ports.inspectWorkItemRevisionTargets?.() ?? [];
|
|
258
|
+
const match = matchRevisionTarget(source.objective, targets);
|
|
259
|
+
if (match !== undefined) {
|
|
260
|
+
return { corridor: 'revise-created', authorities: structuredClone(revisionPins),
|
|
261
|
+
revisionTarget: { parentPlanId: match.parentPlanId, name: match.name } };
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
const creationPins = this.config.usageLearning.workItemAuthorities;
|
|
265
|
+
if (this.config.usageLearning.workItemFailures && creationPins !== undefined
|
|
266
|
+
&& isWorkItemCreationReady(this.ports.inspectWorkItemCreationReadiness?.({ owner }), creationPins, Date.now(), true)) {
|
|
267
|
+
return { corridor: 'create', authorities: structuredClone(creationPins) };
|
|
268
|
+
}
|
|
269
|
+
throw new WorkItemSourcePending('work item engineering peers or authorizations unavailable');
|
|
270
|
+
}
|
|
231
271
|
currentWorkItem(locator) {
|
|
232
272
|
if (locator.configDigest !== this.configDigest || locator.expiresAt <= Date.now()
|
|
233
273
|
|| !same(workItemStableOwner(this.owner()), locator.owner))
|
|
@@ -260,14 +300,19 @@ export class UsageLearningRuntime {
|
|
|
260
300
|
withWorkItemSource(intent, callback) {
|
|
261
301
|
this.abort.signal.throwIfAborted();
|
|
262
302
|
this.currentWorkItem(this.locatorFor(intent));
|
|
263
|
-
|
|
303
|
+
const expectedPins = intent.corridor === 'revise-created'
|
|
304
|
+
? this.config.usageLearning.workItemRevisionAuthorities
|
|
305
|
+
: this.config.usageLearning.workItemAuthorities;
|
|
306
|
+
if (expectedPins === undefined || !same(intent.authorities, expectedPins))
|
|
264
307
|
throw new WorkItemSourceObsolete('work item authority pins changed');
|
|
265
308
|
const fence = this.ports.delivery.withOwnerWorkItemEngineeringContextFence;
|
|
266
309
|
if (!fence)
|
|
267
310
|
throw new WorkItemSourcePending('work item engineering fence unavailable');
|
|
268
311
|
return fence.call(this.ports.delivery, this.expectation(intent.source), source => {
|
|
269
312
|
this.abort.signal.throwIfAborted();
|
|
270
|
-
|
|
313
|
+
const authorityDeadline = intent.corridor === 'revise-created'
|
|
314
|
+
? workItemRevisionAuthorityDeadline(intent.authorities) : workItemAuthorityDeadline(intent.authorities);
|
|
315
|
+
if (!this.active || intent.configDigest !== this.configDigest || Date.now() >= Math.min(intent.expiresAt, authorityDeadline))
|
|
271
316
|
throw new WorkItemSourceObsolete('work item usage lifecycle or authority expired');
|
|
272
317
|
if (!same(workItemRunSource({ ...intent.source, ...source }), workItemRunSource(intent.source))
|
|
273
318
|
|| !isSourceOwnerContinuation(source.task.owner, intent.source.task.owner)
|
|
@@ -352,14 +397,15 @@ export class UsageLearningRuntime {
|
|
|
352
397
|
try {
|
|
353
398
|
this.currentWorkItem(pending.locator);
|
|
354
399
|
const source = this.readWorkItem(pending.locator);
|
|
355
|
-
this.
|
|
400
|
+
const corridor = this.resolveWorkItemCorridor(source);
|
|
356
401
|
const fixed = this.config.provider !== null && this.config.model !== null;
|
|
357
402
|
const intent = { sourceKind: 'work-item', configDigest: this.configDigest, source,
|
|
358
403
|
model: fixed ? { provider: this.config.provider, model: this.config.model, ...(this.config.reasoningEffort === null ? {} : { reasoningEffort: this.config.reasoningEffort }) }
|
|
359
404
|
: structuredClone(source.task.proofIdentity.supplier), modelOrigin: fixed ? 'explicit-growth-override' : 'inherited-owner-task',
|
|
360
405
|
budget: { budgetId: this.config.budgetId, amount: this.config.budgetAmount, maxModelCalls: this.config.maxModelCalls,
|
|
361
406
|
maxToolCalls: this.config.maxToolCalls, maxOutputTokens: this.config.maxOutputTokens, maxDurationMs: this.config.maxDurationMs,
|
|
362
|
-
maxPlansPerWake: this.config.pluginSourceProposals.maxPlansPerWake },
|
|
407
|
+
maxPlansPerWake: this.config.pluginSourceProposals.maxPlansPerWake },
|
|
408
|
+
...corridor,
|
|
363
409
|
createdAt: pending.locator.createdAt, expiresAt: pending.locator.expiresAt };
|
|
364
410
|
this.withWorkItemSource(intent, () => this.store.freezeWorkItem(pending.id, intent));
|
|
365
411
|
}
|
|
@@ -380,12 +426,19 @@ export class UsageLearningRuntime {
|
|
|
380
426
|
if (!job || !isWorkItemUsageIntent(job.intent))
|
|
381
427
|
return this.inspectSourceGrowthRun(request);
|
|
382
428
|
try {
|
|
429
|
+
const expectedProtocol = job.intent.corridor === 'revise-created'
|
|
430
|
+
? 'assistant-growth/source-run/v3' : 'assistant-growth/source-run/v2';
|
|
383
431
|
if (job.digest !== request.intentDigest || !['running', 'reviewed'].includes(job.state) || !job.sourceRun
|
|
384
|
-
|| job.sourceRun.protocol !==
|
|
432
|
+
|| job.sourceRun.protocol !== expectedProtocol)
|
|
385
433
|
return undefined;
|
|
386
|
-
|
|
434
|
+
if (job.intent.corridor === 'revise-created') {
|
|
435
|
+
this.assertWorkItemRevisionReadiness(job.intent.source.task.owner, job.intent.authorities, false);
|
|
436
|
+
}
|
|
437
|
+
else {
|
|
438
|
+
this.assertWorkItemReadiness(job.intent.source.task.owner, false);
|
|
439
|
+
}
|
|
387
440
|
return this.withWorkItemSource(job.intent, () => this.store.withWorkItemRunWriter(request, current => {
|
|
388
|
-
if (!current.sourceRun || current.sourceRun.protocol !==
|
|
441
|
+
if (!current.sourceRun || current.sourceRun.protocol !== expectedProtocol)
|
|
389
442
|
throw new Error('work item run absent');
|
|
390
443
|
this.assertWorkItemBinding(current, current.sourceRun);
|
|
391
444
|
return freezeWorkItemData(current.sourceRun);
|
|
@@ -410,11 +463,19 @@ export class UsageLearningRuntime {
|
|
|
410
463
|
if (!job || job.digest !== input.intentDigest || !isWorkItemUsageIntent(job.intent))
|
|
411
464
|
throw new Error('work item run not found');
|
|
412
465
|
const intent = job.intent;
|
|
413
|
-
|
|
466
|
+
if (intent.corridor === 'revise-created') {
|
|
467
|
+
this.assertWorkItemRevisionReadiness(intent.source.task.owner, intent.authorities, false);
|
|
468
|
+
}
|
|
469
|
+
else {
|
|
470
|
+
this.assertWorkItemReadiness(intent.source.task.owner, false);
|
|
471
|
+
}
|
|
414
472
|
return this.withWorkItemSource(intent, () => this.store.withWorkItemRunWriter(input, current => {
|
|
415
473
|
const binding = current.sourceRun;
|
|
416
|
-
if (!binding || binding.protocol
|
|
417
|
-
||
|
|
474
|
+
if (!binding || binding.protocol === 'assistant-growth/source-run/v1'
|
|
475
|
+
|| (intent.corridor === 'revise-created'
|
|
476
|
+
? binding.protocol !== 'assistant-growth/source-run/v3' : binding.protocol !== 'assistant-growth/source-run/v2')
|
|
477
|
+
|| anySourceGrowthRunDigest(binding) !== input.expectedGrowthRunDigest
|
|
478
|
+
|| binding.configDigest !== this.configDigest || !same(binding.authorities, intent.authorities)
|
|
418
479
|
|| !same(binding.source, workItemRunSource(intent.source)))
|
|
419
480
|
throw new Error('work item run binding changed');
|
|
420
481
|
this.assertWorkItemBinding(current, binding);
|
|
@@ -423,7 +484,9 @@ export class UsageLearningRuntime {
|
|
|
423
484
|
};
|
|
424
485
|
assertWorkItemBinding(job, binding) {
|
|
425
486
|
validateAnySourceGrowthRunBinding(binding);
|
|
426
|
-
if (!isWorkItemUsageIntent(job.intent)
|
|
487
|
+
if (!isWorkItemUsageIntent(job.intent)
|
|
488
|
+
|| (binding.protocol === 'assistant-growth/source-run/v3') !== (job.intent.corridor === 'revise-created')
|
|
489
|
+
|| binding.runId !== job.id || binding.intentDigest !== job.digest
|
|
427
490
|
|| binding.configDigest !== this.configDigest || binding.ownerDigest !== sourceGrowthEvidenceDigest(job.intent.source.task.owner)
|
|
428
491
|
|| binding.native.automationId !== job.id || binding.native.definitionHash !== job.definitionHash || binding.native.occurrenceId !== job.occurrenceId
|
|
429
492
|
|| !same(binding.source, workItemRunSource(job.intent.source)) || !same(binding.model, job.intent.model)
|
|
@@ -435,16 +498,26 @@ export class UsageLearningRuntime {
|
|
|
435
498
|
if (!isWorkItemUsageIntent(queued.intent))
|
|
436
499
|
throw new Error('work item usage expected');
|
|
437
500
|
const intent = queued.intent;
|
|
501
|
+
const revision = intent.corridor === 'revise-created';
|
|
502
|
+
const authorityDeadline = revision
|
|
503
|
+
? workItemRevisionAuthorityDeadline(intent.authorities)
|
|
504
|
+
: workItemAuthorityDeadline(intent.authorities);
|
|
505
|
+
const assertReady = (admission) => {
|
|
506
|
+
if (intent.corridor === 'revise-created')
|
|
507
|
+
this.assertWorkItemRevisionReadiness(intent.source.task.owner, intent.authorities, admission);
|
|
508
|
+
else
|
|
509
|
+
this.assertWorkItemReadiness(intent.source.task.owner, admission);
|
|
510
|
+
};
|
|
438
511
|
let claimed = false;
|
|
439
512
|
try {
|
|
440
|
-
|
|
513
|
+
assertReady(true);
|
|
441
514
|
this.withWorkItemSource(intent, () => { this.store.claim(queued.id, input.definitionHash, input.occurrenceId); claimed = true; });
|
|
442
|
-
const signal = AbortSignal.any([input.signal, this.abort.signal, AbortSignal.timeout(Math.max(1, Math.min(this.config.maxDurationMs, intent.expiresAt - Date.now(),
|
|
515
|
+
const signal = AbortSignal.any([input.signal, this.abort.signal, AbortSignal.timeout(Math.max(1, Math.min(this.config.maxDurationMs, intent.expiresAt - Date.now(), authorityDeadline - Date.now())))]);
|
|
443
516
|
const assertCurrent = () => {
|
|
444
517
|
signal.throwIfAborted();
|
|
445
518
|
// Peer/owner probes can synchronously change source state. Run them
|
|
446
519
|
// before the final complete source frame; its callback is local only.
|
|
447
|
-
|
|
520
|
+
assertReady(false);
|
|
448
521
|
this.withWorkItemSource(intent, () => {
|
|
449
522
|
signal.throwIfAborted();
|
|
450
523
|
const current = this.store.get(queued.id);
|
|
@@ -455,25 +528,21 @@ export class UsageLearningRuntime {
|
|
|
455
528
|
};
|
|
456
529
|
const bindSourceRun = actual => {
|
|
457
530
|
assertCurrent();
|
|
458
|
-
|
|
459
|
-
if (!same(actual.model, intent.model) ||
|
|
460
|
-
|| actual.revisionAcceptance !== undefined || actual.revisionRegressionAcceptance !== undefined
|
|
461
|
-
|| actual.generationDeadlineAt > workItemAuthorityDeadline(intent.authorities))
|
|
531
|
+
assertReady(true);
|
|
532
|
+
if (!same(actual.model, intent.model) || actual.generationDeadlineAt > authorityDeadline) {
|
|
462
533
|
throw new Error('work item run setup authority changed');
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
native: { owner: OWNER, automationId: queued.id, definitionHash: input.definitionHash, occurrenceId: input.occurrenceId },
|
|
468
|
-
sessionId: actual.sessionId, toolContractDigest: actual.toolContractDigest, executionContractDigest: actual.executionContractDigest,
|
|
469
|
-
createdAt: actual.createdAt, generationDeadlineAt: actual.generationDeadlineAt, expiresAt: intent.expiresAt };
|
|
534
|
+
}
|
|
535
|
+
const binding = intent.corridor === 'revise-created'
|
|
536
|
+
? this.bindWorkItemRevisionRun(actual, intent, queued, input)
|
|
537
|
+
: this.bindWorkItemCreationRun(actual, intent, queued, input);
|
|
470
538
|
return this.withWorkItemSource(intent, () => this.store.bindWorkItemSourceRun(queued.id, queued.digest, input.definitionHash, input.occurrenceId, binding));
|
|
471
539
|
};
|
|
472
|
-
|
|
540
|
+
assertReady(true);
|
|
473
541
|
assertCurrent();
|
|
474
542
|
const outcome = await this.ports.reviewWorkItem({ sourceKind: 'work-item', id: queued.id, intentDigest: queued.digest,
|
|
475
|
-
definitionHash: input.definitionHash, occurrenceId: input.occurrenceId, expiresAt: Math.min(intent.expiresAt,
|
|
476
|
-
model: intent.model, source: intent.source, signal, assertCurrent,
|
|
543
|
+
definitionHash: input.definitionHash, occurrenceId: input.occurrenceId, expiresAt: Math.min(intent.expiresAt, authorityDeadline),
|
|
544
|
+
corridor: intent.corridor, model: intent.model, source: intent.source, signal, assertCurrent,
|
|
545
|
+
assertFirstModelAdmission: () => { assertReady(true); assertCurrent(); }, bindSourceRun });
|
|
477
546
|
assertCurrent();
|
|
478
547
|
this.store.settle(queued.id, outcome, outcome === 'reviewed' ? 'review-complete-not-adopted' : 'review-incomplete', input.occurrenceId);
|
|
479
548
|
return result(outcome === 'reviewed' ? 'succeeded' : outcome);
|
|
@@ -484,6 +553,39 @@ export class UsageLearningRuntime {
|
|
|
484
553
|
return result(claimed ? 'unknown' : 'failed');
|
|
485
554
|
}
|
|
486
555
|
}
|
|
556
|
+
bindWorkItemCreationRun(actual, intent, queued, input) {
|
|
557
|
+
if (!same(actual.creationAcceptance, intent.authorities.creationAcceptance)
|
|
558
|
+
|| actual.revisionAcceptance !== undefined || actual.revisionRegressionAcceptance !== undefined) {
|
|
559
|
+
throw new Error('work item run setup authority changed');
|
|
560
|
+
}
|
|
561
|
+
return { protocol: 'assistant-growth/source-run/v2', mode: 'create',
|
|
562
|
+
runId: queued.id, intentDigest: queued.digest, configDigest: intent.configDigest, ownerDigest: sourceGrowthEvidenceDigest(intent.source.task.owner),
|
|
563
|
+
source: workItemRunSource(intent.source), model: actual.model, modelOrigin: intent.modelOrigin, budget: intent.budget,
|
|
564
|
+
creationAcceptance: structuredClone(intent.authorities.creationAcceptance), authorities: structuredClone(intent.authorities),
|
|
565
|
+
native: { owner: OWNER, automationId: queued.id, definitionHash: input.definitionHash, occurrenceId: input.occurrenceId },
|
|
566
|
+
sessionId: actual.sessionId, toolContractDigest: actual.toolContractDigest, executionContractDigest: actual.executionContractDigest,
|
|
567
|
+
createdAt: actual.createdAt, generationDeadlineAt: actual.generationDeadlineAt, expiresAt: intent.expiresAt };
|
|
568
|
+
}
|
|
569
|
+
bindWorkItemRevisionRun(actual, intent, queued, input) {
|
|
570
|
+
if (actual.creationAcceptance !== undefined || actual.revisionAcceptance === undefined
|
|
571
|
+
|| !same(actual.revisionAcceptance, intent.authorities.revisionAcceptance)
|
|
572
|
+
|| (actual.revisionRegressionAcceptance === undefined) !== (intent.authorities.revisionRegressionAcceptance === undefined)
|
|
573
|
+
|| (actual.revisionRegressionAcceptance !== undefined && intent.authorities.revisionRegressionAcceptance !== undefined
|
|
574
|
+
&& !same(actual.revisionRegressionAcceptance, intent.authorities.revisionRegressionAcceptance))) {
|
|
575
|
+
throw new Error('work item revision run setup authority changed');
|
|
576
|
+
}
|
|
577
|
+
return { protocol: 'assistant-growth/source-run/v3', mode: 'revise-created',
|
|
578
|
+
runId: queued.id, intentDigest: queued.digest, configDigest: intent.configDigest, ownerDigest: sourceGrowthEvidenceDigest(intent.source.task.owner),
|
|
579
|
+
source: workItemRunSource(intent.source), model: actual.model, modelOrigin: intent.modelOrigin, budget: intent.budget,
|
|
580
|
+
revisionAcceptance: structuredClone(intent.authorities.revisionAcceptance),
|
|
581
|
+
...(intent.authorities.revisionRegressionAcceptance === undefined ? {} : {
|
|
582
|
+
revisionRegressionAcceptance: structuredClone(intent.authorities.revisionRegressionAcceptance)
|
|
583
|
+
}),
|
|
584
|
+
authorities: structuredClone(intent.authorities),
|
|
585
|
+
native: { owner: OWNER, automationId: queued.id, definitionHash: input.definitionHash, occurrenceId: input.occurrenceId },
|
|
586
|
+
sessionId: actual.sessionId, toolContractDigest: actual.toolContractDigest, executionContractDigest: actual.executionContractDigest,
|
|
587
|
+
createdAt: actual.createdAt, generationDeadlineAt: actual.generationDeadlineAt, expiresAt: intent.expiresAt };
|
|
588
|
+
}
|
|
487
589
|
/** Synchronous nudge, bounded to 1000 heads. Native scan resumes the cursor. */
|
|
488
590
|
scan = () => {
|
|
489
591
|
if (!this.active || this.scanning)
|