Skip to content

feat(pi): add optional repeated-read containment - #7834

Merged
kunchenguid merged 2 commits into
kunchenguid:mainfrom
kesslerio:fix/repeated-successful-reads
Oct 28, 2026
Merged

kunchenguid merged 2 commits into
kunchenguid:mainfrom
kesslerio:fix/repeated-successful-reads

Conversation

@kesslerio

@kesslerio kesslerio commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Closes #7805

What Changed

  • Add a Linux Pi primary extension that can stop repeated recognized reads returning identical successful output, with bounded persisted history, ownership checks, and fresh-user-input reset.
  • Add opt-in configuration, legacy guard migration guidance, and runtime verification documentation.
  • Add policy and SDK/live fixtures and tests; update test-runner routing and locale-stable coverage comparisons.

Risk Assessment

✅ Low: The opt-in containment is bounded, enforces primary ownership, preserves durable stopping and deliberate reset, and introduces no substantiated material defect.

Testing

The installed Pi RPC guard stopped repeated reads, preserved its durable latch, denied operational resets, and allowed genuine user reset. The isolated installed-Pi collision check refused activation with migration guidance and left legacy files and config unchanged. Changed-file selection retained the affected suites and SDK check; coverage and runner/workflow checks passed in the private PID namespace. The initial runner/workflow attempt outside that namespace hit the known orphan-adoption prerequisite and passed when rerun in the supplied isolation.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
An operator enables the managed guard with conflicting ignored legacy files installed; Pi refuses activation with migration guidance and preserves the files and configuration. ✅ pass live Installed Pi collision refusal: disposable HOME/FM_HOME, actual Pi RPC loader, migration diagnostic, and matching before/after SHA-256 hashes.
A user runs the affected-file selector and coverage guard; both retain the read-repetition and SDK checks and report complete, valid suite packing. ✅ pass live --list-scheduled output included fm-read-repetition.test.sh, fm-read-repetition-live.test.sh, and fm-pi-primary-types.test.sh; --check-coverage reported 295 covered suites and valid packing.
A Pi primary encounters repeated successful reads; the installed guard vetoes further execution, retains its stopped state through operational input, and resumes only after genuine user input. ✅ pass live tests/fm-read-repetition-live.test.sh installed Pi RPC fixture reported 3 executions before stop, operational reset denied, user reset allowed, and durable notice; focused policy tests also exercise…
Evidence: Installed Pi collision refusal
exit=1; Pi refused to load the managed extension: “Legacy fm-read-repetition-guard.ts detected; preserve its source/configuration and move its entrypoint outside .pi/extensions before enabling the managed guard.” SHA-256 comparison before and after confirmed the config and both operator-installed legacy files were unchanged.
Evidence: Installed Pi RPC guard
{"installedPiRPC":"passed","executionsBeforeStop":3,"requestsBeforeStop":4,"operationalResetDenied":true,"userResetAllowed":true,"durableNotice":true}
Evidence: Coverage guard
FM_TEST_COVERAGE ok total=295 parallel=26 parallel_max_ms=814249 parallel_imbalance_ms=552 parallel_unhinted=0 serial=253 serial_shards=9 serial_unhinted=25 serial_max_ms=1199546 serial_budget_ms=1200000 herdr=16
- Outcome: 🔧 1 issue found → auto-fixed → no changes applied ✅ across 3 runs (20m56s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

🔧 **Rebase** - 1 issue found → auto-fixed ✅
  • ⚠️ docs/fm-test-portable-shards.md - merge conflict rebasing onto origin/main

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Review** - passed

✅ No issues found.

🔧 **Test** - 1 issue found → auto-fixed → no changes applied ✅
  • ⚠️ live validation verdict: inconclusive (3 of 5 scenarios were driven live against the product); untested: The managed safeguard refuses conflicting legacy files without changing operator-installed ignored files, Affected test selection and packing retain full coverage and serial placement
  • Live validation: ⚠️ inconclusive - 3 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Repeated successful reads are stopped at the configured bounded threshold across alternating, grouped, multiline, continued, and truncated-result forms ✅ pass live tests/fm-read-repetition.test.sh and installed Pi RPC output from tests/fm-read-repetition-live.test.sh
Unknown or mutating shell forms remain uncounted, while the guard stays inert without explicit opt-in ✅ pass live tests/fm-read-repetition.test.sh; installed Pi RPC default-off case in tests/fm-pi-primary-types.test.sh output
Only the verified primary can own the guard; operational and foreign-session events cannot reset its durable stopped state, while genuine user input can ✅ pass live Installed Pi 1.4.0 RPC: executionsBeforeStop=3, requestsBeforeStop=4, operationalResetDenied=true, userResetAllowed=true, durableNotice=true; policy ownership/reset cases
The managed safeguard refuses conflicting legacy files without changing operator-installed ignored files ⏸️ untested no The prior payload cites policy test cases only and does not establish a live result; no live product validation for this scenario is recorded.
Affected test selection and packing retain full coverage and serial placement ⏸️ untested no The prior payload records a coverage/packing command result, but it does not establish that this scenario was driven against the live product.
  • bash bin/fm-test-run.sh tests/fm-read-repetition.test.sh tests/fm-read-repetition-live.test.sh
  • bash tests/fm-pi-primary-types.test.sh (started; output confirmed Pi 1.1 and 1.2 SDK checks before the command ended)
  • LC_ALL=C bash bin/fm-test-run.sh --check-coverage
  • git diff --check

🔧 Fix applied.
2 warnings still open:

  • ⚠️ The changed-file selector includes both read-repetition suites and the Pi SDK check, but its scheduled output also selects many unrelated suites. This validates that the affected checks are retained, not that changed-file selection is narrow.
  • ⚠️ live validation verdict: inconclusive (1 of 3 scenarios were driven live against the product); untested: An operator-installed ignored legacy guard/helper conflicts with activation; loading refuses with migration guidance and leaves those files and configuration unchanged., The test runner selects the affected read-repetition, live-RPC, and Pi SDK checks, while coverage and packing retain every suite and valid serial placement.
  • Live validation: ⚠️ inconclusive - 1 of 3 scenarios driven live against the product
Scenario Result Live Evidence
A Pi primary repeats successful reads until the safeguard stops further execution and retains the stop across restart; operational follow-ups cannot reset it, while genuine user input can. ✅ pass live Installed Pi RPC behavior output from tests/fm-read-repetition-live.test.sh
An operator-installed ignored legacy guard/helper conflicts with activation; loading refuses with migration guidance and leaves those files and configuration unchanged. ⏸️ untested no The prior payload cites policy-suite assertions but does not establish that this scenario was driven against the live product.
The test runner selects the affected read-repetition, live-RPC, and Pi SDK checks, while coverage and packing retain every suite and valid serial placement. ⏸️ untested no The prior payload reports coverage and scheduled-selection command output, but does not establish that this scenario was driven against the live product.
  • bash bin/fm-test-run.sh tests/fm-read-repetition.test.sh tests/fm-read-repetition-live.test.sh
  • bash bin/fm-test-run.sh --check-coverage
  • bash bin/fm-test-run.sh --changed --base 7da4c3621370534ff9689843d2b77f34158057fb --list-scheduled

🔧 No changes applied.
✅ Re-checked - no issues remain.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
An operator enables the managed guard with conflicting ignored legacy files installed; Pi refuses activation with migration guidance and preserves the files and configuration. ✅ pass live Installed Pi collision refusal: disposable HOME/FM_HOME, actual Pi RPC loader, migration diagnostic, and matching before/after SHA-256 hashes.
A user runs the affected-file selector and coverage guard; both retain the read-repetition and SDK checks and report complete, valid suite packing. ✅ pass live --list-scheduled output included fm-read-repetition.test.sh, fm-read-repetition-live.test.sh, and fm-pi-primary-types.test.sh; --check-coverage reported 295 covered suites and valid packing.
A Pi primary encounters repeated successful reads; the installed guard vetoes further execution, retains its stopped state through operational input, and resumes only after genuine user input. ✅ pass live tests/fm-read-repetition-live.test.sh installed Pi RPC fixture reported 3 executions before stop, operational reset denied, user reset allowed, and durable notice; focused policy tests also exercise…
  • bash bin/fm-test-run.sh --changed --base 7da4c3621370534ff9689843d2b77f34158057fb --list-scheduled
  • bash bin/fm-test-run.sh --check-coverage
  • bash bin/fm-test-run.sh tests/fm-read-repetition.test.sh tests/fm-read-repetition-live.test.sh
  • bash tests/fm-pi-primary-types.test.sh
  • Disposable HOME/FM_HOME: installed pi --mode rpc --no-extensions -e <managed-extension> with fake legacy guard/helper files and enabled config; compared SHA-256 hashes before and after
  • bwrap --unshare-user --unshare-pid --unshare-net --die-with-parent ... bash bin/fm-test-run.sh tests/fm-test-run.test.sh tests/fm-ci-workflow.test.sh
  • tests/fm-test-run.test.sh outside the private PID namespace, to confirm the orphan-adoption fixture requires that namespace
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Add an off-by-default Linux Pi primary safeguard with bounded configurable
limits, verified ownership, durable stopping, and deliberate user reset.
Preserve ignored legacy guards and require explicit collision migration.

Cover policy, SDK compatibility, installed RPC behavior, and test selection.
Refs kunchenguid#7805.
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @kesslerio. This follows the shape we discussed on #7805 closely, and the off-by-default, primary-only ownership checks are exactly right.

What I checked at head 246057b1 against main 7da4c362: .pi/extensions/fm-primary-read-repetition.ts loads in every Pi primary. With no config/read-repetition.json, loadReadRepetitionLimits returns DEFAULT_LIMITS (enabled: false), and registerReadRepetitionGuard returns before it registers any hook. The legacy-guard check, the ownership checks, and the ps ancestry walk only run once you enable the guard. When enabled, it is Linux-only and primary-only. It stays inert for workers and supervision actors, and an operational follow-up can't reset the stop. The bin/fm-test-run.sh changes only add the two suites, their family and hint lines, and LC_ALL=C on the coverage-guard comm calls. I found no network or credential handling and no workflow edits.

CI (run 40444119166): everything is green except Behavior portable serial 1. It failed at latch: the first engine error did not hand the wake back in tests/fm-supervision-host.test.sh. That's the supervision-host hand-back flake that's reddening main right now. This PR doesn't touch that file, so it's on our side, not yours. I've asked for a rerun of the failed job. The no-mistakes attestation binds this head, and live validation is reported as 3/3 go.

Contract-class: opt-in. That's my own read: the guard is off unless config/read-repetition.json sets enabled: true, and the unconfigured Pi primary behaves as it does on main.

VISION:

  • One captain, one interface: aligns. A stop hands control back instead of silently burning context.
  • Authority is explicit: aligns. It's opt-in, and only genuine user input resets it.
  • Scripts own the mechanics: aligns. It's exact fingerprint counting.
  • Restart is a non-event: aligns. The latch persists in session entries.
  • Delegation with a spine: n/a.
  • Vendor: aligns. It's a Pi-specific adapter in Pi's own extension surface, and other harnesses are untouched.
  • Scope: aligns.

Nothing is needed from you. If the rerun comes back green and the branch is clean, it's an opt-in merge on a later pass.

@kunchenguid kunchenguid reopened this Oct 28, 2026
@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable defect was established.

Reviews (1) · Last reviewed commit: "no-mistakes(test): Fixed locale-dependen..." · Reviewed by Greptile

@kunchenguid
kunchenguid merged commit 325f7e2 into kunchenguid:main Oct 28, 2026
92 of 96 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @kesslerio — really appreciate you taking the time on this.

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.

Primary Pi session keeps repeating successful unchanged reads

2 participants