Skip to content

Preflight: one answer (binding rule, headroom, contract, first test, freshness) before an agent edits a file #447

Done

Description

@stackbilt-admin

Why

A coding agent, whether Claude, Codex, Gemini, Copilot or Cursor, should see a Charter repo and think "I need this to code like a boss." Today it reaches for Git and search, because Charter's first-contact answers repeat what Git knows, and are sometimes stale. In the 2026-11 review (two independent reviewers, pinned 5412100), Charter won in one place: the evidence gate, which knows exactly what CI will enforce.

This issue combines the pieces into one answer an agent can't cheaply assemble itself, delivered the moment it's about to edit.

Proposed behaviour (additive to charter adf context --files; same answer from MCP getProjectContext with a files argument)

$ 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 274/313 → 39 lines left
Contract:  exit codes + --format json pinned by evidence-contracts.test.ts → breaking = major + migration note
Run first: pnpm exec vitest run packages/cli/src/__tests__/integration/evidence-contracts.test.ts
           (pins this command's exit-code contract)
Fresh:     HEAD 5412100 (full SHA in JSON), tree clean, checked live

Each line changes the agent's next action:

  • extract before writing into a full file
  • load the rule it would have missed
  • classify the version bump correctly
  • run the right test
  • trust the state

JSON keeps existing keys and adds:

  • rules[], with source locations
  • ceilings[]
  • contract
  • tests[], with a reason for each
  • fresh
  • nextActions[]

Builds on (each ships on its own; this issue assembles whatever exists and says unknown for the rest)

Acceptance

  • The example above, run on this repo, produces those fields with correct values. The same input over MCP returns the same rules and fields.
  • A seed with no governance (for example .github/workflows/ci.yml) returns a short answer saying nothing binds it, rather than noise. Agents should be able to skip Charter quickly when it has nothing to add.
  • Runs in under 1 s locally with no network.
  • Existing adf context JSON consumers are unaffected (contract test).

Non-goals

No new mandatory "call first" step. Agents should use this because it's worth it.

Part of #437.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementepic:preflightpriority:p0type:feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions