Skip to content

refactor: modularize the core while preserving the standalone SSH artifact #112

Closed

Description

@abruption

session_peer.py has grown to about 3,972 lines, 133 top-level functions and 16 classes. It now contains Codex home ownership, Claude transport, Antigravity bridging, SSH/Tailscale routing, reply envelopes, diagnostics, update logic and CLI construction. The single-file form remains valuable because SSH list/send can push and execute one standard-library-only file on a destination that has not installed the package.

Design and implement a staged internal modularization without losing that deployment property.

Constraints

  • Python 3.9 remains the core floor and the core CLI remains third-party-dependency-free.
  • session_peer.py must remain directly executable and usable by install.sh, remote push/update and old standalone deployments.
  • Existing CLI flags, exit codes, JSON envelopes, security failure modes and submission/consumption semantics remain compatible unless separately approved.
  • Keep the frozen root cc_peer.py compatibility artifact unchanged.
  • Do not mix relay protocol changes, OAuth/control changes or live infrastructure changes into this refactor.

Proposed direction

  1. Define stable internal boundaries such as codex, claude, antigravity, ssh, diagnostics, updates, replies and CLI wiring.
  2. Keep canonical maintainable source in an internal package.
  3. Produce the standalone script deterministically at build/release time, or choose an equivalently reviewable design that does not require the destination to install a package.
  4. Add a CI check that regenerating the standalone artifact produces no diff.
  5. Migrate one boundary at a time with behavior-focused tests before deleting the old section.

Acceptance criteria

  • Maintainers edit each implementation in one canonical place; no hand-maintained duplicate modular and standalone logic.
  • The standalone script works when copied alone to a clean supported host.
  • Local, SSH, Codex multi-home/wake, Claude, Antigravity, doctor, update, MCP and paired relay dispatch tests retain their current behavior.
  • Wheel and sdist entry points remain installable and the standalone updater remains compatible.
  • Generation is deterministic and fails CI on stale output.
  • macOS/Linux Python 3.9/3.13 and Windows Python 3.13 CI pass, along with optional relay/MCP jobs.
  • Documentation explains the canonical source and generated artifact boundary.

Sequencing

Do this after the repository layout cleanup in #111 so file moves and behavioral refactoring are not mixed in one review.

Activity

  1. added this to the v1.0.0 milestone on Sep 20, 2026
  2. abruption commented on Sep 20, 2026

    @abruption
    OwnerAuthor

    Target release: v1.0.0 stable. Sequence this after the test/CI boundaries in #113. The stable-release gate is behavioral compatibility across the alpha CLI, deterministic standalone generation, clean install/update/remote-push verification, and the full supported OS/runtime matrix; this is not an alpha patch refactor.

  3. abruption commented on Sep 21, 2026

    @abruption
    OwnerAuthor

    The v1 compatibility contract proposed in #120 is the behavioral baseline for this modularization. Please keep tests/fixtures/compatibility-v1.json and tests/test_compatibility_contract.py green, preserve the generated standalone CLI's required JSON/exit/reply behavior, and treat any incompatible surface change through the documented version or migration rule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions