pi-goal-list-loop-audit 0.38.0 → 0.38.1
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 +12 -0
- package/docs/INDEX.md +1 -1
- package/extensions/drafter-model.ts +13 -6
- package/extensions/loops/goal-activation.ts +2 -2
- package/extensions/loops/goal-auditor-hooks.ts +3 -0
- package/extensions/loops/goal-list-queue.ts +45 -12
- package/extensions/loops/goal-settings-ui.ts +8 -4
- package/extensions/loops/goal-tools.ts +1 -0
- package/extensions/settings-menu.ts +4 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.38.1 — drafter/auditor fallback parity with Main (2026-09-02)
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
Drafter model selection now emits the same `model_fallback_select` ledger as Main (`scope: drafter`) for every forbidden/unregistered skip, so `forbiddenModels` edits mid-interview are honored even when the user edits settings while the interview is open.
|
|
7
|
+
|
|
8
|
+
Drafter recovery after a provider failure now walks the dedicated 0-10 chain via `ModelSelector` with the bounded ladder (`5s → base*2^(n-1) cap 5h`, base `mainModelRetryMinutes` default 15) and `forbiddenModels` re-check, instead of an immediate unbounded loop over the lease candidates. Same-model pin (drafter pinned to the session model) remains a same-model retry and is preserved.
|
|
9
|
+
|
|
10
|
+
Auditor `model_fallback_select` ledger (`scope: auditor`) now fires for both the settings-time `resolveAuditorModel` walk and the detached audit fallback (`runAuditorFallbackWithPolicy` via `runDetachedCompletionWithFallback`), closing the gap where detached retries skipped forbidden/unregistered refs silently. `forbiddenRefs` and `retryBaseMinutes` were already wired; `onSelection` is now forwarded.
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
`Drafter fallback agents` menu row → `Drafter fallback models (up to 10)` with count prefix `N/10 · 1. ref → 2. ref` and the shared `ordered and deselectable: current drafter → fallback 1 → fallback 2…` description, matching Main and Auditor rows. Prompt title and notification strings updated to `models` vocabulary. Watchdog budgets (`auditorToolTimeoutMs 5m`, `auditorStallMs 10m` x2 cap 4x) remain independent of the ladder and unchanged.
|
|
14
|
+
|
|
3
15
|
## 0.38.0 — event-driven supervision and drafting discipline (2026-09-02)
|
|
4
16
|
|
|
5
17
|
### Fixed
|
package/docs/INDEX.md
CHANGED
|
@@ -18,7 +18,7 @@ For shipped docs, the relevant entry points are:
|
|
|
18
18
|
failback; v0.35.9 hardened cross-version npm tarball checks; v0.35.10
|
|
19
19
|
handles multi-entry npm dry-run reports; v0.35.11 accepts both npm report
|
|
20
20
|
shapes; v0.35.12 supports npm 12's keyed pack reports; v0.35.13 fixes stale-API recovery loops.
|
|
21
|
-
v0.35.14–v0.38.
|
|
21
|
+
v0.35.14–v0.38.1 continue through the supervisor freeze (`/glla pause`),
|
|
22
22
|
load hold, auditor picker parity, Windows launch fix, zombie-watchdog
|
|
23
23
|
subagent carve-out, due-wait backstop, the `/glla agents` visibility panel,
|
|
24
24
|
durable state-root selection, blank-until-resume auditor context, frozen
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
9
9
|
|
|
10
|
-
import { isForbiddenModel } from "./goal-loop-core.js";
|
|
10
|
+
import { appendLedger, isForbiddenModel } from "./goal-loop-core.js";
|
|
11
11
|
import { MAX_MAIN_MODEL_FALLBACKS, modelRef, normalizeMainModelFallbackRefs } from "./main-model-recovery.js";
|
|
12
12
|
import { ModelSelector } from "./model-selector.js";
|
|
13
13
|
import type { Settings } from "./goal-settings.js";
|
|
@@ -63,15 +63,22 @@ export function resolveDrafterModel(ctx: ExtensionContext, settings: Pick<Settin
|
|
|
63
63
|
getChain: () => configuredRefs,
|
|
64
64
|
resolve: (ref) => resolveDrafterModelRef(ctx, ref),
|
|
65
65
|
isForbidden: forbidden,
|
|
66
|
+
record: (event) => {
|
|
67
|
+
appendLedger(ctx.cwd, "model_fallback_select", {
|
|
68
|
+
scope: event.scope.kind,
|
|
69
|
+
fromRef: event.fromRef,
|
|
70
|
+
toRef: event.toRef,
|
|
71
|
+
reason: event.reason,
|
|
72
|
+
});
|
|
73
|
+
},
|
|
66
74
|
});
|
|
67
75
|
const attempted: string[] = [];
|
|
68
76
|
const candidates: DrafterModelCandidate[] = [];
|
|
69
77
|
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
// available if the first drafting turn fails.
|
|
78
|
+
// KEEP: drafting intentionally leases the current model when pinned (unlike
|
|
79
|
+
// Main which skips `current` via nextUntriedModelRef because it just failed).
|
|
80
|
+
// Align ledger to Main but keep this lease gate — removing it would force a
|
|
81
|
+
// needless setModel when the user pinned the drafter to the session model.
|
|
75
82
|
const configuredPrimary = configuredRefs[0];
|
|
76
83
|
if (
|
|
77
84
|
configuredPrimary &&
|
|
@@ -2023,8 +2023,8 @@ export function registerGoalRuntime(pi: ExtensionAPI): void {
|
|
|
2023
2023
|
// an interview must retry that chain before the main-goal recovery path;
|
|
2024
2024
|
// otherwise a drafting failure would silently consume main-model backups.
|
|
2025
2025
|
if (lastA?.stopReason === "error" && draftingTarget !== null) {
|
|
2026
|
-
const retryDrafting = (globalThis as any).handleDrafterModelFailure as ((context: ExtensionContext) => Promise<boolean>) | undefined;
|
|
2027
|
-
if (retryDrafting) await retryDrafting(ctx);
|
|
2026
|
+
const retryDrafting = (globalThis as any).handleDrafterModelFailure as ((context: ExtensionContext, error?: string) => Promise<boolean>) | undefined;
|
|
2027
|
+
if (retryDrafting) await retryDrafting(ctx, (rawLastA as any)?.errorMessage ?? (rawLastA as any)?.error ?? lastA.text);
|
|
2028
2028
|
// Whether a configured fallback was available or not, drafting owns
|
|
2029
2029
|
// this error. Leave the interview open for an explicit user retry and
|
|
2030
2030
|
// never pass the same failure into main-goal recovery.
|
|
@@ -904,6 +904,7 @@ export async function runDetachedCompletionWithFallback(
|
|
|
904
904
|
onFallback?: (from: AuditorModelCandidate, to: AuditorModelCandidate, error: string) => void;
|
|
905
905
|
forbiddenRefs?: readonly string[];
|
|
906
906
|
retryBaseMinutes?: number;
|
|
907
|
+
onSelection?: (event: { scope: { kind: string }; fromRef?: string; toRef?: string; reason: string }) => void;
|
|
907
908
|
} = {},
|
|
908
909
|
): Promise<{ result: DetachedAuditResult; retriedOnce: boolean; fallbackUsed: boolean; via: string }> {
|
|
909
910
|
return runAuditorFallbackWithPolicy(candidates, run, {
|
|
@@ -911,6 +912,7 @@ export async function runDetachedCompletionWithFallback(
|
|
|
911
912
|
shouldRetry: opts.shouldRetry,
|
|
912
913
|
sleep: opts.sleep,
|
|
913
914
|
retryBaseMinutes: opts.retryBaseMinutes,
|
|
915
|
+
onSelection: opts.onSelection,
|
|
914
916
|
resumeCandidateRef: opts.resumeCandidateRef,
|
|
915
917
|
attemptedRefs: opts.attemptedRefs,
|
|
916
918
|
retryCandidateRef: opts.retryCandidateRef,
|
|
@@ -1101,6 +1103,7 @@ async function retryStoredCompletionAudit(origin: CompletionAuditOrigin = "provi
|
|
|
1101
1103
|
shouldRetry: () => detachedAuditContext(generation, goalId, claim.attemptId!) !== null,
|
|
1102
1104
|
forbiddenRefs: settings.forbiddenModels,
|
|
1103
1105
|
retryBaseMinutes: settings.mainModelRetryMinutes,
|
|
1106
|
+
onSelection: (event: { scope: { kind: string }; fromRef?: string; toRef?: string; reason: string }) => appendLedger(liveCtx.cwd, "model_fallback_select", { scope: "auditor", fromRef: event.fromRef, toRef: event.toRef, reason: event.reason }),
|
|
1104
1107
|
resumeCandidateRef: persistedAuditorCandidateRef,
|
|
1105
1108
|
attemptedRefs: persistedAuditorAttemptedRefs,
|
|
1106
1109
|
retryCandidateRef: persistedAuditorRetryCandidateRef,
|
|
@@ -371,6 +371,7 @@ import {
|
|
|
371
371
|
resolveDrafterModel,
|
|
372
372
|
type DrafterModelCandidate,
|
|
373
373
|
} from "../drafter-model.js";
|
|
374
|
+
import { ModelSelector } from "../model-selector.js";
|
|
374
375
|
import {
|
|
375
376
|
assessSuspiciousObjective,
|
|
376
377
|
deriveObjectiveFromContract,
|
|
@@ -553,25 +554,57 @@ async function restoreDrafterModel(): Promise<void> {
|
|
|
553
554
|
}
|
|
554
555
|
|
|
555
556
|
/**
|
|
556
|
-
* Generic drafting recovery: walk the dedicated chain
|
|
557
|
-
*
|
|
558
|
-
*
|
|
557
|
+
* Generic drafting recovery: walk the dedicated chain via ModelSelector so
|
|
558
|
+
* forbidden/unregistered refs are skipped with the same ledger as Main,
|
|
559
|
+
* and provider retries use the bounded ladder (5s → base*2^(n-1) cap 5h).
|
|
560
|
+
* The session model remains the last resort; same-model lease is preserved.
|
|
559
561
|
*/
|
|
560
|
-
async function handleDrafterModelFailure(ctx: ExtensionContext): Promise<boolean> {
|
|
562
|
+
async function handleDrafterModelFailure(ctx: ExtensionContext, error?: string): Promise<boolean> {
|
|
561
563
|
const lease = draftingModelLease;
|
|
562
564
|
if (!lease || draftingTarget === null || lease.generation !== sessionGeneration || !extensionApi) return false;
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
565
|
+
const settings = loadSettings(ctx.cwd);
|
|
566
|
+
const failure = classifyMainModelFailure(error);
|
|
567
|
+
if (failure.kind === "non-recoverable") return false;
|
|
568
|
+
const configuredRefs = lease.candidates.filter((candidate) => candidate.via === "configured").map((candidate) => candidate.ref);
|
|
569
|
+
const selector = new ModelSelector({
|
|
570
|
+
getChain: () => configuredRefs,
|
|
571
|
+
resolve: (ref) => lease.candidates.find((candidate) => candidate.ref.toLowerCase() === ref.toLowerCase())?.model,
|
|
572
|
+
isForbidden: (ref) => isForbiddenModel(ref, settings.forbiddenModels),
|
|
573
|
+
record: (event) =>
|
|
574
|
+
appendLedger(ctx.cwd, "model_fallback_select", {
|
|
575
|
+
scope: "drafter",
|
|
576
|
+
fromRef: event.fromRef,
|
|
577
|
+
toRef: event.toRef,
|
|
578
|
+
reason: event.reason,
|
|
579
|
+
}),
|
|
580
|
+
});
|
|
581
|
+
let attempt = lease.attempted.length;
|
|
582
|
+
for (;;) {
|
|
583
|
+
const pick = selector.selectNextValid({ kind: "drafter" }, lease.activeRef, lease.attempted);
|
|
584
|
+
for (const visited of selector.lastVisitedRefs) {
|
|
585
|
+
if (!lease.attempted.some((ref) => ref.toLowerCase() === visited.toLowerCase())) lease.attempted.push(visited);
|
|
586
|
+
}
|
|
587
|
+
if (!("model" in pick)) break;
|
|
588
|
+
const delayMs = mainModelFailureDelayMs(failure, ++attempt, (settings as any).mainModelRetryMinutes ?? 15);
|
|
589
|
+
if (delayMs > 5_000) await new Promise<void>((resolve) => setTimeout(resolve, delayMs));
|
|
566
590
|
let switched = false;
|
|
567
|
-
try {
|
|
568
|
-
|
|
591
|
+
try {
|
|
592
|
+
switched = await extensionApi.setModel(pick.model);
|
|
593
|
+
} catch {
|
|
594
|
+
switched = false;
|
|
595
|
+
}
|
|
596
|
+
const alreadyActive = pick.ref.toLowerCase() === lease.activeRef.toLowerCase();
|
|
569
597
|
if (!switched && !alreadyActive) continue;
|
|
570
598
|
const previous = lease.activeRef;
|
|
571
|
-
lease.activeRef =
|
|
599
|
+
lease.activeRef = pick.ref;
|
|
572
600
|
lease.activeThinkingLevel = applyDrafterThinkingLevel(ctx, lease.requestedThinkingLevel);
|
|
573
|
-
appendLedger(ctx.cwd, alreadyActive ? "drafter_model_retry" : "drafter_model_fallback", {
|
|
574
|
-
|
|
601
|
+
appendLedger(ctx.cwd, alreadyActive ? "drafter_model_retry" : "drafter_model_fallback", {
|
|
602
|
+
from: previous,
|
|
603
|
+
to: pick.ref,
|
|
604
|
+
attempted: lease.attempted.slice(),
|
|
605
|
+
delayMs,
|
|
606
|
+
});
|
|
607
|
+
ctx.ui.notify(`Drafting provider failed; retrying the existing interview on ${pick.ref} after ${Math.round(delayMs / 1000)}s.`, "warning");
|
|
575
608
|
const safeSteer = (globalThis as any).safeSteerUser as ((context: ExtensionContext, text: string) => boolean) | undefined;
|
|
576
609
|
if (!safeSteer || !safeSteer(ctx, DRAFTER_RECOVERY_PROMPT)) return false;
|
|
577
610
|
draftingSeedInFlight = true;
|
|
@@ -554,9 +554,13 @@ export function resolveAuditorModel(
|
|
|
554
554
|
resolve: (candidate) => tryRef(candidate).model,
|
|
555
555
|
isForbidden: forbidden,
|
|
556
556
|
record: (event) => {
|
|
557
|
+
appendLedger(ctx.cwd, "model_fallback_select", {
|
|
558
|
+
scope: "auditor",
|
|
559
|
+
fromRef: event.fromRef,
|
|
560
|
+
toRef: event.toRef,
|
|
561
|
+
reason: event.reason,
|
|
562
|
+
});
|
|
557
563
|
if (event.reason === "forbidden" && event.toRef) {
|
|
558
|
-
// Forbidden is an explicit user gate, not an unavailable-model
|
|
559
|
-
// warning. Keep the forensic ledger entry but do not nudge the UI.
|
|
560
564
|
appendLedger(ctx.cwd, "auditor_model_fallback", { configured: event.toRef, reason: "forbidden" });
|
|
561
565
|
return;
|
|
562
566
|
}
|
|
@@ -1222,13 +1226,13 @@ export async function handleSettingChoice(id: string, ctx: ExtensionContext): Pr
|
|
|
1222
1226
|
const current = normalizeMainModelFallbackRefs(global.drafterModelFallbacks);
|
|
1223
1227
|
const refs = await promptModelRefs(
|
|
1224
1228
|
ctx,
|
|
1225
|
-
`Drafter fallback
|
|
1229
|
+
`Drafter fallback models (up to ${MAX_MAIN_MODEL_FALLBACKS}) — ordered; the session model is the last resort; forbidden models are hidden`,
|
|
1226
1230
|
current,
|
|
1227
1231
|
{ excludeRefs: normalizeModelRefs(loadSettings(ctx.cwd).forbiddenModels), maxSelections: MAX_MAIN_MODEL_FALLBACKS, currentRef: modelRef(ctx.model) },
|
|
1228
1232
|
);
|
|
1229
1233
|
if (refs === undefined) return;
|
|
1230
1234
|
saveSettings("global", ctx.cwd, { drafterModelFallbacks: refs.length ? refs : undefined });
|
|
1231
|
-
ctx.ui.notify(refs.length ? `Drafter fallback
|
|
1235
|
+
ctx.ui.notify(refs.length ? `Drafter fallback models saved: ${refs.join(" → ")}.` : "Drafter fallback models cleared — the session model remains the last resort.", "info");
|
|
1232
1236
|
return;
|
|
1233
1237
|
}
|
|
1234
1238
|
case "forbiddenModels": {
|
|
@@ -889,6 +889,7 @@ function registerAgentTools(pi: any): void {
|
|
|
889
889
|
shouldRetry: () => detachedAuditContext(auditGeneration, auditGoalId, auditAttemptId) !== null,
|
|
890
890
|
forbiddenRefs: settings.forbiddenModels,
|
|
891
891
|
retryBaseMinutes: settings.mainModelRetryMinutes,
|
|
892
|
+
onSelection: (event: { scope: { kind: string }; fromRef?: string; toRef?: string; reason: string }) => appendLedger(ctx.cwd, "model_fallback_select", { scope: "auditor", fromRef: event.fromRef, toRef: event.toRef, reason: event.reason }),
|
|
892
893
|
resumeCandidateRef: persistedAuditorCandidateRef,
|
|
893
894
|
attemptedRefs: persistedAuditorAttemptedRefs,
|
|
894
895
|
retryCandidateRef: persistedAuditorRetryCandidateRef,
|
|
@@ -322,12 +322,12 @@ export function buildSettingsRows(
|
|
|
322
322
|
{
|
|
323
323
|
id: "drafterModelFallbacks",
|
|
324
324
|
section: "drafter",
|
|
325
|
-
label:
|
|
325
|
+
label: `Drafter fallback models (up to ${MAX_MAIN_MODEL_FALLBACKS})`,
|
|
326
326
|
valueText: settings.drafterModelFallbacks?.length
|
|
327
|
-
?
|
|
328
|
-
:
|
|
327
|
+
? `${settings.drafterModelFallbacks.length}/${MAX_MAIN_MODEL_FALLBACKS} · ${settings.drafterModelFallbacks.map((ref, index) => `${index + 1}. ${modelThinkingText(ref, drafterThinking, subagent)}`).join(" → ")}`
|
|
328
|
+
: `0/${MAX_MAIN_MODEL_FALLBACKS} · ${sessionRef} · ${drafterThinking} (last resort)`,
|
|
329
329
|
sourceText: src("drafterModelFallbacks"),
|
|
330
|
-
description: "ordered
|
|
330
|
+
description: "ordered and deselectable: current drafter → fallback 1 → fallback 2…; every recoverable provider failure switches one eligible fallback at a time",
|
|
331
331
|
},
|
|
332
332
|
);
|
|
333
333
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-goal-list-loop-audit",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.1",
|
|
4
4
|
"description": "Mission control for autonomous pi: interview-drafted goals, an audited task queue, and forever-loops (metric, spec, project-audit) that run for hours. A detached extension-less auditor process re-verifies every completion with raw evidence without holding the main pi turn; confirmed drafts, decision pauses and consent gates keep you in charge.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"author": "dracon",
|