Skip to content

feat: Policy P-022 headless CLI, SKILL.md, and config/download hardening - #16

Open
lukisch wants to merge 1 commit into
mainfrom
feat/p022-headless-cli-skill-and-hardening-20261126
Open

lukisch wants to merge 1 commit into
mainfrom
feat/p022-headless-cli-skill-and-hardening-20261126

Conversation

@lukisch

@lukisch lukisch commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Policy P-022 Dual-Use Headless CLI (mailprocessor_cli.py, main.py, pyproject.toml):
    • Added dependency-free CLI subcommands (status, scan [--apply], snapshot [--out], register, unregister --yes|--dry-run, launch [--dry-run], store-readiness) plus --version and --json output with redacted path hints.
    • Added [project.scripts] entrypoint mailprocessor = "mailprocessor_cli:main" and lazy PySide6 import in main.py so CLI runs cleanly on headless hosts without Qt.
  • Policy P-022 Documentation (SKILL.md, llm.txt, llms.txt, README.md, README-DE.md, CHANGELOG.md):
    • Added SKILL.md and llm.txt; updated llms.txt (Last-checked: 2026-11-26), README.md, README-DE.md, and CHANGELOG.md [Unreleased] while keeping version 0.1.0 frozen.
  • Config & ToolManager Hardening (config.py, tool_manager.py):
    • Normalized top-level language, first_run, and start_with_windows types in config.load() so malformed JSON values fall back safely.
    • Switched _find_tool() and find_script_in_folder() to is_file() checks.
    • Validated zipball_url scheme (http/https), rejected symlink ZIP entries, and cleaned up partial .zip files on download stream errors.

Verification

  • python -B -X utf8 -m pytest tests -ra: 127 passed
  • ruff check --no-cache .: All checks passed
  • python -B -X utf8 -m compileall -q .: exit 0
  • python -B -X utf8 tests/source_platform_smoke.py: PASS (including headless CLI smoke)
  • lint_mermaid.py: 15 MD / 2 Mermaid CLEAN
  • git diff --check: 0 issues

…/download

- Add dependency-free headless CLI (`mailprocessor_cli.py`) and `mailprocessor` console script entrypoint (`pyproject.toml`) with `--version`, `--json`, `status`, `scan [--apply]`, `snapshot [--out]`, `register`, `unregister --yes|--dry-run`, `launch [--dry-run]`, and `store-readiness`.
- Dispatch headless CLI subcommands/flags in `main.py` before importing PySide6 so CLI runs without GUI dependencies.
- Add Policy P-022 product docs (`SKILL.md`, `llm.txt`) and update `llms.txt`, `README.md`, `README-DE.md`, and `CHANGELOG.md [Unreleased]` (version `0.1.0` frozen).
- Harden `config.load()` top-level field normalization (`language`, `first_run`, `start_with_windows`) and `ToolManager` (`is_file()` checks, HTTP/HTTPS `zipball_url` validation, symlink entry rejection, partial ZIP cleanup on stream errors).
- Expand test suite and source-platform smoke from 116 to 127 passing tests.

@ellmos-multi-bot ellmos-multi-bot 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.

Independent MULTI-BOT Review (REQUEST_CHANGES)

  • Model: Gemini 4 Carbon (Medium) (with independent second-instance verification)
  • Reviewed Head SHA: 42eb31b110dac24823dc748e80a11eae489aa18d
  • Scope: Full diff across all 17 changed files (mailprocessor_cli.py, main.py, config.py, tool_manager.py, pyproject.toml, SKILL.md, llm.txt, llms.txt, README.md, README-DE.md, CHANGELOG.md, and 5 test modules) in an isolated worktree.
  • Verification: python -B -m pytest -q (127 passed, 6 subtests passed), python tests/source_platform_smoke.py (PASS), ruff check . (0), pip install --no-deps --no-build-isolation --dry-run . (OK), GitHub Actions CI 15/15 SUCCESS, repo_privacy_gate.py (Exit 1 — regression vs. main Exit 0).

Findings

  1. [P1] tests/test_tool_manager.py:639 — Breaks repository privacy gate (repo_privacy_gate.py Exit 1):
    • On main, repo_privacy_gate.py passes cleanly (Exit 0). Introducing the literal "file:///etc/passwd" in test_download_tool_rejects_non_http_zipball_url triggers the unresolvable local file:/// URI check (Exit 1). Using a non-HTTP scheme such as "ftp://example.com/release.zip" exercises the exact same scheme guard without tripping the public repository gate.
  2. [P2] tool_manager.py:59-61, 344, 359 — _is_valid_http_url() allows cleartext http:// for executable release archives and leaves zipball_url unstripped:
    • Because download_tool() fetches and extracts runnable Python tool scripts (tool_manager.py:394-420), zipball_url should require https exclusively (rejecting cleartext http:// downgrade paths) and pass the stripped URL to urllib.request.Request.
  3. [P2] mailprocessor_cli.py:23-29 & main.py:129-145 — Unknown CLI arguments silently fall through to the Qt desktop GUI:
    • should_dispatch_cli() only matches known subcommands and five flags (-h, --help, -V, --version, --json). A mistyped subcommand or flag (e.g. python main.py stat --json or python main.py --verison) returns False and launches QApplication(sys.argv) / the tray wizard (or raises ModuleNotFoundError when PySide6 is absent) instead of exiting deterministically with CLI exit code 2.
  4. [P2] README.md:139-155, 207-212 & README-DE.md:139-155, 210-215 — Complete P-022 installation section & dependency scope note:
    • Please add the copyable ### Install with your LLM / ### Mit deinem LLM installieren prompt block referencing llms.txt and SKILL.md under ## Installation, and clarify under Requirements/Voraussetzungen that PySide6 is only needed for the desktop GUI while the headless CLI runs on the Python standard library (matching SKILL.md:35-36).

lukisch commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator Author

Zweitmodell-Review (Cloud-Bot), Head 42eb31b: Mergebar mit Hinweisen (keine Blocker)

Geprüft

  • CI: alle 15 Check-Runs grün (Windows-Tests 3.10–3.13, Source-Platform-Smoke Ubuntu/macOS 3.10–3.13, CodeQL). mergeable_state: clean.
  • Lokal (Linux, Python 3.11, QT_QPA_PLATFORM=offscreen): pytest -q → 126 passed, 1 failed. Der Fehlschlag (test_snapshot_export.py::test_build_snapshot_payload_redacts_private_paths_and_reports_statuses, 'linux' == 'windows') tritt identisch auf main auf, ist also plattformbedingt und keine Regression dieses PRs. ruff check . → sauber.
  • Diff: mailprocessor_cli.py, Lazy-Import in main.py, config.load()-Typnormalisierung, tool_manager.py (is_file(), URL-Schema-Prüfung, Symlink-Ablehnung in ZIPs, Aufräumen von Teil-Downloads). Die Härtungen sind korrekt; stat ist in tool_manager.py bereits importiert, die Zip-Slip-Prüfung bleibt erhalten.
  • CLI ausgeführt (isoliertes HOME): --help, --version, status --json, snapshot, register ohne Argumente (Exit 2), launch bogus (Exit 2, JSON mit valid_tool_ids), unregister ohne --yes (Exit 2). Alle in SKILL.md dokumentierten Aufrufe (<subcommand> … --json) existieren und funktionieren.

Blocker

Keine.

Nicht blockierende Hinweise

  1. --json vor dem Subcommand wird stillschweigend ignoriert (mailprocessor_cli.py:284 + :297): mailprocessor --json status liefert Textausgabe, mailprocessor status --json dagegen JSON. Ursache: parser.set_defaults(json=False) setzt den Default der geteilten --json-Action aus dem common-Parent auf False (argparse teilt die Action-Objekte zwischen Parent und Subparsern). Damit überschreibt der Subparser den bereits gesetzten Top-Level-Wert. Die Hilfe bewirbt aber mailprocessor [-h] [--json] [-V]. Abhilfe: set_defaults(json=False) entfernen und stattdessen getattr(args, "json", False) verwenden, oder ein eigenes dest für das Top-Level-Flag. Ein Test für ["--json", "status"] würde das absichern.
  2. snapshot --out "" (mailprocessor_cli.py:129): if args.out: behandelt einen leeren String wie „kein --out“ und schreibt nach stdout, statt den in write_snapshot() vorgesehenen ValueError/Exit 2 auszulösen. if args.out is not None: wäre konsistenter.
  3. Tippfehler im Subcommand starten die GUI: should_dispatch_cli() leitet nur bekannte Subcommands und Flags an die CLI weiter. mailprocessor statsu startet deshalb den Tray. Auf einem headless Host bricht Qt dann mit SIGABRT ab (lokal: Exit 134). Für Agenten wäre eine Fehlermeldung mit Exit 2 hilfreicher, etwa wenn das erste Argument nicht mit - beginnt und kein bekannter Befehl ist. Das ist eine Designentscheidung, kein Bug.
  4. --version fällt bei fehlender Versionsquelle auf den hartkodierten Wert "0.1.0" zurück (:345, ebenso in _cmd_status). Das ist harmlos, aber beim nächsten Versionssprung leicht zu übersehen.

Generated by Claude Code

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