Repository navigation
feat(atlas): audit the embed hosts the captcha challenge refuses - #1106
Conversation
`scripts/audit-challenge-parents.ts` reads every service's stored `embedMetadata` and prints each inline mount whose origin `GET /api/atlas/challenge` would refuse. It judges with the endpoint's own `allowedParentHosts` and `isParentAllowed`, against the one global allowlist, with no date window, and flags disabled services. Against production on 2026-11-10, 1 of 47 stored inline mounts is refused: `http://lane.test/`, a test run's mount on the local test key. Part of #1077. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Extract the challenge's allowlist into `challengeParentAllowlist` (src/endpoints/atlas/challenge/allowlist.ts). The endpoint and the audit now share every input to the gate, not just its matcher, so a change to who counts as active reaches both. - The audit loads `.env` before reading anything, and skips `onInit`, so a local run works and a boot cancels no stale jobs. - Judge a disabled service as if re-enabled, so its rows name embeds that would still break. - One `inlineMounts` rule feeds both the rows and the totals; rows carry the client instead of copying its fields. - Trim the spec to the audit's own behaviour, and the scripts/AGENTS.md row. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Per /code-review: - Connect with the schema push and `prodMigrations` switched off, so a run against production writes nothing whatever NODE_ENV says. Checked against an empty database in both modes: no table created. - Judge every stored mount. The widget sends its own document's origin as the challenge's parent in a frame too, so an iframe mount off sahajatlas.com is refused on the same grounds. - Exit once stdout has flushed, rather than cutting a piped report or hanging on the boot's open handles. - Count hosts as the gate does (`normalizeHost`), list mounts once, and drop a comment that claimed `serverEnv` parses on import. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…gacy id The runbook step names the one known refused row, says how to run the audit, and carries #1077's WordPress registration check to the cutover. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🚅 Deployed to the SahajCloud-pr-1106 environment in sahajcloud
1 service not affected by this PR
|
|
@sydevs-bot review |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The diff matches #1077's size: the one script and spec it asked for, plus two pieces it forces. Both earn their place. challengeParentAllowlist cannot join challengeRequest.ts, which stays Payload-free so tests/unit/atlas-challenge.spec.ts can cover it. The pure half follows two documented precedents in scripts/AGENTS.md. The endpoint extract is behaviour-preserving: same query, same mapping, same try.
Two acceptance criteria are unmet and the body says so — one refused mount remains, and the WordPress registration moves to the runbook. Both are the owner's call, disclosed.
The one claim I would not ship unasserted is the read-only boot. It is the whole safety story for a production run.
Findings
- should-fix —
audit-challenge-parents.ts:37: the read-only guarantee rests on two untyped writes, with no gate. - consider —
challenge-parents.ts:59: a disabled service's domain is lent per row, so one row names the wrong fix. - consider —
challenge-parents.ts:2: the pure half's name says nothing its sibling's does not.
What was checked
- Read whole: both scripts,
allowlist.ts,challenge/index.ts,challengeRequest.ts,site.ts,embedMetadata.ts,report.ts,env/server.ts, the spec. - Consumer side followed. Judging
iframemounts is right, against the ticket's "inline alone": SahajAtlasWeb'suse-turnstile.ts:133andlib/mount.tsboth readwindow.location, so the mount key's origin is theparentthe gate sees.report.ts:148refuses any other host. serverEnvin a script is harmless: the proxy validates lazily.- Contract files untouched, and no guide enumerates the challenge endpoint's modules, so the new file leaves no stale doc.
- Not re-run: the empty-database boot. Taken from the body's measurement. No preview opened — "nothing to open" holds.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
Both flags were written through a cast that made them optional, so a Payload rename would have compiled and left the script applying `prodMigrations` against production. The keys are now asserted present before they are written. Reading a key back after setting it was the other option, and it proves nothing: a plain data property returns whatever was just assigned, on a renamed key as much as on the right one. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZUpPe91FYd9wpXMPZ
A disabled service's domain is lent back for its own mounts only, so another service's mount on that host is still reported — correctly, since the live gate refuses it — but the row read "give this service a domain" when enabling the owner is the fix. Lending every disabled domain globally was the alternative. It would drop exactly those mounts from the report, which is the breakage the audit exists to find, so the row carries the owner instead. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZUpPe91FYd9wpXMPZ
Its exports speak mounts, and the old name was the script's own minus `audit-`, so neither file said which half was pure. `signin-token.ts` beside `signin-link.ts` and `railway-preview-status.ts` beside `get-railway-preview-url.ts` are the precedents, and both name the spec after the pure half too. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZUpPe91FYd9wpXMPZ
Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZUpPe91FYd9wpXMPZ
Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZUpPe91FYd9wpXMPZ
|
Addressed all three review threads. Pushed to
Lean gate green, 255 files and 3457 tests. Security review skipped: no changed path matches the trigger. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
#1108 renamed Clients.name to label; #1106 landed after it with two new scripts still reading name. The two touch different files, so GitHub merged #1106 without a conflict and main has not typechecked since: tsc --noEmit on e543e6a reports the same three errors this branch inherited on merging it. Both scripts are operator audits printing an internal identifier, so label is the right half of the split rather than the public title. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjWo4RQkAJtqPe72vrB
Five conflicts, all Markdown, and four of them one fact: both sides recounted the unit lane. The merged tree is measured rather than added up — 261 files and 3510 tests, which `perf-figures-pinned.spec.ts` pins to what is on disk. `tests/PERF.md` takes this run as its forty-sixth row; `AGENTS.md`, `docs/rules/testing-reqs.md` and `tests/AGENTS.md` quote the same pair. The fifth is `scripts/AGENTS.md`'s table, where each side added rows: `lib/cloudflare.ts`, `preview-domain.ts` and `preview-domain-plan.ts` from this branch, `audit-challenge-parents.ts` and `challenge-mounts.ts` from #1106, each kept at its own placement. One shared row differs in substance — `get-railway-preview-url.ts`, which this branch rewrote to wait for the head commit rather than for `/api/health` — and that is this branch's, untouched on `main`. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZTnsrufohceG18CSK
…udit `main` does not typecheck. #1106 added `audit-challenge-parents.ts` and `challenge-mounts.ts` reading `Client.name`; #1108 split that field into a required internal `label` and an optional public `title`. Each was green against its own base, and #1106 merged second, so `tsc` fails on `main` itself at three sites — not at any conflict between the two branches. Merging `main` brought the break here, which is why it is fixed here. `label` is the field the split kept for operator-facing output: required, never shown to the public, and what manager-facing mail already uses. `title` is optional and would print nothing for most services. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZTnsrufohceG18CSK
#1106's audit picks `Client['name']`, which #1108 had already renamed to `label` — it branched before that rename and merged after it, so `main` itself does not typecheck. Nothing caught it: neither lint nor Vitest runs `tsc`, and CI's test step does not either, so the Railway build is the first place it fails. The audit prints the service's internal name, which is what `label` holds. Found by the lean gate on this merge, and fixed here because that gate is what the merge had to pass. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZ93GJSxZ1zH4BGeHT
#1106's challenge audit selects and prints `Client.name`, which #1108 renamed to `label` in the same release. Both merged, so `main` itself fails `pnpm typecheck` — nothing in either PR's own gate crossed the other, and the type error reaches no test lane. `label` is the internal name, which is what this operator audit wants: every row it prints names a service for somebody to go and configure. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXtaL1Gdc9Fuxxn6Sz
…er-contacts Three conflicts, all one fact: the unit lane's file and test counts, in docs/rules/testing-reqs.md, tests/AGENTS.md and tests/PERF.md. main's #1106 and this branch each added one spec file and bumped the counts, so neither side's number describes the merged tree. Measured instead: 256 files, 3468 tests. AGENTS.md states the file count too and merged clean at the stale 255, so it is corrected here — tests/unit/perf-figures-pinned.spec.ts pins all four against the tree. Everything else merged clean, and main added no migration, so the chain and its snapshot stand as the seventh merge left them. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXy3iaPMgPWWDuicC8
#1108 split the clients `name` field into `label` and `title`, and #1106 landed afterwards still reading `name`. Each was green on its own branch, so main carries a tsc failure neither PR could see: `name` is not a key of Client. The audit is operator-facing, so it takes `label`, the internal name, not `title`, which is the name registrants see. This is main's break, not this branch's, and it reddens this PR's gate and CI all the same. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXy3iaPMgPWWDuicC8
…#1047) (#1105) * fix(access): lock every Managers field read to the row's holder or an admin Ports the first half of #1045 (commits 1f5c3fb..4e71879) onto main, without its region widening or its activity-log address projection. `atlas-region-manager` holds a collection-wide `managers: read` so the `Events.manager` and `Regions.managers` pickers can list other managers (#821). Nothing narrowed it, so every region manager read every manager's email, contact methods, notification preferences and imported legacy row. - `lockManagerFieldReads` gives every field but `name` a self-or-admin `read` lock. `email` and `_verified` are redeclared at the top level so the lock has a base field to merge onto, keeping Payload's i18n labels. - `loginPlugin`'s three machine columns carry the same lock. - `stripLockedFieldsOnSelfRead` stands down off the caller's own row, so an internal `overrideAccess` read of a colleague keeps its fields. - `UserSubmissions.previewEvent` selects only the assigned manager's name. Refs #908 Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(managers): record when a manager last signed in Nothing recorded it: `sessions` loses its row on sign-out and prunes expired ones, and `updatedAt` moves on every write, the digest job's included. The manager contacts table needs it to tell an active colleague from one who never accepted. - `loginPlugin` appends `lastLoginAt`, read-only and `update: () => false`, with its own self-or-admin read lock like the other appended columns. - `createSession`, the one place a session is minted, stamps it in the same write as the session row. - The migration adds the column and fills it from `legacyData.lastLoginAt`, which the Atlas import kept for 448 of 516 managers. A hand edit, asked for on this PR, on the #1087 precedent: a projection of the same row. - The Atlas import maps it from now on, keeping the later of the stored and the legacy date, so an `--update` never rewinds a real sign-in. Refs #908 Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(atlas): show a region's and an event's managers to the managers above With every field but `name` locked on another manager's row, a region manager had no way to reach the people their region names. The details come back the way an event's registrants do: through a surface that checks its own gate and then reads past the locks, rather than a field lock widened per reader. - `mayReadManagerContacts` is the gate: an admin, the event's own manager, or an active manager whose owned subtree holds the region. That is a region's co-managers and the managers of every region above it, downward only. - `managerContactsField` puts one shared table under `Regions.managers` and `Events.manager`: Payload's condensed `Table` with the name, a `mailto:` email and the last sign-in. It reads the stored row by id, never the form data, and for an event the published row. - `Events.activityLog` reads behind the same gate (`eventContactsFieldAccess`, through a new `read` option on `logField`), since its reminder entries record where each one went. With no row in hand it answers for admins only. - `previewEvent` loads its target without the log: a proposal reaches the managers of the region it proposes, who need not be the event's. - Region-manager reminders already carry the event manager's email. A case now pins it against the new locks. Refs #908, #1047 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(seeds): keep firstDomain's doc block on firstDomain `laterDate` landed between the block and the function it documents, so a reader got the legacy-domain explanation above a date comparison. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVvfniXDQu4ThbSqXV * fix(admin): declare the contacts row type beside its loader `import type` is erased, so the client table taking the row type from `data.ts` pulls no server module into the browser bundle — the shape `EventRegistrations` already has, where `RegistrationRow` is declared in its own `data.ts`. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVvfniXDQu4ThbSqXV * refactor(atlas): render the manager contacts table under the field description The table is now the `Description` of `Regions.managers` and `Events.manager` rather than a `ui` field of its own: it renders the field's own description, then the table, as `PermissionsTable` sits under `Managers.roles`. Both fields also declare an empty `afterInput`, because Payload otherwise renders a `Description` once and keeps it through a save, and the table would go on listing the managers the page loaded with. The last sign-in is one line, `2026/11/10 - 3 weeks ago`, in three states: normal, red past six months, and a muted "Never". Refs #908 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(admin): spell the contacts table's sign-in day with formatShortDate The table's own helper gave `2026/11/10`, under a reason — one unambiguous spelling in every locale — that the module's existing `formatShortDate` already satisfies. It also spells a UTC day, returns `''` for an unparseable value, and is what the Registrations table beside this one shows a date with, so both tables now read the same. The spec spells the expected day out rather than calling the formatter, so the day the table shows stays pinned against it. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZ3Mx2LJUWEV8VFdtU * fix(admin): take the contacts component's props from Payload's own types `path` arrives through `renderField`'s `clientProps`, which Payload types as `FieldPaths`, so `Pick<FieldPaths, 'path'>` says what `{ path?: string }` was restating — and it is always set, so the `''` fallback is gone with it. `admin.description` needed no structural cast either, only a narrower field type: `ServerComponentProps['field']` is the whole `Field` union, whose `row` and `tabs` members omit `description`, while both registrations are on a relationship picker. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZ3Mx2LJUWEV8VFdtU * fix(admin): put the contacts table in Payload's afterInput slot `RelationshipInput` renders `AfterInput` and then the `Description` slot, so the table reaches the same place from the slot Payload already provides for it — and a `beforeInput`/`afterInput` key is what `renderField` tests to re-render a field's components on every form-state request, so the save-follows behaviour now comes from the registration itself rather than from an empty array beside a `Description` override. That override existed only to put the table below the description. Paying for it were four pieces: re-rendering `FieldDescription` by hand, the `path` prop it needs, the `RelationshipField` narrowing for `admin.description`, and the empty-array trap with a ⚠ on each field and in the component. The table now sits above the description instead. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjYYtgW8B9ehUL2Ek4h * docs(access): cut what the field-lock JSDoc already carries Three ⚠ blocks restated, near-verbatim, the JSDoc on `selfOrAdminFieldAccess` and `stripLockedFieldsOnSelfRead` — and this file loads whenever either is edited, so every reader paid for both copies. Each keeps its rule, its #NNN breadcrumb and the one line a reader cannot re-derive, and hands the mechanism back to the JSDoc beside the code that implements it. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjYYtgW8B9ehUL2Ek4h * fix(admin): drop the contacts table's unreachable name fallback `Managers.name` is `required: true`, so `name || email` never took its second arm — and had it ever fired, the Name column would have printed an email. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjYYtgW8B9ehUL2Ek4h * chore(migrations): snapshot resync after the seventh main merge main's 20261110_234836_clients_label_title snapshot was generated on main, so it knows nothing of the last_login_at column this branch adds — and its timestamp is the higher of the two. migrate:create diffed against it and re-emitted ALTER TABLE "managers" ADD COLUMN "last_login_at", which 20261110_220603_manager_last_login already ships. Replaying one statement aborts the boot migration (#566). So the generated file keeps only its .json snapshot, taken on the merged tree, which carries both sides and heals the chain. A probe run afterwards writes no files. CI cannot see any of this: push: !isProduction syncs the schema with Drizzle push and never replays the chain. Only a Railway boot does. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjUvzMXoQtMoVVQaYYp * fix(clients): read the audit's service name from label, not name #1108 split the clients `name` field into `label` and `title`, and #1106 landed afterwards still reading `name`. Each was green on its own branch, so main carries a tsc failure neither PR could see: `name` is not a key of Client. The audit is operator-facing, so it takes `label`, the internal name, not `title`, which is the name registrants see. This is main's break, not this branch's, and it reddens this PR's gate and CI all the same. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXy3iaPMgPWWDuicC8 * refactor(access): trim the manager contact locks to what they need The new comments were 44% of the PR's added source; cut to the why, keeping every warning. The unit sweep over the Managers field locks repeated the integration sweep, which reads the booted config and so already sees the login plugin's columns and the base auth fields: the integration spec now carries the non-vacuity check, and the unit spec keeps the `selfOrAdminFieldAccess` cases. `stripLockedFieldsOnSelfRead` drops its unselected-field skip, a shortcut that saved nothing once the hook ran on the caller's own row alone. `MANAGER_PUBLIC_FIELDS` is no longer exported. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(admin): put the contacts table back under the field description f0f14eb moved the table into `afterInput`, which `Relationship/Input` renders above the description. Under the description is where the owner asked for it, as `roles` sits on Managers, so both fields register the component as their `Description` again, with the empty `afterInput` that re-renders it after a save. The component's docblock now says why the slot is `Description`, so the next review can see the placement was chosen. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
GET /api/atlas/challengerefuses.lane.testtest row.challengeParentAllowlist, so the audit shares it.Change outline
Flow — the gate and its audit share one allowlist
The endpoint's allowlist query moves into its own module. The audit then calls the same function and the same matcher, so it cannot judge against inputs the gate no longer uses.
Preview
Nothing to open on the preview: the change is an operator script, a behaviour-preserving extract inside the challenge endpoint, and docs.
Test results
check.sh— lint, format, typecheck, typecheck:tests, unit (255 files, 3457 tests)challenge-mounts.spec.ts8 passed;atlas-challenge.int.spec.ts9 passedManual verification
railway run --service SahajCloud -- env DATABASE_URL=<Postgres DATABASE_PUBLIC_URL> pnpm tsx scripts/audit-challenge-parents.tsprints one row,http://lane.test/on "Sahaj Atlas (Local Test Key)", and exits.Notes for reviewer
seeds/atlas/AGENTS.md): no WordPress site reports the new widget yet.lane.testrow stays in production by choice; the runbook names it as expected.parentin a frame too.src/endpoints/atlas/challenge/index.tschanged: the read moved verbatim and stays inside the endpoint'stry(503 on failure).lane.testrow would fail every run, and a person reads the check.serverEnvin a script: bootingpayload.configalready validates the same environment.challengeParentAllowlistitself, and the int spec covers that function through the endpoint.clientsqueries: the second is the gate's own, which is the point.sanitizeEmbedMetadataon read, a shared script loader,readonlyonisHostAllowed: other readers cast too, it's outside this diff, and the gain isn't measurable.Detail
clients/38) reports the new widget among the partner services, and it passes. The other mounts are first-party, Workers previews and loopback test keys.meditatenow.online,www.meditaceonline.cz,www.meditaciononline.sahajayoga.com.ar. No service hassite.page, soVerifyEmbedschecks none of them.clients/43"Yoga Essonne" already carrieslegacyId: -32, soCLIENT_SPLITSreconciles it. The import writessite.domainon create only, so an Install-tab fix survives a re-sync.*.pages.dev.normalizeCanonicalDomain('*.pages.dev')returnsnull, sositeDomainValidaterefuses it.NODE_ENV=developmentand underproduction: no table was created either way.push,prodMigrationsandconnectare own properties of the adapter on a real boot, which is what the script now asserts before writing them — a read-back would pass on a renamed key, since all three are plain data properties. The first production run, before this fix, booted withNODE_ENV=productionfrom a checkout with no migration production lacked.payload_migrationsshows nothing applied.Closes #1077
🤖 Generated with Claude Code