Repository navigation
Add agent context budget gate and blocker graph fixes - #486
Conversation
Implement a wide pm SDK/CLI bundle across pm-cu1i, pm-q6gx, and pm-2ldo. - add a deterministic token-budget gate for 14 agent-facing command surfaces and wire it into quality:static and release readiness contracts - preserve search inline field:value tokens so unquoted and quoted status:all hybrid queries keep residual keywords - make update --blocked-by append resolved blocker dependency edges while keeping the latest scalar blocker for compatibility - update SDK command contract descriptions, command docs, generated changelog, tracker metadata, and regression tests Verification: pnpm test:coverage; pnpm version:check && pnpm changelog:pm:check && pnpm contracts:check && pnpm security:scan && pnpm lint && npm pack --dry-run
|
@greptileai |
|
✅ Action performedReview finished.
|
📝 WalkthroughWalkthroughThis PR adds a token-budget regression gate and manifest, changes ChangesToken-budget regression gate
Blocked-by dependency accumulation
Inline search token preservation
Metadata
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant token-budget-gate.mjs
participant dist/cli.js
participant token-budgets.json
token-budget-gate.mjs->>dist/cli.js: seed fixture + run command corpus
dist/cli.js-->>token-budget-gate.mjs: stdout per command
token-budget-gate.mjs->>token-budget-gate.mjs: measureOutput and compareBudgets
token-budget-gate.mjs->>token-budgets.json: buildManifest or validate existing budgets
token-budgets.json-->>token-budget-gate.mjs: pass or violation data
sequenceDiagram
participant update.ts
participant reconcileBlockedByDependency
participant dependencies
update.ts->>reconcileBlockedByDependency: blockedBy value
alt nextBlockedById undefined
reconcileBlockedByDependency->>dependencies: remove all blocked_by edges
else nextBlockedById set
reconcileBlockedByDependency->>dependencies: check existing blocked_by edge
dependencies-->>reconcileBlockedByDependency: exists or missing
reconcileBlockedByDependency->>dependencies: add edge if missing
end
reconcileBlockedByDependency-->>update.ts: updated dependencies
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces a deterministic token-budget regression gate to monitor and enforce token efficiency across 14 CLI surfaces, integrating it into the static quality checks. It also fixes two major issues: GH-484, by ensuring that repeated --blocked-by updates append to the dependency graph rather than overwriting previous blockers, and GH-485, by preserving inline search filter tokens (like status:all) during argument normalization. The reviewer provided valuable feedback on the token-budget gate script, noting that runCli should explicitly check the exit status of executed commands to prevent silent failures from bypassing the gate.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Greptile SummaryThis PR adds a token-budget gate and fixes two agent-facing CLI workflows. The main changes are:
Confidence Score: 5/5Safe to merge with minimal risk. The runtime changes are focused and covered by targeted tests for search token handling, blocked-by graph updates, and token-budget manifest behavior. No files require special attention.
What T-Rex did
Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant CI as quality:static / quality:token-budget
participant Build as pnpm build
participant Gate as token-budget-gate.mjs
participant CLI as dist/cli.js
participant Manifest as token-budgets.json
CI->>Build: build dist CLI (quality:static)
CI->>Gate: run token budget gate
Gate->>Manifest: read checked budgets
Gate->>CLI: init isolated PM workspace
Gate->>CLI: seed deterministic parent/blocker/child/comment
loop 14 agent-facing surfaces
Gate->>CLI: execute command corpus entry
CLI-->>Gate: stdout
Gate->>Gate: measure UTF-8 bytes and estimated tokens
end
Gate->>Manifest: compare measured bytes to max_bytes
Gate-->>CI: pass or fail with offending surface and delta
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant CI as quality:static / quality:token-budget
participant Build as pnpm build
participant Gate as token-budget-gate.mjs
participant CLI as dist/cli.js
participant Manifest as token-budgets.json
CI->>Build: build dist CLI (quality:static)
CI->>Gate: run token budget gate
Gate->>Manifest: read checked budgets
Gate->>CLI: init isolated PM workspace
Gate->>CLI: seed deterministic parent/blocker/child/comment
loop 14 agent-facing surfaces
Gate->>CLI: execute command corpus entry
CLI-->>Gate: stdout
Gate->>Gate: measure UTF-8 bytes and estimated tokens
end
Gate->>Manifest: compare measured bytes to max_bytes
Gate-->>CI: pass or fail with offending surface and delta
Reviews (9): Last reviewed commit: "fix(review): validate token budgets and ..." | Re-trigger Greptile |
Greptile SummaryThis PR adds release gating and fixes several agent-facing CLI behaviors. The main changes are:
Confidence Score: 4/5This PR has one contained blocker-graph bug to fix before merging. The token-budget gate and search parsing changes are well-contained. The remaining issue can remove existing
What T-Rex did
Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant Dev as Developer/CI
participant Script as quality:static
participant Gate as token-budget-gate.mjs
participant CLI as dist/cli.js
participant Fixture as Isolated PM_PATH
participant Manifest as token-budgets.json
Dev->>Script: pnpm quality:static
Script->>Gate: node scripts/release/token-budget-gate.mjs
Gate->>Fixture: create temp workspace
Gate->>CLI: init/create fixture items/comments
CLI-->>Gate: stdout per command
Gate->>Manifest: load checked-in byte budgets
Gate->>Gate: compare measured bytes to max_bytes
Gate-->>Script: pass or fail with offending command deltas
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant Dev as Developer/CI
participant Script as quality:static
participant Gate as token-budget-gate.mjs
participant CLI as dist/cli.js
participant Fixture as Isolated PM_PATH
participant Manifest as token-budgets.json
Dev->>Script: pnpm quality:static
Script->>Gate: node scripts/release/token-budget-gate.mjs
Gate->>Fixture: create temp workspace
Gate->>CLI: init/create fixture items/comments
CLI-->>Gate: stdout per command
Gate->>Manifest: load checked-in byte budgets
Gate->>Gate: compare measured bytes to max_bytes
Gate-->>Script: pass or fail with offending command deltas
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/cli/commands/update.ts (1)
668-699: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winPrevent unresolved
--blocked-byfrom clearing existing edges
context.resolvedBlockedByDependencyIdisundefinedfor unresolved free-text, soapplyBlockedByDependencyEdge()treats it like an explicit unset and removes all existingblocked_byedges. Guard this call so only--unset blocked-byclears edges.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/cli/commands/update.ts` around lines 668 - 699, The `--blocked-by` handling is treating unresolved free-text the same as an explicit unset, which causes existing `blocked_by` edges to be removed; update the call path in `applyBlockedByDependencyEdge`/`reconcileBlockedByDependency` so only an explicit `--unset blocked-by` clears edges. Add a guard before passing `context.resolvedBlockedByDependencyId` into the dependency reconciliation logic so `undefined` from unresolved input does not trigger the removal branch, while preserving the existing behavior for real resolved IDs and explicit unsets.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@CHANGELOG.md`:
- Around line 7-9: The changelog entries currently expose internal
`.agents/pm/...` tracker-artifact links, which should not appear in public docs.
Update the affected bullets in the changelog to remove those private links and
replace them with neutral public references (for example, issue or docs
references) while keeping the release note text intact. Use the existing bullet
entries in the changelog as the location to edit.
In `@package.json`:
- Around line 83-84: The token-budget gate used by quality:static now depends on
build output being present, so update the CI and local workflow that invokes
quality:static to run pnpm build first. Make sure the workflow around the
package.json scripts and any related docs or automation clearly sequences pnpm
build before node scripts/release/static-quality-gate.mjs so dist/cli.js exists
when the chained token-budget check runs.
In `@scripts/release/token-budget-gate.mjs`:
- Around line 213-215: The manifest parsing in token-budget-gate.mjs handles a
bare --manifest incorrectly by treating true as a path, so update the
manifestPath logic to mirror the existing headroom guard and fall back to
DEFAULT_MANIFEST_PATH when flags.get("manifest") is undefined or true. Keep the
behavior consistent with the multiplier handling on multiplierValue/multiplier,
and ensure the path.resolve call only runs when a real manifest value is
provided.
---
Outside diff comments:
In `@src/cli/commands/update.ts`:
- Around line 668-699: The `--blocked-by` handling is treating unresolved
free-text the same as an explicit unset, which causes existing `blocked_by`
edges to be removed; update the call path in
`applyBlockedByDependencyEdge`/`reconcileBlockedByDependency` so only an
explicit `--unset blocked-by` clears edges. Add a guard before passing
`context.resolvedBlockedByDependencyId` into the dependency reconciliation logic
so `undefined` from unresolved input does not trigger the removal branch, while
preserving the existing behavior for real resolved IDs and explicit unsets.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: ASSERTIVE
Plan: Pro
Run ID: 68a92aa6-3921-4b5f-b40a-34e98d9ccc9f
📒 Files selected for processing (20)
.agents/pm/extensions/.managed-extensions.json.agents/pm/history/pm-2ldo.jsonl.agents/pm/history/pm-cu1i.jsonl.agents/pm/history/pm-q6gx.jsonl.agents/pm/issues/pm-2ldo.toon.agents/pm/issues/pm-q6gx.toon.agents/pm/tasks/pm-cu1i.toonCHANGELOG.mddocs/COMMANDS.mdpackage.jsonscripts/release/token-budget-gate.mjsscripts/release/token-budgets.jsonsrc/cli/bootstrap-args.tssrc/cli/commands/update.tssrc/sdk/cli-contracts/commander-mutation-options.tstests/integration/release-automation-contract.spec.tstests/integration/release-readiness-runtime.spec.tstests/unit/cli/bootstrap-args.spec.tstests/unit/commands/update-command.spec.tstests/unit/scripts/release/token-budget-gate.spec.ts
There was a problem hiding this comment.
Code Review
This pull request introduces a deterministic token-budget gate to enforce byte limits on CLI outputs, resolves an issue where pm update --blocked-by overwrote prior blockers instead of appending them (GH-484), and fixes a bug where pm search dropped keywords when parsing inline filters (GH-485). It also updates the corresponding documentation, command contracts, and test suites. Feedback on the changes highlights a high-severity issue in the new token-budget-gate.mjs script, where runCli fails to verify the exit status of executed commands, potentially allowing crashing commands with empty outputs to silently pass the budget check.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Address PR review feedback and CI fallout. - preserve existing blocked_by dependency edges when update --blocked-by receives an unresolved item id - add regression coverage for valid blocker edge followed by unresolved blocker typo - make the token-budget missing-CLI test path-safe on Windows - record review-loop evidence on pm-q6gx and pm-cu1i Verification: focused update/token-budget tests; pnpm quality:token-budget; pnpm lint; pnpm test:coverage; pnpm version:check && pnpm changelog:pm:check && pnpm contracts:check && pnpm security:scan && pnpm lint && npm pack --dry-run
|
Review-loop update pushed in
Verification after the fix: focused update/token-budget tests, @greptileai |
|
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Code Review
This pull request introduces a deterministic token-cost regression gate to enforce output byte budgets across 14 agent-facing CLI surfaces, integrated directly into the static quality checks. It also resolves two major CLI issues: GH-485, by preserving search inline filter tokens to prevent dropping keywords in hybrid queries, and GH-484, by ensuring that repeated --blocked-by updates append to the blocker dependency graph rather than overwriting prior blockers. Feedback on the new token budget gate script recommends merging process.env to preserve critical system environment variables across different OS/CI environments, and using optional chaining on manifest.budgets to gracefully handle malformed or empty manifests.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
@greptileai Review follow-up pushed in a2a7a97. Please review the current head. |
|
✅ Action performedFull review finished. Your plan includes PR reviews subject to rate limits. More reviews will be available in 16 minutes. |
|
Review acknowledgements for the previous head are complete:
Every inline finding was voted and answered in its thread. |
There was a problem hiding this comment.
Code Review
This pull request introduces a deterministic token-cost regression gate for 14 agent-facing CLI surfaces, wiring it into the static quality checks and release contracts. It also fixes two major issues: GH-484, where pm update --blocked-by now appends and deduplicates blocker dependency edges instead of overwriting them, and GH-485, which prevents pm search from dropping keywords when inline filters are used. Feedback on the changes highlights potential test failures on Windows due to hardcoded Unix-style path separators in the new token-budget gate tests, suggesting the use of path.join to ensure platform-agnostic paths.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
@greptileai Windows portability fix pushed in e9fe2e7. Please review the current head. |
|
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Code Review
This pull request introduces a token budget regression gate to monitor and control the size of CLI output, preventing silent regressions in token usage. It also fixes two bugs: one where 'pm search' incorrectly rewrote quoted hybrid queries, and another where 'pm update --blocked-by' silently overwrote existing dependency edges instead of appending them. The PR includes comprehensive regression tests, updated documentation, and improved defensive validation for the new token budget manifest. My feedback focuses on enhancing the robustness of the manifest parsing and ensuring proper test state management.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
@greptileai Manifest validation and test-isolation fixes pushed in c532d14. Please review the current head. |
|
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Code Review
This pull request introduces a deterministic token-cost regression gate to enforce byte and token limits on 14 agent-facing CLI surfaces, wired into the static quality checks. It also resolves GH-484 by ensuring pm update --blocked-by appends resolved blocker dependency edges to the graph instead of overwriting previous ones, and resolves GH-485 by preserving inline search filter tokens as query input to prevent keywords from being dropped during argument normalization. Comprehensive unit and integration tests, along with documentation updates, have been added to support these changes. No review comments were provided, and I have no feedback to add.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
Gemini current-head review acknowledged: no comments or additional feedback on c532d14. Manifest entry validation, process-global test isolation, Windows portability, and the focused/static gates are all green. |
Summary
quality:staticplus release readiness contractspm searchinlinefield:valuetokens so quoted and unquoted hybrid queries keep residual keywordspm update --blocked-byappend resolvedblocked_bydependency edges while the scalar tracks the latest blockerTracked 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.tsnode scripts/run-tests.mjs test -- tests/unit/scripts/release/token-budget-gate.spec.ts && pnpm quality:token-budgetnode scripts/run-tests.mjs test -- tests/integration/release-automation-contract.spec.ts tests/integration/release-readiness-runtime.spec.tsPM_PATHmanual proof forsearch status:all,update --blocked-byappend semantics, and compact context outputpnpm 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-rungreptile 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
scripts/release/token-budget-gate.mjswith a checked-in manifestscripts/release/token-budgets.json; measures UTF-8 bytes and blocks regressions with optional --update. (pm-cu1i)quality:static(now runspnpm buildfirst) and addedquality:token-budget; release automation/readiness tests pin this gate.Bug Fixes
field:valuetokens inpm searchso quoted/unquoted hybrids keep residual keywords (e.g., "status:all scene"). (pm-2ldo)pm update --blocked-bynow appends resolvedblocked_byedges, 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)max_bytes); bare--manifestuses the default path; built CLI before measuring; made missing-CLI path/tests Windows-safe; isolated tests (restoredprocess.argv/process.exitCode, cleared env). Updated SDK command contracts, command docs, and changelog.Written for commit c532d14. Summary will update on new commits.