Repository navigation
feat(cli): fill Contract, Run first and Fresh in the preflight answer (#447) - #468
Merged
Merged
Conversation
…#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]>
Open
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.
Summary
charter adf context --filesand MCPgetProjectContext(withfiles) now fill in the three preflight lines that used to sayunknown. 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.The
.github/workflows/ci.ymlseed still gets the one-lineNothing binds ...answer.#467 fixes (each test failed before its fix):
c:/.../manifest.ts) found no tests. Seeds now go through the newcanonicalRepoFileinadf-path-tokens.ts, which builds onrelativizeFilePathand keeps the on-disk casing. Test:test-rank.test.ts, "finds the same tests for a lowercase drive letter seed".export type Foo = {...}swallowed the next value import, so a pinned file came backpinned: false. The import clause incontract-pins.tsis now matched one statement at a time. Tests: two cases inpinned-by-tests.test.ts.Integration (the new file
adf-preflight-parts.tsholds the logic; no governed file grows):Contractreads one of: pinned, with its surfaces and test → semver rule;not pinned by a contract test (...); orunknown (<reason>).Run firstgives the command, then the reason in parentheses. It saysunknown (<reason>)when there is no direct evidence, and names the nearest transitive test only as such. Non-source files skip the graph scan.Freshgives the short SHA, the branch, and eithertree cleanorN dirty files(with(incl. this file)when the file itself is dirty). Outside git it saysunknown (not a git work tree).ContractandRun firstgive one entry per file.--format jsonwith--files, list and--bundle): additive keys afterbinds, in this order:contract: summary plus per-filefiles[]withevidence.tests[]: each withreason,command,tierandfor.testsUnknown: string or null. This one is beyond the issue's key list; it exists sotests[]stays a plain array.fresh: fullheadSHA,branch, dirty info,checkedLive.nextActions[].adf-ceilings.test.tsis extended, and a new test pins list,--bundleand keywords-only key order.projectContextContentreturns the same fields from the samepreflightAnswer. Tests check that its JSON equals the CLI's, key for key.bindsis 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.readGitFingerprinttakes an optionalroot, which skips a secondrev-parse.Docs:
docs/cli-reference.md: preflight section (new example, what each line means, JSON keys) and the MCP table row.CHANGELOG.md3.0.0 (date placeholder kept): new entries for context-refresh --once and charter_context serve a stale snapshot as fresh after a branch, HEAD or working-tree change #440/PR fix(cli): snapshot freshness fingerprint for context-refresh --once and charter_context (#440) #462, getProjectState reports 'All constraints pass' while live evidence fails #441/PR fix(serve): measure METRICS sources live in getProjectState (#441) #463, Rank first-test candidates by direct symbol evidence, not import distance #444/PR feat(cli): rank first-test candidates by direct symbol evidence (#444) #465, Detect when a file's behaviour is pinned by a contract test, and say what a change means for semver #445/PR feat(cli): detect files pinned by contract tests (#445) #466, smart-commit.sh can't set a message or trailers, so core.adf's commit rule is unfollowable #459/PR fix(scripts): let smart-commit.sh take a message, body and trailers #464 (marked as repo tooling only) and this integration, plus the two Preflight parts follow-ups: Windows drive-letter test ranking, semicolon-free import parse, and 9 minors #467 fixes.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.--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.2095bda,pnpm exec vitest run(parallel): 9 failed, 2240 passed, 2 skipped.2095bda) adf-preflight-guards have a 30 s timeout, because most run several full answers. The one exception is the two-answerci.ymltest in adf-preflight, which skips the graph scan (under 0.4 s) and keeps the 5 s default. At60bc48bthe guards file still had the 5 s default and timed out in parallel runs. At2095bdaall three files pass in the parallel full run.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.node scripts/docs-sync.mjs --check --allow-missing-config(skipped, no config) andnode scripts/papers-lint.mjs(passed).--files packages/cli/src/commands/adf-evidence.tsgives: Binds (adf-dev rules with line numbers); Headroomadf_evidence_loc 261/313; Contract pinned byevidence-contracts.test.ts(exit codes + --format json); Run firstevidence-contracts.test.ts; Fresh with HEAD, checked live. A test asserts each line, that JSONfresh.headequalsgit rev-parse HEAD, and that MCP returns the same rules, ceilings, contract, tests and nextActions.--files .github/workflows/ci.ymlgives the oneNothing bindsline.adf context --keywords adf: min 277 to 454 ms, median 296 ms when quiet and 820 to 1571 ms under load.--files adf-evidence.tstext: 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.--keywordsbaseline rose by the same amount.preflightAnswertakes 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-filesplus the contract tests (about 40 ms) andgit status(about 60 ms).Not done
canonicalRepoFile, but not insidedetectContractPinsitself.computeProjectState(getProjectState reports 'All constraints pass' while live evidence fails #441) is not part of the preflight answer..ai/state.adfwas not updated (the smart-commit hint). Governance files were left alone, as instructed.Refs #447
Part of #437
🤖 Generated with Claude Code