Repository navigation
Refuse org-less lab reads with a verified principal (FIX-1515) - #2073
Conversation
…l (FIX-1515) After FIX-1442 an unconfigured host runs under the development organization, so leg (g) of it-wakes-the-seat-a-file-declared was answered instead of refused. Wire createBearerSecretPrincipalResolver on the lab host and fail-closed when no bearer is presented, so the transport door exercises a real refusal. The development-organization fallback is unchanged. Co-authored-by: Jake Hoffner <jhoffner@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
The model-free gate is green on the verified-principal wire. All five controls still fail on their own perturbation. Co-authored-by: Jake Hoffner <jhoffner@users.noreply.github.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
Simplify review (FIX-1515)
Verdict: approve. The change is the right layer and roughly the smallest behavior fix for BR-17 after FIX-1442’s dev-org fallback—not an over-engineered detour.
What had to happen
BR-17 is probed at the HTTP transport door (inspect with omitOrg: true), not via in-process runAction. An unconfigured host answers that probe under the development organization. Configuring any host-level resolvePrincipal removes that fallback; wiring createBearerSecretPrincipalResolver matches established engine/docs patterns (scheduled cron, install-fsd demo flow, knowledge-base MCP).
The extra resolveLabPrincipal wrapper is not redundant with the one-liner resolvePrincipal: createBearerSecretPrincipalResolver({…}) used in scheduled docs:
- Bearer helper returns
nullwhenAuthorizationis absent (by design). - With only the one-liner, this probe gets
401with “Action request requires non-empty userId” because the body’suserIdis not read through a configured custom resolver the same way as the default body resolver. run.mtsgrades the refusal withrefused.error.includes("org")(~689), so the error shape matters for the evidence leg—not just “something 401’d.”
So: host resolver + null→PrincipalResolutionError is the same structural pattern as resolveDemoPrincipal in the install-fsd template; host scope is appropriate for one shared door.
Where complexity crept in (optional cleanup)
Not blockers—mostly comment and naming weight:
- Comment duplication — FIX-1515 / fail-closed / FIX-1442 / FIX-1503 appears in the file header (item 5), ~15-line block above the secret,
createFlowState, and extendedinspectcomments. One canonical place (header + short block above the secret) would be easier to maintain. - Two bindings —
verifyLabBeareris only used fromresolveLabPrincipal; could be one function (or mirrorresolveDemoPrincipalverbatim, optionally withprocess.envlater likeFSD_DEMO_TOKEN). - Typing ceremony —
Parameters<typeof verifyLabBearer>/Awaited<ReturnType<…>>could bePrincipalResolutionContext+ResolvedPrincipalif you want less noise. - Error copy — Custom message is fine for BR-17; you could align wording with engine’s verified-org
PrincipalResolutionErrorstrings for consistency across repos (optional).
Approaches considered (and why I’d stay on this one)
| Alternative | Trade-off |
|---|---|
Framework createFailClosedBearerSecretPrincipalResolver |
Deduplicates lab + install-fsd; correct long-term, out of scope for a goals-only fix. |
Relax run.mts to accept any 401 |
Smaller host diff; weakens the stated evidence (“verified organization”) and couples grading to status code only. |
Per-flow authentication.resolvePrincipal on each seat kind |
Repeats the same door policy N times; host-level is cleaner. |
Rely on org rejection with { userId } only |
Misstates “verified” identity; worse than fail-closed bearer. |
Performance / structure
No meaningful hot-path concern (one header read + optional constant-time compare per HTTP request). No new cross-package import smell; reuses engine exports as intended.
Skipped (would need product/engine scope): exporting a fail-closed bearer helper from @flow-state-dev/engine.
Sent by Cursor Automation: Review For Best Approach
| */ | ||
| const LAB_PRINCIPAL_SECRET = "devforce-lab-verified-principal"; | ||
|
|
||
| const verifyLabBearer = createBearerSecretPrincipalResolver({ |
There was a problem hiding this comment.
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.
| export const LAB_USER_ID = "u_devforce_lab"; | ||
| export const LAB_ORG_ID = "org_devforce_lab"; | ||
|
|
||
| /** |
There was a problem hiding this comment.
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.
| 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, |
There was a problem hiding this comment.
Optional: this comment repeats the header/JSDoc above the secret; safe to delete if you consolidate commentary once.
There was a problem hiding this comment.
Code Snob — too small to shrink. No POC.
I read goals/devforce-lab/lab/host.mts, createBearerSecretPrincipalResolver, the host resolve path in createInboundTransportHost.ts (a null principal becomes "Action request requires non-empty userId"), and the BR-17 check in it-wakes-the-seat-a-file-declared/run.mts (includes("org")). Also the README row and the verdict line in goal.md.
The contract is a configured resolver, so the development-org fallback does not run, plus a missing bearer whose refusal says what was missing. The published helper returns null when the header is absent, and that null fails the leg. The wrapper is that one translation. Inlining it at createFlowState is the same lines. A failClosed helper is one call site. Parameters / Awaited / NonNullable is type noise on the same function; annotating PrincipalResolver does not shrink it. The header item, the local comment, the assignment note, and the probe note restate the diagnosis the way loadTree already does. Stripping them leaves the same contract. The README row and the verdict log are the two places this lab records a pass.
Not re-litigated: composing the bearer helper now rather than waiting for the FIX-1503 mint, and leaving in-process runAction on the explicit lab org.
Sent by Cursor Automation: Code Snob
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d18de1b491
ℹ️ 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".
…r (FIX-1515) goals typecheck failed: createBearerSecretPrincipalResolver is typed as possibly async, so a sync return after a null check was not assignable. Await the helper and annotate the wrapper as PrincipalResolver. Co-authored-by: Jake Hoffner <jhoffner@users.noreply.github.com>
… checklist framing current (FIX-1457) P1. ER-DevForce PASS read against a stale note in the DevForce goal that said the model-free sibling gate (BR-10 / BR-17) was red. FIX-1515 (#2073, merged 02196ce) fixed it; the gate's own verdict log is PASS at c76ac59. Re-ran the gate on origin/main at 9504947 on 2026-09-24: `pnpm tsx goals/devforce-lab/it-wakes-the-seat-a-file-declared/run.mts` reported PASS on all legs, including the org-less read being refused at the transport door. A dated resolution line was added under the stale paragraph in it-ships-an-artifact-a-person-can-open/goal.md, with the original kept as history. ER-DevForce's row, D6, the ownership prose and the SPEC set-table row now cite FIX-1515 / #2073. P2. The ER-Devtool checklist intro still framed the table as a source read with nothing observed live, and the findings paragraph said rows 4 and 6 need rendering that does not exist. Both are reframed as they stand: rows 4 and 6 rendering shipped (#2032, #2039), row 4 graded live (#2066), row 6 per D11, row 5 per D10, rows 1-3 on FIX-1320. The "as drafted" history is kept. The duplicate "where it stands" line below the table was removed. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016qaz1VpRK4wCQzxpjzZ4Hz
Review on #2167: the ledger contract ends spec and epic rounds at human direction approval and records merge separately. Approval was re-read from each PR's timeline and the coordinator's in-session record. Six of the ten direction PRs record no approval act apart from the owner's merge. #1944 was approved on 89c1a1d and re-approved at merge after the owner's re-cut. #1957 was approved by label and closed unmerged, not merged as the first draft said. #2045 was approved at 17:10Z, three hours before its merge. No round count moved, because no review wave landed between an approval and its merge. Rounds-to-approval, design-off and the numbers the two proposals cite are unchanged. The fix A and B quotes now match the revised skill text, and the #2073 note records FIX-1564, filed at wrap. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016qaz1VpRK4wCQzxpjzZ4Hz


The model-free DevForce gate is red on clean main. An org-less read of
eng.emis answered, because after FIX-1442 an app with no principal resolver runs under the built-in development organization. FIX-1496 BR-10 currently delegates its entire proof to that stale leg.This wires the lab's HTTP door with a host-owned verified principal —
createBearerSecretPrincipalResolver, fail-closed when no bearer is presented — so an unauthenticated read has nothing to fall back to and is refused for real. In-processrunActionstill uses the explicit lab org. FIX-1442's development-organization fallback is unchanged.Option 1, not Option 2. The mint FIX-1503 will ship is not here yet; a thin host-owned stub local to this check is the sequencing that issue already allowed. Retiring the leg would have left BR-10 proved by nothing.
What's asked of you
Nothing further to decide. Option 1 was the preferred path unless it forced invent-killed auth; it did not.
Parts worth reviewing closely
This is for the code reviewer. The weak spot is whether wrapping the published bearer helper to throw on a missing header is still "composing host-owned verified identity," or whether it is a lab-only shim. The wrap exists only because the helper returns
nullon a missing header (scheduled-transport shape), which would 401 as "non-empty userId" and fail the leg's "say what was missing" wording.Fixes FIX-1515. Closes #2052. No changeset — private
goals/only.How to review this — altitude, what's in scope, what's deliberately unsettled
How to review this. This is a bug fix on the direct route: there is no spec and no spec PR, because the hard part was the diagnosis and it happened in code. This PR is the only gate, so unlike a spec-backed change, the approach is in scope — nothing here was signed off upstream.
Most valuable here: the diagnosis chain — does the repro actually reproduce the reported failure, is the named cause the real one, does the fix address that cause rather than the symptom, and does the regression test fail without the fix? Then the second path (the legacy shape, the null boundary, the concurrent case, the cancel path).
In scope to challenge: where the guard was placed, any behaviour change a user could notice, and whether this should have been a spec'd feature instead of a fix.
Engineering calls — decided along the way, no product sign-off needed
createBearerSecretPrincipalResolverand fail-closed on a missing bearer, rather than wait for the unshipped FIX-1503 JWT mint. Inventing a lab JWT would have been the token FIX-1503 kills. If that call is wrong, we either stall this check on an unfiled epic or mint a lab-only JWT.runActionon the explicit lab org. HTTP is fire-and-forget, so the "same read with an org" cannot return facts through the door. If that call is wrong, the happy-path inspect has to grow a second wait/poll just to prove the door accepts a token.Verification — red before the fix, then the passing run
Red on unfixed
main:Transport log named the cause: no
resolvePrincipal, running under__fsd_default_org__.Green on this head:
Org-less HTTP inspect is now
401: Request requires a verified organization: no verified principal was presented.The same read with an org still lands.All five controls still red, each on its own perturbation:
address-the-reviewer— dispatched toeng.reviewerno-commit— row settledpendingswap-documents— missingFEATURE-BRIEFtokendrop-own-skill— missingBRANCH-NAMINGtokenstopped-at-limit— row settledpendingNo changeset. Files:
goals/devforce-lab/lab/host.mts,goals/devforce-lab/lab/README.md, verdict row on the check.