Public: anyone can read this; the crew can change it.

Defect on the v1.0.0 path: the probe's keeper line answers 403 to a crew token on production, so the release tick's health is still unproven #15521

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

The cause is (2): production doesn't know the token. From this run's shell, GET https://lab--forge-trevato-apps.open-platform.sh/api/v1/user with the run's bearer token answers 401 ("authenticate with a bearer token…").

Notes

shipped production is serving it deploy 496afdb

opened this

The cause is (2): production doesn't know the token. From this run's shell, GET https://lab--forge-trevato-apps.open-platform.sh/api/v1/user with the run's bearer token answers 401 ("authenticate with a bearer token…"). The run token was issued by forge.open-platform.sh, but the lab app is a separate forge with its own accounts. Production had no account for the token, so the keeper route treated the caller as anonymous and gave anonymous's 403. It isn't (1), because no account is reached for canWrite to judge. It isn't (3) either: the route does run mayReadKeeper, and test/keeper-writer-reads.test.ts from #15516 still shows a writer's rw and ro tokens get 200.

Changes

  • src/http/api/keeper.ts: when a credential was sent and matches no account here (ctx.auth.refused), GET /api/v1/keeper now answers 401 invalid_token with "that token or password matches no account here". This is the same answer /api/v1/here already gives. Read-only members and anonymous still get 403 with the same words as before.
  • scripts/v1-probe.ts: a refused keeper read is now worded by its cause:
    • A 401 says 401, token not accepted here: <origin> knows no account for it.
    • On a 403 the probe asks /api/v1/user with the same token. If that answers 401, the line says "token not accepted here", so the wording is already right against production as it runs now, before this change lands.
    • Otherwise it names the account (with unsafe characters stripped) and says the account must write the forge's repository.
    • When the beat is read, the line prints PASS or FAIL as before.
  • Tests:
    • test/keeper-writer-reads.test.ts: an unknown token gets 401 invalid_token; before this change it got 403.
    • test/v1-probe.test.ts: "not accepted here" is printed for both the new 401 and the older 403, and the 403 wording for an account without the right is covered.

Not done The last box on the issue ("the probe's keeper line prints PASS or FAIL from the crew's shell") can't be met by code. The crew's shell only holds forge.open-platform.sh tokens, and production won't accept them. Someone has to make the crew account on the lab forge, give it write access to trevato/forge there, and hand the probe that token. After that, the line prints PASS or FAIL. Leave the issue open until then.

Checks

  • bun x tsc --noEmit is clean, and scripts/gate.ts --fix made no changes.
  • bun scripts/fast.ts said the change reaches too many test files to run them all here (2,188 files, about 185 minutes), so I picked eight myself: the keeper, probe and release-keeper tests that cover this. All 56 tests in them pass.
  • The push hook required a commit saying how to try the change, so the branch has an empty commit that does that.

Try it

  • curl -i -H 'authorization: Bearer nope' <preview>/api/v1/keeper → 401 invalid_token.
  • Without the header → 403 with the release-history message.
  • bun scripts/v1-probe.ts <base> trevato/forge run with the crew token prints UNKNOWN keeper's last beat: … token not accepted here.

🤖 Generated with Claude Code

Closes #15520

3 earlier comments · 2 events
commented

The cause is (2): production doesn't know the token. From this run's shell, GET https://lab--forge-trevato-apps.open-platform.sh/api/v1/user with the run's bearer token answers 401 ("authenticate with a bearer token…"). The run token was issued by forge.open-platform.sh, but the lab app is a separate forge with its own accounts. Production had no account for the token, so the keeper route treated the caller as anonymous and gave anonymous's 403. It isn't (1), because no account is reached for canWrite to judge. It isn't (3) either: the route does run mayReadKeeper, and test/keeper-writer-reads.test.ts from #15516 still shows a writer's rw and ro tokens get 200.

Changes

  • src/http/api/keeper.ts: when a credential was sent and matches no account here (ctx.auth.refused), GET /api/v1/keeper now answers 401 invalid_token with "that token or password matches no account here". This is the same answer /api/v1/here already gives. Read-only members and anonymous still get 403 with the same words as before.
  • scripts/v1-probe.ts: a refused keeper read is now worded by its cause:
    • A 401 says 401, token not accepted here: <origin> knows no account for it.
    • On a 403 the probe asks /api/v1/user with the same token. If that answers 401, the line says "token not accepted here", so the wording is already right against production as it runs now, before this change lands.
    • Otherwise it names the account (with unsafe characters stripped) and says the account must write the forge's repository.
    • When the beat is read, the line prints PASS or FAIL as before.
  • Tests:
    • test/keeper-writer-reads.test.ts: an unknown token gets 401 invalid_token; before this change it got 403.
    • test/v1-probe.test.ts: "not accepted here" is printed for both the new 401 and the older 403, and the 403 wording for an account without the right is covered.

Not done The last box on the issue ("the probe's keeper line prints PASS or FAIL from the crew's shell") can't be met by code. The crew's shell only holds forge.open-platform.sh tokens, and production won't accept them. Someone has to make the crew account on the lab forge, give it write access to trevato/forge there, and hand the probe that token. After that, the line prints PASS or FAIL. Leave the issue open until then.

Checks

  • bun x tsc --noEmit is clean, and scripts/gate.ts --fix made no changes.
  • bun scripts/fast.ts said the change reaches too many test files to run them all here (2,188 files, about 185 minutes), so I picked eight myself: the keeper, probe and release-keeper tests that cover this. All 56 tests in them pass.
  • The push hook required a commit saying how to try the change, so the branch has an empty commit that does that.

Try it

  • curl -i -H 'authorization: Bearer nope' <preview>/api/v1/keeper → 401 invalid_token.
  • Without the header → 403 with the release-history message.
  • bun scripts/v1-probe.ts <base> trevato/forge run with the crew token prints UNKNOWN keeper's last beat: … token not accepted here.

🤖 Generated with Claude Code

commented

The keeper line printed UNKNOWN (403) on production because production doesn't know the crew's token. That is cause (2) from the issue, not (1) or (3). The token is issued by forge.open-platform.sh. The lab app is a separate forge with its own accounts, and its GET /api/v1/user answers that token 401. The keeper route treated the unmatched token as anonymous and gave anonymous's 403. It isn't (1), because no account is reached for canWrite to judge. It isn't (3): the route does run mayReadKeeper, and the writer tests from #15516 still show a writer's rw and ro tokens get 200.

Changes

  • src/http/api/keeper.ts: a credential that matches no account here (ctx.auth.refused) now gets 401 invalid_token with "that token or password matches no account here". /api/v1/here already answers this way. Read-only members and anonymous still get 403 with the same words as before.
  • scripts/v1-probe.ts: a refused keeper read is worded by its cause:
    • A 401 prints UNKNOWN … 401, token not accepted here: <origin> knows no account for it.
    • On a 403 the probe asks /api/v1/user with the same token. If that answers 401, it prints "token not accepted here" too, so the wording is right against production as it runs today.
    • Otherwise the line names the account (control characters stripped) and says it must write the forge's repository.
    • When the beat is read, the line prints PASS or FAIL as before.
  • Tests:
    • test/keeper-writer-reads.test.ts: an unknown token gets 401 invalid_token; before this change it got 403.
    • test/v1-probe.test.ts: covers "not accepted here" on both the new 401 and the older 403, and the 403 wording for an account without the right.
  • A commit carries No door:, because the terminal signs in by SSH key, never by bearer token, so an unknown token can't reach it. Its Release keeper already decides with mayReadKeeper. This is what the "both doors" gate rule asked for.

Not done The last box ("the probe's keeper line prints PASS or FAIL from the crew's shell") can't be met by code. The crew's shell only holds forge.open-platform.sh tokens, and production won't accept them. Someone has to make a crew account on the lab forge, give it write access to trevato/forge there, and give the probe its token. After that the line prints PASS or FAIL. Leave the issue open until then.

Checks

  • bun x tsc --noEmit is clean.
  • scripts/gate.ts passes, including the "both doors" rule that failed the check.
  • scripts/fast.ts said the change reaches too many test files to run them all here, so I picked eight that cover the keeper, the probe and release-keeper access. All 56 tests in them pass.

Try it

  • curl -i -H 'authorization: Bearer nope' <preview>/api/v1/keeper → 401 invalid_token.
  • Without the header → 403 with the release-history message.
  • bun scripts/v1-probe.ts https://lab--forge-trevato-apps.open-platform.sh trevato/forge with the crew token → UNKNOWN keeper's last beat: … token not accepted here.

🤖 Generated with Claude Code

Changes requested — before the latest push

One thing to fix first: the preview does not show the change working. curl -H 'authorization: Bearer nope' https://lab--15521--forge-trevato-apps.open-platform.sh/api/v1/keeper answers 403 forbidden with the release-history message, not the 401 invalid_token the pull's 'Try it' promises. /api/v1/here with Bearer forge_nope on the same preview answers you: anonymous (not 401), so ctx.auth.refused is not set for an unknown token there. Either the preview is not at this head, or refused is not raised for a bearer on this path. Find which, make the preview return 401 for an unknown token, and show it. The test passes against a harness that may set refused differently from the live auth path, so add a check through the real auth path (or say why the preview differs).

Also: the probe's 403 branch makes an extra authenticated call to /api/v1/user on every refusal. It is fine on the same origin, but state in the README/probe header that the token is sent to that one endpoint only. The 'No door' claim for the terminal is accepted.

commented

The crew's token gets 403 on production because it never reaches the app. The hosting forge's app proxy deletes the authorization header from every request before forwarding it (stripForgeCredentials in src/apps/proxy.ts, #2957). So this is none of the issue's three causes; my earlier finding of (2) was wrong. On the preview, /api/v1/here sees anonymous even for Basic x:forge_nope, and that 401 rule is older than this pull. So the preview is running this pull's latest commit; the 401 just can't be seen through the proxy. The /api/v1/user 401 I saw on production is explained the same way.

Changes

  • src/http/api/keeper.ts: a credential that reaches the forge and matches no account now gets 401 invalid_token, the same as /api/v1/here. Read-only members and anonymous still get 403 with the same words as before. test/keeper-writer-reads.test.ts checks this against the real server (serve(app) with its real auth code); it isn't a harness that sets refused by hand. A request through the proxy can't show it, because the header is deleted first.
  • scripts/v1-probe.ts words a keeper refusal by cause, using /api/v1/here with the same token:
    • 401: "token not accepted here".
    • you: anonymous: "the token did not reach <origin>: a proxy in front strips the authorization header".
    • Anything else: an account that may not read the release history.
    • The header comment now says the token goes to <base-url> only, and only to /api/v1/keeper and, on a 403, /api/v1/here.
  • Tests:
    • test/v1-probe.test.ts covers all three causes, plus a release that still answers an unknown token 403.
    • test/keeper-writer-reads.test.ts sends a writer's token through the real stripForgeCredentials and shows it arrives as no one (403). That is what production does.

Not done I didn't change the proxy. Letting authorization through to apps changes what every hosted app receives, and that's a person's decision. I opened #15523 for it and made #15520 wait on it. Until it's decided, the keeper line can't print PASS or FAIL from the crew's shell. Today it prints UNKNOWN with the true cause:

UNKNOWN keeper's last beat: https://lab--forge-trevato-apps.open-platform.sh/api/v1/keeper - 403, the token did not reach https://lab--forge-trevato-apps.open-platform.sh: a proxy in front strips the authorization header, so this forge saw no one

Checks

  • bun x tsc --noEmit is clean.
  • scripts/gate.ts --fix rewrapped comments in 3 files; that's committed.
  • The keeper and probe test files pass (31 tests).
  • I didn't use scripts/fast.ts; it names too many files for this change.

Try it

  • bun scripts/v1-probe.ts https://lab--15521--forge-trevato-apps.open-platform.sh with FORGE_TOKEN set prints the line above for the preview.
  • The 401 shows only when you reach the app directly, without the proxy: bun test test/keeper-writer-reads.test.ts.

🤖 Generated with Claude Code

Approved

The cause is now named correctly: the hosting forge app proxy strips authorization before the app (stripForgeCredentials). A test shows a writer token arriving as no one. A credential that does reach the forge and matches no account now gets 401 invalid_token, with a test. The probe words a keeper refusal by cause (401, anonymous because of a proxy, or an account without the right). It sends the token only to the same origin, on /api/v1/keeper and /api/v1/here, and the header comment says so. The account name is sanitised before it is printed. No new dependency, no secret, no new mutation. The terminal signs in by SSH key, so there is no bearer path to mirror. I could not diff against my earlier head (14e5f26269de is not in the clone), so I read the whole current diff. Nothing in it is blocking. The final box needs a person: #15523 decides whether the proxy passes the header. Non-blocking: the 403 branch costs one extra request to /api/v1/here, which is fine for a probe.

commented

Left #15520 open: 1 unticked item remain (after it is live, the probe's keeper line prints PASS or FAIL from the crew's shell — do not close until it does).

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs