Skip to content

FE-869: Runtime topology and prompt-resource ownership cleanup#216

Open
lunelson wants to merge 13 commits into
ln/fe-868-pi-runtime-rehabilitationfrom
ln/fe-869-runtime-topology-cleanup
Open

FE-869: Runtime topology and prompt-resource ownership cleanup#216
lunelson wants to merge 13 commits into
ln/fe-868-pi-runtime-rehabilitationfrom
ln/fe-869-runtime-topology-cleanup

Conversation

@lunelson

@lunelson lunelson commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

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?

  • Moves prompt-resource legality policy into .pi/extensions/runtime.
  • Moves prompt composition and seed-context rendering into .pi/extensions/system-prompts.
  • Keeps .pi/agents as markdown-only keyed agent role resources.
  • Moves workspace/session identity helpers into their owning topology.
  • Reconciles topology READMEs and contributing docs.

Why?

The old layout made .pi/agents carry 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.

lunelson added 13 commits June 15, 2026 12:20
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.

Copy link
Copy Markdown
Contributor Author

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.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@lunelson lunelson changed the title centralize constants FE-869: Runtime topology and prompt-resource ownership cleanup Jun 15, 2026
@lunelson lunelson marked this pull request as ready for review June 15, 2026 16:17
Copilot AI review requested due to automatic review settings June 15, 2026 16:17
@cursor

cursor Bot commented Jun 15, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Mostly file moves, import rewires, and documentation; runtime behavior should be unchanged aside from path resolution in manifest locations. Residual risk is missed import or test path references after deleting the old .pi/agents TypeScript surface.

Overview
Runtime topology cleanup so Pi prompt machinery no longer lives under .pi/agents/. That folder is markdown-only keyed role definitions (definitions/*.md); TypeScript prompt assembly moved to the extensions that consume it.

Prompt-resource legality and manifests move from .pi/agents/state.ts to .pi/extensions/runtime/state.ts (including path fixes for skill/agent markdown locations). Composition and pushed seed context move to .pi/extensions/system-prompts/ (compose.ts, COMPOSE goldens under __previews__/), with seed helpers renamed to renderWorkspaceSeed / renderGraphSeed to distinguish pushed prompt seeds from pull read_context tools and shared renderers/.

Workspace context ownership is tightened: cwd filesystem inventory goes to workspace/cwd-inventory, while multi-spec/session overview stays in session/workspace-overview-context; the context Pi tool imports are updated accordingly. Legacy .pi/agents barrel exports (index.ts, contexts/) are removed in favor of extension-local imports.

Docs/spec alignment: CONTRIBUTING.md is rewritten for current TUI/RPC/dev/seed workflows; memory/SPEC.md, memory/PLAN.md, and topology READMEs (D52-L/D58-L/D60-L) document the new split between agents (markdown), system-prompts/, runtime/, and context/.

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

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 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.json state 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 .brunch constants, 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) uses split, which allocates an array of all lines. For large .jsonl transcripts 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.

Comment on lines +51 to +60
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);
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