feat: TDD refactoring workflows for runner.ts + main.rs decomposition#675
feat: TDD refactoring workflows for runner.ts + main.rs decomposition#675khaliqgant wants to merge 15 commits intomainfrom
Conversation
…ules Extracted 5 modules from runner.ts (6,878 lines): - verification.ts (143 lines) - template-resolver.ts (87 lines) - channel-messenger.ts (151 lines) - step-executor.ts (571 lines) - process-spawner.ts (96 lines) Added characterization tests for all extracted modules. Extracted broker.rs and worker.rs from main.rs. Bug fixes: - Restore stripInjectedTaskEcho in verification.ts - Guard agent.release() against broker 400 race condition - Fix run-summary-table test for new table format - Export normalizeModel for correct pricing resolution - Fix --wave argument parsing in run-refactor.ts - ESM imports in all workflow files
dc80aa5 to
e6c86c6
Compare
tracker.ts: resolveModel now uses normalizeModel for alias resolution (pre-existing fix verified) run-refactor.ts: --wave parsing with proper validation (pre-existing fix verified) step-executor.ts: signal-killed processes now correctly treated as failures channel-messenger.ts: replaced ReDoS-vulnerable regex with iterative indexOf stripping runner.ts: eliminated shell injection by using direct git spawn with argument arrays process-spawner.ts: fixed SIGKILL fallback timer leak by storing and clearing reference Co-Authored-By: My Senior Dev <dev@myseniordev.com>
…ules Extracted 5 modules from runner.ts (6,878 lines): - verification.ts (143 lines) - template-resolver.ts (87 lines) - channel-messenger.ts (151 lines) - step-executor.ts (571 lines) - process-spawner.ts (96 lines) Added characterization tests for all extracted modules. Extracted broker.rs and worker.rs from main.rs. Bug fixes: - Restore stripInjectedTaskEcho in verification.ts - Guard agent.release() against broker 400 race condition - Fix run-summary-table test for new table format - Export normalizeModel for correct pricing resolution - Fix --wave argument parsing in run-refactor.ts - ESM imports in all workflow files
template-resolver.ts: shell-escape interpolated variables (CRITICAL #1) broker_tests.rs: uncomment and wire up 5 real tests (CRITICAL #2) worker_tests.rs: uncomment and wire up 5 real tests (CRITICAL #3) worker.rs: log bypass-flag injection, add .. path traversal rejection (CRITICAL #4, #7) verification.ts: export stripInjectedTaskEcho, add path traversal guard (CRITICAL #5) runner.ts: remove duplicate stripInjectedTaskEcho, add ENV_ALLOWLIST filtering (HIGH #17) channel-messenger.ts: add secret scrubbing, hoist regex constants (MEDIUM #27, #28) process-spawner.ts: add settled guard for race condition (MEDIUM #23) step-executor.ts: add sideEffects to callback type, deprecate alias (HIGH #15, #16) index.ts: export StepExecutor directly (MEDIUM #29) workflows/refactor/*.ts: replace hardcoded paths, remove --no-verify (HIGH #8-11) broker.rs: move is_pid_alive to canonical location (HIGH #14) cost/tracker.ts: add restrictive file permissions (MEDIUM #30) cost/pricing.ts: add last-verified date (MEDIUM #31) verification.test.ts: 9 new tests for exported helpers (MEDIUM #32) Co-Authored-By: My Senior Dev <dev@myseniordev.com>
…elay into feat/refactor-workflows
Moved fix-mcp-spawn.yaml, add-swift-sdk.ts, and cli-observability.ts into workflows/ci/ to clearly distinguish them as CI test suite workflows. Updated .gitignore to allow workflows/ci/ and workflows/refactor/. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix tracker test: expect mode: 0o700 in mkdirSync assertion - Use Object.hasOwn() instead of `in` operator to avoid prototype chain false positives - Use Promise.allSettled to preserve partial output on process timeout - Apply path containment check for absolute paths in checkFileExists Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…and cwd trailing slash - Rename StepExecutor interface in runner.ts to RunnerStepExecutor to avoid shadowing the StepExecutor class export in the barrel index - Normalize cwd with path.resolve() in checkFileExists to handle trailing slashes Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
PR #675 Review — Strong Work, One Blocking IssueWhat's Impressive
Blocking: CodeQL ReDoS in
|
| Check | Status |
|---|---|
| CI (excluding CodeQL) | All passing |
| Tests | 672/672 |
| TypeScript | Clean |
| Rust clippy/build | Passing |
| CodeQL | 1 high (ReDoS) |
One fix needed before merge — the ReDoS in scrubSecrets. Once that's addressed, this is a solid approve. Massive refactor executed well.
Summary
TDD refactoring workflows for the two largest files in the codebase, executed end-to-end with full verification.
Targets
runner.ts(6,878 lines) — decomposed into 5 focused modulesmain.rs(7,023 lines) — decomposition planned, broker/worker extraction attemptedE2E Results (full run with refactored code)
extract-broker-worker failure details
This workflow extracts
BrokerStateandWorkerRegistryfrommain.rs(Rust). It failed on both attempts:Attempt 1 (6 passed, 1 failed, 2 skipped):
broker.rsandworker.rscargo-gate(deterministiccargo testverification) failed with exit code 1 — the extracted Rust modules broke compilationcargo-reviewand downstream steps skippedAttempt 2 (1 passed, 2 failed, 6 skipped):
read-brokerandread-workerfailed — the deterministic steps tried to read the extracted files but they were in a broken state from attempt 1Root cause: Codex's Rust extraction produced code that didn't compile. This is an agent quality issue (the Codex worker made incorrect edits to the Rust source), not a workflow runner or infrastructure issue. The runner correctly detected the failure via the
cargo-gateverification step and reported it.Not a regression — no runner code paths were affected. The workflow SDK correctly:
Extracted Modules
verification.tstemplate-resolver.tschannel-messenger.tsstep-executor.tsprocess-spawner.tsTest Results
Bug Fixes (found during E2E)
stripInjectedTaskEchomissing in extractedverification.ts— Codex extraction lost the task-echo-stripping logic that prevents false positive verification. Restored.agent.release()broker 400 race condition — broker returns HTTP 400 when releasing an already-exited agent. Was causing steps to fail even when the agent completed successfully. Added.catch()guards.require()in an ESM project. Fixed toimport.run-refactor.tsdidn't exit non-zero on single-wave failures. Fixed.Tooling
run-continuous.sh— runs all waves sequentially, retries up to 3x per wave, auto-commits