You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
decisions.ts (726 lines) is a structural duplicate of learn.ts (896 lines). Nearly every subcommand follows the same pattern with minor parametric differences. This tech debt blocks maintainability and introduces risk of divergence bugs between the two command implementations.
Deferred Items
1. Code Duplication
decisions.ts and learn.ts share identical overall structure and logic flow
Nearly every subcommand (e.g., --run-background, --enable, --disable) replicates the same control flow pattern with minor parameter differences
Impact: Changes to one often need applying to both; bugs fixed in one may remain in the other
2. Pipeline Duplication
Both --run-background handlers implement an identical 10-step pipeline sequence
Should be extracted into a shared runBackgroundPipeline(opts) utility
Currently duplicated across both files, reducing maintainability
Impact: Pipeline improvements require updating two separate code paths
3. Monolithic Action Handler
decisions.ts contains a 580-line action handler with all 12 subcommands inlined
Each subcommand branch should be extracted into a named function (e.g., handleEnable(), handleDisable(), handleRun())
Impact: High cognitive load for reviewers, difficult to test individual subcommands in isolation
4. Testing Methodology
Several tests in cli-subcommands.test.ts re-implement inline logic instead of calling actual command handlers
extractBatchMessages and loadExistingObservations lack direct unit tests
Tests duplicate implementation logic, making them fragile to refactoring
Impact: Test coverage is misleading; refactoring breaks tests that should still pass
Currently mitigated by sync NOTEs and parity test suite (convergence-detection.test.ts)
Impact: Changes to convergence algorithm require 3-surface updates; risk of desynchronization if prose drifts from test oracle
Solution Path: Extract convergence logic to shared reference document with build-time distribution to all 3 surfaces (similar to skill/agent distribution model)
Create a shared CommandRunner class/module for dual-command dispatch
Extract --run-background logic to runBackgroundPipeline()
Extract each subcommand into a named function with clear input/output contracts
Refactor tests to call actual handlers instead of duplicating logic
Apply to both learn.ts and decisions.ts simultaneously for consistency
Create a convergence logic reference document (.md) in shared/references/ with schema and decision tables; build-time script replicates to command prose and SKILL.md with parity tests
Summary
decisions.ts (726 lines) is a structural duplicate of learn.ts (896 lines). Nearly every subcommand follows the same pattern with minor parametric differences. This tech debt blocks maintainability and introduces risk of divergence bugs between the two command implementations.
Deferred Items
1. Code Duplication
2. Pipeline Duplication
runBackgroundPipeline(opts)utility3. Monolithic Action Handler
handleEnable(),handleDisable(),handleRun())4. Testing Methodology
extractBatchMessagesandloadExistingObservationslack direct unit tests5. Convergence Logic Triplication
code-review.md,code-review-teams.md,review:orch/SKILL.mdRecommended Approach
CommandRunnerclass/module for dual-command dispatchrunBackgroundPipeline()shared/references/with schema and decision tables; build-time script replicates to command prose and SKILL.md with parity testsRelated