Skip to content

feat(config): define versioned compatibility contracts - #73

Merged
mohanagy merged 33 commits into
developmentfrom
feat/issue-38-compatibility
Jul 14, 2026
Merged

feat(config): define versioned compatibility contracts#73
mohanagy merged 33 commits into
developmentfrom
feat/issue-38-compatibility

Conversation

@mohanagy

@mohanagy mohanagy commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • add strict v1/v2 configuration contracts, released-version fixtures, migration plan/CLI, and versioned public documentation, schema, and types
  • make configuration migration explicit, byte-exact backed up, race-safe, and Windows ACL-aware
  • include real Windows DACL handling and coverage contracts in the core suite
  • anchor the Windows ACL helper PowerShell launcher to the protected default Windows root and fail closed on non-default layouts rather than launching a caller-selected executable

Compatibility

  • v1 remains supported and migratable; v2 rejects legacy aliases with remediation
  • MiftahConfig is intentionally version-discriminated. This is an explicit pre-1.0 breaking type-surface change documented in the changelog and library API documentation; consumers composing application config should use an intersection type. Please review and approve this migration before merge.

Validation

  • npm test — 991 passed, 14 skipped
  • npm run test:core — 387 passed, 14 skipped
  • npm run test:coverage — 95.46% statements overall; config 95.76%
  • npm run lint
  • npm run typecheck
  • npm run build
  • npm run smoke:cli
  • npm run check:pack
  • npm run test:package — 16 passed

Closes #38

Summary by CodeRabbit

  • New Features
    • Added configuration format v2 with stricter canonical validation.
    • Added miftah migrate-config with dry-run reporting, plus safe --write behavior using exact backups.
    • Added management operations in the documented management tool surface: miftah_list_approvals, miftah_approve, miftah_deny.
  • Changed
    • Unrecognized tools now default to destructive risk.
    • Version 2 rejects removed legacy aliases (including the legacy http transport) and v2 runtime exports are now explicitly documented.
    • Audit journal entries now include an immutable schema version marker.
  • Documentation
    • Updated CLI/config/compatibility and plugin ABI compatibility guidance; refreshed example configs.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 29 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ae56e1ff-a901-4c2a-bd04-1ed4495e3701

📥 Commits

Reviewing files that changed from the base of the PR and between 44d97de and 39efb5e.

📒 Files selected for processing (6)
  • src/cli/migrate-config.ts
  • src/cli/windows-config-acl.ts
  • src/config/schema.ts
  • tests/config-diagnostics.test.ts
  • tests/windows-config-acl.test.ts
  • tests/windows-config-migration-acl.test.ts
📝 Walkthrough

Walkthrough

Configuration format v2 is introduced with strict versioned types and validation, a dry-run-first migrate-config CLI workflow, transactional backups, Windows ACL checks, audit schema markers, public version exports, and compatibility coverage for historical fixtures.

Changes

Configuration v2 contracts

Layer / File(s) Summary
Versioned configuration contracts
src/config/*, src/index.ts, examples/*, docs/*, README.md, CHANGELOG.md
Version 2 becomes canonical, legacy aliases remain supported only for v1, and public documentation and examples reflect the updated contract.
Migration planning and publication
src/config/migrate-config.ts, src/cli/migrate-config.ts, src/cli/windows-config-acl.ts
v1 configurations are transformed and validated as v2; writes use snapshots, exclusive backups, non-overwriting publication, recovery, and Windows ACL verification.
CLI and compatibility integrations
src/cli/parse.ts, src/cli/main.ts, src/cli/exit-codes.ts, src/audit/*, src/plugins/plugin-registry.ts, src/runtime/resolve-runtime-config.ts
The new command and errors are wired into the CLI, audit records carry immutable schema versions, plugin checks use the shared API version, and runtime resolution covers v2 configurations.
Validation and release coverage
tests/*, package.json
Tests cover migration planning and races, CLI behavior, schemas, public exports, audit records, plugins, fixtures, runtime resolution, management names, and Windows ACL boundaries.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Operator
  participant CLI
  participant MigrationPlanner
  participant MigrationPublisher
  participant ConfigFile
  Operator->>CLI: run migrate-config
  CLI->>MigrationPlanner: validate and plan v1 to v2 migration
  MigrationPlanner-->>CLI: migration report
  Operator->>CLI: rerun with --write
  CLI->>MigrationPublisher: apply validated migration
  MigrationPublisher->>ConfigFile: create exclusive backup and publish candidate
  ConfigFile-->>CLI: updated configuration and backup status
Loading

Possibly related PRs

Poem

A bunny checks the config twice,
Plans the change, then guards the bytes.
A backup waits, untouched and bright,
While v1 hops safely into v2 tonight.
miftah thumps its happy feet—
Versioned paths are neat and sweet!


Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Docstring Coverage ❌ Error Docstring coverage is 24.68% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title succinctly captures the main change: versioned config compatibility contracts.
Description check ✅ Passed The description includes summary, compatibility, and validation details, with only the Security impact section missing.
Linked Issues check ✅ Passed The PR implements the #38 requirements: migrations, backup/dry-run behavior, docs, fixtures, and compatibility rules.
Out of Scope Changes check ✅ Passed The changed code, docs, examples, and tests all align with the config-versioning and migration contract work.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/issue-38-compatibility

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/cli/migrate-config.ts`:
- Around line 327-434: Extract the repeated restore-and-escalate logic from
installWithoutOverwriting into a small helper that performs the appropriate
restore operation, removes the candidate and transaction when restoration
succeeds, and throws the supplied safe Migration*Error; otherwise throw
MigrationTransactionError. Replace each applicable restoreHeldSource and
restoreCurrentHeldSource branch while preserving their distinct restoration
arguments and error outcomes.

In `@src/config/schema.ts`:
- Around line 8-19: Update the error message in configVersionSchema to derive
the supported version list from SUPPORTED_CONFIG_VERSIONS instead of hardcoding
'1' and '2'. Preserve the existing unsupported-version code, remediation, and
validation behavior while formatting the array values consistently in the
message.
- Around line 1216-1229: Update the alias checks for security.redactSecrets and
audit.redact in the shown schema validation flow to run only when their values
are defined and not false. Preserve the existing alias rejection for non-false
values, allowing the later === false validation to produce the sole diagnostic
for explicit false settings.

In `@tests/windows-config-migration-acl.test.ts`:
- Around line 250-275: Update windowsAclSddl to apply the same 5-second timeout
and child.kill cleanup pattern used by windowsPrivateDirectoryProbe and
windowsCopyFileSecurityProbe. Ensure the timeout rejects the promise with the
established probe failure error, and clear the timer when the child exits or
emits an error.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 0f9fce09-0433-4707-91fe-15a346fcbaac

📥 Commits

Reviewing files that changed from the base of the PR and between f800295 and f5a1de3.

📒 Files selected for processing (50)
  • CHANGELOG.md
  • README.md
  • docs/architecture.md
  • docs/cli.md
  • docs/config.md
  • docs/library-api.md
  • docs/plugins.md
  • examples/generic.miftah.json
  • examples/github.miftah.json
  • examples/multi-upstream.miftah.json
  • examples/plugins.miftah.json
  • examples/sentry.miftah.json
  • package.json
  • src/audit/audit-logger.ts
  • src/audit/audit-types.ts
  • src/cli/exit-codes.ts
  • src/cli/main.ts
  • src/cli/migrate-config.ts
  • src/cli/parse.ts
  • src/cli/windows-config-acl.ts
  • src/config/generate-json-schema.ts
  • src/config/load-config.ts
  • src/config/migrate-config.ts
  • src/config/presets.ts
  • src/config/schema.ts
  • src/config/types.ts
  • src/config/versions.ts
  • src/index.ts
  • src/plugins/plugin-registry.ts
  • src/runtime/resolve-runtime-config.ts
  • src/utils/errors.ts
  • tests/audit-integrity.test.ts
  • tests/audit.test.ts
  • tests/cli-exit-codes.test.ts
  • tests/cli-parse.test.ts
  • tests/config-diagnostics.test.ts
  • tests/config-loader.test.ts
  • tests/config-migration.test.ts
  • tests/config-schema-contract.test.ts
  • tests/fixtures/config-compat/v1/generic-0.1.0.miftah.json
  • tests/fixtures/config-compat/v2/canonical.miftah.json
  • tests/mcp-wrapper.test.ts
  • tests/package-contract.test.ts
  • tests/plugin-api.test.ts
  • tests/public-api.test.ts
  • tests/release-config.test.ts
  • tests/runtime-config-resolution.test.ts
  • tests/windows-config-acl.test.ts
  • tests/windows-config-migration-acl-failure.test.ts
  • tests/windows-config-migration-acl.test.ts

Comment thread src/cli/migrate-config.ts
Comment thread src/config/schema.ts
Comment thread src/config/schema.ts Outdated
Comment thread tests/windows-config-migration-acl.test.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/cli/windows-config-acl.ts`:
- Around line 27-28: Update the ACL persistence verification in the relevant
flow around the selected-section reread to compare the target DiscretionaryAcl
or equivalent SDDL against the source ACL before returning. Retain the existing
reread and failure handling, but reject persistence when the target DACL does
not match the source rather than only checking that an access-control object was
returned.

In `@tests/windows-config-acl.test.ts`:
- Around line 57-73: Update the test for copyWindowsConfigSecurityDescriptor to
reflect strengthened target verification: replace the assertion that the
generated command omits $verifiedAcl.GetSecurityDescriptorBinaryForm with
assertions confirming it validates $verifiedAcl.DiscretionaryAcl, while
preserving the existing source ACL and binary descriptor assertions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 10d814fd-2400-429c-a549-020ab9b9013d

📥 Commits

Reviewing files that changed from the base of the PR and between f5a1de3 and 44d97de.

📒 Files selected for processing (3)
  • src/cli/windows-config-acl.ts
  • tests/windows-config-acl.test.ts
  • tests/windows-config-migration-acl.test.ts

Comment thread src/cli/windows-config-acl.ts Outdated
Comment thread tests/windows-config-acl.test.ts Outdated
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.

[Compatibility] Define stable config migrations and public API guarantees

1 participant