Skip to content

Refuse org-less lab reads with a verified principal (FIX-1515) - #2073

Merged
jhoffner merged 3 commits into
mainfrom
cursor/fix-1515-devforce-lab-org-refusal-8b59
Sep 23, 2026
Merged

jhoffner merged 3 commits into
mainfrom
cursor/fix-1515-devforce-lab-org-refusal-8b59

Conversation

@jhoffner

@jhoffner jhoffner commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

The model-free DevForce gate is red on clean main. An org-less read of eng.em is 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-process runAction still 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 null on 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
  • Compose createBearerSecretPrincipalResolver and 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.
  • Leave in-process runAction on 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:

FAIL —
  - an org-less read of eng.em was answered rather than refused

Transport log named the cause: no resolvePrincipal, running under __fsd_default_org__.

Green on this head:

pnpm tsx goals/devforce-lab/it-wakes-the-seat-a-file-declared/run.mts
→ PASS (exit 0)

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 to eng.reviewer
  • no-commit — row settled pending
  • swap-documents — missing FEATURE-BRIEF token
  • drop-own-skill — missing BRANCH-NAMING token
  • stopped-at-limit — row settled pending

No changeset. Files: goals/devforce-lab/lab/host.mts, goals/devforce-lab/lab/README.md, verdict row on the check.

Open in Web Open in Cursor 

…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>
@vercel

vercel Bot commented Sep 22, 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 Sep 23, 2026 2:16am UTC
flow-state-dev-kitchen-sink Ignored Ignored Sep 23, 2026 2:16am UTC
flow-state-dev-ui Ignored Ignored Preview Sep 23, 2026 2:16am UTC

Request Review

@linear-code

linear-code Bot commented Sep 22, 2026

Copy link
Copy Markdown

FIX-1515

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>
@jhoffner
jhoffner marked this pull request as ready for review September 23, 2026 00:46
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 23, 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-09-23T00:50:57.547685Z d18de1b Draft marked ready
ℹ️ 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.

@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.

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 null when Authorization is absent (by design).
  • With only the one-liner, this probe gets 401 with “Action request requires non-empty userId” because the body’s userId is not read through a configured custom resolver the same way as the default body resolver.
  • run.mts grades the refusal with refused.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:

  1. 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 extended inspect comments. One canonical place (header + short block above the secret) would be easier to maintain.
  2. Two bindings — verifyLabBearer is only used from resolveLabPrincipal; could be one function (or mirror resolveDemoPrincipal verbatim, optionally with process.env later like FSD_DEMO_TOKEN).
  3. Typing ceremony — Parameters<typeof verifyLabBearer> / Awaited<ReturnType<…>> could be PrincipalResolutionContext + ResolvedPrincipal if you want less noise.
  4. Error copy — Custom message is fine for BR-17; you could align wording with engine’s verified-org PrincipalResolutionError strings 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.

Open in Web View Automation 

Sent by Cursor Automation: Review For Best Approach

*/
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.

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.

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.

@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 — 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.

Open in Web View Automation 

Sent by Cursor Automation: Code Snob

@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: 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".

Comment thread goals/devforce-lab/lab/host.mts Resolved
…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>
@jhoffner
jhoffner merged commit 02196ce into main Sep 23, 2026
12 checks passed
jhoffner pushed a commit that referenced this pull request Sep 24, 2026
… 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
jhoffner pushed a commit that referenced this pull request Sep 24, 2026
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
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.

devforce-lab check it-wakes-the-seat-a-file-declared asserts pre-FIX-1442 org refusal; BR-10 currently proved by nothing

2 participants