Skip to content

test(plugins): stop the fake Pi CLI from rewriting settings on read-only commands - #762

Merged
runkids merged 1 commit into
mainfrom
runkids/fix-pi-fake-settings-race
Nov 4, 2026
Merged

runkids merged 1 commit into
mainfrom
runkids/fix-pi-fake-settings-race

Conversation

@runkids

@runkids runkids commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Summary

TestPluginHostStateProducerLegacyProjection/local fails intermittently in CI with:

state_legacy_test.go:114: local proof rejected: {... ID: ... Digest: ...}

It failed three times on the v0.28.3 release run and once on #745, and blocked the release tag until a rerun passed.

Cause: the test fake, not production code. fakePiNpm is the Run fake for every target in a test Service. It re-marshaled and rewrote Pi's settings.json after any command other than --version and --help. Service.Inventory queries all targets concurrently, so another target's read-only CLI call could truncate the file (os.WriteFile) while the pi host was reading it. The pi host then reported no packages, and the legacy proof was rejected.

I confirmed this with temporary instrumentation under load: every failing run read the same settings path with zero entries.

Fix: only install and remove change Pi settings, so only they write. Every other command returns without touching the file. The real Pi CLI never rewrites settings on read-only commands either.

Type

  • Bug fix (flaky test)
  • Small improvement (docs, typo, minor refactor)
  • Feature proposal
  • Approved feature or large change

Linked Issue

None. Found while releasing v0.28.3.

Checklist

  • I've read CONTRIBUTING.md, including its AI-assisted contributions section
  • I've reviewed every line of the diff and can explain it
  • Tests included and passing (make check). The fix is to the test helper itself.
  • No unrelated changes in the diff
  • Scope is focused: one concern per PR

Verification

All in the devcontainer:

  • Before the fix: 12 to 16 concurrent runs of the -race plugin test binary reproduced the failure in about 4 of every 48 runs.
  • After the fix: 48 of 48 runs under the same load pass.
  • go test -race ./internal/plugin passes.
  • go vet and gofmt are clean.
  • make check passes.

Production Pi commands that reach the fake are --version, --help, install, remove and update. update lost its re-serialization of an existing file, and no test depends on that.

Not covered

install and remove still write with os.WriteFile. That would race only if Inventory ran concurrently with an apply, which no test does.

…nly commands

fakePiNpm is the Run fake for every target in a test Service, and it
rewrote Pi's settings.json after any command other than --version and
--help. Inventory queries all targets concurrently, so another target's
read-only CLI call could truncate the file while the pi host read it.
The pi host then saw no packages, and
TestPluginHostStateProducerLegacyProjection/local failed with "local
proof rejected". It failed three times on the v0.28.3 release run and
on PR #745.

Only install and remove change Pi settings, so only they write now.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-04T02:56:39.724856Z
We couldn’t complete this review. Comment @codex review to try again.
2391d54 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@runkids
runkids merged commit af80327 into main Nov 4, 2026
8 checks passed
@runkids
runkids deleted the runkids/fix-pi-fake-settings-race branch November 4, 2026 03:35
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