Repository navigation
feat: Contract Guardian on the CLI and MCP (preview) - #691
Merged
Merged
Conversation
- fixmap contracts lists OpenAPI, AsyncAPI, GraphQL, Protobuf, JSON Schema and SQL migration surfaces in the working tree with kind, declared version and exact fingerprint. - fixmap contracts diff <from>..<to> compares two exact Git refs through Git objects (no checkout, no worktree change) and prints breaking / unknown / compatible changes with before/after fingerprints. - Read-only MCP tool fixmap_contracts (action list|diff, readOnlyHint). - YAML OpenAPI/AsyncAPI now go through a bounded YAML-subset reader and the same decoder as JSON, so both spellings yield identical deltas. Anchors, aliases, tags, merge keys, duplicate keys and multi-document files are reported as contract-parse-failed instead of guessed. - A contract readable on one side and unparseable on the other is now an explicit "contract-unavailable" change with unknown compatibility. - GraphQL/Protobuf/SQL files the scanner does not sample are read in full for contracts, and contractSourcesFromRepo reports them as incomplete rather than parsing an empty sample. - Feature catalog entry (preview), artifact detection for contracts output, rebuilt action bundle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…rites The repository root was realpath'd but the --output path was not, so on macOS (/var vs /private/var), through a symlinked directory, or a Windows junction, an output inside the repository looked outside it and an existing repository file was overwritten. Resolve the output's nearest existing directory through realpath (the leaf stays unresolved so a symlinked output file is still refused) and add a regression using a directory alias. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Work package
codex-briefs/01-contract-guardian-surfaces.md, without step 4 (GitHub Action parity comes later in a separate change;packages/action/srcis untouched, and onlydist/index.mjsis rebuilt because Core changed).What ships (all labelled preview)
fixmap contracts [--repo] [--format markdown|json] [--output] [--no-cache]lists the contract surfaces in the working tree: path, kind, name, declared version (OpenAPI/AsyncAPI version,$schema,proto3/edition), entry count, and exactworktree:sha256fingerprint.fixmap contracts diff <from>..<to>compares two exact Git refs throughgit ls-tree+git cat-file --batch(thefixmap historypattern). It never checks out a ref and never touches the worktree. Changes come out grouped as breaking / unknown / compatible, each with itsgit:<oid>before and after fingerprints. Three-dot ranges, refs that start with-, and--no-cacheare rejected.fixmap_contractstakesaction: "list" | "diff",from,to,repo,format. It setsreadOnlyHint: true(plusdestructiveHint: false,idempotentHint: true,openWorldHint: false) and validates strictly: unknown arguments, a bad action, one-sided or unbounded refs, refs containing..or starting with-, remote repos and bad formats all fail. It delegates to the CLI command, so both surfaces print the same output..yaml/.ymlnow go through a bounded, dependency-free YAML-subset reader (packages/core/src/yaml-subset.ts) and then the same decoder as JSON. YAML and JSON therefore produce identical entries and deltas: parameters, requiredness, schema fields,$refs and flow collections. Before this, YAML extracted only operations. Constructs the reader can't represent faithfully are reported ascontract-parse-failedinstead of guessed: anchors, aliases, tags, merge keys, duplicate keys, tab indentation and multi-document files.preview: true. CLI help readsPreview:, the MCP description readsPreview (may change before v0.10.0):, and the preview-set tests are updated.Core behaviour changes (worth a reviewer's eye)
unknown, not silent. If a contract parses at one ref and not the other,compareContractInventoriesused to emit nothing. It now emits acontract-unavailablechange withcompatibility: "unknown"and the fingerprint from the readable side. It is still never reported ascontract-removed/breaking. The existing test that pinned "no change" was updated to match the brief ("unknown or unparseable contracts are reported as unknown with a diagnostic, never silently skipped")..graphql,.gql,.protoor.sql(not inSOURCE_FILE_EXTENSIONS), socontractSourcesFromRepo, which change-scope uses, parsed an empty string and reported those contracts with zero entries. It now flags them ascontract-source-incomplete. The new Contract Guardian readers read contract files in full (2 MB per file, 64 MB in total; larger or non-UTF-8 files are reported as unread). I didn't add those extensions to the scanner because that would shift ranking.ContractSurfacegains an optionalversion, andContractChange.changegains"contract-unavailable". Both are additive.# FixMap Contracts/# FixMap Contract DiffMarkdown andcontractListVersion/contractDiffVersionJSON) is recognised as a FixMap artifact.--outputrefuses to overwrite any other repository file.Evidence for the "Contract Guardian" ledger row
Closes these items from the row's "remain" list: YAML schema details and CLI/MCP parity (Action parity is still open). Public-language APIs, known-consumer edges and held-out evidence are also still open.
Tests:
packages/cli/test/contracts-command.test.ts(9 tests, real Git repos):worktree:fingerprints, and GraphQL/Proto/SQL are parsed rather than emptygit:fingerprintsgit status --porcelainand a dirty working-tree file are unchanged after the diff--outputoverwrite refusal and replacing its own prior artifactpackages/cli/test/mcp.test.ts: list and diff through MCP,readOnlyHint, schema shape, HEAD/status unchanged, unknown ref, 10 invalid-argument cases. The preview-set and tool-order tests are updated.packages/cli/test/cli-runner.test.ts: catalog preview list andcontractsPreview:help label.packages/core/test/contracts.test.ts: OpenAPI JSON/YAML parity with entries and deltas, AsyncAPI parity, malformed or unsupported YAML, declared versions (YAMLopenapi: 3.0stays"3.0"), and thecontract-unavailablechange.packages/core/test/contracts-repository.test.ts: YAML subset reader (block/flow/quoted/block scalars, refusals), unsampled-contract fix, oversized and non-UTF-8 handling on both the worktree and ref paths, a content-marked.ymlat a ref, and an unknown ref.Verification
The release session asked us to skip the full local
npm run cibecause of CPU load, so I stopped my run early; GitHub CI runs the full gate. Run locally on this branch:npm run typecheck: passnpm run lint: passvitest run: 881 passed, 1 skipped. On the first run, 1 test failed; it passed on an immediate rerun, likely a timeout while other sessions loaded the machine. Its name wasn't captured.vitest run: 343 passed before the final rebase. After rebasing onto feat(action): preview change scope and capability maps #687 I reran the affected files:mcp,cli-runnerandcontracts-command(185 passed), plus the Action suite (66 passed).npm run check:action-bundle: generated artifacts match the checked-in files.Not edited: the ledger,
CHANGELOG.md, package versions, the website changelog,package-lock.json,packages/action/src.Note: the pre-rebase copy of this branch is still on the remote as
claude/contract-guardian-138b5dbecause the force-push was blocked. It can be deleted.🤖 Generated with Claude Code