Provider and Automation Boundary Refactor Implementation Log
Branch: codex/provider-automation-boundary-refactor
Plan: docs/plans/2026-05-14-provider-automation-boundary-refactor.md
2026-05-14#
Baseline#
- Created isolated global worktree at
/Users/rohan/.config/superpowers/worktrees/codealmanac/provider-automation-boundary-refactor. - Created branch
codex/provider-automation-boundary-refactorfromdev. - Copied the accepted design plan into the worktree.
- Installed dependencies with
npm install. - Noted npm engine warning: current shell uses Node
v21.7.3, whilepackage.jsonsupports20.x || 22.x || 23.x || 24.x || 25.x. - Initial
npm testfailed because gitignoreddist/was absent, causing automation tests to resolve Vitest's process entrypoint instead ofdist/codealmanac.js. - Ran
npm run build, then rerannpm test. - Baseline after build:
54test files passed,465tests passed.
Automation Boundary Extraction#
- Added
src/automation/tasks.tsfor scheduler task labels, defaults, plist paths, and default CLI program arguments. - Added
src/automation/launchd.tsfor launchd plist rendering, directory setup, PATH construction, bootstrap, removal, and plist status parsing. - Added
src/automation/legacy-hooks.tsfor private cleanup of historical Claude/Codex/Cursor hook installs. - Rewrote
src/commands/automation.tsas the command-facing orchestrator. It still validates options, records the automation activation baseline, formats command output, and preserves the existing public exports used by setup/uninstall. - Verified focused behavior with
npm test -- --run test/automation.test.ts:5tests passed. - Verified TypeScript/package build with
npm run build: succeeded.
Capture Sweep Boundary Extraction#
- Added
src/capture/discovery/with provider-specific Claude and Codex transcript discovery plus shared JSONL metadata helpers. - Kept transcript discovery outside
src/harness/providers/; harness providers remain execution adapters, while discovery scans historical transcript stores. - Added
src/capture/ledger.tsfor repo-local capture ledger loading, atomic writes, pending-run reconciliation, cursor math, line counting, and prefix hashes. - Added
src/capture/lock.tsfor repo-level sweep lock creation, stale-lock recovery, and release. - Reduced
src/commands/capture-sweep.tsto command parsing, eligibility orchestration, capture enqueueing, summary construction, and command output rendering. - Verified focused behavior with
npm test -- --run test/capture-sweep.test.ts:7tests passed. - Verified TypeScript/package build with
npm run build: succeeded.
Provider Readiness and Config Boundary Cleanup#
- Moved the global config implementation from
src/update/config.tstosrc/config/index.ts. - Left
src/update/config.tsas a compatibility re-export so existing tests and external import paths keep working while production code usessrc/config/. - Moved the provider setup/status projection from
src/agent/provider-view.tstosrc/agent/readiness/view.tsand left the old path as a compatibility re-export. - Updated production imports for
agents,setup,doctor, operation commands, automation, capture sweep, and update commands to usesrc/config/andsrc/agent/readiness/. - Removed unused legacy agent execution methods from the setup/status provider layer. Runtime execution remains in
src/harness/providers/. - Deleted the unused old JSONL execution helpers under
src/agent/providers/. - Verified affected behavior with
npm test -- --run test/provider-view.test.ts test/config-command.test.ts test/setup.test.ts test/doctor.test.ts:33tests passed. - Verified TypeScript/package build with
npm run build: succeeded.
Automation Status Load-State Check#
- Extended launchd status helpers to check
launchctl print gui/<uid>/<label>. - Updated
almanac automation statusoutput to reportlaunchd loaded: yes|noseparately from plist existence. - Added a focused automation test that injects loaded capture automation and unloaded Garden automation.
- Verified focused behavior with
npm test -- --run test/automation.test.ts:6tests passed. - Verified TypeScript/package build with
npm run build: succeeded.
Wiki Updates#
- Updated
.almanac/pages/automation.mdto document the newsrc/automation/split and the separate launchd loaded-state status check. - Updated
.almanac/pages/capture-flow.mdto documentsrc/capture/discovery/,src/capture/ledger.ts, andsrc/capture/lock.ts. - Updated
.almanac/pages/harness-providers.mdto state that runtime execution belongs insrc/harness/providers/, whilesrc/agent/readiness/view.tsand the remainingsrc/agent/providers/code are setup/status/model readiness only.
Review Fixes#
- Addressed review finding
[P2] Runtime capability metadata still lives in readiness providersby removing runtime capability fields fromAgentProviderMetadataand the remaining setup/status providers. - Addressed review finding
[P2] Sweep business logic remains in the command wrapperby moving the sweep coordinator loop intosrc/capture/sweep.ts. - Kept
src/commands/capture-sweep.tsresponsible for parsing command flags, loading config/discovery inputs, adapting torunCaptureCommand(), and rendering command output. - Verified focused behavior with
npm test -- --run test/capture-sweep.test.ts test/provider-view.test.ts test/setup.test.ts test/doctor.test.ts:30tests passed. - Verified TypeScript/package build with
npm run build: succeeded.
Re-review Fix#
- Addressed re-review finding
[P2] Keep CLI result parsing out of sweep coordinatorby changingStartSweepCaptureFnto return a domain result. - Moved
runCaptureCommand()stdout parsing back intosrc/commands/capture-sweep.ts;src/capture/sweep.tsnow receives only{ ok: true, runId }or{ ok: false, error }.