Skip to content

feat(loop): scripts for the event-driven loop (1/4) - #66

Merged
Ardnived merged 5 commits into
mainfrom
claude/loop-scripts
Sep 8, 2026
Merged

Ardnived merged 5 commits into
mainfrom
claude/loop-scripts

Conversation

@Ardnived

@Ardnived Ardnived commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

First of four PRs that move the loop from hourly polling to GitHub-event dispatch. This one adds scripts only; no running skill reads them yet, so the hourly and nightly routines are untouched.

Design: ~/.claude/plans/let-s-consider-and-create-starry-church.md (rev. 3, agreed 2026-09-07/08).

Commits, one behaviour each

Commit What Failure it prevents
payload.mjs + tests Validates the dispatch record a routine is fired with — a pointer only (repo, item, handler, lock, deadline, journal). Refuses with every reason at once; --expect-handler catches a mis-routed fire. A model evaluating "check the fields" differently on each of forty fires a day; a leaked bearer token steering a session by text.
lib/merge-verdict.mjs Copy of the skill-local script with lib/ imports. The old path stays until work-routine is deleted. The dispatcher importing across skill directories.
budget.mjs journalEntry kind (1500); --fit accepts ### sections; an emptied Did heading is dropped once the text fits. A forty-comment journal day exceeding what Sunday's reflect can read; an orphaned heading in every trimmed entry.
version 0.4.0 cache key stale installed plugin

No ceiling change

loop-config.json is untouched. journalEntry: 1500 is a script fallback here and ships to the config in the additive config PR (3/4), per the never-skill-and-ceiling-together rule.

Verification

  • node --test workflow/lib/payload.test.mjs — 12 pass.
  • claude plugin validate ./workflow --strict — passed.
  • --fit --kind journalComment regression on the 7 KB / 19 KB / unfittable bodies from perf(loop): cut the four fixed costs every run pays #62: unchanged results.
  • payload.mjs against main's config correctly refuses everything with "no handlers block" — the config PR adds it.

Next: 2/4 new handler skills · 3/4 additive config · 4/4 the dispatcher (dark).

Ardnived and others added 5 commits September 8, 2026 11:29
The event-driven loop starts every session from one untrusted block: the
`<routine-fire-payload>` the `/fire` endpoint wraps around whatever the
caller sent. A handler may act on it only as a pointer — repo, item,
handler, lock — and must re-read every fact from GitHub.

"Check the fields" as prose is evaluated by a model once per fire, forty
times a day. `payload.mjs` evaluates it the same way every time: schema
version, a handler this config knows, a repo in the configured set, a
github.com url under that repo, the lock label the config names, an
attempt inside `dispatch.maxAttempts`, a deadline in the future, and a
journal pointer at the journal repo. It refuses with every reason at
once, so one journal read diagnoses a bad fire. `--expect-handler`
catches a record routed to the wrong routine. Anything else in the record
is carried through untouched and never acted on.

Reads stdin and `loop-config.json`; never fetches. Tested with
`node --test workflow/lib/payload.test.mjs`.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
… lives

The dispatcher in GitHub Actions is about to become the one caller of the
merge gate, and it imports from `workflow/lib`. The copy under
`skills/work-routine/` stays until that skill is deleted, so the running
loop is untouched. Imports rewritten to `./config.mjs` and
`./merge-gate.mjs`; no rule changed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The journal becomes one comment per run rather than one body per day, so
each comment needs its own kind: `journalEntry`, 1500 characters, sized so
a forty-dispatch day stays near 60 KB for the Sunday reflect to read. The
value is a fallback here and lands in `loop-config.json` separately.

A comment's sections are `###` where the day's body used `##`. `--fit`
now recognises both, and an empty Did heading is removed once the text
fits rather than only while the loop is still cutting — the skill omits an
empty section, and an orphaned heading reads as one.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@Ardnived
Ardnived force-pushed the claude/loop-scripts branch from ad9178c to 6cec8bf Compare September 8, 2026 18:29
@Ardnived
Ardnived merged commit e0fb68d into main Sep 8, 2026
1 check passed
@Ardnived
Ardnived deleted the claude/loop-scripts branch September 8, 2026 18:29
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.

1 participant