Skip to content

feat(loop): discover branch preview aliases, compute journal titles - #30

Merged
Ardnived merged 7 commits into
mainfrom
claude/branch-alias-and-journal-title
Sep 2, 2026
Merged

Ardnived merged 7 commits into
mainfrom
claude/branch-alias-and-journal-title

Conversation

@Ardnived

@Ardnived Ardnived commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Two rules that existed only as prose become tools, because both had already failed as instructions.

  • Preview URLs — a new branch-preview-url.mjs reads the branch alias out of the label Cloudflare writes, so a PR body links a host that follows the branch.
  • Journal titles — a new journal-title.mjs prints Wed — 2 new, 1 revised, 2 merged, 1 closed from queries, replacing prose rewritten by the model on every run.

Why the preview rule needed a tool

SahajAtlasWeb#181 was fixed to use branch aliases and then re-broken, the second time with a stated rationale: "these are per-deployment aliases, so they stay pinned to this commit."

That argument is lifted from get-cloudflare-preview-url.mjs, which ranks a commit alias above a branch alias deliberately — it feeds the CI smoke gate, which must test the exact SHA it was handed, and its docblock argues a branch alias "names none." Sound there, and exactly wrong in a PR body, where the reviewer opens the link two pushes later. finalize-pr pointed at that script with a hedge — "when it gives you a branch alias" — that the script can never satisfy.

One tool cannot serve two opposite requirements, so this adds the second tool rather than a firmer instruction.

Discovered, never constructed. Cloudflare labels the alias on both platforms it deploys here:

Platform Markup
Pages (check run + comment) <strong>Branch Preview URL:</strong></td><td><a href='…'>
Workers Builds (comment) <a href='…'>Branch Preview URL</a>

So the documented slug rule is unnecessary — and it was never safe. It is a guess about a host we do not own, and two branches agreeing in their first 28 characters produce one alias that answers 200 while serving the other branch. A wrong link that 404s is a bad Preview section; a wrong link that works is a bad review.

Verified against both platforms:

  • sydevs/SahajAtlasWeb#181 — Pages, two projects, both aliases 200
  • sydevs/WeMeditateWeb#55 — Workers Builds and Pages in one PR, both 200, project names correct

SahajCloud needs none of this: Railway's preview host is per-PR and already stable across pushes.

Why the journal title needed a tool

It was free prose, re-derived nine times a day — each rewrite re-reading the day to re-summarise it, and each one able to describe activity the run only believed happened. Counts come from queries, cost nothing to regenerate, and read the same on the ninth run as the first. The narrative stays in the body, where it has room.

Term Counts
new Issues the bot opened today. Never PRs; journals excluded
revised Work items handed back to the reviewer today
merged PRs the bot authored that merged today
closed Work items closed today without merging

Scoped to the bot's own authorship — the journal is the loop's record, and a headline that absorbed the reviewer's merges would report their afternoon as its own.

Three things testing caught that reasoning did not

  1. Pairing. A work item is an issue and its PR. Paired through closingIssuesReferences, not a body regex — that is the resolution the merge itself uses, it catches sidebar links that leave no text, and it resolves cross-repo references without guessing which repo a bare #12 meant.

  2. updated: is not an activity filter. It matches an item's current updated_at; GitHub has no activity-range qualifier. Gating candidates on assignee:<reviewer> therefore dropped every item since reassigned — a PR handed back at 09:00 and picked up at 11:00 vanished, so the 13:00 run's title counted one fewer revision than the 09:00 run's. A title that falls through the day is worse than one merely wrong. Replaced with each repo's reverse-chronological issues/events feed, which is the record itself.

  3. That feed's actor is the assignee, not the assigner. It reports SahajAtlasWeb#171 at 15:30 as actor=Ardnived; the timeline for the same event reads ->Ardnived by sydevs-bot. So the feed finds candidates and the timeline confirms attribution. Trusting the feed alone would have counted the reviewer's own triage as the loop's work — silently, and only ever upward.

Buckets are mutually exclusive with the terminal outcome winning: a ticket revised at 15:30 whose PR merges at 16:14 is one item finishing, not two moving.

Verification

Backtested against the four existing journals, and --json names the items behind every count:

2026-09-02   Wed — 4 new, 1 revised, 1 merged
2026-09-01   Tue — 2 new, 1 revised, 3 merged
2026-08-31   Mon — 4 revised, 2 merged
2026-08-30   Sun — 2 revised

Runtime ~17s (4 searches + 5 event feeds + a timeline per candidate), against 23s for the first search-then-timeline draft. claude plugin validate ./workflow --strict passes. No open PR currently carries a commit-pinned alias — #181 merged while this was being written.

Preview

No preview deploy for this repo.

🤖 Generated with Claude Code


Second pass — review requests, ticketless claude-workflow, two more scripts, config cleanup

1. Every PR requests a review

Opening a PR now runs gh pr edit <n> --add-reviewer <assignment.reviewer>, on every PR including drafts. Assignment and review request answer different questions — the assignee is who is working on it, the reviewer is who must look. Handing a PR back sets the first; nothing set the second, so PRs waited in a list the reviewer had no reason to open.

2. claude-workflow no longer needs a ticket

prAllowlistGlobs becomes **. The ticket gate exists so the loop does not write code nobody asked for; in a repo that ships prose and config it buys nothing, because the PR body is the proposal and a ticket restating it adds a round trip before the same reviewer reads the same argument.

Applied in .claude/workflow.json, CLAUDE.md/AGENTS.md, README.md, implement-issue and rung 3.

What still gates the work is unchanged, and is the part that matters: an approving review, wipCapPerRepo, one behaviour per PR, and never a skill change and a ceiling change together. Those bind harder now that nothing upstream forces a pause, which is why this also adds:

mergePolicy.loopMayNotMerge: ["claude-workflow"] — making explicit what CLAUDE.md only said in prose. This is not tidiness. Deriving "no CI configured" as green (below, #29) turns every approved claude-workflow PR into a merge candidate, in the one repo where merging is the deploy of the instructions every subsequent run executes. Without this the gate would have started merging them.

3. The merge gate is a script — lib/merge-gate.mjs

Closes the analysis in #26 and #29. The prose table was wrong in two directions at once:

PR Old reading Reality
SahajCloud#672 success — Railway's deploy status, green 21:14:17Z Lint, Test & Smoke ran until 21:31:40Z
SahajAtlasWeb#181 pending, total_count: 0 5 of 5 check runs green

The first row is the dangerous one. For seventeen minutes an approved PR read as green with its test suite still running, and a run that merged in that window would have been following the skill exactly.

pull_request_read method:get_status returns commit statuses; our CI reports check runs. GraphQL's statusCheckRollup merges both surfaces, so the split that caused #26 does not exist here. Verified live on SahajCloud#674, which returns both Lint, Test & Smoke (check) and sahajcloud - SahajCloud (Railway status).

Two clauses the merged reading still needs:

  • At least one check run, not merely one context — a Railway or Cloudflare deploy posts its own status and would otherwise stand in for a test job that was never scheduled, which is exactly the shape a merge conflict produces.
  • A repo with no Actions is not a repo with unfinished CI (fix(loop): rung 1 can never call a claude-workflow PR green, because this repo runs no CI #29). Derived from the repo's workflow count (claude-workflow → 0), so it cannot go stale the day someone adds a workflow.

/finalize-pr's CI watch shares the module rather than restating it — a second prose copy of "what green means" is how it stayed wrong in both places. ci-status.mjs exits 0 green / 1 red / 2 still running, so the caller parses nothing.

4. The census is a script — worklist.mjs

Rung 0 was a dozen searches, a per-repo PR list, a comment fetch per candidate and a blocker read per ticket — every result crossing the context window, nine times a day, to re-derive a queue the assignee field already stores.

WIP: SahajCloud 1 · SahajAtlasWeb 1 · WeMeditateWeb 1 · SahajAtlasWordpress 0 · claude-workflow 0   cap 3

## Rung 1 — merge (1)
  sydevs/SahajAtlasWeb#187  5 check(s) green  — feat(report): migrate the issue-report form…
## Rung 3 — implement (5)
  …
## Cleared blockers to strike (0)

5.6 seconds, one invocation. It reports; it does not decide — which item to work stays in the skill, and bodies are deliberately absent. It also resolves every Blocked by: URL rather than trusting the line, and separately lists blockers that have since closed, because a stale line is a standing cost: three consecutive journals once called one ticket blocked after its blocker had merged.

5. loop-config.json holds values again

You asked what that file is for and whether every key serves it. Measured: 7,889 of 11,066 bytes — 72% — were prose, across 27 $comment and *Note keys. And an audit of every one found its rule already stated in a skill or in docs/why.md:

Note Also stated in
ceilings.maxWorkItemsNote loop-run
ceilings.ciPollNote loop-run, why.md
labels.gateNote triage-issue, finalize-pr
assignment.handBackNote four skills
issueFields.ownershipNote triage-issue
identity.legacyNote why.md
journal.closePolicy reflect

…and so on for all 27. So the file was a second source of truth for every rule it touched, in the repo whose entire failure history is duplication drifting apart — and a config note cannot be cited with (why: …) or found by someone reading the rule.

Three homes, no overlap:

  • the value → loop-config.json
  • the rule → the skill that enforces it
  • the story → docs/why.md

11.0KB → 5.0KB, no rule lost — verified by checking every removed key against the skills, and by confirming no skill references a key that no longer exists.

Verification

A caveat worth your attention

CLAUDE.md says one behaviour per PR, and this PR is five. That rule exists because a skill change cannot be validated by running it, so when the next run misbehaves you need to know which change did it. If you would rather bisect, the commits split cleanly — a14e489 is this entire second pass and reverts on its own.


Third pass — the scripts could not run in a routine

The scripts in the second pass were broken in the cloud, and I found it by probing rather than by shipping. All of them shell out to gh, and I had verified them only where gh works.

Two routine probes:

Test Result
command -v gh, ls /usr/bin/gh, find / -name gh absent
gh 2.63.2 downloaded to /tmp and run installs and runs fine
gh api repos/<in-session repo> 403 — "GitHub access is not enabled for this session"
curl …/repos/… with the token, and without it 403, byte-identical
curl …/graphql 403 — "only the pinned set of PR-review operations is served"
curl …/user 200
mcp__github__* works, scoped to the session's repos

The identical 403 with and without an auth header is what settles it: the proxy refuses the path, not the credential, so no binary and no better token can help. Only MCP has a route, and a script cannot call MCP.

docs/routine-setup.md asserted the opposite — "gh needs no installing: it ships in the image (/usr/bin/gh, v2.98.0)" — and that line is what licensed the whole approach. loop-run/SKILL.md had it right. Corrected, with the measurements, plus a new why.md anchor.

The fix: the run fetches, the script decides

That is the better boundary regardless. Neither merge-gate failure was in the fetching — both were in deciding what the fetched values meant, and that half had no single home.

  • lib/merge-gate.mjs is now pure. normalizeMcp() takes exactly what the three documented MCP calls return, so cloud and local reach the same code.
  • merge-verdict.mjs is the routine-viable gate: MCP JSON on stdin, exit 0 merge / 1 hold. Verified against all four known cases:
Case Verdict
#26's dangerous one — Railway status green, Lint, Test & Smoke still running HOLD — still running: Lint, Test & Smoke
#29 — approved PR in a repo with no CI HOLD — claude-workflow is merged by a human, never by the loop
Approved, clean, all checks green MERGE
reviewDecision omitted from the input HOLD — no approving review (NONE)

Omissions fail safe, never open. A missing reviewDecision reads as not approved; an unknown workflow count reads as this repo has CI, so a missing check blocks rather than passes. The only error that can merge something is one that invents an approval.

  • branch-preview-url.mjs gains --stdin, taking comment and check-summary text. The parser — where the bug was — is shared; both paths verified.
  • worklist, journal-title, awaiting-review, ci-status are labelled LOCAL ONLY in their own headers. The skills now carry the MCP path for routines beside a pointer to each script for local use.

Two bugs the code found that reading would not have

Every search was scoped org:sydevs. The org still holds retired repositories, so awaiting-review put seven-year-old Atlas and WeMeditate issues into the reviewer's queue on its first run — 8 real items buried under 8 from 2019. Everything now scopes by repo: qualifiers built from repos.

📋 Awaiting you is now a table with a Since column, in the skill as well as the script. It is a triage surface — what needs me, and how long has it waited reads down a column and does not read out of a sentence. A nine-day wait and a one-hour wait are indistinguishable in prose.

| | Item | Waiting for | Since |
| --- | --- | --- | --- |
| 👀 | [sydevs/SahajAtlasWeb#168 — feat(i18n): take the language set from SahajCloud](url) | Review — CI green | 17h |
| 💡 | [sydevs/SahajCloud#670 — reject an unknown select-field value with 400](url) | Verdict on the proposal | 1h |

Not done

dropped-batons.mjs. It would be local-only, and the dropped-baton sweep runs only in the nightly routine — so a script for it would be a tool that never executes where it is needed. The sweep stays prose. The identity preflight is one MCP call and a comparison; it needs no script.


Fourth pass — can a script reach GitHub in a routine at all?

Asked directly, since the third pass left the scripts local-only and the loop runs in routines. Answer: no, not to api.github.com.

getent hosts api.github.com  →  140.82.112.5
curl                         →  peer=127.0.0.1
cert issuer                  →  CN=CCR Upstream Proxy CA (staging); O=Anthropic
env                          →  CCR_AGENT_PROXY_ENABLED · CCR_UPSTREAM_PROXY_ENABLED
                                NODE_EXTRA_CA_CERTS · DENO_TLS_CA_STORE

GitHub API traffic is TLS-intercepted by a local Anthropic proxy with its own CA, and it allowlists by path, regardless of credential: a deliberately invalid PAT drew the identical 403 as the harness token, under both Bearer and token schemes, on REST and GraphQL. So bringing our own token buys nothing, and the remaining routes around it are defeating a sandbox control.

The probe also mapped what is open, which is nearly everything else:

Host Result
example.com 200
de.sentry.io 404 — reached, wrong path
Railway app 401 — reached, auth
raw.githubusercontent.com · codeload.github.com 200
github.com 403

So arbitrary HTTPS egress works — which is how the Sentry and Mailpit rungs already run, and the one route by which a script could reach GitHub state directly: a self-hosted relay holding its own token.

Decided: not building it. The gate that could merge untested code already works in a routine, because the run fetches with MCP and merge-verdict.mjs decides. A relay would only move counting and formatting into scripts, and it would cost a service to keep alive plus a five-repo PAT in an environment with no secret store — undoing the per-session repo scoping the proxy exists to enforce. Both the finding and the decision are in docs/why.md, so this is settled rather than rediscovered.


Fifth pass — the local-only scripts are deleted

Testing the gh-setup-hooks recipe, and connecting the Claude GitHub App for the org, both came back negative — but they surfaced the constraint that actually matters.

The proxy returns three different 403s, and they do not lift together:

Path Message Would repo access fix it?
repos/{owner}/{repo}/... "GitHub access is not enabled for this session. An org admin must connect the Claude GitHub App" —
search/issues "sessions are bound to their configured repositories. Use repository-scoped endpoints" No
graphql "only the pinned set of PR-review operations is served" No

Search is the binding constraint, not repo access — it is cross-repository by nature, and a session is bound to its repositories. The baton worklist is a search, and so are the journal counts and the awaiting-you table. So those three could never have run in a routine, whatever happens to repos/....

Ruled out along the way, each measured rather than reasoned: installing gh (works, then 403s identically); a PAT in GH_TOKEN (the proxy answers before reading a credential — harness token, invalid token and no token give byte-identical 403s); connecting the Claude GitHub App for sydevs (changed nothing). The gh-setup-hooks recipe targets Claude Code on the web, which has a laxer proxy than Routines — not wrong, doesn't transfer.

Deleted — 993 lines

worklist.mjs, journal-title.mjs, awaiting-review.mjs, ci-status.mjs, lib/gh.mjs.

They only ran where gh exists, and the loop does nearly all its work in routines. Keeping them meant two implementations of every rule they held — a local one exercised while developing, a prose one in the skill executed eight times a day. That is precisely the shape of the defect that made the merge gate unsafe: get_status versus check runs was never a fetching bug, it was two readings of "green" with no single home.

The rules survive as specs in the skills: the census queries, the four journal counts with their Vancouver day boundary and the timeline-not-event-feed rule for hand-backs, and the awaiting-you table.

Kept — stdin-only, every fetch path stripped

Script Input Why it earns its place
lib/merge-gate.mjs + merge-verdict.mjs 3 small MCP objects The definition of green and mergeable, in one place. Two live bugs, one dangerous
branch-preview-url.mjs comment + check-summary text The alias parser — the whole of the original fix

Both re-verified against their known cases after the refactor: the seventeen-minute SahajCloud window still holds, an omitted hasWorkflows now defaults to this repo has CI (so a missing check blocks rather than passes), and both Pages and Workers aliases still parse.

The rule, now in CLAUDE.md: no script under workflow/ talks to GitHub. The run gathers, the script decides. It costs the token savings a scripted census would have given and buys the only thing that was load-bearing — one implementation, exercised identically everywhere.

A script earns its place when its input is small enough to hand over and its logic is subtle enough to get wrong in prose. A census, a count and a markdown table clear neither bar.

Recorded, not lost

#31 — blocked-upstream. Carries what each deleted script needed, the git show commands to recover them, a three-line re-test that needs no credential, everything already ruled out so it is not re-tried, and the warning that a proxy 403 (docs.anthropic.com) and a GitHub 401 (Bad credentials) look alike — they were confused twice here, once producing a wrong recommendation.

Also ignores .claude/worktrees/, which a running loop had just created and git add -A picked up as an embedded repository.

Ardnived and others added 2 commits September 2, 2026 09:33
Two prompt-level rules become tools, because both had already failed as
instructions.

**Preview URLs.** SahajAtlasWeb#181 was fixed to use branch aliases and then
re-broken, the second time with a rationale: "these are per-deployment aliases,
so they stay pinned to this commit." That argument comes from
`get-cloudflare-preview-url.mjs`, which ranks a commit alias above a branch alias
on purpose — it feeds the CI smoke gate, which must test the exact SHA it was
handed. Correct there, exactly wrong in a PR body, and finalize-pr pointed at it
with a hedge ("when it gives you a branch alias") that the script can never
satisfy. One tool, two opposite requirements.

`branch-preview-url.mjs` is the second tool. It reads the alias out of the label
Cloudflare writes — `Branch Preview URL` in the Pages check-run summary and in
the Workers comment — so nothing is constructed. That matters beyond tidiness:
the documented slug rule (non-alphanumerics to `-`, truncate to 28) is a guess
about a host we do not own, and two branches agreeing in their first 28
characters produce one alias that answers 200 while serving the other branch.
Verified against both platforms: SahajAtlasWeb#181 (Pages, two projects) and
WeMeditateWeb#55 (Workers Builds + Pages). SahajCloud needs none of this —
Railway's preview host is per-PR and already stable.

**Journal titles.** Prose rewritten by the model nine times a day, each rewrite
re-reading the day to re-summarise it. `journal-title.mjs` prints
`Wed — 2 new, 1 revised, 2 merged, 1 closed` from queries instead.

Three things it had to get right, each found by testing rather than reasoning:

- A work item is an issue and its PR together, paired through
  `closingIssuesReferences` rather than a body regex — that is the resolution the
  merge itself uses, it catches sidebar links that leave no text, and it resolves
  cross-repo references without guessing which repo a bare `#12` meant.
- `updated:` filters on an item's CURRENT `updated_at`, not "was active in this
  range" — GitHub has no activity-range qualifier. Gating candidates on
  `assignee:<reviewer>` therefore dropped every item since reassigned, so the
  count would FALL through the day as work moved on. Replaced with each repo's
  reverse-chronological `issues/events` feed, which is the record itself.
- That feed's `actor` on an `assigned` event is the ASSIGNEE, not whoever
  assigned them: it reports SahajAtlasWeb#171 as `actor=Ardnived` where the
  timeline reads `->Ardnived by sydevs-bot`. So the feed finds candidates and the
  timeline confirms attribution. Trusting the feed alone would have counted the
  reviewer's own triage as the loop's work, silently and only ever upward.

Buckets are mutually exclusive with the terminal outcome winning, so a ticket
revised at 15:30 whose PR merges at 16:14 is one item finishing, not two moving.

Co-Authored-By: Claude Opus 5 <[email protected]>
…om tickets

Four changes that share one idea: a rule that can be evaluated should be
evaluated, and a value should not carry an essay.

**Review requests.** Opening a PR now requests review from `assignment.reviewer`,
always, including on drafts. Assignment and review request answer different
questions — who is working on it, versus who must look — and a PR that never
requests one waits in a list the reviewer has no reason to open.

**`claude-workflow` is ticketless.** `prAllowlistGlobs` becomes `**`. The ticket
gate exists so the loop does not write code nobody asked for, and it buys nothing
in a repo that ships prose and config: the PR body IS the proposal, and a ticket
restating it adds a round trip before the same reviewer reads the same argument.
What still gates the work is unchanged and is the part that matters — an
approving review, `wipCapPerRepo`, one behaviour per PR, and never a skill change
and a ceiling change together.

That last set binds harder now, so `mergePolicy.loopMayNotMerge` makes explicit
what CLAUDE.md only said in prose: the loop opens PRs here and never merges them.
Without it the new gate would have started merging them, because deriving "no CI
configured" as green (#29) turns every approved claude-workflow PR into a
candidate — in the one repo where merging is the deploy of the instructions every
subsequent run executes.

**The merge gate is a script.** `lib/merge-gate.mjs` replaces the prose table that
was wrong in two directions at once (#26):

  - `get_status` returns commit statuses; our CI reports check runs. On
    SahajCloud#672 the only status was Railway's deploy, green at 21:14, while
    `Lint, Test & Smoke` ran until 21:31 — seventeen minutes in which an approved
    PR read as green with its tests still running, and a run merging there would
    have been following the skill exactly.
  - The same call read SahajAtlasWeb#181, five of five checks green, as `pending`
    forever.

GraphQL's `statusCheckRollup` merges both surfaces, so the split that caused #26
does not exist here. Two clauses the merged reading still needs: at least one
CHECK RUN (a deploy status would otherwise stand in for a test job that was never
scheduled), and "this repo runs no Actions" is not "this PR's CI is unfinished" —
derived from the repo's workflow count, so it cannot go stale the day someone
adds a workflow. `/finalize-pr`'s CI watch shares the module, because a second
prose copy of "what green means" is how it stayed wrong in both places.

**The census is a script.** `worklist.mjs` prints every rung's candidates, WIP
against `wipCapPerRepo`, a merge verdict per PR, resolved blockers per ticket and
any cleared blocker still needing its line struck — in about five seconds, once,
where rung 0 was a dozen searches and a blocker read per ticket crossing the
context window nine times a day.

**loop-config.json holds values again.** It carried 7.9KB of prose across 27
`$comment` and `*Note` keys — 72% of its bytes — and an audit found every one of
those rules already stated in a skill or in docs/why.md. Two sources of truth for
every rule, in the repo whose entire failure history is duplication drifting
apart. Three homes, no overlap: the value here, the rule in the skill that
enforces it, the story in why.md. 11.0KB to 5.0KB, no rule lost.

Co-Authored-By: Claude Opus 5 <[email protected]>
Ardnived and others added 3 commits September 2, 2026 10:23
… API

The scripts shipped earlier in this branch cannot run in a routine. All of them
shell out to `gh`, and I verified them only where `gh` works.

Probed rather than reasoned about, twice:

  - `gh` is absent from the routine image. `docs/routine-setup.md` claimed it
    "ships in the image (/usr/bin/gh, v2.98.0)"; that line is wrong and is what
    licensed the whole approach. `loop-run/SKILL.md` had it right.
  - Installing it does not help. A downloaded gh 2.63.2 runs fine and then
    `gh api repos/...` returns 403 "GitHub access is not enabled for this
    session" — byte-identical with and without an auth header, so the proxy
    refuses the PATH, not the credential. curl to REST and to GraphQL 403 the
    same way. `curl /user` returns 200, which is the trap: the token looks
    healthy and the repository looks missing when neither is true.

Only `mcp__github__*` has a route, and a script cannot call MCP.

So the split is: **the run fetches, the script decides.** That is the better
boundary anyway. Neither merge-gate failure was in the fetching — both were in
deciding what the fetched values meant, and that half had no single home.

  - `lib/merge-gate.mjs` is now pure. `normalizeMcp()` accepts exactly what the
    three documented MCP calls return, so cloud and local reach the same code.
  - `merge-verdict.mjs` is the cloud-viable gate: MCP JSON on stdin, exit 0
    merge / 1 hold. Omissions fail SAFE — a missing reviewDecision reads as not
    approved, an unknown workflow count reads as "this repo has CI" so a missing
    check blocks. The only error that can merge something is one that invents an
    approval.
  - `branch-preview-url.mjs` gains `--stdin`, taking comment and check-summary
    text. The parser — where the bug was — is shared by both paths.
  - `worklist`, `journal-title`, `awaiting-review` and `ci-status` are labelled
    LOCAL ONLY in their own headers, and the skills now carry the MCP path for
    routines beside a note pointing at each script for local use.

Also in this commit, both found by running the code rather than reading it:

  - Every search was scoped `org:sydevs`, which drags in retired repositories.
    `awaiting-review` put seven-year-old Atlas and WeMeditate issues in the
    reviewer's queue on its first run. Everything now scopes by `repo:`
    qualifiers built from `repos`.
  - `📋 Awaiting you` becomes a table with a `Since` column. It is a triage
    surface, and a nine-day wait and a one-hour wait look identical in prose.

Co-Authored-By: Claude Opus 5 <[email protected]>
Probed with a deliberately invalid PAT, which drew the same Anthropic 403 as
the harness token under both auth schemes, on REST and GraphQL. api.github.com
connects to peer=127.0.0.1 behind a cert issued by 'CCR Upstream Proxy CA
(staging); O=Anthropic'. So a self-managed token buys nothing, and the question
does not need asking again.

Also recorded what is NOT gated: example.com, de.sentry.io, Railway,
raw.githubusercontent.com and codeload.github.com all answer. Arbitrary HTTPS
egress is how the Sentry and Mailpit rungs already work.

Co-Authored-By: Claude Opus 5 <[email protected]>
The relay is now a live option rather than a hypothetical, so the reasoning for
declining it needs to be on the record too — otherwise a future run rediscovers
that egress works and treats it as a licence.

Co-Authored-By: Claude Opus 5 <[email protected]>
…tches

Four scripts could only ever run where `gh` exists, and the loop does nearly all
its work in routines. Keeping them meant two implementations of every rule they
held — a local one exercised while developing, a prose one in the skill executed
eight times a day. That is the exact shape of the defect that made the merge gate
unsafe: `get_status` versus check runs was never a fetching bug, it was two
readings of "green" with no single home.

Deleted: worklist, journal-title, awaiting-review, ci-status, lib/gh.mjs (993
lines out). The rules they encoded are now specs in the skills — the census
queries, the four journal counts and their day boundary, the awaiting-you table.

Kept, and now stdin-only with every fetch path stripped:
  - lib/merge-gate.mjs + merge-verdict.mjs — the definition of green and
    mergeable, in one place. repoHasWorkflows is seeded by the caller and
    defaults to TRUE when unknown, because assuming CI exists blocks a merge
    while assuming it does not would call an untested PR green.
  - branch-preview-url.mjs — the alias parser, fed comment and check-summary text.

Both verified unchanged against their known cases after the refactor.

Why not make `gh` work instead: it was tried three ways and the ceiling is not
where it looked.

  - Installing `gh` works; `gh api repos/...` then 403s "GitHub access is not
    enabled for this session", identically with the harness token, an invalid
    token, and no token.
  - Connecting the Claude GitHub App for the org — which is what that 403 asks
    for — changed nothing.
  - The community recipe (gh-setup-hooks) sets GH_TOKEN to a personal token. The
    proxy answers before it reads a credential, so it never gets that far. It
    targets Claude Code on the web, which has a laxer proxy than Routines.

And the part that would survive any widening of repo access: `search/issues`
returns "sessions are bound to their configured repositories", and `graphql`
serves "only the pinned set of PR-review operations". Search is cross-repository
by nature, and the loop's worklist IS a search — so the three search-dependent
scripts could never have been cloud-viable, whatever happens to `repos/...`.

Also ignores .claude/worktrees/, which a running loop had just created and which
`git add -A` picked up as an embedded repository.

Co-Authored-By: Claude Opus 5 <[email protected]>
Both sides were largely additive; four files conflicted and three of the
resolutions were judgement calls worth recording.

**The CI-green rule now has one home.** #28 landed the same fix as this branch,
as prose, with its own `why.md` anchor — so main and this branch each carried a
statement of what "green" means, plus `merge-gate.mjs` implementing it. Deleted
my anchor in favour of main's `#ci-truth-lives-in-check-runs`, which is the
better write-up (it also reasons about `skipped`/`neutral` and about why the
mirror-image status clause is deliberately absent), repointed the citations, and
cut rung 1's restatement down to a pointer at the script. The implementation was
checked against main's prose clause by clause: they agree.

**Kept #32's `review` block, dropped its essay.** A four-sentence `$comment`
explaining the fallback idempotency key is a rule, and rules live in the skill
that enforces it — `adversarial-review/SKILL.md` already says all of it.

**Fixed a bug #32 inherited rather than introduced.** Its rung-5 census, its
proposal-ceiling check, its dropped-baton sweep and reflect's new review query
all scope `org:$ORG`. The org still holds retired repositories, and that scope
put seven-year-old Atlas and WeMeditate issues into the reviewer's queue the
first time it was run as a real query. Every search in both skills now uses
`$SCOPE`, built from `repos`, and the rule is stated once at rung 0.

**Rung 5 no longer restates the green rule or hardcodes a repo fact.** It said
"claude-workflow is the one exception: it has no CI" — which `merge-gate.mjs`
derives from the workflow count, so it cannot go stale the day someone adds a
workflow.

Two more things this pass found, neither from #32:

- The journal body still carried a `## This month` table from the era of monthly
  journal issues. The journal has been one issue per day since the baton work; a
  day's body cannot summarise a month, and the Sunday reflect rung is what reads
  across issues.
- The awaiting-you table went into the per-run comment while the BODY — the
  surface the reviewer actually reads, and the one the rules single out as
  "never leave stale" — kept bullets. Both are tables now.

`identity.mentionQuery` removed: nothing reads it since rung 0 spells the query
out, and a config key no code reads is exactly what the values-only rule exists
to prevent.

Co-Authored-By: Claude Opus 5 <[email protected]>
@Ardnived
Ardnived merged commit 4d50781 into main Sep 2, 2026
@Ardnived
Ardnived deleted the claude/branch-alias-and-journal-title branch September 2, 2026 18:36
Ardnived added a commit that referenced this pull request Sep 2, 2026
…ne over shared bookends (#35)

* refactor(loop): rung means one thing — split the two routines into two run skills

The survey routine and the working-day loop diverged long ago — the survey was
split out precisely so a busy queue could not starve it — but both kept
sharing one skill file and one rung numbering. That numbering described a
ladder no run ever descended: the nightly run executed "rung 6" without
climbing 1-5, the loop run stepped over 6 on its way to 7, and preflight and
journal wore rung numbers despite being every run's bookends rather than
priority steps of anything. The costs were concrete: adding one loop rung
(#32) forced a renumbering sweep across four files for a nightly run that had
not changed, and the nightly run's spec formally omitted preflight - auth,
identity, ceilings - because "rung 0" read as the ladder's business.

Now: two run skills over shared bookends.

- preflight - ground rules (prompt-not-spec, writing style, non-negotiables,
  never-subscribe) plus run start (auth, identity, capability limits, census).
  Explicitly both runs': the nightly run's missing preflight is fixed by
  construction.
- journal - the whole journal spec and the run's ending, shared verbatim.
- loop-run - the ladder alone, rungs 1-5 keeping their numbers, so every
  existing rung citation (docs/why.md#rung-2-competes-for-the-same-budget,
  finalize-pr's "rung 1", adversarial-review's "rung 5") stays true. Keeps a
  redirect: a prompt still carrying RUN_KIND=nightly is sent to nightly-run,
  so the stored nightly prompt cannot silently lose its survey while it
  awaits updating.
- nightly-run - survey dispatch and the reconciliation sweeps, stated as what
  it is: a fixed set of once-a-day tasks, not a ladder, no rungs.

In passing: deduplicates rung 1's verdict table and mergePolicy paragraphs
(a #30/#32 merge artifact stated everything twice), removes the duplicated
"GitHub metadata" heading in routine-setup, and corrects surveyCalendar's
comment - surveys are dispatched by the nightly run, not "morning runs".

The nightly routine's stored prompt should be repointed at
nightly-run/SKILL.md after this merges; routine-setup documents that, and the
redirect covers the gap.

Co-Authored-By: Claude Fable 5 <[email protected]>

* refactor(loop): name the run skills for what they do — queue-routine and survey-routine

loop-run and nightly-run named when and how the skills ran, not what they
did — and "loop-run" doubly so once the nightly routine stopped being part
of any loop pass. The queue routine advances the work queue (the assignee
field IS the worklist): merge, revise, implement, review. The survey routine
surveys: the day's calendar survey plus the reconciliation sweeps that keep
the queue honest.

Directory renames carry merge-verdict.mjs along; frontmatter names, the
${CLAUDE_PLUGIN_ROOT} script path, the nightly-prompt redirect, loop-config
comments, README, routine-setup, AGENTS.md, and the why.md section heading
(now covering all four run-adjacent skills) all follow. The system-level
name — "the loop", loop-config.json, the identity marker — stays: that names
the whole machine, not a skill.

Co-Authored-By: Claude Fable 5 <[email protected]>

* chore(loop): keep a transition pointer at the old loop-run path

Both stored routine prompts name the path workflow/skills/loop-run/SKILL.md,
and routines clone main fresh each run - so the moment the rename merges,
every run would open a path that no longer exists, hourly, until someone
updates the prompts. The stub redirects each routine to its new skill,
journals that it was used (the signal the prompts still need updating), and
says to delete itself once both prompts point at the new paths.

Co-Authored-By: Claude Fable 5 <[email protected]>

* refactor(loop): work-routine replaces queue-routine; new routines replace the prompt shim

Renamed the working-day skill to work-routine and removed the loop-run
transition stub: instead of shimming the old path, the cutover is two new
cloud routines created alongside the old ones - sydevs-work-hourly
(trig_01BUwH4WjazMXjG2bnC3TVRL) and sydevs-survey-nightly
(trig_01WzJ2EnTKEk9BJ2Xf6AQ4x6) - same schedules, same environment, same
tool set, created paused. Their prompts point straight at the new skills and
enumerate no rungs; the old routines' prompts had drifted ("rungs 0 through
4, then rung 6"), which is the staleness their own text warns about. The
reviewer enables the new pair and deletes the old pair, so no run ever reads
a path that does not exist.

routine-setup now records the real stored prompt verbatim, the new ids, and
which predecessors to delete; the RUN_KIND redirect is gone from
work-routine along with the rest of the shim.

Co-Authored-By: Claude Fable 5 <[email protected]>

---------

Co-authored-by: Claude Fable 5 <[email protected]>
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