Skip to content

fix(output): escape non-ASCII paths; print each uninstall removal line once (#4330, #4331) - #4425

Closed
Daniel Meppiel (danielmeppiel) wants to merge 6 commits into
mainfrom
bug-sweep/p4330
Closed

Daniel Meppiel (danielmeppiel) wants to merge 6 commits into
mainfrom
bug-sweep/p4330

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

Two 0.37 bug-sweep output defects found by the lifecycle output oracle (#4113).

  • apm install echoes a non-ASCII project path raw in its output #4330 (I6, ASCII output). A non-ASCII package or project path was echoed raw ([+] /tmp/x/pkg-über), which can raise UnicodeEncodeError on cp1252 terminals. Fixed at the console owner, src/apm_cli/utils/console.py: the one ASCII Rich console class (_ascii_console, used by _get_console, _get_stderr_console and new_console) now escapes non-ASCII text with ascii_safe() (\u00fc -> \xfc). Escaping happens in render_str, before layout, so table columns size the escaped text; the render-buffer pass escapes any pre-built renderable; the click fallback escapes too. Every status helper, CommandLogger, table and tree prints through this console.
  • apm uninstall prints the same removal lines once per duplicate declaration #4331 (I9, no duplicate lines). apm uninstall of a package declared more than once printed identical lines once per declaration (found in apm.yml, the dry-run plan, Removed <pkg> from dependencies.apm in apm.yml), and warned not found in apm_modules/ for the second declaration of a copy it had just removed. Each distinct removal line now prints once (_progress_once in commands/uninstall/engine.py, used by the engine and cli.py), and an already removed path is skipped silently. Counts in the summary lines are unchanged.

Strict cells flipped

Issue and approved scope

Fixes #4330 (scope record: #4330 (comment))
Fixes #4331 (scope record: #4331 (comment))

Remaining (follow-up, not in this PR): a few raw click.echo/print calls outside the console (Rich-unavailable fallbacks and legacy adapters) are not routed through ascii_safe; the global oracle covers every lifecycle-tested command.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)
promise: P-INV-I6 -- output is printable ASCII (source: .github/instructions/encoding.instructions.md)
cell: OP=install|deps-list|uninstall SRC=local PRIM=skill SCOPE=project TGT=claude   owner: src/apm_cli/utils/console.py
instrument: today test -> tests/integration/test_non_ascii_path_output_lifecycle.py::test_non_ascii_package_path_is_echoed_escaped (new: no non-ASCII path cell existed)
oracles: [I6, I9 global oracle, exact escaped lines, skill deployed/removed]  decisive: stdout.isascii() and "[+] <path-with-\xfc>" present
failing-before: main src -> OutputOracleError: I6: stdout has characters outside printable ASCII ['0xfc']
passing-after: 1 passed
ledger: #4330

promise: P-INV-I9 -- no duplicate lines (source: tests/quality/promise-catalog.json)
cell: OP=uninstall SRC=git SCOPE=project DECLARATIONS=3 (prod x2, dev x1)   owner: src/apm_cli/commands/uninstall/engine.py
instrument: today test -> tests/integration/test_duplicate_declaration_lifecycle.py::test_uninstall_removes_every_declaration_of_one_package (extends)
oracles: [I9 global oracle, exact line counts in preview and real run]  decisive: "Removed test/c from dependencies.apm in apm.yml" printed exactly once
failing-before: main src -> OutputOracleError: I9: stdout repeats a line: '[i] Removed test/c from dependencies.apm in apm.yml'
passing-after: 1 passed
ledger: #4331

Commands (host load ~0, sequential, -n 0, single nodes):

  • APM_BINARY_PATH=.venv/bin/apm uv run --extra dev pytest -n 0 tests/integration/test_non_ascii_path_output_lifecycle.py "tests/integration/test_duplicate_declaration_lifecycle.py::test_uninstall_removes_every_declaration_of_one_package" -- 2 passed; with main's src/ -- 2 failed (output above).
  • ruff check / ruff format --check (uv.lock-pinned) on touched files -- passed.
  • Full suites: CI.

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

No normative behavior changes.

… line once (#4330, #4331)

#4330: the ASCII Rich console (utils/console.py) escapes non-ASCII text to
printable ASCII (`\xfc`) in render_str, before layout so table columns size
the escaped text, and in its render-buffer pass for pre-built renderables;
the click fallback escapes too. Every status helper, table and tree prints
through this console, so a non-ASCII package or project path never reaches
a cp1252 terminal raw.

#4331: uninstall prints each removal line once when one package has several
declarations sharing a public label (found in apm.yml, the dry-run plan, and
"Removed ... from dependencies.apm in apm.yml"); the second declaration of an
already removed apm_modules copy no longer warns "not found".

Both strict output cells (command-echoes-non-ascii-path,
uninstall-duplicate-declaration-lines) are removed; installed-CLI tests fail
before and pass after.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.37.0 milestone Nov 20, 2026
Copilot AI balanced review requested due to automatic review settings November 20, 2026 16:59
Co-authored-by: copilot-swe-agent[bot] <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Non-ASCII characters in pre-built Text cells are escaped after table layout, causing column misalignment and potential console-width overflow.

1 open issue
What changed in this PR

This PR addresses two CLI output defects exposed by the lifecycle output oracle: raw non-ASCII paths (#4330) and repeated uninstall messages (#4331).

Changes:

  • Escapes non-ASCII text through the shared console and its Click fallback.
  • Deduplicates uninstall progress messages and skips package directories already removed.
  • Adds lifecycle regression coverage, removes corresponding oracle exemptions, and records the fixes.
File Description
tests/​utils/​lifecycle_evidence.py Removes the two known-output exemptions.
tests/​integration/​test_non_ascii_path_output_lifecycle.py Tests escaped paths across install, list, and uninstall.
tests/​integration/​test_duplicate_declaration_lifecycle.py Checks that duplicate declarations produce each removal line once.
tests/​fixtures/​lifecycle_bug_ledger.json Links both fixes to regression tests.
src/​apm_cli/​utils/​console.py Adds ASCII escaping for strings, rendered segments, and fallbacks.
src/​apm_cli/​commands/​uninstall/​engine.py Deduplicates progress and avoids repeated directory removals.
src/​apm_cli/​commands/​uninstall/​cli.py Deduplicates manifest-removal messages.
CHANGELOG.md Documents both user-visible output fixes.

Review effort: Balanced

Comment thread src/apm_cli/utils/console.py Resolved
#4331)

The generator's evidence anchors move with the new _progress_once helper
(engine.py) and the added import (cli.py); obligations regenerated. The unit
test that passed a package twice now expects its 'found in apm.yml' line
once, which is the #4331 fix.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Regenerate tests/quality/lifecycle_obligations.json on the merged tree.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Review: a Text cell bypasses render_str, so escaping it in the render-buffer
pass widened its cell after measurement. The ASCII console's print now
escapes Text (directly or inside a table, panel, padding, tree or group)
before Rich measures it, keeping style spans (ascii_text splits at span
boundaries). Narrow-table regression with ASCII and non-ASCII Text cells.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Main dropped the #4333 cell; this PR drops #4330 and #4331.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
…install removal line once (#4330, #4331)

Co-authored-by: Copilot App <[email protected]>

# Conflicts:
#	tests/fixtures/lifecycle_bug_ledger.json
#	tests/lifecycle/generator/rules.py
#	tests/quality/lifecycle_obligations.json
#	tests/utils/lifecycle_evidence.py
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

Closing as superseded: this change shipped in v0.37.0 through the release train (#4424). Its core source and test files are byte-identical on main, and the linked issues are closed as completed in 0.37.0. The only remaining differences are in shared files that every train PR touches (CHANGELOG, bug ledger, owner registry). Nothing is left to land. -- regent, 0.37 milestone close-out

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.

apm uninstall prints the same removal lines once per duplicate declaration apm install echoes a non-ASCII project path raw in its output

2 participants