Skip to content

docs(ax): entry 44 — a dual-auth route degrades to the other identity silently - #1164

Merged
lilyshen0722 merged 1 commit into
mainfrom
docs/ax-42-dual-auth-silent-fallback
Aug 23, 2026
Merged

docs(ax): entry 44 — a dual-auth route degrades to the other identity silently#1164
lilyshen0722 merged 1 commit into
mainfrom
docs/ax-42-dual-auth-silent-fallback

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

AX entry 42, from @sprint-review (57173) on the comment buried in #1127's test — which they judged a better find than the bug it explains, and the third instance that day of a harness manufacturing a shape production never emits.

/api/v1/tasks doesn't mount one auth middleware. It dispatches on the token:

function auth(req: AuthReq, res: Res, next: () => void) {
  const token = ((req.header?.('Authorization') || '').replace('Bearer ', ''));
  if (token.startsWith('cm_agent_')) return agentRuntimeAuth(req, res, next);
  return regularAuth(req, res, next);
}

The branches produce different request shapesagentRuntimeAuth assigns req.agentUser and never req.user; the human path does the reverse — and the fallback is unconditional. Omitting the header doesn't fail, it succeeds as a human, indistinguishably from the response.

So a test can carry "agent" in its name, assert the right thing, go green, and be about the other identity entirely. That is exactly how the first draft of the tests written to cover the agent shape passed while testing the human one — and how two rounds of fixes to agent-identity code shipped with the agent branch never having run.

Filed as agent-experience rather than a testing note because the false model comes from the surface: a route named auth, mounted once, reads as one identity contract, and nothing at the call site says it picks between two request shapes by string prefix.

Companion to reviewer-checklist rule 17 (#1163), which covers the method that missed it.

Numbered 42 per entry 41's caveat — 39 and 40 remain reserved by #1122 and #1132.

Docs-only. Split from #1163 because that PR merged at 1b6d4ae6 moments before this commit was pushed to its branch — AX 41 mechanism 1, by the author who filed it.

🤖 Generated with Claude Code

@sprint-review, on the comment buried in #1127's test: worth more than the
bug it explains, and the third instance today of a harness manufacturing a
shape production never emits.

`/api/v1/tasks` dispatches on the token — `cm_agent_*` routes to
agentRuntimeAuth, anything else to the human path — and the two branches
produce different request shapes. The fallback is unconditional, so omitting
the header does not fail; it silently succeeds as a human. A test can carry
"agent" in its name, assert the right thing, go green, and be about the other
identity entirely. That is how the first draft of the tests written to cover
the agent shape passed while testing the human one.

Filed as an agent-experience defect rather than a testing note because the
false model comes from the surface: a route named `auth`, mounted once, reads
as one identity contract, and nothing at the call site says it picks between
two request shapes by string prefix.

Companion to reviewer-checklist rule 17 in this same PR, which covers the
method that missed it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@lilyshen0722
lilyshen0722 merged commit cde4d8e into main Aug 23, 2026
10 checks passed
@lilyshen0722
lilyshen0722 deleted the docs/ax-42-dual-auth-silent-fallback branch August 23, 2026 05:22
@lilyshen0722 lilyshen0722 changed the title docs(ax): a dual-auth route degrades to the other identity silently docs(ax): entry 44 — a dual-auth route degrades to the other identity silently Aug 23, 2026
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.

1 participant