Skip to content

[alpha.14] refactor(tools): autoflow/release.ts is 1887 lines — split release lifecycle phases #907

Description

@SisyphusZheng

Context

Found during deep code audit of tools/autoflow/release.ts.

Problem

tools/autoflow/release.ts is 1887 lines — the single largest file in the entire repository. It handles the full AutoFlow3 release lifecycle in one module:

  1. Release policy resolution
  2. Pre-publish checks (git clean, tag exists, ancestor verification)
  3. npm view verification
  4. Build step orchestration
  5. Publish step orchestration (npm publish for each package)
  6. Evidence collection (per-step)
  7. Tag step orchestration (immutable tag, evidence commit)
  8. Documentation version anchors update (VERSION_PLAN, STATUS, ROADMAP across 10+ files)
  9. Release closure record writing
  10. Resumption logic for partial-failure recovery

All 10 phases share one module-level state object and call each other directly.

Impact

  • Bus factor critical: this file is the heart of the release pipeline; one 1887-line file is unmaintainable by anyone other than the original author
  • Test friction: release.test.ts is 1013 lines and growing; testing one phase requires constructing the entire release context
  • Resumption risk: if a release fails mid-pipeline, debugging which of the 10 phases failed requires reading the whole file
  • Evolution blocked: adding a new release step (e.g., provenance attestation) requires touching the monolith

Proposal

  1. Split along the 10 phases into separate modules:
    • release-policy.ts — phase 1
    • release-pre-checks.ts — phase 2-3
    • release-build.ts — phase 4
    • release-publish.ts — phase 5
    • release-evidence.ts — phase 6
    • release-tag.ts — phase 7
    • release-docs-sync.ts — phase 8
    • release-closure.ts — phase 9-10
  2. release.ts becomes a thin orchestrator: imports the phase modules and composes them
  3. Each phase has its own test file with phase-local fixtures
  4. Shared types (ReleaseStepEvidence, ReleaseClosureRecord) move to release-types.ts

Priority

P3 — maintainability. Not a 0.42 blocker but blocks contributor onboarding to the release pipeline.

Audit reference

tools/autoflow/release.ts (1887 lines)
tools/autoflow/__tests__/release.test.ts (1013 lines)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    alpha.14v0.42.0-alpha.14 task train (architecture clean plan)alpha.17v0.42.0-alpha.17 task train (registration decoupling + pre-freeze architect review)maintainabilityrefactortools

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions