Repository navigation
test(backend): the read-back budget is a bound, not an exact attempt count (TASK-112) - #1839
Merged
Merged
Conversation
…count (TASK-112) `npmPublishReadback` asserted `attempts === 3` for a 2s budget with a 1s interval. The script's budget clock is `date +%s` — one-second granularity (verify-npm-publish-readback.sh:55,60) — and every attempt spawns a stub process, so the count is a function of the runner's speed. Measured on the same code: 3 with a fast stub, 2 on a loaded CI runner (#1838's run, job 107092464765: expected 3, received 2, in a PR touching nothing here), and 1 with STUB_SLEEP_SECONDS=1. The assertion was about the runner, not the script. Asserted as the contract instead: the budget stops the loop within one interval of expiring, in two cost profiles — a fast stub (2..3) and a stub that spends the budget in its own calls (1..2, deterministic). Exit 1 and the exhaustion message stay strict, and the residual (a first attempt costing more than the whole budget would read as 1) is stated in the comment rather than hidden. Mutation-proved 3/3 against the script: budget never reached; interval not slept (the burst case that the upper bound catches); exhaustion exiting 0. Baseline 0 failure lines, 10/10.
lilyshen0722
force-pushed
the
kai/npm-readback-budget-bound
branch
from
September 23, 2026 09:46
3a20e66 to
a44a63c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The only required check on main (
Test & Coverage) flaked red on #1838 — a PR that touches no backend test — withexpected 3, received 2innpmPublishReadback. This fixes that assertion.The count is a function of the runner's speed, not a contract. The script's budget clock is
date +%s, one-second granularity (scripts/verify-npm-publish-readback.sh:55,60), and every attempt spawns a stub process. Measurements on the same code:STUB_SLEEP_SECONDS=1(reproduced on demand)So
attempts === 3was an assertion about the runner. Worse than flaky: it is the only required status check, so it goes red at random for every open PR, and the natural reading of a red required check is that the PR is bad.What is asserted now — the contract, in two cost profiles:
2..3, because the budget can already be spent at the second attempt;STUB_SLEEP_SECONDS=1):1..2, deterministic, and it keeps a strict assertion by pinning the cost profile the fast row is racing.Exit code 1 and the exhaustion message (
::error::@commonlyai/cli@<v>) remain strict — the decision the script exists to make is unchanged by the count. A residual is stated in the comment rather than hidden: a first attempt costing more than the entire budget would still read as 1.Verification. Mutation-proved 3/3 against the script (
/tmp/kai112-ledger.py): the budget never reached (lower bound bites); the interval not slept, so the budget is spent in a burst (upper bound bites); exhaustion exiting 0 (the status assertion bites). Baseline: 0 failure lines, 10/10 passed. Three consecutive runs of the file: 10/10 each. Test-only, backend, no version slot.Disclosure — two more flaky members of the same required check, measured but not diagnosed. A full backend run in this worktree gave
Test Suites: 2 failed, 420 passedwithregistry.runtime-tokens.test.js › issues a runtime token for an installed agentandAgentMemory.test.ts › enforces unique (agentName, instanceId). Both then passed in isolation, in this worktree and in a clean main worktree (21/21 both times), so they are load/parallelism-dependent rather than deterministic. I have not isolated their mechanism, so this is a report and not a diagnosis — but if the required check is going to be trusted as a signal, those two want the same treatment as this one.