Skip to content

test(firmware): pin the staging ceiling at the request boundary - #7775

Merged
morluto merged 4 commits into
morluto:mainfrom
XiaoBinGan:fix/firmware-staging-ceiling-wiring
Oct 29, 2026
Merged

morluto merged 4 commits into
morluto:mainfrom
XiaoBinGan:fix/firmware-staging-ceiling-wiring

Conversation

@XiaoBinGan

Copy link
Copy Markdown
Contributor

Summary

baron asked for this follow-up on #6971: exercise the staging budget ceiling through the wiring that analyze_artifact and inspect_artifact actually use, rather than through the service function directly.

Problem and expected behavior

#6971 stopped the firmware guidance from recommending a raise once the staging budget ceiling is already reached, but the existing coverage called the service helper in isolation. The boundary that decides whether a raise is even reachable — the stagingBudget ceiling resolved from the request and forwarded into the firmware analysis options — had no regression.

A behaviour that is only correct when called directly can regress at the wiring layer without any test noticing.

Change and scope

One new boundary test, tests/boundary/firmware/firmwareStagingBudgetWiring.test.ts. It drives the same entry point the tools use with a request whose staging budget is at the ceiling, and asserts the emitted guidance does not recommend a raise. No production code changes.

Contract and boundary impact

  • Semantic owner and earliest changed stage: firmware staging budget resolution at the request boundary.
  • CLI and MCP/tool-catalog contract: no tool, schema, or catalog change; the test pins the existing guidance text.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Generated metadata, package, or installation impact: none; tsc --noEmit and oxfmt --check pass.

Expected effects:

  • Read existing files or captured data.
  • Documentation or usability only; no target interaction.

Evidence and regression coverage

  • Test: tests/boundary/firmware/firmwareStagingBudgetWiring.test.ts — 2 passed. It fails if the ceiling is not forwarded into the analysis options, because the guidance then recommends a raise the caller cannot perform.
  • Follow-up to fix(firmware): stop recommending a raise at the staging budget ceiling #6971, which landed the behaviour; this pins the boundary that decides whether the ceiling applies at all.
  • Remaining gap: the test asserts the guidance text, not a numeric ceiling computation.

Validation performed

  • npx vitest run tests/boundary/firmware/firmwareStagingBudgetWiring.test.ts — 2 passed
  • npx tsc --noEmit -p . — exit 0
  • npx oxfmt --check tests/boundary/firmware/firmwareStagingBudgetWiring.test.ts — exit 0

Compatibility, safety, and release

No breaking change; test-only.

Author readiness

Human owner: @XiaoBinGan

  • 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.

Before merge

  • 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.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

The ceiling recovery added in morluto#6971 was covered through the wording helper only, so a wiring change that passed the schema ceiling where the selected value belongs, or that dropped the remediation, would have stayed green.

Adds boundary coverage that calls inventoryFirmwareOutput itself: a sparse file reaches the real byte ceiling without storing the bytes and asserts the projected refusal carries the ceiling recovery, and a one-byte tree below the ceiling asserts the raise advice. Verified red on both regressions — passing the schema ceiling for the selected value fails the below-ceiling case, and restoring the single-form remediation fails both.
The wiring test matched three phrases of the emitted remediation, so an ad-hoc or truncated action that kept those phrases would still pass while the emitted recovery had diverged from firmwareStagingBudgetRemediation.

Assert exact equality with the owner's output for the selected value in both cases instead. Verified red: replacing the emitted action with a divergent sentence that keeps the ceiling phrases now fails both cases, where the phrase matching passed.
@XiaoBinGan XiaoBinGan changed the title test(firmware):-pin-the-staging-ceiling-at-the-request-boundary test(firmware): pin the staging ceiling at the request boundary Oct 28, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T16:09:44.947626Z 593bae8 New commits
ℹ️ 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.

@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The test-only changes appear safe to merge; the remaining coverage gap is non-blocking.

Findings

  1. P2 Request forwarding stays untested ▶
Fix with agent prompt
### Issue 1
tests/boundary/firmware/firmwareStagingBudgetWiring.test.ts:36-41
The test passes the ceiling directly to `inventoryFirmwareOutput`, so it never checks whether a request's `max_output_bytes` survives parsing and reaches that call. If `FirmwareProvider` forwarded the default instead of the caller's ceiling, both new tests would still pass.

Add a case through `FirmwareAnalysisService.execute` and the real provider path, then check the reported limit and projected guidance. That would cover the request wiring this PR promises.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Adds request-level coverage for firmware staging budgets.

  • Firmware budget tests check which limits reach the provider.
  • Firmware budget tests check the recovery at and below the byte ceiling.

Reviews (2) · Last reviewed commit: "test(firmware): drive the staging ceilin..." · Reviewed by Greptile

Comment on lines +36 to +41
const rejected = await inventoryFirmwareOutput(
root,
MAX_FIRMWARE_STAGING_BYTES,
MAX_FIRMWARE_STAGING_ENTRIES,
"extract_firmware",
).catch((cause: unknown) => cause);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Request forwarding stays untested

The test passes the ceiling directly to inventoryFirmwareOutput, so it never checks whether a request's max_output_bytes survives parsing and reaches that call. If FirmwareProvider forwarded the default instead of the caller's ceiling, both new tests would still pass.

Add a case through FirmwareAnalysisService.execute and the real provider path, then check the reported limit and projected guidance. That would cover the request wiring this PR promises.

Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/boundary/firmware/firmwareStagingBudgetWiring.test.ts
Line: 36-41

Comment:
**Request forwarding stays untested**

The test passes the ceiling directly to `inventoryFirmwareOutput`, so it never checks whether a request's `max_output_bytes` survives parsing and reaches that call. If `FirmwareProvider` forwarded the default instead of the caller's ceiling, both new tests would still pass.

Add a case through `FirmwareAnalysisService.execute` and the real provider path, then check the reported limit and projected guidance. That would cover the request wiring this PR promises.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e4e6ea9678

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +36 to +40
const rejected = await inventoryFirmwareOutput(
root,
MAX_FIRMWARE_STAGING_BYTES,
MAX_FIRMWARE_STAGING_ENTRIES,
"extract_firmware",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Drive the ceiling test through request wiring

If request parsing or provider wiring regresses to drop or replace max_output_bytes, this test still passes because it bypasses FirmwareAnalysisService.execute and FirmwareProvider.execute and supplies MAX_FIRMWARE_STAGING_BYTES directly to the inventory helper; the actual forwarding occurs in src/firmware/FirmwareProvider.ts:521-525. This therefore repeats producer coverage rather than protecting the request boundary, so drive the service/provider with an extract_firmware request at the ceiling and assert the projected refusal.

AGENTS.md reference: AGENTS.md:L86-L86

Useful? React with 👍 / 👎.

greptile and codex both flagged that the ceiling tests called
inventoryFirmwareOutput directly, so they would still pass if request parsing or
the provider wiring dropped or replaced max_output_bytes.

Add a request-level test that records the parsed request a provider receives:
the caller's max_output_bytes arrives unchanged at the schema ceiling and below
it, the documented default applies when omitted, and a budget above the schema
maximum is rejected before the provider runs. That is the wiring the previous
tests assumed rather than asserted.
@XiaoBinGan

Copy link
Copy Markdown
Contributor Author

Addressed in 593bae80f.

Both bots were right that the two existing tests called inventoryFirmwareOutput directly, so they would still pass if request parsing or the provider wiring dropped or replaced max_output_bytes.

The new file tests/boundary/firmware/firmwareStagingBudgetRequest.test.ts drives FirmwareAnalysisService.execute and asserts the parsed request a provider actually receives:

  • max_output_bytes at MAX_FIRMWARE_STAGING_BYTES arrives unchanged;
  • a budget below the ceiling (1) arrives unchanged, so the default is not substituted;
  • omitting it applies the documented 256 MiB default;
  • a budget above the schema maximum is rejected before the provider runs.

The provider records and rejects on arrival, so no execution record has to be fabricated — the request it received is the whole assertion. The original firmwareStagingBudgetWiring tests stay, since they cover the refusal and remediation text at the ceiling rather than the forwarding.

tests/boundary/firmware is 34 passed | 43 skipped; tsc --noEmit and oxfmt --check are clean.

@morluto
morluto merged commit 4671947 into morluto:main Oct 29, 2026
41 checks passed
@morluto morluto added the area: tests Test suite and verification label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: tests Test suite and verification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants