Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/add-compare-gate-mode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ghost-drift": minor
---

Add `--gate` mode to `ghost-drift compare` that reads `.ghost-sync.json` and reports per-dimension verdicts (aligned / covered / reconverging / uncovered). Exits 0 when no uncovered drift, 1 when uncovered, 2 on hard error. Versioned JSON output via `--format json` (schema: `ghost.compare.gate/v1`). Composes over existing `compareFingerprints`, `readSyncManifest`, and `checkBounds` — no new orchestration.
26 changes: 25 additions & 1 deletion apps/docs/src/generated/cli-manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"generatedAt": "2026-05-19T14:36:11.941Z",
"generatedAt": "2026-05-19T16:33:13.019Z",
"tools": [
{
"tool": "ghost",
Expand Down Expand Up @@ -265,6 +265,30 @@
"takesValue": true,
"negated": false
},
{
"rawName": "--gate",
"name": "gate",
"description": "Reconcile against a sync manifest and emit a structured pass/fail verdict (N=2 only)",
"default": null,
"takesValue": false,
"negated": false
},
{
"rawName": "--sync <path>",
"name": "sync",
"description": "Sync manifest path for --gate (default: ./.ghost-sync.json)",
"default": null,
"takesValue": true,
"negated": false
},
{
"rawName": "--max-divergence-days <n>",
"name": "maxDivergenceDays",
"description": "For --gate: flag diverging dimensions older than this many days as uncovered",
"default": null,
"takesValue": true,
"negated": false
},
{
"rawName": "--format <fmt>",
"name": "format",
Expand Down
26 changes: 26 additions & 0 deletions packages/ghost/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
formatTemporalComparisonJSON,
readHistory,
readSyncManifest,
runGateCli,
runGhostDriftCheck,
} from "./core/index.js";
import {
Expand Down Expand Up @@ -56,9 +57,34 @@ export function buildCli(): ReturnType<typeof cac> {
"--history-dir <dir>",
"Directory containing .ghost/history.jsonl (for --temporal, defaults to cwd)",
)
.option(
"--gate",
"Reconcile against a sync manifest and emit a structured pass/fail verdict (N=2 only)",
)
.option(
"--sync <path>",
"Sync manifest path for --gate (default: ./.ghost-sync.json)",
)
.option(
"--max-divergence-days <n>",
"For --gate: flag diverging dimensions older than this many days as uncovered",
)
.option("--format <fmt>", "Output format: cli or json", { default: "cli" })
.action(async (fingerprints: string[], opts) => {
try {
if (opts.gate) {
await runGateCli({
fingerprints,
cwd: process.cwd(),
sync: opts.sync,
format: opts.format,
maxDivergenceDays: opts.maxDivergenceDays,
loadFingerprint: loadComparableFingerprint,
compare,
});
return;
}

const exprs = await Promise.all(
fingerprints.map((path) => loadComparableFingerprint(path)),
);
Expand Down
Loading
Loading