Repository navigation
Test and document warm environments with extra folders for any provider - #8094
Merged
Merged
Conversation
Tests prove that an environment a plugin holds keeps the additionalPaths its provider returned when a thread adopts it, that create can replace them after adopt, that restore receives the destroyed environment's folders, and that a restore which adopts keeps the warm environment's folders. No core change was needed. The Plugin Guide and the bb-plugin-authoring machines reference now show how a custom environment provider keeps prebuilt environments and hands them out, with a multi-folder provider as the example. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The doc-example test wraps each SDK example in a function body, so the example cannot export a plugin factory or call undeclared helpers. It now registers the provider from a function that takes the plugin's own StackBuilder. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
#7869 lets a plugin hold environments (
hold: "plugin") and hand one to a new thread withctx.adopt. Nothing showed that the folders a provider records with an environment (additionalPaths) survive that hand-off, or a later restore. The Plugin Guide did not explain how a custom provider keeps its own prebuilt environments.What changed
No core change: the engine already handles these cases. This PR adds the tests that prove it, and the docs.
Tests (
apps/server/test/environments/environment-holds.test.ts). The test provider now has arestoreand can returnadditionalPaths. New cases:additionalPaths. The environment response shows them.additionalPathsafteradoptreplaces them.previous.environment.additionalPaths, and the rebuilt environment records the folders restore returns.Docs.
bb-plugin-authoring/references/backend-machines.md: a new section, "Keeping prebuilt environments for your provider". It shows a complete provider whose environments are an app checkout plus siblingapianddocscheckouts. It covers building held environments withexperimental_create({ hold: "plugin" }), telling them apart increatebyheldBy, adopting a ready one, refilling, returning the resource afteradopt(orremove()gets null), and whatrestoremust return.plugin-api-docs/src/surfaces.ts): a reference paragraph on the Environment providers surface with the same rules.replacedProjectFoldersis left to #8065, which has not landed.How you verified
Live. I ran the docs example as a real plugin (
bb plugin installof a local "stack" provider) on apnpm start:worktreeserver.bb stack warm <project> <host>built a held environment withapp, plusapianddocsasadditionalPaths.apianddocsfolders as writable.remove()received the resource.bb thread restore-environmentrebuilt it with newapianddocsfolders, and the agent listed those after the restore.adopt, the stack's directory was never removed.previous.environment.additionalPathsas-is fromrestorepointed at the destroyed folders.Checks:
environment-holds.test.ts: 21 passed.pnpm exec turbo run typecheck lint --filter='...[origin/main]'.bb-plugin-plugin-api-docs,bb-plugin-bb-guideand@bb/templatestests.🤖 Generated with Claude Code