Skip to content

FE-1054: unify agent bodies under src/.pi/agents/<id>/ + renames (D90-L migration)#256

Merged
lunelson merged 5 commits into
nextfrom
ln/fe-1054-subagent-reconciliation-ii
Jun 24, 2026
Merged

FE-1054: unify agent bodies under src/.pi/agents/<id>/ + renames (D90-L migration)#256
lunelson merged 5 commits into
nextfrom
ln/fe-1054-subagent-reconciliation-ii

Conversation

@lunelson

Copy link
Copy Markdown
Contributor

FE-1054: unify agent bodies under src/.pi/agents// + renames (D90-L migration)

Slice 3b of subagent-reconciliation (D90-L one agent-body layout):

  • Move background bodies to src/.pi/agents//SYSTEM.md (frontmatter kept as DX)
  • Rename scout->explorer, proposer->projector; reclassify reviewer fg->bg
  • BACKGROUND_SUBAGENT_IDS = [explorer, researcher, projector, reviewer]
  • Loader resolves from unified home; no readdir (D39-L code-owned discovery)
  • Oracle 2 carried forward: planted unlisted /SYSTEM.md not spawnable
  • Side-task reviewer drain (D15-L/D25-L) untouched
  • build:pi-assets copies the six agent dirs from the unified home
  • SPEC/PLAN terminology reconciled to the new home (I29-L invariant + D91-L
    seal flip NOT touched — reserved for slice 3)

Verified: full vitest 1030 pass / 0 fail; npm run check clean.

FE-1054: semi-permeable subagent seal — inject parent world + assembled prompt (D91-L)

Slice 3 of subagent-reconciliation (D91-L):

  • New prompt-assembly.ts: assembled background prompt (control header + injected
    world snapshot + + router), minus foreground elicitation block
  • Thread injected parent world (GraphReaders scoped to parent specId, spec/workspace
    seed, session digest via getBranch()) app root -> pi-subagents.ts -> runSubagent
  • Extract createReadGraphTool; grant explorer read_graph when graph readers injected
  • Isolation by construction: graphReadersForSpec(graph, specId) binds parent specId;
    child cannot reach a sibling spec
  • Oracle 3: assembled prompt carries world snapshot; graph via tool not baked;
    sibling-spec excluded; ambient seal preserved (in-memory services, no ~/.pi)
  • FLIP I29-L invariant + glossary to semi-permeable; D91-L Supersedes reconciled
  • Fix: guard pi.appendEntry.bind in createReadGraphTool call (eager bind threw for
    mock pi without appendEntry — 6 graph-tool tests)

Subagent registration stays dev-gated (context.dev); slice 6 wires the runnable path.

Verified: full vitest 1032 pass / 0 fail; npm run check clean; tsc build clean.

lunelson added 2 commits June 24, 2026 14:25
…-L migration)

Slice 3b of subagent-reconciliation (D90-L one agent-body layout):
- Move background bodies to src/.pi/agents/<id>/SYSTEM.md (frontmatter kept as DX)
- Rename scout->explorer, proposer->projector; reclassify reviewer fg->bg
- BACKGROUND_SUBAGENT_IDS = [explorer, researcher, projector, reviewer]
- Loader resolves from unified home; no readdir (D39-L code-owned discovery)
- Oracle 2 carried forward: planted unlisted <id>/SYSTEM.md not spawnable
- Side-task reviewer drain (D15-L/D25-L) untouched
- build:pi-assets copies the six agent dirs from the unified home
- SPEC/PLAN terminology reconciled to the new home (I29-L invariant + D91-L
  seal flip NOT touched — reserved for slice 3)

Verified: full vitest 1030 pass / 0 fail; npm run check clean.
…ed prompt (D91-L)

Slice 3 of subagent-reconciliation (D91-L):
- New prompt-assembly.ts: assembled background prompt (control header + injected
  world snapshot + <brunch-skills> + router), minus foreground elicitation block
- Thread injected parent world (GraphReaders scoped to parent specId, spec/workspace
  seed, session digest via getBranch()) app root -> pi-subagents.ts -> runSubagent
- Extract createReadGraphTool; grant explorer read_graph when graph readers injected
- Isolation by construction: graphReadersForSpec(graph, specId) binds parent specId;
  child cannot reach a sibling spec
- Oracle 3: assembled prompt carries world snapshot; graph via tool not baked;
  sibling-spec excluded; ambient seal preserved (in-memory services, no ~/.pi)
- FLIP I29-L invariant + glossary to semi-permeable; D91-L Supersedes reconciled
- Fix: guard pi.appendEntry.bind in createReadGraphTool call (eager bind threw for
  mock pi without appendEntry — 6 graph-tool tests)

Subagent registration stays dev-gated (context.dev); slice 6 wires the runnable path.

Verified: full vitest 1032 pass / 0 fail; npm run check clean; tsc build clean.

lunelson commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

Slice 4 of subagent-reconciliation. The op_mode-keyed, code-owned
delegatable-set allowlist is now the subagent write-safety boundary:
registration/advertisement and execution are restricted to
definitions ∩ the foreground agent's canDelegate set, so frontmatter
can never self-author delegation. elicit.canDelegate carries the
read-only background roster; sovereign child-tool grants are exposed
via createSubagentToolCatalog.

Narrowed the architecture guard to per-file forbidden needles: reviewer
now legitimately appears in runtime-policy.ts's canDelegate (a non-write
delegation target), while pi-coder stays out of the foreground registry.

Verified: full vitest 1039 passed / 0 failed; npm run check clean.
Co-authored-by: Cursor <cursoragent@cursor.com>
@lunelson lunelson marked this pull request as ready for review June 24, 2026 13:17
Copilot AI review requested due to automatic review settings June 24, 2026 13:17
@cursor

cursor Bot commented Jun 24, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
This diff is documentation and planning metadata only; runtime risk from the underlying subagent/orchestrator changes is not represented in the files shown here.

Overview
Planning and contract docs catch up to landed subagent-reconciliation work (FE-1054): the frontier moves from active to done, with slices 1–6 recorded in memory/PLAN.md (shared manifest, prompt extraction, unified agent home + renames, D91-L seal, D92-L/I49-L delegatable gate, return renderer, orchestrator standup).

memory/SPEC.md now treats executeorchestrator as live (with codepi-coder still planned), updates subagent topology to explorer / researcher / projector / reviewer bodies at src/.pi/agents/<id>/SYSTEM.md, describes the semi-permeable child seal (injected snapshot + read_graph), and flips I29-L / I49-L from planned to covered with oracle paths pointed at the unified home.

Two completed scope cards are added: agent-home unify (slice 3b) and delegatable-set gate (slice 4). Remaining live frontiers in PLAN are narrowed to demo-polish and renderer-golden-coverage.

Reviewed by Cursor Bugbot for commit 712e90a. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 78bf623. Configure here.

Comment thread src/app/pi-subagents.ts
Co-authored-by: Cursor <cursoragent@cursor.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR advances the subagent-reconciliation frontier by unifying background agent bodies under src/.pi/agents/<id>/SYSTEM.md, renaming/background-roster updates, and implementing D91-L’s semi-permeable seal: background subagents receive an assembled prompt with an injected parent-world snapshot plus spec-bound read_graph when provided, and are wired into the dev-gated runtime path.

Changes:

  • Migrate background agent bodies to the unified src/.pi/agents/<id>/SYSTEM.md home and rename scout→explorer, proposer→projector, plus reclassify reviewer as a background manifest.
  • Inject parent-world snapshot + spec-bound graph readers into subagent execution, and assemble a background system prompt (control header + world snapshot + router rules).
  • Refactor graph read_graph tool creation into a reusable factory and update build/docs/tests to match the new topology and behavior.

Reviewed changes

Copilot reviewed 22 out of 23 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/app/pi-subagents.ts Adds optional injected world wiring and session-digest rendering for subagents.
src/app/brunch-tui.ts Dev-gated loading of subagents with injected world snapshot + spec-bound graph readers.
src/.pi/README.md Updates topology README to include D90-L/D91-L and new agent body entries.
src/.pi/extensions/subagents/subagents.test.ts Updates subagent tests for new IDs/home and adds semi-permeable seal + read_graph coverage.
src/.pi/extensions/subagents/session.ts Threads injected world into tool planning and assembles the background system prompt.
src/.pi/extensions/subagents/README.md Reconciles extension README to the new home, dev gating, and D91-L semi-permeable seal.
src/.pi/extensions/subagents/prompt-assembly.ts New module to assemble the background subagent prompt (control + snapshot + routing).
src/.pi/extensions/subagents/index.ts Exports injected-world type surface.
src/.pi/extensions/subagents/agents.ts Updates registry IDs and loads SYSTEM.md from unified agent home.
src/.pi/extensions/README.md Notes subagents now include assembled prompts + injected world reads.
src/.pi/extensions/graph/index.ts Extracts createReadGraphTool factory and reuses it in registrar and subagents.
src/.pi/agents/reviewer/SYSTEM.md Converts reviewer into a background frontmatter-bearing agent body.
src/.pi/agents/researcher/SYSTEM.md Adds researcher background agent body under unified home.
src/.pi/agents/README.md Reconciles agent-body topology + discovery model (registry-listed backgrounds only).
src/.pi/agents/projector/SYSTEM.md Renames proposer→projector in the agent body.
src/.pi/agents/explorer/SYSTEM.md Renames scout→explorer and adds read_graph to tools list.
src/.pi/tests/prompt-shape-readmes.test.ts Updates assertions for the revised agents README prompt-shape section.
src/.pi/tests/architecture.test.ts Updates architecture expectations for unified agent bodies and new background agents.
package.json Updates build:pi-assets to copy the unified agent directories into dist/.pi/agents.
memory/SPEC.md Reconciles D44-L/I29-L text and glossary rows to D90-L/D91-L changes and new roster terminology.
memory/PLAN.md Marks slices 2b/3 done and updates acceptance wording to match unified home + D91-L.
memory/cards/subagent-reconciliation--world-inject-seal.md New completed scope card capturing D91-L world-injection + assembled prompt slice.
memory/cards/subagent-reconciliation--agent-home-unify.md New completed scope card capturing unified agent-home + rename migration slice.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/app/pi-subagents.ts
Comment on lines +74 to +77
export function renderSubagentSessionDigest(entries: readonly unknown[], maxEntries = 6): string {
if (entries.length === 0) return '- recent entries: none';
const recent = entries.slice(-maxEntries);
const omitted = entries.length - recent.length;
Make `execute` a live operational mode mapped to a new `orchestrator`
foreground agent, granted a code-owned `orchestrator_stub` tool (read-only
plus the stub; bash/edit/write blocked). `code`/`pi-coder` stays planned.
The orchestrator + stub register on the normal product extension path
(not dev-gated); canDelegate is [] so no worker lands this branch. Retires
HANDOFF.md and reconciles SPEC/PLAN + topology READMEs.

Co-authored-by: Cursor <cursoragent@cursor.com>
@lunelson lunelson merged commit acf17d5 into next Jun 24, 2026
6 checks passed
@lunelson lunelson deleted the ln/fe-1054-subagent-reconciliation-ii branch June 24, 2026 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants