Skip to content

fix(op): the gate's ledger write survives a CI checkout, and says so when it does not (#2301, #2303) - #2309

Merged
lex00 merged 3 commits into
mainfrom
fix/2301-gate-ledger
Sep 9, 2026
Merged

lex00 merged 3 commits into
mainfrom
fix/2301-gate-ledger

Conversation

@lex00

@lex00 lex00 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Three failures of one mechanism — the gate's commit on chant/lifecycle — all found by the first real execution of a generated Op pipeline on GitLab CE 17.11 (INTENTIUS/choudoufu#1026).

Why one PR

These were assigned as two issues and are delivered as one PR, because they do not separate cleanly:

#2301 — the write fails with no error text at all

Deliverable 1, the identity. CI checkouts on all three forges clone without user.email or user.name, and git commit-tree refuses rather than inventing one. writeBlobToPath now supplies chant's own — chant <chant@localhost> — through git -c on that one invocation, and only when git var GIT_COMMITTER_IDENT says the checkout cannot name a committer itself. A configured identity is never overridden, so existing commits are byte-identical; nothing is written into the repository's config. CHANT_LIFECYCLE_COMMITTER_NAME / _EMAIL repoint it at a project's own bot account.

This sits in core's single git-plumbing path rather than in the three generated dialects, so github and forgejo — named in the issue as untested and needing to be — are fixed by the same change as gitlab, and a project that generated its pipeline before this needs no regeneration.

Deliverable 2, the silence. This turned out to be a general error-swallowing bug in the Op executor, not something local to the gate. Two causes, one inside the other:

  1. runGateStep was the only step kind that could throw instead of returning a record. runStep has always turned an activity's throw into a failing StepRecord carrying the message ("Never throws — returns a record"); the gate did not, so a git failure unwound the phase loop leaving no record of itself.
  2. runOpLocally's catch unpacks PhaseFailure and GateStop and nothing else. Every other error was used to build an OpRunFailure and then never referenced again — err was dead after that line. Since renderHuman prints text only from records, the cause reached nobody.

Both are closed. A gate that cannot be decided is a failing step like any other; any error the catch does not recognise becomes a synthetic failing record carrying its message, with the original on OpRunFailure.cause. The compensation loop had the same swallow one level down and gets the same treatment. Anything thrown between the phases was equally invisible — the gate is where this was found, not the only thing it hid. The component driver's parallel path was checked and already re-throws what it does not recognise, so it needed no change.

Also: writeBlobToPath's failures now name what was being written and where, and runtimes/local.ts declared no onLedgerError, so a run-ledger append dying for the identical reason was caught and dropped. It warns now.

#2303 — approve-then-re-run, and the force-write

Finding 1. A GitLab CI checkout has no chant/lifecycle, and an absent branch reads exactly like an empty ledger. A retried job recorded a second pending fact and gated again. gitGateLedgerPort.read now fetches the branch first. fetchLifecycleStatus distinguishes the four outcomes a boolean could not — fetched, no-remote (single-machine, local is authoritative), absent (a real empty ledger; a first gate must not be refused), and unreachable / diverged, where LifecycleLedgerUnreadableError refuses by name rather than guessing.

Finding 2, the serious one. writeBlobToPath builds its commit from readTree, which on a checkout with no local branch returns an empty tree and a null tip — so the append parented on nothing and wrote a new root commit replacing the branch. The update-ref CAS did not catch it, because the assertion it makes ("the ref does not exist") was perfectly true locally. recordGateApproval and --expire now call requireLifecycleLedgerWritable first; with real history in the checkout the append parents on it, and the guard refuses outright on divergence.

Proof

packages/core/src/op/gate.test.ts is new and runs against real git: a bare remote, an authoring clone, and a --single-branch clone standing in for the CI checkout (the closest local equivalent of GitLab's refspec fetch). Every assertion was shown red by a deliberate tamper before it went green.

#2301, identity — reverting identityArgs from the commit-tree invocation:

FAIL packages/core/src/op/gate.test.ts > op/gate — a CI checkout with no git identity (#2301) > records the pending fact anyway, under chant's own committer
Error: cannot write _gates/live-apply.jsonl on the chant/lifecycle branch: git commit-tree failed: Author identity unknown

*** Please tell me who you are.
...
fatal: no email was given and auto-detection is disabled

#2301, the error naming — reverting ledgerWriteError to the bare ${stage} failed: ${stderr}:

AssertionError: expected [Function] to throw error matching /cannot…/live-apply\.jsonl on the chant\ but got 'git hash-object failed: fatal: not a …'

- Expected:
/cannot write _gates\/live-apply\.jsonl on the chant\/lifecycle branch/

+ Received:
"git hash-object failed: fatal: not a git repository (or any of the parent directories): .git"

#2301, the swallow — reverting runGateStep's catch:

FAIL ... > a gate whose ledger write fails is a failing step carrying the cause
AssertionError: expected undefined to be 'fail' // Object.is equality

- Expected:
"fail"

+ Received:
undefined

and with the outer backstop reverted as well, the rendered output is the reported symptom exactly — a completed step, then a bare failure line, and no cause:

AssertionError: expected [ '[phase] Plan', …(2) ] to deeply equal []

+ [
+   "[phase] Plan",
+   "  ✓ plan()   0ms",
+   "Op \"test-op\" failed after 0.0s",
+ ]

Compare the issue's report:

[phase] Plan
  ✓ terraformPlan(root=estate, planFile=chant.tfplan)   21.1s
Op "live-apply" failed after 43.8s

#2303 finding 1 — reverting the requireLifecycleLedgerReadable call in gitGateLedgerPort.read. The approve-then-re-run loop does not close:

FAIL ... > finding 1: approve then re-run closes the gate, without a second pending fact
AssertionError: expected false to be true // Object.is equality

- Expected: true
+ Received: false

and the unreachable ledger is read as empty, recording a second pending fact at a different expiry — the reported behaviour:

FAIL ... > finding 1: an unreachable ledger is refused by name, not read as empty
AssertionError: promise resolved "{ satisfied: false, …(2) }" instead of rejecting

+ {
+   "pending": {
+     "expiresAt": "2026-09-11T05:20:00.000Z",
+     "gate": "approve-live-apply",
+     "kind": "pending",
+     "op": "live-apply",
+     "timestamp": "2026-09-09T05:20:00.000Z",
+     "version": 1,
+   },
+   "recorded": true,

#2303 finding 2 — emptying requireLifecycleLedgerWritable. The pending fact is discarded:

FAIL ... > finding 2: approving from an unfetched clone appends, and the pending fact survives
AssertionError: expected [] to have a length of 1 but got +0

- Expected: 1
+ Received: 0
FAIL ... > finding 2: a local ledger that diverged from the remote refuses rather than appending across the fork
AssertionError: promise resolved "undefined" instead of rejecting

Gates

Gate Result
npx tsc --noEmit -p packages/core/tsconfig.json clean
npx tsx scripts/typecheck.ts 31 known failure(s), no regressions — baseline unchanged
just lint 0 errors (2 pre-existing warnings in an untouched file)
just docs-check 20 tutorial, 52 how-to, 58 reference, 34 explanation
vitest, full packages/core 390 files, 6322 passed
vitest, test/ + github/gitlab/forgejo lexicons 187 files, 1489 passed, 18 skipped

No egress-catalogue change: chant run and chant approve already reach the git remote through pushLifecycle, and OFFLINE_SHELL_OUTS scopes the offline phases, which these are not. The egress guard was run and is green.

Part of #2289. Closes #2301. Closes #2303.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Ba8bBNoVmfrpiVKnwYLBzM

…when it does not (#2301, #2303)

Three failures of one mechanism, all found by the first real execution of a
generated Op pipeline on GitLab CE 17.11 (INTENTIUS/choudoufu#1026). The gate
records its pending fact as a commit on `chant/lifecycle`; every guard on both
sides had only ever read generated YAML, so nothing had exercised what that
commit needs from the checkout it runs in.

A CI checkout differs from a developer's in two ways, and the gate depended on
both without saying so.

**No committer identity (#2301).** GitLab CI, GitHub Actions and Forgejo
Actions all clone without `user.email` or `user.name`, and `git commit-tree`
refuses rather than inventing one. `writeBlobToPath` now supplies chant's own
— `chant <chant@localhost>` — through `git -c` on that one invocation, and
only when `git var GIT_COMMITTER_IDENT` says the checkout cannot name a
committer itself. A configured identity is never overridden, so every existing
caller's commits are byte-identical; nothing is written into the repository's
config either way. `CHANT_LIFECYCLE_COMMITTER_NAME` / `_EMAIL` repoint it at a
bot account a project controls. This is in core's one git-plumbing path rather
than in the three generated dialects, so github and forgejo — untested for
this, and named in the issue as needing to be — are fixed by the same change
as gitlab, and a project that generated its pipeline before this needs no
regeneration.

**No error text at all (#2301, the half the issue says matters more).** The
symptom was an apply that printed `Op "live-apply" failed after 43.8s` and
nothing else: no error line, no failing step, exit 1. Two causes, one inside
the other. `runGateStep` was the only step kind that could throw instead of
returning a record — `runStep` has always turned an activity's throw into a
failing `StepRecord` carrying the message, and the gate did not — so a git
failure unwound the phase loop with no record of itself. Then `runOpLocally`'s
catch, which unpacks `PhaseFailure` and `GateStop` and nothing else, built an
`OpRunFailure` from the records it had and never referenced `err` again. Since
`renderHuman` prints text only from records, the cause reached nobody.

Both are closed. A gate that cannot be decided is now a failing step like any
other, and any error the catch does not recognise becomes a synthetic failing
record carrying its message, with the original on `OpRunFailure.cause` for a
programmatic caller. The compensation loop had the same swallow one level down
and gets the same treatment. This is deliberately general: the gate is where it
was found, not the only thing it hid — anything thrown between the phases was
equally invisible. The component driver's parallel path was checked and already
re-throws what it does not recognise, so it needed nothing.

`writeBlobToPath`'s own failures now name what was being written and where
(`cannot write _gates/live-apply.jsonl on the chant/lifecycle branch: ...`),
because `git commit-tree failed: <stderr>` does not say that the thing that
failed was chant recording a fact on its own branch. `runtimes/local.ts` also
declared no `onLedgerError`, so a run-ledger append dying for the identical
reason was caught and dropped; it warns now.

**No ledger branch (#2303).** A GitLab CI checkout fetches the pipeline's own
ref at depth 20 and nothing else, so `chant/lifecycle` is absent — and an
absent branch reads exactly like an empty ledger, which is to say like nothing
having been approved. A retried job therefore recorded a *second* pending fact
and gated again; two runs of one commit produced two pending records with
different expiries. `GIT_DEPTH: 0` does not fix it, because GitLab fetches
refspecs rather than all branches.

The read is what has to be right, so `gitGateLedgerPort.read` fetches the
branch before reading it. `fetchLifecycleStatus` distinguishes the four
outcomes a boolean could not: `fetched`, `no-remote` (a single-machine
project, where local is authoritative by construction), `absent` (the remote
answered and has no such branch — a real empty ledger, and a first gate must
not be refused), and `unreachable` / `diverged`, which is where
`LifecycleLedgerUnreadableError` refuses by name rather than guessing. That
refusal is the issue's stated minimum, and it is only useful because of the
paragraph above: thrown from inside gate evaluation, it would have been
swallowed too.

**`chant approve` force-writing the branch (#2303, the serious one).**
`writeBlobToPath` builds its commit from `readTree`, which on a checkout with
no local `chant/lifecycle` returns an empty tree and a null tip. The append
therefore parented on nothing and wrote a tree holding only the line it had
just produced — a new root commit replacing the branch instead of extending
it. The `update-ref` CAS did not catch it, because the assertion it makes
("the ref does not exist") was perfectly true locally. An operator cloning,
approving and pushing turned a branch holding the pending record into a branch
holding only the resolution: silent history loss on the branch both READMEs
call the approval of record.

`recordGateApproval` and `--expire` now call `requireLifecycleLedgerWritable`
first. Fetching is the fix — with real history in the checkout the append
parents on it and the pending fact survives — and the guard refuses outright
on divergence, which the read path tolerates and a write must not, since
appending across a fork drops one side either way.

Proof is in `packages/core/src/op/gate.test.ts`, new, against real git: a bare
remote, an authoring clone, and a `--single-branch` clone standing in for the
CI checkout, which is the closest local equivalent of GitLab's refspec fetch.
Every assertion was shown red by a deliberate tamper first. Reverting the
identity args reproduces the reported `fatal: no email was given` inside the
new "cannot write ... on the chant/lifecycle branch" wrapper; reverting both
halves of the swallow reproduces the reported output exactly, three lines
ending in a bare failure; reverting the read guard records a second pending
fact at a different expiry; reverting the write guard leaves the pending
record gone (`expected [] to have a length of 1`).

No egress-catalogue change: `chant run` and `chant approve` already reach the
git remote (`pushLifecycle`), and the catalogue's shell-out list scopes the
offline phases, which these are not.

Part of #2289. Closes #2301. Closes #2303.

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

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
lex00 and others added 2 commits September 9, 2026 14:47
`lint-docs-sentences.mjs` gates em-dash density per file, and the new
"What the gate needs from a CI checkout" section pushed
guide/ops.mdx from 23 to 26 against a baseline of 23. Parentheses for
the committer-identity aside and a colon for the absent-branch clause
carry the same meaning without the dashes.

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

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…2303)

Four defects from the adversarial review of #2309. The first is a data-loss
path this PR's own first pass opened, and it is reproduced end to end against
real git.

**A diverged local ledger was read as authoritative, then force-pushed over
the remote.** `requireLifecycleLedgerReadable` fetched, then returned early on
`if (hadLocal)`, which swallowed `diverged` as well as `unreachable`. The
docstring justified it with "it has real history to read", which is only true
when the local branch *is* the remote's history. On a fork, the gate read a
ledger missing every remote approval, recorded a second pending fact, and
pushed it.

The push was unprotected. A rejected non-fast-forward fetch still updates
`refs/remotes/<remote>/chant/lifecycle` opportunistically in a full clone
(verified on git 2.50.1: the `! [rejected]` line comes with
`* [new branch] chant/lifecycle -> origin/chant/lifecycle`), so
`getRemoteLifecycleBranchSha` read the tip the failed fetch had just learned
and `--force-with-lease` matched. A remote holding a pending fact and an
`e2e-operator` approval ended up holding neither.

Divergence now always refuses, for readers and writers alike, and the two
guards are one function: keeping them separate is what let the read path drift
laxer than the write path. `unreachable` still refuses only when there is no
local history, which is the case indistinguishable from an empty ledger;
refusing it with history present would strand every offline run for no gain,
since the lease fails safely on its own there.

Distinguishing a fork from a branch that is merely *ahead* is what makes that
rule safe to apply. git reports "non-fast-forward" for both, and "ahead" is
the ordinary state right after an append whose push has not landed — the state
a retry exists to repair. `fetchLifecycleStatus` resolves the remote tip into
a scratch ref and asks `merge-base --is-ancestor`, so `ahead` and `diverged`
are separate outcomes.

**The identity fallback turned a loud failure into a silent branch
fabrication.** Every ledger writer reaches `writeBlobToPath`, which on a
checkout with no local `chant/lifecycle` builds a tree from an empty read and
commits it with no parent: a root commit that replaces the branch. `updateRefCAS`
cannot catch it, because "the ref does not exist" is true locally. Until #2301
the damage was capped by accident, in that `commit-tree` died for want of a
committer before it could happen. Supplying an identity removed that accident,
on every writer that reaches here without a ledger — a run record on an Op with
no gate at all, a snapshot, a release, a build manifest — and since GitLab
runners reuse `/builds/<project>` across jobs, the next job carried the fork
into the gate. The guard now runs inside `writeBlobToPath`, at the one seam
they all pass through, and only when the branch is absent, so an extend still
costs no fetch and a genuinely first write still creates the branch.

**`chant operator` never got #2301's fix.** It renders its own events rather
than going through `renderHuman`, passed no `onLedgerError`, and reported a
fixed `Op "x" failed — see its ledger record for step-level detail` while
`err.result.records` and `err.cause` sat unread. It pointed the reader at an
artifact that a failed ledger append means is missing. It now names the
failing steps, falls back to `cause`, and reports a dropped ledger append as
its own tick failure.

**Locale and remote selection.** Both strings `fetchLifecycleStatus` matches
are in git's translation catalogs, so under a distro git with NLS and a non-C
`LANG` a project's genuine first gate would fall through to `unreachable` and
be refused. Every git invocation parsed by its output is pinned with
`LC_ALL=C` and a cleared `LANGUAGE`, which needed an `env` option on the
runtime adapter's `spawn` (merged over the parent environment, not replacing
it). A non-zero exit from `git remote` is no longer read as "no remote
configured", since a git that failed to answer is not evidence that a project
is single-machine. `origin` is preferred over whichever remote name sorts
first, so a repo with a `backup` remote does not fetch the ledger from it.

**Two smaller corrections.** The identity fallback is per-field now: `git var
GIT_COMMITTER_IDENT` fails if either half is missing, so filling in both
overwrote a configured `user.name` in a checkout that had a name but no email,
which is not what this file's own doc comment and ops.mdx promise. And both
`chant approve` write sites used `pushLifecycle().catch(() => undefined)` and
then printed unconditional success, so a rejected push read as a completed
approval; they warn and mark the line local-only now, keeping exit 0 because
the local append is still a correct local fact.

`git.test.ts`'s "concurrent write rejected" test asserted the *old* behaviour:
that operator B's fork was caught by the lease at push time. A write that has
to be caught by a lease is the bug, so it is now two tests — B appends to A's
history and both snapshots survive, and a genuinely stale lease still throws.

Every new assertion was shown red by a deliberate tamper. Restoring the
`hadLocal` early return makes the gate record a second pending fact against a
fork and moves the remote tip off the approval; disabling the write guard
leaves the fabricated branch with no trace of the pending fact; restoring the
operator's fixed string, the all-or-nothing identity, and the push swallow
each fail their own assertion.

Part of #2289. Closes #2301. Closes #2303.

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

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@lex00

lex00 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Review defects addressed in 785f3c5. The critical one was real and I reproduced it end to end before fixing it.

1 (critical) — diverged ledger read as authoritative, then force-pushed

Confirmed exactly as described. Standalone repro against git 2.50.1, full clone:

=== fetch ===
 ! [rejected]        chant/lifecycle -> chant/lifecycle  (non-fast-forward)
 * [new branch]      chant/lifecycle -> origin/chant/lifecycle
FETCH_RC=1
=== now the force-with-lease push chant would make ===
lease expected=[9bb8285ba804af0112b75b340375d37ad11ae4a5]
 + 9bb8285...08b8633 chant/lifecycle -> chant/lifecycle (forced update)
PUSH_RC=0
=== is the original approval still reachable on remote? ===
08b8633 forked local
8053dc6 init

The approval is gone. (Note the opportunistic remote-tracking update needs a full clone's default refspec; in a --single-branch clone it does not happen, so the new test fixture clones fully on purpose.)

Fix. Divergence now always refuses, and the two guards are collapsed into one requireLifecycleLedger — keeping them separate is precisely what let the read path drift laxer than the write path. unreachable still refuses only with no local history, since that is the state indistinguishable from an empty ledger; refusing it with history present would strand every offline run and the lease fails safely on its own there.

Making that rule safe required separating two states git reports identically. "non-fast-forward" covers both a fork and a branch merely ahead — and "ahead" is the ordinary state right after an append whose push has not landed, exactly what a retry repairs. fetchLifecycleStatus now resolves the remote tip into a scratch ref and asks merge-base --is-ancestor, so ahead and diverged are distinct outcomes. There is a test for each.

Added the missing assertion you flagged: finding 1 (review) points requireLifecycleLedger (via gitGateLedgerPort.read, the call the gate actually makes) at the divergent checkout, and also asserts the remote tip is unmoved. Under the tamper it fails twice over — first recording a second pending fact:

AssertionError: promise resolved "{ satisfied: false, …(2) }" instead of rejecting
+   "recorded": true,

and then, with that assertion relaxed so execution continues, destroying the remote:

AssertionError: expected 'ab83a37fbe2436ba0e569ce0d7ac022de28ba…' to be 'ac9e52e0cd03913be2b2ab9d8a5dfe5a83d44…'

2 (high) — identity fallback fabricating a branch

Correct, and it contradicted my claim 4. The guard now lives inside writeBlobToPath, at the one seam every writer passes through, rather than at call sites — that covers appendRunRecord, writeSnapshot, auto-release.ts and manifest-persistence.ts together. It runs only when the local branch is absent, so an extend still costs no fetch and a genuinely first write still creates the branch (no-remote and absent both proceed).

Red, on a run-ledger append for an Op with no gate at all:

AssertionError: expected [] to deeply equal [ 'approve-live-apply' ]

3 (medium) — chant operator path

Fixed both halves: onLedgerError is wired and reports a dropped append as its own tick-failed, and the message now names the failing steps, falling back to err.cause. Red:

AssertionError: expected 'Op "staging-converge" failed — see it…' not to match /see its ledger record/

4 (low-medium) — absent classification

All three fixed, not just the first. LC_ALL=C plus a cleared LANGUAGE on every git call parsed by output, which needed an env option on the runtime adapter's spawn (merged over the parent environment, not replacing it). A non-zero git remote exit is no longer read as "no remote". origin is preferred over the alphabetically first remote.

5 (low) — claim 1

Fixed the code rather than the claim: the fallback is per-field now, so a configured user.name with no user.email keeps its name. Red:

AssertionError: expected 'chant <chant@localhost>' to be 'Release Bot <chant@localhost>'

Both texts updated to match. Also fixed the pushLifecycle swallow at both chant approve sites here rather than deferring to #2310 — they warn and mark the line local-only, keeping exit 0 since the local append is still a correct local fact. Red:

AssertionError: expected '�[32mGate "rollout-gate" on "fou…' to match /push to the remote was rejected/

One deliberate test change

git.test.ts's "concurrent write rejected" asserted the old behaviour — that operator B's fork was caught by the lease at push time. A write that has to be caught by a lease is the bug, so it is now two tests: B appends to A's history and both snapshots survive, and a genuinely stale lease (B fetches, A pushes again, B pushes) still throws StaleLifecycleBranchError.

Gates

Gate Result
core typecheck clean
npx tsx scripts/typecheck.ts 31 known failures, no regressions
just lint 0 errors (2 pre-existing warnings, untouched file)
just docs-check passes
node scripts/lint-docs-sentences.mjs 4084 gated finding(s), no regressions
vitest packages/core 390 files, 6330 passed
vitest test/ + all lexicons 793 files, 9768 passed, 30 skipped

@lex00
lex00 merged commit cd191e3 into main Sep 9, 2026
6 checks passed
lex00 added a commit that referenced this pull request Sep 10, 2026
…ead of resolving quietly (#2310) (#2336)

gate.ts:71's `appendPending` still did `await pushLifecycle(opts).catch(() =>
undefined)` after #2309 fixed the same swallow at the two `chant approve`
write sites in `../cli/handlers/operator.ts`. #2309's author left it on
purpose, reasoning that a pending fact reaching only the local branch is
still a correct local answer, and that changing it would alter gated-run
exit semantics.

That reasoning holds for the exit code and does not hold for the report. A
`chant run` that stops at a gate is right to end `gated` whether or not its
push landed: the append to `chant/lifecycle` always succeeds locally
(#2309's fetch-before-append), and there is nothing wrong with the local
fact to fail the run over. But a rejected push means the pending record
exists only in this checkout, and an operator working from a clone of the
remote cannot see a fact they cannot see to approve it. Before this, the run
gave no hint that this was why `chant approve` found nothing to resolve —
exactly `chant approve`'s pre-#2309 bug, one caller over. The decision here
is: still exit 3, still gate, and now say so.

`gate.ts`'s `GateLedgerPort.appendPending` returns `{ record, pushed,
pushWarning? }` instead of the bare `PendingGateRecord`, mirroring the shape
`operator.ts`'s `reportedPush` (#2309 review) already reports through.
`evaluateGate`'s `GateCheck` carries `pushed`/`pushWarning` alongside the
pending fact, present only when this call's own append is what ran —
`recorded: false` (a standing pending fact from an earlier run) has nothing
new to report. From there it threads through both executors exactly the way
#2301 threaded a gate's failure onto `OpRunResult`/`DriverComponentResult`:
`GateStop` in both `local-executor.ts` and `components/driver.ts` carries
`pushed`/`pushWarning`, `runOpLocally`/`runComponentDeploy` land them as
`gatePushed`/`gatePushWarning` on the result, and `cli-support.ts`'s
`RunComponentsResult.gated` and `run.ts` carry them the rest of the way to
`chant run`'s human render, `--json`, and the `GITHUB_STEP_SUMMARY`/
`CHANT_GATE_SUMMARY` block `chant run` already writes for a gated run (the
step summary is the surface an operator working from a different checkout
actually opens, so it is where this mattered most).

Audited every other `pushLifecycle` caller for the same swallow:
- `activities/converge.ts:435` (`convergeTick`'s ledger append) has the
  identical `.catch(() => undefined)` idiom. Left alone here: it is a
  different ledger (the converge tick log, not the gate ledger) with a much
  softer consequence (an informational log line missing a remote, not an
  approval nobody can see), and reporting it would mean extending
  `ConvergeTickResult`/`ConvergeOp`'s outcome attributes, which is its own
  change. Worth its own issue.
- `lifecycle/snapshot.ts:302` and `cli/handlers/lifecycle.ts:531` let a
  rejection propagate/already report `pushed` — no swallow.
- `cli/handlers/components.ts:133`, `components/manifest-persistence.ts:139`
  and `components/auto-release.ts:192` all catch a *rejected* push (a real
  `StaleLifecycleBranchError`) and report failure correctly; only the
  "no remote configured" `false` return goes unremarked in favor of a
  reported success, a smaller and pre-existing gap, not the swallow #2310 is
  about.

Every new assertion was shown red by reverting `gate.ts`'s fix back to
`await pushLifecycle(opts).catch(() => undefined); return { record, pushed:
true };` and rerunning `gate.test.ts`:

    FAIL  packages/core/src/op/gate.test.ts > op/gate — a CI checkout that
    never fetched the ledger (#2303) > a project with no remote is local-only
    and is never refused
    AssertionError: expected true to be false // Object.is equality
      507|     expect(check.pushed).toBe(false);

    FAIL  packages/core/src/op/gate.test.ts > op/gate — a rejected ledger
    push is reported, not swallowed (#2310) > gitGateLedgerPort's
    appendPending reports pushed:false and the rejection reason
    AssertionError: expected true to be false // Object.is equality
      574|     expect(third.pushed).toBe(false);

The second test reproduces the actual race against real git: two clones of
one bare remote, the second fetches and appends on top of the first's push,
then the first appends its own fact on the tip it still knows and pushes
against a lease the remote has since moved past — the same
`StaleLifecycleBranchError` a concurrent `chant approve` can hit. Restored
the fix, both green.

New/extended coverage: `gate.test.ts` (the rejection above, plus
`evaluateGate`'s propagation from a stub port, plus the existing no-remote
test extended to assert `pushed`/`pushWarning`), `local-executor.test.ts`
and `driver.test.ts` (a rejected push still ends the run/component `gated`
and lands `gatePushed`/`gatePushWarning` on the result), `local-output.test.ts`
(`renderHuman`/`renderJson` show the warning), `gate-summary.test.ts` (the
CI step-summary markdown block).

Docs: `docs/cli/run.mdx` gains a paragraph on the append/push split and
what a rejected push means for the run and its `--json`/step-summary output,
answering the issue's "say which in the docs" for the decision made here
(report, don't retry, don't fail).

Gates: `npx tsc --noEmit -p packages/core/tsconfig.json` clean. `npx tsx
scripts/typecheck.ts`: 31 known/0 new. `just lint`: 2 pre-existing warnings
in an unrelated file (packages/core/src/meta/publish-metadata.test.ts), 0
errors. `just docs-check`: 20 tutorial, 52 how-to, 58 reference, 34
explanation, clean. `node scripts/lint-docs-sentences.mjs`: 4084 baselined,
no regressions. Targeted: `npx vitest run packages/core/src/op/gate.test.ts
packages/core/src/op/local-executor.test.ts packages/core/src/op/local-output.test.ts
packages/core/src/op/gate-summary.test.ts packages/core/src/components/driver.test.ts
packages/core/src/components/cli-support.test.ts packages/core/src/lifecycle/git.test.ts
packages/core/src/cli/handlers/operator.test.ts packages/core/src/cli/handlers/run.test.ts`
— 304 passed. Full `npx vitest run packages/core` — 390 files, 6350 passed.

Closes #2310.

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

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant