Skip to content

fix(op): report a gate's pending fact never reaching the remote (#2310) - #2336

Merged
lex00 merged 1 commit into
mainfrom
fix/2310-report-ledger-push-outcome
Sep 10, 2026
Merged

lex00 merged 1 commit into
mainfrom
fix/2310-report-ledger-push-outcome

Conversation

@lex00

@lex00 lex00 commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Closes #2310.

Decision

recordGateApproval's two write sites (chant approve) were fixed by #2309: a rejected push warns and marks the line local-only, exit unchanged. gate.ts:71's appendPending — the gate's own evaluateGate writing a pending fact mid-run — still did await pushLifecycle(opts).catch(() => undefined), deliberately left by #2309's author on the 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.

I agree with the exit-semantics half and disagree that it settles the question. A gated run is right to end gated whether or not the push landed — the local append always succeeds (#2309's fetch-before-append), and there's nothing about that fact to fail the run over. But a push that never reaches the remote means the pending record exists only in this checkout: an operator working from a clone of the remote cannot see it to approve it, and the run gave no hint that this was why their chant approve found nothing to resolve. That's the consequence the issue names, and it's real regardless of the exit code.

So: still exit 3, still gate — now say so. Same shape #2309 already established for chant approve, extended to the gate's own write.

What changed

  • GateLedgerPort.appendPending returns { record, pushed, pushWarning? } instead of a bare PendingGateRecord.
  • evaluateGate's GateCheck carries pushed/pushWarning alongside the pending fact — present only when this call recorded it (recorded: true); a gate left standing from an earlier run has nothing new to report.
  • Threaded through both executors the same way a CI checkout has no git identity, so the gate's pending write fails with no error text at all #2301 threaded a gate failure onto the run result: GateStop (in both op/local-executor.ts and components/driver.ts) carries pushed/pushWarning; OpRunResult/DriverComponentResult land them as gatePushed/gatePushWarning; cli-support.ts and cli/handlers/run.ts carry them to chant run's human render, --json, and the GITHUB_STEP_SUMMARY/CHANT_GATE_SUMMARY block a gated run already writes (the step summary is the surface a remote operator actually opens, so that's where this mattered most).
  • docs/cli/run.mdx documents the append/push split and what a rejected push means, per the issue's "say which in the docs."

Other pushLifecycle callers audited

  • op/activities/converge.ts:435 (convergeTick) has the identical .catch(() => undefined) swallow. Left alone: different ledger (the converge tick log, not the gate ledger), softer consequence (a missing log line, not an unseeable approval), and reporting it needs ConvergeTickResult/ConvergeOp outcome-attribute changes of its own. Worth a follow-up issue.
  • lifecycle/snapshot.ts:302, cli/handlers/lifecycle.ts:531 — no swallow; a rejection propagates or is already reported.
  • cli/handlers/components.ts:133, components/manifest-persistence.ts:139, components/auto-release.ts:192 — a real rejection is caught and reported correctly; only the "no remote configured" false return goes unremarked as a reported success. Smaller, pre-existing, not this issue's swallow.

Proof

Every new assertion shown red by reverting gate.ts's fix to the old swallow 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 drives the real 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.

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, 0 errors
  • just docs-check — clean
  • node scripts/lint-docs-sentences.mjs — 4084 baselined, no regressions
  • Targeted: gate.test.ts, local-executor.test.ts, local-output.test.ts, gate-summary.test.ts, driver.test.ts, cli-support.test.ts, git.test.ts, operator.test.ts, run.test.ts — 304 passed
  • Full npx vitest run packages/core — 390 files, 6350 passed

🤖 Generated with Claude Code

https://claude.ai/code/session_01Ba8bBNoVmfrpiVKnwYLBzM

…ead of resolving quietly (#2310)

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>
@lex00
lex00 merged commit 854f0c0 into main Sep 10, 2026
6 checks passed
lex00 added a commit that referenced this pull request Sep 13, 2026
#2337) (#2464)

`convergeTick` ended with `await pushLifecycle().catch(() => undefined)` —
the last genuine instance of the idiom #2310 was filed about, left out of
#2336 deliberately because fixing it means extending the tick's result shape
rather than editing a line.

The append is local-first and always lands, so the tick's own result was
correct either way. What was missing is whether anyone else can see it: a
converge loop reporting a clean tick whose ledger never left the machine is
telling an operator something untrue.

`ConvergeTickResult` gains `pushed` and an optional `pushWarning`, reported
the way #2336 does for the gate. The two reasons a push does not land are
told apart, since they are not the same thing: `pushLifecycle` returns false
when no remote is configured and throws when the remote rejects.

Softer than the gate's version of this bug, and the doc comment says so — a
lost tick record is an informational log rather than an approval, so nobody
is stranded waiting on a fact they cannot see. It is still not success.

The test drives a real tick with the push mocked three ways, and asserts the
tick's own findings survive a failed push, so this does not trade one wrong
answer for another. Verified red against the old code: three of its four
cases fail with the swallow in place.
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.

chant approve reports success when the ledger push was rejected

1 participant