agentxchain 2.155.19 → 2.155.21
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/package.json +1 -1
- package/src/commands/step.js +29 -0
- package/src/lib/governed-state.js +31 -0
- package/src/lib/intake.js +1 -0
package/package.json
CHANGED
package/src/commands/step.js
CHANGED
|
@@ -100,6 +100,35 @@ export async function stepCommand(opts) {
|
|
|
100
100
|
process.exit(1);
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
if (opts.resume && !opts.turn) {
|
|
104
|
+
const activeTurnsBeforeStaleCheck = getActiveTurns(state);
|
|
105
|
+
const activeTurnListBeforeStaleCheck = Object.values(activeTurnsBeforeStaleCheck);
|
|
106
|
+
const retainedTurn = activeTurnListBeforeStaleCheck.length === 1 ? activeTurnListBeforeStaleCheck[0] : null;
|
|
107
|
+
const materializationResolution = resolveGovernedRole({ state, config });
|
|
108
|
+
if (
|
|
109
|
+
retainedTurn
|
|
110
|
+
&& state.status === 'active'
|
|
111
|
+
&& state.charter_materialization_pending
|
|
112
|
+
&& state.phase === 'planning'
|
|
113
|
+
&& materializationResolution.roleId
|
|
114
|
+
&& materializationResolution.roleId !== retainedTurn.assigned_role
|
|
115
|
+
) {
|
|
116
|
+
const reason = `charter materialization pending superseded stale active ${retainedTurn.assigned_role} turn`;
|
|
117
|
+
const reissued = reissueTurn(root, config, {
|
|
118
|
+
turnId: retainedTurn.turn_id,
|
|
119
|
+
roleId: materializationResolution.roleId,
|
|
120
|
+
reason,
|
|
121
|
+
});
|
|
122
|
+
if (!reissued.ok) {
|
|
123
|
+
console.log(chalk.red(`Failed to reissue active turn for materialization: ${reissued.error}`));
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
state = reissued.state;
|
|
127
|
+
console.log(chalk.yellow(`Reissued active turn for charter materialization: ${reissued.newTurn.turn_id}`));
|
|
128
|
+
console.log(` Role: ${reissued.newTurn.assigned_role}`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
103
132
|
const staleReconciliation = reconcileStaleTurns(root, state, config);
|
|
104
133
|
state = staleReconciliation.state || state;
|
|
105
134
|
if (staleReconciliation.ghost_turns.length > 0) {
|
|
@@ -3312,8 +3312,39 @@ export function initializeGovernedRun(root, config, options = {}) {
|
|
|
3312
3312
|
}
|
|
3313
3313
|
}
|
|
3314
3314
|
|
|
3315
|
+
// BUG-74: When a new run starts from an idle-expansion-derived intent,
|
|
3316
|
+
// set charter_materialization_pending so the first PM turn receives the
|
|
3317
|
+
// "You MUST create or update these planning artifacts" directive.
|
|
3318
|
+
const intakeCtx = options.intakeContext;
|
|
3319
|
+
if (intakeCtx?.category === 'pm_idle_expansion_derived') {
|
|
3320
|
+
updatedState.charter_materialization_pending = {
|
|
3321
|
+
charter: intakeCtx.charter || null,
|
|
3322
|
+
acceptance_contract: Array.isArray(intakeCtx.acceptance_contract)
|
|
3323
|
+
? intakeCtx.acceptance_contract
|
|
3324
|
+
: [],
|
|
3325
|
+
suppressed_transition: 'implementation',
|
|
3326
|
+
source_turn_id: null,
|
|
3327
|
+
recorded_at: new Date().toISOString(),
|
|
3328
|
+
};
|
|
3329
|
+
}
|
|
3330
|
+
|
|
3315
3331
|
writeState(root, updatedState);
|
|
3316
3332
|
|
|
3333
|
+
// BUG-74: emit event so consumers know materialization is required from run start
|
|
3334
|
+
if (updatedState.charter_materialization_pending) {
|
|
3335
|
+
emitRunEvent(root, 'charter_materialization_required', {
|
|
3336
|
+
run_id: runId,
|
|
3337
|
+
phase: updatedState.phase,
|
|
3338
|
+
status: 'active',
|
|
3339
|
+
payload: {
|
|
3340
|
+
suppressed_transition: 'implementation',
|
|
3341
|
+
reason: 'New run from idle-expansion-derived intent must materialize charter into planning artifacts.',
|
|
3342
|
+
new_intake_charter: updatedState.charter_materialization_pending.charter,
|
|
3343
|
+
source: 'run_initialization',
|
|
3344
|
+
},
|
|
3345
|
+
});
|
|
3346
|
+
}
|
|
3347
|
+
|
|
3317
3348
|
const startupIntents = archiveStaleIntentsForRun(root, runId, {
|
|
3318
3349
|
protocolVersion: updatedState.protocol_version || '2.x',
|
|
3319
3350
|
});
|
package/src/lib/intake.js
CHANGED
|
@@ -1139,6 +1139,7 @@ export function startIntent(root, intentId, options = {}) {
|
|
|
1139
1139
|
const initResult = initializeGovernedRun(root, config, {
|
|
1140
1140
|
provenance: startProvenance,
|
|
1141
1141
|
allow_terminal_restart: allowCompletedRestart,
|
|
1142
|
+
intakeContext,
|
|
1142
1143
|
});
|
|
1143
1144
|
if (!initResult.ok) {
|
|
1144
1145
|
return { ok: false, error: `run initialization failed: ${initResult.error}`, exitCode: 1 };
|