Skip to content
This repository was archived by the owner on Oct 5, 2026. It is now read-only.

feat: add .svp manifest.json with schema versioning and auto-migration - #12

Merged
xycld merged 1 commit into
mainfrom
feat/manifest-schema-versioning
Mar 19, 2026
Merged

xycld merged 1 commit into
mainfrom
feat/manifest-schema-versioning

Conversation

@xycld

@xycld xycld commented Mar 19, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds .svp/manifest.json (created during forge init) to track schemaVersion and forgeVersion, enabling forward-compatible schema evolution
  • Implements a migration runner (migrate.ts) with a sequential chain pattern for future schema upgrades (v1→v2→v3…)
  • Guards all CLI commands that read .svp/ with checkCompatibility() — auto-creates manifest for legacy projects, errors on downgrade

Test plan

  • forge init creates .svp/manifest.json with correct schemaVersion: 1.0.0 and current forgeVersion
  • Existing .svp/ without manifest gets auto-upgraded (legacy project support)
  • Downgrade detection throws actionable error
  • Semver major comparison logic tested
  • Migration runner no-op and missing-migration error tested
  • All 685 existing tests still pass

Introduces a manifest.json file in .svp/ to track schema and forge
versions, enabling forward-compatible schema evolution with automatic
migration when users upgrade forge.

- Add manifest.ts with SCHEMA_VERSION, read/write, compatibility check
- Add migrate.ts with sequential migration runner and registry
- Write manifest.json during forge init
- Guard all CLI commands that read .svp/ with checkCompatibility()
- Auto-create manifest for legacy projects missing manifest.json
- Error on downgrade (manifest schema > current forge schema)
- Add 13 tests for manifest and migration logic
Copilot AI review requested due to automatic review settings March 19, 2026 04:55

Copilot AI 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.

Pull request overview

Adds a new .svp/manifest.json mechanism to track schema/forge versions, introduces a migration runner for future schema upgrades, and wires compatibility checks into CLI paths that read .svp/ data.

Changes:

  • Introduce .svp/manifest.json support with schema version checks and upgrade hooks.
  • Add a sequential migration runner + registry scaffold for schema major upgrades.
  • Add checkCompatibility() calls in CLI loaders/commands prior to reading .svp/ data.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
packages/core/migrations/index.ts Adds migration registry scaffold (currently empty).
packages/core/migrate.ts Implements sequential migration runner (runMigrations).
packages/core/migrate.test.ts Adds basic tests for no-op and missing-migration behavior.
packages/core/manifest.ts Implements manifest read/write, schema compatibility checks, and auto-create/migrate logic.
packages/core/manifest.test.ts Adds unit tests for manifest creation, compatibility, and downgrade detection.
packages/core/init.ts Writes .svp/manifest.json during initialization.
packages/core/index.ts Exports new manifest + migration APIs from core package entrypoint.
packages/cli/load.ts Runs compatibility checks before loading .svp/ layers.
packages/cli/commands/view.ts Adds compatibility check inside loadAll() helper used by some subcommands.
packages/cli/commands/rehash.ts Guards rehash command with checkCompatibility().
packages/cli/commands/link.ts Guards link command with checkCompatibility().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread packages/core/manifest.ts
Comment on lines +30 to +31
const m = /^(\d+)/.exec(version);
return m ? Number(m[1]) : 0;
Comment thread packages/core/migrate.ts
root: string,
fromMajor: number,
toMajor: number,
): Promise<void> {
@@ -0,0 +1,120 @@
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
Comment on lines 24 to 33
/** 从 .svp/ 加载所有层数据 */
async function loadAll(root: string): Promise<{
l5: L5Blueprint | undefined;
l4Flows: L4Artifact[];
l3Blocks: L3Block[];
l2Blocks: L2CodeBlock[];
}> {
await checkCompatibility(root);
const l5 = (await readL5(root)) ?? undefined;

Comment thread packages/core/manifest.ts
Comment on lines +36 to +40
try {
const content = await readFile(manifestPath(root), "utf8");
return JSON.parse(content) as Manifest;
} catch {
return null;
Comment thread packages/core/manifest.ts
Comment on lines +44 to +47
/** Write manifest.json */
export async function writeManifest(root: string, manifest: Manifest): Promise<void> {
await writeFile(manifestPath(root), JSON.stringify(manifest, null, 2) + "\n", "utf8");
}
@xycld
xycld merged commit bd6807b into main Mar 19, 2026
5 of 7 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants