Skip to content

Latest commit

 

History

History
118 lines (90 loc) · 5.12 KB

migrate.md

File metadata and controls

118 lines (90 loc) · 5.12 KB

migrate.sh

Revision: 1 Last modified: 2026-12-04T19:00:00Z

Overview

migrate.sh migrates a consumer project onto the current constitution, and records the outcome as one machine-readable record.

Its most important property is that a dry run is not a migration outcome. Without --apply the script runs the preflight only, never writes to the consumer's checkout ($WORKDIR), still writes the --out record with outcome DRY-RUN, and exits 1. That exit is deliberate: audit.py summary never counts a dry run, so a caller cannot mistake "I looked at it" for "it is migrated".

--out holds exactly one record per project. Several records for the same project are a defect the caller is warned about upstream (T177 Round 5), which is why the tool writes one and not one-per-run.

Prerequisites

  • sh, python3.
  • A fastcycle config (--config).
  • --workdir pointing at a real consumer checkout.
  • An explicit scope decision (--scope-decision) when the change is out of the default scope.
  • No environment variables are read.

Usage examples

# preflight only — writes the DRY-RUN record, never touches $WORKDIR, exits 1
sh scripts/fastcycle/consumers/migrate.sh \
  --config fastcycle.yaml \
  --project org/repo \
  --workdir /abs/path/to/consumer \
  --out migration.json

# apply the migration
sh scripts/fastcycle/consumers/migrate.sh \
  --config fastcycle.yaml --project org/repo \
  --workdir /abs/path/to/consumer --out migration.json --apply

# attach the review reference the migration should cite
sh scripts/fastcycle/consumers/migrate.sh \
  --config fastcycle.yaml --project org/repo --workdir /abs/path/to/consumer \
  --out migration.json --apply --review-ref review/round-3.json

# out-of-scope change: record the operator decision explicitly
sh scripts/fastcycle/consumers/migrate.sh \
  --config fastcycle.yaml --project org/repo --workdir /abs/path/to/consumer \
  --out migration.json --scope-decision scope_decision.json

Flags

Flag Meaning
--config The fastcycle config.
--project org/repo of the consumer.
--workdir The consumer checkout directory.
--out The migration record destination (one record per project).
--apply Actually migrate. Absent ⇒ preflight only.
--review-ref Path to the review reference the record should cite.
--operator-blocked Record the consumer as operator-blocked rather than migrated.
--scope-decision The recorded scope decision, required for an out-of-scope change.

Exit codes

Code Meaning
0 MIGRATED.
1 NOT-MIGRATED — the reason is in the JSON body, and this is not a crash. Also the exit for a DRY-RUN preflight.
2 Usage/config error (bad or missing flags, unreadable config).
4 BLIND — the consumer's state could not be established honestly.

Exit 1 carries the diagnosis. A caller should read the record's reason field rather than treating 1 as a tool failure; the distinction that matters is 0 (migrated) versus everything else.

Edge cases

  • No --apply. Preflight only: $WORKDIR is untouched, --out records DRY-RUN, exit 1. This is the intended way to inspect a migration safely.
  • --operator-blocked. Records the block instead of attempting the migration — the honest outcome when the operator must act first (§11.4.21).
  • An out-of-scope change without --scope-decision. Refused; the decision must be recorded, not assumed.
  • A consumer already migrated. The single-record-per-project rule means the record is updated rather than duplicated.
  • A --workdir that is not a checkout. Cannot establish state honestly → BLIND (4).
  • Two records for one project. Not produced by this tool; if present in --out, audit.py summary has a defined resolution order and the duplication is a finding.

Internal behaviour

  1. Parses flags; exit 2 on usage problems.
  2. Validates the config, the project identity and the workdir.
  3. Resolves scope: the default scope, or the change named by --scope-decision.
  4. Without --apply: performs the preflight (what would change, any blocker), writes the DRY-RUN record to --out, and exits 1 without touching $WORKDIR.
  5. With --apply: performs the migration in $WORKDIR, then writes the single MIGRATED or NOT-MIGRATED record with its reason.
  6. Exits 0 on MIGRATED, 1 on NOT-MIGRATED/DRY-RUN, 4 when the state is unknowable.

Related scripts

Contract: specs/004-fast-dev-cycles/contracts/consumer-audit-and-migration.md CA-019..CA-028.

Guarded by scripts/fastcycle/tests/test_consumer_migrate_red.sh (T168).

Related in the same family: scripts/fastcycle/consumers/enumerate.sh (CA-001..CA-005) discovers the consumers this tool migrates; scripts/fastcycle/consumers/audit.py summarises the records.

See also docs/scripts/enumerate.sh.md and docs/scripts/audit.py.md.

Last verified

2026-12-04 — bash -n scripts/fastcycle/consumers/migrate.sh → exit 0. sh scripts/fastcycle/consumers/migrate.sh with no arguments exits 2 with a usage message (required flags absent).