Skip to content

Migronaut v2: add baseline + out-of-order detection, harden redaction - #2

Merged
Alex-Dolid merged 3 commits into
mainfrom
feature/code-review-fixes
Aug 30, 2026
Merged

Alex-Dolid merged 3 commits into
mainfrom
feature/code-review-fixes

Conversation

@Alex-Dolid

Copy link
Copy Markdown

…ilience

Implements the August 2026 multi-agent code review (45 confirmed findings across maintainability, performance, security, scalability, resilience, governance and observability, plus the competitive analysis).

Features

  • migronaut baseline — adopt an existing database with no prior migration tool: mark files on disk as applied (disk checksum, one shared batch, origin: 'baseline') without executing them. Forward-only, idempotent, confirmation-gated, runs under the lock.
  • Out-of-order detection — a bulk up flags pending migrations sorting before the newest applied one. New onOutOfOrder: 'warn' | 'error' | 'allow' (env MIGRONAUT_ON_OUT_OF_ORDER), MIGRATION_OUT_OF_ORDER (exit 23), StatusRow.outOfOrder, and an ordering audit check.
  • Failed-attempt traces — a failing up leaves a best-effort status:'failed' record (error, failedAt, runId); never demotes an applied record, and a successful apply clears it.
  • Audit-trail read surface on StatusRow (executedBy, environment, runId, revertedAt, origin), onKit on runMigrations, exported createLogger, and a cwd option on MigratorKit.

Security

  • Redaction now masks query-string secrets (tlsCertificateKeyFilePassword, proxyPassword, sslKeyPassword, secret authMechanismProperties values) and empty-username passwords — in logs, errors, --json, events and init-generated configs.
  • Terminal sanitization covers the whole C1 block (DCS/OSC/PM/APC), and bin's last-resort handlers sanitize their output.

Resilience

  • Server-time appliedAt/revertedAt/failedAt stamps, so revert ordering survives host clock skew.
  • A non-transactional changelog-write failure after a committed body reports phase: 'changelog-write' instead of the generic migration failure.
  • timeoutMs aborts ctx.signal; SIGINT during pre-connect aborts the run; partial results survive hook/load and lock-release failures; release() without an owner token is a no-op.

Performance

  • Bounded import checksum fan-out (EMFILE), single-round-trip uncontended lock acquire, cached strict drift check, covered-index dry-run up, stall-based lockWaitTimeoutMs.

Docs and tests

  • New guides (baseline, seeding, mongoose, vs-migrate-mongo), refreshed ARCHITECTURE/README/SECURITY/CHANGELOG, four new sync pins, ESM-interop test. 712 tests green; coverage 97/94/98.

…ilience

Implements the August 2026 multi-agent code review (45 confirmed findings
across maintainability, performance, security, scalability, resilience,
governance and observability, plus the competitive analysis).

Features

- `migronaut baseline` — adopt an existing database with no prior migration
  tool: mark files on disk as applied (disk checksum, one shared batch,
  `origin: 'baseline'`) without executing them. Forward-only, idempotent,
  confirmation-gated, runs under the lock.
- Out-of-order detection — a bulk `up` flags pending migrations sorting before
  the newest applied one. New `onOutOfOrder: 'warn' | 'error' | 'allow'`
  (env `MIGRONAUT_ON_OUT_OF_ORDER`), `MIGRATION_OUT_OF_ORDER` (exit 23),
  `StatusRow.outOfOrder`, and an `ordering` audit check.
- Failed-attempt traces — a failing `up` leaves a best-effort `status:'failed'`
  record (error, `failedAt`, `runId`); never demotes an applied record, and a
  successful apply clears it.
- Audit-trail read surface on `StatusRow` (executedBy, environment, runId,
  revertedAt, origin), `onKit` on `runMigrations`, exported `createLogger`,
  and a `cwd` option on `MigratorKit`.

Security

- Redaction now masks query-string secrets (tlsCertificateKeyFilePassword,
  proxyPassword, sslKeyPassword, secret authMechanismProperties values) and
  empty-username passwords — in logs, errors, `--json`, events and
  `init`-generated configs.
- Terminal sanitization covers the whole C1 block (DCS/OSC/PM/APC), and bin's
  last-resort handlers sanitize their output.

Resilience

- Server-time `appliedAt`/`revertedAt`/`failedAt` stamps, so revert ordering
  survives host clock skew.
- A non-transactional changelog-write failure after a committed body reports
  `phase: 'changelog-write'` instead of the generic migration failure.
- `timeoutMs` aborts `ctx.signal`; SIGINT during pre-connect aborts the run;
  partial results survive hook/load and lock-release failures; `release()`
  without an owner token is a no-op.

Performance

- Bounded import checksum fan-out (EMFILE), single-round-trip uncontended
  lock acquire, cached strict drift check, covered-index `dry-run up`,
  stall-based `lockWaitTimeoutMs`.

Docs and tests

- New guides (baseline, seeding, mongoose, vs-migrate-mongo), refreshed
  ARCHITECTURE/README/SECURITY/CHANGELOG, four new sync pins, ESM-interop
  test. 712 tests green; coverage 97/94/98.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
migronaut Ready Ready Preview Aug 30, 2026 10:35am

`should abort the context signal when the timeout fires` awaits a promise that
can only settle from `withTimeout`'s `unref()`ed timer, with a mock context as
the only other handle. Node 24 keeps the loop alive there; Node 22 drains it,
so the test runner cancelled the test — and, by cascade, the two suites after
it (`fail 0`, `cancelled 3`, exit 1) on every Node 22 job.

tests/helpers/event-loop.js exists for exactly this, and the sibling timeout
test already used it; this one did not. Reproduced and verified on Node
v22.23.1: 467/467 unit and 713/713 full, cancelled 0.
v1.0.0 is published on npm, so the contract changes in this cycle need a major
bump rather than folding into 1.0.0: `^1.0.0` would otherwise auto-upgrade
consumers into them.

Major because of three narrow breaks, now documented under their own CHANGELOG
heading with migration notes:

- `unlock --json` requires `--yes` (previously force-released the lock)
- `StatusRow.status` / `MigrationStatus` gained 'failed'
- `MigronautErrorCode` gained 'MIGRATION_OUT_OF_ORDER' (exit 23)

Everything else this cycle is additive, and the most commonly scripted surface
is untouched: `pendingMigrations()` / `list('pending')` still report a file as
pending even when a failed attempt was recorded for it.

Version references updated in the four hand-synced places: package.json,
CHANGELOG.md, SECURITY.md's supported-versions table, ARCHITECTURE.md's
snapshot line, and the docs site version dropdown.
@Alex-Dolid Alex-Dolid changed the title feat: add baseline + out-of-order detection, harden redaction Migronaut v2: add baseline + out-of-order detection, harden redaction Aug 30, 2026
@Alex-Dolid
Alex-Dolid merged commit 54780c6 into main Aug 30, 2026
12 checks passed
@Alex-Dolid
Alex-Dolid deleted the feature/code-review-fixes branch August 30, 2026 10:38

This branch was successfully deployed

1 active deployment
Preview — f5a638d9 Deployed Aug 30, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant