feat: self-healing idempotent publish + tested decision logic + CI#2
Merged
Conversation
Extract ordering/change-detection into publish-logic.ts (classify/specsEqual/ canonicalJson), unit-tested. Fix the self-heal gap: ordering uses strict '<' and an equal-sequence re-run is no longer skipped, so a run that committed but failed to create the release heals on retry instead of being dropped as stale. Unchanged content with an existing release stays a no-op (no churn).
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.
Why
While adding a CI idempotency check, I found the publish guard had a self-heal gap. Trace a partial failure: a run commits + pushes the spec (provenance
sequence=100) butgh release createthen fails. The retry (same pipeline,sequence=100) hit the ordering guard100 <= 100-> "stale", skip, and exited before the release-exists check. The release was never created, and consumers onreleases/lateststayed on the prior release until some future content change cut a different one. ThereleaseExistsguard was effectively unreachable because ordering/change-detection short-circuited first.What
scripts/publish-logic.ts(classify/specsEqual/canonicalJson), pure and unit-tested, withpublish.tsas the I/O around it.<(only a strictly-older deploy is stale), and anunchangedresult no longer exits, it ensures the release recorded inprovenance.tagexists, creating it if missing (self-heal).changedcommits then ensures the new tag's release..github/workflows/ci.yml): typecheck + tests on push/PR, the repo had none. 11 tests cover stale / idempotent re-run / no-churn / changed / first-publish / rollback.Behavior matrix
Note (out of scope)
npm run lint:speccurrently crashes on the committed spec (Cannot read properties of null (reading 'enum')) - a Spectral issue, not a lint finding. I left lint out of CI so it stays green; worth chasing as part of the Phase 3 gate work since it relies on Spectral.