Skip to content

docs(ax): entry 42 — the dispatcher picks a shape, not just an identity - #1212

Open
lilyshen0722 wants to merge 1 commit into
mainfrom
docs/ax42-shape-divergence-downstream
Open

docs(ax): entry 42 — the dispatcher picks a shape, not just an identity#1212
lilyshen0722 wants to merge 1 commit into
mainfrom
docs/ax42-shape-divergence-downstream

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

@sprint-review's amendment to entry 42, plus the census it prompted.

Entry 42 documented the /api/v1/tasks dispatcher choosing between req.user and req.agentUser. Their addition is that the same divergence runs one level down, inside middleware/auth.ts itself — a second dispatcher, on a second prefix, whose two branches both assign req.user, with different shapes:

:51  req.user = { id, username, email, role }   // cm_ API token
:81  req.user = { id }                          // browser JWT

So a consumer reading req.user.username works on one path and is undefined on the other, with no error either way. Their framing — "the entry names the cause; #1124 shipping inert and the term #1127 replaced are what it produced" — is the amendment.

I censused the wide-field consumers on main before writing it down, and two are still unguarded: registry/publish.ts persisted publisher.name: undefined for every browser-session publish (fixed in #1211), and github.ts:146 answers 403 Admin only to a real admin because no browser session carries role (reported on #809, whose hunk contains that line). agentProfile.ts:249 already carries a comment calling this "the third application" of the #1065 lesson — these are the fourth and fifth.

The generalization added at the end is the part worth keeping: a dispatcher that picks an identity is easy to reason about, because you can ask which identity you are. One that picks a shape is not, because the failure is a field that is merely absent, and absence is the one thing neither branch reports.

Placement

Inserted mid-entry, after the "different request shapes" paragraph, rather than at the end of entry 42 — which is the file's last line and the anchor seven open PRs all append at. Verified: clean against #1122, #1132, #1142, #1143, #1171, #1202, #1204. Positive control — a rival append at that tail anchor produces CONFLICT against #1204 — so the nine-clean result is sensitivity-backed rather than an instrument that never fires.

🤖 Generated with Claude Code

@sprint-review's amendment: `middleware/auth.ts` is a second dispatcher on a
second prefix, and its two branches both assign `req.user` with DIFFERENT
shapes — `{ id, username, email, role }` on the cm_ path (`:51`), `{ id }` on
the browser-JWT path (`:81`). A consumer of the wide fields works on one path
and is silently undefined on the other.

Records the census that followed: #1124 shipping inert and the term #1127
replaced are this mechanism downstream, and two unguarded consumers were still
live on main — `registry/publish.ts` (#1211) and `github.ts:146`.

Inserted mid-entry rather than at the tail: seven open PRs append at the file's
last line, and sharing that anchor is what makes insertions conflict.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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