Repository navigation
fix(limits): report details.limit for KernelModuleProvider refusals - #14306
Conversation
…nel reader refusals Attach structured `details.limit` metadata to per-call budget refusals across the remaining `src/native/elf/` providers (`ElfDependenciesProvider`, `KernelModuleProvider`, `KernelBuildConfigProvider`, and `ElfUnwindRangesProvider`), following the `morluto#14243` shared-budget pattern: - Generalize `elfReadBudgetLimit` in `src/domain/native/elfReadBudgets.ts` so ELF and kernel readers share one parameter-limit builder. - Export `ELF_DEPENDENCIES_READ_BUDGETS`, `KERNEL_MODULE_READ_BUDGETS`, `KERNEL_BUILD_CONFIG_READ_BUDGETS`, and `ELF_UNWIND_RANGES_READ_BUDGETS` from their domain schemas so Zod input bounds and projected `details.limit` metadata have a single owner. - Report `details.limit` for caller-selected file, entry, inflation, and record budgets, including `compressed_candidate_bytes` (`max_config_bytes`), while moving `KernelBuildConfigProvider` file-size handling onto `offlineArtifactFailureDialect.fileSize` and removing its unreachable `capacity` branch. - Report `ElfUnwindRangesProvider`'s fixed 16 MiB `symbol_name_text_bytes` allowance through `fixedAllowanceOptions` with narrowing guidance and `related: { parameters: ["limit", "offset"] }`, registered in `scripts/verify/fixed-ceiling-registry.json` under `morluto#14235`, rather than reporting an inverted `details.limit`. - Remove `ElfDependenciesProvider.ts`, `ElfUnwindRangesProvider.ts`, and `KernelBuildConfigProvider.ts` from `scripts/verify/untyped-budget-refusal-baseline.json`, clearing all `src/native/elf/` entries from the baseline, and update `docs/reference/rea-limit-inventory.md` and `docs/reference/limits-and-recovery.md`. Part of morluto#14234
[Medium impact] The PR appears safe to merge; no actionable issue was found. SummaryAdds structured
The previous-review merge bases differ, so the full PR diff was reviewed. Reviews (6) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile |
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
@Plastic-time thanks for the PR — this branch has merge conflicts with |
…udget-limits # Conflicts: # scripts/verify/untyped-budget-refusal-baseline.json # src/domain/native/elfUnwindRanges.ts
|
Merged
|
…udget-limits # Conflicts: # src/native/elf/KernelBuildConfigProvider.ts
|
|
…udget-limits # Conflicts: # docs/reference/limits-and-recovery.md
gensokyo-dev
left a comment
There was a problem hiding this comment.
On main e15d64e the three new kernel-module refusal tests fail because inspect_kernel_module budget refusals carry no details.limit. Merged onto current main, the CLI, MCP, boundary and domain kernel-module tests pass (15/15), along with docs:check, the fixed-ceilings guard, tsc, oxlint and oxfmt. The limit uses the same elfReadBudgetLimit owner as the other ELF note readers, and the schema bounds are unchanged.
Summary
Part of #14234.
Attach structured
details.limitmetadata to caller-adjustable budget refusals inKernelModuleProvider(inspect_kernel_module:max_file_bytesandmax_entries).This PR originally covered four providers under
src/native/elf/. While this PR awaited review, #14631 (1badb6a8a) landeddetails.limit(andfixed_ceilingfor unwind symbol-name text) onmainforElfDependenciesProvider,ElfUnwindRangesProvider, andKernelBuildConfigProvider. After mergingmain, this PR is narrowed to the remainingKernelModuleProviderfix, its tests, and its rows indocs/reference/limits-and-recovery.mdanddocs/reference/rea-limit-inventory.md. No separate sub-issue was opened because #14234 already tracks this migration.Problem and expected behavior
Before this change, when a caller hit
max_file_bytesormax_entriesininspect_kernel_module(for example--max-file-bytes 64or--max-entries 1),KernelModuleProviderreturnedAnalysisResourceConstraintErrorwith only hand-writtenremediationActionprose naming raw field names (max_file_bytes/max_entries) and omitteddetails.limit.Callers and adapters could not read the controlling parameter name, effective value, unit, schema bounds (
minimum,maximum,default_value),applies_at: "next_call", or the CLI adapter's projectedcli_flag(--max-file-bytes,--max-entries) without parsing prose.Expected behavior:
max_file_bytesandmax_entriesrefusals inKernelModuleProviderattachlimit: elfReadBudgetLimit(KERNEL_MODULE_READ_BUDGETS, ...)backed by the same domain bounds thatinspectKernelModuleInputSchemaenforces, and drop the hand-writtenremediationActionso CLI and MCP adapters render adapter-aware recovery text (--max-file-bytes/--max-entrieson CLI,max_file_bytes/max_entrieson MCP). Existingmax_structure_bytesandmemoryfixed-allowance refusals keep their current behavior unchanged.Change and scope
src/domain/native/kernelModule.ts): ExportedKERNEL_MODULE_READ_BUDGETS: ElfReadBudgetsreusingMINIMUM_ELF_READ_FILE_BYTESandDEFAULT_ELF_READ_FILE_BYTES, and wiredinspectKernelModuleInputSchema'smax_file_bytesandmax_entries.min()/.max()/.default()from it.src/native/elf/KernelModuleProvider.ts): Attachedlimit: elfReadBudgetLimit(KERNEL_MODULE_READ_BUDGETS, ...)forfile-size(max_file_bytes, forwarding safe-integerfailure.observedBytesasrequired_value) andcapacity(max_entries)ArtifactReaderFailure("limit")refusals, and removed the superseded hand-writteninputBudgetRemediationhelper.inspect_kernel_moduletodocs/reference/limits-and-recovery.mdand added itsmax_file_bytesandmax_entriesrows todocs/reference/rea-limit-inventory.md.tests/boundary/filesystem/kernelModule.test.ts: Asserts projecteddetails.limit(includingrequired_valueformax_file_bytes: 64) andmax_entries: 1(and verifiesmax_entries: 16succeeds).tests/acceptance/kernelModuleCli.test.ts: Asserts public CLI--jsonrefusal payloads for--max-file-bytes 64(includingrequired_valueandat least <bytes>) and--max-entries 1, checkingdetails.limit(includingcli_flag), adapter-rendered CLI flag guidance inremediation.action, and successful recovery after raising both flags.tests/boundary/mcp/kernelModuleMcp.test.ts: Asserts public MCP refusal payloads formax_file_bytes: 64(withrequired_value) andmax_entries: 1, confirming nocli_flagleakage and contract field names inremediation.action, followed by successful recovery on the same connection.ElfDependenciesProvider,ElfUnwindRangesProvider, andKernelBuildConfigProvider(already migrated onmainvia fix(native)!: report details.limit for remaining native reader budgets and make BEAM table rows adjustable #14631 /1badb6a8a), and remaining non-kernel-module files inscripts/verify/untyped-budget-refusal-baseline.jsontracked under [Bug] Refusals of adjustable per-call budgets name their control only in prose, without details.limit #14234.Follow the contribution scope.
Not applicable: this is an ordinary error-metadata fix within existing read-only offline kernel-module inspection boundaries.
Contract and boundary impact
src/domain/native/kernelModule.tsownsKERNEL_MODULE_READ_BUDGETS; bothinspectKernelModuleInputSchemaandKernelModuleProviderread bounds from that single constant. Downstream error projection (projectAnalysisError) and CLI/MCP adapters consumedetails.limitdirectly.details.limit(and structureddetails.refusal) onresource_constraintpayloads forinspect_kernel_modulewhenmax_file_bytesormax_entriesis exceeded. Input schemas and numeric bounds are unchanged. CLI output automatically includesdetails.limit.cli_flagand renders--max-file-bytes/--max-entriesinremediation.action.reported_limits,partial_observation(file-snapshot-hash), andmax_structure_bytes/memoryfixed-allowance fields remain preserved.withStableArtifactHandle; unchanged lifecycle and cleanup.docs/public/product-catalog.json), package, or installation impact: No schema descriptions, bounds, or catalog entries changed; verified vianpm run build:cachedandnpm run docs:check.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
Evidence and regression coverage
tests/boundary/filesystem/kernelModule.test.ts: assertsdetails.limitformax_file_bytes: 64(includingrequired_value) andmax_entries: 1(and verifiesmax_entries: 16succeeds).tests/acceptance/kernelModuleCli.test.ts: runsrea inspect-kernel-module <path> --max-file-bytes 64 --jsonand--max-entries 1 --jsonthrough the public CLI, assertsdetails.limit(withcli_flagandrequired_value) and CLI flag guidance inremediation.action, and verifies recovery after raising both budgets.tests/boundary/mcp/kernelModuleMcp.test.ts: runsinspect_kernel_modulethrough MCP withmax_file_bytes: 64andmax_entries: 1, assertsdetails.limit(withrequired_valueand nocli_flag) and field-name guidance inremediation.action, and verifies recovery on the same connection.origin/main55c7eaa06with only the 3 updated test files applied and no production fix):npx vitest run tests/boundary/filesystem/kernelModule.test.ts -t "names max_structure_bytes|retains trailer fields|reads module metadata|returns typed resource and cancellation failures"— 1 failed | 3 passed | 1 skipped (5):returns typed resource and cancellation failuresfailed becauseprojectAnalysisError(tooSmall.error).detailsomittedlimit(the 1 skipped test is the pre-existing unprivileged Windows symlinkEPERMtest).npm run test:focused -- tests/acceptance/kernelModuleCli.test.ts tests/boundary/mcp/kernelModuleMcp.test.ts— 2 failed | 6 passed (8):tests/acceptance/kernelModuleCli.test.ts(reports structured details.limit and CLI flags for max-file-bytes and max-entries refusals) failed becausedetails.limitwas absent andremediation.actionemitted the legacy hand-written string ("Raise max_file_bytes above 64 bytes or select a smaller artifact; the limit is the caller-selected input read budget.") without--max-file-bytes.tests/boundary/mcp/kernelModuleMcp.test.ts(reports structured details.limit without CLI flags for max_file_bytes and max_entries refusals and recovers) failed becausefileRefusal.details.limitwasundefined.rea inspect-kernel-module <path> --max-file-bytes 64 --json(958-byte fixture):{ "category": "resource_constraint", "code": "resource_constraint", "message": "Selected artifact exceeds 64 bytes: <path>", "retryable": false, "remediation": { "action": "inspect_kernel_module reached its max_file_bytes budget of 64 bytes. Pass a larger --max-file-bytes on the next rea inspect-kernel-module run (at least 958 bytes; range 64..536870912 bytes), then retry." }, "details": { "operation": "inspect_kernel_module", "resource": "file-size", "reason": "Selected artifact exceeds 64 bytes: <path>", "reported_limits": { "max_file_bytes": 64, "max_entries": 8192 }, "limit": { "control_kind": "parameter", "parameter": "max_file_bytes", "effective_value": 64, "unit": "bytes", "minimum": 64, "maximum": 536870912, "default_value": 67108864, "applies_at": "next_call", "required_value": 958, "cli_flag": "--max-file-bytes" }, "refusal": { "kind": "adjustable_budget", "operation": "inspect_kernel_module", "control": "max_file_bytes", "effective_value": 64, "unit": "bytes", "default_value": 67108864, "required_value": 958, "range": { "minimum": 64, "maximum": 536870912 } } } }tests/boundary/filesystem/kernelModule.test.tscontains one pre-existing non-file symlink test (it("reports non-file and missing selections as caller input errors")) that fails withEPERM: operation not permitted, symlinkon unprivileged Windows; that test was skipped via-tlocally and relies on POSIX CI coverage.Boundary regressions covered: oversized-input (
max_file_bytes) and entry-capacity (max_entries) refusal boundaries oninspect_kernel_modulevia both filesystem boundary and public CLI acceptance tests, plus guard verification (tests/evaluation/fixedCeilingGuard.test.ts). Lifecycle regressions are unaffected (artifact handle lifetime and cleanup paths were not modified).For evidence-bearing changes:
Validation performed
Environment: Windows 11 x64, Node.js v24.22.1, head
4dec3c11a, merged withorigin/main(55c7eaa06; verified zero conflicts against latestorigin/main).npm run test:focused -- src/domain/native/kernelModule.test.ts src/application/binaryDiagnostics/KernelModuleService.test.ts src/native/elf/KernelModuleParser.test.ts tests/acceptance/kernelModuleCli.test.ts tests/boundary/mcp/kernelModuleMcp.test.ts tests/evaluation/fixedCeilingGuard.test.ts— 6 files passed, 48 tests passednpx vitest run tests/boundary/filesystem/kernelModule.test.ts -t "names max_structure_bytes|retains trailer fields|reads module metadata|returns typed resource and cancellation failures"— 1 file passed, 4 passed | 1 skipped (Windows symlinkEPERMtest skipped)npm run check:fast— passed (typecheck,lintincludingfixed-ceilings.mjsandrea-numeric-limits.mjs,verify:architecture-guardsacross 3,167 source files)npm run docs:check(run on74f04dd6c; docs unchanged in4dec3c11a) — passed (6/6 tasks +tests/conformance/readmeConsistency.test.ts8/8 passed)Compatibility, safety, and release
details.limitand structureddetails.refusalare additive; existingcode,reported_limits,partial_observation, and schema bounds are preserved.tests/boundary/filesystem/kernelModule.test.tsrequires privileged symlink creation or POSIX CI.Author readiness
Human owner: @Plastic-time
Author checklist (completed by the PR author before requesting review)
type(scope): outcome.REA_runtime setting with a default, floor, and maximum, unless a fixed ceiling has a stated reason. See Adding a runtime setting.