@osovv/vv-opencode 1.4.2 → 1.4.3-rc.0

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +12 -4
  3. package/dist/lib/orchestration.js +8 -3
  4. package/dist/lib/orchestration.js.map +1 -1
  5. package/dist/plugins/system-context-injection/index.js +7 -7
  6. package/dist/plugins/system-context-injection/index.js.map +1 -1
  7. package/dist/plugins/workflow/checkpoints.d.ts +53 -1
  8. package/dist/plugins/workflow/checkpoints.js +350 -33
  9. package/dist/plugins/workflow/checkpoints.js.map +1 -1
  10. package/dist/plugins/workflow/delegated.d.ts +144 -2
  11. package/dist/plugins/workflow/delegated.js +542 -12
  12. package/dist/plugins/workflow/delegated.js.map +1 -1
  13. package/dist/plugins/workflow/index.js +265 -19
  14. package/dist/plugins/workflow/index.js.map +1 -1
  15. package/dist/plugins/workflow/persistence.d.ts +6 -4
  16. package/dist/plugins/workflow/persistence.js +192 -31
  17. package/dist/plugins/workflow/persistence.js.map +1 -1
  18. package/dist/plugins/workflow/repair.d.ts +2 -0
  19. package/dist/plugins/workflow/repair.js +16 -8
  20. package/dist/plugins/workflow/repair.js.map +1 -1
  21. package/dist/plugins/workflow/state.js +16 -3
  22. package/dist/plugins/workflow/state.js.map +1 -1
  23. package/dist/plugins/workflow/tooling.d.ts +36 -6
  24. package/dist/plugins/workflow/tooling.js +137 -20
  25. package/dist/plugins/workflow/tooling.js.map +1 -1
  26. package/package.json +1 -1
  27. package/schemas/vvoc/v3.json +1 -1
  28. package/templates/agents/vv-code-reviewer.md +1 -0
  29. package/templates/agents/vv-controller.md +14 -6
  30. package/templates/agents/vv-implementer.md +1 -0
  31. package/templates/agents/vv-spec-reviewer.md +1 -0
  32. package/templates/skills/vv-execute/SKILL.md +5 -4
  33. package/templates/skills/vv-review/SKILL.md +1 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## <small>1.4.3-rc.0 (2026-09-12)</small>
2
+
3
+ ### Summary
4
+
5
+ This release makes delegated workflow execution recoverable instead of dead-ending: tasks and checkpoint review cycles that stop or exhaust their ordinary budgets can now resume through a bounded, explicitly recorded recovery operation, with one autonomous grant per target and any further unit requiring a fresh root-user message that the runtime validates for role, session identity, and timing. A worker whose report stays protocol-invalid is now settled truthfully as a rejected report with bounded diagnostics rather than appearing permanently in flight, while observed hard stops are preserved and never converted into success. Persistence advances to version 3, adding recovery and rejected-report records while conservatively loading older snapshots, and recovery changes are written durably before new launch permissions appear. Managed controller, worker, and reviewer prompts were also recalibrated to distinguish stops, recovery, and completion, reserve handoff files for genuine transfers, and scope re-reviews to prior findings and the fix's effects — so users get clearer guidance and fewer unnecessary dead ends without weakening mandatory review.
6
+
7
+ * feat(workflow): add bounded recovery, report-rejection settlement, and calibrated prompts ([f5fa9d3](https://github.com/osovv/vv-opencode/commit/f5fa9d3))
8
+
1
9
  ## <small>1.4.2 (2026-09-11)</small>
2
10
 
3
11
  ### Summary
package/README.md CHANGED
@@ -408,7 +408,7 @@ Four concrete policies control how vv-controller delegates work at runtime:
408
408
  - `single-session` — vv-controller performs exploration, investigation, planning, implementation, and verification directly. Independent reviewer subagents remain available when the user explicitly requests review or when a materially risky completed change benefits from independent cross-model evaluation.
409
409
  - `balanced` — vv-controller keeps architecture, critical reading, and final synthesis in the primary session and may selectively delegate bounded search, investigation, mechanical implementation, or review when that is the lightest safe route. Delegation is optional, not mechanically mandatory.
410
410
  - `orchestrated` — vv-controller uses the full tracked implementer/reviewer workflow with explicit work items, required reviewers, bounded rounds, and hard stops.
411
- - `delegated` — implementation is delegated to workers while the primary session keeps architecture, important code reading, task contracts, explicit acceptance, and final synthesis. Source edits, tests, config changes, formatting, lint fixes, and reviewer-requested fixes — including small mechanical ones — go to workers through bounded task packets. Independent review happens at declared plan checkpoints instead of after every task; `BLOCKED` and `NEEDS_CONTEXT` remain hard stops.
411
+ - `delegated` — implementation is delegated to workers while the primary session keeps architecture, important code reading, task contracts, explicit acceptance, and final synthesis. Source edits, tests, config changes, formatting, lint fixes, and reviewer-requested fixes — including small mechanical ones — go to workers through bounded task packets. Independent review happens at declared plan checkpoints instead of after every task; `BLOCKED` and `NEEDS_CONTEXT` remain hard stops, and stopped or exhausted work resumes only through recorded bounded recovery.
412
412
 
413
413
  Pick a profile explicitly or let a built-in preset select one:
414
414
 
@@ -464,20 +464,28 @@ Delegated tasks are opened with `"mode": "delegated"`, an explicitly empty `requ
464
464
  - `accept` (with rationale and evidence references) records controller acceptance and reaches `ready_to_close`. Acceptance is recorded distinctly from an independent reviewer `PASS`.
465
465
  - `request_changes` returns the task to the implementation path. Controller-directed retries are bounded to an initial attempt plus one correction; re-deciding or reopening never resets that budget. `DONE_WITH_CONCERNS` requires an explicit `concernsDisposition`.
466
466
  - `rework` reopens an accepted task only when a failed checkpoint from the same registered run covers it, preserving acceptance history and granting exactly one additional attempt.
467
+ - `recover` resumes a stopped or exhausted unaccepted task without resetting history. Recovery targets the latest terminal attempt and requires an explicit `diagnosis`, a `changedCondition` (the changed condition or approach), `verification` references, and a stable `recoveryId`. When ordinary budget remains, recovery simply returns a stopped item to the launch gate; when an extra attempt is necessary, it grants exactly one. The first grant per target is the single autonomous allowance; every further unit requires a fresh root-user message referenced by `userMessageId`, which the runtime validates for role, owning-session identity, message identity, and a timestamp at or after the stop — never for its wording — and each message authorizes at most one unit per target. A successful recovery authorization only makes the next bounded attempt possible: it is not a successful implementation, not acceptance, and never satisfies a reviewer.
468
+
469
+ Worker stops stay hard stops for ordinary dispatch: a `BLOCKED` or `NEEDS_CONTEXT` result is never re-launched directly, and its recorded outcome and explanation remain historical facts. The same applies to an exhausted budget — an ordinary third launch is refused until a recorded recovery raises it. Accepted items are not recovery targets; their path is checkpoint-authorized rework.
467
470
 
468
471
  A worker can fail to launch at all: the host task wrapper rejects the call before the worker runs (for example, an unknown provider or model). The host skips the `tool.execute.after` hook on a thrown execution, so the plugin consumes the failure as a distinct **failed attempt** from the live call binding instead of leaving `inFlightAttempt` stranded until a restart. The supported case is deliberately narrow — a fresh ordinary foreground `vv-implementer` task launch (no `background`, no `task_id` resume, no command/subtask path) whose host call errors with the exact `Subagent failed (task_id: <child>): ` wrapper, where the event metadata independently binds the same parent session and child session. When it applies, the attempt is marked `failed` with the bounded host error as evidence and a completion time, the item stays `awaiting_implementer`, and the attempt is charged against the same two-attempt budget. The controller can then explicitly retry with a new call; two failed attempts exhaust the normal budget exactly like two completed ones. A failed attempt never counts as `DONE`, cannot be accepted or decided as a successful completion, and persists across restart. Because a worker may have applied partial edits before failing, inspect the diff before retrying or closing.
469
472
 
470
473
  This is not universal automatic error recovery. Background or promoted launches, resumed/shared/re-prompted children, cancellation or interruption, any task that entered the `tool.execute.after` hook (including a protocol/repair failure there), missing or mismatched parent/child metadata, and unknown or non-wrapper host errors all remain fail-closed: the in-flight block is preserved and no retry is authorized from the event alone. The plugin never hydrates workflow state, infers a work item from error text, or resets a whole session because of an error event, and it does not reclassify legacy-mode or checkpoint-reviewer launches.
471
474
 
475
+ A worker whose execution finishes but whose final report stays protocol-invalid after the bounded continuation is settled truthfully as a **rejected report**: the exact call-bound attempt is recorded as a completed execution with status `report_rejected`, a bounded diagnostic excerpt, and the protocol error code — never as `DONE`, never as a launch failure, and never as a still-in-flight attempt. When the malformed output contains an explicit `VVOC_STATUS: BLOCKED` or `NEEDS_CONTEXT` line, the observed stop is preserved (the item parks in the corresponding hard-stop state) and no continuation runs; otherwise the item returns to the launch gate with the attempt consumed. A rejected report has the same bounded recovery path as any other terminal outcome, and `work_item_list` distinguishes it from a running attempt, an exhausted budget, and a substantive stop by exposing the remaining budget and the supported next action. Unknown or still-running host outcomes (for example a non-string task output) are never guessed terminal and cannot clear a live attempt.
476
+
472
477
  When a tracked subagent returns a recognized task envelope whose inner result is malformed for the strict protocol — a missing `VVOC_STATUS`, a missing `VVOC_ROUTE`, a non-protocol top-block line, or body text without the required blank line — the plugin makes at most one bounded continuation to that same child session. The continuation request carries no `tools` override (so the child's persisted session permissions are preserved), and its instructions direct the child to preserve the original work item, assignment, role, and write scope; to finish unfinished work with its existing history and currently permitted tools; or, if the work was already complete, to correct only the final report without repeating work or inventing evidence; and to report a truthful post-continuation `VVOC_STATUS`/`VVOC_ROUTE` rather than freezing an outdated one. These are instructions to the model, not a mechanical guarantee of compliance: the plugin still reparses the continued output strictly, applies the bounded error-code and explicit-hard-stop gates, and fails closed with the original protocol error and excerpt. Continuation is attempted only once; a valid result never continues, and a failed, empty, or still-malformed continuation is never retried. An explicit `VVOC_STATUS: BLOCKED` or `NEEDS_CONTEXT` line is detected before the call, so malformed hard-stop output fails closed through the original protocol error and excerpt instead of being continued.
473
478
 
474
- Independent review happens at checkpoints declared in the plan. An approved delegated plan carries an `<execution><mode>delegated</mode>` section with `<review_checkpoints>` (`CHECKPOINT-R-NNN` identities, each with kind, wave barrier, covered tasks, reviewed scope files, reviewer set, acceptance criteria, and verification commands) and per-task `<write_scope>` lists. `work_checkpoint` handles three actions:
479
+ Independent review happens at checkpoints declared in the plan. An approved delegated plan carries an `<execution><mode>delegated</mode>` section with `<review_checkpoints>` (`CHECKPOINT-R-NNN` identities, each with kind, wave barrier, covered tasks, reviewed scope files, reviewer set, acceptance criteria, and verification commands) and per-task `<write_scope>` lists. Registration accepts only this supported approved native plan package (the approved spec and plan pair under `.vvoc/specs/`); foreign lifecycle plan formats are not convertible into it. `work_checkpoint` handles four actions:
475
480
 
476
481
  - `register` — loads an approved active plan plus its linked approved spec, fully lints them, and binds the run to their content hashes and the canonical workspace root. Re-registering identical inputs is idempotent; changed approved inputs are explicit plan drift, never a progress reset.
477
482
  - `start` — after every covered task is accepted, captures a SHA-256 fingerprint over the checkpoint scope (file contents, existence, mode bits, and covered accepted attempts) and opens exactly the declared reviewer set as an ordinary `review_only` item. Writes overlapping an in-flight checkpoint scope are refused.
478
- - `verify` — derives `passed`, `failed`, `stale`, or `stopped` from the recorded reviewer results plus freshly recomputed fingerprints and approval hashes. A checkpoint passes only when every declared reviewer passes for the pinned snapshot; a closed review-only `FAIL` report is findings, not approval; edits during review make the generation stale. The final checkpoint seals the run only via `verify` with `complete: true` after every task is accepted, every earlier checkpoint passed, and the complete declared write scope is covered with fresh verification.
483
+ - `verify` — derives `passed`, `failed`, `stale`, or `stopped` from the recorded reviewer results plus freshly recomputed fingerprints and approval hashes. A checkpoint passes only when every declared reviewer passes for the pinned snapshot; a closed review-only `FAIL` report is findings, not approval; edits during review make the generation stale. The final checkpoint seals the run only via `verify` with `complete: true` after every task is accepted, every earlier checkpoint passed, and the complete declared write scope is covered with fresh verification. Completion is refused while a declared reviewer is missing: a skipped reviewer is never fabricated into a pass.
484
+ - `recover` — bounded recovery for a checkpoint generation that stopped (`NEEDS_CONTEXT`) or exhausted its two ordinary generations. Recovery takes the same `diagnosis`, `changedCondition`, `verification`, `recoveryId`, and optional `userMessageId` fields as task recovery, with the same one-unit autonomous-then-user-authorized policy per checkpoint. Recovering a stopped generation settles it into history as a `stopped` entry — it does not convert the stop into a failure, so checkpoint rework stays locked until a real failed generation exists — and recovering an exhausted checkpoint grants exactly one further generation with a fresh snapshot at the next `start`. Recovery never satisfies prerequisites, erases a `FAIL`, or seals a run: only the required passing final review does.
485
+
486
+ Passed milestones stay historical: later planned edits are covered by later checkpoints or the final gate, not by an old approval. Hard stops (`BLOCKED`, `NEEDS_CONTEXT`) are never reset or bypassed by acceptance or checkpoint handling; only a separately recorded recovery decision resumes the affected work. Checkpoint state persists per session and survives restarts; a persisted `PASS` is not fresh evidence until `verify` recomputes current hashes.
479
487
 
480
- Passed milestones stay historical: later planned edits are covered by later checkpoints or the final gate, not by an old approval. Hard stops (`BLOCKED`, `NEEDS_CONTEXT`) are never reset or bypassed by acceptance or checkpoint handling. Checkpoint state persists per session and survives restarts; a persisted `PASS` is not fresh evidence until `verify` recomputes current hashes.
488
+ Delegated and checkpoint state persists under `$XDG_DATA_HOME/vvoc/workflow/<sessionId>/workflow-state.json` at snapshot version 3, which adds recovery histories, replay-protected authorization references, recovery-aware budgets, and rejected-report attempts. Older supported snapshots load conservatively: version 2 files hydrate with empty recovery histories and their original budgets, and version 1 files hydrate as legacy records without plan runs; neither ever synthesizes acceptance, approval, or recovery. A snapshot written by a newer plugin version is refused rather than reset. Recovery mutations commit on the live store and persist synchronously — a failed write rolls the mutation back, so changed launch permissions appear only after a durable record; terminal report settlements stage, persist, and then commit. Because runtime plugins share the startup config snapshot, a plugin upgrade takes effect after an OpenCode restart.
481
489
 
482
490
  Plans without an `<execution>` section keep their legacy meaning; executing them with different acceptance or review obligations requires an explicit agreed plan amendment, and archived plans are never rewritten. In a deterministic dispatch-count scenario, a twenty-task plan with two intermediate code-review checkpoints and one final spec+code checkpoint needs exactly four initial reviewer launches instead of forty — that is a property of the declared checkpoint policy, not a wall-clock or model-quality benchmark.
483
491
 
@@ -21,7 +21,7 @@
21
21
  // END_MODULE_MAP
22
22
  //
23
23
  // START_CHANGE_SUMMARY
24
- // LAST_CHANGE: [C-DELEGATED-WORKFLOW-ASTRA-PRESETS - Added the delegated profile with worker-owned implementation, controller acceptance, and checkpoint review guidance.]
24
+ // LAST_CHANGE: [C-WORKFLOW-BOUNDED-RECOVERY-R1 - Calibrated the delegated policy: worker stops are bounded diagnosis and recovery targets rather than session ends, recovery is distinct from acceptance, and checkpoint registration states its native plan boundary.]
25
25
  // END_CHANGE_SUMMARY
26
26
  // START_BLOCK_PROFILE_TYPES
27
27
  /** Supported orchestration profiles in stable CLI/schema order. */
@@ -67,14 +67,19 @@ You may author specifications, plans, and explicitly requested planning artifact
67
67
  existing approval lifecycle, and you may execute verification commands, including commands that
68
68
  produce ordinary generated verification or build outputs. Do not write complete implementation
69
69
  bodies inside task packets and do not bypass the delegation policy by rewriting source through
70
- shell commands.
70
+ shell commands. work_checkpoint registration accepts only its supported approved native plan
71
+ package (the approved spec and plan pair under .vvoc/specs/); foreign lifecycle plans are not
72
+ convertible into it.
71
73
 
72
74
  Send each worker one bounded task packet and let it complete its local edit, test, and fix cycle
73
75
  before reporting a concise result with evidence references. One active implementation worker is the
74
76
  default; any parallel work requires explicitly disjoint approved scopes. Read the material changed
75
77
  code and evidence yourself, then explicitly accept each completed attempt or request changes with
76
78
  bounded rationale. Spend independent review at declared plan checkpoints instead of after every
77
- task, and treat BLOCKED and NEEDS_CONTEXT as hard stops.
79
+ task, and treat BLOCKED and NEEDS_CONTEXT as hard stops: diagnose a stopped or exhausted task
80
+ yourself and recover it through the session's supported recovery operation — bounded, one unit per
81
+ grant, never an unlimited retry and never a substitute for acceptance or review. A stop suspends
82
+ that work item; it does not end the session.
78
83
  `.trim();
79
84
  const RESOLVED_POLICIES = Object.freeze({
80
85
  "single-session": Object.freeze({
@@ -1 +1 @@
1
- {"version":3,"file":"orchestration.js","sourceRoot":"","sources":["../../src/lib/orchestration.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,iBAAiB;AACjB,wBAAwB;AACxB,yIAAyI;AACzI,yHAAyH;AACzH,oBAAoB;AACpB,kEAAkE;AAClE,kBAAkB;AAClB,sBAAsB;AACtB,sBAAsB;AACtB,EAAE;AACF,mBAAmB;AACnB,0FAA0F;AAC1F,6DAA6D;AAC7D,yEAAyE;AACzE,iGAAiG;AACjG,4FAA4F;AAC5F,0GAA0G;AAC1G,2FAA2F;AAC3F,sGAAsG;AACtG,iBAAiB;AACjB,EAAE;AACF,uBAAuB;AACvB,6KAA6K;AAC7K,qBAAqB;AAErB,4BAA4B;AAC5B,mEAAmE;AACnE,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,gBAAgB;IAChB,UAAU;IACV,cAAc;IACd,WAAW;CACH,CAAC;AAiBX,0FAA0F;AAC1F,MAAM,CAAC,MAAM,6BAA6B,GAAyB,UAAU,CAAC;AAC9E,0BAA0B;AAE1B,gCAAgC;AAChC,MAAM,wCAAwC,GAAG;;;;;;;;;CAShD,CAAC,IAAI,EAAE,CAAC;AAET,MAAM,kCAAkC,GAAG;;;;;CAK1C,CAAC,IAAI,EAAE,C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AAChC,MAAM,UAAU,0BAA0B,CAAC,MAE1C;IACC,MAAM,EAAE,OAAO,EAAE,GAAG,yBAAyB,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IACpE,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC;AACpC,CAAC;AACD,8BAA8B"}
@@ -1,8 +1,8 @@
1
1
  // FILE: src/plugins/system-context-injection/index.ts
2
- // VERSION: 0.4.2
2
+ // VERSION: 0.5.0
3
3
  // START_MODULE_CONTRACT
4
4
  // PURPOSE: Inject universal primary guidance, including correctness obligations for behavior changes, and one startup-resolved concrete orchestration policy into vv-controller without polluting subagent prompts.
5
- // SCOPE: Universal instructions with correctness obligations, vv-controller policy selection, explore-worker guidance, known subagent filtering, startup vvoc snapshot use, custom subagent tracking, and chat.message injection.
5
+ // SCOPE: Universal instructions with correctness obligations and material-assumption discipline, vv-controller policy selection, explore-worker guidance, known subagent filtering, startup vvoc snapshot use, custom subagent tracking, and chat.message injection.
6
6
  // DEPENDS: [@opencode-ai/plugin, src/lib/config-layers.ts, src/lib/managed-agents.ts, src/lib/orchestration.ts, src/lib/vvoc-paths.ts]
7
7
  // LINKS: [M-PLUGIN-SYSTEM-CONTEXT-INJECTION, M-ORCHESTRATION-PROFILES, M-CLI-MANAGED-AGENTS]
8
8
  // ROLE: RUNTIME
@@ -14,7 +14,7 @@
14
14
  // END_MODULE_MAP
15
15
  //
16
16
  // START_CHANGE_SUMMARY
17
- // LAST_CHANGE: [C-CORRECTNESS-OBLIGATIONS-PROMPTS - Added the correctness_obligations universal block: preserved properties, write/impact/verification scope separation, diagnostic counterexamples, and evidence-based acceptance.]
17
+ // LAST_CHANGE: [C-WORKFLOW-BOUNDED-RECOVERY-R1 - Removed mandatory per-claim reasoning labels and the restatement ritual while retaining material-assumption discipline, repository-answerable question resolution, proportional verification, and honest uncertainty.]
18
18
  // END_CHANGE_SUMMARY
19
19
  import { loadVvocConfig } from "../../lib/config-layers.js";
20
20
  import { MANAGED_SUBAGENT_NAMES } from "../../lib/managed-agents.js";
@@ -41,10 +41,10 @@ const UNIVERSAL_PRIMARY_SYSTEM_CONTEXTS = [
41
41
  "<assumption_discipline>",
42
42
  "Do not make silent material assumptions.",
43
43
  "A material assumption is one that affects behavior, scope, API shape, schema, UX, data meaning, or verification.",
44
- "If a material assumption is necessary, state it explicitly.",
44
+ "If a material assumption is necessary, state it explicitly and carry its effect into the result report.",
45
45
  "If a material assumption later becomes false, stop and reroute.",
46
- "Mark each claim in internal reasoning: `✓` verified (name what verified it), `?` asserted-but-unchecked, `✗` refuted (name the evidence).",
47
- "An unmarked claim counts as `?`, and a `?` may not become a downstream premise until verified.",
46
+ "Resolve repository-answerable technical questions from the established code, contracts, and tests yourself; only a genuine business-semantics fork needs a user decision.",
47
+ "Report honest residual uncertainty: an unverified material condition is named as unverified, never presented as a passed check.",
48
48
  "</assumption_discipline>",
49
49
  ].join("\n"),
50
50
  [
@@ -59,7 +59,7 @@ const UNIVERSAL_PRIMARY_SYSTEM_CONTEXTS = [
59
59
  [
60
60
  "<working_state>",
61
61
  "For non-trivial work, stabilize a compact working state before acting: goal, current route, constraints, non-goals when relevant, assumptions, verification target, current unknown, and reroute if.",
62
- "Before acting, restate the requirement in one line in your own words and check it against the original; a constraint dropped here wastes the downstream chain.",
62
+ "Check that state against the original request before and while acting; a constraint dropped early wastes the downstream chain.",
63
63
  "Keep it compact and revise it when evidence changes.",
64
64
  "Surface it explicitly when blocked, rerouting, or handing off to the user.",
65
65
  "</working_state>",
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/system-context-injection/index.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,iBAAiB;AACjB,wBAAwB;AACxB,sNAAsN;AACtN,oOAAoO;AACpO,yIAAyI;AACzI,+FAA+F;AAC/F,kBAAkB;AAClB,sBAAsB;AACtB,sBAAsB;AACtB,EAAE;AACF,mBAAmB;AACnB,0HAA0H;AAC1H,iBAAiB;AACjB,EAAE;AAC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;AACF,yBAAyB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/system-context-injection/index.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,iBAAiB;AACjB,wBAAwB;AACxB,sNAAsN;AACtN,uQAAuQ;AACvQ,yIAAyI;AACzI,+FAA+F;AAC/F,kBAAkB;AAClB,sBAAsB;AACtB,sBAAsB;AACtB,EAAE;AACF,mBAAmB;AACnB,0HAA0H;AAC1H,iBAAiB;AACjB,EAAE;AACF,uBAAuB;AACvB,0QAA0Q;AAC1Q,qBAAqB;AAGrB,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,0BAA0B,GAE3B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EACL,0BAA0B,EAC1B,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,kBAAkB,GAAG,CAAC,SAAS,CAAU,CAAC;AAChD,MAAM,wBAAwB,GAAG,CAAC,UAAU,CAAU,CAAC;AACvD,MAAM,uBAAuB,GAAG,CAAC,YAAY,EAAE,OAAO,EAAE,SAAS,CAAU,CAAC;AAC5E,MAAM,8BAA8B,GAAG,EAAW,CAAC;AACnD,MAAM,gBAAgB,GAAG,SAAkB,CAAC;AAC5C,MAAM,mBAAmB,GAAG,eAAwB,CAAC;AAErD,MAAM,iCAAiC,GAAG;IACxC;QACE,uBAAuB;QACvB,qEAAqE;QACrE,iFAAiF;QACjF,6HAA6H;QAC7H,kFAAkF;QAClF,wBAAwB;KACzB,CAAC,IAAI,CAAC,IAAI,CAAC;IACZ;QACE,yBAAyB;QACzB,0CAA0C;QAC1C,kHAAkH;QAClH,yGAAyG;QACzG,iEAAiE;QACjE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I,CAAC,oBAAoB,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,cAAc,CAAC,EAAE,CAAC;gBAChE,OAAO;YACT,CAAC;YAED,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,oBAAoB,CAC1C,MAAM,CAAC,OAAO,CAAC,MAAM,EACrB,yBAAyB,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CACxD,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AACF,yBAAyB"}
@@ -1,5 +1,6 @@
1
1
  import type { DelegatedPlanDefinition, DelegatedReviewer } from "../../lib/spec-lint.js";
2
2
  import { type LoadedDelegatedPlan } from "./checkpoint-io.js";
3
+ import { type DelegatedRecoveryKind, type LookupRecoveryUserMessage } from "./delegated.js";
3
4
  import { type WorkItemStore, type WorkItemStoreData } from "./state.js";
4
5
  export declare const MAX_CHECKPOINT_REVIEW_ATTEMPTS = 2;
5
6
  export interface DelegatedReviewerOutcome {
@@ -17,10 +18,25 @@ export interface DelegatedCheckpointReview {
17
18
  }
18
19
  export interface DelegatedCheckpointHistoryEntry {
19
20
  generation: number;
20
- outcome: "passed" | "failed" | "stale";
21
+ outcome: "passed" | "failed" | "stale" | "stopped";
21
22
  fingerprint: string;
22
23
  completedAt: string;
23
24
  }
25
+ /**
26
+ * One bounded checkpoint recovery event. `resume` settles a stopped
27
+ * generation without manufacturing budget; grant kinds add exactly one
28
+ * generation each and stay replay-protected by recoveryId and userMessageId.
29
+ */
30
+ export interface DelegatedCheckpointRecoveryRecord {
31
+ recoveryId: string;
32
+ targetGeneration: number;
33
+ kind: DelegatedRecoveryKind;
34
+ diagnosis: string;
35
+ changedCondition: string;
36
+ verification: string[];
37
+ recoveredAt: string;
38
+ userMessageId?: string;
39
+ }
24
40
  export interface DelegatedRunCheckpoint {
25
41
  checkpointId: string;
26
42
  kind: "milestone" | "final";
@@ -33,6 +49,7 @@ export interface DelegatedRunCheckpoint {
33
49
  lastOutcome?: "passed" | "failed" | "stale" | "stopped" | "incomplete";
34
50
  currentReview?: DelegatedCheckpointReview;
35
51
  history: DelegatedCheckpointHistoryEntry[];
52
+ recoveryHistory: DelegatedCheckpointRecoveryRecord[];
36
53
  }
37
54
  export interface DelegatedRunTask {
38
55
  taskId: string;
@@ -54,6 +71,14 @@ export interface DelegatedPlanRun {
54
71
  tasks: Map<string, DelegatedRunTask>;
55
72
  checkpoints: Map<string, DelegatedRunCheckpoint>;
56
73
  }
74
+ /** Deep clone of one registered run for staged persistence commits. */
75
+ export declare function cloneDelegatedPlanRun(run: DelegatedPlanRun): DelegatedPlanRun;
76
+ /** Count of budget-granting checkpoint recovery entries. */
77
+ export declare function checkpointRecoveryGrantCount(history: readonly DelegatedCheckpointRecoveryRecord[]): number;
78
+ /** Allowed generation count: the ordinary maximum plus one per recovery grant. */
79
+ export declare function checkpointGenerationBudget(checkpoint: DelegatedRunCheckpoint): number;
80
+ /** Whether the single autonomous checkpoint grant is already recorded. */
81
+ export declare function checkpointAutonomousGrantConsumed(history: readonly DelegatedCheckpointRecoveryRecord[]): boolean;
57
82
  export type RegisterDelegatedPlanResult = {
58
83
  ok: true;
59
84
  runId: string;
@@ -168,6 +193,33 @@ export interface AuthorizeReworkInput {
168
193
  }
169
194
  export declare function authorizeReworkFromFailedCheckpoint(store: WorkItemStore, input: AuthorizeReworkInput): AuthorizeReworkResult;
170
195
  export declare function authorizeReworkFromFailedCheckpointInStore(data: WorkItemStoreData, input: AuthorizeReworkInput): AuthorizeReworkResult;
196
+ export type RecoverDelegatedCheckpointResult = {
197
+ ok: true;
198
+ checkpoint: DelegatedRunCheckpoint;
199
+ recoveryId: string;
200
+ kind: DelegatedRecoveryKind;
201
+ generationBudget: number;
202
+ settledStoppedGeneration?: number;
203
+ } | {
204
+ ok: false;
205
+ errorCode: "RUN_NOT_FOUND" | "SESSION_MISMATCH" | "CHECKPOINT_NOT_FOUND" | "RUN_SEALED" | "ALREADY_PASSED" | "INVALID_TARGET_STATE" | "DUPLICATE_RECOVERY_ID" | "INVALID_INPUT" | "AUTONOMOUS_GRANT_EXHAUSTED" | "AUTHORIZATION_LOOKUP_FAILED" | "AUTHORIZATION_NOT_FOUND" | "AUTHORIZATION_NOT_USER_MESSAGE" | "AUTHORIZATION_SESSION_MISMATCH" | "AUTHORIZATION_ID_MISMATCH" | "AUTHORIZATION_STALE" | "AUTHORIZATION_REUSED";
206
+ message: string;
207
+ };
208
+ export interface RecoverDelegatedCheckpointInput {
209
+ sessionId: string;
210
+ runId: string;
211
+ checkpointId: string;
212
+ diagnosis: string;
213
+ changedCondition: string;
214
+ verification: string[];
215
+ recoveryId: string;
216
+ /** Fresh root-user message authorizing one further generation for this target. */
217
+ userMessageId?: string;
218
+ /** Read-only authorization lookup supplied by the tool layer. */
219
+ lookupUserMessage?: LookupRecoveryUserMessage;
220
+ }
221
+ export declare function recoverDelegatedCheckpoint(store: WorkItemStore, input: RecoverDelegatedCheckpointInput): Promise<RecoverDelegatedCheckpointResult>;
222
+ export declare function recoverDelegatedCheckpointInStore(data: WorkItemStoreData, input: RecoverDelegatedCheckpointInput): Promise<RecoverDelegatedCheckpointResult>;
171
223
  /** Unsatisfied checkpoint barriers blocking task launches for the given wave, in declaration order. */
172
224
  export declare function checkpointBarrierUnsatisfied(data: WorkItemStoreData, runId: string, wave: string): {
173
225
  ok: true;