From ea970f478c69dd4f662126b8108b0070be462ee7 Mon Sep 17 00:00:00 2001 From: Dotta Date: Mon, 12 Oct 2026 20:03:37 -0500 Subject: [PATCH] fix(workspaces): keep selected source provisioning off controller Bind provisioning to the selected execution environment and durable copy-only source lineage. Preserve suppression through reuse, rebuild, metadata changes and reopen while retaining implicit trusted local defaults. Co-Authored-By: Paperclip --- doc/plans/2026-10-09-task-workspaces.md | 2 + maps/agent-access-map/workspaces.md | 13 +++- maps/feature-map/workspaces.md | 15 +++- maps/storybook-map/INDEX.md | 24 +++--- maps/storybook-map/REVIEW.md | 5 ++ maps/storybook-map/catalog.json | 72 ++++++++--------- .../execution-workspace-reopen.test.ts | 30 +++++++- .../heartbeat-project-repositories.test.ts | 23 ++++-- .../heartbeat-workspace-session.test.ts | 34 ++++---- .../heartbeat-workspace-source-trust.test.ts | 77 +++++++++++++++++++ .../workspace-host-provision.test.ts | 44 +++++++++++ .../src/__tests__/workspace-runtime.test.ts | 28 +++++++ server/src/services/execution-workspaces.ts | 11 ++- server/src/services/heartbeat.ts | 5 +- .../services/heartbeat/runtime-services.ts | 2 + .../heartbeat/workspace-preparation.test.ts | 18 +++++ .../heartbeat/workspace-preparation.ts | 22 ++++-- server/src/services/heartbeat/workspaces.ts | 18 ++--- .../src/services/workspace-host-provision.ts | 27 +++++++ server/src/services/workspace-runtime.ts | 5 +- 20 files changed, 379 insertions(+), 96 deletions(-) create mode 100644 server/src/__tests__/workspace-host-provision.test.ts create mode 100644 server/src/services/workspace-host-provision.ts diff --git a/doc/plans/2026-10-09-task-workspaces.md b/doc/plans/2026-10-09-task-workspaces.md index 8e0774d737d..27362c41b43 100644 --- a/doc/plans/2026-10-09-task-workspaces.md +++ b/doc/plans/2026-10-09-task-workspaces.md @@ -51,6 +51,8 @@ Repository identity alone does not prove that a workspace published into a parti Reopening has no selected execution lease. Before rebuilding a worktree, resolve the bound task’s current task, assignee, organizational-project and filesystem-source policies inside the lifecycle transaction. Any effective low-trust policy suppresses both configured and built-in host provision scripts. Missing referenced authority or denied policy blocks reopening; trusted provisioning keeps its existing behavior. A board comment does not authorize sandbox repository scripts to execute on the host. +Admission derives controller provisioning from the authoritative selected environment, independently of task trust and filesystem permissions. Sandbox and SSH selections suppress configured and built-in controller provision scripts during creation, reuse and rebuild, including host runtime provisioning. Read-only source copying remains available for genuine isolated worktrees; source write grants and board sponsorship do not authorize controller execution. Selected isolated sources are copy-only for controller provisioning even when execution is local: explicit, channel, inherited and legacy choices do not record host-script approval. Foreign organizational/source project lineage and nondefault legacy sources also remain copy-only. Persist a deny-only marker on the realized workspace and preserve it through metadata updates, binding changes, reuse, rebuild and reopening; missing source authority must not become a default approval. Existing implicit trusted local project defaults and taskless operator runs with no source retain their behavior. Unknown task-backed or projectless source identity stays copy-only; the reserved operator-cwd provenance compatibility branch does not imply a new producer or approval API. SSH retains its explicit remote provision-command path. Sandbox workspace staging does not add a remote provision-command or runtime-provision transport in this change. + Channel defaults use optional properties (inherit), explicit null (clear), concrete value (override). Resource override beats endpoint. Defaults are captured once at task creation and reauthorized on use. Changing/deleting/revoking configuration cannot relocate existing tasks. Project choice and workspace choice are independent; choosing a source does not silently assign organizational project. Endpoints without configuration work normally. The organizational task project retains task identity, environment, and secret scope regardless of the filesystem source. An organizational project with no usable configured folder or repository is not a filesystem source. Unbound tasks without typed selection still retain that project's explicit workspace requirements; persisted and typed source choices retain precedence. Both task-project and source-project policies constrain run trust; source policy controls workspace realization. Channel task creation separately checks assignment authority for the effective organizational project and actual assignee against locked endpoint values inside its transaction. Saving defaults does not grant future senders that authority. diff --git a/maps/agent-access-map/workspaces.md b/maps/agent-access-map/workspaces.md index a0d074a9c65..c8cc584b775 100644 --- a/maps/agent-access-map/workspaces.md +++ b/maps/agent-access-map/workspaces.md @@ -40,8 +40,17 @@ selection applies at the next normal admission without interrupting a live run. Writable aliases must also be compatible with current and retained physical source projects' trust boundaries. Incompatible choices are rejected before dispatch; a projectless alias cannot bypass required sandbox containment. -Source-copy checks apply the same trust boundary before provisioning. Low-trust -sandbox runs skip host worktree provisioning, including built-in scripts. +Source-copy checks apply the same trust boundary before provisioning. The +authoritative sandbox or SSH selection suppresses configured and built-in +controller worktree and runtime provisioning regardless of task trust, source +write grants or board sponsorship. Genuine isolated worktrees still permit +authorized read-only source copying. Source write permission does not authorize +controller execution. Explicit, channel, inherited, foreign or nondefault isolated +source choices remain copy-only for controller provisioning even on local runs. +Their deny-only workspace marker survives metadata and binding changes; a board +reopen does not turn it into approval. Implicit trusted local defaults and explicit +SSH remote provisioning retain their existing placement; no new sandbox provision transport +is claimed. Closed-worktree reopening checks current task, agent, organizational and source policies without assuming a future driver. Effective low-trust reopens suppress configured and built-in host scripts. Returned checkpoints must have directory parents for every nested entry before merging, including unchanged entries; invalid output leaves retained host files intact and keeps recovery evidence. Child creation by an admitted agent checks an explicit prospective-task context before the child is saved. The creator run must have an authoritative saved policy and a verified company/agent/parent lineage. Current parent, prospective child and physical source policies must fit that boundary. This creation path does not relax exact task/run checks for existing-task writes. The [child trust regression](../../server/src/__tests__/task-workspace-child-trust.test.ts) is automated source-level evidence, not live agent qualification. Source review for these additions: PR #15749 and diff --git a/maps/feature-map/workspaces.md b/maps/feature-map/workspaces.md index 55d5558cef8..ce40b0ec292 100644 --- a/maps/feature-map/workspaces.md +++ b/maps/feature-map/workspaces.md @@ -48,10 +48,17 @@ An existing projectless folder alias of a sandbox-restricted project must be rejected for a standard local task before its adapter executes. Repeat after relocating the configured source; retained ownership must still enforce the boundary. This is separate from ordinary authorized file preview/download. -For a registered low-trust worktree running in a sandbox, a configured or built-in -provision script must not run on the host during fresh creation, reuse, or rebuild. -Verify the adapter still selects the sandbox and ordinary trusted provisioning -continues to work. +For a registered worktree selected for a sandbox or SSH environment, configured +and built-in provision scripts must not run on the controller during fresh +creation, reuse, or rebuild, including host runtime provisioning. Repeat with +standard trust and a protected read-only source, then with source write grants; +permissions must not change execution placement. Verify isolated source copying +and selected-environment dispatch still work. Repeat an explicit local isolated +source choice: copying remains available but controller scripts must stay absent, +including after binding or metadata changes and closed-worktree reopening. An +implicit trusted local project default remains a positive provisioning control. +SSH keeps its explicit remote provision-command path; these checks +do not claim a new sandbox provision transport. Low-trust closed-worktree reopening, including a board-comment reopen of a projectless task, must also suppress both kinds of host provision script. Returned checkpoints must reject file, symlink or missing parents before host writes, even if a nested file is marked unchanged. The retained host file and recovery evidence must survive rejection. These are automated safety contracts, not new live runtime acceptance. For a child created by an admitted agent with an explicit existing workspace, verify that a matching sandbox boundary permits creation before the child has an ID. A changed child policy, unrelated parent, or forged creator run must fail. See the [child workspace trust regression](../../server/src/__tests__/task-workspace-child-trust.test.ts). This automated contract does not add live acceptance evidence. diff --git a/maps/storybook-map/INDEX.md b/maps/storybook-map/INDEX.md index 85ebd42d8b2..a65ca63edc6 100644 --- a/maps/storybook-map/INDEX.md +++ b/maps/storybook-map/INDEX.md @@ -179,9 +179,9 @@ Status describes product alignment; implementation describes the rendered subjec | [Tasks and conversations/Documents, attachments, and work products/Product/Documents/Annotations](../../ui/storybook/stories/documents-artifacts/document-annotations.stories.tsx) | `documents-artifacts/annotations` | unreviewed / production / fixtures | 9 / 0 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. | | [Tasks and conversations/Documents, attachments, and work products/Product/Document Comments](../../ui/storybook/stories/documents-artifacts/document-comments.stories.tsx) | `documents-artifacts/annotations` | unreviewed / production / fixtures | 1 / 0 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. | | [Tasks and conversations/Documents, attachments, and work products/Components/File Viewer Sheet](../../ui/storybook/stories/documents-artifacts/file-viewer.stories.tsx) | `documents-artifacts/attachments` | unreviewed / production / fixtures | 13 / 0 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. | -| [Tasks and conversations/Documents, attachments, and work products/HTML artifacts/01 Preview](../../ui/storybook/stories/documents-artifacts/html-artifacts/01-preview.stories.tsx) | `documents-artifacts/attachments`, `workspaces/files-git` | unreviewed / production / fixtures | 5 / 0 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. | -| [Tasks and conversations/Documents, attachments, and work products/HTML artifacts/02 Workspace](../../ui/storybook/stories/documents-artifacts/html-artifacts/02-workspace.stories.tsx) | `documents-artifacts/attachments`, `workspaces/files-git` | unreviewed / production / fixtures | 3 / 0 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. | -| [Tasks and conversations/Documents, attachments, and work products/HTML artifacts/03 Task journey](../../ui/storybook/stories/documents-artifacts/html-artifacts/03-task-journey.stories.tsx) | `documents-artifacts/attachments`, `workspaces/files-git` | unreviewed / production / fixtures | 3 / 0 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. | +| [Tasks and conversations/Documents, attachments, and work products/HTML artifacts/01 Preview](../../ui/storybook/stories/documents-artifacts/html-artifacts/01-preview.stories.tsx) | `documents-artifacts/attachments`, `workspaces/files-git` | unreviewed / production / fixtures | 5 / 0 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. The provisioning recipe requires controller script denial for remote selections and copy-only local source choices, including retained denial through metadata changes and reopening; these fixtures do not verify execution placement. | +| [Tasks and conversations/Documents, attachments, and work products/HTML artifacts/02 Workspace](../../ui/storybook/stories/documents-artifacts/html-artifacts/02-workspace.stories.tsx) | `documents-artifacts/attachments`, `workspaces/files-git` | unreviewed / production / fixtures | 3 / 0 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. The provisioning recipe requires controller script denial for remote selections and copy-only local source choices, including retained denial through metadata changes and reopening; these fixtures do not verify execution placement. | +| [Tasks and conversations/Documents, attachments, and work products/HTML artifacts/03 Task journey](../../ui/storybook/stories/documents-artifacts/html-artifacts/03-task-journey.stories.tsx) | `documents-artifacts/attachments`, `workspaces/files-git` | unreviewed / production / fixtures | 3 / 0 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. The provisioning recipe requires controller script denial for remote selections and copy-only local source choices, including retained denial through metadata changes and reopening; these fixtures do not verify execution placement. | | [Tasks and conversations/Documents, attachments, and work products/Task Chat/Rich Work Product Cards](../../ui/storybook/stories/documents-artifacts/rich-work-product-cards.stories.tsx) | `documents-artifacts/work-products` | unreviewed / production / fixtures | 9 / 3 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. | | [Tasks and conversations/Documents, attachments, and work products/Tasks/Artifact Gallery](../../ui/storybook/stories/documents-artifacts/task-artifact-gallery.stories.tsx) | `documents-artifacts/library`, `documents-artifacts/work-products` | unreviewed / production / fixtures | 8 / 0 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. | | [Tasks and conversations/Documents, attachments, and work products/Tasks/Text file tabs](../../ui/storybook/stories/documents-artifacts/task-text-files.stories.tsx) | `documents-artifacts/attachments` | unreviewed / production / fixtures | 7 / 0 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. | @@ -257,9 +257,9 @@ Status describes product alignment; implementation describes the rendered subjec | Story suite | Capabilities | Product / implementation / data | Stories / play functions | Review note | | --- | --- | --- | --- | --- | | [Projects and execution/Projects and repositories/Proposals/Project repos/New project](../../ui/storybook/stories/projects/new-project-repos.stories.tsx) | `projects/repositories` | proposed / mixed / fixtures | 18 / 5 | RepositoryEditor is shipped, but NewProjectPrototype composes its own creation flow. Preserve proposal until route parity is checked. | -| [Projects and execution/Projects and repositories/Workspaces/Project runtime provision command](../../ui/storybook/stories/projects/project-execution-workspace-strategy.stories.tsx) | `projects/defaults`, `workspaces/provisioning` | unreviewed / production / fixtures | 2 / 0 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. | +| [Projects and execution/Projects and repositories/Workspaces/Project runtime provision command](../../ui/storybook/stories/projects/project-execution-workspace-strategy.stories.tsx) | `projects/defaults`, `workspaces/provisioning` | unreviewed / production / fixtures | 2 / 0 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. The provisioning recipe requires controller script denial for remote selections and copy-only local source choices, including retained denial through metadata changes and reopening; these fixtures do not verify execution placement. | | [Projects and execution/Projects and repositories/Proposals/Project repos/Configuration](../../ui/storybook/stories/projects/project-repos-configuration.stories.tsx) | `projects/repositories` | proposed / mixed / fixtures | 12 / 0 | Production properties plus local configuration page composition; repository interaction is simulated. | -| [Projects and execution/Projects and repositories/Product/Projects Goals Workspaces](../../ui/storybook/stories/projects/projects-goals-workspaces.stories.tsx) | `projects/lifecycle`, `goals/hierarchy`, `workspaces/binding` | unreviewed / production / fixtures | 1 / 0 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed nullable project references and guarded runtime invalidations. Existing summaries remain project-bound and retain their routes; null-project execution workspace rendering and controls remain a coverage gap. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. | +| [Projects and execution/Projects and repositories/Product/Projects Goals Workspaces](../../ui/storybook/stories/projects/projects-goals-workspaces.stories.tsx) | `projects/lifecycle`, `goals/hierarchy`, `workspaces/binding` | unreviewed / production / fixtures | 1 / 0 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed nullable project references and guarded runtime invalidations. Existing summaries remain project-bound and retain their routes; null-project execution workspace rendering and controls remain a coverage gap. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. The provisioning recipe requires controller script denial for remote selections and copy-only local source choices, including retained denial through metadata changes and reopening; these fixtures do not verify execution placement. | ## questions-and-approvals @@ -424,13 +424,13 @@ Status describes product alignment; implementation describes the rendered subjec | Story suite | Capabilities | Product / implementation / data | Stories / play functions | Review note | | --- | --- | --- | --- | --- | -| [Projects and execution/Workspaces, services, and files/Tasks/Browser Use/Task activity](../../ui/storybook/stories/workspaces/browser-use-activity.stories.tsx) | `workspaces/services`, `tasks/discussion` | unreviewed / production / fixtures | 7 / 0 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. | -| [Projects and execution/Workspaces, services, and files/Tasks/Browser Use/Footer](../../ui/storybook/stories/workspaces/browser-use-footer.stories.tsx) | `workspaces/services`, `tasks/discussion` | unreviewed / production / fixtures | 21 / 2 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. | -| [Projects and execution/Workspaces, services, and files/Tasks/Browser Use/Panel](../../ui/storybook/stories/workspaces/browser-use.stories.tsx) | `workspaces/services`, `tasks/discussion` | unreviewed / production / fixtures | 28 / 3 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. | -| [Projects and execution/Workspaces, services, and files/Components/SearchableSelect/Workspace picker](../../ui/storybook/stories/workspaces/searchable-select.stories.tsx) | `workspaces/binding` | unreviewed / production / fixtures | 9 / 0 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. | -| [Projects and execution/Workspaces, services, and files/Issue/Workspace File Browser](../../ui/storybook/stories/workspaces/workspace-file-browser.stories.tsx) | `workspaces/files-git` | unreviewed / production / fixtures | 6 / 0 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. | -| [Projects and execution/Workspaces, services, and files/Workspaces/Runtime provisioning status](../../ui/storybook/stories/workspaces/workspace-runtime-provisioning.stories.tsx) | `workspaces/provisioning` | unreviewed / production / fixtures | 6 / 0 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed ExecutionWorkspaceDetail null-project handling. This suite mounts only the unchanged RuntimeProvisionStatusValue inside a local context row; it does not exercise the full detail page or projectless queries. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. | -| [Projects and execution/Workspaces, services, and files/Workspaces/Service control bar](../../ui/storybook/stories/workspaces/workspace-service-control-bar.stories.tsx) | `workspaces/services` | unreviewed / production / fixtures | 16 / 0 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. | +| [Projects and execution/Workspaces, services, and files/Tasks/Browser Use/Task activity](../../ui/storybook/stories/workspaces/browser-use-activity.stories.tsx) | `workspaces/services`, `tasks/discussion` | unreviewed / production / fixtures | 7 / 0 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. The provisioning recipe requires controller script denial for remote selections and copy-only local source choices, including retained denial through metadata changes and reopening; these fixtures do not verify execution placement. | +| [Projects and execution/Workspaces, services, and files/Tasks/Browser Use/Footer](../../ui/storybook/stories/workspaces/browser-use-footer.stories.tsx) | `workspaces/services`, `tasks/discussion` | unreviewed / production / fixtures | 21 / 2 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. The provisioning recipe requires controller script denial for remote selections and copy-only local source choices, including retained denial through metadata changes and reopening; these fixtures do not verify execution placement. | +| [Projects and execution/Workspaces, services, and files/Tasks/Browser Use/Panel](../../ui/storybook/stories/workspaces/browser-use.stories.tsx) | `workspaces/services`, `tasks/discussion` | unreviewed / production / fixtures | 28 / 3 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. The provisioning recipe requires controller script denial for remote selections and copy-only local source choices, including retained denial through metadata changes and reopening; these fixtures do not verify execution placement. | +| [Projects and execution/Workspaces, services, and files/Components/SearchableSelect/Workspace picker](../../ui/storybook/stories/workspaces/searchable-select.stories.tsx) | `workspaces/binding` | unreviewed / production / fixtures | 9 / 0 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. The provisioning recipe requires controller script denial for remote selections and copy-only local source choices, including retained denial through metadata changes and reopening; these fixtures do not verify execution placement. | +| [Projects and execution/Workspaces, services, and files/Issue/Workspace File Browser](../../ui/storybook/stories/workspaces/workspace-file-browser.stories.tsx) | `workspaces/files-git` | unreviewed / production / fixtures | 6 / 0 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. The provisioning recipe requires controller script denial for remote selections and copy-only local source choices, including retained denial through metadata changes and reopening; these fixtures do not verify execution placement. | +| [Projects and execution/Workspaces, services, and files/Workspaces/Runtime provisioning status](../../ui/storybook/stories/workspaces/workspace-runtime-provisioning.stories.tsx) | `workspaces/provisioning` | unreviewed / production / fixtures | 6 / 0 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed ExecutionWorkspaceDetail null-project handling. This suite mounts only the unchanged RuntimeProvisionStatusValue inside a local context row; it does not exercise the full detail page or projectless queries. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. The provisioning recipe requires controller script denial for remote selections and copy-only local source choices, including retained denial through metadata changes and reopening; these fixtures do not verify execution placement. | +| [Projects and execution/Workspaces, services, and files/Workspaces/Service control bar](../../ui/storybook/stories/workspaces/workspace-service-control-bar.stories.tsx) | `workspaces/services` | unreviewed / production / fixtures | 16 / 0 | Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. The provisioning recipe requires controller script denial for remote selections and copy-only local source choices, including retained denial through metadata changes and reopening; these fixtures do not verify execution placement. | ## Capability lookup diff --git a/maps/storybook-map/REVIEW.md b/maps/storybook-map/REVIEW.md index 507117f2284..f8fe0bc01d6 100644 --- a/maps/storybook-map/REVIEW.md +++ b/maps/storybook-map/REVIEW.md @@ -204,3 +204,8 @@ persistence or permission tests. ## Workspace safety recipe follow-up — 2026-10-12 Reviewed the twelve entries that depend on the workspace feature recipe: browser-use activity/footer/page, the three HTML-artifact suites, project execution strategy and project workspace summaries, searchable selection, workspace files, runtime provisioning and service controls. Their production subjects, fixtures, feature folders, sidebar titles and stable IDs are unchanged. The recipe now requires prospective child boundary checks, safe low-trust reopening, and coherent returned checkpoint ancestry. These backend safety contracts are not exercised by those fixtures. Each entry remains unreviewed for full production parity. Only the reviewed recipe fingerprints were refreshed; no browser render, play, screenshot baseline or production acceptance was run for this follow-up. + + +## Remote provisioning recipe follow-up — 2026-10-13 + +Reviewed the same twelve workspace-recipe-dependent entries after extending the controller-provisioning boundary to standard-trust sandbox and SSH selections. Their components, fixtures and stable IDs are unchanged. Project strategy stories demonstrate configuration fields with environment selection disabled; runtime provisioning stories demonstrate status values with a no-operation log handler. Browser, artifact, file and service-control fixtures do not execute source scripts or prove admission placement. The new recipe requires controller marker denial independent of source write grants while copying and dispatch remain available, including local copy-only selections, retained deny-only metadata and closed-worktree reopening. Implicit trusted local defaults remain separate positive controls. All twelve entries retain their unreviewed production classification. Refreshed only these recipe fingerprints after this source review; no browser render, play, screenshot, Storybook build or live runtime qualification is claimed. diff --git a/maps/storybook-map/catalog.json b/maps/storybook-map/catalog.json index f4131b33af5..961ced7c7ff 100644 --- a/maps/storybook-map/catalog.json +++ b/maps/storybook-map/catalog.json @@ -1208,8 +1208,8 @@ "status": "unreviewed", "implementation": "production", "boundary": "fixtures", - "notes": "Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture.", - "reviewedAt": "2026-10-12", + "notes": "Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. The provisioning recipe requires controller script denial for remote selections and copy-only local source choices, including retained denial through metadata changes and reopening; these fixtures do not verify execution placement.", + "reviewedAt": "2026-10-13", "sources": [ "maps/feature-map/tasks.md", "maps/feature-map/workspaces.md", @@ -1219,7 +1219,7 @@ "ui/storybook/fixtures/browser-use.tsx", "ui/storybook/stories/workspaces/browser-use-activity.stories.tsx" ], - "fingerprint": "6cc5f1faeef9fcf1b5659c54768e034e3cc22d4574488ad4d55fc16706c8f1ce", + "fingerprint": "fac17537782080b626f458516a96054703a19bbdf9035c4b69588bcabec13e52", "stableId": "tasks-browser-use-task-activity", "sidebarTitle": "Projects and execution/Workspaces, services, and files/Tasks/Browser Use/Task activity" }, @@ -1233,8 +1233,8 @@ "status": "unreviewed", "implementation": "production", "boundary": "fixtures", - "notes": "Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture.", - "reviewedAt": "2026-10-12", + "notes": "Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. The provisioning recipe requires controller script denial for remote selections and copy-only local source choices, including retained denial through metadata changes and reopening; these fixtures do not verify execution placement.", + "reviewedAt": "2026-10-13", "sources": [ "maps/feature-map/tasks.md", "maps/feature-map/workspaces.md", @@ -1243,7 +1243,7 @@ "ui/storybook/fixtures/browser-use.tsx", "ui/storybook/stories/workspaces/browser-use-footer.stories.tsx" ], - "fingerprint": "5177955d3d027e278fdd5a4037c3c5980d7b966a133ade56dcee797ec80c5ce1", + "fingerprint": "71d0150d011280848a25ac27800b5e171a215a144f79bee29657d063c27c87d6", "stableId": "tasks-browser-use-footer", "sidebarTitle": "Projects and execution/Workspaces, services, and files/Tasks/Browser Use/Footer" }, @@ -1279,8 +1279,8 @@ "status": "unreviewed", "implementation": "production", "boundary": "fixtures", - "notes": "Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture.", - "reviewedAt": "2026-10-12", + "notes": "Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. The provisioning recipe requires controller script denial for remote selections and copy-only local source choices, including retained denial through metadata changes and reopening; these fixtures do not verify execution placement.", + "reviewedAt": "2026-10-13", "sources": [ "maps/feature-map/tasks.md", "maps/feature-map/workspaces.md", @@ -1290,7 +1290,7 @@ "ui/storybook/fixtures/paperclipData.ts", "ui/storybook/stories/workspaces/browser-use.stories.tsx" ], - "fingerprint": "fc58d3850fd8c0739ddd5a8ce0b46ee177fe8eab3af35767cd6ba2a24a824bc9", + "fingerprint": "b44fc42cdaf4ea934e8a98bacdcf569e13d4757f33c9052460c4137c8c6e4a06", "stableId": "tasks-browser-use-panel", "sidebarTitle": "Projects and execution/Workspaces, services, and files/Tasks/Browser Use/Panel" }, @@ -2664,8 +2664,8 @@ "status": "unreviewed", "implementation": "production", "boundary": "fixtures", - "notes": "Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture.", - "reviewedAt": "2026-10-12", + "notes": "Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. The provisioning recipe requires controller script denial for remote selections and copy-only local source choices, including retained denial through metadata changes and reopening; these fixtures do not verify execution placement.", + "reviewedAt": "2026-10-13", "sources": [ "maps/feature-map/documents-artifacts.md", "maps/feature-map/workspaces.md", @@ -2673,7 +2673,7 @@ "ui/storybook/stories/documents-artifacts/html-artifacts/01-preview.stories.tsx", "ui/storybook/support/html-artifacts/fixtures.ts" ], - "fingerprint": "bcc90a3a8706dee7b74667fe2898c5a346ca5575746d1cff0045770ca223e6d2", + "fingerprint": "7db2f0aebd69921dce278da4c8c1af46a58a04dc1007e8152b8001b27e6971e1", "stableId": "html-artifacts-01-preview", "sidebarTitle": "Tasks and conversations/Documents, attachments, and work products/HTML artifacts/01 Preview" }, @@ -2687,8 +2687,8 @@ "status": "unreviewed", "implementation": "production", "boundary": "fixtures", - "notes": "Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture.", - "reviewedAt": "2026-10-12", + "notes": "Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. The provisioning recipe requires controller script denial for remote selections and copy-only local source choices, including retained denial through metadata changes and reopening; these fixtures do not verify execution placement.", + "reviewedAt": "2026-10-13", "sources": [ "maps/feature-map/documents-artifacts.md", "maps/feature-map/workspaces.md", @@ -2697,7 +2697,7 @@ "ui/storybook/stories/documents-artifacts/html-artifacts/02-workspace.stories.tsx", "ui/storybook/support/html-artifacts/fixtures.ts" ], - "fingerprint": "e19cc06690585d75315283bddcb19caad7a444447dce03c0b0b66fc7942bce3b", + "fingerprint": "a45155473d06d00e5f7e60b75da3a2f082ddc2e951dc216a1be4d8448bfeebef", "stableId": "html-artifacts-02-workspace", "sidebarTitle": "Tasks and conversations/Documents, attachments, and work products/HTML artifacts/02 Workspace" }, @@ -2711,8 +2711,8 @@ "status": "unreviewed", "implementation": "production", "boundary": "fixtures", - "notes": "Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture.", - "reviewedAt": "2026-10-12", + "notes": "Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. The provisioning recipe requires controller script denial for remote selections and copy-only local source choices, including retained denial through metadata changes and reopening; these fixtures do not verify execution placement.", + "reviewedAt": "2026-10-13", "sources": [ "maps/feature-map/documents-artifacts.md", "maps/feature-map/workspaces.md", @@ -2724,7 +2724,7 @@ "ui/storybook/stories/documents-artifacts/html-artifacts/03-task-journey.stories.tsx", "ui/storybook/support/html-artifacts/fixtures.ts" ], - "fingerprint": "180397152fab8d5ab6768438dc51be59a3bffe193bc6616ee4afbcde8e5a1f31", + "fingerprint": "f2bbffcba1da252f2d5dcd13eafbdf0be49673847154e19042e6aa060386a652", "stableId": "html-artifacts-03-task-journey", "sidebarTitle": "Tasks and conversations/Documents, attachments, and work products/HTML artifacts/03 Task journey" }, @@ -3940,8 +3940,8 @@ "status": "unreviewed", "implementation": "production", "boundary": "fixtures", - "notes": "Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture.", - "reviewedAt": "2026-10-12", + "notes": "Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. The provisioning recipe requires controller script denial for remote selections and copy-only local source choices, including retained denial through metadata changes and reopening; these fixtures do not verify execution placement.", + "reviewedAt": "2026-10-13", "sources": [ "maps/feature-map/projects.md", "maps/feature-map/workspaces.md", @@ -3949,7 +3949,7 @@ "ui/storybook/fixtures/paperclipData.ts", "ui/storybook/stories/projects/project-execution-workspace-strategy.stories.tsx" ], - "fingerprint": "4801904641a1a9728fbf9200784ac0941d773462e6775692f24f2f48ec1ef55e", + "fingerprint": "548093972cc2f7cabbb8d2f190b64aa5a3859019e97fb3944ba1c2bf3da95d2c", "stableId": "workspaces-project-runtime-provision-command", "sidebarTitle": "Projects and execution/Projects and repositories/Workspaces/Project runtime provision command" }, @@ -3993,8 +3993,8 @@ "status": "unreviewed", "implementation": "production", "boundary": "fixtures", - "notes": "Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed nullable project references and guarded runtime invalidations. Existing summaries remain project-bound and retain their routes; null-project execution workspace rendering and controls remain a coverage gap. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture.", - "reviewedAt": "2026-10-12", + "notes": "Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed nullable project references and guarded runtime invalidations. Existing summaries remain project-bound and retain their routes; null-project execution workspace rendering and controls remain a coverage gap. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. The provisioning recipe requires controller script denial for remote selections and copy-only local source choices, including retained denial through metadata changes and reopening; these fixtures do not verify execution placement.", + "reviewedAt": "2026-10-13", "sources": [ "maps/feature-map/goals.md", "maps/feature-map/projects.md", @@ -4009,7 +4009,7 @@ "ui/storybook/fixtures/paperclipData.ts", "ui/storybook/stories/projects/projects-goals-workspaces.stories.tsx" ], - "fingerprint": "78ca1e35c4ffc444182a0d5b700b40194291d2fc0a45c8654ed624d57b3a847a", + "fingerprint": "1078070d0221e67bea262307d1bbab499132d203aad7e90cd4a3150900d31c53", "stableId": "product-projects-goals-workspaces", "sidebarTitle": "Projects and execution/Projects and repositories/Product/Projects Goals Workspaces" }, @@ -4678,14 +4678,14 @@ "status": "unreviewed", "implementation": "production", "boundary": "fixtures", - "notes": "Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture.", - "reviewedAt": "2026-10-12", + "notes": "Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. The provisioning recipe requires controller script denial for remote selections and copy-only local source choices, including retained denial through metadata changes and reopening; these fixtures do not verify execution placement.", + "reviewedAt": "2026-10-13", "sources": [ "maps/feature-map/workspaces.md", "ui/src/components/SearchableSelect.tsx", "ui/storybook/stories/workspaces/searchable-select.stories.tsx" ], - "fingerprint": "91c53ef285a9b66f826844fccf76cff3610ef3f17c2a790ebcd9ce9136b6e4b0", + "fingerprint": "0f868bb5cae6bbd0edf46283e990045e389aee3db96de60a23472eb8ddf7173d", "stableId": "components-searchableselect-workspace-picker", "sidebarTitle": "Projects and execution/Workspaces, services, and files/Components/SearchableSelect/Workspace picker" }, @@ -5545,15 +5545,15 @@ "status": "unreviewed", "implementation": "production", "boundary": "fixtures", - "notes": "Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture.", - "reviewedAt": "2026-10-12", + "notes": "Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. The provisioning recipe requires controller script denial for remote selections and copy-only local source choices, including retained denial through metadata changes and reopening; these fixtures do not verify execution placement.", + "reviewedAt": "2026-10-13", "sources": [ "maps/feature-map/workspaces.md", "ui/src/components/FileViewerSheet.tsx", "ui/src/components/IssueWorkspaceCard.tsx", "ui/storybook/stories/workspaces/workspace-file-browser.stories.tsx" ], - "fingerprint": "17143b289ff1f961d8c7a62bc3885a0cf7be625b1d488084e6d1ccddd1f5365e", + "fingerprint": "627120ee9fafecf0159629bb1f7584e0581a2ed44ad92ddcd0f1ff012117c040", "stableId": "issue-workspace-file-browser", "sidebarTitle": "Projects and execution/Workspaces, services, and files/Issue/Workspace File Browser" }, @@ -5566,14 +5566,14 @@ "status": "unreviewed", "implementation": "production", "boundary": "fixtures", - "notes": "Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed ExecutionWorkspaceDetail null-project handling. This suite mounts only the unchanged RuntimeProvisionStatusValue inside a local context row; it does not exercise the full detail page or projectless queries. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture.", - "reviewedAt": "2026-10-12", + "notes": "Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed ExecutionWorkspaceDetail null-project handling. This suite mounts only the unchanged RuntimeProvisionStatusValue inside a local context row; it does not exercise the full detail page or projectless queries. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. The provisioning recipe requires controller script denial for remote selections and copy-only local source choices, including retained denial through metadata changes and reopening; these fixtures do not verify execution placement.", + "reviewedAt": "2026-10-13", "sources": [ "maps/feature-map/workspaces.md", "ui/src/pages/ExecutionWorkspaceDetail.tsx", "ui/storybook/stories/workspaces/workspace-runtime-provisioning.stories.tsx" ], - "fingerprint": "18d507bd030d34ea196fd8525b498de790c2b9372596cf669f51a2d051f86723", + "fingerprint": "ce86fc1a5fe57c67533ae8695b6a23f8bb034040027f3a65f60de898dfe54291", "stableId": "workspaces-runtime-provisioning-status", "sidebarTitle": "Projects and execution/Workspaces, services, and files/Workspaces/Runtime provisioning status" }, @@ -5586,14 +5586,14 @@ "status": "unreviewed", "implementation": "production", "boundary": "fixtures", - "notes": "Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture.", - "reviewedAt": "2026-10-12", + "notes": "Shipped subjects identified through imports and local wrappers; full state, fixture-contract and route parity remain unreviewed. Task-workspace reconciliation reviewed the expanded workspace recipe; these examples do not establish durable task-folder continuity, repository authorization or sandbox admission. The workspace recipe now requires child boundary, safe reopen and checkpoint ancestry controls; these backend checks are not established by this fixture. The provisioning recipe requires controller script denial for remote selections and copy-only local source choices, including retained denial through metadata changes and reopening; these fixtures do not verify execution placement.", + "reviewedAt": "2026-10-13", "sources": [ "maps/feature-map/workspaces.md", "ui/src/components/WorkspaceServiceControlBar.tsx", "ui/storybook/stories/workspaces/workspace-service-control-bar.stories.tsx" ], - "fingerprint": "53376ddaeab2e4ade78ad68c244cd224f76f491278df9c258a8199fac94413f7", + "fingerprint": "48088c0aaf3632ee383516f48aa84c7f4313f72b3b7e42a43111e52083a061e0", "stableId": "workspaces-service-control-bar", "sidebarTitle": "Projects and execution/Workspaces, services, and files/Workspaces/Service control bar" } diff --git a/server/src/__tests__/execution-workspace-reopen.test.ts b/server/src/__tests__/execution-workspace-reopen.test.ts index f9405df786b..9c35a79bbf0 100644 --- a/server/src/__tests__/execution-workspace-reopen.test.ts +++ b/server/src/__tests__/execution-workspace-reopen.test.ts @@ -261,7 +261,7 @@ describeEmbeddedPostgres("reopen archived isolated execution workspace", () => { } describe.each(["configured", "builtin"] as const)("reopen %s host provision containment", kind => { - it.each(["task", "agent", "organization", "source", "same-source", "trusted"] as const)("honors persisted %s policy before running repository scripts", async restriction => { + it.each(["task", "agent", "organization", "source", "same-source", "trusted", "explicit", "projectless", "nondefault", "foreign-source-task", "retained-missing", "retained-false", "retained-null"] as const)("honors persisted %s policy before running repository scripts", async restriction => { const { companyId, projectId, projectWorkspaceId } = await seedCompanyProject(); const directory = await makeExistingDir(); const base = join(directory, "source"), target = join(directory, "target"), marker = join(directory, "host-provision-ran"); @@ -279,7 +279,7 @@ describeEmbeddedPostgres("reopen archived isolated execution workspace", () => { [EXECUTION_WORKSPACE_LIFECYCLE_GENERATION_METADATA_KEY]: 1, config: { provisionCommand: command }, } }).where(eq(executionWorkspaces.id, workspaceId)); const issueId = await seedIssue({ companyId, projectId, workspaceId, issueNumber: 4199 }); - let organizationId: string | null = restriction === "same-source" ? projectId : null; + let organizationId: string | null = restriction === "projectless" ? null : projectId; if (restriction === "organization") { organizationId = randomUUID(); await db.insert(projects).values({ id: organizationId, companyId, name: "Organizational policy" }); @@ -296,6 +296,30 @@ describeEmbeddedPostgres("reopen archived isolated execution workspace", () => { await db.update(projects).set({ executionWorkspacePolicy: policy }) .where(eq(projects.id, restriction === "organization" ? organizationId! : projectId)); } + if (restriction === "explicit" || restriction.startsWith("retained-")) { + await db.update(issues).set({ workspaceSelection: { version: 1, source: "explicit", + selection: { kind: "configured_source", projectWorkspaceId, mode: "managed_isolated" } } }) + .where(eq(issues.id, issueId)); + } + if (restriction === "nondefault") { + await db.insert(projectWorkspaces).values({ companyId, projectId, name: "Earlier default", + sourceType: "local_path", cwd: base, createdAt: new Date(0) }); + } + if (restriction === "foreign-source-task") { + const sourceIssueId = await seedIssue({ companyId, projectId, workspaceId, issueNumber: 4198 }); + await db.update(executionWorkspaces).set({ sourceIssueId }).where(eq(executionWorkspaces.id, workspaceId)); + } + if (restriction.startsWith("retained-")) { + const workspace = await readWorkspace(workspaceId); + await db.update(executionWorkspaces).set({ metadata: { ...workspace?.metadata, + _controllerProvisionCopyOnly: true } }).where(eq(executionWorkspaces.id, workspaceId)); + await db.update(issues).set({ workspaceSelection: null }).where(eq(issues.id, issueId)); + const service = executionWorkspaceService(db); + await service.update(workspaceId, { metadata: restriction === "retained-null" ? null + : restriction === "retained-false" ? { _controllerProvisionCopyOnly: false } : {} }); + if (kind === "configured") await service.update(workspaceId, { metadata: { config: { provisionCommand: command } } }); + expect((await readWorkspace(workspaceId))?.metadata).toMatchObject({ _controllerProvisionCopyOnly: true }); + } const result = await executionWorkspaceService(db).reopenClosedIsolatedExecutionWorkspaceForIssue({ workspaceId, issue: { id: issueId, companyId, projectId: organizationId }, actor: { agentId: null, actorType: "user" }, @@ -306,6 +330,8 @@ describeEmbeddedPostgres("reopen archived isolated execution workspace", () => { if (restriction === "trusted") await expect(readFile(marker, "utf8")).resolves.toBe("host execution\n"); else await expect(readFile(marker, "utf8")).rejects.toMatchObject({ code: "ENOENT" }); expect(await readWorkspace(workspaceId)).toMatchObject({ status: "active", projectId, projectWorkspaceId }); + if (["explicit", "projectless", "nondefault", "foreign-source-task"].includes(restriction) || restriction.startsWith("retained-")) expect((await readWorkspace(workspaceId))?.metadata) + .toMatchObject({ _controllerProvisionCopyOnly: true }); expect((await db.select().from(issues).where(eq(issues.id, issueId)))[0]) .toMatchObject({ projectId: organizationId, executionWorkspaceId: workspaceId, assigneeAgentId: agentId }); }); diff --git a/server/src/__tests__/heartbeat-project-repositories.test.ts b/server/src/__tests__/heartbeat-project-repositories.test.ts index eb4cb0513c1..9214e504e1c 100644 --- a/server/src/__tests__/heartbeat-project-repositories.test.ts +++ b/server/src/__tests__/heartbeat-project-repositories.test.ts @@ -469,10 +469,11 @@ suite("task project repository provisioning", () => { expect(await readFile(path.join(cwd, "work.txt"), "utf8")).toBe("Protected source content"); }, 30_000); - it.each(["success", "provision_failure", "occupied_target"] as const)("checks nested private source access before worktree copy and retains it after read-grant revocation (%s)", async (scenario) => { + it.each(["success", "provision_failure", "copy_only_provision", "occupied_target"] as const)("checks nested private source access before worktree copy and retains it after read-grant revocation (%s)", async (scenario) => { const previousPrivacyMode = process.env.PAPERCLIP_ISSUE_PRIVACY_MODE; vi.stubEnv("PAPERCLIP_ISSUE_PRIVACY_MODE", "enforce"); try { + if (scenario === "provision_failure") await instanceSettingsService(db).updateExperimental({ enableIsolatedWorkspaces: true }); const companyId = randomUUID(), projectId = randomUUID(), privateProjectId = randomUUID(); const sourceId = randomUUID(), agentId = randomUUID(), issueId = randomUUID(); const cwd = path.join(root, companyId, "public-source"); @@ -504,9 +505,15 @@ suite("task project repository provisioning", () => { sourceType: "local_path", cwd: path.dirname(occupiedTarget), isPrimary: false, }); await db.insert(agents).values({ id: agentId, companyId, name: "Isolated reader", status: "idle", adapterType: "codex_local", adapterConfig: {}, permissions: {} }); + if (scenario === "provision_failure") await db.insert(companyMemberships).values({ companyId, principalType: "agent", principalId: agentId, status: "active", membershipRole: "member" }); await db.insert(issues).values({ id: issueId, companyId, title: "Read isolated source", status: "todo", assigneeAgentId: agentId, - projectWorkspaceId: sourceId, executionWorkspaceSettings: { mode: "isolated_workspace", workspaceStrategy: { type: "git_worktree", ...(scenario === "provision_failure" ? { provisionCommand: "exit 42" } : {}), ...(scenario === "occupied_target" ? { branchTemplate: "occupied-private", provisionCommand: "touch provision-ran" } : {}) } }, - workspaceSelection: { version: 1, source: "explicit", selection: { kind: "configured_source", projectWorkspaceId: sourceId, mode: "managed_isolated" } } }); + projectId: scenario === "provision_failure" ? projectId : null, + projectWorkspaceId: sourceId, executionWorkspaceSettings: { mode: "isolated_workspace", workspaceStrategy: { type: "git_worktree", ...(scenario === "provision_failure" ? { provisionCommand: "exit 42" } : {}), ...(scenario === "copy_only_provision" ? { provisionCommand: "touch provision-ran; exit 42" } : {}), ...(scenario === "occupied_target" ? { branchTemplate: "occupied-private", provisionCommand: "touch provision-ran" } : {}) } }, + workspaceSelection: scenario === "provision_failure" ? null : { version: 1, source: "explicit", selection: { kind: "configured_source", projectWorkspaceId: sourceId, mode: "managed_isolated" } } }); + if (scenario === "provision_failure") await db.insert(principalPermissionGrants).values([ + { companyId, principalType: "agent", principalId: agentId, permissionKey: "tasks:assign_scope", scope: { projectId, assigneeAgentId: agentId } }, + { companyId, principalType: "user", principalId: "responsible-user", permissionKey: "tasks:assign_scope", scope: { projectId, assigneeAgentId: agentId } }, + ]); const admit = async () => { const run = await heartbeat.wakeup(agentId, { source: "on_demand", triggerDetail: "manual", contextSnapshot: { issueId } }); expect(run).not.toBeNull(); @@ -524,11 +531,11 @@ suite("task project repository provisioning", () => { { companyId, projectId: privateProjectId, subjectType: "user", subjectId: "responsible-user" }, ]); expect(await accessService(db).decide({ actor: { type: "agent", agentId, companyId, source: "agent_jwt", onBehalfOfUserId: "responsible-user" }, - action: "tasks:assign", resource: { type: "issue", companyId, projectId, assigneeAgentId: agentId }, scope: { projectId, assigneeAgentId: agentId } })).toMatchObject({ allowed: false }); + action: "tasks:assign", resource: { type: "issue", companyId, projectId, assigneeAgentId: agentId }, scope: { projectId, assigneeAgentId: agentId } })).toMatchObject({ allowed: scenario === "provision_failure" }); const allowed = await admit(); const calls = execute.mock.calls.filter(([input]) => input.runId === allowed.id); let copiedCwd: string; - if (scenario !== "success") { + if (scenario === "provision_failure" || scenario === "occupied_target") { expect(allowed.status).toBe("failed"); expect(calls).toHaveLength(0); if (scenario === "provision_failure") { @@ -558,6 +565,12 @@ suite("task project repository provisioning", () => { expect(calls).toHaveLength(1); expect(calls[0]![0].context.paperclipWorkspace.strategy).toBe("git_worktree"); copiedCwd = calls[0]![0].context.paperclipWorkspace.cwd; + if (scenario === "copy_only_provision") { + await expect(readFile(path.join(copiedCwd, "provision-ran"), "utf8")).rejects.toMatchObject({ code: "ENOENT" }); + const [bound] = await db.select().from(issues).where(eq(issues.id, issueId)); + const [workspace] = await db.select().from(executionWorkspaces).where(eq(executionWorkspaces.id, bound.executionWorkspaceId!)); + expect(workspace.metadata?._controllerProvisionCopyOnly).toBe(true); + } } const workspace = { cwd: copiedCwd }; expect(await realpath(workspace.cwd)).not.toBe(await realpath(cwd)); diff --git a/server/src/__tests__/heartbeat-workspace-session.test.ts b/server/src/__tests__/heartbeat-workspace-session.test.ts index 399548df7c8..9f1d856959e 100644 --- a/server/src/__tests__/heartbeat-workspace-session.test.ts +++ b/server/src/__tests__/heartbeat-workspace-session.test.ts @@ -37,7 +37,6 @@ import { resolveWorkspaceAfterLowTrustPreflight, resolveRuntimeSessionParamsForWorkspace, shouldDeferFollowupWakeForSameIssue, - stripHostWorkspaceProvisionForLowTrustSandbox, stripWorkspaceRuntimeFromExecutionRunConfig, shouldResetTaskSessionForModelChange, stripConfiguredModelFromSessionParams, @@ -49,6 +48,7 @@ import { buildAnchorFallbackWorkspaceNotes, type ResolvedWorkspaceForRun, } from "../services/heartbeat.ts"; +import { stripHostWorkspaceProvision } from "../services/heartbeat/workspaces.js"; import type { TrustPresetResolution } from "../services/trust-preset-resolver.ts"; const execFile = promisify(execFileCallback); @@ -1125,8 +1125,15 @@ describe("requiresPushCapabilityPreflight", () => { }); }); -describe("stripHostWorkspaceProvisionForLowTrustSandbox", () => { - it("removes only the host-side provision command for sandbox-backed low-trust runs", () => { +describe("stripHostWorkspaceProvision", () => { + it.each(["sandbox", "ssh"])("removes nested and top-level runtime commands immutably for %s", selectedEnvironmentDriver => { + const config = { runtimeProvisionCommand: "top-level", workspaceStrategy: { type: "git_worktree", provisionCommand: "host", runtimeProvisionCommand: "nested" } }; + const original = structuredClone(config); + expect(stripHostWorkspaceProvision({ config, skipHostProvision: true })) + .toEqual({ workspaceStrategy: { type: "git_worktree" } }); + expect(config).toEqual(original); + }); + it("removes controller provisioning while retaining unrelated settings", () => { const config = { workspaceStrategy: { type: "git_worktree", @@ -1139,10 +1146,9 @@ describe("stripHostWorkspaceProvisionForLowTrustSandbox", () => { }, }; - const result = stripHostWorkspaceProvisionForLowTrustSandbox({ + const result = stripHostWorkspaceProvision({ config, - trustPreset: lowTrustResolution(), - selectedEnvironmentDriver: "sandbox", + skipHostProvision: true, }); expect(result).not.toBe(config); @@ -1155,7 +1161,7 @@ describe("stripHostWorkspaceProvisionForLowTrustSandbox", () => { expect(config.workspaceStrategy.provisionCommand).toBe("bash ./scripts/provision-worktree.sh"); }); - it("preserves provision commands for standard-trust runs", () => { + it("strips provision commands when the controller is not the execution target", () => { const config = { workspaceStrategy: { type: "git_worktree", @@ -1163,14 +1169,13 @@ describe("stripHostWorkspaceProvisionForLowTrustSandbox", () => { }, }; - expect(stripHostWorkspaceProvisionForLowTrustSandbox({ + expect(stripHostWorkspaceProvision({ config, - trustPreset: standardTrustResolution(), - selectedEnvironmentDriver: "sandbox", - })).toBe(config); + skipHostProvision: true, + })).toEqual({ workspaceStrategy: { type: "git_worktree" } }); }); - it("preserves provision commands when a low-trust run is not sandbox-backed", () => { + it("preserves provision commands when the server permits controller provisioning", () => { const config = { workspaceStrategy: { type: "git_worktree", @@ -1178,10 +1183,9 @@ describe("stripHostWorkspaceProvisionForLowTrustSandbox", () => { }, }; - expect(stripHostWorkspaceProvisionForLowTrustSandbox({ + expect(stripHostWorkspaceProvision({ config, - trustPreset: lowTrustResolution(), - selectedEnvironmentDriver: "local", + skipHostProvision: false, })).toBe(config); }); }); diff --git a/server/src/__tests__/heartbeat-workspace-source-trust.test.ts b/server/src/__tests__/heartbeat-workspace-source-trust.test.ts index 0c7241b4c6b..310c1810874 100644 --- a/server/src/__tests__/heartbeat-workspace-source-trust.test.ts +++ b/server/src/__tests__/heartbeat-workspace-source-trust.test.ts @@ -139,4 +139,81 @@ suite("heartbeat physical workspace source trust", () => { } }); + it.each([ + ["configured", "none", "sandbox"], ["builtin", "none", "sandbox"], + ["configured", "agent", "sandbox"], ["builtin", "agent", "sandbox"], + ["configured", "both", "sandbox"], ["builtin", "both", "sandbox"], + ["configured", "both", "local"], ["builtin", "both", "local"], + ["configured", "none", "local"], ["builtin", "none", "local"], + ["configured", "both", "local_default"], ["builtin", "both", "local_default"], + ] as const)("places standard source %s provisioning with %s grants on %s", async (provisionKind, grants, placement) => { + const implicitDefault = placement === "local_default"; + const companyId = randomUUID(), projectId = randomUUID(), sourceId = randomUUID(), agentId = randomUUID(), issueId = randomUUID(); + await instanceSettingsService(db).updateExperimental({ enableIsolatedWorkspaces: true }); + const cwd = path.join(root, companyId, "read-only-source"); + const marker = path.join(root, companyId, "host-script-ran"); + await mkdir(path.join(cwd, "scripts"), { recursive: true }); + await writeFile(path.join(cwd, "source.txt"), "read-only source bytes"); + await writeFile(path.join(cwd, "scripts", "provision-worktree.sh"), `printf host-script-ran > '${marker}'\n`); + const git = (...args: string[]) => execFileSync("git", args, { cwd, stdio: "ignore" }); + git("init", "-b", "main"); git("add", "."); + git("-c", "user.name=Fixture", "-c", "user.email=fixture@example.test", "commit", "-m", "source"); + git("remote", "add", "origin", pathToFileURL(cwd).href); + await db.insert(companies).values({ id: companyId, name: "Read-only source", issuePrefix: `R${companyId.slice(0, 6)}`, defaultResponsibleUserId: "responsible-user" }); + await db.insert(companyMemberships).values({ companyId, principalType: "user", principalId: "responsible-user", status: "active", membershipRole: "owner" }); + await db.insert(projects).values({ id: projectId, companyId, name: "Protected source", executionWorkspacePolicy: { + authorizationPolicy: { assignmentPolicy: { mode: "protected" } }, + } }); + await db.insert(projectWorkspaces).values({ id: sourceId, companyId, projectId, name: "Source", sourceType: "local_path", cwd, repoUrl: pathToFileURL(cwd).href, isPrimary: true }); + await db.insert(agents).values({ id: agentId, companyId, name: "Reader", status: "idle", adapterType: "codex_local", adapterConfig: { fullAuto: grants === "both" }, permissions: {} }); + await db.insert(companyMemberships).values({ companyId, principalType: "agent", principalId: agentId, status: "active", membershipRole: "member" }); + await db.insert(issues).values({ id: issueId, companyId, projectId: implicitDefault ? projectId : null, title: "Read-only isolated source", status: "todo", assigneeAgentId: agentId, + projectWorkspaceId: sourceId, executionWorkspaceSettings: { mode: "isolated_workspace", workspaceStrategy: { type: "git_worktree", + worktreeParentDir: path.join(root, companyId, "worktrees"), ...(provisionKind === "configured" ? { provisionCommand: `printf host-script-ran > '${marker}'` } : {}) } }, + workspaceSelection: implicitDefault ? null : { version: 1, source: "explicit", selection: { kind: "configured_source", projectWorkspaceId: sourceId, mode: "managed_isolated" } } }); + if (grants !== "none") await db.insert(principalPermissionGrants).values({ companyId, principalType: "agent", principalId: agentId, + permissionKey: "tasks:assign_scope", scope: { projectId, assigneeAgentId: agentId } }); + if (grants === "both") await db.insert(principalPermissionGrants).values({ companyId, principalType: "user", principalId: "responsible-user", + permissionKey: "tasks:assign_scope", scope: { projectId, assigneeAgentId: agentId } }); + const actor = { type: "agent" as const, agentId, companyId, source: "agent_jwt" as const, onBehalfOfUserId: "responsible-user" }; + expect(await accessService(db).decide({ actor, action: "project:read", resource: { type: "project", companyId, projectId } })).toMatchObject({ allowed: true }); + expect(await accessService(db).decide({ actor, action: "project:write_workspace", resource: { type: "issue", companyId, projectId, issueId, assigneeAgentId: agentId }, scope: { projectId, assigneeAgentId: agentId } })).toMatchObject({ allowed: grants === "both" }); + const environmentId = randomUUID(); + await db.insert(environments).values({ id: environmentId, name: `Standard sandbox ${companyId}`, driver: "sandbox", status: "active", config: { provider: "fake", image: "fake:test" } }); + await db.update(agents).set({ defaultEnvironmentId: placement === "sandbox" ? environmentId : null }).where(eq(agents.id, agentId)); + const driver = heartbeatService(db, { environmentRuntime: { ...environmentRuntimeService(db), execute: async input => ({ + exitCode: 0, stdout: execFileSync(input.command, input.args ?? [], { cwd: root, input: input.stdin, encoding: "utf8", env: { ...process.env, ...input.env } }), + stderr: "", signal: null, timedOut: false, + }) } }); + const run = await driver.wakeup(agentId, { source: "on_demand", triggerDetail: "manual", contextSnapshot: { issueId } }); + expect(run).not.toBeNull(); + await vi.waitFor(async () => expect((await driver.getRun(run!.id))?.status).toMatch(/^(succeeded|failed)$/), { timeout: 15_000 }); + await drainHeartbeatRunsToQuiescence(db, driver); + expect(await driver.getRun(run!.id)).toMatchObject({ status: "succeeded", error: null }); + const [bound] = await db.select().from(issues).where(eq(issues.id, issueId)); + const [workspace] = await db.select().from(executionWorkspaces).where(eq(executionWorkspaces.id, bound.executionWorkspaceId!)); + expect(workspace.cwd).not.toBe(cwd); + expect(await readFile(path.join(workspace.cwd!, "source.txt"), "utf8")).toBe("read-only source bytes"); + const calls = execute.mock.calls.filter(([input]) => input.runId === run!.id); + expect(calls).toHaveLength(1); + expect(calls[0][0].context.paperclipEnvironment.driver).toBe(placement === "sandbox" ? "sandbox" : "local"); + if (!implicitDefault) await expect(readFile(marker, "utf8")).rejects.toMatchObject({ code: "ENOENT" }); + else expect(await readFile(marker, "utf8")).toBe("host-script-ran"); + await rm(marker, { force: true }); + if (grants === "none") await rm(workspace.cwd!, { recursive: true, force: true }); + await db.update(issues).set({ status: "todo" }).where(eq(issues.id, issueId)); + const { executionWorkspaceService } = await import("../services/execution-workspaces.js"); + if (placement === "local" && grants === "both") await db.update(issues).set({ projectId, workspaceSelection: null }).where(eq(issues.id, issueId)); + await executionWorkspaceService(db).update(workspace.id, { metadata: { ...workspace.metadata, + _controllerProvisionCopyOnly: false, config: { provisionCommand: `printf host-script-ran > '${marker}'` } } }); + const resumed = await driver.wakeup(agentId, { source: "on_demand", triggerDetail: "manual", contextSnapshot: { issueId } }); + await vi.waitFor(async () => expect((await driver.getRun(resumed!.id))?.status).toMatch(/^(succeeded|failed)$/), { timeout: 15_000 }); + await drainHeartbeatRunsToQuiescence(db, driver); + expect(await driver.getRun(resumed!.id)).toMatchObject({ status: "succeeded", error: null }); + expect((await db.select().from(issues).where(eq(issues.id, issueId)))[0].executionWorkspaceId).toBe(workspace.id); + expect(await readFile(path.join(workspace.cwd!, "source.txt"), "utf8")).toBe("read-only source bytes"); + if (!implicitDefault) await expect(readFile(marker, "utf8")).rejects.toMatchObject({ code: "ENOENT" }); + else expect(await readFile(marker, "utf8")).toBe("host-script-ran"); + }, 30_000); + }); diff --git a/server/src/__tests__/workspace-host-provision.test.ts b/server/src/__tests__/workspace-host-provision.test.ts new file mode 100644 index 00000000000..79773f94598 --- /dev/null +++ b/server/src/__tests__/workspace-host-provision.test.ts @@ -0,0 +1,44 @@ +import type { Db } from "@paperclipai/db"; +import { describe, expect, it, vi } from "vitest"; +import { workspaceRequiresCopyOnlyProvisioning } from "../services/workspace-host-provision.js"; + +describe("controller provision source classification", () => { + function fixture(rows: Array<{ id: string }> = [{ id: "default-source" }]) { + const query = { from: vi.fn(), where: vi.fn(), orderBy: vi.fn(), limit: vi.fn(async () => rows) }; + query.from.mockReturnValue(query); + query.where.mockReturnValue(query); + query.orderBy.mockReturnValue(query); + const db = { select: vi.fn(() => query) } as unknown as Db; + const input = { companyId: "company", task: { id: "task", projectId: "project" }, + sourceProjectId: "project", sourceWorkspaceId: "default-source" }; + return { db, input }; + } + + it.each(["explicit", "channel", "parent", "legacy"] as const)("keeps %s source choice copy-only even on the organizational default", async source => { + const { db, input } = fixture(); + expect(await workspaceRequiresCopyOnlyProvisioning(db, { ...input, task: { ...input.task, + workspaceSelection: { version: 1, source, selection: { kind: "configured_source", projectWorkspaceId: "default-source", mode: "managed_isolated" } } } })).toBe(true); + }); + + it("preserves the implicit organizational default and server-generated operator cwd", async () => { + const { db, input } = fixture(); + expect(await workspaceRequiresCopyOnlyProvisioning(db, input)).toBe(false); + expect(await workspaceRequiresCopyOnlyProvisioning(db, { ...input, sourceProjectId: null, sourceWorkspaceId: null, + task: { ...input.task, workspaceSelection: { version: 1, source: "operator_cwd", selection: { kind: "task_directory" } } } })).toBe(false); + expect(await workspaceRequiresCopyOnlyProvisioning(db, { ...input, task: null, sourceProjectId: null, sourceWorkspaceId: null })).toBe(false); + }); + + it("preserves copy-only lineage after intent clearing and source ownership changes", async () => { + const { db, input } = fixture(); + expect(await workspaceRequiresCopyOnlyProvisioning(db, { ...input, boundWorkspace: { metadata: { _controllerProvisionCopyOnly: true } } })).toBe(true); + expect(await workspaceRequiresCopyOnlyProvisioning(db, { ...input, boundWorkspace: { sourceIssueId: "parent-task" } })).toBe(true); + expect(await workspaceRequiresCopyOnlyProvisioning(db, { ...input, task: { ...input.task, projectId: null } })).toBe(true); + expect(await workspaceRequiresCopyOnlyProvisioning(db, { ...input, sourceWorkspaceId: null })).toBe(true); + }); + + it("does not upgrade missing or fallback source identities to a default approval", async () => { + const { db, input } = fixture([{ id: "earlier-unusable-source" }]); + expect(await workspaceRequiresCopyOnlyProvisioning(db, input)).toBe(true); + expect(await workspaceRequiresCopyOnlyProvisioning(fixture([]).db, input)).toBe(true); + }); +}); diff --git a/server/src/__tests__/workspace-runtime.test.ts b/server/src/__tests__/workspace-runtime.test.ts index e1566b435f3..0d6da1071f3 100644 --- a/server/src/__tests__/workspace-runtime.test.ts +++ b/server/src/__tests__/workspace-runtime.test.ts @@ -4314,6 +4314,34 @@ describe("ensureRuntimeServicesForRun", () => { }; } + it.each(["configured", "builtin"] as const)("suppresses %s runtime provision scripts for remote runs without disabling local provisioning", async kind => { + const workspaceRoot = await fs.mkdtemp(path.join(os.tmpdir(), "paperclip-remote-runtime-provision-")); + const restorePaperclipEnv = configureRuntimeProvisionTestHome(workspaceRoot, "remote-runtime-provision"); + const marker = path.join(workspaceRoot, "runtime-script-ran"); + const command = `printf host-runtime > '${marker}'`; + await fs.mkdir(path.join(workspaceRoot, "scripts")); + await fs.writeFile(path.join(workspaceRoot, "scripts", "provision-worktree-runtime.sh"), `${command}\n`); + const workspace = { ...buildWorkspace(workspaceRoot), strategy: "git_worktree" as const, worktreePath: workspaceRoot }; + const config = runtimeProvisionTestConfig({ provisionCommand: kind === "configured" ? command : undefined }); + const { recorder, operations } = createWorkspaceOperationRecorderDouble(); + const input = { runId: randomUUID(), agent: { id: "agent-1", name: "Remote worker", companyId: "company-1" }, + issue: null, workspace, config, executionWorkspaceId: randomUUID(), adapterEnv: {}, recorder }; + try { + expect(await ensureRuntimeServicesForRun({ ...input, skipHostProvision: true })).toHaveLength(1); + await expect(fs.readFile(marker, "utf8")).rejects.toMatchObject({ code: "ENOENT" }); + expect(operations.filter(operation => ["workspace_seed", "workspace_runtime_provision"].includes(operation.phase))).toHaveLength(0); + await stopRuntimeServicesForExecutionWorkspace({ executionWorkspaceId: input.executionWorkspaceId, workspaceCwd: workspaceRoot }); + const local = ensureRuntimeServicesForRun({ ...input, runId: randomUUID() }); + if (kind === "builtin") await expect(local).rejects.toThrow(/without a readable seed manifest/); + else expect(await local).toHaveLength(1); + expect(await fs.readFile(marker, "utf8")).toBe("host-runtime"); + } finally { + await stopRuntimeServicesForExecutionWorkspace({ executionWorkspaceId: input.executionWorkspaceId, workspaceCwd: workspaceRoot }); + await fs.rm(workspaceRoot, { recursive: true, force: true }); + restorePaperclipEnv(); + } + }); + it("runs runtime provisioning once when service starts race for the same workspace", async () => { const workspaceRoot = await fs.mkdtemp(path.join(os.tmpdir(), "paperclip-runtime-provision-race-")); const restorePaperclipEnv = configureRuntimeProvisionTestHome(workspaceRoot, "runtime-provision-race"); diff --git a/server/src/services/execution-workspaces.ts b/server/src/services/execution-workspaces.ts index 14c791d844d..9c4798614b8 100644 --- a/server/src/services/execution-workspaces.ts +++ b/server/src/services/execution-workspaces.ts @@ -1,6 +1,7 @@ import { assertTaskWorkspaceAccess, assertTaskWorkspaceSourceProjectAccess } from "./task-workspace-source-access.js"; import { parseObject } from "../adapters/utils.js"; import { resolveCoreTrustPreset } from "./trust-preset-resolver.js"; +import { CONTROLLER_PROVISION_COPY_ONLY, workspaceRequiresCopyOnlyProvisioning } from "./workspace-host-provision.js"; import { instanceSettingsService } from "./instance-settings.js"; import { taskWorkspaceSelectableCondition } from "./task-workspace-selection.js"; import { executionWorkspaceRepositoryService, lockExecutionWorkspaceRootProvenance, preserveExecutionWorkspaceRootProvenance, assertExecutionWorkspaceRootWriteAccess, assertExecutionWorkspaceRootReadAccess, assertIsolatedWorkspaceSourceReadAccess, retainIsolatedWorkspaceSourceAccess, canonicalRepositoryRoot, type IsolatedWorkspaceSourceAccess, type TaskWorkspaceCreationTrustContext } from "./execution-workspace-repositories.js"; @@ -258,6 +259,9 @@ async function preserveWorkspaceOwnershipForPatch( _issuePrivacySources: retainedSources, }; } + if (current.metadata?.[CONTROLLER_PROVISION_COPY_ONLY] === true) { + nextPatch.metadata = { ...(nextPatch.metadata ?? current.metadata), [CONTROLLER_PROVISION_COPY_ONLY]: true }; + } return nextPatch; } @@ -3417,9 +3421,14 @@ export function executionWorkspaceService(db: Db, opts: ExecutionWorkspaceServic const trust = resolveCoreTrustPreset({ companyId: row.companyId, agent: assignee, issue: boundTask, project: organization, workspaceSourceProject: sourceProject }); if (trust.kind === "denied") throw forbidden(trust.detail); + const copyOnlyProvisioning = await workspaceRequiresCopyOnlyProvisioning(tx, { + companyId: row.companyId, task: boundTask, sourceProjectId: row.projectId, + sourceWorkspaceId: row.projectWorkspaceId, boundWorkspace: row, + }); + if (copyOnlyProvisioning) nextMetadata[CONTROLLER_PROVISION_COPY_ONLY] = true; const realized = await ensurePersistedExecutionWorkspaceAvailable({ db: tx as unknown as Db, - skipHostProvision: trust.kind === "low_trust_review", + skipHostProvision: trust.kind === "low_trust_review" || copyOnlyProvisioning, beforeSourceCopy: verifyCopyIdentity, afterSourceCopy: verifyCopyIdentity, base: { diff --git a/server/src/services/heartbeat.ts b/server/src/services/heartbeat.ts index fa5f08bacf4..c8df58d270a 100644 --- a/server/src/services/heartbeat.ts +++ b/server/src/services/heartbeat.ts @@ -148,7 +148,6 @@ export { mergeExecutionWorkspaceMetadataForPersistence, resolveExecutionWorkspaceBranchOwnership, stripWorkspaceRuntimeFromExecutionRunConfig, - stripHostWorkspaceProvisionForLowTrustSandbox, preflightLowTrustWorkspaceIsolation, resolveWorkspaceAfterLowTrustPreflight, ensureManagedProjectWorkspace, @@ -2669,6 +2668,7 @@ export function heartbeatService( const { resolvedWorkspace, hostExecutionWorkspaceConfig, + skipHostProvision, latestWorkspaceConfigMetadata, workspaceConfigFreshness, workspaceOperationRecorder, @@ -2693,6 +2693,7 @@ export function heartbeatService( context, responsibleUserId, previousSessionParams, + workspaceSelection: taskWorkspaceIntentRow?.intent ?? null, }, policy: { trustPreset, @@ -3203,7 +3204,7 @@ export function heartbeatService( ); const runtimeServices = await startHeartbeatRuntimeServices(db, { run, agent, issueId, issueRef, executionWorkspace, context, issuesSvc, onLog, - persistedExecutionWorkspace, hostExecutionWorkspaceConfig, adapterEnv, workspaceOperationRecorder, + persistedExecutionWorkspace, hostExecutionWorkspaceConfig, skipHostProvision, adapterEnv, workspaceOperationRecorder, }); const adapter = getServerAdapter(agent.adapterType); const durableGoalControlRun = diff --git a/server/src/services/heartbeat/runtime-services.ts b/server/src/services/heartbeat/runtime-services.ts index 8f7d4a87646..83630e2904c 100644 --- a/server/src/services/heartbeat/runtime-services.ts +++ b/server/src/services/heartbeat/runtime-services.ts @@ -92,6 +92,7 @@ export function prepareHeartbeatRuntimeServiceIntents(input: { export async function startHeartbeatRuntimeServices(db: Db, input: RuntimeServiceContext & { persistedExecutionWorkspace: { id: string } | null; hostExecutionWorkspaceConfig: Record; + skipHostProvision?: boolean; adapterEnv: RuntimeInput["adapterEnv"]; workspaceOperationRecorder: RuntimeInput["recorder"]; }) { @@ -112,6 +113,7 @@ export async function startHeartbeatRuntimeServices(db: Db, input: RuntimeServic issueRef?.executionWorkspaceId ?? null, config: hostExecutionWorkspaceConfig, + skipHostProvision: input.skipHostProvision, adapterEnv, onLog, recorder: workspaceOperationRecorder, diff --git a/server/src/services/heartbeat/workspace-preparation.test.ts b/server/src/services/heartbeat/workspace-preparation.test.ts index 0fddf246d3d..dbacebdb8f2 100644 --- a/server/src/services/heartbeat/workspace-preparation.test.ts +++ b/server/src/services/heartbeat/workspace-preparation.test.ts @@ -116,6 +116,24 @@ describe.skipIf(!support.supported)("heartbeat workspace preparation boundary", expect(input.controllerLease.assertOwned).toHaveBeenCalledTimes(2); }); + it.each(["sandbox", "ssh", "local", null] as const)("uses the selected %s placement for controller provisioning", async driver => { + const { input, source, issue, envOrchestrator } = await fixture(true); + const marker = join(source, "host-provision-ran"); + const provisionCommand = `printf host > '${marker}'`; + input.config.mergedConfig = { workspaceStrategy: { type: "git_worktree", provisionCommand, runtimeProvisionCommand: "printf runtime" } }; + const originalConfig = structuredClone(input.config.mergedConfig); + input.environment.selectedEnvironmentForConfig = driver === null ? null : { ...input.environment.localEnvironment, driver }; + const stopped = new Error("Fixture stops before transport acquisition"); + vi.spyOn(envOrchestrator, "acquireForRun").mockRejectedValue(stopped); + await expect(prepareHeartbeatWorkspace(db, input)).rejects.toBe(stopped); + const bound = await readIssue(issue.id); + const [workspace] = await db.select().from(executionWorkspaces).where(eq(executionWorkspaces.id, bound.executionWorkspaceId!)); + expect(await readFile(join(workspace.cwd!, "README.md"), "utf8")).toBe("source content\n"); + if (driver === "sandbox" || driver === "ssh") await expect(readFile(marker, "utf8")).rejects.toMatchObject({ code: "ENOENT" }); + else expect(await readFile(marker, "utf8")).toBe("host"); + expect(input.config.mergedConfig).toEqual(originalConfig); + }); + it("checks physical root admission before publishing configured sibling repositories", async () => { const { input, source, issue } = await fixture(); await db.insert(projectWorkspaces).values({ companyId: issue.companyId, projectId: issue.projectId!, diff --git a/server/src/services/heartbeat/workspace-preparation.ts b/server/src/services/heartbeat/workspace-preparation.ts index ed6aaa5984c..9d0a5a7ba1c 100644 --- a/server/src/services/heartbeat/workspace-preparation.ts +++ b/server/src/services/heartbeat/workspace-preparation.ts @@ -1,7 +1,7 @@ import { resolveWorkspaceAfterLowTrustPreflight, WorkspaceValidationFailure, - stripHostWorkspaceProvisionForLowTrustSandbox, + stripHostWorkspaceProvision, assertGitWorktreeBaseWorkspaceReady, buildEffectiveRunWorkspaceConfigMetadata, resolveExecutionWorkspaceConfigFreshness, @@ -16,6 +16,7 @@ import { import { resolvePaperclipInstanceRoot } from "../../home-paths.js"; import fs from "node:fs/promises"; import path from "node:path"; +import { CONTROLLER_PROVISION_COPY_ONLY, workspaceRequiresCopyOnlyProvisioning } from "../workspace-host-provision.js"; import { and, asc, eq } from "drizzle-orm"; import { type ExecutionWorkspace } from "@paperclipai/shared"; import { heartbeatRuns, projectWorkspaces } from "@paperclipai/db"; @@ -93,6 +94,7 @@ export interface HeartbeatWorkspacePreparationInput { context: Record; responsibleUserId: string | null; previousSessionParams: Record | null; + workspaceSelection?: import("@paperclipai/shared").TaskWorkspaceIntent | null; }; policy: { trustPreset: TrustPresetResolution; @@ -326,13 +328,19 @@ export async function prepareHeartbeatWorkspace(db: Db, input: HeartbeatWorkspac : workspace; }, }); - const skipHostProvision = trustPreset.kind === "low_trust_review" - && lowTrustPreflightEnvironmentDriver === "sandbox"; + const hostProvisionDriver = selectedEnvironmentForConfig?.driver ?? lowTrustPreflightEnvironmentDriver; + const copyOnlyProvisioning = await workspaceRequiresCopyOnlyProvisioning(db, { + companyId: agent.companyId, + task: issueRef ? { ...issueRef, workspaceSelection: input.task.workspaceSelection } : null, + sourceProjectId: resolvedWorkspace.projectId, + sourceWorkspaceId: resolvedWorkspace.workspaceId, + boundWorkspace: reusableExistingExecutionWorkspace ?? existingExecutionWorkspace, + }); + const skipHostProvision = copyOnlyProvisioning || hostProvisionDriver === "sandbox" || hostProvisionDriver === "ssh"; const hostExecutionWorkspaceConfig = isDotRun ? {} : - stripHostWorkspaceProvisionForLowTrustSandbox({ + stripHostWorkspaceProvision({ config: mergedConfig, - trustPreset, - selectedEnvironmentDriver: lowTrustPreflightEnvironmentDriver, + skipHostProvision, }); const executionWorkspaceBase = { baseCwd: resolvedWorkspace.cwd, @@ -743,6 +751,7 @@ export async function prepareHeartbeatWorkspace(db: Db, input: HeartbeatWorkspac } const nextExecutionWorkspaceMetadata = { ...baseExecutionWorkspaceMetadata, + ...(copyOnlyProvisioning ? { [CONTROLLER_PROVISION_COPY_ONLY]: true } : {}), ...(persistedWorktreeInstanceRoot ? { [WORKTREE_INSTANCE_ROOT_METADATA_KEY]: @@ -1126,6 +1135,7 @@ export async function prepareHeartbeatWorkspace(db: Db, input: HeartbeatWorkspac return { resolvedWorkspace, hostExecutionWorkspaceConfig, + skipHostProvision, latestWorkspaceConfigMetadata, workspaceConfigFreshness, workspaceOperationRecorder, diff --git a/server/src/services/heartbeat/workspaces.ts b/server/src/services/heartbeat/workspaces.ts index ba396795a66..1c37505aa95 100644 --- a/server/src/services/heartbeat/workspaces.ts +++ b/server/src/services/heartbeat/workspaces.ts @@ -330,18 +330,17 @@ export function buildExecutionWorkspaceConfigSnapshot( return hasSnapshot ? snapshot : null; } -export function stripHostWorkspaceProvisionForLowTrustSandbox(input: { +export function stripHostWorkspaceProvision(input: { config: Record; - trustPreset: TrustPresetResolution; - selectedEnvironmentDriver: string | null | undefined; + skipHostProvision: boolean; }): Record { - if (input.trustPreset.kind !== "low_trust_review") return input.config; - if (input.selectedEnvironmentDriver !== "sandbox") return input.config; + if (!input.skipHostProvision) return input.config; const workspaceStrategy = parseObject(input.config.workspaceStrategy); if ( typeof workspaceStrategy.provisionCommand !== "string" && - typeof workspaceStrategy.runtimeProvisionCommand !== "string" + typeof workspaceStrategy.runtimeProvisionCommand !== "string" && + typeof input.config.runtimeProvisionCommand !== "string" ) return input.config; @@ -349,10 +348,9 @@ export function stripHostWorkspaceProvisionForLowTrustSandbox(input: { delete nextWorkspaceStrategy.provisionCommand; delete nextWorkspaceStrategy.runtimeProvisionCommand; - return { - ...input.config, - workspaceStrategy: nextWorkspaceStrategy, - }; + const nextConfig: Record = { ...input.config, workspaceStrategy: nextWorkspaceStrategy }; + delete nextConfig.runtimeProvisionCommand; + return nextConfig; } export async function preflightLowTrustWorkspaceIsolation(input: { diff --git a/server/src/services/workspace-host-provision.ts b/server/src/services/workspace-host-provision.ts new file mode 100644 index 00000000000..e7144571b19 --- /dev/null +++ b/server/src/services/workspace-host-provision.ts @@ -0,0 +1,27 @@ +import { projectWorkspaces, type Db } from "@paperclipai/db"; +import type { TaskWorkspaceIntent } from "@paperclipai/shared"; +import { and, asc, eq } from "drizzle-orm"; + +export const CONTROLLER_PROVISION_COPY_ONLY = "_controllerProvisionCopyOnly"; + +export async function workspaceRequiresCopyOnlyProvisioning(db: Db | Parameters[0]>[0], input: { + companyId: string; + task: { id: string; projectId: string | null; workspaceSelection?: TaskWorkspaceIntent | null } | null; + sourceProjectId: string | null; + sourceWorkspaceId: string | null; + boundWorkspace?: { sourceIssueId?: string | null; metadata?: Record | null } | null; +}) { + if (input.boundWorkspace?.metadata?.[CONTROLLER_PROVISION_COPY_ONLY] === true) return true; + const task = input.task; + if (!task) return Boolean(input.sourceProjectId || input.sourceWorkspaceId); + const intent = task.workspaceSelection; + if (intent && !["project", "operator_cwd", "task_default"].includes(intent.source)) return true; + if (intent?.selection.kind === "existing") return true; + if (input.boundWorkspace?.sourceIssueId && input.boundWorkspace.sourceIssueId !== task.id) return true; + if (intent?.source === "operator_cwd" && !input.sourceProjectId && !input.sourceWorkspaceId) return false; + if (!input.sourceProjectId || input.sourceProjectId !== task.projectId || !input.sourceWorkspaceId) return true; + const [defaultSource] = await db.select({ id: projectWorkspaces.id }).from(projectWorkspaces) + .where(and(eq(projectWorkspaces.companyId, input.companyId), eq(projectWorkspaces.projectId, input.sourceProjectId))) + .orderBy(asc(projectWorkspaces.createdAt), asc(projectWorkspaces.id)).limit(1); + return !defaultSource || defaultSource.id !== input.sourceWorkspaceId; +} diff --git a/server/src/services/workspace-runtime.ts b/server/src/services/workspace-runtime.ts index b4b32280af2..35fe6657772 100644 --- a/server/src/services/workspace-runtime.ts +++ b/server/src/services/workspace-runtime.ts @@ -7448,6 +7448,7 @@ type EnsureRuntimeServicesForRunInput = { workspace: RealizedExecutionWorkspace; executionWorkspaceId?: string | null; config: Record; + skipHostProvision?: boolean; adapterEnv: Record; onLog?: (stream: "stdout" | "stderr", chunk: string) => Promise; recorder?: WorkspaceOperationRecorder | null; @@ -7464,7 +7465,9 @@ async function ensureRuntimeServicesForRunInvocation( }); const acquiredServiceIds: string[] = []; const refs: RuntimeServiceRef[] = []; - const runtimeProvision = resolveRuntimeProvision(input); + const runtimeProvision = input.skipHostProvision + ? { command: "", kind: null } + : resolveRuntimeProvision(input); const runtimeProvisionCommand = runtimeProvision.command; const provisionCoordinator = createRuntimeProvisionCoordinator(); const allowFixedPortFallback = await isPersistedIsolatedExecutionWorkspace({