@pellux/goodvibes-sdk 0.33.21 → 0.33.23

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.
@@ -3,7 +3,7 @@
3
3
  "product": {
4
4
  "id": "goodvibes",
5
5
  "surface": "operator",
6
- "version": "0.33.21"
6
+ "version": "0.33.23"
7
7
  },
8
8
  "auth": {
9
9
  "modes": [
@@ -82,6 +82,7 @@ export declare class WrfcController {
82
82
  private createBaseChain;
83
83
  private startEngineeringChain;
84
84
  private handleEngineerCompletion;
85
+ private canonicalizeFixerReportConstraints;
85
86
  private spawnWrfcAgent;
86
87
  private withRouteReason;
87
88
  private completeChainAsPassed;
@@ -1 +1 @@
1
- {"version":3,"file":"wrfc-controller.d.ts","sourceRoot":"","sources":["../../../src/platform/agents/wrfc-controller.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AASnD,OAAO,KAAK,EAGV,SAAS,EACT,sBAAsB,EAKvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAG3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAc,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,KAAK,EACV,8BAA8B,EAE9B,8BAA8B,EAC/B,MAAM,wCAAwC,CAAC;AAUhD,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,kBAAkB,CAAC;AAmB1B,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAczG,KAAK,eAAe,GAAG,IA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,CAAC,qBAAqB;IAU7B,OAAO,CAAC,eAAe;IAQvB,OAAO,CAAC,WAAW;YAqCL,WAAW;IAyBzB,OAAO,CAAC,kBAAkB;IAO1B,OAAO,CAAC,cAAc;IAEtB,OAAO,CAAC,kBAAkB;IAE1B,OAAO,CAAC,mBAAmB;IA0C3B,OAAO,CAAC,mBAAmB;IAM3B,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,eAAe;IAgCvB,OAAO,CAAC,qBAAqB;IA0C7B,OAAO,CAAC,wBAAwB;IA0EhC,OAAO,CAAC,kCAAkC;IAiB1C,OAAO,CAAC,cAAc;IAkCtB,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,qBAAqB;IAc7B,OAAO,CAAC,kBAAkB;IAiC1B,OAAO,CAAC,sBAAsB;IAiD9B,OAAO,CAAC,yBAAyB;IA6BjC,OAAO,CAAC,gCAAgC;IAgCxC,OAAO,CAAC,oBAAoB;IAW5B,OAAO,CAAC,sBAAsB;IAQ9B,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,eAAe;CAKxB"}
@@ -910,6 +910,7 @@ export class WrfcController {
910
910
  this.upsertWrfcWorkPlanTask(chain, 'engineer', engineerRecord, 'in_progress');
911
911
  }
912
912
  handleEngineerCompletion(chain, agentId, report) {
913
+ let reportForReview = report;
913
914
  this.completeCurrentNode(chain, report.summary);
914
915
  if (chain.state === 'engineering') {
915
916
  chain.engineerReport = report;
@@ -938,16 +939,39 @@ export class WrfcController {
938
939
  // Fixer continuity validation: verify the fixer returned the same constraint id-set.
939
940
  // If it diverged, inject a synthetic critical issue for the next review pass.
940
941
  const fixerConstraints = isEngineerReportShape(report) ? (report.constraints ?? []) : [];
941
- const expectedIds = new Set(chain.constraints.map((c) => c.id));
942
- const actualIds = new Set(fixerConstraints.map((c) => c.id));
943
- const missing = [...expectedIds].filter((id) => !actualIds.has(id));
944
- const extra = [...actualIds].filter((id) => !expectedIds.has(id));
945
- if (missing.length > 0 || extra.length > 0) {
946
- const description = `Fixer regressed constraint continuity: missing=[${missing.join(',')}] extra=[${extra.join(',')}]`;
942
+ if (isEngineerReportShape(report)) {
943
+ reportForReview = this.canonicalizeFixerReportConstraints(report, chain.constraints);
944
+ }
945
+ if (chain.constraints.length === 0) {
946
+ if (fixerConstraints.length > 0) {
947
+ logger.warn('WrfcController: ignored fixer-invented constraints for unconstrained chain', {
948
+ chainId: chain.id,
949
+ extra: fixerConstraints.map((constraint) => constraint.id),
950
+ });
951
+ }
952
+ }
953
+ else if (isEngineerReportShape(report)) {
954
+ const expectedIds = new Set(chain.constraints.map((c) => c.id));
955
+ const actualIds = new Set(fixerConstraints.map((c) => c.id));
956
+ const missing = [...expectedIds].filter((id) => !actualIds.has(id));
957
+ const extra = [...actualIds].filter((id) => !expectedIds.has(id));
958
+ if (missing.length > 0 || extra.length > 0) {
959
+ const description = `Fixer regressed constraint continuity: missing=[${missing.join(',')}] extra=[${extra.join(',')}]`;
960
+ logger.warn('WrfcController: fixer constraint-continuity violation', {
961
+ chainId: chain.id,
962
+ missing,
963
+ extra,
964
+ });
965
+ chain.syntheticIssues ??= [];
966
+ chain.syntheticIssues.push({ severity: 'critical', description });
967
+ }
968
+ }
969
+ else {
970
+ const description = `Fixer regressed constraint continuity: missing=[${chain.constraints.map((c) => c.id).join(',')}] extra=[]`;
947
971
  logger.warn('WrfcController: fixer constraint-continuity violation', {
948
972
  chainId: chain.id,
949
- missing,
950
- extra,
973
+ missing: chain.constraints.map((constraint) => constraint.id),
974
+ extra: [],
951
975
  });
952
976
  chain.syntheticIssues ??= [];
953
977
  chain.syntheticIssues.push({ severity: 'critical', description });
@@ -955,7 +979,23 @@ export class WrfcController {
955
979
  // The authoritative constraint list is NOT overwritten — chain.constraints remains the
956
980
  // original enumeration from the initial engineer turn.
957
981
  }
958
- this.startReview(chain, report);
982
+ this.startReview(chain, reportForReview);
983
+ }
984
+ canonicalizeFixerReportConstraints(report, constraints) {
985
+ const canonical = {
986
+ ...report,
987
+ constraints: constraints.map((constraint) => ({ ...constraint })),
988
+ };
989
+ const { reviewableOutput: _ignored, ...jsonReport } = canonical;
990
+ canonical.reviewableOutput = [
991
+ 'Controller-canonicalized EngineerReport for WRFC review.',
992
+ 'The constraint list below is the authoritative chain constraint list; fixer-invented or renamed constraints were not forwarded to the reviewer.',
993
+ '',
994
+ '```json',
995
+ JSON.stringify(jsonReport, null, 2),
996
+ '```',
997
+ ].join('\n');
998
+ return canonical;
959
999
  }
960
1000
  spawnWrfcAgent(chain, role, template, task, dangerouslyDisableWrfc) {
961
1001
  const owner = this.agentManager.getStatus(chain.ownerAgentId);
@@ -1 +1 @@
1
- {"version":3,"file":"wrfc-reporting.d.ts","sourceRoot":"","sources":["../../../src/platform/agents/wrfc-reporting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,iBAAiB,EAAkB,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAG9H,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAQzD,KAAK,0BAA0B,GAAG,gBAAgB,GAAG;IACnD,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAuBhE;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAK7F;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAAC,QAAQ,CAAC,CAa5E;AAED,wBAAgB,6BAA6B,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,0BAA0B,CAkB/G;AAED,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,cAAc,CA6BhB;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,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,0BAA0B,CAkB/G;AAED,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,cAAc,CA6BhB;AAID,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,0BAA0B,EAClC,SAAS,EAAE,MAAM,EACjB,WAAW,GAAE,UAAU,EAAO,GAC7B,MAAM,CAuDR;AAiGD,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,WAAW,GAAE,UAAU,EAAO,EAC9B,kBAAkB,GAAE,iBAAiB,EAAO,GAC3C,MAAM,CAiER;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,SAAS,iBAAiB,EAAE,EACzC,WAAW,GAAE,SAAS,UAAU,EAAO,GACtC,MAAM,CAuCR"}
@@ -266,7 +266,11 @@ export function buildFixTask(chainId, originalTask, review, threshold, fixAttemp
266
266
  `6. Return a structured EngineerReport JSON block including gatheredContext, plannedActions, and appliedChanges in your final response.`,
267
267
  ].join('\n');
268
268
  if (constraints.length === 0) {
269
- return base;
269
+ return [
270
+ base,
271
+ ``,
272
+ `Constraint continuity: the initial engineer declared no user-declared constraints for this chain. Return "constraints": [] in your EngineerReport. Do not invent constraint ids from the review findings, implementation details, or quality rubric.`,
273
+ ].join('\n');
270
274
  }
271
275
  // Build a finding-lookup map: constraintId -> ConstraintFinding
272
276
  const findingMap = new Map();
@@ -25,6 +25,7 @@ export declare function handleToolResponseOutcome(args: {
25
25
  emitterContext: EmitterContextFactory;
26
26
  turnId: string;
27
27
  response: ChatResponseWithReasoning;
28
+ userText: string;
28
29
  executeToolCalls: (turnId: string, calls: ToolCall[]) => Promise<ToolResult[]>;
29
30
  setPendingToolCalls: (calls: ToolCall[]) => void;
30
31
  messageQueueLength: number;
@@ -1 +1 @@
1
- {"version":3,"file":"orchestrator-turn-helpers.d.ts","sourceRoot":"","sources":["../../../src/platform/core/orchestrator-turn-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAGjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAY,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAIlE,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,KAAK,qBAAqB,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,8BAA8B,EAAE,cAAc,CAAC;AACvG,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG;IACjF,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC,CAAC;AAQF,wBAAgB,gCAAgC,CAC9C,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,OAAO,EACpB,eAAe,EAAE,IAAI,CAAC,e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B,CAAC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,uBAAuB,EAAE,OAAO,CAAC;CAClC,GAAG,IAAI,CAsBP"}
@@ -3,6 +3,7 @@ import { logger } from '../utils/logger.js';
3
3
  import { emitPlanStrategySelected, emitToolReconciled, emitTurnCompleted } from '../runtime/emitters/index.js';
4
4
  import { buildSyntheticResult } from './tool-reconciliation.js';
5
5
  import { autoSpawnPendingItems } from './orchestrator-tool-runtime.js';
6
+ import { buildWrfcWorkflowRoutingPrompt, toolResultIndicatesAuthoritativeWrfcChain } from './wrfc-routing.js';
6
7
  const PROJECT_PRIMING_SIGNALS = new Set([
7
8
  'parallelism_keywords',
8
9
  'multi_sentence_actions',
@@ -54,6 +55,10 @@ export function prepareConversationForTurn(conversation, providerRegistry, text,
54
55
  else {
55
56
  conversation.addUserMessage(content ?? text);
56
57
  }
58
+ const wrfcRoutingPrompt = buildWrfcWorkflowRoutingPrompt(text);
59
+ if (wrfcRoutingPrompt) {
60
+ conversation.addSystemMessage(wrfcRoutingPrompt);
61
+ }
57
62
  const activePlan = planManager?.getActive(sessionId) ?? null;
58
63
  if (!activePlan) {
59
64
  const classification = classifyIntent(text);
@@ -70,17 +75,40 @@ export function prepareConversationForTurn(conversation, providerRegistry, text,
70
75
  }
71
76
  return preTurnPlan;
72
77
  }
78
+ function attachAuthoritativeTaskToAgentCalls(toolCalls, userText) {
79
+ const authoritativeTask = userText.trim();
80
+ if (!authoritativeTask)
81
+ return [...toolCalls];
82
+ return toolCalls.map((call) => {
83
+ if (call.name !== 'agent')
84
+ return call;
85
+ const args = call.arguments;
86
+ const mode = args.mode;
87
+ if (mode !== 'spawn' && mode !== 'batch-spawn')
88
+ return call;
89
+ if (typeof args.parentAgentId === 'string' && args.parentAgentId.trim().length > 0)
90
+ return call;
91
+ return {
92
+ ...call,
93
+ arguments: {
94
+ ...args,
95
+ authoritativeTask,
96
+ },
97
+ };
98
+ });
99
+ }
73
100
  export async function handleToolResponseOutcome(args) {
74
- args.setPendingToolCalls(args.response.toolCalls);
101
+ const toolCalls = attachAuthoritativeTaskToAgentCalls(args.response.toolCalls, args.userText);
102
+ args.setPendingToolCalls(toolCalls);
75
103
  args.conversation.addAssistantMessage(args.response.content, {
76
- toolCalls: args.response.toolCalls,
104
+ toolCalls,
77
105
  reasoningContent: args.response.reasoning || undefined,
78
106
  reasoningSummary: args.response.reasoningSummary || undefined,
79
107
  usage: args.response.usage,
80
108
  model: args.providerRegistry.getCurrentModel().displayName,
81
109
  provider: args.providerRegistry.getCurrentModel().provider,
82
110
  });
83
- const results = await args.executeToolCalls(args.turnId, args.response.toolCalls);
111
+ const results = await args.executeToolCalls(args.turnId, toolCalls);
84
112
  args.conversation.addToolResults(results);
85
113
  args.setPendingToolCalls([]);
86
114
  const allImages = results
@@ -93,33 +121,44 @@ export async function handleToolResponseOutcome(args) {
93
121
  ];
94
122
  args.conversation.addUserMessage(imageParts);
95
123
  }
96
- const spawnedAgents = args.response.toolCalls.some((tc) => {
124
+ const spawnedAgents = toolCalls.some((tc) => {
97
125
  const mode = tc.arguments.mode;
98
126
  return tc.name === 'agent' && (mode === 'spawn' || mode === 'batch-spawn');
99
127
  });
128
+ const spawnedAuthoritativeWrfcChain = spawnedAgents && results.some(toolResultIndicatesAuthoritativeWrfcChain);
100
129
  if (spawnedAgents || args.messageQueueLength > 0) {
101
130
  if (spawnedAgents) {
102
131
  const planManager = args.planManager;
103
132
  const activePlan = planManager?.getActive(args.sessionId) ?? null;
104
133
  if (activePlan) {
105
134
  const summary = planManager?.getSummary(activePlan) ?? '';
106
- const nextItems = planManager?.getNextItems(activePlan) ?? [];
107
- if (nextItems.length > 0) {
108
- const autoSpawnedDescs = autoSpawnPendingItems(args.conversation, activePlan, nextItems, args.agentManager, args.configManager, args.providerRegistry, args.runtimeBus, args.emitterContext(args.turnId), planManager);
109
- if (autoSpawnedDescs.length > 0) {
110
- args.conversation.addSystemMessage(`[Plan] Auto-spawned ${autoSpawnedDescs.length} agent(s) for remaining plan items: ${autoSpawnedDescs.join(', ')}. Plan progress: ${summary}.`);
135
+ if (spawnedAuthoritativeWrfcChain) {
136
+ args.conversation.addSystemMessage(`A WRFC owner chain is now the authoritative owner for this deliverable. Do not spawn additional root agents for review, testing, verification, or fixing this same work; inspect the WRFC chain status instead. Plan progress: ${summary}.`);
137
+ }
138
+ else {
139
+ const nextItems = planManager?.getNextItems(activePlan) ?? [];
140
+ if (nextItems.length > 0) {
141
+ const autoSpawnedDescs = autoSpawnPendingItems(args.conversation, activePlan, nextItems, args.agentManager, args.configManager, args.providerRegistry, args.runtimeBus, args.emitterContext(args.turnId), planManager);
142
+ if (autoSpawnedDescs.length > 0) {
143
+ args.conversation.addSystemMessage(`[Plan] Auto-spawned ${autoSpawnedDescs.length} agent(s) for remaining plan items: ${autoSpawnedDescs.join(', ')}. Plan progress: ${summary}.`);
144
+ }
145
+ else {
146
+ const nextDesc = nextItems.map(i => i.description).join(', ');
147
+ args.conversation.addSystemMessage(`Plan progress: ${summary}. Next items ready: ${nextDesc}. Continue spawning agents for remaining work.`);
148
+ }
111
149
  }
112
150
  else {
113
- const nextDesc = nextItems.map(i => i.description).join(', ');
114
- args.conversation.addSystemMessage(`Plan progress: ${summary}. Next items ready: ${nextDesc}. Continue spawning agents for remaining work.`);
151
+ args.conversation.addSystemMessage(`Plan progress: ${summary}. All items are accounted for.`);
115
152
  }
116
153
  }
117
- else {
118
- args.conversation.addSystemMessage(`Plan progress: ${summary}. All items are accounted for.`);
119
- }
120
154
  }
121
155
  else {
122
- args.conversation.addSystemMessage('You spawned an agent for part of the task. If there are remaining tasks, continue spawning agents now.');
156
+ if (spawnedAuthoritativeWrfcChain) {
157
+ args.conversation.addSystemMessage('A WRFC owner chain is now the authoritative owner for this deliverable. Do not spawn additional root agents for review, testing, verification, or fixing this same work; inspect the WRFC chain status instead.');
158
+ }
159
+ else {
160
+ args.conversation.addSystemMessage('You spawned an agent for part of the task. If there are remaining tasks, continue spawning agents now.');
161
+ }
123
162
  }
124
163
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EAAE,KACpB,MAAM,CAAC;IACZ,QAAQ,CAAC,qBAAqB,EAAE,MAAM,MAAM,CAAC;IAC7C,QAAQ,CAAC,uBAAuB,EAAE,MAAM,OAAO,CAAC;IAChD,QAAQ,CAAC,mBAAmB,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,IAAI,CAAC;IAC1D,QAAQ,CAAC,mBAAmB,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;IACtF,QAAQ,CAAC,kBAAkB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACtD,QAAQ,CAAC,uBAAuB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1D,QAAQ,CAAC,wBAAwB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3D,QAAQ,CAAC,yBAAyB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5D,QAAQ,CAAC,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrD,QAAQ,CAAC,cAAc,EAAE,MAAM,IAAI,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE;QACd,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,wBAAsB,2BAA2B,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,IAAI,CAAC,CAyWrG"}
@@ -7,6 +7,7 @@ import { HelperModel } from '../config/helper-model.js';
7
7
  import { logger } from '../utils/logger.js';
8
8
  import { emitMalformedToolUseWarning, handleFinalResponseOutcome, handleToolResponseOutcome, } from './orchestrator-turn-helpers.js';
9
9
  import { appendGoodVibesRuntimeAwarenessPrompt } from '../tools/goodvibes-runtime/index.js';
10
+ import { buildWrfcWorkflowRoutingPrompt } from './wrfc-routing.js';
10
11
  const AUTO_SPAWN_FALLBACK_DELAY_MS = 5_000;
11
12
  export async function executeOrchestratorTurnLoop(context) {
12
13
  const helperModel = context.helperModel;
@@ -108,11 +109,13 @@ export async function executeOrchestratorTurnLoop(context) {
108
109
  });
109
110
  }
110
111
  try {
112
+ const baseSystemPrompt = appendGoodVibesRuntimeAwarenessPrompt(context.getSystemPrompt());
113
+ const wrfcRoutingPrompt = buildWrfcWorkflowRoutingPrompt(context.text);
111
114
  response = await provider.chat({
112
115
  model: model.id,
113
116
  messages: context.conversation.getMessagesForLLM(),
114
117
  tools: toolDefinitions.length > 0 ? toolDefinitions : undefined,
115
- systemPrompt: appendGoodVibesRuntimeAwarenessPrompt(context.getSystemPrompt()),
118
+ systemPrompt: wrfcRoutingPrompt ? `${baseSystemPrompt}\n\n${wrfcRoutingPrompt}` : baseSystemPrompt,
116
119
  maxTokens: tokenLimits.maxOutputTokens,
117
120
  reasoningEffort: (() => {
118
121
  const configured = context.configManager.get('provider.reasoningEffort');
@@ -270,6 +273,7 @@ export async function executeOrchestratorTurnLoop(context) {
270
273
  emitterContext: (id) => context.emitterContext(id),
271
274
  turnId: context.turnId,
272
275
  response: enrichedResponse,
276
+ userText: context.text,
273
277
  executeToolCalls: (id, calls) => context.executeToolCalls(id, calls),
274
278
  setPendingToolCalls: (calls) => { context.setPendingToolCalls(calls); },
275
279
  messageQueueLength: context.getMessageQueueLength(),
@@ -0,0 +1,5 @@
1
+ import type { ToolResult } from '../types/tools.js';
2
+ export declare function isWrfcWorkflowRequest(text: string): boolean;
3
+ export declare function buildWrfcWorkflowRoutingPrompt(text: string): string | null;
4
+ export declare function toolResultIndicatesAuthoritativeWrfcChain(result: ToolResult): boolean;
5
+ //# sourceMappingURL=wrfc-routing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrfc-routing.d.ts","sourceRoot":"","sources":["../../../src/platform/core/wrfc-routing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAM3D;AAED,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG1E;AAyBD,wBAAgB,yCAAyC,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAQrF"}
@@ -0,0 +1,51 @@
1
+ export function isWrfcWorkflowRequest(text) {
2
+ const normalized = text.trim().toLowerCase();
3
+ if (!/\bwrfc\b/.test(normalized))
4
+ return false;
5
+ if (/^(what|why|how|explain|describe|define)\b/.test(normalized))
6
+ return false;
7
+ return /\bwrfc\b.{0,80}\b(review|agent|build|make|implement|fix|test|verify|for)\b/.test(normalized)
8
+ || /\b(review|agent|build|make|implement|fix|test|verify)\b.{0,80}\bwrfc\b/.test(normalized);
9
+ }
10
+ export function buildWrfcWorkflowRoutingPrompt(text) {
11
+ if (!isWrfcWorkflowRequest(text))
12
+ return null;
13
+ return '[WRFC routing] The user is asking for WRFC-owned work. Use the agent tool to start exactly one WRFC owner chain with mode=spawn, template=engineer, reviewMode=wrfc. Do not answer by describing WRFC, and do not spawn reviewer/tester/verifier roots.';
14
+ }
15
+ function isRecord(value) {
16
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
17
+ }
18
+ function parseToolOutput(output) {
19
+ if (!output)
20
+ return null;
21
+ try {
22
+ const parsed = JSON.parse(output);
23
+ return isRecord(parsed) ? parsed : null;
24
+ }
25
+ catch {
26
+ return null;
27
+ }
28
+ }
29
+ function recordIsAuthoritativeWrfcOwner(record) {
30
+ if (record.orchestrationStopSignal === 'wrfc_owner_chain_started')
31
+ return true;
32
+ if (record.authoritativeWrfcChain === true && record.continueRootSpawning === false)
33
+ return true;
34
+ return record.wrfcRole === 'owner'
35
+ && typeof record.wrfcId === 'string'
36
+ && record.wrfcId.length > 0
37
+ && record.continueRootSpawning === false;
38
+ }
39
+ export function toolResultIndicatesAuthoritativeWrfcChain(result) {
40
+ if (!result.success)
41
+ return false;
42
+ const payload = parseToolOutput(result.output);
43
+ if (!payload)
44
+ return false;
45
+ if (recordIsAuthoritativeWrfcOwner(payload))
46
+ return true;
47
+ const agents = payload.agents;
48
+ if (!Array.isArray(agents))
49
+ return false;
50
+ return agents.some((agent) => isRecord(agent) && recordIsAuthoritativeWrfcOwner(agent));
51
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/platform/tools/agent/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAmB,YAAY,EAAoB,MAAM,cAAc,CAAC;AAK/E,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AA2F7D,wBAAgB,eAAe,CAAC,MAAM,EAAE;IACtC,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,EAAE,IAAI,CAAC,eAAe,EAAE,aAAa,GAAG,MAAM,CAAC,CAAC;IAC1D,cAAc,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,YAAY,CAAC,GAAG,SAAS,CAAC;IAChE,eAAe,CAAC,EAAE,IAAI,CAAC,eAAe,EAAE,eAAe,CAAC,GAAG,SAAS,CAAC;IACrE,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;CAC3C,GAAG,IAAI,CAmlBP"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/platform/tools/agent/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAmB,YAAY,EAAoB,MAAM,cAAc,CAAC;AAK/E,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAgH7D,wBAAgB,eAAe,CAAC,MAAM,EAAE;IACtC,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,EAAE,IAAI,CAAC,eAAe,EAAE,aAAa,GAAG,MAAM,CAAC,CAAC;IAC1D,cAAc,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,YAAY,CAAC,GAAG,SAAS,CAAC;IAChE,eAAe,CAAC,EAAE,IAAI,CAAC,eAAe,EAAE,eAAe,CAAC,GAAG,SAAS,CAAC;IACrE,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;CAC3C,GAAG,IAAI,CAulBP"}
@@ -36,6 +36,18 @@ function agentTopology(record) {
36
36
  parentNodeId: record.parentNodeId ?? null,
37
37
  };
38
38
  }
39
+ function agentOrchestrationControl(record) {
40
+ const authoritativeWrfcChain = record.wrfcRole === 'owner' && typeof record.wrfcId === 'string' && record.wrfcId.length > 0;
41
+ return {
42
+ authoritativeWrfcChain,
43
+ continueRootSpawning: authoritativeWrfcChain ? false : true,
44
+ rootSpawnContinuation: authoritativeWrfcChain ? 'stop' : 'allowed',
45
+ orchestrationStopSignal: authoritativeWrfcChain ? 'wrfc_owner_chain_started' : null,
46
+ orchestrationInstruction: authoritativeWrfcChain
47
+ ? 'This WRFC owner chain is authoritative for the deliverable. Do not spawn additional root review/test/verification/fix agents for the same work.'
48
+ : null,
49
+ };
50
+ }
39
51
  function agentExecutionContract(record) {
40
52
  return {
41
53
  executionIntent: record.executionIntent ?? null,
@@ -63,10 +75,17 @@ function agentSummary(record) {
63
75
  ...agentTopology(record),
64
76
  };
65
77
  }
78
+ function agentSpawnSummary(record) {
79
+ return {
80
+ ...agentSummary(record),
81
+ ...agentOrchestrationControl(record),
82
+ };
83
+ }
66
84
  function batchTaskToSpawnInput(input, taskDef) {
67
85
  return {
68
86
  mode: 'spawn',
69
87
  task: taskDef.task,
88
+ authoritativeTask: input.authoritativeTask ?? input.task,
70
89
  template: taskDef.template ?? input.template ?? 'general',
71
90
  model: taskDef.model ?? input.model,
72
91
  provider: taskDef.provider ?? input.provider,
@@ -147,6 +166,7 @@ export function createAgentTool(config) {
147
166
  task: record.task,
148
167
  ...agentExecutionContract(record),
149
168
  ...agentTopology(record),
169
+ ...agentOrchestrationControl(record),
150
170
  }),
151
171
  };
152
172
  }
@@ -450,11 +470,12 @@ export function createAgentTool(config) {
450
470
  return {
451
471
  success: true,
452
472
  output: JSON.stringify({
453
- agents: [{ ...agentSummary(record), task: record.task.slice(0, 80) }],
473
+ agents: [{ ...agentSpawnSummary(record), task: record.task.slice(0, 80) }],
454
474
  count: 1,
455
475
  cohort: input.cohort,
456
476
  skipped: 0,
457
477
  normalizedToSpawn: true,
478
+ ...agentOrchestrationControl(record),
458
479
  }),
459
480
  };
460
481
  }
@@ -473,7 +494,7 @@ export function createAgentTool(config) {
473
494
  return {
474
495
  success: true,
475
496
  output: JSON.stringify({
476
- agents: [{ ...agentSummary(record), task: record.task.slice(0, 80) }],
497
+ agents: [{ ...agentSpawnSummary(record), task: record.task.slice(0, 80) }],
477
498
  count: 1,
478
499
  cohort: input.cohort,
479
500
  skipped: 0,
@@ -481,6 +502,8 @@ export function createAgentTool(config) {
481
502
  collapsedTaskCount: input.tasks.length,
482
503
  reason: batchPolicy.reason,
483
504
  roleTaskIndexes: batchPolicy.roleTaskIndexes ?? [],
505
+ scopeMutation: batchPolicy.scopeMutation ?? null,
506
+ ...agentOrchestrationControl(record),
484
507
  }),
485
508
  };
486
509
  }
@@ -525,7 +548,7 @@ export function createAgentTool(config) {
525
548
  error: summarizeError(error),
526
549
  };
527
550
  }
528
- results.push({ ...agentSummary(record), task: taskDef.task.slice(0, 80) });
551
+ results.push({ ...agentSpawnSummary(record), task: taskDef.task.slice(0, 80) });
529
552
  }
530
553
  return {
531
554
  success: true,
@@ -1 +1 @@
1
- {"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../../src/platform/tools/agent/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAcrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAE1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAGhE,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9C,CAAC;AAEF,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,eAAe,CAAC,EAAE,IAAI,CAAC,eAAe,EAAE,eAAe,CAAC,GAAG,SAAS,CAAC;IAC9E,QAAQ,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,eAAe,EAAE,eAAe,CAAC,GAAG,SAAS,C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,IAAI,IAAI,WAAW,EAAE;IAIrB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,EAAE;IAI3C,KAAK,IAAI,IAAI;IAKb,WAAW,IAAI,WAAW,EAAE;IAU5B,WAAW,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,IAAI;IAOzC,WAAW,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,GAAG,IAAI;IAIjD,iBAAiB,CAAC,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,aAAa,CAAC,GAAG,IAAI,GAAG,IAAI;CAGpF"}
@@ -7,7 +7,7 @@ import { evaluateOrchestrationSpawn } from '../../runtime/orchestration/spawn-po
7
7
  import { logger } from '../../utils/logger.js';
8
8
  import { summarizeError } from '../../utils/error-display.js';
9
9
  import { splitModelRegistryKey } from '../../providers/registry-helpers.js';
10
- import { isRootReviewRoleTask } from './wrfc-batch-policy.js';
10
+ import { isRootReviewRoleTask, resolveAuthoritativeWrfcScope, resolveImplementationToolContract, resolveNarrowedRootSpawnScope, } from './wrfc-batch-policy.js';
11
11
  export const AGENT_TEMPLATES = {
12
12
  engineer: {
13
13
  description: 'Full-stack implementation agent',
@@ -99,24 +99,80 @@ export class AgentManager {
99
99
  throw new Error('AgentManager requires configManager');
100
100
  }
101
101
  let template = input.template ?? 'general';
102
- if (!input.parentAgentId && isRootReviewRoleTask({ task, template })) {
102
+ let wrfcRouteReason;
103
+ const rootReviewRoleTask = !input.parentAgentId && isRootReviewRoleTask({ task, template });
104
+ if (rootReviewRoleTask) {
105
+ wrfcRouteReason = 'root-review-role-normalized';
106
+ const scope = resolveAuthoritativeWrfcScope(input, task);
107
+ const toolContract = input.authoritativeTask || scope.scopeMutation
108
+ ? resolveImplementationToolContract({
109
+ tools: input.tools,
110
+ restrictTools: input.restrictTools,
111
+ authoritativeTask: scope.task,
112
+ proposedTask: task,
113
+ scopeMutation: scope.scopeMutation,
114
+ })
115
+ : { tools: input.tools, restrictTools: input.restrictTools, scopeMutation: scope.scopeMutation };
103
116
  input = {
104
117
  ...input,
118
+ task: scope.task,
119
+ authoritativeTask: scope.task,
120
+ tools: toolContract.tools,
121
+ restrictTools: toolContract.restrictTools,
105
122
  template: 'engineer',
106
123
  reviewMode: 'wrfc',
107
124
  dangerously_disable_wrfc: false,
108
125
  context: [
109
126
  input.context?.trim(),
110
127
  'SDK WRFC topology enforcement normalized this root review/test/verification task into a single owner chain. Review, test, verification, and fix work are lifecycle phases owned by the WRFC controller, not independent root agents.',
128
+ `Authoritative original ask for this WRFC chain:\n${scope.task}`,
129
+ toolContract.scopeMutation
130
+ ? `Scope mutation warning: ${toolContract.scopeMutation.warnings.join(' ')} Model-proposed child scope:\n${toolContract.scopeMutation.proposedTask}`
131
+ : undefined,
111
132
  ].filter((part) => Boolean(part)).join('\n\n'),
112
133
  successCriteria: [
113
134
  ...(input.successCriteria ?? []),
135
+ `Satisfy the authoritative WRFC ask exactly: ${scope.task}`,
136
+ 'Do not treat model-invented review/test/design/no-write wording as limiting scope unless it appears in the authoritative ask.',
114
137
  'Keep the work as one WRFC owner chain; review, test, verification, and fix phases must remain lifecycle children.',
115
138
  ],
116
139
  };
117
140
  task = input.task ?? task;
118
141
  template = input.template ?? 'engineer';
119
142
  }
143
+ else if (!input.parentAgentId) {
144
+ const scope = resolveNarrowedRootSpawnScope(input, task);
145
+ const toolContract = input.authoritativeTask || scope.scopeMutation
146
+ ? resolveImplementationToolContract({
147
+ tools: input.tools,
148
+ restrictTools: input.restrictTools,
149
+ authoritativeTask: scope.task,
150
+ proposedTask: task,
151
+ scopeMutation: scope.scopeMutation,
152
+ })
153
+ : { tools: input.tools, restrictTools: input.restrictTools, scopeMutation: scope.scopeMutation };
154
+ if (scope.scopeMutation || toolContract.scopeMutation !== scope.scopeMutation) {
155
+ input = {
156
+ ...input,
157
+ task: scope.task,
158
+ tools: toolContract.tools,
159
+ restrictTools: toolContract.restrictTools,
160
+ context: [
161
+ input.context?.trim(),
162
+ toolContract.scopeMutation
163
+ ? `Scope mutation warning: ${toolContract.scopeMutation.warnings.join(' ')} Model-proposed task:\n${toolContract.scopeMutation.proposedTask}`
164
+ : undefined,
165
+ `Authoritative original ask for this agent:\n${scope.task}`,
166
+ ].filter((part) => Boolean(part)).join('\n\n'),
167
+ successCriteria: [
168
+ ...(input.successCriteria ?? []),
169
+ `Satisfy the authoritative original ask exactly: ${scope.task}`,
170
+ 'Do not treat model-invented design-only or no-write wording as limiting scope unless it appears in the authoritative ask.',
171
+ ],
172
+ };
173
+ task = scope.task;
174
+ }
175
+ }
120
176
  const archetype = this.archetypeLoader.loadArchetype(template);
121
177
  const templateDef = AGENT_TEMPLATES[template] ?? AGENT_TEMPLATES.general;
122
178
  const defaultTools = archetype ? archetype.tools : templateDef.defaultTools;
@@ -234,6 +290,7 @@ export class AgentManager {
234
290
  } : {}),
235
291
  ...(input.parentAgentId ? { parentAgentId: input.parentAgentId } : {}),
236
292
  ...(parentNodeId ? { parentNodeId } : {}),
293
+ ...(wrfcRouteReason ? { wrfcRouteReason } : {}),
237
294
  ...(toolResolution.capabilityCeilingTools ? { capabilityCeilingTools: toolResolution.capabilityCeilingTools } : {}),
238
295
  ...(input.successCriteria ? { successCriteria: [...input.successCriteria] } : {}),
239
296
  ...(input.requiredEvidence ? { requiredEvidence: [...input.requiredEvidence] } : {}),
@@ -14,6 +14,7 @@ export interface AgentProviderRoutingPolicy {
14
14
  export interface AgentInput {
15
15
  mode: 'spawn' | 'batch-spawn' | 'status' | 'cancel' | 'list' | 'templates' | 'get' | 'budget' | 'plan' | 'wait' | 'message' | 'wrfc-chains' | 'wrfc-history' | 'cohort-status' | 'cohort-report';
16
16
  task?: string | undefined;
17
+ authoritativeTask?: string | undefined;
17
18
  template?: string | undefined;
18
19
  model?: string | undefined;
19
20
  provider?: string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/platform/tools/agent/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc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G,SAAS,CAAC;IAExH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B"}
@@ -18,7 +18,8 @@ export const AGENT_TOOL_SCHEMA = {
18
18
  'wrfc-history (detailed event history for a specific WRFC chain — reviews, scores, issues, gates), ' +
19
19
  'cohort-status (JSON summary of all agents in a named cohort), ' +
20
20
  'cohort-report (markdown table report for all agents in a named cohort).' +
21
- ' Discovery: use mode=list to see all agents and their status, mode=templates to see available agent templates.',
21
+ ' Discovery: use mode=list to see all agents and their status, mode=templates to see available agent templates. ' +
22
+ 'If the user asks for WRFC, agent review, reviewed implementation, review/fix cycles, or test/verify work for one deliverable, call this tool with mode=spawn, template=engineer, reviewMode=wrfc; do not answer by describing WRFC in prose.',
22
23
  sideEffects: ['agent', 'workflow', 'state'],
23
24
  concurrency: 'serial',
24
25
  supportsProgress: true,
@@ -34,7 +35,11 @@ export const AGENT_TOOL_SCHEMA = {
34
35
  // mode: spawn
35
36
  task: {
36
37
  type: 'string',
37
- description: 'Task description for the agent to execute (mode: spawn).',
38
+ description: 'Task description for the agent to execute (mode: spawn). For a user request that asks for WRFC/review/test/verify of one deliverable, describe the implementation deliverable itself and use reviewMode=wrfc; do not spawn reviewer/tester roots. For batch-spawn collapse, the SDK preserves authoritativeTask/task as the original user ask when present.',
39
+ },
40
+ authoritativeTask: {
41
+ type: 'string',
42
+ description: 'Exact original user request supplied by the host/orchestrator. The SDK uses this as the authoritative WRFC scope when normalizing review/test role fanout; do not invent or narrow it.',
38
43
  },
39
44
  template: {
40
45
  type: 'string',
@@ -119,7 +124,7 @@ export const AGENT_TOOL_SCHEMA = {
119
124
  reviewMode: {
120
125
  type: 'string',
121
126
  enum: ['none', 'wrfc'],
122
- description: 'Review loop requirement for the spawned agent (mode: spawn). Default: wrfc unless explicitly disabled.',
127
+ description: 'Review loop requirement for the spawned agent (mode: spawn). Default: wrfc unless explicitly disabled. Use wrfc for any requested WRFC, review/fix cycle, reviewed implementation, test, or verification flow for a single deliverable.',
123
128
  },
124
129
  communicationLane: {
125
130
  type: 'string',
@@ -5,9 +5,37 @@ export interface WrfcBatchPolicyDecision {
5
5
  readonly reason?: string | undefined;
6
6
  readonly ownerInput?: AgentInput | undefined;
7
7
  readonly roleTaskIndexes?: readonly number[] | undefined;
8
+ readonly scopeMutation?: WrfcScopeMutation | undefined;
9
+ }
10
+ export interface WrfcScopeMutation {
11
+ readonly detected: true;
12
+ readonly action: 'used-authoritative-task' | 'normalized-narrowed-task';
13
+ readonly proposedTask: string;
14
+ readonly authoritativeTask: string;
15
+ readonly warnings: readonly string[];
16
+ }
17
+ export interface WrfcToolContractResolution {
18
+ readonly tools?: string[] | undefined;
19
+ readonly restrictTools?: boolean | undefined;
20
+ readonly scopeMutation?: WrfcScopeMutation | undefined;
8
21
  }
9
22
  export declare function isRootReviewRoleTemplate(template: string | undefined): boolean;
10
23
  export declare function isRootReviewRoleTask(task: Pick<BatchTask, 'task' | 'template'>): boolean;
24
+ export declare function resolveAuthoritativeWrfcScope(input: Pick<AgentInput, 'authoritativeTask' | 'task'>, proposedTask: string): {
25
+ readonly task: string;
26
+ readonly scopeMutation?: WrfcScopeMutation | undefined;
27
+ };
28
+ export declare function resolveNarrowedRootSpawnScope(input: Pick<AgentInput, 'authoritativeTask'>, proposedTask: string): {
29
+ readonly task: string;
30
+ readonly scopeMutation?: WrfcScopeMutation | undefined;
31
+ };
32
+ export declare function resolveImplementationToolContract(args: {
33
+ readonly tools: string[] | undefined;
34
+ readonly restrictTools: boolean | undefined;
35
+ readonly authoritativeTask: string;
36
+ readonly proposedTask: string;
37
+ readonly scopeMutation?: WrfcScopeMutation | undefined;
38
+ }): WrfcToolContractResolution;
11
39
  export declare function evaluateWrfcBatchPolicy(input: AgentInput): WrfcBatchPolicyDecision;
12
40
  export {};
13
41
  //# sourceMappingURL=wrfc-batch-policy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wrfc-batch-policy.d.ts","sourceRoot":"","sources":["../../../../src/platform/tools/agent/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GAAG,SAAS,CAAA;CAAE,CAoBnF;AAED,wBAAgB,iCAAiC,CAAC,IAAI,EAAE;IACtD,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,aAAa,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5C,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,aAAa,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;CACxD,GAAG,0BAA0B,CA2B7B;AAkCD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,UAAU,GAAG,uBAAuB,CAgFlF"}
@@ -10,6 +10,8 @@ const IMPLEMENTATION_TEMPLATES = new Set(['engineer', 'general']);
10
10
  const ROLE_PREFIX_RE = /^\s*(?:\[?\s*)?(?:reviewer|tester|verifier|qa|quality\s+assurance|test|review|verify|validator)\b[\]\s:;-]*/i;
11
11
  const ROLE_ACTION_RE = /\b(?:test|tests|testing|review|reviews|reviewing|verify|verifies|verifying|verification|validate|validates|validating|validation|qa)\s+(?:the|this|that|implementation|solution|feature|deliverable|code|changes|work|output|result|patch|diff)\b/i;
12
12
  const IMPLEMENTATION_ACTION_RE = /\b(?:build|implement|create|add|write|fix|repair|update|refactor|change|modify|deliver|make)\b/i;
13
+ const DESIGN_ONLY_ACTION_RE = /\b(?:design|plan|outline|specify|propose|describe)\b/i;
14
+ const NO_WRITE_RE = /\b(?:do\s+not|don't|without)\s+(?:write|modify|edit|create|change)\s+(?:files?|code|source|implementation)\b|\bno[-\s]?write\b|\bread[-\s]?only\b/i;
13
15
  export function isRootReviewRoleTemplate(template) {
14
16
  return ROOT_REVIEW_ROLE_TEMPLATES.has((template ?? '').trim().toLowerCase());
15
17
  }
@@ -23,6 +25,142 @@ function isImplementationLikeTask(task) {
23
25
  const template = (task.template ?? '').trim().toLowerCase();
24
26
  return IMPLEMENTATION_TEMPLATES.has(template) || IMPLEMENTATION_ACTION_RE.test(task.task);
25
27
  }
28
+ function normalizeTaskText(value) {
29
+ const trimmed = typeof value === 'string' ? value.trim() : '';
30
+ return trimmed.length > 0 ? trimmed : undefined;
31
+ }
32
+ function looksLikeScopeNarrowing(proposedTask, authoritativeTask) {
33
+ if (!NO_WRITE_RE.test(proposedTask) && !DESIGN_ONLY_ACTION_RE.test(proposedTask))
34
+ return false;
35
+ if (authoritativeTask && (NO_WRITE_RE.test(authoritativeTask) || DESIGN_ONLY_ACTION_RE.test(authoritativeTask))) {
36
+ return false;
37
+ }
38
+ return NO_WRITE_RE.test(proposedTask)
39
+ || (DESIGN_ONLY_ACTION_RE.test(proposedTask) && IMPLEMENTATION_ACTION_RE.test(authoritativeTask ?? proposedTask));
40
+ }
41
+ function authoritativeTaskAllowsReadOnly(task) {
42
+ return NO_WRITE_RE.test(task)
43
+ || (DESIGN_ONLY_ACTION_RE.test(task) && !IMPLEMENTATION_ACTION_RE.test(task));
44
+ }
45
+ function removesImplementationCapability(tools) {
46
+ const normalized = new Set((tools ?? []).map((tool) => tool.trim().toLowerCase()).filter(Boolean));
47
+ const hasWriteTool = normalized.has('write') || normalized.has('edit');
48
+ const hasExecutionTool = normalized.has('exec') || normalized.has('precision_exec');
49
+ return !hasWriteTool || !hasExecutionTool;
50
+ }
51
+ function appendScopeMutationWarning(existing, proposedTask, authoritativeTask, warning) {
52
+ if (existing) {
53
+ return {
54
+ ...existing,
55
+ warnings: [...existing.warnings, warning],
56
+ };
57
+ }
58
+ return {
59
+ detected: true,
60
+ action: 'used-authoritative-task',
61
+ proposedTask,
62
+ authoritativeTask,
63
+ warnings: [warning],
64
+ };
65
+ }
66
+ function stripNoWriteSentences(task) {
67
+ const sentences = task
68
+ .split(/(?<=[.!?])\s+/)
69
+ .map((sentence) => sentence.trim())
70
+ .filter((sentence) => sentence.length > 0 && !NO_WRITE_RE.test(sentence));
71
+ return (sentences.length > 0 ? sentences.join(' ') : task.replace(NO_WRITE_RE, '')).trim();
72
+ }
73
+ function normalizeNarrowedTask(proposedTask) {
74
+ let normalized = stripNoWriteSentences(proposedTask);
75
+ normalized = normalized.replace(/^\s*(?:independently\s+)?(?:design|plan|outline|specify|propose|describe)\b/i, 'Implement').trim();
76
+ if (!IMPLEMENTATION_ACTION_RE.test(normalized)) {
77
+ normalized = `Implement ${normalized.replace(/^\s*(?:an?|the)\s+/i, '')}`;
78
+ }
79
+ return normalized.endsWith('.') ? normalized : `${normalized}.`;
80
+ }
81
+ export function resolveAuthoritativeWrfcScope(input, proposedTask) {
82
+ const authoritativeTask = normalizeTaskText(input.authoritativeTask) ?? normalizeTaskText(input.task);
83
+ if (authoritativeTask && authoritativeTask !== proposedTask) {
84
+ return {
85
+ task: authoritativeTask,
86
+ scopeMutation: {
87
+ detected: true,
88
+ action: 'used-authoritative-task',
89
+ proposedTask,
90
+ authoritativeTask,
91
+ warnings: [
92
+ 'WRFC role-fanout collapse preserved the original user ask as the review scope instead of the model-proposed child task.',
93
+ ...(looksLikeScopeNarrowing(proposedTask, authoritativeTask)
94
+ ? ['The proposed child task appeared narrower than the original ask and was not allowed to limit the WRFC scope.']
95
+ : []),
96
+ ],
97
+ },
98
+ };
99
+ }
100
+ if (!authoritativeTask && looksLikeScopeNarrowing(proposedTask, undefined)) {
101
+ const normalized = normalizeNarrowedTask(proposedTask);
102
+ if (normalized !== proposedTask) {
103
+ return {
104
+ task: normalized,
105
+ scopeMutation: {
106
+ detected: true,
107
+ action: 'normalized-narrowed-task',
108
+ proposedTask,
109
+ authoritativeTask: normalized,
110
+ warnings: [
111
+ 'WRFC role-fanout collapse removed design-only/no-write narrowing from the owner scope because no authoritative original ask was supplied.',
112
+ 'Hosts should pass authoritativeTask with the exact user request so the SDK can preserve full WRFC scope without heuristic normalization.',
113
+ ],
114
+ },
115
+ };
116
+ }
117
+ }
118
+ return { task: authoritativeTask ?? proposedTask };
119
+ }
120
+ export function resolveNarrowedRootSpawnScope(input, proposedTask) {
121
+ const authoritativeTask = normalizeTaskText(input.authoritativeTask);
122
+ if (!authoritativeTask || authoritativeTask === proposedTask) {
123
+ return { task: proposedTask };
124
+ }
125
+ if (!looksLikeScopeNarrowing(proposedTask, authoritativeTask)) {
126
+ return { task: proposedTask };
127
+ }
128
+ return {
129
+ task: authoritativeTask,
130
+ scopeMutation: {
131
+ detected: true,
132
+ action: 'used-authoritative-task',
133
+ proposedTask,
134
+ authoritativeTask,
135
+ warnings: [
136
+ 'Root agent spawn preserved the original user ask because the model-proposed task appeared to narrow implementation work into design-only/no-write work.',
137
+ ],
138
+ },
139
+ };
140
+ }
141
+ export function resolveImplementationToolContract(args) {
142
+ const implementationLike = IMPLEMENTATION_ACTION_RE.test(args.authoritativeTask)
143
+ || IMPLEMENTATION_ACTION_RE.test(args.proposedTask);
144
+ if (!args.restrictTools || !implementationLike || authoritativeTaskAllowsReadOnly(args.authoritativeTask)) {
145
+ return {
146
+ tools: args.tools,
147
+ restrictTools: args.restrictTools,
148
+ scopeMutation: args.scopeMutation,
149
+ };
150
+ }
151
+ if (!removesImplementationCapability(args.tools)) {
152
+ return {
153
+ tools: args.tools,
154
+ restrictTools: args.restrictTools,
155
+ scopeMutation: args.scopeMutation,
156
+ };
157
+ }
158
+ return {
159
+ tools: undefined,
160
+ restrictTools: false,
161
+ scopeMutation: appendScopeMutationWarning(args.scopeMutation, args.proposedTask, args.authoritativeTask, 'WRFC scope enforcement ignored restrictive child tool settings that removed write or execution capability from an implementation-like authoritative ask.'),
162
+ };
163
+ }
26
164
  function uniqueStrings(values) {
27
165
  const unique = [...new Set(values.flatMap((value) => value ?? []).filter((value) => value.trim().length > 0))];
28
166
  return unique.length > 0 ? unique : undefined;
@@ -31,14 +169,17 @@ function formatTask(task, index) {
31
169
  const template = task.template ?? 'general';
32
170
  return `${index + 1}. [${template}] ${task.task}`;
33
171
  }
34
- function buildCollapsedContext(input, tasks, roleTaskIndexes) {
172
+ function buildCollapsedContext(input, tasks, roleTaskIndexes, authoritativeTask, scopeMutation) {
35
173
  const roleIndexText = roleTaskIndexes.map((index) => index + 1).join(', ');
36
174
  const existing = input.context?.trim();
37
175
  return [
38
176
  existing ? `Caller context:\n${existing}` : null,
39
177
  'SDK WRFC topology enforcement collapsed this batch because root review/test/verification tasks are lifecycle phases, not independent root agents.',
178
+ `Authoritative original ask for this WRFC chain:\n${authoritativeTask}`,
40
179
  `Collapsed role-task indexes: ${roleIndexText}.`,
41
180
  'The WRFC owner must keep one root chain for the original deliverable. The controller owns engineer, reviewer, tester/verifier, and fixer child lifecycle agents after owner output exists.',
181
+ scopeMutation ? `Scope mutation warning: ${scopeMutation.warnings.join(' ')}` : null,
182
+ scopeMutation ? `Model-proposed child scope that was not allowed to narrow review:\n${scopeMutation.proposedTask}` : null,
42
183
  'Original batch:',
43
184
  ...tasks.map(formatTask),
44
185
  ].filter((line) => Boolean(line)).join('\n');
@@ -60,9 +201,18 @@ export function evaluateWrfcBatchPolicy(input) {
60
201
  ? 'engineer'
61
202
  : ownerTask.template ?? input.template ?? 'engineer';
62
203
  const template = isRootReviewRoleTemplate(ownerTemplate) ? 'engineer' : ownerTemplate;
204
+ const scope = resolveAuthoritativeWrfcScope(input, ownerTask.task);
205
+ const toolContract = resolveImplementationToolContract({
206
+ tools: ownerTask.tools ?? input.tools,
207
+ restrictTools: ownerTask.restrictTools ?? input.restrictTools,
208
+ authoritativeTask: scope.task,
209
+ proposedTask: ownerTask.task,
210
+ scopeMutation: scope.scopeMutation,
211
+ });
63
212
  const ownerInput = {
64
213
  mode: 'spawn',
65
- task: ownerTask.task,
214
+ task: scope.task,
215
+ authoritativeTask: scope.task,
66
216
  template,
67
217
  model: ownerTask.model ?? input.model,
68
218
  provider: ownerTask.provider ?? input.provider,
@@ -70,13 +220,15 @@ export function evaluateWrfcBatchPolicy(input) {
70
220
  routing: ownerTask.routing ?? input.routing,
71
221
  executionIntent: ownerTask.executionIntent ?? input.executionIntent,
72
222
  reasoningEffort: ownerTask.reasoningEffort ?? input.reasoningEffort,
73
- tools: ownerTask.tools ?? input.tools,
74
- restrictTools: ownerTask.restrictTools ?? input.restrictTools,
75
- context: buildCollapsedContext(input, tasks, roleTaskIndexes),
223
+ tools: toolContract.tools,
224
+ restrictTools: toolContract.restrictTools,
225
+ context: buildCollapsedContext(input, tasks, roleTaskIndexes, scope.task, toolContract.scopeMutation),
76
226
  successCriteria: uniqueStrings([
77
227
  ownerTask.successCriteria,
78
228
  input.successCriteria,
79
229
  ...tasks.map((task) => task.successCriteria),
230
+ [`Satisfy the authoritative WRFC ask exactly: ${scope.task}`],
231
+ ['Do not treat model-invented design-only or no-write wording from collapsed child tasks as limiting scope unless it appears in the authoritative ask.'],
80
232
  ['Keep the WRFC work as one owner chain; review, test, verification, and fix work must be WRFC lifecycle children, not sibling root agents.'],
81
233
  ]),
82
234
  requiredEvidence: uniqueStrings([
@@ -104,5 +256,6 @@ export function evaluateWrfcBatchPolicy(input) {
104
256
  reason: 'batch-spawn contained root review/test/verification role tasks for the same deliverable',
105
257
  ownerInput,
106
258
  roleTaskIndexes,
259
+ scopeMutation: toolContract.scopeMutation,
107
260
  };
108
261
  }
@@ -1,6 +1,6 @@
1
1
  import { readFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
- let version = '0.33.21';
3
+ let version = '0.33.23';
4
4
  try {
5
5
  const pkg = JSON.parse(readFileSync(join(import.meta.dir, '..', '..', 'package.json'), 'utf-8'));
6
6
  version = pkg.version ?? version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pellux/goodvibes-sdk",
3
- "version": "0.33.21",
3
+ "version": "0.33.23",
4
4
  "description": "TypeScript SDK for building GoodVibes operator, peer, web, mobile, and daemon-connected apps with typed contracts, auth, realtime events, and transport layers.",
5
5
  "keywords": [
6
6
  "goodvibes",
@@ -449,14 +449,14 @@
449
449
  "sideEffects": false,
450
450
  "type": "module",
451
451
  "dependencies": {
452
- "@pellux/goodvibes-contracts": "0.33.21",
453
- "@pellux/goodvibes-daemon-sdk": "0.33.21",
454
- "@pellux/goodvibes-errors": "0.33.21",
455
- "@pellux/goodvibes-operator-sdk": "0.33.21",
456
- "@pellux/goodvibes-peer-sdk": "0.33.21",
457
- "@pellux/goodvibes-transport-core": "0.33.21",
458
- "@pellux/goodvibes-transport-http": "0.33.21",
459
- "@pellux/goodvibes-transport-realtime": "0.33.21"
452
+ "@pellux/goodvibes-contracts": "0.33.23",
453
+ "@pellux/goodvibes-daemon-sdk": "0.33.23",
454
+ "@pellux/goodvibes-errors": "0.33.23",
455
+ "@pellux/goodvibes-operator-sdk": "0.33.23",
456
+ "@pellux/goodvibes-peer-sdk": "0.33.23",
457
+ "@pellux/goodvibes-transport-core": "0.33.23",
458
+ "@pellux/goodvibes-transport-http": "0.33.23",
459
+ "@pellux/goodvibes-transport-realtime": "0.33.23"
460
460
  },
461
461
  "optionalDependencies": {
462
462
  "@agentclientprotocol/sdk": "^0.21.0",