Skip to content

fix: prevent concurrent package archive overwrites - #27

Merged
gachakra merged 1 commit into
developfrom
fix/archive-publication
Dec 4, 2026
Merged

gachakra merged 1 commit into
developfrom
fix/archive-publication

Conversation

@gachakra

@gachakra gachakra commented Dec 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Make the commit-based archive helper publish atomically without overwriting a destination created during the build.
  • Build in a private temporary directory on the output filesystem, then use PHP's link() to publish the fully verified TAR at the exact final path. A failed link returns nonzero; there is no overwrite or copy fallback. The destination filesystem must support hard links.
  • Add a deterministic concurrency regression: pause the first Composer invocation after archive creation, publish a different commit in a second invocation, resume the first, require its failure, compare the winning TAR byte-for-byte, and verify cleanup and startup refusal.

Scope

Only the archive helper, its regression script and the CI step are changed. Existing checks, dependency audit, package contents, library APIs, dependencies, lockfile and Docker configuration are unchanged.

Validation

Actual Composer and the concurrency regression must pass in CI and independent review. No merge or release is requested.

@gachakra gachakra left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review

No actionable findings on 4ef8782bf88a1126056d29d2a0682ab0bf5f5144, reviewed against c70c2615cf75c9ad0a7aba335a44487f6b8157dc.

  • Concurrent publication. Using Composer 2.11.3 and PHP 8.6.0 in an isolated checkout, I paused an invocation after Composer built its TAR and let a different commit publish first. The winner exited 0. The resumed invocation exited 1 and left the winning TAR byte-for-byte intact. Running the same test with the old helper from c70c2615cf75c9ad0a7aba335a44487f6b8157dc yielded two exit codes of 0 and overwrote the winner. The new regression forces this ordering and checks both the loser's exit code and the winning bytes.
  • Failure and cleanup. An existing file, directory, live symlink and dangling symlink were refused and preserved, both when present at startup and when created during packaging. A real PHP destination denial via open_basedir returned 1 with the destination still absent. A forced Composer failure also left no archive. Verified that staging and publication were on the same filesystem, the published file kept the staged file's inode, and the staging directories were removed. Publication requires an output filesystem that supports hard links.
  • Distribution and CI. Git TAR, GitHub source ZIP, Composer TAR and the helper's output from a dirty checkout matched all 22 allowed files byte-for-byte. Untracked, ignored and staged source files and staged and unstaged README edits stayed out of the helper's artifact. The lockfile remains tracked and unignored and stays out of the package. Strict Composer validation, Bash syntax and git diff --check passed. Dependency constraints, lockfile, library source, documentation and Docker configuration are unchanged.
  • Checks on the reviewed head. PHP 8.4 and PHP 8.5 passed archive verification and the new concurrency regression. Composer Audit ran on PHP 8.4 and was skipped on PHP 8.5 as intended. Docker development environment also passed. Existing check names, permissions and Action pins are unchanged. Workflow run

@gachakra
gachakra merged commit 4bc876d into develop Dec 4, 2026
3 checks passed
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.

1 participant