Skip to content

feat(preview): give the loop a way through a gated PR preview - #242

Merged
Ardnived merged 11 commits into
mainfrom
claude/feat-241-preview-auth
Nov 7, 2026
Merged

Ardnived merged 11 commits into
mainfrom
claude/feat-241-preview-auth

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • The loop can now sign in to a gated preview and fill it, and where a repo's CI reds on a preview it could not fill, a line in the body no longer stands in for data.
  • Joined: docs/why.md claimed a seed script anonymised 495 coordinator identities. No code does — it was a hand seed, and the passage stated the opposite of the parent goal's premise.

Change outline

Nothing here can be tested by running it: a skill edit takes effect on the next session, never this one. So each view below is paired with the failure it prevents, which is the only evidence available before merge.

Contract — what the helper answers, and what reads it

jq -c '{previewUrl} + {pr: 7}' .claude/workflow.json | node workflow/lib/preview-auth.mjs
  → { host, seedsPreviews, access, signIn, seed }

       host          previewUrl.pattern with {pr} filled — https: only, digits only — or null
       seedsPreviews a USABLE previewUrl.seed || .auth   # the one verdict both skills read
       access        { clientId: { envVar, set }, clientSecret: { envVar, set }, headers }
                       envVar from loop-config.json → previewAccess
                       set only — never a value
                       headers are shell references: "CF-Access-Client-Id: $VAR"
                       and empty unless BOTH are set AND the target is gated
       signIn        { method, url, body, tokenField } from previewUrl.auth, else null
                       url is joined, then its origin is compared against host's
       seed          previewUrl.seed, else null

… | node workflow/lib/preview-auth.mjs --on-host <link>
  → ON_HOST | OFF_HOST     one link's origin against host's. The check a caller makes
                           before it attaches the pair to a link read out of a PR body

⚠ It decides and never fetches. workflow/lib/railway.mjs is the precedent and states the reason: a routine cannot reach an API from a script, so a helper that fetched would run only on a maintainer's laptop — a second implementation of a rule the cloud path executes another way, which is the shape of this loop's worst bug to date.

The failure this prevents: review-pr reads no repo config at all today. Without one answer in one place, each skill would re-derive "does this repo seed previews" on every dispatch of its handler — 25 to 40 times a day, forever — and the two are then free to derive it differently.

Behaviour — when a body line stops being enough

 review-pr, gathering context                        workflow/skills/review-pr/SKILL.md
   open each ## Preview link
+    --on-host first: ON_HOST → send the headers
+                     OFF_HOST → no header, and a should-fix of its own
     a link that shows no data…
       …with no line in the body saying why    → should-fix
-      …with a line saying why                → accepted
+      …with a line saying why
+        seedsPreviews false (four repos)      → accepted, unchanged
+        seedsPreviews true                    → should-fix: the red check is the gate

 finalize-pr step 7, Every link opens on data        workflow/skills/finalize-pr/SKILL.md
+  ask preview-auth.mjs first
+  with a signIn → send it with the plan's headers, read its tokenField
+    to an ON_HOST link only
   run previewUrl.seed
   on timeout → write `Data: not seeded yet`
+    seedsPreviews true → say the seed check reds the PR where a preview was discovered

⚠ Conditional, never a removal. That text is correct for the other four repos, which have no seeding check and no gate — there the line is still the only honest thing to write.

The failure this prevents has already happened twice. sydevs/SahajCloud#1073 shipped its Registrations page with Data: not seeded and a console snippet to paste, and that read as compliance to every check including the adversarial review. sydevs/SahajCloud#874 linked three pages nobody saw anything on; filling that preview by hand afterwards found three defects in a minute.

Files

workflow/lib/preview-auth.mjs        the helper. node: stdlib only, no dependency
workflow/lib/preview-auth.test.mjs   its sibling — the ONLY thing that gates it:
                                     leanGate runs `node --test workflow/lib/*.test.mjs`,
                                     and eight scripts there have no test sibling today
workflow/lib/budget.test.mjs         its verdict-word scan now reads the union of the
                                     lists each script exports, not budget.mjs's alone
loop-config.json → previewAccess     the two token env-var names. Values here, rule in the
                                     script, story in docs/why.md — three homes, no overlap
docs/why.md                          two new anchors, each beside the rule it extends
docs/routine-setup.md                a row in the secrets table (github-ci), §4's
                                     environment block (claude-loop), and the Access
                                     application steps that make §4's promise true

What review changed

Three review passes found fourteen things. The ones worth the reviewer's attention here, because each was wrong in an earlier push:

Was Prevents
"Send each link with the plan's access.headers" — with no check that the link is on the host The Access service token going to whatever host a PR body names. review-pr reads the ## Preview links out of the body under review, and dispatcher/decide.mjs fires it on a PR no member authored as soon as a respondTo login types the review verb. So anyone able to open a PR could name their own host and collect the pair from their logs. onHost answers per link, and an OFF_HOST link is now a should-fix of its own
headers: [] read as "no service token", in both skills A should-fix silenced on a repo carrying seed alone, and step 7 writing "unreachable" instead of checking data in all four repos that declare no .auth — authPlan empties headers whenever signIn is null, so the sentence matched both
A sign-in route was concatenated onto the host unchecked, so @evil.example/x moved the origin — with the Access token attached The service token going to someone else's origin. The origin is now compared after the join; https: and digit-only {pr} are checked for the same reason
headers was built from the variable names, so an environment with no token still got two headers that expand to empty A failed service-token attempt reading to the run as a working credential. SahajCloud's accessTokenHeaders already answered this the same way — two answers were one too many
The pair rode with every request, gated or not Sending it to an ordinary host, including a preview host a repo has since moved — a name anyone may claim
seedsPreviews was true for any truthy auth, {} included A should-fix on every empty preview in a repo where no run can sign in or seed: a finding no author can comply with
finalize-pr promised the seed check "will red this PR" A report naming a red check that will not happen — SahajCloud reds only where a preview was discovered
finalize-pr said the example's hosts "became unreachable the day #1081 shut Railway's address" A false sentence in the next run's context. #1081 is open, and the raw host redirects rather than going dark. The reason the hosts are gone is timeless, so it is stated that way
review-pr was told to call the helper, but not where previewUrl lives, nor to use the CLAUDE_PLUGIN_ROOT path, nor to attach the headers A skill whose new instruction cannot execute: previewUrl is in no config that skill opens, a relative path resolves to nothing from a product repo, and an unauthenticated request to a gated preview answers with the login screen and reads as empty — the critic would file its own missing credential as a finding
review-pr carried no Never print the token rule, while finalize-pr did The pair in a public What was checked section. The script never holds a value, but the shell that sends the request expands one
Hard rules still carried the unconditional form of the rule this PR makes conditional The #148 shape: four statements of one rule, the fourth disagreeing, in the section a run under pressure re-reads
The suite passed 7 of 7 mutations, and grepped for fetch( alone A module importing node:https passing the assertion that the whole script layer rests on. It now pins the import list; 11 mutations were watched failing
accountsPage Nothing. The seed route takes only an admin manager, so a run picking another account could not then seed — the field widened what the credential was used for and added no capability. Dropped
CF_ACCESS_* documented as an org secret with --visibility all Handing one repo's previews to every workflow in five. Now a repo secret on SahajCloud

And one finding dismissed. The security pass read auth.account as publishing SahajCloud's PREVIEW_ADMIN_EMAIL into a public file, on the strength of previewAdmin's "the address is the credential there". That premise is what the sibling PR retires: sydevs/SahajCloud#1082 makes the address a committed constant and signs any manager in, because Cloudflare Access is the gate now. It read main, not the branch. The derived ask does hold, so the config table row now says account must be an address the gate does not treat as the credential.

Test results

  • Lean gate: ✓ claude plugin validate ./workflow --strict and node --test workflow/lib/*.test.mjs (119 tests), run from the checkout and from a .claude/worktrees/<slug> worktree — which is where implement-ticket runs it, and where a cwd-relative config read would have failed
  • 11 mutations of the helper's plan, each watched failing the suite: a node:https import, both field-name overrides ignored, replaceAll→replace, the pr guard broken on 0, one trailing slash, headers on a name alone, headers on an ungated host, seedsPreviews on any auth, the route not origin-checked, the https: check dropped
  • 4 further mutations of onHost, each watched failing: the https: guard dropped, endsWith for origin equality, hostname for origin, and always allowing. A fifth — dropping the null-host guard — survives and is behaviour-preserving: the try/catch already answers false. One more on budget.test.mjs's scan: dropping OFF_HOST from the exported list fails it
  • --on-host by hand against a gated fixture: the preview's own path ON_HOST; an attacker host, a host + ".evil.example" suffix, http:, a port, and another PR's preview all OFF_HOST
  • node workflow/lib/rule-delta.mjs --base origin/main workflow/skills: directives 90 → 92, unmoved by the two review passes since. Three added — Never spell one here, Never print the token, Never seed real people's contact details, and never quote data the preview already held. One removal to adjudicate: Never seed real people's contact details. was not dropped — the third addition contains it verbatim and extends it
  • python3 workflow/lib/ste-lint.py on both edited skills: the same hard-violation count as the base (4 and 2), no new one. One reword was needed to hold that — gets no header put get beside the file's existing fetch
  • node workflow/lib/comment-lint.mjs --base origin/main: no banned comment added
  • git diff origin/main -- loop-config.json touches only the new previewAccess block; nothing under ceilings
  • Build / CI: N/A — this repo has no CI (loop-config.json → ci.noCi), so review is the only gate

Manual verification

  1. grep -rn 'cloud-preview.sydevelopers.com\|sahajcloud-sahajcloud-pr' workflow/ docs/ loop-config.json returns nothing. The example Preview block in finalize-pr used to name a real SahajCloud host; it now writes <host>, because a host spelled here goes stale the day that repo moves it.
  2. grep -rn 'preview\.invalid' docs/ returns only the corrected sentence, which names it as a one-off hand seed.
  3. echo '{"previewUrl":{"pattern":"https://x-pr-{pr}.invalid"},"pr":7}' | node workflow/lib/preview-auth.mjs exits 0 and reports seedsPreviews: false, signIn: null, and access.headers: [].
  4. The same input with --on-host https://x-pr-7.invalid/x answers ON_HOST, and with any other origin OFF_HOST.
  5. Read the two skill edits and confirm each still reads as an instruction with its (why: …) citation removed.

Notes for reviewer

This is child 2 of 2, and it merges second. sydevs/SahajCloud#1081 builds the gate, the picker and the fixture; this gives the loop its way through. It is blocked by that one: the helper has nothing to sign in to, and the conditional text has no red check to be conditional on, until sydevs/SahajCloud#1082 merges. It provides nothing back.

Both halves of the switch are config, and this PR is only one half. After this merges, seedsPreviews is still false in all five repos and both new skill branches are unreachable — no repo carries previewUrl.auth or .seed yet. What activates it is a person adding that block to SahajCloud's .claude/workflow.json, a Protected Path, listed in #1081's notes. Until then the two new environment variables are read by nothing. docs/routine-setup.md now says so, because a credential nothing reads is a credential nobody audits.

The credential leak the third pass found was armed by the same config, not by this merge. headers is empty while no repo declares previewUrl.auth, so nothing could have been sent anywhere yet. It would have armed the moment someone completed docs/routine-setup.md §4 — which is this PR's own instruction — so it is fixed here rather than filed.

Merging to main here IS the deploy. The cloud routines read these skills fresh from main on every run, so a merge reaches them on their next run and there is no rollback but another PR. Eleven commits, one per behaviour, each separately revertable:

Commit Behaviour
feat(lib) the helper, its test, and the two config values
feat(finalize-pr) previewUrl.auth's meaning, and the example host
fix(review-pr) the conditional text, and the docs/why.md anchor
docs(routine-setup) both Access tokens written down
chore(plugin) 5.3.0 → 5.4.0
fix(why) the 874 anonymisation correction
fix(lib) the review pass on the helper: origin, scheme, token halves, verdict, tests
fix(skills) the review pass on the prose: three false claims, two unexecutable instructions, two new rules
fix(review-pr) the critic's thread: the unreachable preview keys on a signIn, not on empty headers
fix(finalize-pr) the same, and the condition named as access.clientId.set / .clientSecret.set
fix(preview) the security pass: the Access pair goes only to the plan's own host

A running cost, stated. finalize-pr grows 1.9 KB and review-pr 1.2 KB over main, and both are read on every dispatch. Each addition prevents a named failure above, and finalize-pr step 7b now points at the step-7 bullet rather than restating it, which paid some of it back. The third pass added 0.2 KB and 0.4 KB of that, for one origin check and one Never print the token.

No ceiling moves, so the skill/ceiling split does not bite. previewAccess adds two env-var names under a new key — a value, not a ceiling — and ceilings is byte-identical to origin/main.

previewUrl.auth's shape is defined here and written there. This PR decides what the key means; a person hand-writes it into SahajCloud's own .claude/workflow.json as { "signInPath": "/api/managers/request-magic-link", "account": "[email protected]" }. That same edit should replace previewUrl.pattern, which still names the Railway host #1082 puts a gate in front of. Nothing here hard-codes the route, the address or the host — they are that repo's config values, and a copy here would be a second definition free to go stale. The test fixture uses a .invalid host for the same reason.

The security review runs, and that is expected: securityReview.triggerPattern matches ^workflow/lib/, ^workflow/skills/.+\.md$ and ^loop-config\.json$, because a skill body is an instruction to an agent holding write access to five repos. It is what found the leak above.

One judgement worth checking. The loop's token variables are named PREVIEW_ACCESS_CLIENT_ID / PREVIEW_ACCESS_CLIENT_SECRET rather than reusing CI's CF_ACCESS_CLIENT_ID / CF_ACCESS_CLIENT_SECRET. They are different tokens in different places, and the distinct names are what make "the loop's, and preview-only" readable at the variable in a cloud environment that has no secret store.

Detail

Why seedsPreviews reads a usable plan rather than key presence. previewUrl.seed predates .auth and a repo may carry one without the other, so the verdict must not require the pair — but it must not fire on an auth block too incomplete to sign in with either, because the finding it drives is one the author cannot act on. Cannot seed still covers an unset .seed.

Why the token is reported per variable. It is a pair, and one half present is a misconfiguration Cloudflare logs as a failed service-token attempt rather than ignoring — so a plan saying only "set" would hide the case that actually goes wrong. access.clientId / .clientSecret are therefore reported even on an ungated host, where headers is empty: a run can then say which half is missing instead of guessing.

Why headers: [] could not carry the "no token" meaning. authPlan returns access: signIn ? access : { ...access, headers: [] }, so an empty list means no gate as often as no credential — and today, with no repo declaring .auth, it always means the former. Both skills now key that sentence on a signIn with a half unset, which is the only shape that means this environment cannot pass a gate.

Why the origin check is a script and not a sentence. The module already compared an origin once, in routeOn, for the one URL it builds. The prose then attached the same headers to URLs the module never saw, which is the same rule evaluated in two places with only one of them hardened. onHost is that comparison, exported, so each skill asks rather than eyeballs — and @evil.example, a trailing-suffix host and a bare port are each a spelling a prose rule would have had to anticipate.

Why two Service Auth policies. One policy on "any service token" turns switching either token off into a deletion of both, and the parent goal asks that the loop's and the checks' tokens be switchable off alone. The ⚠ in docs/routine-setup.md §4 now says so, because the single-policy shape reads like the simpler choice. §4 also now carries the three steps that create the policy, and a verification curl against the live hostname expecting 403 — a service token is account-scoped, so what it opens is decided by that policy and not by the token, and nothing in the loop can detect a pair that opens production.

Why the token must never be printed. The script never holds a value — it reports set only, and the headers are $VAR references. But the shell that sends the request expands them, so -v, --trace-ascii, set -x or a pasted failing command puts the secret in the transcript, and from there into a journal comment on a public repo. fix-ci already states this rule for reading CI logs; its absence from review-pr was an inconsistency, not a new policy.

Nothing here writes under .claude/. The four .claude/workflow.json edits this work depends on land in SahajCloud's copy and are a person's, listed in #1081's notes. So no part of this is handed back for the Protected Paths guard.

Closes #241


🤖 Generated with Claude Code

https://claude.ai/code/session_01Mg9rjW1KpxUngcdTDx7hQ1

`workflow/lib/preview-auth.mjs` turns a repo's own `previewUrl` block and a PR
number into the host, the sign-in request to send, the Access headers to attach
by env-var name, and one verdict both `finalize-pr` and `review-pr` read:
whether this repo seeds previews at all.

It decides and never fetches, like `railway.mjs` beside it — a routine cannot
reach an API from a script, so the session sends the request and this file holds
no credential. Each token variable is reported only as set or unset, and the
headers are shell references, so a plan can be logged.

The two token env-var names go in `loop-config.json` as `previewAccess`, beside
`railway.tokenEnvVar`: a name typed into a skill is a tuning change nobody can
review on its own. `ceilings` is untouched.

The route and the account are the producing repo's, carried in its `.auth`
block, so nothing here knows either and nothing here goes stale when they
change. The test fixture deliberately uses a `.invalid` host for the same
reason: a copy of another repo's config value is a second definition, in a
fixture as much as in a skill.

The failure this prevents: `review-pr` reads no repo config today, so without one
answer in one place each skill would re-derive "does this repo seed previews" on
every dispatch — 25 to 40 times a day — and the two are then free to disagree.

Refs #241

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjX5KDEbK7EeiEzbPvZ
Step 7's *Every link opens on data* now asks the helper first, and signs in with
what it answers where a repo declares `previewUrl.auth`. The configuration table
gains the key beside `.pattern` and `.seed`.

The example Preview block stops naming a real host. The pair it used names
SahajCloud's Railway address, which sydevs/SahajCloud#1081 shuts — so the
example would have told the next reader to write a link that 403s, and a host
spelled in this skill is a copy of a config value either way.

The failure this prevents: a run that holds a preview-only Access token still
had nowhere to read the route, the account or the header names from, so it
would have written `Data: not seeded yet` beside a preview it could have filled.

⚠ No step assumes `previewUrl.seed` is set. SahajCloud's copy carries only
`.pattern` today, and the same hand-edit that adds `.auth` adds `.seed`; the
`Cannot seed` case still covers an unset one.

Refs #241

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjX5KDEbK7EeiEzbPvZ
Two places let a change admit it has no data and pass anyway. Where a repo's own
CI goes red on a preview that exists and could not be filled, the red check is
the gate and a sentence cannot stand in for it.

⚠ **Conditional, never a removal.** That text is correct for the other four
repos, which have no seeding check and no gate — there the line is still the only
honest thing to write. Each edit decides from the helper's verdict, so neither
skill names a number, a label or a repo. `rule-delta.mjs` reports no dropped
rule.

The failure this prevents is the one the written rule has already accepted twice:
sydevs/SahajCloud#1073 shipped its Registrations page with `Data: not seeded` and
a console snippet to paste, and sydevs/SahajCloud#874 linked three pages nobody
saw anything on — filling that one by hand afterwards found three defects in a
minute.

The story goes behind one new `docs/why.md` anchor, beside the rule it extends.
Each edit still reads as an instruction with the citation removed.

Refs #241

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjX5KDEbK7EeiEzbPvZ
They live in two different places, so the doc needs a row in each: the
`github-ci` pair as an org-level GitHub secret, read by SahajCloud CI's seed and
smoke steps, and the `claude-loop` pair as a Claude cloud-environment variable,
read only by `workflow/lib/preview-auth.mjs`.

The ⚠ on "There is no secret store" now says what a preview-only Access token
reaches — every preview of the gated repo, as a service identity whose every use
Cloudflare logs — and what it does not: anything on the live site, whose address
it cannot change.

The failure this prevents is a person setting up the loop with one Service Auth
policy on "any service token", which reads like the simpler choice and makes
switching one token off a deletion of both. Two named policies are what let the
loop's be switched off while CI keeps running, and the other way round.

Nothing here names a stopgap variable: sydevs/SahajCloud#1081 retires it, and
this doc never carried a row for it.

Refs #241

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjX5KDEbK7EeiEzbPvZ
Every skill change in this PR reaches a cloud routine on its next run, and an
installed plugin on no run at all until this string moves:
`installed_plugins.json` records a `gitCommitSha` and never revisits it, and the
cache directory is named after `version`. A skill change without a bump is the
one failure this repo has already paid eight days of stale skills for.

`.claude-plugin/marketplace.json` still parses and still points at `./workflow`.

Refs #241

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjX5KDEbK7EeiEzbPvZ
That passage read as though the seed itself replaced coordinator identities with
`preview.invalid` addresses. It did not: `grep -rn 'preview\.invalid'` over
sydevs/SahajCloud returns zero hits, and nothing writes that address. The
anonymisation was done by hand, once, on one preview.

Left as it was, the passage stated the opposite of the parent goal's whole
premise — that the content system has nothing safe to fill a preview with, since
its only data scripts import real people's names and addresses. A reader who
trusted it would have concluded the problem was already solved.

What makes made-up preview data true in code is the committed fixture
sydevs/SahajCloud#1081 adds, and that is structural rather than tested: the
real-data files left that checkout in sydevs/SahajCloud#1079, so no CI run holds
a real name to leak. It remains no promise about a preview somebody filled by
hand.

Replaced in place, not appended.

Refs #241

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjX5KDEbK7EeiEzbPvZ
…lf a token

Four defects found reviewing the helper, each the kind a prose rule cannot
hold and a script can.

A sign-in route came from config and was concatenated onto the host with no
check, so `@evil.example/x` or a bare `.evil.example/x` moved the origin while
`finalize-pr` attached the Access service token to the request. The route is
joined, then the composed origin is compared against the host's; anything else
plans no sign-in. For the same reason `{pr}` now takes digits only — the slot
sits inside the hostname — and a pattern must be `https:`, since `http:` would
put the pair on the wire in cleartext and `file:` would read the disk.

`headers` was built from the variable NAMES, so an environment holding no
token still handed the session two headers that expand to empty. Cloudflare
logs a blank client id as a failed service-token attempt, and the run reads two
headers as a working credential. Both halves must now be set. SahajCloud's
`accessTokenHeaders` already answered this question the same way; two answers
were one too many. The pair also rides only with a gated request now: a repo
declaring no `.auth` has no Access in front of it, and a preview host a repo
has since moved is a name anyone may claim.

`seedsPreviews` was true for any truthy `auth`, `{}` included. That verdict
tells `review-pr` to raise a `should-fix` on every empty preview in a repo
where no run can sign in or seed — a finding no author can comply with. It now
reads a usable plan.

`accountsPage` is gone. The seed route accepts only an admin manager, so a run
that picked another account from that page could not then seed, and the field
widened what the credential was used for while adding nothing.

The suite caught none of this: 7 of 7 mutations survived it, the
"opens no connection" assertion grepped for `fetch(` alone and passed a module
importing `node:https`, and neither field-name override was exercised. It now
asserts the import list against an allowlist, and 11 mutations were watched
failing against it.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjX5KDEbK7EeiEzbPvZ
…lse claims

Review found the skill half stated things that are not true and asked for
things a run cannot do.

False, and a false sentence in a skill is in the next run's context: the
example's hosts did not "become unreachable the day #1081 shut Railway's
address" — that ticket is open, and the raw host redirects rather than going
dark. The reason the hosts are gone is timeless, so it is stated that way.
`finalize-pr` promised that a repo's seed check "will red this PR", but
SahajCloud's step reds only where a preview was discovered; with none, CI
warns. `why.md` claimed in the present tense a fixture that an unmerged PR
commits, and named the ticket rather than the PR.

Not executable: `review-pr` was told to call the helper but never where its
input lives — `previewUrl` is not in `loop-config.json`, which is the only
config that skill opens — nor that the path needs the `CLAUDE_PLUGIN_ROOT`
convention, which is why 52 sessions once lost a call each. It also never got
the Access headers, so on a gated repo every preview link answers with the
login screen and reads as empty: the critic would have filed its own missing
credential as a finding. And the new absolute collided with the carve-out two
lines above it, leaving a mid-build 404 ambiguous.

`finalize-pr` asked for a JSON subobject hand-spliced into a single-quoted
shell string while the file was right there, and named no check on the token
before sending. Both are `jq` and one clause. Hard rules still carried the
unconditional form of the rule this PR makes conditional, which is the section
a run under pressure re-reads, and step 7b restated the bullet instead of
pointing at it.

Two rules added rather than corrected. The token must never be printed —
`fix-ci` already says so for the analogous case, and the values reach the
shell even though the script never holds them. And data a preview already held
must never be quoted into a public body: somebody may have filled it by hand
from a real source. `rule-delta` reports that second one as a removal because
it absorbed the shorter "never seed real people's contact details", which it
contains.

The docs now carry the Access application steps, because a service token is
account-scoped and the promise that it "opens nothing on the live site" is kept
by a policy nobody was told to create — with a verification `curl` against the
live hostname expecting 403. The `CF_ACCESS_*` row moves to a repo secret:
`--visibility all` would hand one repo's previews to every workflow in five.
And both docs now say the feature is inert until a repo declares
`previewUrl.auth`, naming its keys, which nothing told the person who must
write that block.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjX5KDEbK7EeiEzbPvZ
@sydevs-bot

sydevs-bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 21:34Z address-review · attempt 1 · session · done
  • 21:34Z address-review · attempt 1 · session
  • 21:27Z review-pr · attempt 1 · session · done
  • 21:27Z review-pr · attempt 1 · session

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 5, 2026

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 Adversarial review

The shape matches #241 part for part: one helper both skills read, the verdict in a script, the names in loop-config.json, the rule made conditional rather than removed. Nothing is smuggled — the joined docs/why.md correction is named in the Summary, ceilings is byte-identical, the version is bumped. The helper earns its file: two skills need the same two answers, railway.mjs is the precedent, and nothing in workflow/lib/ already fills a pattern or joins a route.

One defect, in both skills, from one misreading of the plan. headers: [] is also what a repo with no .auth gets, so "empty headers means no service token" is wrong wherever seedsPreviews is true on seed alone — the branch's own test at preview-auth.test.mjs:141 is that case. access.clientId.set / .clientSecret.set tells the two apart.

Findings

  • should-fix — workflow/skills/review-pr/SKILL.md:98: empty headers read as "no token" silences the should-fix on a seed-only repo.
  • should-fix — workflow/skills/finalize-pr/SKILL.md:286: the same sentence, unscoped. Today's four repos always have empty headers.

What was checked

Read whole: preview-auth.mjs, its test, both skill diffs, the docs/ and loop-config.json diffs, railway.mjs, #241, the reviewer profile. Ladder: one new module, four functions, two values in their one home, no dependency — every import is ./config.mjs or ./payload.mjs, and isMain matches its five siblings. From a worktree: node --test workflow/lib/*.test.mjs, 116 pass; the helper on a seed-only and an auth-only input, which is how headers: [] reproduced twice. The body's greps re-run — no SahajCloud host, no PREVIEW_ADMIN_EMAIL, preview.invalid only in the corrected sentence. No preview link: this repo publishes none. Producer side not read.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread workflow/skills/review-pr/SKILL.md Resolved
Comment thread workflow/skills/finalize-pr/SKILL.md Resolved
@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 5, 2026
@sydevs-bot sydevs-bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 5, 2026
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 5, 2026
@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 5, 2026
sydevs-bot and others added 3 commits November 5, 2026 21:36
…aders

`headers: []` has two causes and the text read only one. `authPlan` empties
it whenever `signIn` is null, so every repo with no `previewUrl.auth` — all
four product repos today — matched the sentence, and so did a repo carrying
`seed` alone. The branch's own test at `workflow/lib/preview-auth.test.mjs:141`
is that case: `seedsPreviews: true`, `signIn: null`, `headers: []`.

Read as written, the rule recorded such a preview unreachable and raised
nothing, cancelling the `should-fix` the next sentence demands. The condition
is now a `signIn` present with either `access` half unset, which is the only
shape that means this environment cannot pass a gate, and empty `headers`
with no `signIn` is named as no gate rather than a missing token.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjW1KpxUngcdTDx7hQ1
…e field

Same misreading as review-pr:98, and unscoped here. `authPlan` returns
`headers: []` whenever `signIn` is null, so all four repos carrying no
`previewUrl.auth` matched this sentence on every preview. Read as written,
step 7 stopped checking data and wrote "unreachable" instead — the exact
failure the step exists to prevent.

The sentence now requires a `signIn`, and names the condition as
`access.clientId.set` / `.clientSecret.set` rather than leaving the run to
infer it from an empty list. Empty `headers` with no `signIn` is stated to
mean no gate, so the data check proceeds as before.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjW1KpxUngcdTDx7hQ1
The security review found a credential leak this PR introduced, and it is the
kind a prose rule cannot hold.

`review-pr` was told to "send each link with the plan's `access.headers`",
where each link is a `## Preview` link read out of the body under review. That
body is not ours. `dispatcher/decide.mjs` fires `review-pr` with `onDemand`
on a PR no member authored as soon as a `respondTo` login types the review
verb, and the skill is told to judge a ticketless PR against its own body. So
anyone able to open a PR could name their own host in a Preview section and
collect the Cloudflare Access service token from their logs — a token that
opens every PR preview of the gated repo.

The branch had already hardened the script against leaving the host: `routeOn`
joins the sign-in route and compares the composed origin. The prose then left
by a different door, because the module validated the one URL it built while
the skill attached the same headers to URLs it never saw.

`onHost` closes it where a rule can be evaluated, and `--on-host <link>`
answers `ON_HOST` or `OFF_HOST` for one link. Both skills now send the pair to
an `ON_HOST` link only, and an `OFF_HOST` link in a body is a `should-fix` of
its own: a body pointing where the repo publishes no preview is one a reviewer
cannot check. `review-pr` also gains the `Never print the token` rule its
`finalize-pr` counterpart already carried, since it publishes a public
What-was-checked section. `railway.mjs` allowlists an outside poster's host for
the same reason.

Four mutations of the check were watched failing the suite: the `https:` guard
dropped, `endsWith` for origin equality, hostname for origin, and always
allowing. A fifth, dropping the null-host guard, is behaviour-preserving — the
try/catch already answers false.

`budget.test.mjs` asserts every verdict word a skill names is one a script can
print, so each script now exports its own list and the test reads their union.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjW1KpxUngcdTDx7hQ1
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Both critic findings held. authPlan empties headers whenever signIn is null, so headers: [] never told a missing token from an ungated host.

Each now keys on a signIn with an access half unset, and names empty headers with no signIn as no gate. Both resolved.

The security review found a leak this PR introduced. "Send each link with the plan's access.headers" sent the Access pair to whatever host a PR body names, and decide.mjs fires review-pr on a stranger's PR on request. d7e1564 adds onHost and --on-host: both skills send to an ON_HOST link only, an OFF_HOST link is a should-fix, and review-pr gains the Never print the token rule.

Nothing rebutted or asked. Base already current. Gate ✓ 119 tests, checkout and worktree. Body refreshed.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 5, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review November 5, 2026 21:54
@sydevs-bot
sydevs-bot requested a review from Ardnived November 5, 2026 21:54
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Ready to review with sydevs/SahajCloud#1081. It merges after sydevs/SahajCloud#1081 does: auto-merge is armed once that closes, after its contract re-sync lands here.

🤖 sydevs dispatcher

@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 5, 2026
@Ardnived
Ardnived merged commit 9bbe264 into main Nov 7, 2026
44 of 47 checks passed
@Ardnived
Ardnived deleted the claude/feat-241-preview-auth branch November 7, 2026 21:46
@sydevs-bot sydevs-bot moved this from Awaiting to Done in SYDevelopers Technical Roadmap Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

feat(loop): sign in to a gated preview, and a red check over a line

3 participants