Skip to content

fix: resolve second-round audit findings for Rust runtime removal (R2-1..R2-7) - #129

Merged
zy1233 merged 2 commits into
mainfrom
fix/rust-runtime-removal-audit-r2
Nov 15, 2026
Merged

zy1233 merged 2 commits into
mainfrom
fix/rust-runtime-removal-audit-r2

Conversation

@zy1233

@zy1233 zy1233 commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Summary

Resolves all findings (R2-1 through R2-7 plus first-audit follow-up items) from the second code audit of the Rust Agent Runtime Removal implementation (docs/AUDIT/AUDIT-RUST-RUNTIME-REMOVAL-2026-11-15.md):

  • R2-1 (pi/session/delete state cleanup in Python): Extract _release_session(session_id) shared by close_session and ext_method("pi/session/delete") in packages/pi-agent-cli/pi_agent_cli/agent.py so deleting an open session also forgets _session_models, _session_cwds, and calls auto.cancel().
  • R2-2 (F-1 follow-up: early tracing init & deduplicated telemetry init): Move GROK_LOG_SAMPLING and crate::tracing::init_tracing() to the entry of pi_pager::app::run (before acp::connect and resolve_startup), pass TracingHandle into event_loop::run, remove the duplicate pi_telemetry::external::init call in app/mod.rs, and remove unused parameters from unified_log::make_entry.
  • R2-3 (F-2 follow-up: <home>/pager-cache orphan image placeholder allowlist): Include <home>/pager-cache in build_content_blocks_with_workspace's allowed prefix list (allowed_prefixes_with_pager_cache_in) so orphan [Image #N: <path>] placeholders in the relocated pager cache directory can be resolved while keeping <home> root files excluded.
  • R2-4 (scripts/tui_baseline.py #[cfg(test)] parser hardening): Track the indentation of mod tests and handle single-line mod tests {}, same-line #[cfg(test)] mod tests, and comments/blank lines between #[cfg(test)] and mod tests in production_lines().
  • R2-5 (pi-home tilde expansion): Expand ~, ~/..., and ~\... in PI_HOME / GROK_HOME against os_home in tui/crates/codegen/pi-home/src/lib.rs, matching Python (expanduser()) and pi-vscode (expandHome).
  • R2-6 (pi-pager-bin -p -v precedence, dead compaction env vars, print_mode::ignored_flags): Check -v/--version and doctor before dispatch_python_print, remove dead GROK_COMPACTION_MODE / GROK_COMPACTION_DETAIL env var writes in async_main, and add --trust, --compaction-mode, --compaction-detail, --worktree-ref, --restore-code, --no-ask-user, --no-wait-for-background, and --oauth to print_mode::ignored_flags.
  • R2-7 (AcpMethod::ext_name forwarding, ACP extension register, stale comments): Forward AcpMethod::ext_name() on AcpArgsGeneric, AcpClientMessageGeneric, and AcpAgentMessageGeneric; update docs/specs/2026-11-05-acp-extension-registry.md with packages/pi-vscode callers and §5 client-only _meta keys; clean up stale comments in agent_modes.rs and session_startup.rs.

Verification

  • .venv/bin/ruff check & .venv/bin/ruff format --check
  • .venv/bin/python -m pytest packages/pi-agent-cli/tests/ scripts/tests/
  • .venv/bin/python scripts/tui_baseline.py gates
  • cargo test --locked -p pi-home -p pi-acp-lib -p pi-pager-render -p pi-pager-bin & cargo check --locked -p pi-pager -p pi-pager-bin --tests

zy1233 and others added 2 commits November 15, 2026 12:23
…-1..R2-7)

Second full-repo audit of the Rust Agent Runtime Removal implementation
against `PLAN-RUST-AGENT-RUNTIME-REMOVAL.md` (r48), `docs/DESIGN.md` §8,
and `docs/specs/2026-11-05-acp-extension-registry.md` (`docs/AUDIT/AUDIT-RUST-RUNTIME-REMOVAL-2026-11-15.md`):

- R2-1 (`packages/pi-agent-cli/pi_agent_cli/agent.py`): unify open-session
  release in `_release_session()` shared by `close_session` and
  `ext_method("pi/session/delete")` so deleting an open session also pops
  `_session_models`, `_session_cwds`, and cancels its `auto` gate.
- R2-2 (`tui/crates/codegen/pi-pager`): initialize `tracing` at the start
  of `app::run` before `acp::connect` and `resolve_startup`, remove the
  duplicate `pi_telemetry::external::init()` call, log startup connection
  errors to tracing, and drop unused `_lvl`/`_sid` parameters in
  `unified_log::make_entry`.
- R2-3 (`tui/crates/codegen/pi-pager-render/src/prompt_images.rs`): add
  `<home>/pager-cache` to the orphan `[Image #N: <path>]` placeholder
  recovery prefix allowlist after F-2 moved pasted image caches out of
  `<home>/sessions`.
- R2-4 (`scripts/tui_baseline.py`): harden `production_lines()` against
  indented or single-line `#[cfg(test)] mod tests` blocks and intervening
  comments/attributes so gate scanners cannot skip following production code.
- R2-5 (`tui/crates/codegen/pi-home/src/lib.rs`): expand leading `~` in
  `PI_HOME` / `GROK_HOME` against `os_home`, matching Python and VS Code.
- R2-6 (`tui/crates/codegen/pi-pager-bin`): handle `-v`/`--version` and
  `doctor` before `dispatch_python_print`, remove dead
  `GROK_COMPACTION_MODE` / `GROK_COMPACTION_DETAIL` env writes, and add the
  remaining 8 unforwarded flags to `print_mode::ignored_flags`.
- R2-7 (`pi-acp-lib`, `docs/specs/2026-11-05-acp-extension-registry.md`,
  `pi-pager`): forward `AcpMethod::ext_name()` through `AcpArgsGeneric`,
  `AcpClientMessageGeneric`, and `AcpAgentMessageGeneric`; record
  `packages/pi-vscode` callers and client-only `_meta` keys in the ACP
  extension register; clean up two stale comments from F-5.
…stale numbers and comments

The ACP register and the second audit named files and functions of the
VS Code extension that do not exist (session-service.ts,
session-projector.ts) and the old folder packages/pi-vscode, which is
vscode/ on main. Use the real places (acp-connection.ts,
chat-controller.ts, first-run.ts).

Also: docs/baselines/tui.md equals the manifest (1,098 and 8,241); the
orphan-prefix helper no longer sits between a doc comment and its
function; three stale GROK_COMPACTION_* comments; two stray words and the
close_session sentence in the audit file. Docs and comments only.
@zy1233
zy1233 merged commit 891624a into main Nov 15, 2026
18 checks passed
@zy1233
zy1233 deleted the fix/rust-runtime-removal-audit-r2 branch November 15, 2026 09:26
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.

2 participants