@aragon-agent/cli 0.6.64 → 0.6.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/CHANGELOG.md +79 -0
- package/README.md +79 -4
- package/dist/agent/controller.d.ts +75 -0
- package/dist/agent/controller.js +128 -1
- package/dist/agent/governance-wiring.js +2 -0
- package/dist/agent/headless.js +24 -3
- package/dist/agent/reconnect-memory.d.ts +68 -0
- package/dist/agent/reconnect-memory.js +82 -0
- package/dist/app/App.js +116 -3
- package/dist/app/use-governance-rounds.d.ts +44 -0
- package/dist/app/use-governance-rounds.js +71 -0
- package/dist/commands/builtins.js +8 -72
- package/dist/commands/catalog.js +1 -1
- package/dist/commands/governance-command.js +45 -3
- package/dist/commands/retry-command.d.ts +52 -0
- package/dist/commands/retry-command.js +225 -0
- package/dist/config/cli-commands.d.ts +2 -2
- package/dist/config/cli-commands.js +54 -0
- package/dist/exec/events.d.ts +12 -0
- package/dist/exec/runner.js +6 -0
- package/dist/gene/cli-commands.js +30 -1
- package/dist/gene/command-report.js +5 -1
- package/dist/gene/curator/budget.d.ts +24 -1
- package/dist/gene/curator/budget.js +67 -14
- package/dist/gene/curator/curator.d.ts +10 -0
- package/dist/gene/curator/curator.js +35 -5
- package/dist/gene/curator/task-context.d.ts +8 -0
- package/dist/gene/curator/task-context.js +10 -0
- package/dist/gene/curator/task-runner.js +16 -5
- package/dist/gene/hub.d.ts +10 -1
- package/dist/gene/hub.js +30 -7
- package/dist/gene/import-plan.js +8 -5
- package/dist/gene/learn/learner.js +7 -3
- package/dist/gene/queue.d.ts +8 -0
- package/dist/gene/queue.js +38 -2
- package/dist/governance/copy.d.ts +8 -0
- package/dist/governance/copy.js +16 -1
- package/dist/governance/engine/cards.js +9 -1
- package/dist/governance/engine/digest.js +6 -2
- package/dist/governance/engine/engine-core.d.ts +12 -0
- package/dist/governance/engine/engine-core.js +29 -0
- package/dist/governance/engine/engine.d.ts +1 -0
- package/dist/governance/engine/engine.js +4 -1
- package/dist/governance/engine/lifecycle.d.ts +36 -1
- package/dist/governance/engine/lifecycle.js +185 -2
- package/dist/governance/engine/report.d.ts +8 -0
- package/dist/governance/engine/report.js +17 -0
- package/dist/governance/engine/stage-runner.js +48 -3
- package/dist/governance/engine/state-machine.d.ts +27 -2
- package/dist/governance/engine/state-machine.js +146 -20
- package/dist/governance/prompts/orchestrator-block.d.ts +2 -0
- package/dist/governance/prompts/orchestrator-block.js +25 -0
- package/dist/governance/store/events-log.d.ts +4 -2
- package/dist/governance/store/events-log.js +4 -2
- package/dist/governance/tools/inspector-tools.js +4 -0
- package/dist/governance/tools/lead-tools.d.ts +1 -1
- package/dist/governance/tools/lead-tools.js +14 -2
- package/dist/host/controller-factory.js +6 -0
- package/dist/logging/install.d.ts +3 -0
- package/dist/logging/install.js +8 -0
- package/dist/session/persist.js +8 -1
- package/dist/session/validate-session.js +15 -5
- package/package.json +3 -3
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import { TEAM_LIMITS } from '@aragon-agent/tui/model/team/limits';
|
|
19
19
|
import { GOV_LIMITS } from '@aragon-agent/tui/model/governance/limits';
|
|
20
|
+
import { ensureRunRounds, grantRound, roundGrantRefusal, wouldStartRound, } from '@aragon-agent/tui/model/governance/rounds';
|
|
20
21
|
import { STAGE_KINDS, } from '@aragon-agent/tui/model/governance/types';
|
|
21
22
|
export const NOT_ACCEPTED = 'NOT ACCEPTED:';
|
|
22
23
|
// ---------------------------------------------------------------------------
|
|
@@ -250,15 +251,27 @@ export function formatNext(actions) {
|
|
|
250
251
|
return 'NEXT: (none)';
|
|
251
252
|
return `NEXT:\n${actions.map((action) => `- ${action}`).join('\n')}`;
|
|
252
253
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
254
|
+
/**
|
|
255
|
+
* Which dispositions a kind accepts. A FUNCTION, not a table, because `rounds_exhausted`
|
|
256
|
+
* carries two shapes: with a `wpId` it is a rework question, without one it is an
|
|
257
|
+
* integration question. The three older kinds return exactly what the old table returned.
|
|
258
|
+
*/
|
|
259
|
+
export function dispositionsFor(escalation) {
|
|
260
|
+
switch (escalation.kind) {
|
|
261
|
+
case 'wp_rework_cap':
|
|
262
|
+
return ['retry', 'accept_as_is', 'drop'];
|
|
263
|
+
case 'integration_exhausted':
|
|
264
|
+
return ['retry', 'accept_failing'];
|
|
265
|
+
case 'rounds_exhausted':
|
|
266
|
+
return escalation.wpId ? ['retry', 'accept_as_is', 'drop'] : ['retry', 'accept_failing'];
|
|
267
|
+
case 'dispute':
|
|
268
|
+
return [];
|
|
269
|
+
}
|
|
270
|
+
}
|
|
258
271
|
function escalationActions(escalations) {
|
|
259
272
|
const actions = [];
|
|
260
273
|
for (const esc of escalations.filter((e) => e.status === 'open')) {
|
|
261
|
-
const allowed =
|
|
274
|
+
const allowed = dispositionsFor(esc);
|
|
262
275
|
const disposition = allowed.length > 0 ? `,"disposition":"${allowed.join('|')}"` : '';
|
|
263
276
|
actions.push(`ask_user: put ${esc.id} (${esc.kind}) to the user: ${esc.topic}`);
|
|
264
277
|
const ruling = '"ruling":"<user ruling>"';
|
|
@@ -266,13 +279,17 @@ function escalationActions(escalations) {
|
|
|
266
279
|
}
|
|
267
280
|
return actions;
|
|
268
281
|
}
|
|
269
|
-
function stageCalls(run, stage,
|
|
282
|
+
function stageCalls(run, stage, options) {
|
|
270
283
|
const evaluation = evaluateStage(run, stage, undefined);
|
|
271
284
|
if (!evaluation.ok)
|
|
272
285
|
return [];
|
|
286
|
+
// The SAME gate `checkStage` applies, so `NEXT` never lists a dispatch that would be
|
|
287
|
+
// refused for the round budget (RV-P1-1).
|
|
288
|
+
if (roundsGate(run, stage, evaluation.wpIds, options) !== null)
|
|
289
|
+
return [];
|
|
273
290
|
if (stage === 'settle' || stage === 'integrate' || stage === 'fix')
|
|
274
291
|
return [dispatchCall(stage)];
|
|
275
|
-
const groups = chunk(evaluation.wpIds, stageChunkSize(stage,
|
|
292
|
+
const groups = chunk(evaluation.wpIds, stageChunkSize(stage, ceilingOf(options)));
|
|
276
293
|
return groups.map((ids) => dispatchCall(stage, ids));
|
|
277
294
|
}
|
|
278
295
|
function dropHints(run) {
|
|
@@ -288,10 +305,10 @@ function dropHints(run) {
|
|
|
288
305
|
'gov_run {"action":"abandon","reason":"..."} and restart with a revised plan',
|
|
289
306
|
];
|
|
290
307
|
}
|
|
291
|
-
function executingActions(run,
|
|
308
|
+
function executingActions(run, options) {
|
|
292
309
|
if (canClose(run))
|
|
293
310
|
return ['gov_run {"action":"close","summary":"<what was delivered>"}'];
|
|
294
|
-
const calls = STAGE_KINDS.flatMap((stage) => stageCalls(run, stage,
|
|
311
|
+
const calls = STAGE_KINDS.flatMap((stage) => stageCalls(run, stage, options));
|
|
295
312
|
const phase = currentPhase(run);
|
|
296
313
|
if (calls.length === 0 && phase && isIntegrationExhausted(run, phase)) {
|
|
297
314
|
return [
|
|
@@ -300,16 +317,31 @@ function executingActions(run, ceiling) {
|
|
|
300
317
|
];
|
|
301
318
|
}
|
|
302
319
|
const hints = dropHints(run);
|
|
303
|
-
if (calls.length === 0 && hints.length === 0)
|
|
320
|
+
if (calls.length === 0 && hints.length === 0) {
|
|
321
|
+
// No legal call is left. Say WHICH cap closed the door: with the round budget spent the
|
|
322
|
+
// next loop-back escalates instead of running, and (in auto mode) the orchestrator may
|
|
323
|
+
// ask for one more round with a reason - which is the one thing a `gov_run status` here
|
|
324
|
+
// must not hide.
|
|
325
|
+
const rounds = roundsHint(run, options);
|
|
326
|
+
if (rounds !== null)
|
|
327
|
+
return [rounds];
|
|
304
328
|
return ['gov_run {"action":"status"}'];
|
|
329
|
+
}
|
|
305
330
|
return [...calls, ...hints];
|
|
306
331
|
}
|
|
332
|
+
/** The "the round budget is spent" hint, or null when that is not what is blocking. */
|
|
333
|
+
function roundsHint(run, options) {
|
|
334
|
+
const spent = roundsSpent(run, options);
|
|
335
|
+
if (spent === null)
|
|
336
|
+
return null;
|
|
337
|
+
return ('the round budget is spent; the next loop-back round escalates ' +
|
|
338
|
+
'(auto mode: gov_run {"action":"rounds","reason":"..."})');
|
|
339
|
+
}
|
|
307
340
|
/**
|
|
308
341
|
* Ordered legal next calls for the run's current state. Pure. Stage width beyond
|
|
309
342
|
* `teamCeiling` is split into chunk calls (D-24), each independently legal.
|
|
310
343
|
*/
|
|
311
344
|
export function nextActions(run, options) {
|
|
312
|
-
const ceiling = ceilingOf(options);
|
|
313
345
|
switch (run.status) {
|
|
314
346
|
case 'closed':
|
|
315
347
|
case 'abandoned':
|
|
@@ -321,16 +353,50 @@ export function nextActions(run, options) {
|
|
|
321
353
|
case 'executing':
|
|
322
354
|
return run.stage?.status === 'running'
|
|
323
355
|
? ['a stage is running; wait for it to finish, then gov_run {"action":"status"}']
|
|
324
|
-
: executingActions(run,
|
|
356
|
+
: executingActions(run, options);
|
|
325
357
|
}
|
|
326
358
|
}
|
|
327
359
|
// ---------------------------------------------------------------------------
|
|
328
360
|
// checkStage
|
|
329
361
|
// ---------------------------------------------------------------------------
|
|
330
|
-
|
|
362
|
+
/**
|
|
363
|
+
* THE round-budget decision, and the ONLY one (governance-round-budget RV-P1-1).
|
|
364
|
+
*
|
|
365
|
+
* `checkStage` and `stageCalls` both call it, because `stageCalls` builds `NEXT` straight
|
|
366
|
+
* from `evaluateStage` and never passes through `checkStage`: gating only the former would
|
|
367
|
+
* print a `gov_dispatch` in `NEXT` that the very next call refuses, which teaches the
|
|
368
|
+
* orchestrator that `NEXT` lies. Returns the refusal sentence, or null to let the stage run.
|
|
369
|
+
*/
|
|
370
|
+
export function roundsGate(run, stage, wpIds, options) {
|
|
371
|
+
if (!wouldStartRound(run, stage, wpIds))
|
|
372
|
+
return null;
|
|
373
|
+
const spent = roundsSpent(run, options);
|
|
374
|
+
if (spent === null)
|
|
375
|
+
return null;
|
|
376
|
+
return (`the round budget is spent (${spent.used}/${spent.limit}): ` +
|
|
377
|
+
'this stage would start a loop-back round.');
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* `used` and `limit` when the budget is SPENT, else null - and the ONE place that comparison
|
|
381
|
+
* is made. `roundsGate` asks it before refusing a stage and `roundsHint` asks it before
|
|
382
|
+
* choosing the `NEXT` line, so the two can never disagree about whether the cap has been hit
|
|
383
|
+
* (the reason `roundsLimit` shows up twice in this file is that both callers pass it in).
|
|
384
|
+
*/
|
|
385
|
+
function roundsSpent(run, options) {
|
|
386
|
+
const limit = options?.roundsLimit;
|
|
387
|
+
if (limit === undefined)
|
|
388
|
+
return null;
|
|
389
|
+
const rounds = ensureRunRounds(run);
|
|
390
|
+
return rounds.used < limit ? null : { used: rounds.used, limit };
|
|
391
|
+
}
|
|
392
|
+
function refuse(run, reason, options, head, code) {
|
|
331
393
|
const first = head ?? reason;
|
|
332
394
|
const next = formatNext(nextActions(run, options));
|
|
333
|
-
return {
|
|
395
|
+
return {
|
|
396
|
+
ok: false,
|
|
397
|
+
message: `${NOT_ACCEPTED} ${first}\n${next}`,
|
|
398
|
+
...(code === undefined ? {} : { code }),
|
|
399
|
+
};
|
|
334
400
|
}
|
|
335
401
|
function runLevelRefusal(run) {
|
|
336
402
|
switch (run.status) {
|
|
@@ -379,6 +445,11 @@ export function checkStage(run, stage, wps, options) {
|
|
|
379
445
|
`dispatch at most ${size} WPs per call.\n${formatNext(calls)}`,
|
|
380
446
|
};
|
|
381
447
|
}
|
|
448
|
+
// LAST, after legality and width: a stage that is illegal or too wide is refused for that
|
|
449
|
+
// reason first, and only a stage that COULD run is charged against the round budget.
|
|
450
|
+
const spent = roundsGate(run, stage, evaluation.wpIds, options);
|
|
451
|
+
if (spent !== null)
|
|
452
|
+
return refuse(run, spent, options, undefined, 'rounds_exhausted');
|
|
382
453
|
return { ok: true, phase: evaluation.phase.index, wpIds: evaluation.wpIds };
|
|
383
454
|
}
|
|
384
455
|
/** Stages that are legal right now (ignores `teamCeiling`; chunking is not legality). */
|
|
@@ -558,12 +629,62 @@ function applyIntegrationDisposition(run, escalation, disposition) {
|
|
|
558
629
|
affectedDependents: [],
|
|
559
630
|
};
|
|
560
631
|
}
|
|
632
|
+
/**
|
|
633
|
+
* The `rounds_exhausted` ruling. `retry` grants ONE more round - and it succeeds for a
|
|
634
|
+
* FIXED budget too, because the number on a fixed budget is the USER's, and the user is the
|
|
635
|
+
* one ruling here (RV-P0-1). The rework/fix counters are deliberately untouched: those are
|
|
636
|
+
* the per-WP and per-phase gates, and a round grant must not silently raise them as well.
|
|
637
|
+
*/
|
|
638
|
+
function applyRoundsDisposition(run, escalation, disposition, budget) {
|
|
639
|
+
if (disposition === 'accept_as_is') {
|
|
640
|
+
const wp = escalation.wpId ? run.workPackages[escalation.wpId] : undefined;
|
|
641
|
+
return wp
|
|
642
|
+
? acceptAsIs(wp)
|
|
643
|
+
: resolveFailure(`escalation ${escalation.id} names no work package.`);
|
|
644
|
+
}
|
|
645
|
+
if (disposition === 'drop') {
|
|
646
|
+
const wp = escalation.wpId ? run.workPackages[escalation.wpId] : undefined;
|
|
647
|
+
return wp
|
|
648
|
+
? dropWorkPackage(run, wp)
|
|
649
|
+
: resolveFailure(`escalation ${escalation.id} names no work package.`);
|
|
650
|
+
}
|
|
651
|
+
if (disposition === 'accept_failing') {
|
|
652
|
+
return applyIntegrationDisposition(run, escalation, 'accept_failing');
|
|
653
|
+
}
|
|
654
|
+
return grantRoundForEscalation(run, escalation, budget);
|
|
655
|
+
}
|
|
656
|
+
function grantRoundForEscalation(run, escalation, budget) {
|
|
657
|
+
const rounds = ensureRunRounds(run);
|
|
658
|
+
const granted = grantRound(rounds, 'user', budget);
|
|
659
|
+
if (!granted.ok)
|
|
660
|
+
return resolveFailure(roundGrantRefusal(granted.reason, rounds, budget));
|
|
661
|
+
run.rounds = granted.rounds;
|
|
662
|
+
if (escalation.wpId)
|
|
663
|
+
unblockRework(run, escalation.wpId);
|
|
664
|
+
const where = escalation.wpId ? ` '${escalation.wpId}' is back in rework.` : '';
|
|
665
|
+
return {
|
|
666
|
+
ok: true,
|
|
667
|
+
message: `one more round granted (limit now ${granted.limit}).${where}`,
|
|
668
|
+
affectedDependents: [],
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
/** Put a WP back into `rework` without touching `reworkGrants` (that is `grantRework`'s job). */
|
|
672
|
+
function unblockRework(run, wpId) {
|
|
673
|
+
const wp = run.workPackages[wpId];
|
|
674
|
+
if (wp === undefined)
|
|
675
|
+
return;
|
|
676
|
+
wp.status = 'rework';
|
|
677
|
+
delete wp.blockedAt;
|
|
678
|
+
}
|
|
561
679
|
/**
|
|
562
680
|
* Apply the user's `disposition` for an escalation (spec 7.2 table). Mismatched or
|
|
563
681
|
* over-cap dispositions are refused with a reason; no disposition changes nothing.
|
|
564
682
|
* Mutates `run`; does NOT mark the escalation resolved (`closeEscalation` does).
|
|
683
|
+
*
|
|
684
|
+
* `budget` is the LIVE `governance.rounds` value (`core.config().rounds`): a round grant
|
|
685
|
+
* must judge against the number in force right now, not against one frozen at run start.
|
|
565
686
|
*/
|
|
566
|
-
export function applyResolveDisposition(run, escalation, disposition) {
|
|
687
|
+
export function applyResolveDisposition(run, escalation, disposition, budget = null) {
|
|
567
688
|
if (escalation.status === 'resolved') {
|
|
568
689
|
return resolveFailure(`escalation ${escalation.id} is already resolved.`);
|
|
569
690
|
}
|
|
@@ -574,13 +695,18 @@ export function applyResolveDisposition(run, escalation, disposition) {
|
|
|
574
695
|
affectedDependents: [],
|
|
575
696
|
};
|
|
576
697
|
}
|
|
577
|
-
const allowed =
|
|
698
|
+
const allowed = dispositionsFor(escalation);
|
|
578
699
|
if (!allowed.includes(disposition)) {
|
|
579
700
|
const list = allowed.length > 0 ? allowed.join(', ') : 'none';
|
|
580
701
|
return resolveFailure(`disposition '${disposition}' does not apply to a ${escalation.kind} escalation ` +
|
|
581
702
|
`(allowed: ${list}).`);
|
|
582
703
|
}
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
704
|
+
switch (escalation.kind) {
|
|
705
|
+
case 'wp_rework_cap':
|
|
706
|
+
return applyReworkDisposition(run, escalation, disposition);
|
|
707
|
+
case 'rounds_exhausted':
|
|
708
|
+
return applyRoundsDisposition(run, escalation, disposition, budget);
|
|
709
|
+
default:
|
|
710
|
+
return applyIntegrationDisposition(run, escalation, disposition);
|
|
711
|
+
}
|
|
586
712
|
}
|
|
@@ -26,6 +26,8 @@ export interface OrchestratorLimits {
|
|
|
26
26
|
maxFixCycles: number;
|
|
27
27
|
/** Team token budget; 0 or absent means unlimited. */
|
|
28
28
|
budgetTokens?: number;
|
|
29
|
+
/** Round budget: `null` = auto (the engine derives it and may extend on request). */
|
|
30
|
+
rounds?: number | null;
|
|
29
31
|
}
|
|
30
32
|
export interface OrchestratorBlockOptions {
|
|
31
33
|
posture: Posture;
|
|
@@ -48,6 +48,31 @@ function limitsLines(limits) {
|
|
|
48
48
|
`reworked ${rework} times and a phase gets ${fixes} integration fix cycles before the engine`,
|
|
49
49
|
`escalates to the user; at most ${GOV_LIMITS.hardMaxDispatches} gov_dispatch calls per run.`,
|
|
50
50
|
budgetText,
|
|
51
|
+
...roundsLines(limits.rounds),
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* How the round budget is worded for the model. A clean pass costs nothing - only a rework
|
|
56
|
+
* loop or a fix stage does - so the paragraph names the counting rule, what happens at the
|
|
57
|
+
* cap, and the two ways out. In fixed mode the ONLY way out is the user: the model must not
|
|
58
|
+
* promise itself a round the user did not grant.
|
|
59
|
+
*/
|
|
60
|
+
function roundsLines(rounds) {
|
|
61
|
+
const head = 'Round budget: a round is one loop-back dispatch (a dev stage that reworks a work ' +
|
|
62
|
+
'package, or a fix stage); a clean run costs none.';
|
|
63
|
+
if (rounds === null || rounds === undefined) {
|
|
64
|
+
return [
|
|
65
|
+
`${head} It is AUTO here: the engine derives it from the plan and you may ask for more`,
|
|
66
|
+
'with gov_run {action:"rounds",reason:"..."} (a real reason, at most ' +
|
|
67
|
+
`${GOV_LIMITS.autoRoundExtensionsPerRun} times per run).`,
|
|
68
|
+
'When it runs out the engine escalates to the user instead of retrying.',
|
|
69
|
+
];
|
|
70
|
+
}
|
|
71
|
+
const fixed = clampInt(rounds, 0, GOV_LIMITS.hardMaxRounds);
|
|
72
|
+
return [
|
|
73
|
+
`${head} It is FIXED at ${fixed} by the user: do not ask for more - only the user can`,
|
|
74
|
+
'raise it (they may rule "retry" on the escalation card, or use /gov rounds <n>).',
|
|
75
|
+
'When it runs out the engine escalates to the user instead of retrying.',
|
|
51
76
|
];
|
|
52
77
|
}
|
|
53
78
|
function powersSection() {
|
|
@@ -14,8 +14,10 @@
|
|
|
14
14
|
* `ruling` and `resolution` rows, each of which changes the replayed ledger or run state,
|
|
15
15
|
* so a literal reading would make a compacted log replay to a DIFFERENT ledger than its
|
|
16
16
|
* checkpoint (breaks I-G2). The kept set therefore includes every type that replay folds;
|
|
17
|
-
* what is dropped are the audit-only rows: `view_*`, `ownership_violation`, `budget
|
|
18
|
-
* `submission` (the submission itself lives in the artifact store).
|
|
17
|
+
* what is dropped are the audit-only rows: `view_*`, `ownership_violation`, `budget`,
|
|
18
|
+
* `rounds_granted` and `submission` (the submission itself lives in the artifact store).
|
|
19
|
+
* `rounds_granted` is audit by construction: a round is a flow resource, not a ledger
|
|
20
|
+
* claim (governance-round-budget D-10), so replay never folds it.
|
|
19
21
|
*/
|
|
20
22
|
import type { StoredEvent, StoredEventType } from '@aragon-agent/tui/model/governance/types';
|
|
21
23
|
/** Types that survive once `events.jsonl` has passed `GOV_LIMITS.eventsFileBytes`. */
|
|
@@ -14,8 +14,10 @@
|
|
|
14
14
|
* `ruling` and `resolution` rows, each of which changes the replayed ledger or run state,
|
|
15
15
|
* so a literal reading would make a compacted log replay to a DIFFERENT ledger than its
|
|
16
16
|
* checkpoint (breaks I-G2). The kept set therefore includes every type that replay folds;
|
|
17
|
-
* what is dropped are the audit-only rows: `view_*`, `ownership_violation`, `budget
|
|
18
|
-
* `submission` (the submission itself lives in the artifact store).
|
|
17
|
+
* what is dropped are the audit-only rows: `view_*`, `ownership_violation`, `budget`,
|
|
18
|
+
* `rounds_granted` and `submission` (the submission itself lives in the artifact store).
|
|
19
|
+
* `rounds_granted` is audit by construction: a round is a flow resource, not a ledger
|
|
20
|
+
* claim (governance-round-budget D-10), so replay never folds it.
|
|
19
21
|
*/
|
|
20
22
|
/** Types that survive once `events.jsonl` has passed `GOV_LIMITS.eventsFileBytes`. */
|
|
21
23
|
export const EVENTS_KEPT_AFTER_CAP = new Set([
|
|
@@ -39,6 +39,10 @@ const MISS_KINDS = ['review_integration', 'test_defect', 'test_boundary'];
|
|
|
39
39
|
const ESCALATION_KINDS = [
|
|
40
40
|
'wp_rework_cap',
|
|
41
41
|
'integration_exhausted',
|
|
42
|
+
// A handwritten list, so adding a kind to the union does NOT fail to compile - it only
|
|
43
|
+
// makes the inspector refuse a `rounds_exhausted` escalation SILENTLY, which is the
|
|
44
|
+
// worst kind of omission (governance-round-budget RV-P1-3).
|
|
45
|
+
'rounds_exhausted',
|
|
42
46
|
'dispute',
|
|
43
47
|
];
|
|
44
48
|
function argsOf(raw, issues, expected) {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
import { type AgentTool } from '@aragon-agent/core';
|
|
20
20
|
import type { GovernanceEngineApi } from '@aragon-agent/tui/model/governance/types';
|
|
21
21
|
/** The `gov_run` actions, in the order the description lists them. */
|
|
22
|
-
export declare const GOV_RUN_ACTIONS: readonly ["start", "status", "resume", "close", "abandon", "resolve"];
|
|
22
|
+
export declare const GOV_RUN_ACTIONS: readonly ["start", "status", "resume", "close", "abandon", "resolve", "rounds"];
|
|
23
23
|
export type GovRunAction = (typeof GOV_RUN_ACTIONS)[number];
|
|
24
24
|
/** Text returned when the tool call's signal was already aborted at entry. */
|
|
25
25
|
export declare const DISPATCH_ABORTED_AT_ENTRY: string;
|
|
@@ -26,6 +26,7 @@ export const GOV_RUN_ACTIONS = [
|
|
|
26
26
|
'close',
|
|
27
27
|
'abandon',
|
|
28
28
|
'resolve',
|
|
29
|
+
'rounds',
|
|
29
30
|
];
|
|
30
31
|
const GOV_RUN_DESCRIPTION = 'Define and manage the governed run. action: ' +
|
|
31
32
|
'"start" (needs goal, spec, workPackages; optional contracts, integrationCommands, ' +
|
|
@@ -34,7 +35,10 @@ const GOV_RUN_DESCRIPTION = 'Define and manage the governed run. action: ' +
|
|
|
34
35
|
'(optional summary) finishes a fully integrated run; "abandon" (needs reason) gives up the ' +
|
|
35
36
|
'whole run; "resolve" (needs escalationId and ruling, optional favor and disposition) ' +
|
|
36
37
|
'records the user\'s decision on an ESCALATION and can dispose of the escalated object ' +
|
|
37
|
-
'(disposition: retry, accept_as_is, drop or accept_failing, matching the escalation kind)
|
|
38
|
+
'(disposition: retry, accept_as_is, drop or accept_failing, matching the escalation kind); ' +
|
|
39
|
+
'"rounds" prints the round budget (used / limit / grants left), or with a reason of at ' +
|
|
40
|
+
`least ${GOV_LIMITS.roundsReasonMinChars} chars asks for ONE more round - the engine decides ` +
|
|
41
|
+
'whether that is allowed (auto mode only: a budget the user fixed is theirs to raise). ' +
|
|
38
42
|
`Sizes: goal <= ${GOV_LIMITS.goalChars} chars, spec <= ${GOV_LIMITS.specChars} chars; ` +
|
|
39
43
|
`each work package: id <= ${GOV_LIMITS.wpIdChars} chars, title <= ${GOV_LIMITS.wpTitleChars}, ` +
|
|
40
44
|
`goal <= ${GOV_LIMITS.wpGoalChars}, <= ${GOV_LIMITS.wpFilesMax} files (include its test ` +
|
|
@@ -128,6 +132,11 @@ async function runAction(engine, action, params, signal) {
|
|
|
128
132
|
}
|
|
129
133
|
case 'resolve':
|
|
130
134
|
return textResult(await engine.resolve(payload));
|
|
135
|
+
case 'rounds':
|
|
136
|
+
// Read-only without a `reason`; with one, the orchestrator asks for one more round.
|
|
137
|
+
// `reason` is reused (no new field) and NOT length-constrained by the schema: the
|
|
138
|
+
// engine enforces `roundsReasonMinChars`, which is where policy belongs.
|
|
139
|
+
return textResult(await engine.rounds(payload));
|
|
131
140
|
}
|
|
132
141
|
}
|
|
133
142
|
/**
|
|
@@ -157,7 +166,10 @@ export function makeGovRunTool(engine) {
|
|
|
157
166
|
},
|
|
158
167
|
runId: { type: 'string', description: 'resume: a specific run id.' },
|
|
159
168
|
summary: { type: 'string', description: 'close: closing note.' },
|
|
160
|
-
reason: {
|
|
169
|
+
reason: {
|
|
170
|
+
type: 'string',
|
|
171
|
+
description: 'abandon: why. rounds: why one more round is needed.',
|
|
172
|
+
},
|
|
161
173
|
escalationId: { type: 'string', description: 'resolve: the ESC id.' },
|
|
162
174
|
ruling: { type: 'string', description: 'resolve: the user\'s ruling.' },
|
|
163
175
|
favor: { type: 'string', description: 'resolve: whom the ruling favors.' },
|
|
@@ -67,6 +67,12 @@ export function makeController(flags, opts = { interactive: true }) {
|
|
|
67
67
|
const controller = new AgentController(config, {
|
|
68
68
|
version: VERSION,
|
|
69
69
|
todoPanelCapable,
|
|
70
|
+
// THE SAME ANSWER `todoPanelCapable` GIVES, for the same reason (tiered-reconnect
|
|
71
|
+
// §4.4 / D-6): a headless host is headless. `-p`, `aragon exec` and every
|
|
72
|
+
// subcommand build with `interactive: false` and therefore get the BOUNDED
|
|
73
|
+
// ladder (two tiers), while the TUI keeps the full three. Derived here rather
|
|
74
|
+
// than threaded through five call sites, so no host can forget it.
|
|
75
|
+
reconnectMode: opts.interactive ? 'interactive' : 'headless',
|
|
70
76
|
confirm: (req) => confirmBridge.handler ? confirmBridge.handler(req) : Promise.resolve(true),
|
|
71
77
|
// THE TWO CAN NEVER BOTH BE PRESENT: `interactive: false` is the only path
|
|
72
78
|
// that supplies a bridge gate, and the interactive branch is the only one that
|
package/dist/logging/install.js
CHANGED
|
@@ -373,6 +373,14 @@ export function attachAgentEvents(logger, controller) {
|
|
|
373
373
|
// retry line stays small; an HTTP-error body already arrives cut at 300.
|
|
374
374
|
message: typeof se.message === 'string' ? se.message.slice(0, 200) : undefined,
|
|
375
375
|
retryAfterMs: se.retryAfterMs,
|
|
376
|
+
// TIERED RECONNECT (§4.6.7). `attempt` is per-tier, so an operator
|
|
377
|
+
// reading one line cannot tell a 3rd fast retry from a 3rd five-minute
|
|
378
|
+
// hold; these three say which ladder and how long it has been going.
|
|
379
|
+
// Absent when the host does not escalate, so the record shape is
|
|
380
|
+
// unchanged there.
|
|
381
|
+
...(se.tier !== undefined ? { tier: se.tier } : {}),
|
|
382
|
+
...(se.tierCount !== undefined ? { tierCount: se.tierCount } : {}),
|
|
383
|
+
...(se.totalAttempts !== undefined ? { totalAttempts: se.totalAttempts } : {}),
|
|
376
384
|
providerId: cfg.provider,
|
|
377
385
|
modelId: cfg.model,
|
|
378
386
|
});
|
package/dist/session/persist.js
CHANGED
|
@@ -196,8 +196,15 @@ export function normalizeLoadedEntries(entries) {
|
|
|
196
196
|
// would never advance past it and every frame for the rest of the session
|
|
197
197
|
// would re-render the whole tail. `resumeAt` is dropped for the same reason
|
|
198
198
|
// the phase changes: there is no attempt coming.
|
|
199
|
+
//
|
|
200
|
+
// `tierEndsAt` GOES WITH IT (tiered-reconnect P1-2). This is the load-time
|
|
201
|
+
// normalisation, and it is the ONLY one — the reducer's `abortMark` / `runEnd`
|
|
202
|
+
// paths are runtime settlement, not load. A card saved while waiting in tier 3
|
|
203
|
+
// would otherwise revive holding an instant that says "this tier ends at ..."
|
|
204
|
+
// for a ladder that no longer exists, which is exactly the stale fact the
|
|
205
|
+
// phase change was meant to remove.
|
|
199
206
|
if (entry.kind === 'retry' && (entry.phase === 'waiting' || entry.phase === 'retrying')) {
|
|
200
|
-
return { ...entry, phase: 'interrupted', resumeAt: undefined };
|
|
207
|
+
return { ...entry, phase: 'interrupted', resumeAt: undefined, tierEndsAt: undefined };
|
|
201
208
|
}
|
|
202
209
|
// THE FOURTH CLAUSE (fast-model-tier §5.4 / C-5 / AC-28). A review card
|
|
203
210
|
// saved while its call was open resumes claiming to be running while nothing
|
|
@@ -205,6 +205,13 @@ const ENTRY_FIELDS = {
|
|
|
205
205
|
resumeAt: optional(number), startedAt: number, totalRetries: optional(number),
|
|
206
206
|
elapsedMs: optional(number),
|
|
207
207
|
phase: enumeration('waiting', 'retrying', 'recovered', 'exhausted', 'interrupted'),
|
|
208
|
+
// TIERED RECONNECT (tiered-reconnect §4.8). Four OPTIONAL fields, and `number`
|
|
209
|
+
// rather than a 1|2|3 enumeration on purpose: a hand-edited or future tier id
|
|
210
|
+
// is not worth refusing a whole session over, and a bad value simply renders as
|
|
211
|
+
// the tier-1 line. A card saved by an older build lacks all four and loads
|
|
212
|
+
// unchanged.
|
|
213
|
+
tier: optional(number), tierCount: optional(number), totalAttempts: optional(number),
|
|
214
|
+
tierEndsAt: optional(number),
|
|
208
215
|
},
|
|
209
216
|
fast: { reviewIndex: number, model: string,
|
|
210
217
|
status: enumeration('running', 'ok', 'advice', 'empty', 'failed', 'dropped'),
|
|
@@ -220,9 +227,11 @@ const ENTRY_FIELDS = {
|
|
|
220
227
|
tokensBefore: number, tokensAfter: number, summary: optional(string), model: string,
|
|
221
228
|
durationMs: optional(number), startedAt: optional(number), live: boolean,
|
|
222
229
|
tailRelief: optional(shape({ messages: number, charsRemoved: number })),
|
|
223
|
-
// THE v3 OPTIONAL FIELDS (context-compaction-v3 §4.7).
|
|
224
|
-
//
|
|
225
|
-
//
|
|
230
|
+
// THE v3 OPTIONAL FIELDS (context-compaction-v3 §4.7). DECLARED HERE SO THEY
|
|
231
|
+
// ARE CHECKED, not because an undeclared key would be refused: `shape()`
|
|
232
|
+
// iterates the keys it was GIVEN (see above), so an unknown field on disk
|
|
233
|
+
// passes through untouched. Declaring one is what turns a malformed value into
|
|
234
|
+
// a precise error instead of a silent `undefined` at render time.
|
|
226
235
|
prune: optional(shape({ actions: nonnegative, removedChars: nonnegative,
|
|
227
236
|
removedTokens: nonnegative, inspected: nonnegative, kinds: object })),
|
|
228
237
|
budget: optional(shape({ limitTokens: nonnegative, spentTokens: nonnegative,
|
|
@@ -241,8 +250,9 @@ const ENTRY_FIELDS = {
|
|
|
241
250
|
startedAt: number, readyAt: optional(number), endedAt: optional(number), rows: array(string),
|
|
242
251
|
rowsSeen: number, terminal: optional(boolean), killIncomplete: optional(boolean),
|
|
243
252
|
// THE FOUR FIELDS long-task-jobs adds (AC-38), and the reason this validator
|
|
244
|
-
// has to learn them:
|
|
245
|
-
//
|
|
253
|
+
// has to learn them: `shape()` only checks the keys it is given, so an
|
|
254
|
+
// undeclared one is passed through UNVALIDATED — a job card with a malformed
|
|
255
|
+
// `jobKind` would reach the renderer and be trusted there, which is a P0 in
|
|
246
256
|
// R-8's terms.
|
|
247
257
|
//
|
|
248
258
|
// ALL FOUR ARE OPTIONAL HERE, DELIBERATELY, and that is a correction to the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aragon-agent/cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.68",
|
|
4
4
|
"description": "AragonAgent CLI — a Claude-Code / Codex-style interactive terminal UI (TUI) on top of the @aragon-agent/core engine. Installable and runnable via npm / npx.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "AragonAgent contributors",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"prepublishOnly": "npm run build"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@aragon-agent/core": "^0.2.
|
|
62
|
-
"@aragon-agent/tui": "0.0.
|
|
61
|
+
"@aragon-agent/core": "^0.2.80",
|
|
62
|
+
"@aragon-agent/tui": "0.0.21",
|
|
63
63
|
"commander": "^12.1.0",
|
|
64
64
|
"dotenv": "^16.6.1",
|
|
65
65
|
"env-paths": "^3.0.0",
|