Skip to content

fix(sync): the gitlink sync never opened a PR — its gate diffed the wrong thing - #73

Merged
atrawog merged 2 commits into
mainfrom
fix/sync-gate-diffs-wrong-thing
Aug 31, 2026
Merged

atrawog merged 2 commits into
mainfrom
fix/sync-gate-diffs-wrong-thing

Conversation

@atrawog

@atrawog atrawog commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The daily gitlink sync has been running green and doing nothing. Its change gate diffs the
wrong thing, so it reports "nothing to sync" precisely when it has work to do.

One line changed: git diff --quiet → git diff --quiet HEAD.

Root cause

Two facts that are individually fine and fatal together:

where what
scripts/sync-gitlinks.sh:33 git add "$path" — every bumped gitlink is staged
.github/workflows/sync.yml:30 if git diff --quiet — compares worktree against index

git diff with no revision does not look at the index against HEAD; it looks at the worktree
against the index. Since the script stages everything it changes, a successful sync leaves
nothing unstaged, the gate sets changed=false, and both the "Skip if a sync PR is already open"
and PR-creation steps are if:-gated off.

The automation is therefore a no-op exactly when it has work, and exits 0 either way — the
failure shape where a step reports success having done nothing. It is also why every gitlink sync
that has actually landed (#66, #67, #68) was opened by hand, against a rulebook that says the
fix for a stale pin "is a sync (task sync + PR), not a hand-pin".

How tested

1. The live run that exposed it. Run 33360266234, dispatched 2026-08-31T05:21Z with three
repos demonstrably drifted. The "Bump pins" step computed the correct new pin:

== charly (default-branch HEAD) ==
  charly -> 0443e07

and the run still finished success with no PR, leaving the umbrella pinned at 1d0164f0
while charly's default-branch HEAD was 0443e073 — a straight policy-B violation
(README line 53: "charly → its own default-branch HEAD (main)").

2. The git semantics, reduced to a reproduction. In a scratch repo, stage a modification, then:

git diff --quiet          -> exit 0    "nothing to sync"
git diff --cached --quiet -> exit 1    there IS a change
git diff --quiet HEAD     -> exit 1    there IS a change
git status --porcelain    -> "M  f"

3. The fixed workflow, executed before merging. workflow_dispatch can run a workflow from a
branch, so this was not left as a claim — run
33360774123 ran sync.yml
from fix/sync-gate-diffs-wrong-thing. The gate now fires: the run proceeded past the dirty
check and the already-open-PR check, all the way into the PR-creation step, which the old gate had
never reached. It then failed there:

Open sync PR: pull request create failed: GraphQL: GitHub Actions is not
permitted to create or approve pull requests (createPullRequest)
##[error]Process completed with exit code 1

That is a second, independent defect this change exposed rather than caused — and reaching it
is itself proof that the gate is fixed, because with git diff --quiet the job skipped that step
every time.

4. End to end, after the second blocker was cleared. With
can_approve_pull_request_reviews enabled, the same workflow was dispatched again from the same
branch — run
33361509708:

status=completed  conclusion=success
→ opened opencharly#75  "chore: sync gitlinks"  (branch sync/20260831-054851)

That is the first sync PR this workflow has ever opened. It carries the real drift, including
charly and plugin-wl, which had been stale on main.

The second blocker — found here, cleared separately

The sync was disabled twice over: a gate that never fired, hiding a permission that was never
granted. Measured:

$ gh api repos/opencharly/opencharly/actions/permissions/workflow
{"default_workflow_permissions":"read","can_approve_pull_request_reviews":false}
$ gh api orgs/opencharly/actions/permissions/workflow
{"default_workflow_permissions":"read","can_approve_pull_request_reviews":false}

The workflow already declares permissions: pull-requests: write, so the job-level grant is not the
problem — the org/repo toggle "Allow GitHub Actions to create and approve pull requests" is off.

The toggle is not flipped in this diff, on purpose — it bundles create with approve, so
enabling it also lets any workflow approve pull requests, which against a repo that auto-merges on
a PASS verdict is a review-bypass surface. That is a security decision for a human, not a side
effect of a one-line CI fix. It was put to the maintainer explicitly and enabled org-wide by their
decision, as a separate settings change:

$ gh api orgs/opencharly/actions/permissions/workflow
{"default_workflow_permissions":"read","can_approve_pull_request_reviews":true}

(The umbrella repo carried its own override reading false, which shadows the org value, so it was
set at both levels.) The re-run above is what that unblocked.

Worth stating plainly: even without the settings change this diff would be worth landing, because
it turns a silent no-op into a loud, actionable failure. Before it, the sync reported success
while pins drifted; after it, it says exactly why it cannot proceed.

4. The workflow still parses — yaml.safe_load on the changed file.

Why HEAD and not --cached

git diff --cached --quiet would also fix today's bug, but it would break the moment
sync-gitlinks.sh stopped staging — swapping one silent-disarm for its mirror image. Comparing
against HEAD sees staged and unstaged alike, so the gate stays correct regardless of what the
script does with the index. The comment added above the gate records both halves so the next reader
does not "simplify" it back.

Rulebook compliance

  • R1 — RCA every anomaly. The empty sync run was root-caused to the diff form rather than
    written off as "nothing had changed"; the diagnosis was confirmed against a live run whose own log
    shows it computing a pin it then discarded.
  • R3 — no duplication. One gate, one line; no second dirty-check introduced beside it.
  • R4 — no workarounds. The fix is the gate, not another hand-opened sync PR — which is exactly
    the workaround this defect has been forcing for weeks.
  • R6 — git safety. Working tree checked before staging and clean after commit; fix/ branch off
    a fresh clone; no force-push, no direct push to main, no hook bypass.
  • R7 — prove the gate, not the plan. The changed workflow was dispatched from its own branch and
    its output pasted above, rather than reasoned about.
  • R10 — fresh disposable proof. The verification run is a fresh CI run from the committed branch,
    on a clean runner.

Change classification

  • Change class: CI workflow — one condition in the sync job's dirty gate, plus the comment
    explaining it. No scripts, no pins, no submodules, no Go.
  • Verification gate: the workflow itself, dispatched from this branch twice — once to prove the
    gate now fires (run 33360774123, which reached the PR-creation step it had never reached) and
    once end to end after the permission was granted (run 33361509708, success, which opened
    #75).
  • Breaking change + rollback: none. Rollback restores a sync that silently never fires.
  • Producer → consumer order: self-contained.

Attribution tier: fully tested and validated — the changed workflow ran green on a real runner
from this branch and produced the artifact it exists to produce, a chore: sync gitlinks PR
(#75), which is the first this workflow has ever opened.

One consequence to note before merging

#75 was produced by dispatching the workflow from this branch, so its sync branch was cut from
this branch and its diff contains this sync.yml change alongside the gitlink bumps. That makes it
a poor changelog for either concern. The clean sequence is: land this focused PR first, then
re-dispatch from main so the next sync PR is gitlinks only — and close #75 rather than merge it.
Noted here so a reviewer does not read the overlap as an accident.


Assisted-by: Claude Code claude-opus-5[1m] (fully tested and validated)

…hing

The daily sync workflow has been running green and doing nothing. Its change
gate is

    if git diff --quiet; then changed=false

and `git diff` with no revision compares the WORKTREE against the INDEX, while
scripts/sync-gitlinks.sh line 33 does `git add "$path"` for every gitlink it
bumps. A sync that changed something therefore leaves nothing UNSTAGED, the gate
reads changed=false, and the PR step is skipped.

So the automation is a no-op exactly when it has work to do, and reports success
either way. That is why every gitlink sync that has actually landed was opened by
hand.

Measured on run 33360266234 (dispatched 2026-08-31T05:21Z, with three repos
demonstrably drifted): the "Bump pins" step computed the correct new pin —

    == charly (default-branch HEAD) ==
      charly -> 0443e07

— and the run still finished with no PR, leaving the umbrella pinned at 1d0164f0.

The git semantics, reduced to a two-line reproduction:

    (stage a modification, then)
    git diff --quiet          -> 0   "nothing to sync"
    git diff --cached --quiet -> 1   there IS a change
    git diff --quiet HEAD     -> 1   there IS a change

Fix: gate on `git diff --quiet HEAD`, which sees staged and unstaged alike, so a
future change to whether the script stages cannot silently disarm the workflow
again.

Claude-Session: https://claude.ai/code/session_01Gf42A3bau77JigFYLALrnq
@github-actions

Copy link
Copy Markdown
Contributor

Review — PASS

Head SHA: 37c0210c1334 (branch: fix/sync-gate-diffs-wrong-thing)

Security screen: PASS — single-line CI condition fix (git diff --quiet → git diff --quiet HEAD) plus explanatory comment; no scope mismatch, no secrets/exfiltration, no weakened guardrails, no supply-chain change. The change strengthens the sync gate (turns a silent no-op into a loud failure) rather than loosening anything.

Checklist: All applicable rules PASS or NA.

  • A1/A2/A3: Body fully accounts for the one changed file; How-tested names the workflow gate, the fresh branch-dispatched run, live execution of the changed path (run 33360774123 reached the PR-creation step), and pasted output. Attribution tier analysed on a live system is honest and not inflated — the end-to-end gate did not go green and the body explicitly does not claim it did.
  • B5 (R1): Both anomalies (empty sync run, permissions failure) root-caused with real evidence; no flake/transient framing.
  • B6 (R2): The second blocker (org/repo "allow Actions to create PRs" toggle) is a GitHub setting, not code — not fixable in-tree via a PR, and it is a security decision (bundles create+approve) requiring human sign-off. The body names the exit this PR advances (silent no-op → loud actionable failure) and does not park it as vague follow-up.
  • B7/B8/B10/B15: No duplication, no workaround, one atomic commit, no dead-code sweep needed.
  • B16: Placement correct — a workflow condition belongs in .github/workflows/sync.yml; no core/sdk/candy layer involved.
  • B12/R10: Verification is the workflow itself dispatched from the branch; pasted outputs are internally consistent (gate now fires, reaching the previously-unreachable PR-creation step). No new functionality lacking a test — the gate run is the proof.
  • B13/B17/B18: N/A (no candy/schema/Go, no resource destroy, no Go code).

Verdict: PASS


ollama/deepseek-v4-flash — pi-review-action.

View action run

@github-actions

Copy link
Copy Markdown
Contributor

Review — PASS

Head SHA: e9a50200264a (branch: fix/sync-gate-diffs-wrong-thing)

Change class: CI workflow — one condition in the sync job's dirty gate (git diff --quiet → git diff --quiet HEAD) plus an explanatory comment.

Security screen: PASS — single-line gate fix that strengthens the sync (turns a silent no-op into a loud failure); no scope mismatch, no secrets/exfiltration, no weakened guardrails, no supply-chain change.

Checklist: All applicable rules PASS or NA.

  • A1/A2/A3: Body fully accounts for the one changed file; How-tested names the workflow gate, the branch-dispatched runs, live execution of the changed path (run 33360774123 reached the previously-unreachable PR-creation step; run 33361509708 succeeded end-to-end and opened #75), with pasted output. Attribution footer present in the required form; tier fully tested and validated is justified — the changed gate executed live and the end-to-end run went green.
  • B5 (R1): Both anomalies (empty sync run, permissions failure) root-caused with real evidence; no flake/transient framing.
  • B6 (R2): The second blocker (org/repo "allow Actions to create PRs" toggle) is a GitHub settings change that cannot be fixed in-tree via a PR; the body documents it was actually resolved by maintainer decision (not parked as vague follow-up) and names the exit this PR advances.
  • B7/B8/B10/B15: No duplication, no workaround, one atomic fix commit (plus a main merge), no dead-code sweep needed.
  • B16: Placement correct — a workflow condition belongs in .github/workflows/sync.yml; no core/sdk/candy layer involved.
  • B12/R10: Verification is the workflow itself dispatched from the branch; pasted outputs are internally consistent (gate now fires, reaching the previously-unreachable PR-creation step, then succeeding end-to-end). No new functionality lacking a test — the gate run is the proof.
  • B13/B17/B18: N/A (no candy/schema/Go, no resource destroy, no Go code).

Comment intake: One prior github-actions[bot] PASS review (head 37c0210c1334). Re-derived against the current diff — the change is unchanged (one line + comment), so its findings remain valid. verified-non-blocking.

Verdict: PASS


ollama/deepseek-v4-flash — pi-review-action.

View action run

@atrawog
atrawog merged commit aa67a09 into main Aug 31, 2026
1 check passed
@atrawog
atrawog deleted the fix/sync-gate-diffs-wrong-thing branch August 31, 2026 05:55
charly-auto-merge Bot added a commit that referenced this pull request Aug 31, 2026
@atrawog atrawog mentioned this pull request Aug 31, 2026
atrawog added a commit that referenced this pull request Aug 31, 2026
…an pass A1 (#78)

* fix(sync): open the PR with the org's bot app, not the default token

#73 fixed the gate so the sync finally reaches its PR step. That step then failed:

    pull request create failed: GitHub Actions is not permitted to create or
    approve pull requests (createPullRequest)

The obvious unblock is the org toggle `can_approve_pull_request_reviews`, and it
does work -- but marketplace's refresh.yml already warns against exactly that, in
as many words:

    Do NOT 'fix' it by enabling can_approve_pull_request_reviews
    -- that also lets workflows approve PRs.

The warning is right: the toggle bundles create with approve, and this org
auto-merges on a PASS verdict, so granting approve to every workflow is a
review-bypass surface.

refresh.yml already solves this properly by minting a short-lived GitHub App
token, and the org secrets it uses (CHARLY_AUTO_MERGE_APP_ID /
CHARLY_AUTO_MERGE_PRIVATE_KEY) are present. This adopts the identical pattern --
same SHA-pinned action, same secrets, same fallback -- so the umbrella stops
being the one repo that needed a security toggle to do what its sibling already
does safely.

The toggle was enabled earlier in the session to unblock the sync before this
pattern was found; it is turned back off, and the verification run below is with
it off, which is what proves the app token rather than the toggle is doing the
work.

Claude-Session: https://claude.ai/code/session_01Gf42A3bau77JigFYLALrnq

* fix(sync): the sync PR body cannot pass A1 — name every moved gitlink

With the App token in place the workflow finally opened a PR that CI could see
(#76). It was immediately BLOCKed:

    A1 — scope mismatch / incomplete body. The PR title is "chore: sync gitlinks"
    and the body says only "Automated sync of all umbrella submodule pins to
    policy B".

79 submodules moved and the body named none of them. A one-line body cannot
satisfy "every diff item accounted for", so the automation would have kept
producing unmergeable PRs — the same defect class marketplace's refresh.yml has,
where a count stood in for an accounting.

The body now:

- names every moved gitlink, captured from `git diff --cached --name-only` after
  staging so the list is exactly what commits
- explains what those entries ARE -- submodule pointers, whose content was gated
  by each owning repo's own pr-validator before tagging, and which this PR
  therefore cannot review and does not restate
- states the gate (`scripts/verify-pins.sh`, which fails closed on a dangling
  pin, a dirty submodule, or a policy-B violation) and the producer
- carries no `Assisted-by:` footer, with the reason given inline: A1 requires it
  on an AI-authored body, this one is emitted by a fixed block with no model in
  the loop, and inventing a model name to satisfy the pattern would be the false
  claim the rule exists to prevent

`git add -A` is deliberately kept before the capture. sync-gitlinks.sh already
stages each bumped gitlink, but dropping the add would silently narrow what the
sync commits to whatever the script happened to stage.

Claude-Session: https://claude.ai/code/session_01Gf42A3bau77JigFYLALrnq

---------

Co-authored-by: atrawog <[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