Skip to content

feat(limits)!: report the value a per-call limit needs and derive its recovery - #14625

Merged
morluto merged 4 commits into
mainfrom
feat/per-call-limit-required-value
Nov 26, 2026
Merged

morluto merged 4 commits into
mainfrom
feat/per-call-limit-required-value

Conversation

@morluto

@morluto morluto commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Behavior change

When a per-call parameter limit (control_kind: "parameter") refuses a request, the refusal now:

  • carries details.limit.required_value when the producer measured the smallest value that admits the request;
  • projects a typed adjustable_budget under details.refusal (control, effective_value, unit, range, default_value, optional required_value), the same as registered-setting limits;
  • derives remediation.action from those facts (one owner in src/domain/analysisRefusal.ts): "Pass a larger <parameter> on the next <operation> call (at least N; range a..b), then retry". When the control is already at its maximum, or the need is above it, it asks for a narrower request instead. Environment controls and measured exhaustion stay excluded.
  • A per-call control backed by a registered setting (reported as that setting's limit with parameter and source, as javascript.max_heap_mb already is) names both routes: the next call, then "To raise it for this session, set <setting> with update_analysis_settings." A one-invocation caller (CLI) gets the setting's launch environment variable instead, or only the per-call route when there is none. Per-call-only controls keep the single route. The wording depends only on the refusal's facts.
  • Recovery is rendered once, at projection, in the delivering adapter's spelling (src/domain/analysisRefusalSpelling.ts): MCP by default; a CLI command binds cliRefusalSpelling around its run (flag or JSON-option path, rea <command>, launch-environment route). No adapter rewrites the sentence afterwards, and authored recovery never reaches the renderer. Setting refusals also report source in details.refusal.
  • On the CLI, the step names the command's flag and command (--max-artifact-paths on rea inspect-wasm-artifact); a member set through a whole-field JSON option keeps its path (producer_limits.input_bytes (in --producer-limits)). MCP keeps the contract field and tool.

Count quantities are rendered without a unit word ("budget of 1", "range 1..256").

Producers that duplicated this prose drop their authored remediationAction and report the measured need where they already compute it:

  • ELF notes and debug-link (max_file_bytes, max_entries; section-name budget reports required_value)
  • pcap producer_limits.input_bytes (capture size as required_value) and output_bytes
  • PE/native read budgets via artifactReadBudgetConstraint (required_value = reads needed)
  • inspect_wasm_artifact max_artifact_paths (selected path count)

Other per-call sites keep their authored recovery for now (it still wins over the generated text, so their wording is unchanged); they gain details.refusal.

ArtifactReaderLimitFact (details.reader_limit) stays separate: its required_value is a string when a declared size exceeds Number.MAX_SAFE_INTEGER (exact bigint preservation), and it lives on ArtifactOperationError with its own can_increase/retry semantics and consumers (Flutter, inventory classification). Folding it in would change that error's projection and retry rule, which is outside this foundation change.

Docs: docs/reference/limits-and-recovery.md#adjustable-budget-recovery owns the agent-facing rule; docs/development/tool-design.md gets the contributor rule for per-call vs registered-setting limits and links to it.

Example (CLI, before → after)

Before:

"remediation": {"action": "Raise max_artifact_paths to at least 2 (maximum 4294967295); then retry the same selection. ..."}
"details": {"limit": {"control_kind": "parameter", "parameter": "max_artifact_paths", "effective_value": 1, ..., "cli_flag": "--max-artifact-paths"}}

After:

"remediation": {"action": "inspect_wasm_artifact reached its max_artifact_paths budget of 1. Pass a larger --max-artifact-paths on the next rea inspect-wasm-artifact run (at least 2; range 1..4294967295), then retry."},
"details": {
  "limit": {"control_kind": "parameter", "parameter": "max_artifact_paths", "effective_value": 1, "unit": "count", "minimum": 1, "maximum": 4294967295, "default_value": 16, "applies_at": "next_call", "required_value": 2, "cli_flag": "--max-artifact-paths"},
  "refusal": {"kind": "adjustable_budget", "operation": "inspect_wasm_artifact", "control": "max_artifact_paths", "effective_value": 1, "unit": "count", "range": {"minimum": 1, "maximum": 4294967295}, "default_value": 16, "required_value": 2}
}

Validation

  • Domain: src/domain/analysisRefusal.test.ts covers both routes (continuing and invocation), the single route (invocation without a seed), the derived recovery (with and without required_value, both caller lifetimes), at-maximum and need-above-maximum branches, authored-recovery precedence, environment-control exclusion and the details.refusal projection.
  • Real CLI + stdio MCP: tests/boundary/cli/wasmAcquiredInputsCli.test.ts asserts details.limit.required_value, details.refusal and the flag/field spelling of the recovery on each adapter.
  • Updated: tests/boundary/filesystem/elfDebugLink.test.ts, tests/boundary/mcp/pcapWorkspaceAllocation.test.ts, tests/acceptance/pcapProducerLimitsCliMcp.test.ts (Linux-only; runs in CI).
  • Focused runs of ELF, PE, pcap, WASM, web bundle, JavaScript, Rust, Go, managed, il2cpp, kernel module, Flutter, Apple dispatch and CLI projection tests; oxfmt --check ., oxlint, architecture guards, fixed-ceilings, module boundaries, docs:check.
  • No real-provider behavior changed; the pcap acceptance path needs Linux prlimit and was not run locally.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-26T02:12:26.418745Z
We couldn’t complete this review. Comment @codex review to try again.
96609df PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@greptile-apps

greptile-apps Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · No new issue requiring changes was found in the reviewed code.RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] No new issue requiring changes was found in the reviewed code.

Summary

Adds required_value and typed refusal facts for per-call limits, then generates recovery text using the delivering adapter’s names.

  • Resource-limit refusals include typed facts and generated recovery.
  • CLI refusals name the command and option the caller can change.
  • Producers report the measured limit a refused request needs.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Producer reports limit facts] --> B[Typed refusal]
  B --> C[Project error]
  C --> D{Authored recovery?}
  D -->|Yes| E[Keep authored text]
  D -->|No| F[Generate recovery from facts]
  G[CLI command spelling or MCP default] --> F
  F --> H[Return recovery and refusal facts]
  E --> H
Loading

Reviews (5) · Last reviewed commit: "test: expect the typed refusal for Flutt..." · Reviewed by Greptile

Comment thread src/cli/projectCliAnalysisResult.ts Resolved
… recovery

A per-call parameter limit (`control_kind: "parameter"`) now carries an
optional `required_value`, and its refusal projects the typed
`adjustable_budget` under `details.refusal` with `control`, `default_value`
and `required_value`. The refusal owns the recovery: "Pass a larger
<parameter> on the next <operation> call (at least N; range a..b), then
retry", or a narrower request when the control is at or below the need's
maximum. The CLI renders the step with the command's flag and command.

ELF notes and debug-link, pcap producer limits, PE/native read budgets and
WASM artifact paths drop their duplicate authored recovery and report the
measured need where they compute it.

BREAKING CHANGE: per-call parameter refusals gain `details.refusal`, and
their `remediation.action` wording changes to the generated form.
…all limit

The adjustable_budget recovery is now rendered from its details.refusal
facts alone (which gain `source` for settings), so the CLI parses those facts
and re-renders the recovery with its flag and command instead of matching
display text; authored recovery is never rewritten. A per-call control backed
by a registered setting names both routes: the next call, then the setting
through update_analysis_settings, or its launch environment variable for a
one-invocation caller. Per-call-only controls keep one route.

inspect_wasm_artifact reports the larger of its oversized selection counts
as required_value, so one retry admits both fields.
…ter's spelling

Refusal recovery is rendered at projection in the spelling of the adapter
that delivers it: MCP names the contract field and tool; a CLI command binds
its own spelling (flag or JSON-option path, rea <command>, launch
environment route) around its run. Authored recovery never reaches the
renderer, so nothing distinguishes it by text. The CLI no longer re-parses
details.refusal or rewrites the generated sentence; the prefix-matching
rewrite and its fact schema are removed.
Per-call parameter limits now carry details.refusal; these tests landed on
main asserting its absence.
@morluto
morluto force-pushed the feat/per-call-limit-required-value branch from c7dd6e5 to 3324d6f Compare November 26, 2026 03:05
@morluto
morluto merged commit 78cb717 into main Nov 26, 2026
49 checks passed
@morluto
morluto deleted the feat/per-call-limit-required-value branch November 26, 2026 03:24
@morluto

morluto commented Nov 26, 2026

Copy link
Copy Markdown
Owner Author

@greptileai review

Comment thread src/resources/artifactReadBudget.ts Resolved
morluto added a commit that referenced this pull request Nov 26, 2026
…he native reader controls

With #14625 the refusal owns per-call recovery, so the devicetree, Windows shortcut, kernel build config, firmware staging and byte-entropy refusals drop their authored sentences. inspect_byte_entropy reports the smallest admitting block_size as required_value.
morluto added a commit that referenced this pull request Nov 26, 2026
…he remaining native controls

With #14625 the refusal owns per-call recovery, so the ELF dependency, ELF unwind, Apple IPS, DWARF, initializer, PE resource and BEAM refusals drop their authored sentences. BEAM reports the complete row and atom counts as required_value. The unwind per-page text allowance is a registered fixed allowance whose narrowing names a smaller limit, because a larger page would not admit it.
morluto added a commit that referenced this pull request Nov 26, 2026
…#14622)

* fix(native)!: report details.limit for native reader per-call budgets

Devicetree, Windows shortcut, kernel build config, firmware staging and
byte-entropy refusals of caller-selected budgets named their control only
in remediation prose. Each now sets details.limit from a domain-owned
budget object that also builds the schema (src/domain/parameterBudget.ts),
so the reported range is the one the next call accepts.

inspect_devicetree's fixed 32 MiB decoded representation allowance becomes
the per-call max_decoded_bytes (default 32 MiB, 1 KiB to 256 MiB); its
refusal reports boundary max_decoded_bytes instead of decoded_bytes.

The pwntools allocation failure declares measuredExhaustion, the firmware
inherited RLIMIT_FSIZE refusal declares measuredExhaustion, and the LLDB
combined-result ceiling is a registered representation bound.

Part of #14234 and #14235.

BREAKING CHANGE: inspect_devicetree's decoded-representation refusal reports
reported_limits.boundary "max_decoded_bytes" with details.limit, instead of
"decoded_bytes".

* fix(native): keep FIT decoded-budget boundary, LLDB narrowing and entropy length range exact

The FIT reader compared the renamed devicetree limit against decoded_bytes, so a decoded-budget refusal became capacity; it now checks max_decoded_bytes, with a test. The LLDB representation ceiling keeps a short name and carries its recovery as narrowing. The byte-entropy length maximum is the window the selected block_size admits.

* fix(cli): describe inspect-devicetree --max-decoded-bytes

* refactor(native): let the generated adjustable-budget recovery name the native reader controls

With #14625 the refusal owns per-call recovery, so the devicetree, Windows shortcut, kernel build config, firmware staging and byte-entropy refusals drop their authored sentences. inspect_byte_entropy reports the smallest admitting block_size as required_value.
morluto added a commit that referenced this pull request Nov 26, 2026
…he remaining native controls

With #14625 the refusal owns per-call recovery, so the ELF dependency, ELF unwind, Apple IPS, DWARF, initializer, PE resource and BEAM refusals drop their authored sentences. BEAM reports the complete row and atom counts as required_value. The unwind per-page text allowance is a registered fixed allowance whose narrowing names a smaller limit, because a larger page would not admit it.
morluto added a commit that referenced this pull request Nov 26, 2026
…s and make BEAM table rows adjustable (#14631)

* fix(native)!: report details.limit for native reader per-call budgets

Devicetree, Windows shortcut, kernel build config, firmware staging and
byte-entropy refusals of caller-selected budgets named their control only
in remediation prose. Each now sets details.limit from a domain-owned
budget object that also builds the schema (src/domain/parameterBudget.ts),
so the reported range is the one the next call accepts.

inspect_devicetree's fixed 32 MiB decoded representation allowance becomes
the per-call max_decoded_bytes (default 32 MiB, 1 KiB to 256 MiB); its
refusal reports boundary max_decoded_bytes instead of decoded_bytes.

The pwntools allocation failure declares measuredExhaustion, the firmware
inherited RLIMIT_FSIZE refusal declares measuredExhaustion, and the LLDB
combined-result ceiling is a registered representation bound.

Part of #14234 and #14235.

BREAKING CHANGE: inspect_devicetree's decoded-representation refusal reports
reported_limits.boundary "max_decoded_bytes" with details.limit, instead of
"decoded_bytes".

* fix(native): keep FIT decoded-budget boundary, LLDB narrowing and entropy length range exact

The FIT reader compared the renamed devicetree limit against decoded_bytes, so a decoded-budget refusal became capacity; it now checks max_decoded_bytes, with a test. The LLDB representation ceiling keeps a short name and carries its recovery as narrowing. The byte-entropy length maximum is the window the selected block_size admits.

* fix(cli): describe inspect-devicetree --max-decoded-bytes

* refactor(native): let the generated adjustable-budget recovery name the native reader controls

With #14625 the refusal owns per-call recovery, so the devicetree, Windows shortcut, kernel build config, firmware staging and byte-entropy refusals drop their authored sentences. inspect_byte_entropy reports the smallest admitting block_size as required_value.

* fix(native)!: report details.limit for remaining native reader budgets and make BEAM table rows adjustable

inspect_elf_dependencies, inspect_elf_unwind_ranges, inspect_apple_ips,
inspect_dwarf_units, inspect_native_initializers and inspect_pe_resources
named their per-call budgets only in remediation prose. Each now reports
details.limit from a domain-owned budget object that also builds the
schema. The unwind per-page symbol-name text refusal names the page size
`limit`, the control that admits it.

The fixed 65,536-row BEAM table ceiling becomes the per-call
max_table_rows (default 65,536, at most 1,048,576).

The plist nesting allowance is reclassified as a representation bound
(MAX_JSON_DEPTH less the report envelope). GPU and APK input refusals that
named their fixed allowances only in prose now declare them, registered
as pending #14235.

Part of #14234 and #14235.

BREAKING CHANGE: a BEAM table-row refusal reports details.limit for
max_table_rows instead of a fixed_ceiling refusal.

* fix(native): keep naming the dependency and BEAM row controls in recovery

* refactor(native): let the generated adjustable-budget recovery name the remaining native controls

With #14625 the refusal owns per-call recovery, so the ELF dependency, ELF unwind, Apple IPS, DWARF, initializer, PE resource and BEAM refusals drop their authored sentences. BEAM reports the complete row and atom counts as required_value. The unwind per-page text allowance is a registered fixed allowance whose narrowing names a smaller limit, because a larger page would not admit it.

* style: format the PE resources provider test

* refactor(native): keep one owner of the IPS budget bounds and document the unwind text allowance
@morluto morluto added the area: domain Domain logic, errors, and pure functions label Nov 26, 2026
@morluto morluto added the enhancement New feature or request label Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant