FE-869: Runtime topology and prompt-resource ownership cleanup#216
FE-869: Runtime topology and prompt-resource ownership cleanup#216lunelson wants to merge 13 commits into
Conversation
Relocates compose + the pushed prompt-seed renderers (workspace/graph) out of .pi/agents into the system-prompts extension that consumes them, and renames them to the seed vocabulary (renderWorkspaceSeed/renderGraphSeed) so 'context' no longer collides with renderers/ or the read_context pull tool. Behavior-preserving: graph seed rendering is unchanged.
Moves the agents topology guard to .pi/__tests__/ and rewrites .pi/agents/README to describe a markdown-only role-definition directory. Updates source, .pi, extensions, session, graph, and session-query READMEs so they point prompt composition at extensions/system-prompts and manifest/legality at extensions/runtime. Includes trailing format reflow from the prior moves.
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
PR SummaryLow Risk Overview Prompt-resource legality and manifests move from Workspace context ownership is tightened: cwd filesystem inventory goes to Docs/spec alignment: Reviewed by Cursor Bugbot for commit 52dc938. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Pull request overview
This PR realigns Brunch’s runtime topology with the intended ownership boundaries by moving prompt composition/seed rendering into .pi/extensions/system-prompts, moving prompt-resource legality/manifests into .pi/extensions/runtime, and extracting workspace identity + .brunch/workspace.json persistence into workspace/ so session coordination and render/context surfaces consume the right owning seams.
Changes:
- Introduces
workspace/-owned project identity discovery, cwd inventory, and.brunch/workspace.jsonstate persistence (with unit tests). - Moves workspace overview context building into
session/workspace-overview-context.ts, and rewires callers/renderers/tools to use the new split. - Centralizes
.brunchconstants, updates topology READMEs/boundary tests, and migrates.pi/agents/to markdown-only role definitions (prompt assembly now lives in extensions).
Reviewed changes
Copilot reviewed 46 out of 53 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/workspace/workspace-state-store.ts | New .brunch/workspace.json read/write module owned by workspace/. |
| src/workspace/workspace-state-store.test.ts | Tests for workspace state persistence + schema validation behavior. |
| src/workspace/README.md | Updates workspace ownership notes to include state store + inventory. |
| src/workspace/project-identity.ts | New shallow manifest-based project identity discovery + slugify. |
| src/workspace/project-identity.test.ts | Tests for manifest precedence and slugify normalization. |
| src/workspace/cwd-inventory.ts | Removes graph/session coupling; inventories cwd + session file sizes directly. |
| src/workspace/cwd-inventory.test.ts | Tests for gitignore-aware inventory + session/markdown sizing. |
| src/session/workspace-session-coordinator/canonical-session-files.ts | Uses shared constants; preserves canonical session classification behavior. |
| src/session/workspace-session-coordinator.ts | Delegates workspace.json persistence to workspace/ store; updates defaults writing. |
| src/session/workspace-overview-context.ts | New session-owned workspace overview composition (specs + session turn counts). |
| src/session/workspace-overview-context.test.ts | Tests overview node counts and session turn counts from fixtures + JSONL. |
| src/session/workspace-context.test.ts | Deletes legacy combined workspace-context tests (split into new homes). |
| src/session/README.md | Updates session ownership/docs for new workspace split + prompt topology. |
| src/rpc/methods/session.ts | Rewires overview context import to workspace-overview-context. |
| src/renderers/workspace/workspace-context.ts | Updates input type imports to new workspace/ + session/ sources. |
| src/renderers/README.md | Allows renderers to import workspace/ input types. |
| src/README.md | Updates top-level topology description and dependency rules. |
| src/projections/topology-boundaries.test.ts | Adds enforcement that workspace/ stays a leaf (no domain/adapter imports). |
| src/projections/session/readiness-estimate.test.ts | Updates paths for moved runtime state manifest file. |
| src/projections/README.md | Updates documentation for the new workspace context source split. |
| src/graph/workspace-store.ts | Uses shared constants; inlines data db filename. |
| src/graph/README.md | Updates prompt consumer references from .pi/agents to .pi/extensions/system-prompts. |
| src/constants.ts | New shared constants for .brunch dir and state/session filenames. |
| src/app/brunch-tui.ts | Rewires overview context import to new module. |
| src/.pi/skills/README.md | Updates manifest owner path from .pi/agents/state.ts to .pi/extensions/runtime/state.ts. |
| src/.pi/README.md | Updates .pi/agents description to markdown-only and moves prompt assembly ownership. |
| src/.pi/extensions/system-prompts/seed/workspace.ts | Renames workspace seed renderer and fixes import paths after move. |
| src/.pi/extensions/system-prompts/seed/workspace.test.ts | Updates tests to new seed renderer name/path. |
| src/.pi/extensions/system-prompts/seed/graph.ts | Renames graph seed renderer and fixes import paths after move. |
| src/.pi/extensions/system-prompts/seed/graph.test.ts | Updates tests to new graph seed renderer name/path. |
| src/.pi/extensions/system-prompts/previews.test.ts | Fixes preview normalization location after topology move. |
| src/.pi/extensions/system-prompts/index.ts | Switches to extension-owned compose/seed functions instead of .pi/agents exports. |
| src/.pi/extensions/system-prompts/compose.ts | Updates relative imports + pulls manifest data from runtime extension state. |
| src/.pi/extensions/system-prompts/compose.test.ts | Updates imports and expected root resolution after move. |
| src/.pi/extensions/system-prompts/previews/elicitor--pushed-context.md | New composed-prompt golden in new location. |
| src/.pi/extensions/system-prompts/previews/elicitor--pinned-strategy-lens.md | New composed-prompt golden in new location. |
| src/.pi/extensions/system-prompts/previews/elicitor--auto-high-coverage.md | New composed-prompt golden in new location. |
| src/.pi/extensions/system-prompts/previews/elicitor--auto-floor-gaps-open.md | New composed-prompt golden in new location. |
| src/.pi/extensions/session-query/README.md | Updates “does not own” section to new manifest/composition ownership. |
| src/.pi/extensions/runtime/state.ts | Moves manifest path resolution to account for new file location; updates imports. |
| src/.pi/extensions/runtime/state.test.ts | Updates imports to match new runtime manifest location. |
| src/.pi/extensions/runtime/index.ts | Rewires activeToolNamesForPosture import to local state.ts. |
| src/.pi/extensions/README.md | Updates extension directory descriptions for runtime/ and system-prompts/. |
| src/.pi/extensions/context/get-cwd.ts | Splits overview vs cwd-inventory imports per new ownership. |
| src/.pi/agents/README.md | Rewrites as markdown-only role-definition directory; documents migration. |
| src/.pi/agents/index.ts | Removes TypeScript export surface from .pi/agents. |
| src/.pi/agents/contexts/node.ts | Deletes legacy agents context renderer implementation. |
| src/.pi/agents/contexts/index.ts | Deletes legacy agents context renderer exports. |
| src/.pi/tests/prompting.test.ts | Rewires compose import to new extension-owned compose implementation. |
| src/.pi/tests/architecture.test.ts | New architecture guardrails for legacy prompt-path residues and resource bodies. |
| memory/SPEC.md | Updates decisions/invariants to match new prompt/runtime/workspace ownership topology. |
| memory/PLAN.md | Updates plan references to new runtime manifest location and compose golden paths. |
| CONTRIBUTING.md | Updates contributor docs to match the new topology + current dev commands. |
Comments suppressed due to low confidence (1)
src/workspace/cwd-inventory.ts:174
countLines(content)usessplit, which allocates an array of all lines. For large.jsonltranscripts this adds avoidable memory pressure during inventory collection. Counting newline characters avoids the extra allocation while keeping behavior identical (including the trailing-newline +1 line).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const sessions = await inspectCanonicalSessionFiles(resolvedCwd); | ||
| const availableSessions = await Promise.all( | ||
| sessions | ||
| .filter((session) => session.available) | ||
| .map(async (session) => { | ||
| const spec = specsById.get(session.specId); | ||
| if (!spec) { | ||
| return null; | ||
| } | ||
| const entries = await readJsonl(session.file); |

Stack Context
This stack is a post-demo rehabilitation pass. The previous PR stabilizes the runtime baseline; this PR makes the Pi runtime topology match the ownership model before renderer/context coverage continues above it.
What?
.pi/extensions/runtime..pi/extensions/system-prompts..pi/agentsas markdown-only keyed agent role resources.Why?
The old layout made
.pi/agentscarry both semantic agent prompt resources and runtime prompt machinery. This PR separates those concerns so future renderer and agent-context coverage has a clearer ownership boundary.