Skip to content

fix(pipeline): check that the token may publish before the first model call - #285

Merged
goldbarth merged 1 commit into
mainfrom
fix/publish-token-preflight
Sep 30, 2026
Merged

goldbarth merged 1 commit into
mainfrom
fix/publish-token-preflight

Conversation

@goldbarth

Copy link
Copy Markdown
Owner

Closes #262

  • Why: generate found out that the token could not publish only in its last step, after every model call. A read-only token, or none, paid for the whole run and then ended on Not published:.
  • The check is POST releases/generate-notes: GitHub requires Contents write for it and stores nothing, so it answers "may this token write releases?" without writing one. It costs one GitHub request. The answer is discarded.
  • Port, not a pipeline detail: IReleaseNotesWriter.EnsureCanWriteAsync sits next to WriteAsync, so the platform decides how to ask, and chartula doctor (chartula doctor: check the setup before the first run #254) can reuse the same check.
  • Only generate checks: preview and generate --no-publish publish nothing, so they do not ask and still run without a token.
  • After the range confirmation, before the pull requests are read: the confirmation stays ahead of the first API request, as feat: render a first tag from the first commit, and confirm a large range before it is read #282 set it up, and a refused token stops the run before the per-commit requests and the model calls.
  • Same message as a refused publication, worded as a check: GitHub does not let this run publish ... instead of GitHub refused to publish ..., since nothing was sent. The pipeline adds that the run stopped before any model call and names --no-publish.
  • The late failure path stays: GitHub can still refuse the write for a reason the check cannot see, and the run then keeps the written files and reports Not published: as before.
  • docs/github.md and docs/cli.md describe the check (roadmap follow-up 2.3, the generate finds out the token cannot publish only after every model call #262 part).

Reproduced and verified end to end against goldbarth/chartula v0.1.0-preview.3, GITHUB_TOKEN unset, local Ollama (qwen3:14b-ctx24k), --audience technical, in a scratch clone:

Before, on main:

Not published: the release notes.
  GitHub refused to publish the release notes for v0.1.0-preview.3 to goldbarth/chartula (401 Unauthorized).
    The request carried no token: GITHUB_TOKEN is not set.
    Publishing needs a token with Contents read and write on goldbarth/chartula.
  ...
  Total:            8,889 tokens in 7.1 s

After, on this branch:

Range:  the commits after v0.1.0-preview.2, up to v0.1.0-preview.3 (7 commits)
Error: GitHub does not let this run publish the release notes for v0.1.0-preview.3 to goldbarth/chartula (401 Unauthorized).
  The request carried no token: GITHUB_TOKEN is not set.
  Publishing needs a token with Contents read and write on goldbarth/chartula.
  The run stopped before any model call. --no-publish writes the files without publishing them.

Exit 1, no run record, no file written. The same run with --no-publish renders and writes as before.
The endpoint itself, checked with curl: 200 with a token that can write, 401 without a token, 404 with a token on a repository it cannot write to. A tag GitHub does not know still answers 200.

Tests: ReleasePipelineTests (a refused check stops before rendering and writing, preview and --no-publish do not check, generate checks once and publishes), GitHubReleaseNotesWriterTests (a token that may write, one that may not with the permission GitHub names, no token). Full suite passing, build without warnings, dotnet format clean.

@goldbarth goldbarth self-assigned this Sep 30, 2026
@goldbarth
goldbarth merged commit 633a521 into main Sep 30, 2026
4 checks passed
@goldbarth
goldbarth deleted the fix/publish-token-preflight branch September 30, 2026 11:38
goldbarth added a commit that referenced this pull request Sep 30, 2026
…n stops (#299)

Follows #298, which added `docs/costs-and-checks.md`, the page this one
takes the diagnosis sections from.

- **Why:** the messages a run stops with were spread over `cli.md`,
`github.md`, `configuration.md`, `what-goes-into-a-release.md` and
`run-metrics.md`, each explained where its topic lives, but nothing let
a user start from the message. `docs/troubleshooting.md` is that entry:
message, cause, fix, with a link to the page that explains more.
- **It opens with `chartula doctor`,** which finds most of the setup and
range situations before anything is spent, and says which ones it cannot
find (a spent rate limit, a first tag, everything that only shows once
the model writes a whole release).
- **The situations:** no model key; GitHub cannot read the repository
(404); a rejected token (401); a token that cannot publish, which stops
`generate` before its first model call (#285); the rate limit, with and
without a token; a configuration error; a shallow clone; a first tag
without a terminal; a failed model call by status (404, 401 with and
without a key, 403), an unreachable endpoint, and an answer the SDK
cannot read, kept apart from an unreachable one (#288); an answer that
does not match the facts; an answer cut off at `maxOutputTokens`; a
context window too small; a thorough check that verified nothing; a slow
run, read from the progress lines (#297) and the run summary.
- **Every message is from a real run of the built binary,** in a scratch
repository, with GitHub and the model served by a local stub (a mode per
case: 404, 401, rate limit with `x-ratelimit-remaining: 0`, 403 with
`x-accepted-github-permissions`, model 404/401, an unknown
`finish_reason`, a reported prompt of 120 tokens, prose instead of a
verdict, a cut answer, a 4 s delay per call). Paths are anonymized to
`/work/my-repo`, the stub's address to `https://api.github.com/` and
`http://localhost:11434/v1`. The line after `The endpoint said:` came
from the stub, so the page shows it as `...` and says its wording
depends on the provider. The slow run's summary is the real local run
from the chartula-evals sweep already used in #298.
- **One home per explanation:** a message appears here and, where it has
one, on the page that explains its topic; the explanation itself stays
there and is linked. From `cli.md`, the status-by-status account of a
failed model call and the missing-key example move here and are replaced
by links. From `costs-and-checks.md`, the three diagnosis sections (slow
run, unreadable check, cut prompt) move here; the summary page keeps a
short list of the lines that point to a problem, each linking its
section.
- **A message corrected on the way:** the warning without a GitHub token
said a run spends "roughly one [request] per pull request". It spends
one per commit in the range, as `docs/github.md` says, so a release
merged with merge commits was underestimated. The class comment also
still claimed that an exhausted limit fails with a 403 naming a commit;
the run names the rate limit (`GitHubErrorResponse.cs`). Both are
corrected in `GitHubTokenNotice.cs`.
- **README:** Troubleshooting joins the "Setting it up" index;
`getting-started.md` links it under "Next".

**Verified:**
- Every case ran with the binary built from this branch; the outputs
match the page, and the corrected no-token warning was rerun after the
fix.
- Every relative link and anchor in all Markdown files of the repository
resolves (script, with a negative test).
- `dotnet build -c Release` without warnings, `dotnet format
--verify-no-changes` clean.

Tests: full suite passing (920), no test changed; no test asserts the
warning's wording.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01BQ1Z71j4Q2W1CwGYjF55No

---
_Generated by [Claude
Code](https://claude.ai/code/session_01BQ1Z71j4Q2W1CwGYjF55No)_

Co-authored-by: Claude <[email protected]>
goldbarth added a commit that referenced this pull request Oct 7, 2026
Follows #344. Step 1 of `docs/development/releasing.md`.

- **Why now:** the launch points are merged, and the binary people
install is still `0.1.0-preview.3`, which has none of them. The
announcement needs a release that holds what the README and the docs on
`main` describe.
- **What ships since preview.3,** 63 commits:
- a first run: `chartula doctor` (#295, grouped in #341), `chartula
--version` (#286), a free `preview` (#292), progress while a run works
(#297, with a spinner and `--plain` in #340), a first tag from the first
commit with a confirmation for a large range (#282);
- what a release contains: commits without a pull request (#291), issue
numbers at every depth (#293), a sentence for a release with nothing for
developers (#307 in #333);
- checks and prompts: pull request text quoted and bounded (#338), no
false flag for a wrapped phrase or a fenced block (#336), flags set
apart from the entries (#331);
- publishing: the token checked before the first model call (#285), a
published release not replaced unless asked (#335);
- the files: `changelog.json` without descriptions and readable as text
(#294, #332).
- **Breaks to state in the notes,** as `docs/versioning.md` asks of a
preview:
- `changelog.json` is schema version 2: a change's `description` is gone
(#294). The run record is schema version 3 and holds the complete facts.
- `generate` stops on a tag whose release is already published;
`--replace-published` restores the old behaviour (#335).
- An option a command does not take stops the run (#301), and
`--whole-history` is gone (#282).
- The terminal output changed form (#340 to #342): the summary's first
line, audience headings in place of `--- Technical ---`, and `doctor`'s
last line. A script that reads those lines needs a look; exit codes and
the files are unchanged.
- The csproj `Version` is the single source; nothing else carries the
number.

**After merge:** tag the merge commit on `main` with `v0.1.0-preview.4`
and push it; `release.yml` builds the draft, `chartula generate --tag
v0.1.0-preview.4` writes the notes into it, and publishing runs
`install.yml`. The pinned `v0.1.0-preview.3` in `docs/ci.md` and
`docs/install.md`, and the template link in the `doctor` samples, move
to the new tag once the release exists, with the changelog pull request
of step 6.

**Verified:** the built CLI prints `chartula 0.1.0-preview.4+<commit>`.

Tests: no test changed. Full suite 1,010 passing, build without
warnings.
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.

generate finds out the token cannot publish only after every model call

1 participant