Skip to content

feat(cli): fill Contract, Run first and Fresh in the preflight answer (#447) - #468

Merged
stackbilt-admin merged 2 commits into
mainfrom
feat/issue-447-preflight-integration
Nov 28, 2026
Merged

stackbilt-admin merged 2 commits into
mainfrom
feat/issue-447-preflight-integration

Conversation

@stackbilt-admin

@stackbilt-admin stackbilt-admin commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

Summary

charter adf context --files and MCP getProjectContext (with files) now fill in the three preflight lines that used to say unknown. They use the parts that have already merged: contract pins (#445, PR #466), first-test ranking (#444, PR #465) and the live git fingerprint (#440, PR #462). It also fixes the two #467 findings that gave a confidently wrong answer.

$ charter adf context --files packages/cli/src/commands/adf-evidence.ts
Binds:     adf-dev.adf → "ADF package has zero runtime dependencies"  (.ai/adf-dev.adf:18)
           ...
Headroom:  adf_evidence_loc 261/313 → 52 lines left [pass] (core.adf)
Contract:  exit codes + --format json pinned by evidence-contracts.test.ts → breaking = major + migration note; additive = minor
Run first: pnpm exec vitest run packages/cli/src/__tests__/integration/evidence-contracts.test.ts
           (references adfEvidence (9); pins this file's contract; 2 more ranked in --format json)
Fresh:     HEAD fcd73f3 on feat/issue-447-preflight-integration, 18 dirty files, checked live

The .github/workflows/ci.yml seed still gets the one-line Nothing binds ... answer.

#467 fixes (each test failed before its fix):

  • Item 1: a seed with a lowercase Windows drive letter (c:/.../manifest.ts) found no tests. Seeds now go through the new canonicalRepoFile in adf-path-tokens.ts, which builds on relativizeFilePath and keeps the on-disk casing. Test: test-rank.test.ts, "finds the same tests for a lowercase drive letter seed".
  • Item 2: in semicolon-free code, an export type Foo = {...} swallowed the next value import, so a pinned file came back pinned: false. The import clause in contract-pins.ts is now matched one statement at a time. Tests: two cases in pinned-by-tests.test.ts.

Integration (the new file adf-preflight-parts.ts holds the logic; no governed file grows):

  • Text output:
    • Contract reads one of: pinned, with its surfaces and test → semver rule; not pinned by a contract test (...); or unknown (<reason>).
    • Run first gives the command, then the reason in parentheses. It says unknown (<reason>) when there is no direct evidence, and names the nearest transitive test only as such. Non-source files skip the graph scan.
    • Fresh gives the short SHA, the branch, and either tree clean or N dirty files (with (incl. this file) when the file itself is dirty). Outside git it says unknown (not a git work tree).
    • With several files, Contract and Run first give one entry per file.
  • JSON (--format json with --files, list and --bundle): additive keys after binds, in this order:
    • contract: summary plus per-file files[] with evidence.
    • tests[]: each with reason, command, tier and for.
    • testsUnknown: string or null. This one is beyond the issue's key list; it exists so tests[] stays a plain array.
    • fresh: full head SHA, branch, dirty info, checkedLive.
    • nextActions[].
    • Existing keys, their order and exit codes are unchanged. The key-order contract test in adf-ceilings.test.ts is extended, and a new test pins list, --bundle and keywords-only key order.
  • MCP: projectContextContent returns the same fields from the same preflightAnswer. Tests check that its JSON equals the CLI's, key for key.
  • binds is now also true when a contract test pins a file. Such a file gets the full answer instead of "Nothing binds". This is listed under Changed in the CHANGELOG.
  • Speed:
    • readGitFingerprint takes an optional root, which skips a second rev-parse.
    • The import graph is built once per call and shared across the per-file rankings.

Docs:

Verification (local, Windows; Actions is not running)

  • pnpm install --frozen-lockfile: ok.
  • pnpm exec tsc --build tsconfig.build.json: exit 0.
  • pnpm exec tsc --noEmit -p tsconfig.json: exit 0.
  • Targeted tests, run serially (--no-file-parallelism): 83/83 pass. Files: adf-preflight, adf-preflight-cwd, adf-preflight-guards, adf-ceilings, adf-path-root, test-rank, pinned-by-tests, context-refresh-freshness.
  • Full suite at 2095bda, pnpm exec vitest run (parallel): 9 failed, 2240 passed, 2 skipped.
  • The real-repo preflight tests in adf-preflight, adf-preflight-cwd and (since 2095bda) adf-preflight-guards have a 30 s timeout, because most run several full answers. The one exception is the two-answer ci.yml test in adf-preflight, which skips the graph scan (under 0.4 s) and keeps the 5 s default. At 60bc48b the guards file still had the 5 s default and timed out in parallel runs. At 2095bda all three files pass in the parallel full run.
  • Gates:
    • node packages/cli/dist/bin.js adf evidence --auto-measure --ci --format text: PASS, exit 0. The one warning, adf_migrate_loc at 792/792, was already on main.
    • validate --ci, drift --ci, doctor --adf-only --ci: exit 0.
    • The pre-commit hook passed.
  • Docs: node scripts/docs-sync.mjs --check --allow-missing-config (skipped, no config) and node scripts/papers-lint.mjs (passed).
  • Acceptance on this repo:
    • --files packages/cli/src/commands/adf-evidence.ts gives: Binds (adf-dev rules with line numbers); Headroom adf_evidence_loc 261/313; Contract pinned by evidence-contracts.test.ts (exit codes + --format json); Run first evidence-contracts.test.ts; Fresh with HEAD, checked live. A test asserts each line, that JSON fresh.head equals git rev-parse HEAD, and that MCP returns the same rules, ceilings, contract, tests and nextActions.
    • --files .github/workflows/ci.yml gives the one Nothing binds line.
  • Timing (built CLI, 4 to 5 other agents loading the machine, so medians swing; min is the best guide):
    • CLI startup baseline, adf context --keywords adf: min 277 to 454 ms, median 296 ms when quiet and 820 to 1571 ms under load.
    • --files adf-evidence.ts text: median 737 ms in the first quiet run (min 618 to 715 ms).
    • --files adf-evidence.ts --format json: median 617 ms in the first quiet run (min 569 to 655 ms).
    • --files .github/workflows/ci.yml: min 671 ms in the first run. This was measured before the non-source short-circuit, which takes the in-process cost from about 300 ms to 70 ms.
    • Later runs under heavier load had medians of 1.1 to 2.2 s, but the --keywords baseline rose by the same amount.
    • In process, preflightAnswer takes 317 ms median (min 260 ms) for adf-evidence.ts and 70 ms for ci.yml. The cost is the graph scan (about 160 ms), ranking (about 55 ms), git ls-files plus the contract tests (about 40 ms) and git status (about 60 ms).
    • Under 1 s when the machine is quiet. Nothing is cached, so each call is a live read.

Not done

Refs #447
Part of #437

🤖 Generated with Claude Code

kovermier and others added 2 commits November 28, 2026 09:55
…#447)

Wire contract pins (#445), first-test ranking (#444) and the live git fingerprint (#440) into charter adf context --files and MCP getProjectContext through the shared preflightAnswer path. JSON gains additive contract, tests, testsUnknown, fresh and nextActions keys after binds; existing keys, order and exit codes are unchanged. A part without evidence says unknown with its reason.

Fix #467 items 1 and 2: lowercase Windows drive-letter seeds now find their tests (seeds go through canonicalRepoFile), and a semicolon-free export type no longer swallows the next value import in contract-pins.

Docs: cli-reference preflight section; CHANGELOG 3.0.0 entries for #440, #441, #444, #445, #459 and this integration.
Refs: #447
Refs: #467
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Each test runs up to ten full preflight answers, which now include git and an import-graph scan. Under a parallel full-suite run they exceeded vitest's 5s default.

Refs: #447
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

2 participants