Skip to content

feat(devforce-lab): FIX-1762 code in the project's repository or its files (4/4) - #2748

Merged
jhoffner merged 13 commits into
mainfrom
claude/fix-1762-lab-and-goal-bea8wn
Oct 6, 2026
Merged

jhoffner merged 13 commits into
mainfrom
claude/fix-1762-lab-and-goal-bea8wn

Conversation

@jhoffner

@jhoffner jhoffner commented Oct 4, 2026 •

Copy link
Copy Markdown
Collaborator

Requested by Jake · project thread

PR 4 of 4 for FIX-1762. PRs 1 to 3 (#2737, #2738, #2744) have merged, so this PR targets main and its diff is only PR 4's change. One review fix here touches code from PR 2: project ids now refuse a backslash. The files tool's description fix already landed with PR 2.

Before

  • A project could name a repository, and the harness manager could run on a workspace host. Nothing connected the two.
  • The DevForce lab's coder ran every row on one fixed scratch repository, whatever project held the board.
  • A run's notes outside git were lost when the run ended.
  • The chief of staff couldn't change a project's repository, and nobody approved a repository before it was written.

After

  • projectWorkspace({ board }) (workforce, minor) is a RunSource for a project's mailbox board. It finds the project that holds the board's workstream and answers in one of three ways:

    • Repository: the project's repository, with its kept files in project/ beside the checkout.
    • Files: the project's files alone, in workspace/, when the project has no repository.
    • Refusal: not-a-member when the run's owner isn't a member, no-project when no project holds the workstream, or no-such-project.

    It reads exactly two rows: the workstream claim and the project. It derives the mailbox from the board id, and the run's owner comes from the server-set identity (BP-031). Its collections come through projectWorkspaceCapability. harness-manager does not import Workforce.

  • DevTeam (Shift Manager):

    • The coder runs on localWorkspaceHost, which allows only file:// remotes, with projectWorkspace as its source.
    • Storefront names a bare repository kept beside the store. A new Sandbox project has no repository.
    • The chief of staff gains setRepository. Every repository write waits on a human_approval in Inbox, whether it comes from setRepository or from createProject with a repository. Approve writes it and Deny writes nothing. What Inbox shows leaves out any password.
  • Brief tab: it names the project's repository, or shows "No repository · runs on project files". A legacy row with no repository key reads as none.

  • Goal check goals/devforce-lab/it-codes-in-the-projects-repository/: three legs and two controls (see Verification).

  • Docs:

    • projects guide: a "Coding work in a project" section, plus project/ beside the checkout.
    • harness-manager guide and README: a link to that section and a snippet.
    • Shift Manager README and overview: the Brief's repository line.
  • phase.mts validate now receives the host. A host run counts as done in one of two cases:

    • a files run whose workspace/ changed from what it held as its harness started (and that passes acceptance when requireAcceptance is on);
    • a repository run with a commit on no remote-tracking ref.

How

  • project-workspace.ts: the claim is read from workstream-claims/<mailboxId>, then the project row, which is parsed through projectRowSchema. Membership is checked before any file is read. The kept files are bound to the caller's own project-files collection id, so every hydrate and flush is scoped to that project's key.
  • Lab: openLab({ workspace: { root, remotes } }) builds the host. labWorkspaceHost's saveNothing is the no-sync-back control. The repository ask is a tapIf/tap handler ahead of the write step, so a Deny throws out before the write runs.
  • Merged with PR 3 and main:
    • filesOnly pinning and "a failed final save fails the attempt" needed no code change here.
    • The projects guide now says both: a run stays on the files it began with, and a run isn't done until its files are saved.
    • The harness-manager README conflict was resolved by keeping both paragraphs.
    • The coder worker keeps both main's ledger door and this PR's project workspace.
    • The repository-approval test moved with Shift Manager to packages/shift-manager/test/.

Verification

All of the following ran on the latest merge of main (head 8b3452e2). The shift-manager suite ran with no model keys set.

  • VG, goal check: pnpm tsx goals/devforce-lab/it-codes-in-the-projects-repository/run.mts passes, keyless, in about 4 s.

    • a: the branch holds marker A and "storefront run: add the greeting". The note is in project-files/storefront/notes/storefront-plan.md, and git status is clean.
    • b: the first sandbox run started in an empty workspace/. Its app/index.html is in project-files/sandbox/, and the second run started with it. A platform run started empty.
    • c: the row was cancelled before its harness ran: remote-not-allowed: the remote "https://git.example.com/acme/platform.git" is not allowed on this host. .clones holds only storefront's.
  • Controls: both fail where they must, and the control-shape guard passes.

    • GOAL_CONTROL=fixed-source: FAIL at a:marker (… does not hold MARKER-A.txt with marker A: it was not cut from storefront's repository), and on every leg that needs a project's source.
    • GOAL_CONTROL=no-sync-back: FAIL on exactly a:note-saved, b:file-saved and b:second-run-sees-file (the second run started with [], not the first run's app/index.html).
  • Held-out fixture: a second fixture, with nested paths and an ssh git@ remote, also passes.

  • V6, projectWorkspace: packages/workforce/test/project-workspace.test.ts covers:

    • the files and repository answers;
    • one project's files and never another's;
    • the only reads being workstream-claims.getOptional(eng.feature) and projects.getOptional(sandbox);
    • not-a-member and no-project refused, with no files read and no place made;
    • a bad board id or a missing capability throwing.

    It goes red with the membership check removed and with the files branch forced.

  • V7, repository approval: packages/shift-manager/test/devteam-repository-ask.test.ts uses a scripted chief-of-staff model, answered through the engine's resume route as Inbox does. It covers:

    • setRepository: nothing changes while waiting or on Deny, and Approve writes it.
    • createProject with a repository: Deny creates nothing.
    • createProject without one: no ask.
    • The password is hidden from what Inbox shows.

    All three tests go red when the ask is removed.

  • Suites:

    • workforce 1351 passed, workspace 176, harness-manager 210, shift-manager 358 (1 skipped).
    • Typecheck passes for all five, goals tsc --noEmit passes, and package-boundary validation passes.
    • pnpm install --frozen-lockfile passes.
  • Sibling checks: All five other DevForce goal checks pass.

Review fixes

  • readProjectFiles's action description now says path and size, not body.
  • The lab uses workspace's redactRemote (now exported, with a patch changeset) instead of its own copy.
  • A files run that changed nothing is not done, and it goes through the acceptance gate.
  • projectIdProblem refuses a backslash, which a workspace mount scope rejects.
  • openLab takes a modelResolver, so the approval test's resume uses its scripted model. Before this it used the environment's model, and with no key that failed in CI.

Notes

  • Changesets: workforce gets a minor and workspace a patch. Goals and labs get none.
  • Profile defaults: in the DevTeam profile, Sandbox holds no workstream. A store from before this change keeps its Storefront row with no repository, because stored rows are handed back unchanged. Delete the store for the new defaults.
  • Leg b moves eng.feature between projects, because the lab opens one board.
  • The approval is lab behaviour. The framework docs don't describe the Inbox approval on a repository write.
  • The lockfile importer lines for goals and workforce → workspace were added by hand. A full pnpm install also rewrote unrelated entries, and I reverted those.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HncstYwr5VM81872oUq6gc

claude added 6 commits October 4, 2026 23:01
…ry-tikxs6' into claude/fix-1762-lab-and-goal-bea8wn
…rd (FIX-1762)

A coding run on a mailbox board now gets its files from the project that
holds the board's workstream: board -> mailbox (derived from the board's
minted id) -> the workstream's claim -> the project row -> its repository
with the project's files beside the checkout, or the project's files
alone. Reads only the claim and the row; refuses a run whose owner is not
a member, or whose workstream no project holds, before any file is read.
projectWorkspaceCapability declares the collections it reads.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P9UuEKLJUWaKiSrYWCJbt5
…its files (FIX-1762)

The lab's coder runs on a workspace host whose source is projectWorkspace on
the board. Storefront names a bare repository beside the store; a new Sandbox
project names none. The chief of staff gains setRepository, and every
repository write (setRepository, or createProject with one) waits on a
human_approval in Inbox first. phase.mts validate now receives the host.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P9UuEKLJUWaKiSrYWCJbt5
The Brief tab shows the repository the project's coding work runs in, or
"No repository · runs on project files". A legacy row reads as none.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P9UuEKLJUWaKiSrYWCJbt5
…(FIX-1762)

Three legs on the DevTeam lab: a project with a repository runs on a branch of
it with its kept files beside the checkout; a project without one runs on its
files and the next run sees them; a remote the host does not allow is refused
by name before anything is cloned. Controls fixed-source and no-sync-back.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P9UuEKLJUWaKiSrYWCJbt5
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P9UuEKLJUWaKiSrYWCJbt5
@jhoffner jhoffner self-assigned this Oct 4, 2026
@vercel

vercel Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

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

3 Skipped Deployments
Project Deployment Actions Updated
flow-state-dev-docs Ignored Ignored Oct 6, 2026 4:34pm UTC
flow-state-dev-kitchen-sink Ignored Ignored Oct 6, 2026 4:34pm UTC
flow-state-dev-ui Ignored Ignored Preview Oct 6, 2026 4:34pm UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-04T23:10:21.944042Z d0070bf PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@linear-code

linear-code Bot commented Oct 4, 2026

Copy link
Copy Markdown

FIX-1762

@cursor

cursor Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 37e4b489-3873-4515-870a-fe3dcb8b1efc)

jhoffner commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator Author

Second look + architecture pass (PR 4/4, FIX-1762)

Reviewed the five commits above B. The overall shape holds up: projectWorkspace as a RunSource that reads two rows, with Workforce knowing about projects and harness-manager staying ignorant of it. I don't see a leaner approach for that part. Findings below, most important first.

1. Correctness: a files run is "done" without the harness doing anything (goals/devforce-lab/lab/phase.mts, leftFiles)

leftFiles returns true when workspace/ holds any entry other than the ask-marker dir. But provisionFiles in packages/workspace/src/local-host.ts hydrates workspace/ from the project's kept files before the run. So on any run after the first in a project, workspace/ is already non-empty. The done-condition passes even if the harness wrote nothing, and the row settles.

The goal check doesn't catch this. Leg b's second run starts with app/index.html, and the check never asserts that a no-op second run fails. Suggested fix: compare against what the host laid down. For example, snapshot the listing and mtimes/hashes at validate/start, or ask the host which files changed since hydrate. Then add a control where the harness does nothing on a run that starts with files, and expect the row not to settle.

2. Brittle coupling: host layout inferred from a directory name (phase.mts, basename(context.workspacePath) === "workspace")

The phase decides between "files run" and "repo run" by matching the host's internal directory name. A repo checkout is checkout/, but nothing guarantees a future layout or a differently named place stays distinguishable. projectWorkspace already knows the answer (kind: "files" | "repo") and the host knows it too. Having the host expose the kind on the run's place would remove the name match. It would also fix #1 more cleanly, since the same place could report its hydrated baseline. If the cross-package change is too much for this PR, a one-line note on the coupling in phase.mts is the minimum.

3. Duplicate helper (goals/devforce-lab/lab/host.mts, withoutCredentials)

packages/workspace/src/remotes.ts already has redactRemote, which is not exported from the package index. The lab re-implements it with new URL. The two can drift (the existing one documents the "last @" rule). Export redactRemote from @flow-state-dev/workspace and use it here. The repo's convention is no duplicate helper copies across packages.

4. Two identity reads in one function (project-workspace.ts)

The owner comes from ctx.user?.identity?.id, and the files collection id from principalFromContext(ctx). They should agree, but the header's BP-031 argument is stronger if both derive from the same call. Take the owner from the principal principalFromContext already returns, if it carries a user id.

5. Architecture notes (no action needed in this PR)

  • OpenLabOptions.workspace is now a union discriminated by "sourceRepo" in …. The phase uses another duck-type, "provision" in workspace. Two parallel ways to configure where runs work will outlive this PR. Once the other checks move onto the host path, the fixed-repo shape can go. Worth a follow-up issue rather than doing it here.
  • askRepository lives in the lab, so the framework docs don't describe it. That is acknowledged in the PR notes. If the Inbox approval on a repository write is wanted by other apps, it belongs next to setRepository in Workforce, with a flag to turn it on. Not now, but if a second app asks for it, move it then.
  • Hand-edited lockfile importer lines. Fine as described, but CI's --frozen-lockfile is the real test. Confirm it is green on the head commit.

What I'd leave alone

  • The three-way answer shape and the refusals. They are small and each is tested.
  • Reading exactly two rows. The test pinning that is good.
  • The tapIf/tap ordering so a Deny throws before the write.

Generated by Claude Code

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Problem this PR solves

Coding runs were tied to a single lab scratch repo regardless of which project held the board, and non-git project artifacts did not survive across runs. FIX-1762 (4/4) wires per-project repository + project-files, a projectWorkspace run source, engine list(prefix) for lazy org collections, lab/shift-manager integration, and a model-free goal that reads outcomes from git + lab.stored.

Is this the right shape?

Mostly yes. The split matches how the repo is already layered:

  • @flow-state-dev/workspace — clone, mount, projection, remotes allowlist
  • workforce — project row semantics, membership, claims, what gets stored on the row
  • harness-manager — supervision; consumes RunSource via localWorkspaceHost

A simpler story (“just put a repository on the project row”) does not cover the goal: notes beside the checkout must not land in git, and repository-less projects need durable files. A separate project-files collection plus projectWorkspace is the minimal way to express “repo branch + project/ tree” vs “files only” without overloading the projects row or inventing a second git remote.

The engine resource-registry list(prefix) → scoped getByPrefix change is load-bearing (BP-033). Without it, multi-project orgs would bulk-load every project-files/** row on the first scoped list. Good that it ships in the same PR as the consumer.

Where complexity crept in (and what I’d do differently)

Area Observation Cleaner alternative (if revisiting)
readProjectFiles Lists paths/sizes but readContent() + UTF-8 encode every file (see inline). projectFileSchema already carries hash / updatedAt from projection sync but not size. Persist size (bytes) at write/sync time in state (or expose byte length from the store API) so listing stays metadata-only.
Remote validation repository-value.ts (what may be stored) parallels workspace/remotes.ts (what may be cloned). Rules will drift. Shared pure parse layer; workforce maps to refusal strings, workspace adds allowlist + cloneKey. npm git-url parsers do not cover your scp + smuggling rules.
host.mts Large integration surface in one module (projects seeding, workspace host, ask flow, session client). Not wrong for a lab entrypoint; if churn continues, split at documented seams (lab-session-client, lab-door, chief-of-staff tools) rather than growing openLab further.
Claim create vs stampClaim createProject inlines claim create loops instead of reusing stampClaim (intentionally never “adopts”). Small createClaimOnly helper to avoid future drift — optional.
Escaped-segment tests Multiple adapter packages repeat similar flow-kind vectors (some may ride in from the parent branch). Shared test vectors from engine — follow-up, not a blocker for this epic slice.

Smaller fixes worth doing in this PR

  • defineProjectBlocks action description for readProjectFiles still says “body” while the handler and README return path + size only — tools/models will trust the action map.

What I would not simplify away

  • projectWorkspaceCapability + refusal reasons before clone — correct BP-031 story.
  • No browser read on project-files + member-only handler — intentional.
  • Goal anti-game (read git + storage, not harness logs) — appropriate for FIX-1762 proof.
  • Volume of docs/tests — heavy but proportional to a new public workforce surface.

Verdict

Direction looks right and the cross-package boundaries are clean. I’m not approving yet because readProjectFiles scales with total file bytes for a metadata API, and the action description mismatch is a real foot-gun for chief-of-staff tooling. Neither requires re-architecting the epic; both are tighten-ups on the chosen approach.

Happy to approve after those are addressed or explicitly accepted as known v1 limits in the PR description.

Open in Web View Automation 

Sent by Cursor Automation: Review For Best Approach

Comment thread goals/devforce-lab/lab/host.mts Resolved
…(FIX-1762)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HncstYwr5VM81872oUq6gc

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Snob

withoutCredentials in goals/devforce-lab/lab/host.mts is a second copy of redactRemote (packages/workspace/src/remotes.ts). Inbox only needs the password left out of the remote it shows. Call the existing function: one export line, and the lab helper goes.

POC (draft, do not merge): #2749

Fold that subtraction into this PR, then close the POC unmerged after this lands.

I also read packages/workforce/src/projects/project-workspace.ts, goals/devforce-lab/lab/phase.mts, goals/devforce-lab/lab/scratch-repo.mts, goals/devforce-lab/it-codes-in-the-projects-repository/run.mts, and the Brief / setRepository wiring. The three-way answer, the ask-before-write, and the two rev-list probes are the contract. Folding the probes into one counter ties once each question stays. The file headers restate the code and are not a smaller shape.

Open in Web View Automation 

Sent by Cursor Automation: Code Snob

Comment thread goals/devforce-lab/lab/host.mts Resolved
jhoffner pushed a commit that referenced this pull request Oct 4, 2026
The action description still said each file's body after the handler
stopped returning bodies. Same text as #2748's 3ad370c.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UyaSbP7u4EMjKM6U3bXQ6t

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d0070bf674

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread goals/devforce-lab/lab/phase.mts Resolved
Comment thread goals/devforce-lab/lab/phase.mts Resolved
claude added 3 commits October 4, 2026 23:12
…e (FIX-1762)

Drops the lab's own withoutCredentials copy; workspace now exports
redactRemote. Folds Cursor's POC #2749.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HncstYwr5VM81872oUq6gc
…tance; refuse a backslash in a project id (FIX-1762)

- A files run is done only when workspace/ differs from what it held as
  the harness started (recorded through the harness cwd feed), and it
  now goes through the requireAcceptance gate like a repository run.
- projectIdProblem refuses '\\', which a workspace mount scope rejects.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HncstYwr5VM81872oUq6gc
…sume uses (FIX-1762)

The test swapped the model on the runtime's config after boot, which the
HTTP door's router had already copied, so the Approve resume resolved
the environment's model: a live one locally, none in CI. openLab now
takes a modelResolver and the test hands it a scripted one once.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HncstYwr5VM81872oUq6gc
@jhoffner
jhoffner added this pull request to stack #2755 October 4, 2026 23:48
Base automatically changed from claude/fix-1762-harness-manager-cztr0w to main October 5, 2026 23:32
@cursor

cursor Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: e83d20de-03aa-4614-a03e-e3f020d10d44)

…nd-goal-bea8wn

# Conflicts:
#	goals/devforce-lab/lab/workforce/flows/workers/coder.mts
…nd-goal-bea8wn

# Conflicts:
#	packages/shift-manager/test/devteam-repository-ask.test.ts
@cursor

cursor Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 92438e7f-3b2d-4a43-98a5-074e56077fed)

@jhoffner
jhoffner merged commit 9fd92e5 into main Oct 6, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants