Skip to content

workflows: handoff can exceed maxTotalBytes via mandatory headers (unvalidated impossible config) #117

Closed

Description

@tt-a1i

Description

Verified by read-only audit (seal/gpt-5.6-sol subagent, verdict: CONFIRMED — real component-contract defect, low production impact).

Mechanism

  • Minimum maxTotalBytes is 256 bytes (handoff.ts:14-27, 108-113); defaults are 64 refs / 16 KiB each / 48 KiB total (handoff.ts:5-7).
  • payloadCap = Math.max(0, maxTotalBytes - fixedBytes) (handoff.ts:193) — negative remaining capacity collapses to zero, but every result still emits a full header and projected body (handoff.ts:205-222).
  • Worse, projectText(..., { maxBytes: 0 }) still emits projection text rather than zero bytes (extensions/shared/text-projection.ts:31-55).

Quantified worst case

64 production-shaped refs: prefix 163 B + 64 headers 6,199 B = 6,362 B fixed. With maxTotalBytes: 256, headers alone exceed the cap by 6,106 B. Since maxRefs has no upper ceiling and artifact paths allow arbitrarily many digits (handoff.ts:143-146), the configurable worst case is not meaningfully bounded.

Production impact

Low: production constructs the registry with defaults only (index.ts:1191), and the 48 KiB default leaves ~42.8 KiB after normal 64-ref overhead. The 256-byte value is not exposed through setup config. But neither validation nor rendering rejects impossible configurations — a genuine contract violation, not acceptable-by-design.

Suggested fix

  • Validate at construction that configured total capacity can hold the mandatory metadata (prefix + per-ref headers) for the configured maxRefs, or reject/refuse configs that cannot.
  • Budget/truncate prefix and section headers within the same UTF-8 byte budget.
  • Note projectText(..., { maxBytes: 0 }) emitting non-zero text.

Test coverage gap

handoff.test.ts:224-267 covers 4 and 64 refs only at the 48 KiB default — no test of minimum maxTotalBytes with multiple refs (assert final UTF-8 byte length).

Found by automated workflow audit (run wf_56028a5b018b).

Activity

  1. added a commit that references this issue on Aug 25, 2026
    9d1e23b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions