Add agent context budget gate and blocker graph fixes

Merged
UN
4mo ago
+979-46

Summary

  • add a deterministic token-budget release gate over 14 agent-facing CLI surfaces and wire it into quality:static plus release readiness contracts
  • preserve pm search inline field:value tokens so quoted and unquoted hybrid queries keep residual keywords
  • make repeated pm update --blocked-by append resolved blocked_by dependency edges while the scalar tracks the latest blocker
  • update SDK contract descriptions, command docs, pm tracker evidence, and generated changelog

Tracked pm items: pm-cu1i, pm-q6gx, pm-2ldo.

Verification

  • node scripts/run-tests.mjs test -- tests/unit/cli/bootstrap-args.spec.ts tests/unit/commands/update-command.spec.ts
  • node scripts/run-tests.mjs test -- tests/unit/scripts/release/token-budget-gate.spec.ts && pnpm quality:token-budget
  • node scripts/run-tests.mjs test -- tests/integration/release-automation-contract.spec.ts tests/integration/release-readiness-runtime.spec.ts
  • isolated temp PM_PATH manual proof for search status:all, update --blocked-by append semantics, and compact context output
  • pnpm test:coverage (267 files, 5480 tests, 100% statements/branches/functions/lines)
  • pnpm version:check && pnpm changelog:pm:check && pnpm contracts:check && pnpm security:scan && pnpm lint && npm pack --dry-run
  • greptile review --branch main --agent (final pass: confidence 5/5, no review comments)

Summary by cubic

Adds a deterministic token-budget gate for 14 agent-facing CLI surfaces and fixes search parsing and blocker graph updates. Hardens the gate with manifest entry validation, builds the CLI before measuring, and makes tests platform-safe to keep agent context output small and reliable.

  • New Features

    • Added scripts/release/token-budget-gate.mjs with a checked-in manifest scripts/release/token-budgets.json; measures UTF-8 bytes and blocks regressions with optional --update. (pm-cu1i)
    • Wired the gate into quality:static (now runs pnpm build first) and added quality:token-budget; release automation/readiness tests pin this gate.
  • Bug Fixes

    • Search: preserved inline field:value tokens in pm search so quoted/unquoted hybrids keep residual keywords (e.g., "status:all scene"). (pm-2ldo)
    • Blockers: pm update --blocked-by now appends resolved blocked_by edges, dedupes repeats, preserves existing edges when the new value is unresolved, and clears all on --unset blocked-by; scalar keeps the latest blocker. (pm-q6gx)
    • Token-budget gate hardening: kept child-process env; validated manifest shape and each entry (string id, non-negative max_bytes); bare --manifest uses the default path; built CLI before measuring; made missing-CLI path/tests Windows-safe; isolated tests (restored process.argv/process.exitCode, cleared env). Updated SDK command contracts, command docs, and changelog.