Skip to content

fix(serve): measure METRICS sources live in getProjectState (#441) - #463

Merged
stackbilt-admin merged 1 commit into
mainfrom
fix/issue-441-project-state-measured
Nov 28, 2026
Merged

stackbilt-admin merged 1 commit into
mainfrom
fix/issue-441-project-state-measured

Conversation

@stackbilt-admin

Copy link
Copy Markdown
Member

Summary

MCP getProjectState checked the static numbers written in .adf METRICS and never measured anything. So it could say "All constraints pass" while adf evidence --auto-measure --ci failed. It now measures the manifest METRICS sources live, using measureMetricSources from adf-ceilings.ts, the same code adf evidence --auto-measure uses. When a constraint fails it reports the measured value and the ceiling.

  • New module packages/cli/src/commands/project-state.ts:
    • computeProjectState(aiDir, manifest) returns { measured, allPassing, failCount, warnCount, metrics[], modules[] }. Each metric carries value, ceiling, status, module, measured, source? and note?.
    • formatProjectState(state) renders the tool's text.
    • Integrating it elsewhere takes one line.
  • METRICS paths resolve against the parent of .ai/, as computeFileCeilings does, so the result doesn't depend on the server's cwd. With the default .ai, this gives the same paths as adf evidence.
  • It still checks every manifest module (default plus on-demand), as before.
  • Values it can't measure are labelled, not trusted silently. A missing source file or a metric with no METRICS source gets measured: false and a note like "static value, not measured (...)". The top-level measured is true only when every metric value was measured live.
  • serve.ts diff is confined to the getProjectState tool, plus its import line and the removal of the now-unused validateConstraints import.

Response shape (additive only)

  • These text lines are unchanged: ## Project State, ### <module> — N issue(s), - [FAIL] <message>, All constraints pass — no violations detected.
  • Issue lines gain a (measured) or (static value, not measured) suffix.
  • A ### Measurement section is appended. It has a measured: true|false line and one line per metric.
  • New structuredContent field carrying the same data. content is still a single text item.

Verified

  • pnpm install --frozen-lockfile: ok
  • pnpm exec tsc --build tsconfig.build.json: exit 0
  • pnpm exec tsc --noEmit -p tsconfig.json: exit 0
  • pnpm exec vitest run packages/cli/src/__tests__/project-state.test.ts packages/cli/src/__tests__/serve-zod4.test.ts packages/cli/src/__tests__/serve-context.test.ts:
    • The new tests (5) pass.
    • They reproduce the getProjectState reports 'All constraints pass' while live evidence fails #441 case: bundler_loc: 129 / 144 is declared while the source has 149 lines. The result is [FAIL] bundler_loc: 149 / 144 [lines] -- FAIL (measured).
    • An in-ceiling fixture still says "All constraints pass".
    • Values that can't be measured are labelled static.
    • An end-to-end MCP stdio call to getProjectState, run from an unrelated cwd, reports the failure.
    • The only failure is the known Windows separator failure in serve-context, which is unrelated.
  • pnpm exec vitest run (full suite): 14 failures, all in files this PR doesn't touch.
  • node packages/cli/dist/bin.js adf evidence --auto-measure --ci --format text: Verdict PASS, exit 0. The pre-commit hook passed too.

Not done

  • Not yet wired into the preflight answer. That's left to the later integration PR, which can call computeProjectState.

Closes #441
Part of #437

🤖 Generated with Claude Code

getProjectState validated the static values written in .adf METRICS and
never measured, so it reported "All constraints pass" while
`adf evidence --auto-measure --ci` failed. It now measures manifest METRICS
sources through measureMetricSources (the code adf evidence uses), resolved
against the .ai/ parent, and reports failing constraints with the measured
value and ceiling.

Additive only: the existing text lines are kept; issue lines gain a
"(measured)" / "(static value, not measured)" suffix, a Measurement section
lists per-metric values with `measured: true|false`, and the result carries
structuredContent with the same data. Logic lives in the new
commands/project-state.ts (computeProjectState, formatProjectState).

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