Skip to content

fix(sync): print counts only in the template-sync open job's log - #160

Merged
giulmonte merged 2 commits into
mainfrom
fix/sync-log-counts
Nov 24, 2026
Merged

giulmonte merged 2 commits into
mainfrom
fix/sync-log-counts

Conversation

@enri3l

@enri3l enri3l commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

What and why

This repository is public, so the log of the template-sync.yml open job is readable by anyone. I read the log of a real run, not only the scripts. It held more than the known template-sync-pr.sh lines, and an invariants review of the first version of this PR found more that still leaked under CI.

What the log showed, and what is fixed (in a workflow run, GITHUB_ACTIONS=true):

  • The --write step printed the full comparison table and a finding line per stale file, with its path and how far it is out of date. It now prints only refreshed N copies.
  • template-sync-pr.sh printed the repository, the file list, the branch, the title, a git diff --stat table and the commit authors of an older pull request. It now prints N file(s), M bytes.
  • Its refusals printed the paths (none is sent: ..., got: ..., the modes). They now say how many.
  • A failed gh call printed gh's own message, which holds the repository, the branch and the title: the commit call, gh pr create, gh pr view, gh pr close (which also reports the title and the deleted branch) and every other call. In a workflow gh's stderr is dropped and the script says only that a call failed. The commit errors are counted.
  • template-sync.mjs error messages (repository missing or private, a read that failed with gh's first line, a template that could not be rendered) name no repository, file or gh text under CI, in the plan job too (--json, no --write). One flag, redact, decides that.
  • A copy held back because its refresh would rename a job is not mentioned in a workflow log. It would tell an outsider which repository renamed a required check.

Run by hand, all of it is unchanged: that is the audit view.

What the log still shows, and why

What Why
The repository being refreshed The step environment, the token action's inputs and actions/checkout print it, not these scripts. The names are already public in sync.json.
That a leg ran for it A leg exists only for a repository with a stale copy, so its existence says that one is behind. Not which file, how far, or why.
The URL of the pull request it opened The script prints it itself and it holds the repository name. The pull request is public in the other repository.

Known, left as it was

  • An uncaught error (for example from jq) exits 1, the same code as a refusal, and can print what the tool prints. The script has no ERR trap and does not use the 3-versus-gh-code convention of template-sync.mjs. Both predate this change.
  • The three process substitutions in template-sync-pr.sh.

How you checked it

  • tests/sync-log-public.test.mjs is a behavioural ratchet. It runs template-sync-pr.sh in CI mode against a stub gh that puts a distinctive repository, file, branch, title and author into everything it prints and every error, through the success path, an existing pull request, an older pull request closed and left open, and nine failing calls, plus the refusals. None of those strings may reach stdout or stderr (the URL line is taken out first). The same runs by hand must show them, so the check could have failed. A static backstop makes a new $ expansion in a print statement reviewed.
  • tests/template-sync-cli.test.mjs drives template-sync.mjs through a private repository, a missing one, a failed read and an unrenderable template with each option set (--write, --json, --check, none).
  • Against the scripts on main, 27 of the new tests fail. The full node --test "tests/*.test.mjs" run passes 461 of 461, both with GITHUB_ACTIONS unset and with it exported as true. shellcheck, actionlint and node design/source/docs-kit/build.mjs --check pass.
  • gh pr close --help does not say what it prints or on which stream, so both streams are silenced under CI instead of guessed.
  • tests/sync-log-public.test.mjs is wired into the stop hook, so editing either script or either workflow runs it.
  • Rebased onto main after feat(sync): refresh a repository's extra copies of a starter #159 (the twins change) merged: no conflicts. Its tests go through runSync and sync_, so GITHUB_ACTIONS is cleared for them.

Checklist

  • The repository's full check passes (the docs check and the full test run, locally)
  • Every commit is signed off (git commit -s) and signed
  • The title is a Conventional Commit: fix(sync): print counts only in the template-sync open job's log
  • New behaviour has tests, and a bug fix has a regression test
  • Visual or docs changes follow m3l-design: one paragraph and one table of wording

Not done: I did not run the real sync, so the first scheduled run is the live test of the new log.

🤖 Generated with Claude Code

@enri3l
enri3l requested a review from giulmonte as a code owner November 24, 2026 11:29
@github-actions github-actions Bot added area:blueprint Org blueprint and the baseline script area:docs Documentation and the docs site labels Nov 24, 2026
giulmonte
giulmonte previously approved these changes Nov 24, 2026
enri3l and others added 2 commits November 24, 2026 15:05
The log of a public repository is readable by anyone. A --write run in a workflow printed the
full comparison table and a finding line per stale file, and template-sync-pr.sh printed
the file list. In a workflow run (GITHUB_ACTIONS=true) both print counts only now. By hand
they keep the full detail, which is the audit view.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Enrico Lionello <enri3l@monte3l.com>
The review found paths that still printed names under CI: the refusal messages, the commit
call's stderr and errors, gh pr close and gh pr create, and the error messages of the plan job.
They now say how many, or only that a call failed. A --write leg prints only how many copies
it refreshed, and a copy held for its job names is not mentioned. By hand nothing changes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Enrico Lionello <enri3l@monte3l.com>
@enri3l
enri3l force-pushed the fix/sync-log-counts branch from 88baf60 to 91e2c80 Compare November 24, 2026 14:10
@github-actions github-actions Bot added the area:harness Claude Code harness: rules, skills, agents, settings label Nov 24, 2026
@enri3l
enri3l requested a review from giulmonte November 24, 2026 14:13
@giulmonte
giulmonte merged commit f9fe56d into main Nov 24, 2026
12 checks passed
@giulmonte
giulmonte deleted the fix/sync-log-counts branch November 24, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:blueprint Org blueprint and the baseline script area:docs Documentation and the docs site area:harness Claude Code harness: rules, skills, agents, settings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants