Repository navigation
Description
Summary
rule-delta.mjs is the only guard against a skill rewrite silently dropping a rule, and the base
ref documented for it — --base main — is the wrong baseline. In a routine clone the local main
branch ref is stale, so the tool invents removals and can hide a real one. Six documented call
sites carry the wrong ref, one of which a routine executes, and three scripts read a base ref
and all three mishandle it.
Approach
Reproduced in this run's clone, working tree clean and identical to origin/main, after
start-run step 6 (git fetch origin main, then git remote set-head origin main):
$ git rev-parse main origin/main HEAD
83a9b8eb12897c12a081fc9a9b59390b34d4f414 # refs/heads/main — stale, 25 skill files behind
ae51afef3e3eae83317e3836b626ea76f2fdb13c # refs/remotes/origin/main
ae51afef3e3eae83317e3836b626ea76f2fdb13c # HEAD
$ node workflow/lib/rule-delta.mjs --base main workflow/skills
fatal: path 'workflow/skills/audit-code/SKILL.md' exists on disk, but not in 'main'
… 24 more fatal: lines …
directives: 26 → 77
ADDED (50): …
REMOVED — adjudicate each (1): - Never merge the base branch in to keep a PR fresh.
EXIT=1
$ node workflow/lib/rule-delta.mjs --base origin/main workflow/skills
directives: 77 → 77
No directive disappeared.
EXIT=0
Exit 1 on an unchanged tree: 25 fatal: lines, 50 phantom additions, and one phantom removal
handed to a human to adjudicate. Neither command in step 6 moves refs/heads/main — confirmed
here, main was still 83a9b8e after both. A run that follows start-run exactly still gets the
wrong answer.
The drift grows. The first revision of this ticket, three days ago, saw one phantom ADDED and
one phantom REMOVED. The same command on a clean tree now reports 50 and 1.
Phase 1 — one base spelling in the documented commands
| File:line | Documented base | Note |
|---|---|---|
AGENTS.md:124 |
main |
the contributor instruction |
workflow/skills/improve-loop/SKILL.md:106 |
main |
a routine executes this — auditCalendar.sunday |
docs/rollback/README.md:115 |
main |
|
workflow/lib/rule-delta.mjs:30 |
main |
usage header |
workflow/lib/comment-lint.mjs:32-33 |
main |
usage header |
workflow/lib/comment-fingerprint.mjs:32-33 |
main |
usage header — the third reader, missed by the first revision |
workflow/skills/finalize-pr/SKILL.md:124 |
origin/main |
already correct |
docs/cleanup.md:54 |
origin/main |
already correct |
workflow/skills/audit-code/comment-sweep.md:112 |
<branch-point> |
already correct |
Change the six wrong ones to origin/main.
Also reword AGENTS.md:129, which reads "Both are development tools, never run steps." Both are
run steps: improve-loop/SKILL.md:103-106 has the Sunday run execute rule-delta.mjs, and
audit-code/comment-sweep.md:68 has audit-code run ste-lint.py --json on three weekdays.
Keep what the sentence was reaching for — neither is part of the automated gate, which is
leanGate.command alone — and name the two runs that do execute them.
improve-loop/SKILL.md is a skill edit, so raise version in
workflow/.claude-plugin/plugin.json to 3.0.1 in the same commit — it is the install cache
key, main is at 3.0.0, and cut-release/SKILL.md:31-32 makes a fix a patch bump.
Phase 2 — the scripts derive their own baseline
origin/main is right for a stale local ref and still wrong when the base advances after the
branch point, which is this same defect mirrored: a rule the base gained reads as REMOVED, a rule
it dropped reads as ADDED.
rule-delta.mjs:116-124 (collectRef), comment-lint.mjs:180,186-190 and
comment-fingerprint.mjs:343,376-380 all take the named ref raw. Three changes, in each of the
three scripts:
-
Resolve a bare branch name to
refs/remotes/origin/<name>when that ref exists, and warn
once on stderr when the local ref differs from it.git merge-basealone does not fix this —
git merge-base main HEADreturned83a9b8ehere, because the stale ref is an ancestor.
Resolve to the remote ref first. -
Then take
git merge-base <resolved> HEADas the baseline, so commits the base gained
after the branch point stay out of the delta.comment-fingerprint.mjsalready documents its
base as<branch-point>(audit-code/comment-sweep.md:112) — same vocabulary. -
Fail loudly on a ref that does not resolve, with one message, in all three. Today they
diverge, and only one of the three is silent:Script --base no-such-reftodayWanted rule-delta.mjsNo directive disappeared.— exit 0one message, exit non-zero comment-lint.mjs20-line uncaught stack trace, exit 1 one message, exit non-zero comment-fingerprint.mjs39-line uncaught stack trace, exit 1 one message, exit non-zero collectRefswallows everygit showerror (rule-delta.mjs:120), so an unresolvable base
yields an empty before-set and a clean report. The other two throw from theirgit diff
(comment-lint.mjs:180,comment-fingerprint.mjs:343) before thebaseSrc = ''fallback is
ever reached, so that fallback is not the defect there — the missingcatchis.
Cover all three changes in a new workflow/lib/rule-delta.test.mjs, following
workflow/lib/budget.test.mjs. node --test workflow/lib/*.test.mjs passes 37 tests today.
One commit per phase, each named in the PR body. No ceiling change rides along.
Acceptance criteria
- Every documented
rule-delta.mjs,comment-lint.mjsandcomment-fingerprint.mjs
invocation names a base that is correct in a fresh routine clone, with no step beyond
start-runstep 6. - All three scripts are documented with the same kind of base ref.
-
AGENTS.md:129no longer says neither tool is a run step, and names the two runs that
execute them. -
versioninworkflow/.claude-plugin/plugin.jsonis3.0.1, because
improve-loop/SKILL.mdchanges. - A base ref that does not resolve makes all three scripts exit non-zero with one message:
rule-delta.mjsinstead of reporting a clean delta, the other two instead of a stack trace. - A bare branch name resolves to its remote counterpart, and warns when the local ref differs.
- Commits the base gained after the branch point no longer appear in the delta.
Verification checklist
- In a clone where
git rev-parse maindiffers fromgit rev-parse origin/main, the command
as written inAGENTS.md, run on a clean tree, printsNo directive disappeared.and
exits 0. -
grep -rn '\-\-base ' AGENTS.md docs workflow --include=*.md --include=*.mjsshows one base
spelling per script. -
node workflow/lib/rule-delta.mjs --base no-such-ref workflow/skillsexits non-zero and
prints one message, not a clean delta. -
node workflow/lib/comment-lint.mjs --base no-such-refand
node workflow/lib/comment-fingerprint.mjs --base no-such-refeach print one message, not a
stack trace. -
node --test workflow/lib/*.test.mjspasses. -
claude plugin validate ./workflow --strictpasses. -
node workflow/lib/rule-delta.mjs --base origin/main workflow/skillsaccounts for every
directive this PR removes.
Decisions
AGENTS.md:127-129callsrule-delta.mjsandste-lint.py"development tools, never run
steps", while a routine executes both. Which line is true? → Neither tool is a development
tool only.AGENTS.md:129is the wrong line, and Phase 1 rewords it; the two skill
instructions stand. This was a fact, not a decision — settled from
improve-loop/SKILL.md:103-106,audit-code/comment-sweep.md:68andauditCalendar
(settled from source, 2026-10-09)- Phase 2: resolve a bare name silently, or warn when the named ref is behind
origin/<name>? → Warn, once, on stderr, only when a remote counterpart exists and differs.
Silent resolution reads identically to today's bug: a run seeingNo directive disappeared.
cannot tell which ref it compared against, and that ambiguity is what produced the phantom
REMOVED line above. The warning also leaves the only trace a routine's journal can carry.
--base <sha>and--base <other-branch>stay unsurprising, because the warning fires only on
a divergent remote counterpart (bot recommendation, 2026-10-09)
Notes
Filed as an incidental finding by the adversarial review of #161. It is not
that PR's defect — that PR's own rule-delta line is correct, confirmed against origin/main —
and a critic never touches the branch, so it is a ticket rather than a fix there.
Nothing is broken at runtime. The cost is a wrong line in the PR body a human reads to adjudicate
rule removals, which is the one place rule-delta is supposed to be trustworthy.
Re-grounded against the code at ae51afe. Three skills were renamed since the first revision, so
every path in the previous body was stale: reflect → improve-loop, handler-preflight →
start-run, surveyCalendar → auditCalendar. The planned version 2.8.0 is also stale —
main is at 3.0.0.
workflow/skills/improve-loop/SKILL.md matches securityReview.triggerPattern, so the PR carries
a security review.
🤖 Written by the sydevs autonomous loop — see what this is
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Hold Until
Projects
- StatusShow more project fieldsDone
Activity
sydevs-bot commentedon Oct 6, 2026
🤖 no session running
recent dispatches
Written by the sydevs dispatcher. Sessions never edit this comment.
[-]fix(docs): rule-delta's documented `--base main` misreports in a routine clone[/-][+]fix(loop): rule-delta's documented base is wrong in a routine clone[/+]sydevs-bot commentedon Oct 6, 2026
Revised from the code. The defect reproduces here:
--base mainexits 1 on a clean tree identical toorigin/main.workflow/skills/reflect/SKILL.md:105is one a routine runs on Sunday — exactly the stale-clone case.handler-preflightstep 6 does not moverefs/heads/main.No directive disappeared., verified with--base no-such-ref.origin/mainis still wrong once the base advances past the branch point.git merge-base main HEADdoes not rescue a stale ref. Resolve to the remote ref first.## Approach.Retitled the scope
docs→loop, since the work now touchesworkflow/lib. Type staysBug. EffortEasy→Moderate.@sydevs-bot implementstarts the work.🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
Ardnived commentedon Oct 9, 2026
@sydevs-bot implement
3 remaining items
[-]fix(loop): rule-delta's documented base is wrong in a routine clone[/-][+]fix(loop): three base-ref scripts trust a stale local main[/+]sydevs-bot commentedon Oct 9, 2026
Both open questions were facts, not decisions. Settled from source, now in
## Decisions.1. "Development tools, never run steps" —
AGENTS.md:129is the wrong line. The Sunday run executesrule-delta.mjs(improve-loop/SKILL.md:103-106), andaudit-coderunsste-lint.py(comment-sweep.md:68). Phase 1 rewordsAGENTS.md.2. Silent resolution, or a warning — warn once, on stderr, only when a remote counterpart differs. Silence reads like the bug: a clean report never says which ref it compared.
Re-grounded at
ae51afe:reflect→improve-loop,handler-preflight→start-run,surveyCalendar→auditCalendar.comment-fingerprint.mjs:32-33. Three scripts read a base ref, not two.rule-deltaexits 0 on an unresolvable ref. The other two throw an uncaught stack.2.8.0→3.0.1.mainalready reads3.0.0.Retitled for scope.
No open questions remain.
@sydevs-bot implementstarts the work. Either call is onereviseaway.🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
Ardnived commentedon Oct 10, 2026
@sydevs-bot implement
fix(loop): three base-ref scripts trust a stale local main (#175)