Skip to content

feat(cli): report live ceiling headroom in adf context --files - #454

Merged
stackbilt-admin merged 1 commit into
mainfrom
feat/issue-443-ceiling-headroom
Nov 28, 2026
Merged

stackbilt-admin merged 1 commit into
mainfrom
feat/issue-443-ceiling-headroom

Conversation

@stackbilt-admin

Copy link
Copy Markdown
Member

Summary

  • charter adf context --files ... --format json now has an additive ceilings array. Each file that maps to a manifest METRICS source gets one entry: { file, metric, value, ceiling, headroom, status, module }. Text mode prints a Ceilings: block. The --bundle JSON output gets the same key.
  • The measuring moved into a new module, packages/cli/src/commands/adf-ceilings.ts, and adf evidence --auto-measure now uses it too. Both commands count lines the same way (split('\n').length, so the trailing newline counts as a line). The number an agent sees before editing is the number CI enforces. adf-evidence.ts got shorter (274 -> 261 lines).
  • status and ceiling come from validateConstraints on the module that declares the metric. That module is searched for in DEFAULT_LOAD first, then ON_DEMAND, so pass/warn/fail follows the gate's own rules.

Behaviour

  • Files with no metric get no entry. A metric file that doesn't exist on disk also gets no entry.
  • The ceilings key appears only when --files is given (it can be an empty array). Output from --keywords alone is unchanged. Existing keys and exit codes are unchanged.
  • Paths are normalized before matching, so ./src/x.ts, absolute paths and Windows backslashes all match. file is always the manifest's repo-relative path.

Acceptance check (this repo)

$ node packages/cli/dist/bin.js adf context --files packages/cli/src/commands/adf-migrate.ts --format json
"ceilings": [{ "file": "packages/cli/src/commands/adf-migrate.ts", "metric": "adf_migrate_loc",
  "value": 792, "ceiling": 792, "headroom": 0, "status": "warn", "module": "core.adf" }]

adf evidence --auto-measure reports adf_migrate_loc: 792 for the same file.

Notes for merge

  • adf-context.ts changes are only in the import block, the two JSON output objects, one line in the text branch, and two helper functions at the end of the file. The --bundle reader (~line 90) and filePathToKeywords are untouched, so this should merge cleanly with the parallel branches.
  • There is no --bundle test. On main, --bundle throws Module not found because it joins aiDir twice; the parallel bundle-reader branch fixes that. A test for ceilings in bundle output can go in once that lands.
  • serve.ts (updateEvidence MCP tool) still has its own copy of the line count. I left it alone to keep this diff small; it can switch to measureLines later.

Tests

  • New: packages/cli/src/__tests__/adf-ceilings.test.ts (trailing-newline counting, headroom equal to ceiling minus the auto-measured value, files with no metric, no key for --keywords alone, ON_DEMAND module attribution, path normalization, missing files).
  • tsc --build and tsc --noEmit are clean. The targeted tests (adf-ceilings, adf-context, adf-metrics) pass.
  • Full suite on Windows: 2022 passed, 14 failed. Rerun on their own, the vendor/copilot/bootstrap-reset files pass. The 3 hook/precommit failures that remain are bash/sh environment problems (spawnSync sh ENOENT, WSL path mangling). The remaining failures are the known Windows ones (context-refresh/serve-context paths, bootstrap bootstrap: phases 6/7 collect warnings without printing them; absoluteAiDirArg misses Windows paths on POSIX #307, github-commit-range timeouts). None of them touch the changed code.

Closes #443
Part of #437

🤖 Generated with Claude Code

For each --files entry that maps to a manifest METRICS source, adf context
now adds an additive `ceilings` array ({ file, metric, value, ceiling,
headroom, status, module }) to its JSON output, plus a Ceilings block in
text mode. Measurement moves into a shared adf-ceilings module that adf
evidence --auto-measure now also uses, so the value an agent sees before
editing is exactly what the gate enforces (trailing newline included).

Closes #443
Part of #437

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@stackbilt-admin
stackbilt-admin merged commit 02d7a32 into main Nov 28, 2026
7 checks passed
@stackbilt-admin
stackbilt-admin deleted the feat/issue-443-ceiling-headroom branch November 28, 2026 02:09
stackbilt-admin pushed a commit that referenced this pull request Nov 28, 2026
Add 3.0.0 entries for #453 (MCP getProjectContext task tokenizer parity,
adf context --bundle path fix; #438, #439), #454 (live ceiling headroom in
adf context --files; #443), #382 (publish:check on Windows) and #385
(Dependabot covers the pinned SBOM generator).

Apply the #456 review nits: drop the two stray blank lines that made the
Changed list loose, and note that #425 also updated the supply-chain
workflow and dependabot.yml comments.

The 3.0.0 date placeholder is left for the release owner.

Refs #397

Co-Authored-By: Claude Opus 5.5 <[email protected]>
stackbilt-admin pushed a commit that referenced this pull request Nov 28, 2026
Brings in #453 (task tokenizer parity, --bundle path fix) and #454
(ceiling headroom). Resolves the adf-context.ts conflict by keeping both
the path-token import and triggerMatches (this branch) and the ceilings
field (main). The adf-ceilings key-order test now expects triggerMatches
between resolvedModules and ceilings.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
stackbilt-admin pushed a commit that referenced this pull request Nov 28, 2026
…o feat/issue-447-preflight-slice

Brings in #453 and #454 (squash-merged on main) through #452's round-3
merge, plus #452's memoized resolvePathTokenRoot and filePathRoutingKeywords.
Conflicts resolved toward this branch's preflight code (which already
contains the #443/#454 ceilings work); fileRoutingKeywords is kept as a thin
wrapper over #452's filePathRoutingKeywords.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
stackbilt-admin added a commit that referenced this pull request Nov 28, 2026
Add 3.0.0 entries for #453 (MCP getProjectContext task tokenizer parity,
adf context --bundle path fix; #438, #439), #454 (live ceiling headroom in
adf context --files; #443), #382 (publish:check on Windows) and #385
(Dependabot covers the pinned SBOM generator).

Apply the #456 review nits: drop the two stray blank lines that made the
Changed list loose, and note that #425 also updated the supply-chain
workflow and dependabot.yml comments.

The 3.0.0 date placeholder is left for the release owner.

Refs #397

Co-authored-by: Kurt Overmier <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
stackbilt-admin pushed a commit that referenced this pull request Nov 28, 2026
Review fixes for #458:
- #454 entry: ceilings print as the preflight Headroom line, not a
  Ceilings: block; drop the stale "--keywords-only output unchanged".
- #455 entry: parse errors are tolerated only without --bundle; the
  preflight block goes to stderr with --bundle; MCP returns the full
  preflight fields.
- Changed: #452 signals now read the repo-relative path; nothing-binds
  shortens CLI text and the MCP response.
- Breaking: scope "MCP argument shapes unchanged" to the Zod migration.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
stackbilt-admin added a commit that referenced this pull request Nov 28, 2026
* docs(changelog): add 3.0.0 entries for #452 and #455

Both merged after #457, so 3.0.0 would have shipped them without notes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(changelog): correct 3.0.0 entries for #452, #454 and #455

Review fixes for #458:
- #454 entry: ceilings print as the preflight Headroom line, not a
  Ceilings: block; drop the stale "--keywords-only output unchanged".
- #455 entry: parse errors are tolerated only without --bundle; the
  preflight block goes to stderr with --bundle; MCP returns the full
  preflight fields.
- Changed: #452 signals now read the repo-relative path; nothing-binds
  shortens CLI text and the MCP response.
- Breaking: scope "MCP argument shapes unchanged" to the Zod migration.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: scope 3.0.0 preflight notes to --bundle and MCP behavior

Second review round for #458:
- Changed: --files text output changes on every run (preflight block
  first); the nothing-binds one-liner applies without --bundle only.
- Move the MCP files response shape into the #455 Added entry; calls
  without files are unchanged.
- Parse errors under --bundle/MCP produce no preflight fields; rule
  locations are repo-root relative; note the non-git root fallback and
  checkout-root words.
- cli-reference: scope the unreadable and one-line claims to non-bundle.
- Zod 4 migration guide: scope "argument shapes remain stable" to the
  migration and point at the new optional files argument.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(changelog): note subdirectory signals and MCP unreadable scope

Round-3 review notes for #458:
- #452 Changed: a relative path from a subdirectory now gains that
  subdirectory's signals, not only loses checkout-root ones.
- #455 Added: over MCP, unreadable is always empty because a parse
  error fails the call; drop it from "same as the CLI".

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Kurt Overmier <[email protected]>
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.

adf context --files: report live ceiling headroom for each file

2 participants