Skip to content

fix(limits): report details.limit for pyc budget refusals - #14386

Merged
vincentkoc merged 2 commits into
morluto:mainfrom
trism-prism:fix/owned-budget-refusal-limits
Nov 30, 2026
Merged

vincentkoc merged 2 commits into
morluto:mainfrom
trism-prism:fix/owned-budget-refusal-limits

Conversation

@trism-prism

@trism-prism trism-prism commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Rebased onto main and trimmed to the pyc part only. The devicetree and NuGet parts of the original PR landed through #14622 and #14629.

Summary

Refusals of the per-call budgets on inspect_python_pyc carried their recovery only in remediationAction prose. A caller had to parse text to learn which parameter to raise and how far. They now carry a structured details.limit (control_kind: "parameter", parameter, effective_value, unit, minimum, maximum, default_value, applies_at: "next_call"), the same shape inspect_elf_notes reports.

Refs #14234

Problem and expected behavior

Smallest trigger: inspect_python_pyc with max_objects: 1. The refusal is resource_constraint, but details has no limit; the only recovery is remediationAction taken from the parser's detail string.

Expected: the refusal names the parameter, its effective value, default and accepted range, so the next call can be built from details.limit alone.

Change and scope

  • The pyc domain module now has one bounds object (PYTHON_PYC_READ_BUDGETS) that feeds both the Zod schema and a pythonPycBudgetLimit() builder for AnalysisParameterLimit. Prose stays as explanation.
  • pyc: a parser limit owned by exactly one control reports limit. nested_code_steps and nested_code_references depend on max_objects and max_depth together, so they report related_parameters instead of a single range. The prose no longer embeds CLI --flag spellings; the CLI adds cli_flag itself.
  • The superseded PYTHON_PYC_LIMIT_MAXIMA table is removed; the bounds object replaces it.
  • docs/reference/limits-and-recovery.md lists inspect_python_pyc.
  • Resource kinds (capacity/memory/file-size) and advertised input schemas are unchanged. Not touched: ELF/kernel, PE, pcap, entropy, devicetree, NuGet owners (other PRs).
  • Related: fix(limits): report details.limit for KernelModuleProvider refusals #14306 (ELF/kernel owners of [Bug] Refusals of adjustable per-call budgets name their control only in prose, without details.limit #14234) is open and also edits scripts/verify/fixed-ceiling-registry.json, scripts/verify/untyped-budget-refusal-baseline.json and docs/reference/limits-and-recovery.md; whichever lands second needs a small merge in those files.

Contract and boundary impact

  • Semantic owner and earliest changed stage: each domain module owns its budget bounds; providers build the refusal from them.
  • Contribution scope fit and linked maintainer decision: not applicable; ordinary fix within existing boundaries.
  • CLI and MCP/tool-catalog contract: additive details.limit / details.related_parameters on pyc refusals; remediation.action for pyc no longer contains --flag text. Input schemas identical.
  • Provider, bridge, target-format, or platform compatibility: not applicable.
  • Evidence, artifact, provenance, or reconstruction contract: the projected refusal (which Evidence retains) gains the additive details.limit / details.related_parameters fields; no identity, provenance or result change.
  • Target selection, authority, upstream behavior, and cleanup details: not applicable.
  • Generated metadata, package, or installation impact: none.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

State: executed evidence unless marked source-derived.

  • Tests added or updated:
    • tests/boundary/filesystem/pythonPyc.test.ts: details.limit for the four pyc budgets; remediation contains no -- flag spelling.
    • tests/boundary/filesystem/pythonPycNestedLimit.test.ts (new): nested_code_steps and nested_code_references report details.related_parameters: ["max_objects", "max_depth"] and no details.limit, with the parser mocked to raise them (see gaps).
    • tests/acceptance/pythonPycCli.test.ts: a new test that the CLI adds cli_flag: "--max-objects" to details.limit; the existing --max-depth / --max-file-bytes refusal test now expects field-only remediation and details.limit.cli_flag.
  • Base reproduction: with the two changed src files restored to the base revision (tests and docs kept), every new pyc boundary assertion failed (details.limit / related_parameters absent): 2 of 2 nested-limit tests, 1 of 2 in pythonPyc.test.ts; the other pyc assertion passed at base.
  • User-visible CLI/MCP output (if applicable): inspect_python_pyc with max_objects: 1 returns a limit shape for max_objects (default 16384), with remediation "Raise max_objects above 1, up to 65536, on the next call. …" and no --flag text. On the CLI (inspect-python-pyc --max-objects 1 --json), details.limit also carries "cli_flag": "--max-objects", asserted by the acceptance test in CI; not captured locally (no build on this host).
  • Remaining proof gaps:
    • pyc nested-code limits are reached only through a mocked parser. Source-derived reason: the nested walk skips visited containers and reuses cached child lists, and both budgets are max_objects * max_depth, so max_objects or max_depth refuses first for any real marshal stream tried; the test covers the provider's classification and projection, not the parser's accounting.
    • cli_flag is exercised in CLI tests only for pyc.
    • CI ran on Linux. The Windows capability lane was path-filtered out; these readers have no platform-specific code. Boundary tests also ran locally on Windows 11.
    • Author host limits (no effect on the change itself): the full npm run typecheck ran out of memory once on this host (Windows commit-memory exhaustion); the Windows native build needs the x86_64-w64-mingw32-g++ cross compiler, which is not installed, so local CLI acceptance runs were not possible; local Node was 24.19.0 against the pinned 24.22.1. CI covers this change.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

Rebase validation (Linux, Node 24.22.1, rebased head 7bff6bb41):

  • npx vitest run on the pyc boundary tests (tests/boundary/filesystem/pythonPyc.test.ts, tests/boundary/filesystem/pythonPycNestedLimit.test.ts) — 4 passed.
  • node scripts/run-typescript.mjs --noEmit --checkers 1 -p tsconfig.build.json (GOMEMLIMIT=3000MiB) — exit 0.
  • npx oxfmt --check on the changed files — clean.
  • The CLI acceptance tests were not run locally after the rebase: they need the compiled runtime (npm run build:cached), which is not built on this host, so the shared CLI process exits before the tests run. They passed in fork CI before the rebase (pythonPycCli.test.ts: 16 passed at 81634e2, run); upstream CI on the rebased head is awaiting maintainer workflow approval (action_required).
  • Pre-rebase validation of the same pyc change was done on Windows 11, Node 24.19.0: oxfmt --check clean, lint 0 errors, lint:typed 0 errors, verify:module-boundaries passed, verify:test-discovery passed, knip:production passed, check:fast passed for each pushed commit.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. details.limit is additive; pyc remediation prose no longer includes --flag spellings.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable; these are offline file parsers, no provider involved.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none; parsing limits only.

Author readiness

Human owner: @trism-prism

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Author checklist (completed by the PR author before requesting review)

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.
  • I ran every test, build, or measurement needed to validate this change, reported a browser, GPU, or environment gap only when that runtime or hardware is unavailable, and reported the checks I ran and their results without presenting inferred correctness or speedups as measured.
  • Comments explain constraints or non-obvious decisions; task history and conversations stay out of code and docs.
  • Documentation is concise and factual, without punchy slogans or promotional language.
  • This change fixes the root cause and follows the engineering rules in AGENTS.md.
  • Formatted input is interpreted once at the owning boundary, and consumers use the owner's parsed facts. See Interpret boundary facts once.
  • Combined failures preserve partial observations, remaining resources, and cleanup facts. See Own the lifecycle.
  • A hardcoded limit is an REA_ runtime setting with a default, floor, and maximum, unless a fixed ceiling has a stated reason. See Adding a runtime setting.

@greptile-apps

greptile-apps Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable defects were found.

Summary

Adds structured recovery details to budget refusals from inspect_devicetree, inspect_nuget_nupkg, and inspect_python_pyc.

  • Devicetree refusals identify the budget or fixed ceiling that stopped inspection.
  • NuGet refusals identify the package budget that stopped inspection.
  • Python bytecode refusals name the budget or budgets that stopped inspection.

Review was source-based; no tests were run. Whether another PR supersedes this one could not be checked because GitHub access required authentication.

Acknowledged by trism-prism: the fixed devicetree allowance remains deferred under issue 14236; nested Python limits have mocked coverage because ordinary object or depth limits refuse first; local CLI capture was unavailable, with acceptance coverage reported in CI.

Reviews (1) · Last reviewed commit: "Merge remote-tracking branch 'upstream/m..." · Reviewed by Greptile

@trism-prism
trism-prism marked this pull request as ready for review November 24, 2026 18:23
Copilot AI adaptive review requested due to automatic review settings November 24, 2026 18:23
@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-24T18:23:18.328041Z
We couldn’t complete this review. Comment @codex review to try again.
13b87c9 Draft marked ready
ℹ️ 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

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@morluto morluto added area: domain Domain logic, errors, and pure functions bug Something isn't working labels Nov 26, 2026
@N0zoM1z0

Copy link
Copy Markdown
Collaborator

Thanks for this. Two of its three parts have since landed on main through other PRs, so merging main now conflicts in 10 files:

Could you rebase onto main and keep only the pyc part, with its untyped-budget-refusal-baseline.json, fixed-ceiling registry and limits-and-recovery.md entries? The required CI runs for this branch are waiting for approval, and I'll approve them on the rebased head.

Rebased onto main; the devicetree and NuGet parts were dropped here (landed via morluto#14622 and morluto#14629). This commit now carries only the pyc part.

Refusals of the per-call budgets on inspect_devicetree, inspect_nuget_nupkg
and inspect_python_pyc carried recovery only in remediation prose. Each
owner now keeps one bounds object that feeds both its input schema and a
structured details.limit (parameter, effective value, unit, range, default).

A pyc limit that depends on max_objects and max_depth together reports
related_parameters instead of a single range. The fixed decoded devicetree
allowance is reported as a fixed ceiling and registered as pending.

Refs morluto#14234
@trism-prism trism-prism changed the title fix(limits): report details.limit for devicetree, NuGet, and pyc budget refusals fix(limits): report details.limit for pyc budget refusals Nov 28, 2026
@trism-prism
trism-prism force-pushed the fix/owned-budget-refusal-limits branch from 13b87c9 to 7bff6bb Compare November 28, 2026 00:40
Copilot AI adaptive review requested due to automatic review settings November 28, 2026 00:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@trism-prism

Copy link
Copy Markdown
Contributor Author

@N0zoM1z0 Rebased onto main and trimmed to the pyc part only. The devicetree and NuGet changes are out, since they landed in #14622 and #14629. The diff is now just the pyc budgets, its tests, and the limits-and-recovery.md entry. The CI runs should be ready for your approval whenever you have a moment.

@vincentkoc
vincentkoc merged commit 52b3358 into morluto:main Nov 30, 2026
39 checks passed
@vincentkoc

Copy link
Copy Markdown
Collaborator

Thanks — merged after clean review and CI. The pyc refusal now reports the exact budget and accepted range, with CLI and MCP coverage passing on this head.

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 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants