Skip to content

FE-1842: Gather Brunch's website code under its plugin and stop packages importing each other's files - #10029

Merged
lunelson merged 29 commits into
mainfrom
ln/fe-1842-brunch-topology
Oct 15, 2026
Merged

lunelson merged 29 commits into
mainfrom
ln/fe-1842-brunch-topology

Conversation

@lunelson

@lunelson lunelson commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

🌟 Purpose

This PR provisionally settles the layout, for the various packages contributing to brunch-agent concerns; it also ensures that import paths across packages follow repository rules and conventions; and finally it aligns (at least on a file-placement level) with the new petrinaut "plugin API" in terms of isolating UI code.

🔍 Changes

Start with apps/petrinaut-website/src/main/app/plugins/brunch/use-brunch-assistant.tsx: everything else either moved into the Brunch plugin folder around it or stopped importing across packages.

  • One Brunch hook replaces the shell's wiring. useBrunchAssistant assembles Brunch's assistant (Flue client, document binding, mutation approval, Ledger tab, transport, history, stop, Voice check) and returns the host's plugins with Brunch's added. The demo shell drops from about 790 to 290 lines and only chooses between Brunch and the stock assistant.
  • Brunch's cards read the editor through a plugin api. A required website.brunch plugin publishes its own api as a plugin service; the approval, follow-up and draft-experiment cards take it as a prop instead of reading Petrinaut's React contexts. The draft card is the exception that remains: it takes the document handle, because Brunch hashes the full document (see Known issues).
  • Voice moves under plugins/brunch/voice. Renames and import paths only.
  • The stock assistant no longer borrows Brunch's conversation id. Petrinaut already keys the panel by net, so the stock chat still starts fresh per net.
  • No package imports another's files by relative path. no-restricted-imports now rejects relative paths that leave the package, in the website, the Brunch app and library, @local/pi-faux-providers and the new test package. Two moves follow from it:
    • The four website tests that run against the built Brunch server move to a new package, tests/petrinaut-brunch-integration, which depends on both apps, like tests/hash-backend-integration does for the HASH API. The website no longer depends on Brunch's server, so its builds and deploys don't build it.
    • pi-ai provider doubles move to a private @local/pi-faux-providers, and the app exports its built-server harness as @apps/brunch-agent/testing/*.
  • Unit tests sit beside their modules in the Brunch app and library. The Docker image deletes the app's src/ and test/ after the build and runs from dist/. Nothing ships from src/ now that FE-1764: Keep elicited knowledge in an efficient append-only Ledger #9865 drops the RDS IAM probe, which was the one script that ran from it.

Users see one change: while Brunch is the assistant, User settings → Plugins lists Brunch, with no switch. Petrinaut's packages are untouched.

⚠️ Known issues

  • Brunch still depends on Petrinaut where the plugin API can't reach yet. Each needs a change inside Petrinaut:
    • Petrinaut's assistant panel renders Brunch's transcript, and Brunch imports Petrinaut's assistant types and components (FE-1958, then FE-1960).
    • Petrinaut's panel runs Brunch's tools against the raw document handle (FE-1959).
  • The draft card checks revisions against the full document, not api.document.net, which leaves out data for disabled extensions. The two are equal on the website. A test pins the current choice until it is decided (FE-1961).
  • website/plugins.mdx in the Petrinaut architecture docs doesn't list website.brunch yet (FE-1962), and nobody has checked the new Plugins entry in a browser.
  • The new test package's test:integration depends on ^build, so it also builds the website bundle.

@lunelson
lunelson requested review from a team as code owners October 13, 2026 15:13
@lunelson
lunelson added this pull request to stack #9964 October 13, 2026 15:13
@vercel

vercel Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hash Ready Ready Preview Oct 15, 2026 10:11am UTC
petrinaut Ready Ready Preview Oct 15, 2026 10:11am UTC
petrinaut-docs Ready Ready Preview Oct 15, 2026 10:11am UTC
1 Skipped Deployment
Project Deployment Actions Updated
hashdotdesign-tokens Ignored Ignored Preview Oct 15, 2026 10:11am UTC

Request Review

@cursor

cursor Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches Brunch assistant wiring, destructive-edit approvals, and draft experiment flows in the real editor; Docker and import-boundary changes affect builds and cross-package test layout but not production auth or data stores.

Overview
Consolidates Brunch on the Petrinaut website into plugins/brunch/: a new useBrunchAssistant hook owns Flue transport, document binding, mutation approval, Ledger tab, and Voice, shrinking the demo shell to assistant selection only. Brunch UI cards (destructive approvals, draft experiments, experiment follow-up) now read the editor through a required website.brunch plugin api instead of Petrinaut React contexts; the draft card still uses the document handle for revision checks when extensions hide data from api.document.net.

Enforces workspace import hygiene with no-restricted-imports (website + brunch-agent): no relative paths into other packages. Faux pi-ai providers move to @local/pi-faux-providers; the built-server harness is exported as @apps/brunch-agent/testing/*. Website integration tests that hit the built Brunch server move to @tests/petrinaut-brunch-integration (website drops test:integration and heavy Brunch build deps). Brunch-agent unit tests live beside src/; the Docker image strips src/ and test/ after build.

Brunch-agent test/tooling tweaks: persona browser turn waits for admission before watching approvals; generic agent admission URL matching; new manual test:manual:browser:persona witness; admission-controls runner exported for reuse.

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

@github-actions github-actions Bot added area/deps Relates to third-party dependencies (area) area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > frontend Owned by the @frontend team type/eng > backend Owned by the @backend team area/tests New or updated tests area/apps type/legal Owned by the @legal team labels Oct 13, 2026
@lunelson lunelson changed the title ln/fe 1842 brunch topology FE-1842: Gather Brunch's website code under its plugin and stop packages importing each other's files Oct 13, 2026
@lunelson
lunelson force-pushed the ln/fe-1842-brunch-topology branch from 004fec1 to e7969c2 Compare October 14, 2026 07:21
@lunelson
lunelson force-pushed the ln/fe-1842-brunch-topology branch from e7969c2 to 4e5087a Compare October 14, 2026 08:41
@lunelson
lunelson requested a review from CiaranMn October 14, 2026 08:44
Comment thread tests/petrinaut-brunch-integration/.oxlintrc.json
…ssion wiring and fold provider admission back into the app
The four website tests that need the built Brunch server move to
`tests/petrinaut-brunch-integration`, which depends on both apps. The website
no longer depends on Brunch's server, so its builds and deploys do not build
it. `@local/brunch-testing` is removed: its harness returns to
`apps/brunch-agent/test/` and is exported as `@apps/brunch-agent/testing/*`,
so no package loads another's build by relative path.
Moving one of those modules already fails the test package's type check, and tests/hash-backend-integration imports deep paths the same way without one.
The probe was the one script the image ran from src/. Without it the Dockerfile removes the app's src/ and test/ after the build; the server runs from dist/.
A Brunch card without the plugin's api rendered nothing, so an approval waited with nothing to answer it. The editor shows its view only after every plugin has run, so a missing api means the host left the plugin out or it failed: the card now says so and reports the failure. The file is renamed to editor-api-plugin.tsx, since use-brunch-assistant.tsx is Brunch's entry point.
The rule caught relative paths into another package's src or dist, but not into its test folder or anything under tests/, so imports this branch removed, such as the website's reach into brunch-agent/test, would still have passed.
document and editor described the same open document: one carried the id the conversation binds to, the other its live handle once loaded. BrunchOpenDocument holds both, with the handle null while the document loads.
The transport answered every send with a stream that closed at once. The tool call stayed waiting, so the editor's chat sent again in a loop that starved timers. On CI a query timed out under that load, and the worker ran out of memory after an hour. A stream that stays open, as a real turn does, makes one send.
…sends

A static tool-deleteItemsByIds part is one the editor runs itself, so the seeded call ran without anyone answering and the turn continued. Brunch's calls are dynamic tools the editor leaves to the host.

@TimDiekmann TimDiekmann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Re-approval

This branch was successfully deployed

3 active deployments
Preview – hash — fdc60e91 Deployed Oct 15, 2026 by vercel[bot]
Preview – petrinaut-docs — fdc60e91 Deployed Oct 15, 2026 by vercel[bot]
Preview – petrinaut — fdc60e91 Deployed Oct 15, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/apps area/deps Relates to third-party dependencies (area) area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) area/tests New or updated tests type/eng > backend Owned by the @backend team type/eng > frontend Owned by the @frontend team type/legal Owned by the @legal team

Development

Successfully merging this pull request may close these issues.

7 participants