pi-better-goal 0.12.1 → 0.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -4
- package/package.json +1 -1
- package/src/goal-state.ts +12 -2
- package/src/index.ts +22 -87
- package/src/permission-hold.ts +13 -26
- package/src/types.ts +4 -5
- package/src/workflow-gates.ts +60 -14
- package/src/workflow.ts +7 -0
package/README.md
CHANGED
|
@@ -19,11 +19,12 @@ Use `pi-better-goal` when a Pi session should keep an explicit objective visible
|
|
|
19
19
|
- A compact goal widget that does not replace Pi's footer.
|
|
20
20
|
- Background activity tracking for subagents and other registered providers.
|
|
21
21
|
- A progress-aware follow-up loop with ten identical no-progress retries and linear backoff (60s through 600s by default), followed by a sticky hold recoverable with `/goal resume` or `alt+g`. Conversation, changed callback results, and background drains do not reopen an exhausted hold. Delays saturate at Node's timer limit, and observed background drains reset non-held progress before callback turns can cancel the wake. Pi's network retry policy remains independent.
|
|
22
|
+
- Permission failure reports remain available to the agent as diagnostic evidence. They do not pause Goal or require a one-turn `/goal resume` release. The agent can retry, wait, or continue other authorized work; tool and sandbox permissions remain enforced independently. Repeated unchanged work still reaches the ordinary no-progress hold. Legacy permission-paused goals resume normally with `/goal resume` or `alt+g`.
|
|
22
23
|
- An observable-progress stall state for active goals.
|
|
23
24
|
|
|
24
25
|
## Optional Harness-Owned Outcome & Todo
|
|
25
26
|
|
|
26
|
-
When `pi-better-harness` is installed, its optional **Outcome & Todo** runtime owns the session's structured outcome and checklist. Goal keeps its own objective, clocks,
|
|
27
|
+
When `pi-better-harness` is installed, its optional **Outcome & Todo** runtime owns the session's structured outcome and checklist. Goal keeps its own objective, clocks, pauses, workflow gates, background wake behavior, and continuation policy; it also sends lifecycle requests to the Harness runtime so a bound outcome starts, pauses, resumes, and completes with the Goal. When the runtime is present, Goal stops adding its own active-objective text to avoid duplicating the Harness-owned outcome, whether Outcome & Todo is enabled or off.
|
|
27
28
|
|
|
28
29
|
`/goal` does not install, enable, or configure Outcome & Todo. Install Harness and enable **Outcome & Todo** in `/harness-settings` if you want that shared outcome and checklist. Without Harness, this package keeps its standalone prompts and behavior unchanged. The stored Goal objective remains the raw original trigger (for example, a bound command invocation) so `/goal resume` can re-enter the work; it is not the authoritative business outcome when Harness owns one.
|
|
29
30
|
|
|
@@ -65,10 +66,12 @@ After every successful context compaction (Pi's `session_compact` event) while a
|
|
|
65
66
|
|
|
66
67
|
### Scheduler-backed workflow gates
|
|
67
68
|
|
|
68
|
-
A coordinator that ships the resolve-issues scheduler (`scripts/next-actions.mjs` in its skill directory, or in a sibling `resolve-issues` skill) keeps its Goal from ending while the run still has work. The extension first runs `node next-actions.mjs --run <run dir> --slots 1 --peek --json` (read-only, 20-second timeout), where the run directory is the folder of the task plan bound through `
|
|
69
|
+
A coordinator that ships the resolve-issues scheduler (`scripts/next-actions.mjs` in its skill directory, or in a sibling `resolve-issues` skill) keeps its Goal from ending while the run still has work. The extension first runs `node next-actions.mjs --run <run dir> --slots 1 --peek --json` (read-only, 20-second timeout), where the run directory is the folder of the task plan bound through `update_todo` with `workflow.path` and `workflow.revision`. For completion and handback only, if the sole due action is `sync`, it reruns with `--sync` to obtain a fresh issue tree. This live check has a four-minute timeout to accommodate the tree fetcher's network attempts and follow-ups. Because `--peek` suppresses scheduler bookkeeping but not issue-tree cache writes, the live check uses a temporary copy of the scheduler's plan, tree, bookkeeping, review, and result inputs; it does not write the bound run. Heartbeat probes never request live synchronization. A failed or incomplete tree fetch that produces `sync` still refuses completion or handback; cached evidence is not treated as live. Output that is not a well-formed due list is a failure, not an empty run: a due entry without an `action` invalidates the whole answer instead of being dropped, so it cannot hide due work.
|
|
69
70
|
|
|
70
|
-
-
|
|
71
|
-
|
|
71
|
+
How a gate reports an unverifiable run follows the workflow that owns it. The issue workflows (`rush-issues` and `resolve-issues`) always have a scheduler available (rush-issues through its `resolve-issues` dependency), so only that scheduler can declare their run finished: a missing plan, a missing scheduler, a scheduler error, a timeout, or invalid output refuses completion and leaves the Goal active and the workflow bound. A coordinator that ships no scheduler, such as a release workflow, has no run authority to consult, so its completion gate keeps the fail-open warning that avoids deadlocking it.
|
|
72
|
+
|
|
73
|
+
- **Completion.** `update_goal` complete is refused, with each due action (action, unit, first 200 characters of detail), unless the scheduler reports `finish` and nothing else is due (an empty due list means workers are still running, so it is refused too). An unverifiable issue-workflow run is refused as well, with the step that restores it: bind the task plan with `update_todo({workflow:{path,revision}})`, rebind the run with `/skill:<coordinator>`, or fix the scheduler. The Goal stays active.
|
|
74
|
+
- **Pause.** `release_workflow` is refused unless every unfinished unit is quiet (nothing due for it) or blocked `human-decision` with `humanItem` 2-5. A unit blocked `retry-ci` or any other reason the run retries itself, or a `human-decision` item 1, is named in the refusal and the Goal stays active. Execution failures keep the fail-open warning here, so a genuine human hold can always hand the run back.
|
|
72
75
|
- **Auto-bind.** Invoking `/skill:rush-issues` or `/skill:resolve-issues` with no active goal (none, or a completed one) creates and activates a Goal whose objective is the invocation text, exactly as `/goal <invocation>` would, without sending the command a second time. A paused or active Goal is left alone.
|
|
73
76
|
- **Wait timer.** When the scheduler's only due action is `wait` with a "next automatic attempt is at <ISO time>" detail, the next automatic continuation is scheduled for that time (at most the maximum timer delay, at least 5 seconds) and the wake-up is not counted as a no-progress retry. Other due work, or an unparseable time, uses the ordinary retry schedule. `autoContinue` off disables this timer.
|
|
74
77
|
|
package/package.json
CHANGED
package/src/goal-state.ts
CHANGED
|
@@ -66,7 +66,16 @@ function isGoalStatus(value: unknown): value is GoalStatus {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
function isPauseReason(value: unknown): value is GoalPauseReason {
|
|
69
|
-
return value === "interrupt" || value === "
|
|
69
|
+
return value === "interrupt" || value === "handback";
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Goals persisted by older releases can carry `permission-blocker`. Reports no
|
|
74
|
+
* longer pause a goal, so such a goal resumes like `/goal pause` (human-only
|
|
75
|
+
* `/goal resume` or alt+g); loading grants no permission and rewrites nothing.
|
|
76
|
+
*/
|
|
77
|
+
function normalizedPauseReason(value: unknown): GoalPauseReason | undefined {
|
|
78
|
+
return isPauseReason(value) ? value : undefined;
|
|
70
79
|
}
|
|
71
80
|
|
|
72
81
|
function isGoalLike(value: unknown): value is GoalLike {
|
|
@@ -119,12 +128,13 @@ function normalizeGoal(goal: GoalLike): GoalSnapshot {
|
|
|
119
128
|
const now = unixSeconds();
|
|
120
129
|
const createdAt = typeof goal.createdAt === "number" ? goal.createdAt : now;
|
|
121
130
|
const updatedAt = typeof goal.updatedAt === "number" ? goal.updatedAt : createdAt;
|
|
131
|
+
const pauseReason = goal.status === "paused" ? normalizedPauseReason(goal.pauseReason) : undefined;
|
|
122
132
|
return {
|
|
123
133
|
goalId: goal.goalId,
|
|
124
134
|
objective: goal.objective,
|
|
125
135
|
...(isCommandBinding(goal.command) ? { command: goal.command } : {}),
|
|
126
136
|
status: goal.status,
|
|
127
|
-
...(
|
|
137
|
+
...(pauseReason ? { pauseReason } : {}),
|
|
128
138
|
tokenBudget: typeof goal.tokenBudget === "number" ? goal.tokenBudget : null,
|
|
129
139
|
usage: {
|
|
130
140
|
tokensUsed: typeof goal.usage?.tokensUsed === "number" ? goal.usage.tokensUsed : 0,
|
package/src/index.ts
CHANGED
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
type GoalEntrySource,
|
|
30
30
|
} from "./goal-state.js";
|
|
31
31
|
import { continuationEvidence, type ContinuationEvidence } from "./continuation.js";
|
|
32
|
-
import { currentPermissionHold, logicalPermissionBlockerKey, MAX_PERMISSION_BLOCKERS, MAX_PERMISSION_RECORDS,
|
|
32
|
+
import { currentPermissionHold, logicalPermissionBlockerKey, MAX_PERMISSION_BLOCKERS, MAX_PERMISSION_RECORDS, permissionGapRecord, permissionHoldRecord, reportedPermissionBlockers, reportedPermissionGap, type PermissionHold } from "./permission-hold.js";
|
|
33
33
|
import { publishGoalGuidance } from "./prompt.js";
|
|
34
34
|
import { observeGoalStall } from "./stall.js";
|
|
35
35
|
import {
|
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
import { createRenderScheduler } from "./shared-render-scheduler.js";
|
|
43
43
|
import { initializeNavigatorPanels, setNavigatorPanel } from "./shared-navigator-panels.js";
|
|
44
44
|
import { collectSubagentActivity } from "./subagents.js";
|
|
45
|
-
import { currentWorkflowOwner, skillCommandName, workflowEntry, workflowOwnerFromSkill, WORKFLOW_ENTRY_TYPE } from "./workflow.js";
|
|
45
|
+
import { currentWorkflowOwner, ISSUE_WORKFLOW_SKILLS, skillCommandName, workflowEntry, workflowOwnerFromSkill, WORKFLOW_ENTRY_TYPE } from "./workflow.js";
|
|
46
46
|
import { completionGate, pauseGate, schedulerWaitUntil, operationResumeSchedulerGate } from "./workflow-gates.js";
|
|
47
47
|
import { workflowRehydrateMessage, WORKFLOW_REHYDRATE_MESSAGE_TYPE } from "./rehydrate.js";
|
|
48
48
|
import { requestTaskContext } from "./task-context.js";
|
|
@@ -66,7 +66,7 @@ const MAX_TIMER_DELAY_MS = 2_147_483_647;
|
|
|
66
66
|
/** Never re-poll a workflow's scheduler sooner than this, even when its stated attempt time has passed. */
|
|
67
67
|
const MIN_WAIT_DELAY_MS = 5_000;
|
|
68
68
|
/** Workflow skills whose invocation binds a goal when none is active, so the run cannot stop silently. */
|
|
69
|
-
const AUTO_BIND_SKILLS =
|
|
69
|
+
const AUTO_BIND_SKILLS = ISSUE_WORKFLOW_SKILLS;
|
|
70
70
|
const WAKE_DISABLED =
|
|
71
71
|
process.env.PI_BETTER_GOAL_DISABLE_WAKE === "1" ||
|
|
72
72
|
process.env.PI_BETTER_EXTENSION_DISABLE_WAKE === "1";
|
|
@@ -103,7 +103,6 @@ export function agentResumable(goal: GoalSnapshot | null, conversationalResume =
|
|
|
103
103
|
|
|
104
104
|
/** Footer status for a paused goal, telling the user how to resume it. */
|
|
105
105
|
export function pausedGoalStatus(goal: GoalSnapshot, conversationalResume = true): string {
|
|
106
|
-
if (goal.pauseReason === "permission-blocker") return "goal held: permission blocker · /goal resume (one retry)";
|
|
107
106
|
return agentResumable(goal, conversationalResume) ? 'goal paused · say "go" or /goal resume' : "goal paused · /goal resume";
|
|
108
107
|
}
|
|
109
108
|
|
|
@@ -111,9 +110,11 @@ function pausedGoalPrompt(goal: GoalSnapshot, conversationalResume: boolean, inc
|
|
|
111
110
|
return [
|
|
112
111
|
goal.pauseReason === "handback"
|
|
113
112
|
? `Pi Better Goal is paused because its workflow handed back unfinished work for the user's answer.${includeObjective ? ` Goal: ${goal.objective}` : ""}`
|
|
114
|
-
:
|
|
113
|
+
: goal.pauseReason === "interrupt"
|
|
114
|
+
? `Pi Better Goal is paused because the user pressed escape.${includeObjective ? ` Goal: ${goal.objective}` : ""}`
|
|
115
|
+
: `Pi Better Goal is paused.${includeObjective ? ` Goal: ${goal.objective}` : ""}`,
|
|
115
116
|
"Treat the user's messages as ordinary conversation: answer them, but do not continue the goal's work until it is resumed.",
|
|
116
|
-
conversationalResume ? GOAL_RESUME_RULE : "Only the user can resume this goal, with /goal resume or alt+g. A conversational go-ahead does not resume it.",
|
|
117
|
+
agentResumable(goal, conversationalResume) ? GOAL_RESUME_RULE : "Only the user can resume this goal, with /goal resume or alt+g. A conversational go-ahead does not resume it.",
|
|
117
118
|
].join("\n");
|
|
118
119
|
}
|
|
119
120
|
|
|
@@ -260,8 +261,8 @@ function formatGoal(
|
|
|
260
261
|
`Status: ${goal.status}`,
|
|
261
262
|
...(goal.pauseReason ? [`Pause reason: ${goal.pauseReason}`] : []),
|
|
262
263
|
...(permissions?.blockers.length ? [
|
|
263
|
-
`Permission
|
|
264
|
-
...(permissions.saturated ? ["Permission observation incomplete: history/scope limit reached;
|
|
264
|
+
`Permission diagnostics: ${permissions.blockers.length} scope(s); ${permissions.recordCount} history records`,
|
|
265
|
+
...(permissions.saturated ? ["Permission observation incomplete: history/scope limit reached. Diagnostics only; continuation is unaffected."] : []),
|
|
265
266
|
] : []),
|
|
266
267
|
`Token budget: ${budget}`,
|
|
267
268
|
`Tokens used: ${goal.usage.tokensUsed}`,
|
|
@@ -396,13 +397,6 @@ export default function (pi: ExtensionAPI): void {
|
|
|
396
397
|
};
|
|
397
398
|
|
|
398
399
|
const setGoal = (goal: GoalSnapshot, ctx: ExtensionContext, source: GoalEntrySource): void => {
|
|
399
|
-
const permissionHold = currentPermissionHold(ctx, goal.goalId);
|
|
400
|
-
if (goal.status === "paused" && permissionHold.blockers.length > 0) {
|
|
401
|
-
if (permissionHold.retryPending && permissionHold.recordCount < MAX_PERMISSION_RECORDS) {
|
|
402
|
-
pi.appendEntry(EXTENSION_NAME, permissionRecord(goal.goalId, "permission-retry-finished"));
|
|
403
|
-
}
|
|
404
|
-
goal = { ...goal, pauseReason: "permission-blocker" };
|
|
405
|
-
}
|
|
406
400
|
executionGeneration += 1;
|
|
407
401
|
lastAgentEvidence = null;
|
|
408
402
|
const previous = getGoal(ctx);
|
|
@@ -458,9 +452,7 @@ export default function (pi: ExtensionAPI): void {
|
|
|
458
452
|
}
|
|
459
453
|
const held = currentContinuationState(ctx, goal.goalId)?.blocked === true;
|
|
460
454
|
setGoal(goalWithStatus(goal, "paused", undefined, held ? undefined : "interrupt"), ctx, "runtime");
|
|
461
|
-
notifyGoal(ctx,
|
|
462
|
-
? "Goal remains permission-held. Use /goal resume or alt+g for one same-scope retry."
|
|
463
|
-
: preferences.conversationalResume && !held
|
|
455
|
+
notifyGoal(ctx, preferences.conversationalResume && !held
|
|
464
456
|
? 'Goal paused. Say "go" to resume it, or use /goal resume.'
|
|
465
457
|
: "Goal paused. Use /goal resume or alt+g to resume it.");
|
|
466
458
|
};
|
|
@@ -530,18 +522,6 @@ export default function (pi: ExtensionAPI): void {
|
|
|
530
522
|
return { ok: false, message: blocker };
|
|
531
523
|
}
|
|
532
524
|
const goal = held ? current : goalWithStatus(current, "active");
|
|
533
|
-
const permissions = currentPermissionHold(ctx, current.goalId);
|
|
534
|
-
if (current.pauseReason === "permission-blocker" && permissions.blockers.length === 0) {
|
|
535
|
-
return { ok: false, message: "Permission hold evidence is unavailable. The goal stays held; inspect the report before replacing this goal explicitly." };
|
|
536
|
-
}
|
|
537
|
-
if (permissions.blockers.length > 0) {
|
|
538
|
-
if (source === "tool" || permissions.saturated) {
|
|
539
|
-
return { ok: false, message: permissions.saturated
|
|
540
|
-
? "Permission hold history is full. The goal stays held; inspect it and create a new goal explicitly if needed."
|
|
541
|
-
: "Only /goal resume or alt+g can release one permission retry." };
|
|
542
|
-
}
|
|
543
|
-
pi.appendEntry(EXTENSION_NAME, permissionRecord(current.goalId, "permission-release"));
|
|
544
|
-
}
|
|
545
525
|
// Resuming a skill-bound goal is explicit re-entry into its workflow: rebind the owner the
|
|
546
526
|
// goal was created with (released by a handback) before the continuation runs.
|
|
547
527
|
const owner = goalWorkflowOwner(current);
|
|
@@ -579,11 +559,8 @@ export default function (pi: ExtensionAPI): void {
|
|
|
579
559
|
if (!boundCommandReady(goal, ctx)) return;
|
|
580
560
|
clearIdleContinuation();
|
|
581
561
|
continuationQueuedFor = goal.goalId;
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
sendGoalContinuation(goal, permissions.blockers.length > 0
|
|
585
|
-
? `${continuationPrompt(goal, getWorkflow(ctx))}\n\n${permissionInstruction(permissions)}`
|
|
586
|
-
: continuationPrompt(goal, getWorkflow(ctx)), "continuation");
|
|
562
|
+
resetContinuationState(goal);
|
|
563
|
+
sendGoalContinuation(goal, continuationPrompt(goal, getWorkflow(ctx)), "continuation");
|
|
587
564
|
};
|
|
588
565
|
|
|
589
566
|
function clearIdleContinuation(): void {
|
|
@@ -606,7 +583,6 @@ export default function (pi: ExtensionAPI): void {
|
|
|
606
583
|
if (WAKE_DISABLED || !preferences.autoContinue || !isPokeable(goal) || continuationQueuedFor === goal.goalId) {
|
|
607
584
|
return;
|
|
608
585
|
}
|
|
609
|
-
if (currentPermissionHold(ctx, goal.goalId).blockers.length > 0) return;
|
|
610
586
|
if (currentContinuationState(ctx, goal.goalId)?.blocked) {
|
|
611
587
|
return;
|
|
612
588
|
}
|
|
@@ -637,7 +613,6 @@ export default function (pi: ExtensionAPI): void {
|
|
|
637
613
|
if (WAKE_DISABLED || !preferences.autoContinue || execution !== executionGeneration || wake !== wakeGeneration) return false;
|
|
638
614
|
const current = currentGoalSnapshot(ctx);
|
|
639
615
|
return isPokeable(current) && current.goalId === goalId &&
|
|
640
|
-
currentPermissionHold(ctx, goalId).blockers.length === 0 &&
|
|
641
616
|
!currentContinuationState(ctx, goalId)?.blocked &&
|
|
642
617
|
continuationQueuedFor !== goalId && !isForegroundBusy(ctx);
|
|
643
618
|
};
|
|
@@ -703,8 +678,7 @@ export default function (pi: ExtensionAPI): void {
|
|
|
703
678
|
const goal = currentGoalSnapshot(ctx);
|
|
704
679
|
const wakePlan = planBackgroundDrainWake(backgroundDrainTracker, goal, snapshot);
|
|
705
680
|
backgroundDrainTracker = wakePlan.nextTracker;
|
|
706
|
-
if (isPokeable(goal) && wakePlan.wakeSignature &&
|
|
707
|
-
!currentContinuationState(ctx, goal.goalId)?.blocked) {
|
|
681
|
+
if (isPokeable(goal) && wakePlan.wakeSignature && !currentContinuationState(ctx, goal.goalId)?.blocked) {
|
|
708
682
|
// Persist external progress now: a foreground/callback turn may cancel its delayed wake.
|
|
709
683
|
clearIdleContinuation();
|
|
710
684
|
resetContinuationState(goal);
|
|
@@ -878,7 +852,6 @@ export default function (pi: ExtensionAPI): void {
|
|
|
878
852
|
if ((request.owner.goalId ?? null) !== (goal?.goalId ?? null)) { held("Owning Goal is no longer current"); return; }
|
|
879
853
|
if (goal && !preferences.autoContinue) { held("Goal automatic continuation is disabled"); return; }
|
|
880
854
|
if (goal && !isPokeable(goal)) { held("Goal is not active"); return; }
|
|
881
|
-
if (goal && currentPermissionHold(ctx, goal.goalId).blockers.length) { held("Goal has an active permission hold"); return; }
|
|
882
855
|
if (goal && currentContinuationState(ctx, goal.goalId)?.blocked) { held("Goal continuation requires human resume"); return; }
|
|
883
856
|
if (goal && !boundCommandReady(goal, ctx)) { held("Bound workflow is not ready"); return; }
|
|
884
857
|
const workflow = getWorkflow(ctx);
|
|
@@ -889,7 +862,7 @@ export default function (pi: ExtensionAPI): void {
|
|
|
889
862
|
const latest = getGoal(ctx);
|
|
890
863
|
if ((request.owner!.goalId ?? null) !== (latest?.goalId ?? null)) { held("Owning Goal changed during resume admission"); return; }
|
|
891
864
|
if (latest && !preferences.autoContinue) { held("Goal automatic continuation is disabled"); return; }
|
|
892
|
-
if (latest && (!isPokeable(latest) ||
|
|
865
|
+
if (latest && (!isPokeable(latest) || currentContinuationState(ctx, latest.goalId)?.blocked)) {
|
|
893
866
|
held("Goal became held during resume admission"); return;
|
|
894
867
|
}
|
|
895
868
|
if (!gate.ok) { held(gate.reason); return; }
|
|
@@ -903,7 +876,6 @@ export default function (pi: ExtensionAPI): void {
|
|
|
903
876
|
if ((request.owner!.goalId ?? null) !== (active?.goalId ?? null)) return false;
|
|
904
877
|
if (JSON.stringify(getWorkflow(ctx)) !== JSON.stringify(workflow)) return false;
|
|
905
878
|
return !active || (preferences.autoContinue && isPokeable(active)
|
|
906
|
-
&& !currentPermissionHold(ctx, active.goalId).blockers.length
|
|
907
879
|
&& !currentContinuationState(ctx, active.goalId)?.blocked && boundCommandReady(active, ctx));
|
|
908
880
|
};
|
|
909
881
|
reply({ allowed: true, revision, isCurrent });
|
|
@@ -1263,10 +1235,6 @@ export default function (pi: ExtensionAPI): void {
|
|
|
1263
1235
|
notifyGoal(ctx, error instanceof Error ? error.message : String(error), "error");
|
|
1264
1236
|
}
|
|
1265
1237
|
const restoredGoal = getGoal(ctx);
|
|
1266
|
-
if (restoredGoal?.status === "active" && currentPermissionHold(ctx, restoredGoal.goalId).blockers.length > 0) {
|
|
1267
|
-
// A persisted release is not a replayable dispatch ticket after reload.
|
|
1268
|
-
setGoal(goalWithStatus(restoredGoal, "paused", undefined, "permission-blocker"), ctx, "runtime");
|
|
1269
|
-
}
|
|
1270
1238
|
if (restoredGoal?.status === "active" && !restoredGoal.command && skillCommandName(restoredGoal.objective)) {
|
|
1271
1239
|
setGoal(goalWithStatus(restoredGoal, "paused"), ctx, "runtime");
|
|
1272
1240
|
notifyGoal(ctx, "Goal paused: invoke its skill directly before resuming.", "error");
|
|
@@ -1336,8 +1304,7 @@ export default function (pi: ExtensionAPI): void {
|
|
|
1336
1304
|
// A paused goal stays paused while the user talks: the message is ordinary
|
|
1337
1305
|
// conversation. Only /goal resume, the hotkey, or goal_resume resume it.
|
|
1338
1306
|
const goal = getGoal(ctx);
|
|
1339
|
-
if (goal?.status === "active" &&
|
|
1340
|
-
!currentContinuationState(ctx, goal.goalId)?.blocked) {
|
|
1307
|
+
if (goal?.status === "active" && !currentContinuationState(ctx, goal.goalId)?.blocked) {
|
|
1341
1308
|
executionGeneration += 1;
|
|
1342
1309
|
clearIdleContinuation();
|
|
1343
1310
|
lastAgentEvidence = null;
|
|
@@ -1354,17 +1321,8 @@ export default function (pi: ExtensionAPI): void {
|
|
|
1354
1321
|
const harnessPresent = requestTaskContext(pi, "inspect", goal).enabled !== undefined;
|
|
1355
1322
|
const snapshot = await publishSnapshot(ctx);
|
|
1356
1323
|
if (!snapshot) return;
|
|
1357
|
-
const
|
|
1358
|
-
|
|
1359
|
-
(permissions.blockers.length > 0 || goal?.pauseReason === "permission-blocker")
|
|
1360
|
-
? permissionInstruction({ ...permissions, retryPending: permissions.retryPending && goal?.status === "active" }) +
|
|
1361
|
-
(permissions.blockers.length === 0 ? "\nBlocker evidence is unavailable. Stay held; do not invent a retry scope." : "") : "";
|
|
1362
|
-
// A held goal overrides workflow ownership without invoking or invalidating that workflow.
|
|
1363
|
-
if (permissionPrompt && goal?.status === "paused") {
|
|
1364
|
-
return publishGoalGuidance(event, permissionPrompt);
|
|
1365
|
-
}
|
|
1366
|
-
const pausedInstruction = permissionPrompt || (goal?.status === "paused" && (goal.pauseReason === "interrupt" || goal.pauseReason === "handback")
|
|
1367
|
-
? pausedGoalPrompt(goal, preferences.conversationalResume, !harnessPresent) : "");
|
|
1324
|
+
const pausedInstruction = goal?.status === "paused"
|
|
1325
|
+
? pausedGoalPrompt(goal, preferences.conversationalResume, !harnessPresent) : "";
|
|
1368
1326
|
if (!isPokeable(goal) && !owner) {
|
|
1369
1327
|
return publishGoalGuidance(event, pausedInstruction);
|
|
1370
1328
|
}
|
|
@@ -1392,9 +1350,7 @@ export default function (pi: ExtensionAPI): void {
|
|
|
1392
1350
|
return publishGoalGuidance(
|
|
1393
1351
|
event,
|
|
1394
1352
|
pausedInstruction &&
|
|
1395
|
-
`${pausedInstruction}\n` +
|
|
1396
|
-
? "These permission constraints override the workflow instructions below.\n\n"
|
|
1397
|
-
: "While the goal is paused, this overrides the workflow instructions below: do not advance the workflow until the goal is resumed.\n\n"),
|
|
1353
|
+
`${pausedInstruction}\n` + "While the goal is paused, this overrides the workflow instructions below: do not advance the workflow until the goal is resumed.\n\n",
|
|
1398
1354
|
`Active workflow: ${owner.name} (${owner.path}). Its task plan owns planning and the parent is a coordinator, not a product-code implementer. Follow the workflow instructions below, including on resumed turns:\n\n${instructions}`,
|
|
1399
1355
|
isPokeable(goal) && (harnessPresent
|
|
1400
1356
|
? "Complete the goal only after the workflow completion audit."
|
|
@@ -1416,13 +1372,11 @@ export default function (pi: ExtensionAPI): void {
|
|
|
1416
1372
|
heldInstruction,
|
|
1417
1373
|
backgroundInstruction.trim(),
|
|
1418
1374
|
questionInstruction.trim(),
|
|
1419
|
-
permissionPrompt,
|
|
1420
1375
|
);
|
|
1421
1376
|
}
|
|
1422
1377
|
return publishGoalGuidance(
|
|
1423
1378
|
event,
|
|
1424
1379
|
`Pi Better Goal active objective: ${goal.objective}. ${heldInstruction || "Keep working through clear low-risk next steps, and mark complete only after an evidence-backed completion audit."}${backgroundInstruction}${questionInstruction}`,
|
|
1425
|
-
permissionPrompt,
|
|
1426
1380
|
);
|
|
1427
1381
|
});
|
|
1428
1382
|
|
|
@@ -1472,31 +1426,22 @@ export default function (pi: ExtensionAPI): void {
|
|
|
1472
1426
|
const incomplete = reportedPermissionGap(pi, event.toolName, event.details);
|
|
1473
1427
|
if (reports.length === 0 && !incomplete) return;
|
|
1474
1428
|
let hold = currentPermissionHold(ctx, goal.goalId);
|
|
1475
|
-
let changed = false;
|
|
1476
1429
|
for (const blocker of reports) {
|
|
1477
1430
|
const previous = hold.blockers.find((item) => logicalPermissionBlockerKey(item) === logicalPermissionBlockerKey(blocker));
|
|
1478
|
-
if (
|
|
1431
|
+
if (previous && JSON.stringify(previous) === JSON.stringify(blocker)) continue;
|
|
1479
1432
|
if (hold.saturated || (!previous && hold.blockers.length >= MAX_PERMISSION_BLOCKERS)) {
|
|
1480
1433
|
if (!hold.saturated && hold.recordCount < MAX_PERMISSION_RECORDS) {
|
|
1481
|
-
pi.appendEntry(EXTENSION_NAME,
|
|
1434
|
+
pi.appendEntry(EXTENSION_NAME, permissionGapRecord(goal.goalId));
|
|
1482
1435
|
}
|
|
1483
1436
|
break;
|
|
1484
1437
|
}
|
|
1485
1438
|
pi.appendEntry(EXTENSION_NAME, permissionHoldRecord(goal.goalId, blocker));
|
|
1486
|
-
changed = true;
|
|
1487
1439
|
hold = currentPermissionHold(ctx, goal.goalId);
|
|
1488
1440
|
}
|
|
1489
1441
|
if (incomplete && !hold.saturated && hold.recordCount < MAX_PERMISSION_RECORDS) {
|
|
1490
|
-
pi.appendEntry(EXTENSION_NAME,
|
|
1491
|
-
changed = true;
|
|
1492
|
-
hold = currentPermissionHold(ctx, goal.goalId);
|
|
1493
|
-
}
|
|
1494
|
-
if (hold.retryPending && hold.recordCount < MAX_PERMISSION_RECORDS) {
|
|
1495
|
-
pi.appendEntry(EXTENSION_NAME, permissionRecord(goal.goalId, "permission-retry-finished"));
|
|
1442
|
+
pi.appendEntry(EXTENSION_NAME, permissionGapRecord(goal.goalId));
|
|
1496
1443
|
}
|
|
1497
|
-
|
|
1498
|
-
setGoal(goalWithStatus(goal, "paused", undefined, "permission-blocker"), ctx, "runtime");
|
|
1499
|
-
notifyGoal(ctx, "Goal held for a permission blocker. /goal resume or alt+g releases one same-scope retry.", "warning");
|
|
1444
|
+
// Diagnostics only: the goal keeps running and continuation is unchanged.
|
|
1500
1445
|
});
|
|
1501
1446
|
|
|
1502
1447
|
pi.on("tool_execution_start", async (event, ctx) => {
|
|
@@ -1535,16 +1480,6 @@ export default function (pi: ExtensionAPI): void {
|
|
|
1535
1480
|
const snapshot = await publishSnapshot(ctx);
|
|
1536
1481
|
if (!snapshot) return;
|
|
1537
1482
|
const goal = getGoal(ctx);
|
|
1538
|
-
if (isPokeable(goal)) {
|
|
1539
|
-
const permissions = currentPermissionHold(ctx, goal.goalId);
|
|
1540
|
-
if (permissions.blockers.length > 0) {
|
|
1541
|
-
if (permissions.retryPending && permissions.recordCount < MAX_PERMISSION_RECORDS) {
|
|
1542
|
-
pi.appendEntry(EXTENSION_NAME, permissionRecord(goal.goalId, "permission-retry-finished"));
|
|
1543
|
-
}
|
|
1544
|
-
setGoal(goalWithStatus(goal, "paused", undefined, "permission-blocker"), ctx, "runtime");
|
|
1545
|
-
return;
|
|
1546
|
-
}
|
|
1547
|
-
}
|
|
1548
1483
|
if (!isPokeable(goal) || snapshot.backgroundRunning) {
|
|
1549
1484
|
return;
|
|
1550
1485
|
}
|
package/src/permission-hold.ts
CHANGED
|
@@ -4,6 +4,12 @@ import { dirname, join } from "node:path";
|
|
|
4
4
|
import { isPermissionBlocker, permissionBlockerKey, type PermissionBlocker } from "./shared-permission-blocker.js";
|
|
5
5
|
import { EXTENSION_NAME } from "./types.js";
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Permission failure reports are diagnostics. This ledger records observed
|
|
9
|
+
* blockers so `/goal` and `get_goal` can show them; it never pauses a goal,
|
|
10
|
+
* limits resume, suppresses continuation/wakes/audits, or grants permission.
|
|
11
|
+
* Tool and sandbox enforcement remain the only authority.
|
|
12
|
+
*/
|
|
7
13
|
export const MAX_PERMISSION_BLOCKERS = 32;
|
|
8
14
|
export const MAX_PERMISSION_RECORDS = 128;
|
|
9
15
|
|
|
@@ -13,7 +19,6 @@ export type PermissionRecord =
|
|
|
13
19
|
|
|
14
20
|
export interface PermissionHold {
|
|
15
21
|
blockers: PermissionBlocker[];
|
|
16
|
-
retryPending: boolean;
|
|
17
22
|
recordCount: number;
|
|
18
23
|
saturated: boolean;
|
|
19
24
|
}
|
|
@@ -26,10 +31,9 @@ export function logicalPermissionBlockerKey(blocker: PermissionBlocker): string
|
|
|
26
31
|
});
|
|
27
32
|
}
|
|
28
33
|
|
|
29
|
-
/** Replay
|
|
34
|
+
/** Replay the goal's compact diagnostic records, independently of progress resets. */
|
|
30
35
|
export function currentPermissionHold(ctx: ExtensionContext, goalId: string): PermissionHold {
|
|
31
36
|
const blockers = new Map<string, PermissionBlocker>();
|
|
32
|
-
let retryPending = false;
|
|
33
37
|
let recordCount = 0;
|
|
34
38
|
let saturated = false;
|
|
35
39
|
for (const entry of ctx.sessionManager.getBranch()) {
|
|
@@ -41,7 +45,6 @@ export function currentPermissionHold(ctx: ExtensionContext, goalId: string): Pe
|
|
|
41
45
|
if (data.version !== 1 || typeof data.at !== "number" || !Number.isFinite(data.at) ||
|
|
42
46
|
(data.kind === "permission-hold" && !isPermissionBlocker(data.blocker))) {
|
|
43
47
|
saturated = true;
|
|
44
|
-
retryPending = false;
|
|
45
48
|
recordCount += 1;
|
|
46
49
|
continue;
|
|
47
50
|
}
|
|
@@ -49,20 +52,15 @@ export function currentPermissionHold(ctx: ExtensionContext, goalId: string): Pe
|
|
|
49
52
|
const key = logicalPermissionBlockerKey(data.blocker);
|
|
50
53
|
if (blockers.has(key) || blockers.size < MAX_PERMISSION_BLOCKERS) blockers.set(key, compactBlocker(data.blocker));
|
|
51
54
|
else saturated = true;
|
|
52
|
-
retryPending = false;
|
|
53
|
-
} else if (data.kind === "permission-release" && blockers.size > 0) {
|
|
54
|
-
retryPending = !saturated;
|
|
55
|
-
} else if (data.kind === "permission-retry-finished") {
|
|
56
|
-
retryPending = false;
|
|
57
55
|
} else if (data.kind === "permission-gap") {
|
|
58
56
|
saturated = true;
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
}
|
|
58
|
+
// Legacy release records remain countable history but carry no authority.
|
|
61
59
|
recordCount += 1;
|
|
62
|
-
// Reserve room to record an incomplete scope
|
|
60
|
+
// Reserve room to record an incomplete scope.
|
|
63
61
|
if (recordCount >= MAX_PERMISSION_RECORDS - 2) saturated = true;
|
|
64
62
|
}
|
|
65
|
-
return { blockers: [...blockers.values()],
|
|
63
|
+
return { blockers: [...blockers.values()], recordCount, saturated };
|
|
66
64
|
}
|
|
67
65
|
|
|
68
66
|
function compactBlocker(blocker: PermissionBlocker): PermissionBlocker {
|
|
@@ -130,21 +128,10 @@ export function reportedPermissionGap(pi: ExtensionAPI, toolName: string, detail
|
|
|
130
128
|
return typeof omitted === "number" && Number.isSafeInteger(omitted) && omitted > 0;
|
|
131
129
|
}
|
|
132
130
|
|
|
133
|
-
export function
|
|
134
|
-
return { version: 1, kind, goalId, at: Math.floor(Date.now() / 1000) };
|
|
131
|
+
export function permissionGapRecord(goalId: string): PermissionRecord {
|
|
132
|
+
return { version: 1, kind: "permission-gap", goalId, at: Math.floor(Date.now() / 1000) };
|
|
135
133
|
}
|
|
136
134
|
|
|
137
135
|
export function permissionHoldRecord(goalId: string, blocker: PermissionBlocker): PermissionRecord {
|
|
138
136
|
return { version: 1, kind: "permission-hold", goalId, blocker: compactBlocker(blocker), at: Math.floor(Date.now() / 1000) };
|
|
139
137
|
}
|
|
140
|
-
|
|
141
|
-
export function permissionInstruction(hold: PermissionHold): string {
|
|
142
|
-
return [
|
|
143
|
-
hold.retryPending
|
|
144
|
-
? "The human explicitly released ONE bounded retry of the held operation and scope below. This is not a permission grant or evidence of success."
|
|
145
|
-
: "The goal is paused for a permission blocker. Answer ordinary questions, but do not advance goal or workflow work. Only /goal resume or alt+g releases one bounded retry; goal_resume cannot release it.",
|
|
146
|
-
...hold.blockers.map((blocker) => `- ${blocker.context}: ${blocker.resource}; operation=${blocker.operation}; basis=${blocker.basis}; remoteOutcome=${blocker.remoteOutcome}` +
|
|
147
|
-
(blocker.runId ? `; runId=${blocker.runId}` : "") + (blocker.policySnapshotId ? `; policySnapshotId=${blocker.policySnapshotId}` : "")),
|
|
148
|
-
"Keep the same operation and scope. Do not switch to foreground execution, copy credentials, change authentication, or broaden permissions. Changed worker settings require a fresh worker; retain the logical operation identity. Runtime-observed refusals and agent-reported blockers are distinct. Unknown remote outcome is never evidence of success.",
|
|
149
|
-
].join("\n");
|
|
150
|
-
}
|
package/src/types.ts
CHANGED
|
@@ -71,12 +71,11 @@ export type GoalStatus = "active" | "paused" | "budgetLimited" | "complete";
|
|
|
71
71
|
* resume a goal on their own. An `interrupt` pause may be resumed by the agent
|
|
72
72
|
* with `goal_resume` when the user clearly says to proceed. A paused goal
|
|
73
73
|
* without a reason (`/goal pause`, an unavailable command or workflow) resumes
|
|
74
|
-
* only through `/goal resume` or the resume hotkey.
|
|
75
|
-
*
|
|
76
|
-
* keeping its separate blocker/release history.
|
|
74
|
+
* only through `/goal resume` or the resume hotkey. Permission failure reports
|
|
75
|
+
* are diagnostics and never create a pause reason.
|
|
77
76
|
*/
|
|
78
|
-
/** Why a goal paused: escape,
|
|
79
|
-
export type GoalPauseReason = "interrupt" | "
|
|
77
|
+
/** Why a goal paused: escape, or a workflow handing back unfinished work for the user's answer. */
|
|
78
|
+
export type GoalPauseReason = "interrupt" | "handback";
|
|
80
79
|
|
|
81
80
|
export interface GoalUsage {
|
|
82
81
|
tokensUsed: number;
|
package/src/workflow-gates.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { cpSync, existsSync, mkdtempSync, readFileSync, rmSync, statSync } from
|
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
5
5
|
|
|
6
|
-
import type
|
|
6
|
+
import { ISSUE_WORKFLOW_SKILLS, type WorkflowOwner } from "./workflow.js";
|
|
7
7
|
|
|
8
8
|
/** Branch entry the plan extension writes when it binds a workflow-owned task plan. */
|
|
9
9
|
const WORKFLOW_PLAN_ENTRY = "pi-better-workflow-plan";
|
|
@@ -88,13 +88,18 @@ function parseSchedulerOutput(stdout: string): SchedulerRun {
|
|
|
88
88
|
return { ok: false, reason: "the scheduler printed output that is not JSON" };
|
|
89
89
|
}
|
|
90
90
|
if (!isRecord(parsed) || !Array.isArray(parsed.due)) return { ok: false, reason: "the scheduler output has no due list" };
|
|
91
|
-
const due
|
|
92
|
-
|
|
91
|
+
const due: SchedulerAction[] = [];
|
|
92
|
+
for (const item of parsed.due) {
|
|
93
|
+
// A malformed entry could hide due work, so it invalidates the answer instead of being dropped.
|
|
94
|
+
if (!isRecord(item) || typeof item.action !== "string") {
|
|
95
|
+
return { ok: false, reason: "the scheduler output has a due entry without an action" };
|
|
96
|
+
}
|
|
97
|
+
due.push({
|
|
93
98
|
action: item.action,
|
|
94
99
|
unit: item.unit === null || item.unit === undefined ? null : String(item.unit),
|
|
95
100
|
detail: typeof item.detail === "string" ? item.detail : "",
|
|
96
|
-
}
|
|
97
|
-
|
|
101
|
+
});
|
|
102
|
+
}
|
|
98
103
|
return { ok: true, due };
|
|
99
104
|
}
|
|
100
105
|
|
|
@@ -114,6 +119,10 @@ function executeScheduler(script: string, runDir: string, timeoutMs: number, liv
|
|
|
114
119
|
if (error) {
|
|
115
120
|
// An exit status of 1 means "actions due"; any other failure (exit 2, timeout, spawn error) is real.
|
|
116
121
|
if ((error as { code?: unknown }).code !== 1) {
|
|
122
|
+
if ((error as { killed?: unknown }).killed === true) {
|
|
123
|
+
resolve({ ok: false, reason: `the scheduler timed out after ${timeoutMs} ms` });
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
117
126
|
const detail = String(stderr).trim().split("\n")[0] || error.message;
|
|
118
127
|
resolve({ ok: false, reason: `the scheduler failed (${detail.slice(0, DETAIL_LIMIT)})` });
|
|
119
128
|
return;
|
|
@@ -150,11 +159,14 @@ interface PlannedRun {
|
|
|
150
159
|
script: string;
|
|
151
160
|
}
|
|
152
161
|
|
|
153
|
-
|
|
162
|
+
/** The run a gate would check, or what it could not locate, so each gate decides how to report it. */
|
|
163
|
+
type RunLocation = PlannedRun | { missing: "scheduler" | "plan"; problem: string };
|
|
164
|
+
|
|
165
|
+
function locateRun(entries: Iterable<EntryLike>, owner: WorkflowOwner): RunLocation {
|
|
154
166
|
const script = findScheduler(owner);
|
|
155
|
-
if (!script) return {
|
|
167
|
+
if (!script) return { missing: "scheduler", problem: `${owner.name} ships no scheduler` };
|
|
156
168
|
const plan = boundPlanPath(entries, owner);
|
|
157
|
-
if (!plan) return {
|
|
169
|
+
if (!plan) return { missing: "plan", problem: `no task plan is bound for ${owner.name} yet` };
|
|
158
170
|
return { runDir: dirname(plan), script };
|
|
159
171
|
}
|
|
160
172
|
|
|
@@ -167,16 +179,50 @@ function describe(action: SchedulerAction): string {
|
|
|
167
179
|
return `- ${action.action}${action.unit ? ` (unit ${action.unit})` : ""}: ${detail}`;
|
|
168
180
|
}
|
|
169
181
|
|
|
170
|
-
/**
|
|
182
|
+
/** Coordinators whose runs the resolve-issues scheduler drives, so only it can declare the run finished. */
|
|
183
|
+
function schedulerOwnsCompletion(owner: WorkflowOwner): boolean {
|
|
184
|
+
return ISSUE_WORKFLOW_SKILLS.has(owner.name);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function unverifiedCompletion(owner: WorkflowOwner, problem: string, recovery: string): GateVerdict {
|
|
188
|
+
return {
|
|
189
|
+
allow: false,
|
|
190
|
+
due: [],
|
|
191
|
+
message: `Goal not marked complete: ${problem}, so the run's completion is not verified. ${recovery} ` +
|
|
192
|
+
`The ${owner.name} workflow stays bound and the Goal stays active.`,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Completion is allowed only when the scheduler reports `finish` and nothing else is due. For the
|
|
198
|
+
* issue workflows an unavailable plan or scheduler never counts as permission: the run has a
|
|
199
|
+
* completion authority, and only that authority may declare it finished. Any other coordinator has
|
|
200
|
+
* no scheduler to consult, so its gate keeps the fail-open warning that avoids deadlocking it.
|
|
201
|
+
*/
|
|
171
202
|
export async function completionGate(
|
|
172
203
|
entries: Iterable<EntryLike>,
|
|
173
204
|
owner: WorkflowOwner,
|
|
174
205
|
options: { timeoutMs?: number } = {},
|
|
175
206
|
): Promise<GateVerdict> {
|
|
207
|
+
const owned = schedulerOwnsCompletion(owner);
|
|
176
208
|
const located = locateRun(entries, owner);
|
|
177
|
-
if ("
|
|
209
|
+
if ("missing" in located) {
|
|
210
|
+
if (!owned) return unchecked(`${located.problem}, so the run was not checked`);
|
|
211
|
+
const recovery = located.missing === "plan"
|
|
212
|
+
? `Bind the run's task plan with update_todo({workflow:{path,revision}}), or rebind the run with /skill:${owner.name}, ` +
|
|
213
|
+
"then call update_goal again once the scheduler reports finish."
|
|
214
|
+
: `Restore the run's scheduler or rebind the run with /skill:${owner.name}, ` +
|
|
215
|
+
"then call update_goal again once the scheduler reports finish.";
|
|
216
|
+
return unverifiedCompletion(owner, located.problem, recovery);
|
|
217
|
+
}
|
|
178
218
|
const run = await settlementScheduler(located.script, located.runDir, options.timeoutMs);
|
|
179
|
-
if (!run.ok)
|
|
219
|
+
if (!run.ok) {
|
|
220
|
+
const problem = `the ${owner.name} run could not be checked (${run.reason})`;
|
|
221
|
+
if (!owned) return unchecked(problem);
|
|
222
|
+
return unverifiedCompletion(owner, problem,
|
|
223
|
+
`Fix the scheduler, or rebind the run with /skill:${owner.name} if its plan moved, ` +
|
|
224
|
+
"then call update_goal again once the scheduler reports finish.");
|
|
225
|
+
}
|
|
180
226
|
const open = run.due.filter((action) => action.action !== "finish");
|
|
181
227
|
if (open.length === 0 && run.due.length > 0) return { allow: true };
|
|
182
228
|
if (open.length === 0) {
|
|
@@ -215,7 +261,7 @@ export async function pauseGate(
|
|
|
215
261
|
options: { timeoutMs?: number } = {},
|
|
216
262
|
): Promise<GateVerdict> {
|
|
217
263
|
const located = locateRun(entries, owner);
|
|
218
|
-
if ("
|
|
264
|
+
if ("missing" in located) return unchecked(`${located.problem}, so the run was not checked`);
|
|
219
265
|
const units = readUnits(located.runDir);
|
|
220
266
|
if (!units) return unchecked(`could not read the ${owner.name} task plan`);
|
|
221
267
|
const run = await settlementScheduler(located.script, located.runDir, options.timeoutMs);
|
|
@@ -271,7 +317,7 @@ export async function operationResumeSchedulerGate(
|
|
|
271
317
|
options: { timeoutMs?: number } = {},
|
|
272
318
|
): Promise<OperationResumeSchedulerGate> {
|
|
273
319
|
const located = locateRun(entries, owner);
|
|
274
|
-
if ("
|
|
320
|
+
if ("missing" in located) return { ok: false, reason: `${located.problem}, so the run was not checked` };
|
|
275
321
|
const run = await runScheduler(located.script, located.runDir, options.timeoutMs);
|
|
276
322
|
if (!run.ok) return { ok: false, reason: `Workflow admission evidence unavailable: ${run.reason}` };
|
|
277
323
|
return { ok: true, waitUntil: waitUntil(run.due) };
|
|
@@ -284,7 +330,7 @@ export async function schedulerWaitUntil(
|
|
|
284
330
|
options: { timeoutMs?: number } = {},
|
|
285
331
|
): Promise<number | undefined> {
|
|
286
332
|
const located = locateRun(entries, owner);
|
|
287
|
-
if ("
|
|
333
|
+
if ("missing" in located) return undefined;
|
|
288
334
|
const run = await runScheduler(located.script, located.runDir, options.timeoutMs);
|
|
289
335
|
return run.ok ? waitUntil(run.due) : undefined;
|
|
290
336
|
}
|
package/src/workflow.ts
CHANGED
|
@@ -3,6 +3,13 @@ import { parse } from "yaml";
|
|
|
3
3
|
|
|
4
4
|
export const WORKFLOW_ENTRY_TYPE = "pi-better-workflow";
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Coordinators whose runs the resolve-issues scheduler drives, so only its next-actions scheduler can
|
|
8
|
+
* declare the run finished. Other coordinators (a release workflow, say) ship no scheduler, and their
|
|
9
|
+
* completion gates keep the fail-open behavior that avoids deadlocking them.
|
|
10
|
+
*/
|
|
11
|
+
export const ISSUE_WORKFLOW_SKILLS: ReadonlySet<string> = new Set(["rush-issues", "resolve-issues"]);
|
|
12
|
+
|
|
6
13
|
export interface WorkflowOwner {
|
|
7
14
|
name: string;
|
|
8
15
|
path: string;
|