Skip to content

feat(state): a workflow owns the mechanical state; the loop keeps judgement - #44

Merged
Ardnived merged 2 commits into
mainfrom
claude/feat-state-machine
Sep 4, 2026
Merged

Ardnived merged 2 commits into
mainfrom
claude/feat-state-machine

Conversation

@Ardnived

@Ardnived Ardnived commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Three asks that turned out to be one change.

1. awaiting is the primary human-attention signal. One boolean label in all five repos. It exists because nothing else can span both types: issue fields are issues-only, and unsearchable besides (field. returns 0 through the REST search a routine has), so no field can ever be a worklist query or a board filter. Filter any board view by label:awaiting and that is your queue.

2. A reusable workflow owns every mechanical transition. Your question — "most of these decisions are mechanical, not something which needs an AI" — was right, and the prize is bigger than not-forgetting:

Was Now
Loop sets Implemented + unassigns, up to 8h later pull_request: opened → within seconds
Loop sets Proposed on a proposal it filed issues: opened → within seconds
Loop sets Revising when you comment issue_comment: created → before the run even starts
Loop must remember to hand back ready_for_review / review submitted → it cannot forget

Every "as your final action, reassign / set Stage" rule left the skills entirely. What remains is judgement: choosing a Hold Until date, deciding a block lifted, revoking Implement, deciding the work is done — plus four awaiting adds for dead ends no event expresses (CI cap, unrebaseable conflict, a rebutted thread, an investigation's finding).

Per your third point, the skills carry an explicit prohibition table rather than a silence — a deleted instruction is invisible to a run that half-remembers it:

The loop must never write Who does
Any assignee, on anything You add the bot; the workflow removes it at Implemented
Stage, outside the four judgement cases The workflow, from the event
awaiting, outside the four dead ends The workflow
Stage: Implement, ever You only — the one safety property, untouched

3. Nothing is ever assigned to you again. awaiting carries that signal, so the assignment was a second source of truth for one fact — and it was the half nothing ever cleared (the accumulation I flagged in #36). An issue's assignee now means exactly one thing everywhere.

Journal → flight recorder

The board answers "what needs me" continuously and cannot go stale, so 📋 Awaiting you is gone and the did-this lists compress to one line each. What survives is what nothing else records — ⚠️ Failed, ⏭️ Ceiling (which cap bound, and what it cost), 🧭 Friction. The title reports health (Wed — 8 runs · 2 failed · 3 ceiling stops) rather than volume the board already shows. Its reader is Sunday.

Reflect, redesigned

  • It grades itself first. Opens by reading last week's reflection PR and stating, per change, whether the failure recurred: held / did not hold / too early. A reflection that never checks its own past changes is opinion with a PR attached.
  • Recurrence gates every proposal, not just profile edits. One occurrence is weather — named, not acted on.
  • It reads instead of re-deriving. Each day's journal body collects that day's failures and ceiling stops, so one read per day covers the week. Ceiling proposals carry arithmetic ("binding on 5 of 7 days, cost 3 reviews").

One design bug caught while writing it

I wrote if: github.actor != 'sydevs-bot' as a recursion guard, then realised it skips the transitions that matter most — the bot authors its own issues and PRs. Recursion is bounded by idempotency instead: every writer reads current state first and returns early when it matches, so a re-fired field_added is one free no-op run. Both the workflow and routine-setup.md say so, loudly, so it is not re-added.

Already done outside this PR

  • awaiting created in all five repos; seeded across the backlog — 5 items, including claude-workflow#40: approved in the one repo loopMayNotMerge forbids the loop to merge, which is exactly the edge case this adds.
  • The reviewer unassigned from the 5 issues that carried them.
  • Five superseded PRs closed (#41, SahajCloud#690, WeMeditateWeb#76, SahajAtlasWeb#193, SahajAtlasWordpress#11) — board membership folds into the same caller.

⚠ Needs you before this works

  1. ADD_TO_PROJECT_PAT needs write, not read. Currently repo Issues/PRs read; the state machine needs read/write on both, plus org Projects read/write. Issue-field writes go through a repo endpoint but the field is org-level, and whether GITHUB_TOKEN suffices is undocumented — hence the PAT throughout.
  2. Four caller PRs follow once this merges (the callers reference @main).
  3. The project's built-in auto-add is no longer used — the workflow adds items in every repo, which the free plan's single slot could not.

Test results

  • ✓ claude plugin validate ./workflow --strict · ✓ loop-config.json parses · ✓ both workflow YAMLs parse · ✓ every (why: docs/why.md#…) resolves
  • ✓ Sweep: no assign … reviewer, no 📋 Awaiting you table, no orphaned state-write instruction

Manual verification, post-merge

Event-by-event on a scratch issue and PR in SahajCloud, asserting after each: bot-authored issue → Proposed+awaiting; your comment → Revising, awaiting gone; Implement unassigned → awaiting returns; assign bot → gone; PR opened closing it → Implemented+unassigned; closed unmerged → Revising+awaiting. Then confirm a single transition produces one workflow run, not a cascade.

🤖 Generated with Claude Code

…gement

Three changes that turned out to be one.

**`awaiting` is the primary human-attention signal.** One boolean label in all
five repos. It exists because nothing else can span both types: issue fields are
issues-only, and unsearchable besides (`field.` returns 0 through the REST
search a routine has), so no field can be a worklist query or a board filter.
Sub-labels were rejected — a boolean cannot be self-inconsistent, and the KIND
of attention is already legible from where the item sits.

**A reusable workflow owns every mechanical transition.** Almost every state
write the loop made was determined by an event, not by judgement, and the loop
made them up to eight hours late and could forget. `state-machine.yml` makes
them from the event within seconds and cannot forget: Stage on open, Implemented
+ unassign when a PR appears, Revising when one is abandoned, and awaiting on
every handover and every reply. One copy here, a ~20-line caller in each repo.

The prize is larger than punctuality: every "as your final action, reassign /
set Stage" rule left the skills entirely. What remains is judgement — choosing
a Hold Until date, deciding a block lifted, revoking Implement, deciding the
work is done — plus four `awaiting` adds for dead ends no event expresses.
The skills now carry an explicit prohibition table rather than a silence, because
a deleted instruction is invisible to a run that half-remembers it.

Recursion is bounded by idempotency, not an actor guard. An actor guard was
written first and was wrong: the bot authors its own issues and PRs, so
`github.actor != 'sydevs-bot'` skips the transitions that matter most.

**Nothing is ever assigned to the reviewer again.** `awaiting` carries that
signal, so the assignment was a second source of truth for one fact — and it was
the half nothing ever cleared. An issue's assignee now means exactly one thing
everywhere: the bot is present and it is the loop's turn, or it is not.

**The journal becomes a flight recorder.** The board answers "what needs me"
continuously and cannot go stale, so `📋 Awaiting you` is gone and the did-this
lists compress to one line each. What survives is what nothing else records:
what failed, which ceiling bound and what it cost, which rule misfired. The
title reports health rather than volume. Its reader is Sunday's reflect.

**Reflect grades itself.** It now opens by reading last week's reflection PR and
stating, per change, whether the failure it addressed recurred — held, did not
hold, or too early. A reflection that never checks its own past changes is
opinion with a PR attached. Recurrence becomes the gate for every proposal, not
just profile edits, and ceiling proposals carry arithmetic over seven days
rather than impression.

`.github/workflows/` exists here now and is not CI. Editing state-machine.yml
changes behaviour in all five repos on the next event, so it carries a skill's
blast radius and a skill's rules.

Done outside the repo: `awaiting` created in five repos; the reviewer unassigned
from the five issues that carried them; the label seeded across the backlog (5
items, including claude-workflow#40 — approved in the one repo the loop may
never merge, which is exactly the edge case this adds). Five superseded PRs
closed.

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

Two corrections, both found by reading the loop's own open work.

**The revision handover had no event.** `changes_requested` clears `awaiting`
because the ball is the loop's; pushing the fix puts it back with the reviewer,
and nothing said so — a revised PR would have waited unlabelled forever. Adds a
`synchronize` transition, guarded on the reviewer's latest review still being
CHANGES_REQUESTED so ordinary mid-work pushes do not flag a PR nobody is waiting
on.

Found by the loop in claude-workflow#42, which caught the same gap in the
journal query this label replaces: `review:none` silently dropped every PR the
loop had reviewed itself, including an approved one in the repo where only a
human may merge. That surface is gone, but the gap was real in both.

**Approval was gated on respondTo, which is too wide.** Four of the five repos
are public, so any account can submit an APPROVED review; respondTo also carries
antontcymbal and Copilot. Approval authority is assignment.reviewer's alone, and
a list admitting every feedback-giver is wider than the authority it stands in
for. respondTo still governs what counts as feedback — only approval narrows.

Same reasoning as the open claude-workflow#40, which fixes the mirror of this in
rung 1's merge gate. That PR is approved and unmerged; it will need a rebase
after this lands, and its docs/why.md anchor is the permanent home for the
argument — this states the rule inline meanwhile.

Also: journal.titleFormat was still the old volume title while journal/SKILL.md
had moved to reporting health. Now they agree.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@Ardnived
Ardnived merged commit e939bb7 into main Sep 4, 2026
@Ardnived
Ardnived deleted the claude/feat-state-machine branch September 4, 2026 17:01
@github-project-automation github-project-automation Bot moved this from In progress to Done in SYDevelopers Technical Roadmap Sep 4, 2026
Ardnived added a commit that referenced this pull request Sep 4, 2026
#44 landed the state machine and the flight-recorder journal while this sat
approved-and-unmerged, so this brings it current. One real conflict:

**journal.titleFormat** — this PR moved it to `filed / opened / merged / closed`
to match what journal/SKILL.md then computed. #44 moved the journal to reporting
health instead, and the title with it. Resolved to main's
`<n> runs · <n> failed · <n> ceiling stops`; volume lives on the board now.

Everything else auto-merged, and the security fix is intact and still wired:
reviewDecisionFrom is called by merge-verdict.mjs with the config's allowlist
applied after the spread, so a snapshot cannot widen its own authority.

Verified rather than assumed — all ten cases re-run against the merged tree,
including the two that matter: a stranger's APPROVED on a public repo returns
null, and so does a respondTo peer's. #44 had the mirror of this hole in the
state machine's label transition and states the rule inline; that inline
statement is now re-linked to this PR's docs/why.md#only-the-reviewers-approval-counts,
which is its permanent home. One rule, both sites where an approval is read.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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