Skip to content

Architecture: deepen local runtime seams #44

Description

@ElbertePlinio

Goal

Concentrate repeated local runtime policy into a few deep modules so future browser, storage, and provisioning work changes one implementation rather than lockstep CLI/MCP or command paths.

Why

Current source duplicates local session lifecycle composition across CLI and MCP, splits local teardown between explicit destroy and reaping, divides run verification among readers, and leaves provisioning privilege metadata outside execution policy. This increases change cost and makes the important interface test surface hard to exercise once.

Top priority

PR 1 — Centralize local session lifecycle composition. It removes source-confirmed duplicate transaction policy with high confidence and medium risk, while preserving browser ownership, viewer behavior, evidence wrapping, and control-state separation.

Architecture constraints

Scope / acceptance checklist

  • One local lifecycle implementation owns recipe expansion, rollback, typed destroy dispatch, and canonical status aggregation; CLI/MCP output behavior remains unchanged.
  • Reaper and explicit destroy use one typed runtime teardown owner; retry and durable finalization semantics remain characterized.
  • One verified run catalog owns root precedence, directory/manifest binding, ordering, and verified reads before Store run artifacts outside project repositories by default #34 storage modes land.
  • One provisioning implementation owns consent, dry-run, privilege routing, cancellation, and partial results; no credential material is captured or persisted.
  • Focused characterization tests cover the retained invariants before each migration.
  • Typecheck and build pass for every PR; full validation follows normal repository policy.

Dependency-ordered PR plan

PR 1 — Centralize local session lifecycle composition

  • Depends on: none
  • Touches: CLI/MCP session adapters, MCP session resources, shared local lifecycle implementation, focused lifecycle tests
  • Prove: desktop+Android rollback, abort behavior, browser status, destroy-all partial failures, and adapter-specific viewer/evidence behavior remain unchanged
  • Validation: bun run test packages/cli/test/commands.test.ts packages/mcp-server/test/tools.test.ts packages/mcp-server/test/browser.test.ts; bun run typecheck; bun run build
  • Link: pending

PR 2 — Route reaper teardown through typed runtime ownership

  • Depends on: PR 1 preferred; coordinate with Harden pre-identity browser daemon cleanup #29
  • Touches: core reaper, desktop/Android/browser teardown adapters, reaper/destroy characterization tests
  • Prove: explicit destroy and reaping share typed stop outcomes; failed cleanup retains retryable state; durable finalization remains correct
  • Validation: focused core session/reaper plus desktop, Android, and browser destroy tests; bun run typecheck
  • Link: pending

PR 3 — Establish verified run catalog and land #34 storage resolver

  • Depends on: none
  • Touches: core run/evidence/path/config logic, CLI artifacts, MCP resources, storage compatibility tests
  • Prove: verified reads bind manifest identity to its directory; legacy runs remain readable; new writes follow configured storage mode with no automatic migration
  • Validation: bun run test packages/core/test/run.test.ts packages/core/test/evidence.test.ts packages/mcp-server/test/resources.test.ts; focused Store run artifacts outside project repositories by default #34 config/path tests; bun run typecheck; bun run build
  • Link: pending

PR 4 — Deepen provisioning execution policy

  • Depends on: none; Support secure graphical sudo prompts for agent commands #27 follows through this implementation
  • Touches: provisioning executor, setup-lab-user, setup-android, doctor, init, planner/executor tests
  • Prove: consent, dry-run, privileged routing, cancellation, and partial failures are consistent across commands without changing command wording
  • Validation: bun run test packages/cli/test/executor.test.ts packages/cli/test/planner.test.ts packages/cli/test/cli.test.ts; bun run typecheck; bun run build
  • Link: pending

Existing issue coordination

Non-goals

  • No generic session plugin registry.
  • No merge of CLI and MCP adapters.
  • No provider-neutral cloud abstraction before a proven provider implementation.
  • No broad evidence-journal split.
  • No automatic storage migration.
  • No new runtime command for Standardize isolated Flutter component previews #43.

No-feature-flag decision

No feature flag. Each PR is an internal refactor or backward-compatible storage rollout with preserved current defaults and independently reviewable behavior.

Audit commit snapshot

de467fbd14d00d4afa4946f610d05d724a6fa777 on main.

Current status

Planned.

Next action

Open PR 1 with characterization tests and migrate only local lifecycle composition; do not combine teardown, storage, or privilege execution changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions