Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,5 @@ one in the code that pays it.
## Verdict log
| Date | Commit | Model | Verdict | Notes |
|------|--------|-------|---------|-------|
| 2026-09-22 | c76ac5969 | n/a | PASS | Option 1 (FIX-1515): lab host wires a fail-closed verified principal. Org-less HTTP read is 401 with "verified organization"; same read with an org lands. All seven legs green; all five controls red, each on clauses traceable to its one perturbation. |
| 2026-09-17 | 4d7a5749f | n/a | PASS | All seven legs green; all five controls red, each on clauses traceable to its one perturbation. |
2 changes: 1 addition & 1 deletion goals/devforce-lab/lab/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ no opinion at that spot — not because a convention is missing.
| `board.mts` | The loader walks four folders and silently ignores everything else, so a board declared as a tree folder would look declared and be read by nobody. Boards are declared in code, by design. |
| `workforce/flows/workers/em.mts` | The coordinator kind. It owns the board and files rows, and declares **no task entry at all** — so "the EM seat does no harness work" is a fact about the kind, not about one run. |
| `workforce/flows/workers/coder.mts` | The working kind. One task entry, `harnessManager` behind it, and the harness itself passed in as a slot. |
| `host.mts` | Read the tree, build the kinds, hire, register. The assignee → seat address is supplied by the caller, because a board's `workers` keys are assignees and which seat one reaches is a dispatcher's static `flowKind`. |
| `host.mts` | Read the tree, build the kinds, hire, register. The assignee → seat address is supplied by the caller, because a board's `workers` keys are assignees and which seat one reaches is a dispatcher's static `flowKind`. The HTTP door is wired with a host-owned `resolvePrincipal`, so an unauthenticated read is refused rather than waved through under the development-organization fallback. |
| the channel door in `host.mts`, with `notify.mts` | Which channel this lab opens, and when, is the app's — and so is which member resolves to which seat, because the dispatch seam refuses a target read out of stored data. `openChannels` takes no `orgId` and needs no wrapper: the server-created session carries the organization from the verified principal (FIX-1442). |
| the bare clone in `scratch-repo.mts` | Where an artifact has to survive to is the lab's question, not the framework's. A temp-directory repository plus a bare repository at a declared path the work is published to keeps the check re-runnable with no credential while still giving the artifact an address that outlives the process. |
| `acceptance-check.mjs`, with `acceptance.mts` | The requester's half of the brief. It names the module, the export and the behaviour, and is spawned from here against the produced tree — never copied into a checkout, because a check the run can reach is a check the run can satisfy by rewriting it. |
Expand Down
55 changes: 52 additions & 3 deletions goals/devforce-lab/lab/host.mts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* handles. Every convention file it reads is found by walking from one root; no
* file is named in this code.
*
* Four pieces here are the lab's rather than the framework's, each because the
* Five pieces here are the lab's rather than the framework's, each because the
* framework has no opinion at that spot:
*
* 1. **The board and its address map** (`board.mts`). The loader walks four
Expand All @@ -25,6 +25,10 @@
* opened at all. The framework keeps the member walk and runs a notify block
* once per declared member; which member resolves to which seat is the app's,
* because the dispatch seam refuses a target read out of stored data.
* 5. **The host `resolvePrincipal`.** FSD does not provide login. After
* FIX-1442 an unconfigured host runs under the development organization,
* which is not a refusal. The lab wires a fail-closed bearer check so an
* unauthenticated HTTP read is turned away for real (FIX-1515 / BR-17).
*
* **Not `workforce.gen.ts`.** `fsdev gen` renders that file for an app
* directory, and `goals/` is not one. The kinds are hand-assembled here, which
Expand All @@ -33,7 +37,13 @@
* reason.
*/

import { createFlowState, runAction } from "@flow-state-dev/engine";
import {
createBearerSecretPrincipalResolver,
createFlowState,
PrincipalResolutionError,
runAction,
type PrincipalResolver,
} from "@flow-state-dev/engine";
import type { FlowInstance } from "@flow-state-dev/core/types";
import {
CHANNEL_KIND,
Expand Down Expand Up @@ -70,6 +80,40 @@ export const LAB_TREE = fileURLToPath(new URL("./workforce", import.meta.url));
export const LAB_USER_ID = "u_devforce_lab";
export const LAB_ORG_ID = "org_devforce_lab";

/**

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.

Nit (simplify): This block plus header item 5, the createFlowState comment, and the extra lines in inspect all tell the same FIX-1515 story. Consider keeping one canonical explanation (header + ≤8 lines here) and dropping the site comments at the wiring call site—easier to keep true when FIX-1503 lands.

* Host-owned verified identity for this lab's HTTP door (FIX-1515).
*
* After FIX-1442 an app that configures no resolver runs under the built-in
* development organization. That default is not a refusal, so an org-less
* probe at the transport door was being answered. Wiring a real
* `resolvePrincipal` is what makes an unauthenticated read have nothing to
* fall back to — the same posture a deployment that has verified identity
* uses. The mint FIX-1503 will ship is not here yet; this is the thin
* host-owned stub that issue allows: one secret, one principal, fail-closed
* when nothing verified is presented.
*
* In-process `runAction` is not HTTP and keeps the explicit lab org
* (FIX-1503: trusted process callers). Only the door this check probes goes
* through the resolver.
*/
const LAB_PRINCIPAL_SECRET = "devforce-lab-verified-principal";

const verifyLabBearer = createBearerSecretPrincipalResolver({

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.

Nit (simplify): verifyLabBearer is only referenced from resolveLabPrincipal below. Collapsing to a single resolveLabPrincipal (build the resolver once at module scope inside it, or assign createBearerSecretPrincipalResolver({…}) to a const only used here) would match resolveDemoPrincipal in plugins/flow-state-dev/skills/install-fsd/templates/flow.mts without changing behavior.

secret: LAB_PRINCIPAL_SECRET,
principal: { userId: LAB_USER_ID, orgId: LAB_ORG_ID },
});

const resolveLabPrincipal: PrincipalResolver = async (context) => {
const principal = await verifyLabBearer(context);
if (principal === null) {
throw new PrincipalResolutionError(
"Request requires a verified organization: no verified principal was presented.",
{ status: 401 },
);
}
return principal;
};

/**
* Read a workforce tree into records, refusing a tree that did not load
* cleanly.
Expand Down Expand Up @@ -302,6 +346,9 @@ export async function openLab(options: OpenLabOptions): Promise<Lab> {
...Object.fromEntries(hired.map((seat) => [seat.id, seat])),
},
stores: { default: { primary: options.stores } },
// A configured resolver, so the development-organization fallback does
// not answer an unauthenticated HTTP read (FIX-1515 / BR-17).
resolvePrincipal: resolveLabPrincipal,

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.

Optional: this comment repeats the header/JSDoc above the secret; safe to delete if you consolidate commentary once.

...(options.logger === undefined ? {} : { runtimeConfig: { logger: options.logger } }),
} as never);

Expand Down Expand Up @@ -507,10 +554,12 @@ export async function openLab(options: OpenLabOptions): Promise<Lab> {
if (seatId in seats === false) throw new Error(`no seat "${seatId}" was hired`);

// BR-17 is about the DOOR, and the door is the transport host: a bare
// `runAction` never reaches `validateDispatch`, so an org-less one runs
// `runAction` never reaches `resolvePrincipal`, so an org-less one runs
// happily — and, because a file-declared document's body is static
// content rather than stored state, it even reads the document. The
// refusal this rule names therefore has to be asked for where it lives.
// The host is wired with `resolveLabPrincipal`, so this request has
// nothing to fall back to: no bearer, no verified org, 401.
if (inspectOptions?.omitOrg === true) {
// A session id nothing has used, and that is load-bearing:
// `validateDispatch` satisfies the org requirement from an EXISTING
Expand Down
Loading