Skip to content

feat(workspace): per-thread workspace resolver, and the rung 3 design - #780

Merged
blove merged 15 commits into
mainfrom
blove/software-factory-rung3-spec
Sep 22, 2026
Merged

blove merged 15 commits into
mainfrom
blove/software-factory-rung3-spec

Conversation

@blove

@blove blove commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Sub-project 1 of the software factory's rung 3 (live issues), plus the rung 3 design and its plan.

  • sandbox.workspace in b4.config.ts may now be a WorkspaceResolver: host code called once per thread, at first admission, with { threadId, metadata, signal }, returning that thread's initial WorkspaceDefinition (captured then) or CapturedWorkspaceDefinition (verified). The result is recorded by digest in the thread's creation intent exactly as a static definition is; later turns, restarts and readers use the record.
  • b4 build records a resolver marker { version: 2, kind: "resolver" } in place of captured source; startup refuses an artifact whose form disagrees with the config in either direction ("Workspace configuration changed; rebuild the app"); version-1 artifacts still boot. b4 check reports the per-thread form.
  • The runtime hands admission a lazy loader for the thread's stored client metadata (reserved key stripped, shape-guarded, frozen), keyed by the sandbox key so subagents resolve through their parent's thread.
  • Docs: API contract, exports, lifecycle, and a sandbox.mdx "Per-thread workspaces" section. Minor changeset for @b4run/workspace and @b4run/cli.
  • Design: docs/superpowers/specs/2026-09-21-software-factory-rung3-design.md (decisions, two framework findings, sub-project ladder, "As landed" notes). Plan: docs/superpowers/plans/2026-09-21-per-thread-workspace-resolver.md.

Every task was reviewed twice (spec, then quality) and a final whole-branch review ran; findings were fixed or recorded.

Backward compatibility

A static sandbox.workspace behaves exactly as before at boot, build, check, admission, restart and read. One observable change: the canonical threads-store resolution is hoisted above admission (below the managed-workspace guard), so a fallback-less embedder with no store fails before admission rather than after.

Follow-ups recorded in the spec (§9)

  • Orphan workspace_sources rows when provider.resolveEnvironment fails after the source is put (pre-existing for the dev hook; a reclaim is the fix).
  • The development recapture hook loads thread metadata it ignores.
  • Per-thread permissions (§5.4): the builder app will run on the union of its targets' allow-lists until then.
  • The factory two-thread sandbox lane belongs to sub-project 3.

Merge note

Squash-merge. Task 1 widens the type before the CLI adapts to it, so the CLI typecheck is red from the first code commit until the fourth; the commits are not bisectable as a series.

Test plan

  • @b4run/workspace and @b4run/cli lint, typecheck, tests (2093 passed) green locally
  • B4_TEST_DOCKER=1 managed-workspace process and reader lanes green
  • node scripts/check-docs.mjs and seo:lastmod:check green
  • examples/code-fixer has no diff; both example servers typecheck
  • CI validate green

🤖 Generated with Claude Code

blove and others added 15 commits September 21, 2026 19:36
…d oracle

Records the design conversation's decisions (model-drafted human-approved
oracle, operator-pulled intake, target per package with the pin recorded at
create, approve-or-reject gate), the two framework findings (per-thread
workspace resolution; no durable model-free workflow primitive), the
controller's move onto b4 workflow routes, and the sub-project ladder.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ace resolver

Sub-project 1 of rung 3. Eight tasks, TDD, one commit each; verified against
the managed-workspace manager, artifact, resolver and runtime seams on main.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Async-only resolver with an abort signal on its input, the example test that
reads sandbox.workspace, the expected-red gates between tasks, and a
strengthened type test.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Abort check before the source write, distinct empty-result error, guarded
and cancellable metadata loader, docs on the resolver's critical section,
and the orphan-source reclaim recorded as a follow-up.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
What the resolver sees in metadata, the server-assigned thread id, and the
b4 run behaviour, for the docs task and the spec's §5.2.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@vercel

vercel Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
b4-run Ready Ready Preview Sep 22, 2026 4:46am UTC

Request Review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated approval: this PR received an intelligent (AI) code review. See the review comments on this PR.

@blove
blove enabled auto-merge (squash) September 22, 2026 04:46
@blove
blove merged commit 71bccb3 into main Sep 22, 2026
31 of 32 checks passed
@blove
blove deleted the blove/software-factory-rung3-spec branch September 22, 2026 05:01

This branch was successfully deployed

1 active and 1 inactive deployments
Preview — 470426ce Deployed Sep 22, 2026 by vercel[bot]
vercel-preview — 470426ce Deployed Sep 22, 2026 by blove via vercel-native #2175
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.

1 participant