@juicesharp/rpiv-pi 2.7.1 → 2.9.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 (34) hide show
  1. package/README.md +2 -2
  2. package/docs/architecture.md +3 -3
  3. package/docs/skills.md +8 -6
  4. package/docs/workflows.md +3 -3
  5. package/extensions/rpiv-core/agent-enablement.ts +164 -0
  6. package/extensions/rpiv-core/agents.ts +98 -12
  7. package/extensions/rpiv-core/built-in-workflows.ts +373 -142
  8. package/extensions/rpiv-core/built-ins/gates.ts +38 -15
  9. package/extensions/rpiv-core/built-ins/goal-baseline.ts +43 -1
  10. package/extensions/rpiv-core/built-ins/grade-panel.ts +98 -29
  11. package/extensions/rpiv-core/built-ins/index.ts +1 -0
  12. package/extensions/rpiv-core/built-ins/priors.ts +208 -38
  13. package/extensions/rpiv-core/built-ins/reconcile-directives.d.mts +29 -0
  14. package/extensions/rpiv-core/built-ins/reconcile-directives.mjs +338 -0
  15. package/extensions/rpiv-core/built-ins/reconcile.ts +88 -130
  16. package/extensions/rpiv-core/built-ins/slices.ts +5 -1
  17. package/extensions/rpiv-core/frontmatter.ts +22 -0
  18. package/extensions/rpiv-core/lane-relay-ui.ts +25 -1
  19. package/extensions/rpiv-core/models-config.ts +86 -6
  20. package/extensions/rpiv-core/outcome-derivation.ts +1 -0
  21. package/extensions/rpiv-core/package-checks.ts +13 -0
  22. package/extensions/rpiv-core/pipeline-pointer.ts +1 -1
  23. package/extensions/rpiv-core/workflow-execution-host.ts +3 -2
  24. package/package.json +3 -3
  25. package/skills/_shared/reconcile-lint.mjs +125 -0
  26. package/skills/acceptance/SKILL.md +123 -0
  27. package/skills/elaborate/SKILL.md +3 -3
  28. package/skills/grade/SKILL.md +8 -7
  29. package/skills/implement/SKILL.md +17 -2
  30. package/skills/quick-plan/SKILL.md +19 -2
  31. package/skills/research/SKILL.md +28 -1
  32. package/skills/slice/SKILL.md +4 -4
  33. package/skills/synthesize/SKILL.md +1 -1
  34. package/skills/validate/SKILL.md +11 -5
@@ -1,153 +1,92 @@
1
1
  /**
2
2
  * The post-implement reconciliation backstop: `#### Reconciliation` directive
3
- * parsing and write-restricted application.
3
+ * application, write-restricted to the plan's declared write-set.
4
+ *
5
+ * The directive grammar and parser live in the sibling
6
+ * reconcile-directives.mjs — the SAME module the skills/_shared/
7
+ * reconcile-lint.mjs pre-flight CLI (run by the implement skill before it
8
+ * finishes a phase) imports, so a directive that lints clean locally parses
9
+ * identically here.
4
10
  */
5
11
  import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
6
12
  import { basename, isAbsolute, join } from "node:path";
7
13
  import { handleToString, type Output, type ScriptContext } from "@juicesharp/rpiv-workflow/registration";
14
+ import { phaseFiles, planPhaseRecords, withTestTwins } from "./plan-phases.js";
15
+ import { classifyApplication, type ReconciliationDirective, reconciliationRecords } from "./reconcile-directives.mjs";
8
16
  import {
9
17
  containedPath,
10
18
  haltPreflight,
11
19
  latestFsArtifact,
12
20
  readArtifactFile,
13
- TEST_PATH_RE,
14
21
  VERDICT_DIR,
15
22
  VERDICT_FAIL_SCORE,
16
23
  VERDICT_PASS_SCORE,
17
24
  } from "./shared.js";
18
25
 
19
26
  /**
20
- * One `#### Reconciliation` directive parsed from a plan body: a machine-applicable
21
- * `find → replace` against a single test-expectation file. The implement lane records
22
- * these in a phase's OWN section when a correct change invalidates a test that lives
23
- * in a sibling phase's landed section (which the implementer may NOT edit); `reconcile`
24
- * applies them write-restricted to `*.test.*` targets.
25
- */
26
- interface ReconciliationDirective {
27
- /** Repo-root-relative test target (`*.test.*`). */
28
- target: string;
29
- /** Substring to find (replaced exactly once via `String.replace`). */
30
- find: string;
31
- /** Replacement string. */
32
- replace: string;
33
- }
34
-
35
- /** Directive grammar: `` - `<target>`: replace `<find>` → `<replace>` — <rationale> ``.
36
- * The `→` (U+2192) separates find/replace; the em-dash `—` (U+2014) + rationale is
37
- * optional. Find/replace carry no inner backticks. The two spans are intentionally
38
- * asymmetric and MUST NOT be symmetrized: `find` is one-or-more `[^`]+` (an empty
39
- * find has no anchored target and `String.replace("")` prepends the replacement on
40
- * every run, so the parser rejects it at parse time), while `replace` is
41
- * zero-or-more `[^`]*` (an empty replace is a legitimate deletion directive). */
42
- const RECONCILE_DIRECTIVE_RE = /^-\s+`([^`]+)`\s*:\s*replace\s+`([^`]+)`\s*→\s*`([^`]*)`\s*(?:—\s+.*)?$/;
43
- /** A directive ATTEMPT — `- `<target>`:` — that does not match the full grammar. Used
44
- * to surface a malformed directive as a finding rather than silently dropping it. */
45
- const RECONCILE_DIRECTIVE_ATTEMPT_RE = /^-\s+`[^`]+`\s*:/;
46
-
47
- /**
48
- * Parse every `#### Reconciliation` directive from a plan body. Returns the
49
- * well-formed directives AND the malformed attempts (lines that carry the
50
- * `- `<target>`:` shape but not the full `replace … → …` grammar); `reconcile`
51
- * turns each malformed attempt into a finding so a broken directive is visible,
52
- * never silently dropped. Prose list items are ignored. Pure: no I/O, no throw.
53
- * A section opens at a `#### Reconciliation` heading and closes at the next
54
- * `#{1,4}` heading (so `### Success Criteria` / `## Phase N:` / a sibling
55
- * `#### Automated Verification:` all end it).
56
- */
57
- const reconciliationRecords = (
58
- body: string,
59
- ): {
60
- directives: ReconciliationDirective[];
61
- malformed: string[];
62
- } => {
63
- const directives: ReconciliationDirective[] = [];
64
- const malformed: string[] = [];
65
- let inSection = false;
66
- for (const raw of body.split("\n")) {
67
- const line = raw.trimEnd();
68
- if (/^####\s+Reconciliation\b/.test(line)) {
69
- inSection = true;
70
- continue;
71
- }
72
- // Any other heading ends the section (the open-heading branch above `continue`s,
73
- // so this only fires for non-`#### Reconciliation` headings).
74
- if (/^#{1,4}\s/.test(line)) {
75
- inSection = false;
76
- continue;
77
- }
78
- if (!inSection) continue;
79
- const m = RECONCILE_DIRECTIVE_RE.exec(line);
80
- if (m) {
81
- directives.push({ target: m[1]!.trim(), find: m[2]!, replace: m[3]! });
82
- } else if (RECONCILE_DIRECTIVE_ATTEMPT_RE.test(line)) {
83
- malformed.push(line.trim());
84
- }
85
- }
86
- return { directives, malformed };
87
- };
88
-
89
- const isTestPath = (target: string): boolean => TEST_PATH_RE.test(target);
90
-
91
- /**
92
- * Apply each `#### Reconciliation` directive, write-restricted to test-expectation
93
- * files (`isTestPath` — reconcile writes ONLY test files; a non-test target is a
94
- * finding, left untouched, fail-closed). A present `find` is replaced exactly
95
- * once (`String.replace`, first match); an absent `find` whose `replace` is empty
96
- * is the idempotent-re-run no-op for a deletion (find-absent is the deletion's
97
- * success condition — the directive was already applied, no finding, no write); an
98
- * absent `find` whose non-empty `replace` is ALSO absent is a finding (reconcile
99
- * does not guess); an absent `find` whose non-empty `replace` is already present is
100
- * the idempotent-re-run no-op for a substitution (a prior successful apply, no
101
- * finding, no write). Paths resolve through `cwd` and must stay INSIDE it
102
- * (`containedPath` — an absolute or `..`-escaping target is a finding, never a
103
- * read/write; the suffix allowlist alone cannot confine the sink, so containment
104
- * is checked on the SAME resolved path `readFileSync`/`writeFileSync` use).
105
- * Fail-soft: a read/apply throw degrades to a finding naming
106
- * the target, never a terminal throw. Returns findings in DIRECTIVE order and
107
- * performs the side-effecting writes itself (`reconcile` spreads the return).
27
+ * Apply each `#### Reconciliation` directive, write-restricted to the plan's
28
+ * declared write-set — the union of every phase's `files:`, twin-expanded
29
+ * (`withTestTwins`), the SAME authority the scope floor enforces, so reconcile
30
+ * can never write a path the floor would flag. Eligibility derives from the
31
+ * plan's own declarations, never from a filename convention, so the gate works
32
+ * identically in a project of any language; an undeclared target is a finding,
33
+ * left untouched, fail-closed (a `files:`-less plan declares nothing and
34
+ * rejects every directive).
35
+ *
36
+ * The apply decision per directive is `classifyApplication` (shared with the
37
+ * lint): `already-applied` / `deletion-satisfied` are the idempotent-re-run
38
+ * no-ops (reconcile-fix and validate-fix loop re-entries are normal — see the
39
+ * containment-shaped-directive rationale on `classifyApplication`); `apply`
40
+ * substitutes the FIRST match exactly once (`String.replace`); `missing` is a
41
+ * finding (reconcile does not guess). Paths resolve through `cwd` and must
42
+ * stay INSIDE it (`containedPath` — an absolute or `..`-escaping target is a
43
+ * finding, never a read/write; the declared-set membership check alone cannot
44
+ * confine the sink, so containment is checked on the SAME resolved path
45
+ * `readFileSync`/`writeFileSync` use). Fail-soft: a read/apply throw degrades
46
+ * to a finding naming the target, never a terminal throw. Returns findings in
47
+ * DIRECTIVE order and performs the side-effecting writes itself (`reconcile`
48
+ * spreads the return).
108
49
  */
109
50
  const applyReconciliationDirectives = (
110
51
  directives: readonly ReconciliationDirective[],
52
+ declared: ReadonlySet<string>,
111
53
  cwd: string,
112
54
  ): { detail: string; where: string }[] => {
113
55
  const findings: { detail: string; where: string }[] = [];
114
- // Apply directives, write-restricted to test-expectation files.
115
56
  for (const d of directives) {
116
- if (!isTestPath(d.target)) {
57
+ const abs = containedPath(cwd, d.target);
58
+ if (abs === undefined) {
117
59
  findings.push({
118
- detail: `reconcile: directive target ${d.target} is not a test-expectation file (*.test.{ts,tsx,js,jsx}) — reconcile writes only test files; record the directive against a test target or apply the edit in the owning phase`,
60
+ detail: `reconcile: directive target ${d.target} resolves outside the working tree — reconcile reads and writes only inside cwd; record the directive against a repo-root-relative target`,
119
61
  where: d.target,
120
62
  });
121
63
  continue;
122
64
  }
123
- const abs = containedPath(cwd, d.target);
124
- if (abs === undefined) {
65
+ if (!declared.has(d.target)) {
125
66
  findings.push({
126
- detail: `reconcile: directive target ${d.target} resolves outside the working tree — reconcile reads and writes only inside cwd; record the directive against a repo-root-relative test target`,
67
+ detail: `reconcile: directive target ${d.target} is not in the plan's declared write-set (the union of every phase's 'files:', twin-expanded) — reconcile writes only what the plan declares, the same authority the scope floor enforces; declare the file in the owning phase's 'files:', or route the edit through validate's remediation arm`,
127
68
  where: d.target,
128
69
  });
129
70
  continue;
130
71
  }
131
72
  try {
132
73
  const content = readFileSync(abs, "utf-8");
133
- if (content.includes(d.find)) {
134
- // `String.replace` with a string pattern replaces the FIRST match exactly once.
135
- writeFileSync(abs, content.replace(d.find, d.replace), "utf-8");
136
- } else if (d.replace !== "" && content.includes(d.replace)) {
137
- // Idempotent re-run: the find is gone but the replacement is present ⇒ the
138
- // directive was already applied (e.g. a vet review-fix loop re-running
139
- // reconcile). Treated as satisfied — reconcile must not fail on its own
140
- // prior successful apply.
141
- } else if (d.replace === "") {
142
- // Idempotent re-run of a deletion: the find is gone and the replacement is
143
- // empty ⇒ find-absent is the deletion's success condition (a prior successful
144
- // apply removed it). Treated as satisfied — reconcile must not fail on its
145
- // own prior successful apply (e.g. a validate-fix loop re-running reconcile).
146
- } else {
147
- findings.push({
148
- detail: `reconcile: directive find substring not present in ${d.target} (and the replacement is absent — not already applied) — the expected text to replace is absent; the directive is stale or the test no longer matches`,
149
- where: d.target,
150
- });
74
+ switch (classifyApplication(d, content)) {
75
+ case "already-applied":
76
+ case "deletion-satisfied":
77
+ // Idempotent re-run: treated as satisfied — reconcile must not fail
78
+ // (or re-write) on its own prior successful apply.
79
+ break;
80
+ case "apply":
81
+ // `String.replace` with a string pattern replaces the FIRST match exactly once.
82
+ writeFileSync(abs, content.replace(d.find, d.replace), "utf-8");
83
+ break;
84
+ case "missing":
85
+ findings.push({
86
+ detail: `reconcile: directive find substring not present in ${d.target} (and the replacement is absent — not already applied) — the expected text to replace is absent; the directive is stale or the target no longer matches. Repair IN THE PLAN: update the directive's find text to match the target file's current content byte-for-byte (Read the file to ground it; if the text carries backticks, rewrite the directive in the fenced find:/replace: form, which preserves bytes exactly), or delete the directive if it no longer applies`,
87
+ where: d.target,
88
+ });
89
+ break;
151
90
  }
152
91
  } catch (err) {
153
92
  findings.push({
@@ -163,17 +102,19 @@ const applyReconciliationDirectives = (
163
102
  * Deterministic post-implement reconciliation — the coherence backstop the
164
103
  * parallel implement lane needs. Sibling phases run concurrently in one tree;
165
104
  * each phase's own `#### Automated Verification:` passed in isolation, but a
166
- * phase's correct change can invalidate a test that lives in a SIBLING phase's
167
- * landed section (which the implementer may not edit), and the combined tree can
168
- * break in ways no single phase's checks surface. `reconcile` runs after the
169
- * scope floor (which proved the write-set) and before `validate`:
105
+ * phase's correct change can invalidate an expectation that lives in a SIBLING
106
+ * phase's landed section (which the implementer may not edit), and the combined
107
+ * tree can break in ways no single phase's checks surface. `reconcile` runs
108
+ * after the scope floor (which proved the write-set) and before `validate`:
170
109
  *
171
110
  * 1. reads the latest plan (`latestFsArtifact(state, "plans")` — latest-wins);
172
- * 2. parses every `#### Reconciliation` directive — fail-soft (a malformed
173
- * directive / unreadable plan degrades to a finding, never a terminal
174
- * `FAIL_SCRIPT_THREW` halt — a `produces.script` that throws becomes one);
175
- * 3. applies each directive write-restricted to test paths (`isTestPath`); a
176
- * present `find` is replaced exactly once (`String.replace`); an absent `find`
111
+ * 2. parses every `#### Reconciliation` directive (shared parser) and derives
112
+ * the plan's declared write-set (`planPhaseRecords` + `phaseFiles`, twin-
113
+ * expanded) — fail-soft (a malformed directive / unreadable or unparseable
114
+ * plan degrades to a finding, never a terminal `FAIL_SCRIPT_THREW` halt —
115
+ * a `produces.script` that throws becomes one);
116
+ * 3. applies each directive write-restricted to the declared set; a present
117
+ * `find` is replaced exactly once (`String.replace`); an absent `find`
177
118
  * whose replacement is ALSO absent is a finding (reconcile does not guess);
178
119
  * 4. appends a timestamped `### Reconciliation Log (<iso>)` under the plan's
179
120
  * `## Synthesis Notes` (best-effort bookkeeping write — non-fatal);
@@ -189,8 +130,12 @@ const applyReconciliationDirectives = (
189
130
  * commands as an agent, with a real shell and the judgment to tell a legitimate
190
131
  * post-rename mismatch from actual plan-vs-tree drift.
191
132
  *
192
- * The route is the `match("verdict", …, { from: "reconcile" })` gate idiom — pass ⇒
193
- * validate, fail/missing ⇒ STOP (no fallback), mirroring `implementScopeCheck`.
133
+ * The route is `reconcileGate` (built-in-workflows.ts) — pass ⇒ validate; fail ⇒
134
+ * the `reconcile-fix` arm (`/skill:amend` over the plan's directives from this
135
+ * verdict — every reconcile failure class is a plan-TEXT defect, so the plan
136
+ * reviser has authority over all of them; amend never edits directive targets,
137
+ * this stage stays the sole applier), looping back here; a missing/corrupt
138
+ * verdict ⇒ STOP (integrity clause).
194
139
  * Mirrors `implementScopeCheck`'s `ScriptContext` shape, basename-keyed verdict
195
140
  * path, and `dimension`/`pass`/`verdict`/`score`/`severity` data shape. `reads:
196
141
  * ["plans"]` only — reconcile consumes no run-start `goal` baseline (the scope
@@ -212,15 +157,22 @@ const reconcile = ({ state, cwd }: ScriptContext): Omit<Output, "meta"> => {
212
157
  const planAbs = isAbsolute(planPath) ? planPath : join(cwd, planPath);
213
158
  const findings: { detail: string; where: string }[] = [];
214
159
 
215
- // Fail-soft read + parse: an unreadable plan or malformed directive degrades
216
- // to a finding, never a terminal throw. If the read fails there is nothing to
217
- // apply.
160
+ // Fail-soft read + parse: an unreadable plan, unparseable phase frontmatter,
161
+ // or malformed directive degrades to a finding, never a terminal throw. If
162
+ // the read fails there is nothing to apply. Assignment order is load-bearing:
163
+ // `directives` lands only after the declared set derived, so a
164
+ // phase-frontmatter defect yields ONE parse finding, never a cascade of
165
+ // per-directive not-declared findings against an empty set.
218
166
  let body = "";
219
167
  let directives: ReconciliationDirective[] = [];
220
168
  let malformed: string[] = [];
169
+ let declared: ReadonlySet<string> = new Set<string>();
221
170
  try {
222
171
  body = readArtifactFile(planPath, cwd);
223
172
  const parsed = reconciliationRecords(body);
173
+ declared = new Set(
174
+ withTestTwins(planPhaseRecords(body, "reconcile", planPath).flatMap((r) => phaseFiles(r.entry))),
175
+ );
224
176
  directives = parsed.directives;
225
177
  malformed = parsed.malformed;
226
178
  } catch (err) {
@@ -231,12 +183,18 @@ const reconcile = ({ state, cwd }: ScriptContext): Omit<Output, "meta"> => {
231
183
  }
232
184
  for (const m of malformed) {
233
185
  findings.push({
234
- detail: `reconcile: malformed Reconciliation directive — expected a line of the form: - \`<target>\`: replace \`<find>\` → \`<replace>\` (target/find/replace each backtick-wrapped) — ${m}`,
186
+ detail:
187
+ "reconcile: malformed Reconciliation directive — rewrite the directive IN THE PLAN as either " +
188
+ "(a) one list item: - `<target>`: replace `<find>` → `<replace>` — <rationale> " +
189
+ "(find/replace may span lines but must carry no inner backticks), or " +
190
+ "(b) the fenced form for content with backticks: - `<target>`: replace — <rationale>, then a " +
191
+ "`find:` line followed by a fenced code block, then a `replace:` line followed by a fenced code " +
192
+ `block — offending item: ${m}`,
235
193
  where: "reconciliation-directive",
236
194
  });
237
195
  }
238
196
 
239
- findings.push(...applyReconciliationDirectives(directives, cwd));
197
+ findings.push(...applyReconciliationDirectives(directives, declared, cwd));
240
198
 
241
199
  // Best-effort bookkeeping: append a timestamped log under ## Synthesis Notes.
242
200
  // Non-fatal — a write failure here is silent (the verdict below is the signal).
@@ -60,12 +60,16 @@ const sliceDeps = (entry: Record<string, unknown>): number[] => {
60
60
  /** Fan `design-slice` out over the latest slice map's `slices:` array — one design
61
61
  * session per slice, dependency-ordered. `deps` (slice-N unit ids) drive the wave
62
62
  * scheduler; `depArtifactFlag` injects each completed dependency's design path as
63
- * `--upstream <path>` so a dependent slice reads its dependency's decided Key Interfaces. */
63
+ * `--upstream <path>` so a dependent slice reads its dependency's decided Key
64
+ * Interfaces. `haltWhenAllFailed` closes the observed dead-generation shape: when
65
+ * every design unit of a generation fails, the run halts at this stage instead of
66
+ * falling through to `design-review` over an empty `designs` channel. */
64
67
  const SLICE_DESIGN_FANOUT = fanout({
65
68
  source: "slices",
66
69
  unit: { by: "frontmatter-array", pattern: "slices" },
67
70
  max: MAX_PHASES,
68
71
  depArtifactFlag: "--upstream",
72
+ haltWhenAllFailed: true,
69
73
  units: ({ state, cwd }) => {
70
74
  const doc = latestFsArtifact(state, "slices");
71
75
  if (doc?.handle.kind !== "fs") return [];
@@ -30,3 +30,25 @@ export function parseFrontmatterBounds(lines: string[]): { start: number; end: n
30
30
 
31
31
  return null; // unclosed frontmatter
32
32
  }
33
+
34
+ /**
35
+ * Read the raw scalar value of `key` within the frontmatter bounds.
36
+ *
37
+ * Returns the trimmed text after `${key}:` on the key's own line, or
38
+ * `undefined` when the key is absent from the block. Single-line scalars
39
+ * only — a key whose value lives on following lines (block sequence) reads
40
+ * as "", and callers treat that as an unmergeable form. The read
41
+ * counterpart to applyKeyUpdates in agents.ts.
42
+ */
43
+ export function readFrontmatterKey(
44
+ lines: string[],
45
+ bounds: { start: number; end: number },
46
+ key: string,
47
+ ): string | undefined {
48
+ for (let i = bounds.start + 1; i < bounds.end; i++) {
49
+ const line = lines[i];
50
+ if (!line.startsWith(`${key}:`)) continue;
51
+ return line.slice(key.length + 1).trim();
52
+ }
53
+ return undefined;
54
+ }
@@ -37,7 +37,10 @@
37
37
  * A Proxy (not a hand-written delegate) keeps the relay drift-proof. The relay is
38
38
  * BRANDED (LANE_RELAY_BRAND) so the launcher's own session hooks
39
39
  * (session-capture, lane-switcher) can detect a detached-child session_start and
40
- * skip launcher-only work (isLaneRelayUiContext).
40
+ * skip launcher-only work (isLaneRelayUiContext). The brand is reported as an own
41
+ * enumerable key (ownKeys/getOwnPropertyDescriptor traps), so it SURVIVES a host
42
+ * that re-wraps ctx.ui by spread — pi ≥0.84.4's wrapUIPromptContext does exactly
43
+ * that, and a get-trap-only brand would silently un-gate every child.
41
44
  */
42
45
 
43
46
  import type { ExtensionUIContext } from "@earendil-works/pi-coding-agent";
@@ -97,5 +100,26 @@ export function createLaneRelayUiContext(
97
100
  const value = Reflect.get(target, prop, target);
98
101
  return typeof value === "function" ? value.bind(target) : value;
99
102
  },
103
+ // Spread survival — pi ≥0.84.4 wraps every extension's ctx.ui via `{...ui}`
104
+ // (wrapUIPromptContext, the ui_prompt_start/end feature; upstream #8829). A
105
+ // spread enumerates OWN keys, so a brand served only by the `get` trap would
106
+ // vanish from the copy, `isLaneRelayUiContext` would return false in every
107
+ // detached child, and the launcher-only session hooks (lane-switcher,
108
+ // session-capture) would run against the child's relay — hijacking the dock
109
+ // editor and foreground capture. Reporting the brand as an own ENUMERABLE key
110
+ // makes `{...relayProxy}` carry `[LANE_RELAY_BRAND]: true`; the relay's
111
+ // behavioral overrides need no help (the spread `get`s them through the proxy).
112
+ ownKeys(target) {
113
+ const keys = Reflect.ownKeys(target);
114
+ // A duplicate entry in an ownKeys result is a TypeError — guard the
115
+ // (never-expected) case of an already-branded target.
116
+ return keys.includes(LANE_RELAY_BRAND) ? keys : [...keys, LANE_RELAY_BRAND];
117
+ },
118
+ getOwnPropertyDescriptor(target, prop) {
119
+ // `configurable: true` is REQUIRED by the Proxy invariant for a key the
120
+ // target does not itself own.
121
+ if (prop === LANE_RELAY_BRAND) return { value: true, writable: false, enumerable: true, configurable: true };
122
+ return Reflect.getOwnPropertyDescriptor(target, prop);
123
+ },
100
124
  });
101
125
  }
@@ -58,10 +58,12 @@ const _persistableLevelsMatchPiAi: _PersistableLevelsMatchPiAi = true;
58
58
  * Background-lane concurrency cap fallback. The fail-soft default applied by
59
59
  * `resolveMaxConcurrency` when `~/.config/rpiv-pi/models.json` is absent or
60
60
  * carries no valid `maxConcurrency`. Rate limits, not CPU, are the real cap —
61
- * 4 background lanes is the safe default. Re-exported from
61
+ * 6 lanes clears the widest built-in fanout batch (the 5-dimension grade
62
+ * panel, which a cap of 4 split into a 4+1 second batch on every panel) with
63
+ * one lane of headroom; no rate-limit events were observed at 4. Re-exported from
62
64
  * packages/rpiv-pi/extensions/rpiv-core/workflow-execution-host.ts to preserve the tested public surface.
63
65
  */
64
- export const DEFAULT_MAX_CONCURRENCY = 4;
66
+ export const DEFAULT_MAX_CONCURRENCY = 6;
65
67
 
66
68
  // ---------------------------------------------------------------------------
67
69
  // TypeBox schemas
@@ -106,6 +108,18 @@ const ModelEntrySchema = Type.Union(
106
108
  }),
107
109
  ),
108
110
  thinking: Type.Optional(ThinkingLevelSchema),
111
+ extensions: Type.Optional(
112
+ Type.Array(Type.String(), {
113
+ description:
114
+ "Sibling extension names the agent may load when installed (per-agent axis only — ignored in defaults)",
115
+ }),
116
+ ),
117
+ tools: Type.Optional(
118
+ Type.Array(Type.String(), {
119
+ description:
120
+ "Tool selectors appended to the agent's tools frontmatter (per-agent axis only — ignored in defaults)",
121
+ }),
122
+ ),
109
123
  },
110
124
  { additionalProperties: false },
111
125
  ),
@@ -172,6 +186,10 @@ export interface ResolvedModelConfig {
172
186
  model?: string;
173
187
  /** Explicit level incl. "off" (disable). Absent ⇒ inherit session/baseline. */
174
188
  thinking?: ModelThinkingLevelValue;
189
+ /** Sibling extensions the agent may load when installed (per-agent axis only). */
190
+ extensions?: string[];
191
+ /** Tool selectors appended to the agent's tools frontmatter (per-agent axis only). */
192
+ tools?: string[];
175
193
  }
176
194
 
177
195
  /** The resolved config shape returned by loadModelsConfig. */
@@ -189,6 +207,24 @@ export interface ModelsConfig {
189
207
  // Helper — resolve a ModelEntry (string or object) to ResolvedModelConfig.
190
208
  // ---------------------------------------------------------------------------
191
209
 
210
+ /**
211
+ * String-filter salvage for the agent-axis arrays, hardened against
212
+ * frontmatter-line injection: keeps strings, drops non-strings silently (the
213
+ * standing salvage contract), and drops any string carrying `\n`/`\r` with a
214
+ * console.warn naming the field — such an entry would smuggle extra physical
215
+ * lines into a synced agent's frontmatter (see the call-site comment).
216
+ */
217
+ function filterFrontmatterSafeStrings(values: readonly unknown[], field: "tools" | "extensions"): string[] {
218
+ const strings = values.filter((v): v is string => typeof v === "string");
219
+ const safe = strings.filter((v) => !/[\r\n]/.test(v));
220
+ if (safe.length !== strings.length) {
221
+ console.warn(
222
+ `[rpiv-pi] models.json: dropped ${strings.length - safe.length} \`${field}\` entr${strings.length - safe.length === 1 ? "y" : "ies"} containing newline characters — a multi-line entry would inject frontmatter lines into synced agent definitions`,
223
+ );
224
+ }
225
+ return safe;
226
+ }
227
+
192
228
  /** Resolve a raw ModelEntry value to a ResolvedModelConfig. */
193
229
  function resolveModelEntry(entry: unknown): ResolvedModelConfig {
194
230
  if (typeof entry === "string") {
@@ -209,6 +245,21 @@ function resolveModelEntry(entry: unknown): ResolvedModelConfig {
209
245
  );
210
246
  }
211
247
  }
248
+ // Agent-axis fields: per-field string-filter salvage — an array value
249
+ // survives with non-string elements dropped (an explicit [] is meaningful:
250
+ // it suppresses the map default downstream); a non-array value drops the
251
+ // field entirely (falls back to map defaults). Entries carrying \n/\r are
252
+ // dropped LOUDLY: these strings land on one logical frontmatter line of
253
+ // ~/.pi/agent/agents/*.md, where an interior newline becomes a physical
254
+ // line the Pi runtime reads as agent capability config — a copy-paste
255
+ // artifact like "x\nisolated: false" would silently un-isolate an agent
256
+ // (review 2026-08-31 S1).
257
+ if (Array.isArray(obj.tools)) {
258
+ result.tools = filterFrontmatterSafeStrings(obj.tools, "tools");
259
+ }
260
+ if (Array.isArray(obj.extensions)) {
261
+ result.extensions = filterFrontmatterSafeStrings(obj.extensions, "extensions");
262
+ }
212
263
  return result;
213
264
  }
214
265
  return {};
@@ -231,6 +282,29 @@ export function loadModelsConfig(): ModelsConfig {
231
282
  const validated = validateConfig(ModelsConfigSchema, raw);
232
283
 
233
284
  const defaults = resolvedEntry(validated.defaults);
285
+ // Agent-axis-only fields never cascade: strip them from `defaults` (one
286
+ // warn) so the {...defaults, ...resolved} cascade and the
287
+ // getAgentModelConfig defaults fallback cannot leak enablement to every
288
+ // configured agent.
289
+ if (defaults && (defaults.extensions !== undefined || defaults.tools !== undefined)) {
290
+ console.warn("[rpiv-pi] models.json: `extensions`/`tools` in `defaults` are ignored — they are per-agent fields");
291
+ delete defaults.extensions;
292
+ delete defaults.tools;
293
+ }
294
+ // The SAME strip on every other non-agents axis (review 2026-08-31 I3):
295
+ // the shared ModelEntrySchema admits `tools`/`extensions` everywhere, but
296
+ // only the agents-axis lookup consumes them — a stages/skills/preset entry
297
+ // carrying them passed validation and silently granted nothing. One warn
298
+ // per load, naming the offending axes.
299
+ const strippedAxes = new Set<string>();
300
+ const stripAgentAxisFields = (entry: ResolvedModelConfig, axis: string): ResolvedModelConfig => {
301
+ if (entry.extensions !== undefined || entry.tools !== undefined) {
302
+ strippedAxes.add(axis);
303
+ delete entry.extensions;
304
+ delete entry.tools;
305
+ }
306
+ return entry;
307
+ };
234
308
  const agents: Record<string, ResolvedModelConfig> = {};
235
309
  const stages: Record<string, ResolvedModelConfig> = {};
236
310
  const skills: Record<string, ResolvedModelConfig> = {};
@@ -244,13 +318,13 @@ export function loadModelsConfig(): ModelsConfig {
244
318
 
245
319
  if (validated.stages && typeof validated.stages === "object") {
246
320
  for (const [name, entry] of Object.entries(validated.stages)) {
247
- stages[name] = resolvedEntryWithCascade(entry, defaults);
321
+ stages[name] = stripAgentAxisFields(resolvedEntryWithCascade(entry, defaults), "stages");
248
322
  }
249
323
  }
250
324
 
251
325
  if (validated.skills && typeof validated.skills === "object") {
252
326
  for (const [name, entry] of Object.entries(validated.skills)) {
253
- skills[name] = resolvedEntryWithCascade(entry, defaults);
327
+ skills[name] = stripAgentAxisFields(resolvedEntryWithCascade(entry, defaults), "skills");
254
328
  }
255
329
  }
256
330
 
@@ -260,7 +334,7 @@ export function loadModelsConfig(): ModelsConfig {
260
334
  const presetStages: Record<string, ResolvedModelConfig> = {};
261
335
  if (presetBlock.stages && typeof presetBlock.stages === "object") {
262
336
  for (const [stageName, entry] of Object.entries(presetBlock.stages)) {
263
- presetStages[stageName] = resolvedEntryWithCascade(entry, defaults);
337
+ presetStages[stageName] = stripAgentAxisFields(resolvedEntryWithCascade(entry, defaults), "presets");
264
338
  }
265
339
  }
266
340
  if (Object.keys(presetStages).length > 0) {
@@ -269,6 +343,12 @@ export function loadModelsConfig(): ModelsConfig {
269
343
  }
270
344
  }
271
345
 
346
+ if (strippedAxes.size > 0) {
347
+ console.warn(
348
+ `[rpiv-pi] models.json: \`extensions\`/\`tools\` in ${[...strippedAxes].sort().join("/")} entries are ignored — they are per-agent fields (only \`agents.<name>\` consumes them)`,
349
+ );
350
+ }
351
+
272
352
  const result: ModelsConfig = {
273
353
  defaults,
274
354
  agents: Object.keys(agents).length > 0 ? agents : undefined,
@@ -359,7 +439,7 @@ export function resolveStageModel(
359
439
 
360
440
  /**
361
441
  * Resolve the background-lane concurrency cap from `~/.config/rpiv-pi/models.json`.
362
- * Returns `DEFAULT_MAX_CONCURRENCY` (4) when the key is absent OR holds an invalid
442
+ * Returns `DEFAULT_MAX_CONCURRENCY` (6) when the key is absent OR holds an invalid
363
443
  * value (non-integer, < 1).
364
444
  *
365
445
  * NOTE: `Value.Clean` (typebox@1.3.6) does NOT strip invalid scalars — it only
@@ -28,6 +28,7 @@ import { isModuleNotFound } from "./utils.js";
28
28
  export const BUCKET_BY_KIND: Readonly<Record<string, string>> = {
29
29
  plan: "plans",
30
30
  research: "research",
31
+ acceptance: "acceptance",
31
32
  slices: "slices",
32
33
  design: "designs",
33
34
  elaboration: "elaborations",
@@ -17,3 +17,16 @@ export function findMissingSiblings(): SiblingPlugin[] {
17
17
  const installed = result.packages.filter((e): e is string => typeof e === "string");
18
18
  return SIBLINGS.filter((s) => !installed.some((entry) => s.matches.test(entry)));
19
19
  }
20
+
21
+ /**
22
+ * Return the SIBLINGS currently installed — the exact complement of
23
+ * findMissingSiblings over the same readPiAgentSettings() read. No settings
24
+ * file (or a packages array that isn't one) ⇒ [] — mirroring
25
+ * findMissingSiblings' all-missing fallback in the opposite direction.
26
+ */
27
+ export function findInstalledSiblings(): SiblingPlugin[] {
28
+ const result = readPiAgentSettings();
29
+ if (!result) return [];
30
+ const installed = result.packages.filter((e): e is string => typeof e === "string");
31
+ return SIBLINGS.filter((s) => installed.some((entry) => s.matches.test(entry)));
32
+ }
@@ -36,7 +36,7 @@ export const PIPELINE_POINTER = [
36
36
  "Other explicit-only commands: /skill:slice, /skill:revise, /skill:elaborate,",
37
37
  "/skill:architecture-review, /skill:frontend-design",
38
38
  "Workflow-internal (dispatched by lanes — never suggest): amend, design-slice,",
39
- "design-review, synthesize, grade, remediate, quick-plan",
39
+ "design-review, synthesize, grade, remediate, quick-plan, acceptance",
40
40
  ].join("\n");
41
41
 
42
42
  export function injectPipelinePointer(pi: ExtensionAPI): void {
@@ -97,7 +97,7 @@ export function createWorkflowExecution(
97
97
  cwd: observer.cwd,
98
98
  runId,
99
99
  childSessionsDir, // resolved by the runner; rpiv-pi does not synthesize the path
100
- maxConcurrency: resolveMaxConcurrency(loadModelsConfig()), // config-driven background-lane cap (default 4)
100
+ maxConcurrency: resolveMaxConcurrency(loadModelsConfig()), // config-driven background-lane cap (default 6)
101
101
  });
102
102
 
103
103
  // Record this run as a switchable lane at launch (appears in the ambient
@@ -177,7 +177,8 @@ export async function registerWorkflowExecutionHostProvider(): Promise<void> {
177
177
  const { registerWorkflowExecutionHost } = await import("@juicesharp/rpiv-workflow/startup");
178
178
  registerWorkflowExecutionHost({
179
179
  createHost: createWorkflowExecution,
180
- resolveModel: ({ stage, skill }) => toModelSelection(resolveStageModel(loadModelsConfig(), { stage, skill })),
180
+ resolveModel: ({ workflow, stage, skill }) =>
181
+ toModelSelection(resolveStageModel(loadModelsConfig(), { workflow, stage, skill })),
181
182
  // Death-scene reader — re-open the just-failed session's persisted JSONL
182
183
  // and return its branch, narrowed to the workflow-owned BranchEntry shape
183
184
  // (the SDK's SessionEntry union carries private discriminators — the
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@juicesharp/rpiv-pi",
3
- "version": "2.7.1",
4
- "description": "A skill-based development workflow for Pi Agent. 29 contract-carrying skills (discover → research → design → plan → implement → validate → code-review → commit, and more), the 15 named subagents they dispatch, and four built-in /wf workflows that chain them end to end in detached parallel runs.",
3
+ "version": "2.9.0",
4
+ "description": "A skill-based development workflow for Pi Agent. 30 contract-carrying skills (discover → research → design → plan → implement → validate → code-review → commit, and more), the 15 named subagents they dispatch, and four built-in /wf workflows that chain them end to end in detached parallel runs.",
5
5
  "keywords": [
6
6
  "pi-package",
7
7
  "pi-extension",
@@ -50,7 +50,7 @@
50
50
  ]
51
51
  },
52
52
  "dependencies": {
53
- "@juicesharp/rpiv-config": "^2.7.1",
53
+ "@juicesharp/rpiv-config": "^2.9.0",
54
54
  "typebox": "^1.1.24"
55
55
  },
56
56
  "peerDependencies": {