Goal
Move structured setup/check/doctor JSON assembly out of shell argument construction and into Python-owned code while preserving the current JSON schema and command behavior.
Background
#1570 split the coherent shell ownership domains out of setup_common.sh: Linux/Debian platform setup, macOS/Homebrew setup, Base runtime venv/bootstrap, and setup/check profiles. The remaining structured JSON path is a different cleanup boundary. It is schema and serialization work, not another shell helper split.
Keeping JSON payload assembly in shell makes schema changes harder to test and increases quoting/escaping risk. Python is already the owner for structured project data, manifest parsing, artifact decisions, workspace data, and stable JSON serialization.
Scope
- Inventory the JSON payloads currently coordinated by setup_common.sh, including setup_run_check_json(), project virtualenv check/doctor snippets, and Base finding metadata.
- Add Python-owned assembly/serialization for the structured check and doctor payloads.
- Keep shell responsible for command dispatch, process orchestration, human text rendering, exit-status handling, and pre-runtime fallback routing.
- Preserve current JSON keys, value types, ordering expectations where tests depend on them, and exit behavior.
- Add focused tests that compare representative before/after payloads for base, profile, project, and pre-venv failure paths.
Acceptance Criteria
- setup_common.sh no longer owns general JSON argument assembly for setup check/doctor payloads.
- Current JSON output shape is preserved for existing tested setup/check/doctor paths.
- Shell remains the thin orchestrator for dispatch and fallback paths.
- Python owns schema construction and serialization for structured payloads.
- Documentation records the new boundary between shell orchestration and Python JSON ownership.
Validation
- Focused Python tests for the new JSON assembly surface.
- Existing setup/check/doctor JSON tests.
- Focused BATS coverage for shell dispatch into the Python JSON surface.
- Shell syntax checks for touched shell files.
- ShellCheck at the repository standard for touched shell files where practical.
- git diff --check.
Non-Goals
- Do not change user-visible setup/check/doctor JSON schema in this issue.
- Do not rewrite top-level setup/check/doctor orchestration in Python.
- Do not move platform install bodies out of their current domain helpers.
- Do not use this issue to continue splitting shell files by line count.
Project Fields
- Priority: P2
- Status: Backlog
- Size: M
- Area: Setup
- Initiative: Contract Hardening
Agent Assignment
Goal
Move structured setup/check/doctor JSON assembly out of shell argument construction and into Python-owned code while preserving the current JSON schema and command behavior.
Background
#1570 split the coherent shell ownership domains out of setup_common.sh: Linux/Debian platform setup, macOS/Homebrew setup, Base runtime venv/bootstrap, and setup/check profiles. The remaining structured JSON path is a different cleanup boundary. It is schema and serialization work, not another shell helper split.
Keeping JSON payload assembly in shell makes schema changes harder to test and increases quoting/escaping risk. Python is already the owner for structured project data, manifest parsing, artifact decisions, workspace data, and stable JSON serialization.
Scope
Acceptance Criteria
Validation
Non-Goals
Project Fields
Agent Assignment