refactor/cmd: split runUp and the harness policy command, share one JSONC stripper #94

Merged
pti merged 1 commit from refactor/complexity-cmd into main 2026-10-19 22:33:35 +02:00
Owner

Part of #71, the cmd slice. runUp was at Sonar cognitive complexity 32 and newHarnessPolicySetCmd at 34. runUp now delegates to upWorkspaceRoot, loadUpConfig, validateUpContainerOptions, ensureUpServer and upReadyHook with the step order unchanged, record check before runtime selection, validation, sbx preflight, token provisioning, server ensure, bring-up with the ready hook writing the worktree record right before the attach. The policy set command builds a policySetRequest with validate and apply methods, flags and help text unchanged. The two byte-identical JSONC strippers in cmd and doctor, both at 27, are replaced by one internal/jsonc package whose Strip is split into small helpers, with the old tests moved there plus new edge-case assertions. Reviewer pass ran a differential test of the new stripper against the old one over the repo's real devcontainer files, hand-written edge cases and two million random inputs, all byte-identical, and confirmed the ensureServer seam and XDG isolation of the runUp tests. 🤖 Generated with Claude Code

Part of #71, the cmd slice. runUp was at Sonar cognitive complexity 32 and newHarnessPolicySetCmd at 34. runUp now delegates to upWorkspaceRoot, loadUpConfig, validateUpContainerOptions, ensureUpServer and upReadyHook with the step order unchanged, record check before runtime selection, validation, sbx preflight, token provisioning, server ensure, bring-up with the ready hook writing the worktree record right before the attach. The policy set command builds a policySetRequest with validate and apply methods, flags and help text unchanged. The two byte-identical JSONC strippers in cmd and doctor, both at 27, are replaced by one internal/jsonc package whose Strip is split into small helpers, with the old tests moved there plus new edge-case assertions. Reviewer pass ran a differential test of the new stripper against the old one over the repo's real devcontainer files, hand-written edge cases and two million random inputs, all byte-identical, and confirmed the ensureServer seam and XDG isolation of the runUp tests. 🤖 Generated with Claude Code
refactor(cmd): split runUp and the harness policy command, share one JSONC stripper
All checks were successful
Lint / lint (pull_request) Successful in 54s
Lint / sonarqube (pull_request) Has been skipped
7566754443
Sonar go:S3776 flagged runUp, newHarnessPolicySetCmd and two
byte-identical JSONC strippers (cmd/up.go and internal/doctor/pool.go)
above the cognitive-complexity bar of 25.

runUp keeps its exact step order (record check, runtime selection,
server ensure, bring-up, ready hook before the attach) but delegates
workspace-root resolution, config loading, container-option validation,
server ensure and the ready hook to named helpers. The policy set
command moves validation and manifest mutation onto a small request
struct. Flag names, defaults, help text and messages are unchanged.

The two JSONC strippers collapse into internal/jsonc.Strip, split into
string, line-comment and block-comment helpers; their tests move there
with every case kept, plus coverage of unterminated inputs.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
pti merged commit 33b81bc08d into main 2026-10-19 22:33:35 +02:00
pti deleted branch refactor/complexity-cmd 2026-10-19 22:33:35 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
pti/wraptool!94
No description provided.