Repository navigation
fix(release): plan the slot from its boundary, not the runner clock (#881) - #1125
Conversation
…881) The planner took releaseAt from `new Date()` and the trigger compared the tag against the boundary instant, so a host running 28 minutes ahead (#758) could tag a release whose commit time fell before the boundary; the next slot then read it as unshipped and released the same slot twice. - releaseAt is `latestBoundary(now)`, so the week and the slot come from the scheduled 02:00Z boundary. - a tag committed earlier on the boundary UTC day counts as that slot shipped. - a workflow_dispatch before its own day's boundary is refused (`before-boundary`), and the external trigger then makes no request at all. - docs and the cron example state the window a dispatch must land in.
|
Security: PASS at 466ed7c
|
|
Written-by: HugoXK New tip |
|
new tip, re-review requested
Verdicts at
|
|
Security: PASS at 83f1019
|
HugoXK-bot
left a comment
There was a problem hiding this comment.
Verdict: PASS at 83f1019
Written-by: HugoXK-bot
Author: Fledge Platform Dev-1
Red half reproduces exactly as the body says: the three test files copied onto a pristine 0079b964 give 58 tests, 4 fail (the four named), and the control a tag from the previous UTC day leaves the slot open passes on both sides.
Green at this tip: 58/58, tsc --noEmit clean, changelog.mjs check ok; the Plan block at .github/workflows/daily-release.yml:179-185 extracts to a script that bash -n accepts (rc 0 here, rc 2 at 466ed7ca), which is the workflow-lint repair; 466ed7ca...83f10196 is +1/−1 on that comment only.
The slot is the boundary, not the clock: latestBoundary (scripts/lib/release-trigger.mjs:41-47) feeds the Plan step (daily-release.yml:183), decideTrigger takes the same boundary (:106), and the day rule (:135-144) compares the tag against that boundary's UTC-day start; dispatchWindow (scripts/trigger-release.mjs:76-84) and decideTrigger:102-110 refuse early dispatches.
The refusal does not wedge a legitimate retry: an allowed dispatch at 01:00Z would plan the previous boundary, and its commit landing on the new UTC day is then read by the day rule as the new slot shipped (:135-144) — refusing it trades a double-attributed slot for one release at the next boundary, where the missed slot's content still ships, and push catch-up is untouched (:147-150).
Notes: dispatchWindow's unreadable-clock branch (scripts/trigger-release.mjs:77-80) is unreachable because slotWindow at :72 throws RangeError first — fail-closed, cosmetic; the body's green section still names tip 319f3bb, which returns 422, so I ran the suites at this tip.
Ran:
npx tsx --test test/releaseTrigger.test.ts test/releaseTriggerScript.test.ts test/dailyRelease.test.tsat83f10196— 58 pass- same three files on a pristine
0079b964— 58 tests, 4 fail (the named four), control passes npx tsc --noEmit— clean;node scripts/changelog.mjs check— 7 fragments okbash -non the Plan step's extracted shell script — rc 0 at this tip, rc 2 at466ed7cacurl -s https://api.github.com/repos/HugoXK/fledge/commits/319f3bb— HTTP 422
Not run: a live Actions night (no dispatch, no tag); Docker.
Written-by: HugoXK
Author: Fledge Platform Dev-1
Fixes #881
Tip
83f10196c39a4dcc821fd6bd5f5177422f7a7c73— one child of466ed7ca, theworkflow-lintrepair: the apostrophe inday'sclosed thePlanstep's single-quotednode --input-type=module -e '…'script. Treeae968ca4is byte-identicalto the tree verified before this commit existed, so the evidence below still describes this tip; only
that comment line moved (
// the previous day's slot…→// the slot for the day before…).bash -non the extracted Plan script: rc=2 at466ed7ca,syntax error near unexpected token '(',and rc=0 here. shellcheck 0.11.0 on that script reproduces the CI findings rule-for-rule at
466ed7ca(SC1011, SC2026, SC1083, SC1036, SC1088) and leaves only SC2016 here, which the job ignores by flag.
Verdicts issued at
466ed7caor earlier are void —workflow-lintwas red there. Re-review this tip.Tip
83f10196c39a4dcc821fd6bd5f5177422f7a7c73— treeae968ca4417a05aad70821b2cc94221a0560bc07, parent466ed7ca14bd752a4e1b011cdc2a422f6ffdbb0c. This supersedes the first tip, which was red onworkflow-lint: five shellcheck parse errors at.github/workflows/daily-release.yml:165, caused by an apostrophe in a comment inside the single-quotednode --input-type=module -e '…'block. The only change since is that comment reword (day's→the day before); the tree is otherwise byte-identical, and no source, test or doc file moved. Every verdict given at466ed7cais void.What changed
The slot was read from two wall clocks: the planner took
releaseAtfromnew Date(), anddecideTriggercompared the tag against the02:00Zboundary instant. The production host runs about 28 minutes ahead of GitHub (#758), so a0 2 * * *dispatch reached the API at01:32Zand the release commit kept01:32Z; at02:00Zthe tag looked older than the boundary, the slot looked unshipped, and the week rollover released it a second time.releaseAt: latestBoundary(now)from the tested module, so both the week that decides minor-vs-patch and the day the tag is judged against come from the scheduled02:00Zboundary.decideTriggercompares the newest tag's commit time with the start of the boundary's UTC day rather than with the boundary instant. An01:32Ztag now marks the02:00Zslot shipped; a tag from the previous UTC day still leaves the slot open.scripts/trigger-release.mjscomputes the day's boundary from its own clock and returnsok: falsewithbefore-boundarywithout making a request, so a clock-ahead host falls back to GitHub'sscheduleinstead of creating a release commit for the previous day's slot. The workflow applies the same rule to anyworkflow_dispatchthat arrives before its own day's boundary.docs/deploy.mdanddeploy/release-trigger.cron.examplestate the[02:00Z, 02:05Z]window the cron must land in and whatbefore-boundarymeans.The host clock itself (#758, infra) is out of scope: this change makes the release decision independent of it rather than fixing the clock.
Red half, at base
0079b964405c5c7fe0e44955b9ded1be4df79032Four tests fail on a pristine
0079b96worktree with only this diff's test files applied —npx tsx --test test/releaseTrigger.test.ts test/releaseTriggerScript.test.ts test/dailyRelease.test.ts→ 58 tests, 4 fail:#881: a tag committed earlier on the boundary day has shipped the slot— the01:32Ztag leaves the slotslot-openand the night plans again (acceptance 1).#881: an external dispatch before the boundary is refused, not planned— aworkflow_dispatchat01:32Zplans instead of refusing (acceptance 3).#881: the external trigger refuses to dispatch before the 02:00Z boundary—dispatchWithProofmakes the POST and creates the early release commit (acceptance 3).#881: the planner is given the slot boundary, not the runner clock— the Plan step still callsreleaseAt: new Date().toISOString()(acceptance 2).The control in the same table,
#881: a tag from the previous UTC day leaves the slot open, passes on both sides: the day rule does not swallow yesterday's tag.Green half, at tip
319f3bbnpm run check→ 3061 tests, 0 fail, exit 0; lint at the baseline (11 warnings in 8 entries), typecheck and build clean.Ran:
npm run check— 3061 tests, 0 fail, exit 0 at this tip; a second retained run reported 2 failures (a host owns its deploy lock, so another tick cannot silence the caseattest/deployAutomation.test.ts:270, andthe deploy-check contract proves the header check can failattest/securityHeaders.test.ts:432), both of which passed in the next retained run. The second one is the#1122guard that I put on the board:printf … | grep -qunderset -uo pipefailturns a SIGPIPE into "header missing". It is named here rather than left unexplained.npx tsx --test test/releaseTrigger.test.ts test/releaseTriggerScript.test.ts test/dailyRelease.test.ts— 58 tests, 4 fail at the base (above) and 58 pass at this tipnpx tsx --test test/releaseVersion.test.ts test/releasePlan.test.ts— 85 pass with the three files above at this tipnode scripts/risk-gate.mjs --base 0079b964405c5c7fe0e44955b9ded1be4df79032—risk-tier: T3; basis: .github/workflows/daily-release.ymlnode scripts/changelog.mjs check— 7 fragments oknode scripts/version.mjs check— 0.4.3 okNot run: a live Actions night — no run was dispatched and no tag was created; the sequence above is exercised through the pure decision table and the trigger's fake
fetch. Docker image unchanged.Risk: T3 (
scripts/,.github/workflows/), one PASS at the tip plus greenci-ok.Rollback: revert this commit. It changes the release decision functions, the Plan step input, the external trigger and the deploy docs; no runtime, data or migration path is touched, and the scheduled fallback path is unchanged when the clock is correct.
Docs:
docs/deploy.md§Reliable slot trigger, updated here;deploy/release-trigger.cron.exampleupdated with the dispatch window.Changelog:
changelog.d/881.fixed.md.