pi-goal-list-loop-audit 0.38.39 → 0.38.41

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 CHANGED
@@ -1,5 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.38.41 — grilling standard codified (2026-09-09)
4
+
5
+ ### Fixed
6
+
7
+ - **Questionnaire discipline is now GLLA behavior, not an agreement:** all three drafting prompts (`goal-loop-draft.md`, `goal-loop-forever-draft.md`, `goal-loop-plan.md`) carry the roadmap-then-stages rule (batch independent questions, sequence dependent ones with the roadmap stated first), the rich-option standard (concrete-consequence descriptions + preview pane where end-states matter, never padded to four), and the explicit Esc-correction invitation.
8
+ - **Pin test:** `tests/drafting-questionnaire.test.ts` (9 pins) fails if any prompt drops any part of the rule.
9
+
10
+ ### Verification
11
+
12
+ - New pin test green; full `release:check` 0 failures; `tsc --noEmit` clean.
13
+
14
+ ## 0.38.40 — provider overflow errors count as starvation (2026-09-09)
15
+
16
+ ### Fixed
17
+
18
+ - **PR #48 (Bjynt, merged):** `isContextStarvedLengthStop` now detects explicit provider context-overflow errors (`exceed_context_size_error`, `exceeds the available context size`, `context window exceeded`, …) arriving as `stopReason="error"`, firing the starvation ladder + emergency compactor (≥90% usage gate kept). Case 1 refactor is behavior-identical. Wiring confirmed live via the raw session message's `errorMessage`.
19
+ - Follow-up noted on the PR: OpenAI-style `maximum context length` wording still falls through the matcher set.
20
+
21
+ ### Verification
22
+
23
+ - Contributor's Case 2 tests + full `release:check` 0 failures; `tsc --noEmit` clean.
24
+
3
25
  ## 0.38.39 — Codex-like terminal summary (2026-09-09)
4
26
 
5
27
  ### 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.39 continue through the supervisor freeze (`/glla pause`),
21
+ v0.35.14–v0.38.41 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
@@ -46,6 +46,10 @@ export interface AssistantLengthMessageLike {
46
46
  usage?: {
47
47
  output?: number;
48
48
  };
49
+ /** Provider error message, when stopReason is "error". */
50
+ errorMessage?: string;
51
+ /** Error type from provider (e.g., "exceed_context_size_error"). */
52
+ errorType?: string;
49
53
  }
50
54
 
51
55
  export const LENGTH_CONTINUE_CONTEXT_STARVED_PERCENT = 90;
@@ -60,21 +64,49 @@ export const LENGTH_CONTINUE_CONTEXT_STARVED_MAX_OUTPUT = 8;
60
64
  * here queues another 1-token request before pi's post-agent_end compaction
61
65
  * check and delays the actual cure (field: darklord 2026-08-02, 198,116 /
62
66
  * 198,179 total tokens of a 200,000 window, output=1 twice).
67
+ *
68
+ * v0.38.36: also detect explicit context-overflow provider errors
69
+ * (e.g., "exceed_context_size_error", "exceeds the available context size")
70
+ * which arrive as stopReason="error" with an errorMessage, not as
71
+ * stopReason="length". These are also context starvation — the request
72
+ * exceeded the model's context window before generation could start.
63
73
  */
64
74
  export function isContextStarvedLengthStop(
65
75
  message: AssistantLengthMessageLike | null | undefined,
66
76
  contextUsage: ContextUsageLike | null | undefined,
67
77
  ): boolean {
68
- if (message?.stopReason !== "length") return false;
69
- const output = message.usage?.output;
70
- if (typeof output !== "number" || !Number.isFinite(output)) return false;
71
- if (output > LENGTH_CONTINUE_CONTEXT_STARVED_MAX_OUTPUT) return false;
72
- const percent = typeof contextUsage?.percent === "number"
73
- ? contextUsage.percent
74
- : typeof contextUsage?.tokens === "number" && typeof contextUsage?.contextWindow === "number" && contextUsage.contextWindow > 0
75
- ? (contextUsage.tokens / contextUsage.contextWindow) * 100
76
- : null;
77
- return percent !== null && Number.isFinite(percent) && percent >= LENGTH_CONTINUE_CONTEXT_STARVED_PERCENT;
78
+ // Case 1: pi's context-safety clamp (stopReason="length" with tiny output)
79
+ if (message?.stopReason === "length") {
80
+ const output = message.usage?.output;
81
+ if (typeof output === "number" && Number.isFinite(output) && output <= LENGTH_CONTINUE_CONTEXT_STARVED_MAX_OUTPUT) {
82
+ const percent = typeof contextUsage?.percent === "number"
83
+ ? contextUsage.percent
84
+ : typeof contextUsage?.tokens === "number" && typeof contextUsage?.contextWindow === "number" && contextUsage.contextWindow > 0
85
+ ? (contextUsage.tokens / contextUsage.contextWindow) * 100
86
+ : null;
87
+ return percent !== null && Number.isFinite(percent) && percent >= LENGTH_CONTINUE_CONTEXT_STARVED_PERCENT;
88
+ }
89
+ return false; // Real overlong response, not context starvation
90
+ }
91
+ // Case 2: explicit provider context-overflow error (stopReason="error")
92
+ if (message?.stopReason === "error") {
93
+ const errMsg = (message.errorMessage ?? message.errorType ?? "").toLowerCase();
94
+ if (
95
+ errMsg.includes("exceed_context_size") ||
96
+ errMsg.includes("exceeds the available context") ||
97
+ errMsg.includes("exceeds the context window") ||
98
+ (errMsg.includes("exceeds the model") && errMsg.includes("context")) ||
99
+ (errMsg.includes("context window") && errMsg.includes("exceed"))
100
+ ) {
101
+ const percent = typeof contextUsage?.percent === "number"
102
+ ? contextUsage.percent
103
+ : typeof contextUsage?.tokens === "number" && typeof contextUsage?.contextWindow === "number" && contextUsage.contextWindow > 0
104
+ ? (contextUsage.tokens / contextUsage.contextWindow) * 100
105
+ : null;
106
+ return percent !== null && Number.isFinite(percent) && percent >= LENGTH_CONTINUE_CONTEXT_STARVED_PERCENT;
107
+ }
108
+ }
109
+ return false;
78
110
  }
79
111
 
80
112
  export function makeLengthContinueTracker(max: number = LENGTH_CONTINUE_MAX) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-goal-list-loop-audit",
3
- "version": "0.38.39",
3
+ "version": "0.38.41",
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",
@@ -78,6 +78,14 @@ request into a **confirmed goal contract**. Do NOT start substantive work yet.
78
78
  If an `ask_user_question` tool is available in this session, prefer it for
79
79
  structured choices (it renders proper option lists); plain conversation is
80
80
  fine otherwise and for free-form answers.
81
+ **Questionnaire discipline — roadmap, then stages:** batch independent
82
+ questions upfront in one `ask_user_question` call; when a later question
83
+ depends on an earlier answer, state the full roadmap first, then ask
84
+ stage-by-stage so every option makes sense when answered. Every option
85
+ description states its concrete consequence, plus a preview pane wherever
86
+ what the option produces matters — two honest options beat four padded
87
+ guesses. Close every batch by inviting correction: if any of this is off,
88
+ Esc and say what's wrong, and you re-ask.
81
89
  2. Targeted read-only research is allowed when it helps define a better
82
90
  contract (read a file, check the repo layout). Do NOT implement anything.
83
91
  **Default to subagents for research**: use the `subagent` tool to spawn a `scout` subagent
@@ -56,6 +56,15 @@ stops it.
56
56
  genuinely endless (an ever-improving spec, continuous hardening).
57
57
  3. Clarify the **direction**: is lower better (min) or higher better (max)?
58
58
  (Skip this for a metricless loop — there is no direction without a metric.)
59
+ **Questionnaire discipline — roadmap, then stages:** batch independent
60
+ questions upfront in one `ask_user_question` call; when a later question
61
+ depends on an earlier answer (bounds depend on the metric, metricless
62
+ depends on no-number), state the full roadmap first, then ask
63
+ stage-by-stage so every option makes sense when answered. Every option
64
+ description states its concrete consequence, plus a preview pane wherever
65
+ what the option produces matters — two honest options beat four padded
66
+ guesses. Close every batch by inviting correction: if any of this is off,
67
+ Esc and say what's wrong, and you re-ask.
59
68
  4. Optional tuning: `window` (plateau stop after N non-improving iterations,
60
69
  default 5 — meaningless for metricless), `max` (iteration cap: default 50
61
70
  for METRIC loops; default UNBOUNDED (`max=0`) for metricless loops,
@@ -27,7 +27,14 @@ confirms.
27
27
  - **Verification strategy** — how each milestone proves itself done.
28
28
  Ask one focused question at a time within a round; offer a recommended
29
29
  default with each question so the user can answer "yes". Prefer
30
- `ask_user_question` for structured choices when available.
30
+ `ask_user_question` for structured choices when available. The rounds
31
+ ARE the stages: state the full round roadmap first, then work it
32
+ round-by-round (later rounds depend on earlier answers — never batch a
33
+ later round's questions upfront). Every option description states its
34
+ concrete consequence, plus a preview pane wherever what the option
35
+ produces matters — two honest options beat four padded guesses. Close
36
+ every round by inviting correction: if any of this is off, Esc and say
37
+ what's wrong, and you re-ask.
31
38
  3. **The proposal is a structured expanded objective.** Use this shape
32
39
  inside the objective text:
33
40
  - **Current state** — what exists today, with file/module references.