Skip to content

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

Merged
lunelson merged 13 commits into
nextfrom
ln/fe-869-runtime-topology-cleanup
Jun 16, 2026
Merged

FE-869: Runtime topology and prompt-resource ownership cleanup#216
lunelson merged 13 commits into
nextfrom
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 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

@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

Medium Risk
Mostly moves and doc/test path updates, but prompt composition and active-tool legality are on the hot path for every agent turn—wrong imports or manifest paths would break TUI/RPC prompting without necessarily failing unit tests alone.

Overview
Runtime topology cleanup so Pi prompt machinery no longer lives under .pi/agents/. Prompt-resource manifest and method/tool legality move to .pi/extensions/runtime/state.ts; composeAgentPrompt and COMPOSE goldens move to .pi/extensions/system-prompts/; pushed turn context uses renamed renderWorkspaceSeed / renderGraphSeed under system-prompts/seed/. The old .pi/agents/ TypeScript barrel (compose.ts, state.ts, contexts/) is removed—.pi/agents/ is markdown role definitions only (.pi/skills/-style).

Import rewires: runtime/ and system-prompts/ consume the moved modules; tests and invariants in memory/SPEC.md point at the new paths. Workspace cwd inventory inspection moves to workspace/cwd-inventory.js; overview/session aggregation stays in session/workspace-overview-context.ts, with get-cwd.ts updated accordingly.

Docs: CONTRIBUTING.md is rewritten for current TUI/RPC dev flow, D52-L topology, and explicit seeding; memory/PLAN.md and memory/SPEC.md (D52-L, D58-L, D60-L, D74-L, I31-L, I35-L, I38-L, I42-L) document the manipulations split and completed topology-readmes work.

Reviewed by Cursor Bugbot for commit ab4e03f. 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);
Base automatically changed from ln/fe-868-pi-runtime-rehabilitation to next June 16, 2026 16:50
lunelson added 13 commits June 16, 2026 16:51
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.
@lunelson lunelson force-pushed the ln/fe-869-runtime-topology-cleanup branch from 52dc938 to ab4e03f Compare June 16, 2026 16:51
@graphite-app

graphite-app Bot commented Jun 16, 2026

Copy link
Copy Markdown

Merge activity

  • Jun 16, 4:51 PM UTC: Graphite rebased this pull request, because this pull request is set to merge when ready.

@lunelson lunelson merged commit c4e2b0b into next Jun 16, 2026
6 checks passed
@lunelson lunelson deleted the ln/fe-869-runtime-topology-cleanup branch June 16, 2026 16:53
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