@dsh-enhanced/assistant-evolution 0.1.32 → 0.1.35
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/lib/goals-port.d.ts +25 -0
- package/lib/goals-port.d.ts.map +1 -0
- package/lib/goals-port.js +2 -0
- package/lib/goals-port.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/service.d.ts +41 -1
- package/lib/service.d.ts.map +1 -1
- package/lib/service.js +136 -10
- package/lib/service.js.map +1 -1
- package/lib/store.d.ts +17 -0
- package/lib/store.d.ts.map +1 -1
- package/lib/store.js +55 -1
- package/lib/store.js.map +1 -1
- package/lib/strategy-learning.d.ts +83 -0
- package/lib/strategy-learning.d.ts.map +1 -0
- package/lib/strategy-learning.js +151 -0
- package/lib/strategy-learning.js.map +1 -0
- package/lib/tools.d.ts.map +1 -1
- package/lib/tools.js +21 -0
- package/lib/tools.js.map +1 -1
- package/lib/types.d.ts +9 -0
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +10 -0
- package/lib/types.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +14 -7
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read-only optional-peer seam for assistant-goals strategy advice.
|
|
3
|
+
*
|
|
4
|
+
* This intentionally models only the values evolution consumes. The live
|
|
5
|
+
* service is discovered through Cordis at runtime, so importing its package
|
|
6
|
+
* declarations here would create a clean-build dependency cycle between two
|
|
7
|
+
* independently installable bundles.
|
|
8
|
+
*/
|
|
9
|
+
export interface GoalsAdviceScope {
|
|
10
|
+
principalId: string;
|
|
11
|
+
principalRecordId: string;
|
|
12
|
+
principalVersion: number;
|
|
13
|
+
workspace: string;
|
|
14
|
+
preset: string;
|
|
15
|
+
}
|
|
16
|
+
export interface GoalsAdviceDefinitionSummary {
|
|
17
|
+
situation: string;
|
|
18
|
+
goalInstances: number;
|
|
19
|
+
adviceRuns: number;
|
|
20
|
+
distinctRequests: number;
|
|
21
|
+
}
|
|
22
|
+
export interface AssistantGoalsAdvicePort {
|
|
23
|
+
hostSummarizeAdviceByDefinition(scope: GoalsAdviceScope): readonly GoalsAdviceDefinitionSummary[];
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=goals-port.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"goals-port.d.ts","sourceRoot":"","sources":["../src/goals-port.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAA;IACnB,iBAAiB,EAAE,MAAM,CAAA;IACzB,gBAAgB,EAAE,MAAM,CAAA;IACxB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,4BAA4B;IAC3C,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,MAAM,CAAA;CACzB;AAED,MAAM,WAAW,wBAAwB;IACvC,+BAA+B,CAAC,KAAK,EAAE,gBAAgB,GAAG,SAAS,4BAA4B,EAAE,CAAA;CAClG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"goals-port.js","sourceRoot":"","sources":["../src/goals-port.ts"],"names":[],"mappings":""}
|
package/lib/index.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export type { Config };
|
|
|
9
9
|
export { HOST_RECOVERY_BACKGROUND_ID, SUPERVISED_GROWTH_ANALYST_AUTOMATION_ID, AssistantEvolutionError, canonicalEvolutionHostScope, } from './service.js';
|
|
10
10
|
export type { AssistantEvolutionHealth, EvaluationOutcomeInput, EvaluationProjectionInput, EvolutionHostOperation, EvolutionHostScope, EvolutionOwnerUndoInput, EvolutionProposalResult, EvolutionRollbackResult, } from './service.js';
|
|
11
11
|
export * from './types.js';
|
|
12
|
+
export { isGoalDefinitionSituation, joinStrategyLearningObservations, toStrategyAdviceSignal, } from './strategy-learning.js';
|
|
13
|
+
export type { GoalDefinitionEpisodeSummary, StrategyAdviceSignal, StrategyLearningJoinInput, StrategyLearningObservation, } from './strategy-learning.js';
|
|
12
14
|
export declare function apply(ctx: Context, config: Config): void;
|
|
13
15
|
export default AssistantEvolutionService;
|
|
14
16
|
//# sourceMappingURL=index.d.ts.map
|
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,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;
|
|
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;AAC1B,OAAO,EACL,yBAAyB,EACzB,gCAAgC,EAChC,sBAAsB,GACvB,MAAM,wBAAwB,CAAA;AAC/B,YAAY,EACV,4BAA4B,EAC5B,oBAAoB,EACpB,yBAAyB,EACzB,2BAA2B,GAC5B,MAAM,wBAAwB,CAAA;AAE/B,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAExD;AAED,eAAe,yBAAyB,CAAA"}
|
package/lib/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export const inject = ['assistantPolicy', 'assistantEvaluation'];
|
|
|
5
5
|
export { AssistantEvolutionService, version };
|
|
6
6
|
export { HOST_RECOVERY_BACKGROUND_ID, SUPERVISED_GROWTH_ANALYST_AUTOMATION_ID, AssistantEvolutionError, canonicalEvolutionHostScope, } from './service.js';
|
|
7
7
|
export * from './types.js';
|
|
8
|
+
export { isGoalDefinitionSituation, joinStrategyLearningObservations, toStrategyAdviceSignal, } from './strategy-learning.js';
|
|
8
9
|
export function apply(ctx, config) {
|
|
9
10
|
new AssistantEvolutionService(ctx, config);
|
|
10
11
|
}
|
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,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;
|
|
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;AAC1B,OAAO,EACL,yBAAyB,EACzB,gCAAgC,EAChC,sBAAsB,GACvB,MAAM,wBAAwB,CAAA;AAQ/B,MAAM,UAAU,KAAK,CAAC,GAAY,EAAE,MAAc;IAChD,IAAI,yBAAyB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;AAC5C,CAAC;AAED,eAAe,yBAAyB,CAAA"}
|
package/lib/service.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
|
3
3
|
import Schema from '@deepseek-ai/schemastery';
|
|
4
4
|
import type { TrustedDeliveryPresentationProducer, TrustedDeliveryPresentationRegistration } from '@dsh-enhanced/assistant-delivery';
|
|
5
5
|
import type { ApprovalProposalResult } from '@dsh-enhanced/assistant-policy';
|
|
6
|
-
import type { EvolutionProposalMutation, QualityEvidenceKind, RuleCandidate, StoredAutonomousRollback, StoredEpisode, StoredProposal, StoredRule, SupervisedGrowthAnalystProposalInput, SupervisedGrowthAnalystReview } from './types.js';
|
|
6
|
+
import type { EvolutionProposalMutation, GoalDefinitionEpisodeSummary, QualityEvidenceKind, RuleCandidate, StoredAutonomousRollback, StoredEpisode, StoredProposal, StoredRule, SupervisedGrowthAnalystProposalInput, SupervisedGrowthAnalystReview } from './types.js';
|
|
7
7
|
export interface Config {
|
|
8
8
|
databasePath: string;
|
|
9
9
|
/** Recent episodes per situation considered when judging a rule. */
|
|
@@ -168,6 +168,12 @@ export declare class AssistantEvolutionService extends Service implements Truste
|
|
|
168
168
|
private readonly config;
|
|
169
169
|
private readonly now;
|
|
170
170
|
private delivery;
|
|
171
|
+
/**
|
|
172
|
+
* Optional live assistant-goals handle, used only to read advice repetition
|
|
173
|
+
* for goal-definition adoption drafts. Resolved dynamically (never a static
|
|
174
|
+
* inject) so evolution keeps no dependency/ordering edge on the goals plugin.
|
|
175
|
+
*/
|
|
176
|
+
private goals;
|
|
171
177
|
private readonly presentationProducerGeneration;
|
|
172
178
|
private presentationSink;
|
|
173
179
|
private active;
|
|
@@ -290,6 +296,20 @@ export declare class AssistantEvolutionService extends Service implements Truste
|
|
|
290
296
|
hostListRules(input: EvolutionHostOperation & {
|
|
291
297
|
status?: 'active' | 'retired';
|
|
292
298
|
}): StoredRule[];
|
|
299
|
+
/**
|
|
300
|
+
* Agent-free, exact-scope read of trusted goal-definition episode aggregates
|
|
301
|
+
* for the fixed Host runbook (G2 phase 2 strategy learning).
|
|
302
|
+
*
|
|
303
|
+
* This is observation only: the Store returns just the content-bound
|
|
304
|
+
* situation plus counts over rows the ledger itself marked
|
|
305
|
+
* `learning_eligible`, and this method mints no candidate, writes no row and
|
|
306
|
+
* widens no permission. Correlating the aggregates with assistant-goals'
|
|
307
|
+
* advice repetition stays on the Host side of the seam.
|
|
308
|
+
*/
|
|
309
|
+
hostGoalDefinitionEpisodes(input: EvolutionHostOperation & {
|
|
310
|
+
window?: number;
|
|
311
|
+
limit?: number;
|
|
312
|
+
}): readonly GoalDefinitionEpisodeSummary[];
|
|
293
313
|
/**
|
|
294
314
|
* Remove one exact active guidance generation through the opt-in low-risk lane.
|
|
295
315
|
*
|
|
@@ -354,6 +374,26 @@ export declare class AssistantEvolutionService extends Service implements Truste
|
|
|
354
374
|
*/
|
|
355
375
|
private withLearningWriterFence;
|
|
356
376
|
private candidatesForScope;
|
|
377
|
+
/**
|
|
378
|
+
* Adoption candidates the supervised-growth analyst is allowed to turn into a
|
|
379
|
+
* review draft. Non-`goal-definition` candidates pass through unchanged. A
|
|
380
|
+
* content-bound `goal-definition:<digest>` candidate must additionally clear
|
|
381
|
+
* the same repeated-and-failing gate the read-only recovery runbook observes:
|
|
382
|
+
* enough trusted failing episodes AND goals-side evidence that the same advice
|
|
383
|
+
* keeps recurring. This only *selects* a candidate for the existing
|
|
384
|
+
* review-token → owner-approval chain; it never adopts, writes a rule or reads
|
|
385
|
+
* any permission table.
|
|
386
|
+
*
|
|
387
|
+
* The episode input is the candidate's own exact adoption window — its
|
|
388
|
+
* complete `stats` plus the newest bound evidence sample's `occurredAt` — not a
|
|
389
|
+
* second store query, so the gate can never drift onto rows (e.g. a retired
|
|
390
|
+
* rule's era) that the candidate's own evidence digest does not cover. The
|
|
391
|
+
* advice side needs both the live assistant-goals handle and a dispatch route
|
|
392
|
+
* carrying full principal lineage; absent either, goal-definition drafts fail
|
|
393
|
+
* closed rather than minting a token with no owner/lineage destination.
|
|
394
|
+
*/
|
|
395
|
+
private analystAdoptionCandidates;
|
|
396
|
+
private sortAdoptionCandidates;
|
|
357
397
|
private trustedTaskLearningReceipt;
|
|
358
398
|
private applyTrustedTaskLearningReceipt;
|
|
359
399
|
private verifiedAutomationAttribution;
|
package/lib/service.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAEnD,OAAO,MAAM,MAAM,0BAA0B,CAAA;AAQ7C,OAAO,KAAK,EACV,mCAAmC,EACnC,uCAAuC,EACxC,MAAM,kCAAkC,CAAA;
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAEnD,OAAO,MAAM,MAAM,0BAA0B,CAAA;AAQ7C,OAAO,KAAK,EACV,mCAAmC,EACnC,uCAAuC,EACxC,MAAM,kCAAkC,CAAA;AAEzC,OAAO,KAAK,EAIV,sBAAsB,EAGvB,MAAM,gCAAgC,CAAA;AAoBvC,OAAO,KAAK,EAIV,yBAAyB,EACzB,4BAA4B,EAC5B,mBAAmB,EACnB,aAAa,EACb,wBAAwB,EACxB,aAAa,EAEb,cAAc,EACd,UAAU,EACV,oCAAoC,EACpC,6BAA6B,EAC9B,MAAM,YAAY,CAAA;AAMnB,MAAM,WAAW,MAAM;IACrB,YAAY,EAAE,MAAM,CAAA;IACpB,oEAAoE;IACpE,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CA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QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM;IAO/B,OAAO,CAAC,gBAAgB;IAOxB,OAAO,CAAC,cAAc;IA8EtB,OAAO,CAAC,SAAS;IAiBjB,OAAO,CAAC,YAAY;CAGrB;AAED,YAAY,EAAE,sBAAsB,EAAE,CAAA"}
|
package/lib/service.js
CHANGED
|
@@ -9,6 +9,7 @@ import { buildGuidance, buildGuidanceSnapshot } from './guidance.js';
|
|
|
9
9
|
import { evolutionMutationReview } from './review.js';
|
|
10
10
|
import { EvolutionStore, EvolutionStoreError, evolutionDigest, supervisedGrowthAnalystProposalIdempotencyKey, } from './store.js';
|
|
11
11
|
import { registerEvolutionTools } from './tools.js';
|
|
12
|
+
import { isGoalDefinitionSituation, joinStrategyLearningObservations, toStrategyAdviceSignal, } from './strategy-learning.js';
|
|
12
13
|
import { legacyEvolutionScope, SUPERVISED_GROWTH_ANALYST_CONTRACT_VERSION, } from './types.js';
|
|
13
14
|
const configSchema = Schema.object({
|
|
14
15
|
databasePath: Schema.string().required(),
|
|
@@ -50,6 +51,17 @@ export class AssistantEvolutionError extends Error {
|
|
|
50
51
|
export const HOST_RECOVERY_BACKGROUND_ID = 'dsh-enhanced-assistant-recovery';
|
|
51
52
|
/** The only Automation allowed to use the model-visible analyst capability. */
|
|
52
53
|
export const SUPERVISED_GROWTH_ANALYST_AUTOMATION_ID = 'heartbeat:supervised-growth-analyst';
|
|
54
|
+
/**
|
|
55
|
+
* Frozen advice-repetition floor a `goal-definition` adoption must additionally
|
|
56
|
+
* clear before the supervised-growth analyst is shown a draft. These mirror the
|
|
57
|
+
* read-only recovery strategy-learning catalog thresholds (minTrustedEpisodes
|
|
58
|
+
* 3 / minRepeatedAdviceRuns 2); they are duplicated here rather than imported
|
|
59
|
+
* from assistant-recovery because that package depends on this one, and the
|
|
60
|
+
* pure observation kernel they gate lives in this package. They are policy
|
|
61
|
+
* constants, not configuration, and must not be tuned by the growth executor.
|
|
62
|
+
*/
|
|
63
|
+
const STRATEGY_DRAFT_MIN_TRUSTED_EPISODES = 3;
|
|
64
|
+
const STRATEGY_DRAFT_MIN_REPEATED_ADVICE_RUNS = 2;
|
|
53
65
|
const evolutionHostScopeBrand = Symbol('assistant-evolution.host-scope');
|
|
54
66
|
/** Canonical, immutable and intentionally non-serializable Host scope token. */
|
|
55
67
|
export function canonicalEvolutionHostScope(input) {
|
|
@@ -140,6 +152,12 @@ export class AssistantEvolutionService extends Service {
|
|
|
140
152
|
config;
|
|
141
153
|
now;
|
|
142
154
|
delivery;
|
|
155
|
+
/**
|
|
156
|
+
* Optional live assistant-goals handle, used only to read advice repetition
|
|
157
|
+
* for goal-definition adoption drafts. Resolved dynamically (never a static
|
|
158
|
+
* inject) so evolution keeps no dependency/ordering edge on the goals plugin.
|
|
159
|
+
*/
|
|
160
|
+
goals;
|
|
143
161
|
presentationProducerGeneration = `assistant-evolution-presentation:${randomUUID()}`;
|
|
144
162
|
presentationSink;
|
|
145
163
|
active = true;
|
|
@@ -171,6 +189,18 @@ export class AssistantEvolutionService extends Service {
|
|
|
171
189
|
this.delivery = undefined;
|
|
172
190
|
};
|
|
173
191
|
});
|
|
192
|
+
// Optional and dynamic, exactly like assistantDelivery: goal-definition
|
|
193
|
+
// adoption drafts additionally require goals-side advice repetition, but a
|
|
194
|
+
// deployment without assistant-goals must still activate (those drafts then
|
|
195
|
+
// fail closed to absent advice instead of breaking the service).
|
|
196
|
+
ctx.inject(['assistantGoals'], goalsCtx => {
|
|
197
|
+
const goals = goalsCtx.get('assistantGoals');
|
|
198
|
+
this.goals = goals;
|
|
199
|
+
return () => {
|
|
200
|
+
if (this.goals === goals)
|
|
201
|
+
this.goals = undefined;
|
|
202
|
+
};
|
|
203
|
+
});
|
|
174
204
|
ctx.inject(['tools'], toolsCtx => registerEvolutionTools(toolsCtx, this));
|
|
175
205
|
ctx.on('agent/session-start', ({ agent }) => {
|
|
176
206
|
// Injection must never break session startup; a missing guidance block is
|
|
@@ -427,16 +457,8 @@ export class AssistantEvolutionService extends Service {
|
|
|
427
457
|
const execution = this.authorizeSupervisedGrowthAnalyst(agent, 'inspect', 'analyst-adoption');
|
|
428
458
|
// Even review requires the route that a later proposal will use. This
|
|
429
459
|
// prevents an analyst with no owner destination from minting stale tokens.
|
|
430
|
-
this.approvalRoute(agent, undefined);
|
|
431
|
-
const candidate = this.
|
|
432
|
-
.filter(entry => entry.kind === 'adopt')
|
|
433
|
-
.sort((left, right) => {
|
|
434
|
-
const rateOrder = right.stats.failures * left.stats.total
|
|
435
|
-
- left.stats.failures * right.stats.total;
|
|
436
|
-
return rateOrder || right.stats.failures - left.stats.failures
|
|
437
|
-
|| right.stats.total - left.stats.total
|
|
438
|
-
|| left.situation.localeCompare(right.situation);
|
|
439
|
-
})[0];
|
|
460
|
+
const route = this.approvalRoute(agent, undefined);
|
|
461
|
+
const candidate = this.analystAdoptionCandidates(agent, execution.scopeKey, route)[0];
|
|
440
462
|
if (candidate === undefined) {
|
|
441
463
|
return Object.freeze({ contractVersion: SUPERVISED_GROWTH_ANALYST_CONTRACT_VERSION });
|
|
442
464
|
}
|
|
@@ -556,6 +578,23 @@ export class AssistantEvolutionService extends Service {
|
|
|
556
578
|
const scopeKey = this.authorizeHost(input, 'inspect', `rules:${input.status ?? 'all'}`);
|
|
557
579
|
return this.store.listRules(scopeKey, input.status);
|
|
558
580
|
}
|
|
581
|
+
/**
|
|
582
|
+
* Agent-free, exact-scope read of trusted goal-definition episode aggregates
|
|
583
|
+
* for the fixed Host runbook (G2 phase 2 strategy learning).
|
|
584
|
+
*
|
|
585
|
+
* This is observation only: the Store returns just the content-bound
|
|
586
|
+
* situation plus counts over rows the ledger itself marked
|
|
587
|
+
* `learning_eligible`, and this method mints no candidate, writes no row and
|
|
588
|
+
* widens no permission. Correlating the aggregates with assistant-goals'
|
|
589
|
+
* advice repetition stays on the Host side of the seam.
|
|
590
|
+
*/
|
|
591
|
+
hostGoalDefinitionEpisodes(input) {
|
|
592
|
+
const scopeKey = this.authorizeHost(input, 'inspect', 'goal-definition-episodes');
|
|
593
|
+
const window = input.window ?? this.config.evaluationWindow;
|
|
594
|
+
return this.store.summarizeGoalDefinitionEpisodes(input.limit === undefined
|
|
595
|
+
? { scopeKey, window }
|
|
596
|
+
: { scopeKey, window, limit: input.limit });
|
|
597
|
+
}
|
|
559
598
|
/**
|
|
560
599
|
* Remove one exact active guidance generation through the opt-in low-risk lane.
|
|
561
600
|
*
|
|
@@ -1087,6 +1126,93 @@ export class AssistantEvolutionService extends Service {
|
|
|
1087
1126
|
evidenceSampleLimit: this.config.maxEvidenceSamples,
|
|
1088
1127
|
});
|
|
1089
1128
|
}
|
|
1129
|
+
/**
|
|
1130
|
+
* Adoption candidates the supervised-growth analyst is allowed to turn into a
|
|
1131
|
+
* review draft. Non-`goal-definition` candidates pass through unchanged. A
|
|
1132
|
+
* content-bound `goal-definition:<digest>` candidate must additionally clear
|
|
1133
|
+
* the same repeated-and-failing gate the read-only recovery runbook observes:
|
|
1134
|
+
* enough trusted failing episodes AND goals-side evidence that the same advice
|
|
1135
|
+
* keeps recurring. This only *selects* a candidate for the existing
|
|
1136
|
+
* review-token → owner-approval chain; it never adopts, writes a rule or reads
|
|
1137
|
+
* any permission table.
|
|
1138
|
+
*
|
|
1139
|
+
* The episode input is the candidate's own exact adoption window — its
|
|
1140
|
+
* complete `stats` plus the newest bound evidence sample's `occurredAt` — not a
|
|
1141
|
+
* second store query, so the gate can never drift onto rows (e.g. a retired
|
|
1142
|
+
* rule's era) that the candidate's own evidence digest does not cover. The
|
|
1143
|
+
* advice side needs both the live assistant-goals handle and a dispatch route
|
|
1144
|
+
* carrying full principal lineage; absent either, goal-definition drafts fail
|
|
1145
|
+
* closed rather than minting a token with no owner/lineage destination.
|
|
1146
|
+
*/
|
|
1147
|
+
analystAdoptionCandidates(agent, scopeKey, route) {
|
|
1148
|
+
const adoption = this.candidatesForScope(scopeKey).filter(entry => entry.kind === 'adopt');
|
|
1149
|
+
const goalDefinitionSituations = new Set(adoption
|
|
1150
|
+
.map(entry => entry.situation)
|
|
1151
|
+
.filter(situation => isGoalDefinitionSituation(situation)));
|
|
1152
|
+
if (goalDefinitionSituations.size === 0) {
|
|
1153
|
+
return this.sortAdoptionCandidates(adoption);
|
|
1154
|
+
}
|
|
1155
|
+
// Fail closed: advice repetition is unreadable without goals, and the advice
|
|
1156
|
+
// ledger is scoped by the owner's exact principal lineage, which only the
|
|
1157
|
+
// delivery dispatch route carries (a headless route has no dispatch).
|
|
1158
|
+
if (this.goals === undefined || route.dispatch === undefined
|
|
1159
|
+
|| route.dispatch.principalRecordId.trim() === ''
|
|
1160
|
+
|| typeof route.dispatch.principalVersion !== 'number') {
|
|
1161
|
+
return this.sortAdoptionCandidates(adoption.filter(entry => !goalDefinitionSituations.has(entry.situation)));
|
|
1162
|
+
}
|
|
1163
|
+
const workspace = agent.session.header.cwd;
|
|
1164
|
+
const preset = agent.session.header.agentPreset;
|
|
1165
|
+
if (workspace === undefined || !isAbsolute(workspace)
|
|
1166
|
+
|| preset === undefined || preset.trim() === '') {
|
|
1167
|
+
// authorize() already established this for the analyst call; defending it
|
|
1168
|
+
// here keeps the goals scope construction honest if the method is reused.
|
|
1169
|
+
throw new AssistantEvolutionError('missing-identity', 'goals advice scope requires an absolute workspace and preset');
|
|
1170
|
+
}
|
|
1171
|
+
const goalScope = Object.freeze({
|
|
1172
|
+
principalId: route.dispatch.principal,
|
|
1173
|
+
principalRecordId: route.dispatch.principalRecordId,
|
|
1174
|
+
principalVersion: route.dispatch.principalVersion,
|
|
1175
|
+
workspace,
|
|
1176
|
+
preset,
|
|
1177
|
+
});
|
|
1178
|
+
const advice = this.goals
|
|
1179
|
+
.hostSummarizeAdviceByDefinition(goalScope)
|
|
1180
|
+
.map(toStrategyAdviceSignal);
|
|
1181
|
+
// One kernel input row per candidate, built strictly from its own window.
|
|
1182
|
+
const episodes = [];
|
|
1183
|
+
for (const candidate of adoption) {
|
|
1184
|
+
if (!goalDefinitionSituations.has(candidate.situation))
|
|
1185
|
+
continue;
|
|
1186
|
+
const total = candidate.stats.total;
|
|
1187
|
+
const failures = candidate.stats.failures;
|
|
1188
|
+
episodes.push(Object.freeze({
|
|
1189
|
+
situation: candidate.situation,
|
|
1190
|
+
failures,
|
|
1191
|
+
succeeded: total - failures,
|
|
1192
|
+
total,
|
|
1193
|
+
lastOccurredAt: candidate.evidence[0]?.occurredAt ?? 0,
|
|
1194
|
+
}));
|
|
1195
|
+
}
|
|
1196
|
+
const repeatedAndFailing = new Set(joinStrategyLearningObservations({
|
|
1197
|
+
episodes,
|
|
1198
|
+
advice,
|
|
1199
|
+
minTrustedEpisodes: STRATEGY_DRAFT_MIN_TRUSTED_EPISODES,
|
|
1200
|
+
minRepeatedAdviceRuns: STRATEGY_DRAFT_MIN_REPEATED_ADVICE_RUNS,
|
|
1201
|
+
})
|
|
1202
|
+
.filter(observation => observation.repeatedAndFailing)
|
|
1203
|
+
.map(observation => observation.situation));
|
|
1204
|
+
return this.sortAdoptionCandidates(adoption.filter(entry => !goalDefinitionSituations.has(entry.situation)
|
|
1205
|
+
|| repeatedAndFailing.has(entry.situation)));
|
|
1206
|
+
}
|
|
1207
|
+
sortAdoptionCandidates(candidates) {
|
|
1208
|
+
return candidates.slice().sort((left, right) => {
|
|
1209
|
+
const rateOrder = right.stats.failures * left.stats.total
|
|
1210
|
+
- left.stats.failures * right.stats.total;
|
|
1211
|
+
return rateOrder || right.stats.failures - left.stats.failures
|
|
1212
|
+
|| right.stats.total - left.stats.total
|
|
1213
|
+
|| left.situation.localeCompare(right.situation);
|
|
1214
|
+
});
|
|
1215
|
+
}
|
|
1090
1216
|
trustedTaskLearningReceipt(scope, evaluationId) {
|
|
1091
1217
|
const evaluation = this.context.get('assistantEvaluation');
|
|
1092
1218
|
if (evaluation === undefined || typeof evaluation.getTrustedTaskLearningProjection !== 'function') {
|