Skip to content

feat(dashboard): raise the hand-written page and package caps - #20685

Closed
chenmingwei23 wants to merge 1 commit into
mainfrom
fix/20634-raise-dashboard-page-caps
Closed

chenmingwei23 wants to merge 1 commit into
mainfrom
fix/20634-raise-dashboard-page-caps

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Closes #20634.

Problem / Motivation

Goal: Let a hand-written dashboard page that inlines a client-side library be saved, previewed, applied and drawn, by raising the page, package and frame byte caps to a size such a page actually needs.

A dashboard package refuses an agent-written view.html page over 128 KiB
(MAX_VIEW_HTML_BYTES), caps the whole package at 256 KiB
(MAX_PACKAGE_BYTES), and the frame refuses a raw page over 1,000,000 bytes
(dashboard_frame.MAX_PAGE_BYTES). A page that inlines a client-side library —
a 3D renderer, a charting bundle — together with its own scene or layout code is
several hundred KB to a few MB of markup with no data baked into it, and such a
page is a common thing to build. Today it can never be saved as a package, and a
page loaded from a template folder cannot be used once it passes the frame's
limit.

Why it matters

Pages like this are a normal thing to build and are entirely layout — no data is
baked in — so the cap turns a legitimate page away. The 128 KiB / 1,000,000-byte
limits make inlining a real client-side library impossible, which blocks a whole
class of dashboards (3D scenes, rich charts) from existing at all.

Not a goal

  • Not changing any other bound: the model field count, per-field label length,
    theme caps, view-block count and package-structure checks are untouched.
  • Not loosening the fail-closed refusals: a page or package over the (new) limit
    is still refused with the existing error, now naming the new number.
  • Not changing behaviour for pages/packages under today's caps.
  • Not adding configuration or an operator knob for the cap.

What changed (motivation → approach → change)

The three caps on the save-and-draw path were set where a layout-only page fits
and a runaway generation does not — but at a size (128 KiB) chosen as a
baked-values heuristic, which the issue shows is a weak signal and which puts a
legitimate inlined-library page out of reach. The approach is to raise the three
caps together so a page that saves is always a page the frame draws, and to say
plainly that the page cap is now a RESOURCE bound, not a baked-values check:

  • MAX_VIEW_HTML_BYTES: 128 KiB → 3 MiB (3 * 1024 * 1024).
  • MAX_PACKAGE_BYTES: 256 KiB → page cap + 128 KiB (3,276,800) — the page
    cap plus the room the rest of the package (model, view wrapper, theme, and the
    ~12% the indented stored form adds) has always had, so a page saved at the
    page cap never pushes the package over on its own.
  • dashboard_frame.MAX_PAGE_BYTES: 1,000,000 → 3 MiB (3 * 1024 * 1024),
    equal to the page cap. validate_page measures the RAW page (the inline body,
    before compose wraps it in the head, stale band, data island and bootstrap),
    the same string the store caps at MAX_VIEW_HTML_BYTES. The frame ceiling
    EQUALS the page cap, so a page the store will save is exactly a page the frame
    will compose; nothing measures the composed document, so no headroom above the
    page is needed.
  • Comments, the over-cap refusal message, and docs/.../artifacts.md updated to
    the new numbers and the resource-bound framing. Data still belongs in the crew
    log and reaches the page through the fold / bus / controller path; what keeps
    the DATA island small is the per-field model caps, not the page size.

The size cap is now a resource bound, not a baked-values check — this is the
explicit framing the issue asks for.

Other limits on the path (checked)

The issue asks to check every other limit a page crosses and raise it or say why
it already fits:

  • Artifact content cap — artifacts.MAX_CONTENT_BYTES is 25 MiB; a 3 MiB
    package is well under it. Already fits, unchanged.
  • Save route body cap — the dashboard package is written through the
    artifacts handler, whose _MAX_BODY_BYTES is MAX_CONTENT_BYTES + 8 MiB.
    Already fits, unchanged.
  • Preview / apply route (member_dashboard) — reads the staged package
    through the store with no byte cap below the package cap, so the raised
    MAX_PACKAGE_BYTES governs it. No separate limit to raise.
  • Frame-composed document — compose() is never size-checked as a whole;
    only the raw page is, via MAX_PAGE_BYTES, which is raised to equal the page
    cap. A page the store accepts is therefore always one the frame will compose.
    Covered.
  • Instance template ceiling — instance.MAX_INSTANCE_HTML_BYTES is defined
    as dashboard_frame.MAX_PAGE_BYTES, so it tracks the raise with no code
    change. Auto-tracked.
  • Website side — no byte cap in website/src/lib sizes or copies the frame
    document; the browser wrapper applies the frame's CSP, not a length limit.
    Nothing to raise.
  • Authored-page preview arg (validation.py html, 64 KiB) — bounds a field
    always refused one layer up (AUTHORED_PAGE_REFUSAL): an authored page cannot
    be previewed or adopted, so this gates no real page and stays small. Left
    as-is; its stale "matches the store ceiling" comment corrected.

Backwards compatibility

Compatible: this only RAISES caps. Every page and package that saves today still
saves; the fail-closed refusals remain and now name a larger number. No field is
added, renamed or removed, no validator is tightened, and no default behaviour
changes.

Reproduction

On origin/main, a view.html of 131,116 bytes (just over 128 KiB) is refused:

view.html: is 131116 bytes, over the 131072-byte limit for a page

With this change: a page at exactly 3,145,728 bytes saves, one byte over is
refused naming the new limit, the package cap leaves room for a cap-size page,
and a cap-size page is accepted by the frame (its cap equals the page cap).

Tests

  • test/test_dashboard_package_html_view.py: page exactly at the cap saves; one
    byte over refused with the limit named; package cap leaves room for a cap-size
    page; a cap-size page is accepted by the frame.
  • test/test_dashboard_frame.py: the frame cap's value and that it equals
    the save-side page cap.
  • test/test_artifact_dashboard_package.py: the stored-form (indented) cap test
    rescaled to the new cap — compact submit at the cap, indented stored form over.

CI runs the cross-surface backend set.

@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Oct 15, 2026
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of ace97dafe4da5db4c7c743872229871a0deaeb89 and found no blocking issues.

This comment is updated in place on each push.

Review details

FINDING -- src/kiro_crew/artifact_store/dashboard_package.py:76 -- “still leaves that room” overlooks JSON escaping: a validated 3 MiB page containing quoted JavaScript and newlines exceeds the package cap and is refused on save -> Fix: clarify that escaping also consumes the 128 KiB allowance, so meeting the raw-page cap does not guarantee saveability.
[GPT-REVIEWED] ace97da

False positive or not applicable? A repository writer can comment:
/ai-review override gpt ace97dafe4da5db4c7c743872229871a0deaeb89: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision ace97dafe4da5db4c7c743872229871a0deaeb89 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — 🟡 CONCERNS

Design-level review of ace97dafe4da5db4c7c743872229871a0deaeb89 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

The description says the frame cap is 3 MiB + 128 KiB to leave headroom for template-directory pages, but the code sets it to exactly 3 MiB and says no headroom is needed.

Watch

  • The description and the diff disagree on the frame cap. The description says dashboard_frame.MAX_PAGE_BYTES becomes "3 MiB + 128 KiB (3,276,800)… The frame ceiling sits ABOVE the page cap, so… the extra 128 KiB gives a page arriving straight from a shipped template directory the same room." The diff sets MAX_PAGE_BYTES: Final[int] = 3 * 1024 * 1024, and its comment says "Equal to that cap… no headroom above the page is needed." The new test also pins MAX_PAGE_BYTES == dp.MAX_VIEW_HTML_BYTES. A reader of the PR record will take a template page between 3 MiB and 3,276,800 bytes to be accepted, and the code refuses it. instance.MAX_INSTANCE_HTML_BYTES follows this value, so the same gap applies to dashboard instances.
    Clears when: the code and the PR text name the same frame cap, and dashboard-instances.md's size-ceiling section states that value.
  • Lowering the cap later would blank stored dashboards. The store's own reader refuses content over MAX_PACKAGE_BYTES (dashboard_package.py:986). After this ships, any later reduction, including a plain revert, makes every stored package above the new number unreadable, and those dashboards render blank with nothing refused at read time.
    Clears when: the spec or the MAX_PACKAGE_BYTES comment records that the cap can only go up for packages already stored, or the read path gets its own ceiling that never drops below what the store has written.

[DESIGN-REVIEWED] ace97da

Description read

[DESCRIPTION-READ] 5c25f7aed8e25d357e2b842ac9b0dfec51b9f5e44977ee2bc59f8b22a4cdafc8

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — 🟡 CONCERNS

Premise-level review of ace97dafe4da5db4c7c743872229871a0deaeb89 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

The description says the frame cap is 3 MiB + 128 KiB with headroom for template pages, but the diff sets it to exactly 3 MiB.

Not justified as shipped

  • Item 3 — inherited: the description says MAX_PAGE_BYTES goes to "3 MiB + 128 KiB (3,276,800) … the extra 128 KiB gives a page arriving straight from a shipped template directory the same room". The diff ships MAX_PAGE_BYTES: Final[int] = 3 * 1024 * 1024 with the comment "no headroom above the page is needed". The template-folder pages the Goal names ("a page loaded from a template folder cannot be used once it passes the frame's limit") get whichever number is true, and right now the PR states two. The deleted pin test_the_cap_is_dsh_visualizes_own_default ("taken rather than invented: the brief asks for its default") is overridden on Dashboard package: raise the 128 KiB page cap and 256 KiB package cap for hand-written pages #20634. That only holds if the number the PR ships is the number it argues for.
    Clears when: ## What changed and dashboard_frame.MAX_PAGE_BYTES state the same value.

What this change ships

Inventory (7 items) — 5 justified

Intent: let a hand-written dashboard page that inlines a client-side library be saved and drawn. This is an ADDITION (a limit raise).

  1. A view.html page up to 3 MiB now saves (was 128 KiB) — justified
  2. A whole package up to 3 MiB + 128 KiB now saves (was 256 KiB) — justified
  3. The frame composes raw pages up to 3 MiB (was 1,000,000 bytes) — inherited: description and diff give different values
  4. The template-instance ceiling rises with it through instance.MAX_INSTANCE_HTML_BYTES — justified
  5. The over-cap refusal text drops "values baked in" and suggests a smaller library — justified
  6. The comment on the authored-page preview html field is reworded, cap unchanged — rides along
  7. The artifacts spec shows the new cap and the resource-bound framing — justified

[FIRST-PRINCIPLES-REVIEWED] ace97da

Description read

[DESCRIPTION-READ] 1c8b724c58030e1bd45a67529d52d000787121bb968943fc2414ba89b8b02a02

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed ace97dafe4da5db4c7c743872229871a0deaeb89 — this comment is updated in place on each push.

Review details

FINDING — dashboard_package.py:79: a page under the view cap can still be refused as too large once JSON escaping is counted. Advisory, does not block.

FINDING — src/kiro_crew/artifact_store/dashboard_package.py:79 — MAX_PACKAGE_BYTES = MAX_VIEW_HTML_BYTES + 128 * 1024 leaves no room for how much a page grows once it is JSON-escaped. In a JSON string, every ", \ and newline in inlined JS takes two bytes. So a script page of 2,988,438 bytes, under the 3,145,728 view cap, becomes a 3,735,637-byte package and is refused at _decode_package. The refusal text is also misleading: "which a layout is not -- check whether values leaked into it". The comment's claim that "a page that saves at MAX_VIEW_HTML_BYTES still leaves that room" is false for real HTML/JS. → Fix: size the package cap against worst-case escaping (2 * MAX_VIEW_HTML_BYTES + 128 * 1024, which is the 2× ratio the old 128 KiB/256 KiB pair kept), or measure the page's JSON-escaped length against the view cap.

[OPUS-REVIEWED] ace97da

Verdict parsed from the review's SHA-scoped output markers for commit ace97dafe4da5db4c7c743872229871a0deaeb89.

False positive or not applicable? A repository writer can comment:
/ai-review override fable ace97dafe4da5db4c7c743872229871a0deaeb89: <one-sentence reason>

A dashboard package refused an agent-written view.html over 128 KiB and
the whole package over 256 KiB, and the frame refused a raw page over
1,000,000 bytes. A hand-written page that inlines a client-side library
(a 3D renderer, a charting bundle) with its own scene code is MB-scale by
design, so such a page could never be saved, previewed or drawn.

Raise MAX_VIEW_HTML_BYTES to 3 MiB, derive MAX_PACKAGE_BYTES as the page
cap plus the 128 KiB the rest of the package has always had, and raise
dashboard_frame.MAX_PAGE_BYTES (which validate_page measures the raw page
against) above the page cap with headroom, so a page that saves is always
one the frame composes. Every other bound (model field count, per-field
label, theme, package-structure) and the fail-closed refusals are kept;
the page cap is now a plain resource bound rather than a baked-values
heuristic, which size was a weak signal for. The artifact content cap
(25 MiB) and request body caps already fit 3 MiB.

Boundary tests cover a page at the cap saving, one byte over refused, the
package cap leaving room for a cap-size page, and a cap-size page composed
by the frame.
@chenmingwei23
chenmingwei23 force-pushed the fix/20634-raise-dashboard-page-caps branch from 6e7b8d7 to ace97da Compare October 15, 2026 09:24
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Addressed in ace97dafe4da5db4c7c743872229871a0deaeb89.

You were right on both points. dashboard_frame.MAX_PAGE_BYTES only ever measures the raw saved page — validate_page(html) takes len(html.encode("utf-8")), and both call sites (dashboard_package.validate_package and the member-dashboard preview handler) pass the author's own page, never a composed document; nothing anywhere measures compose()'s output. So the frame cap only needs to be at least the page cap, and the + 128 KiB headroom and the "same room as a shipped template" rationale (templates are capped at MAX_INSTANCE_HTML_BYTES, which is this constant) added nothing.

Changes in this revision:

  • MAX_PAGE_BYTES is now 3 * 1024 * 1024 (equal to the page cap), with the comment rewritten to state that relationship.
  • Deleted the composed-length assertion in test_a_page_at_the_view_cap_is_composed_by_the_frame; it kept the honest check (a max-size raw page is accepted by the frame) and dropped the one that asserted a composed-document bound nothing enforces.
  • test_dashboard_frame.py now asserts MAX_PAGE_BYTES == MAX_VIEW_HTML_BYTES instead of >.

The package cap stays at page cap + 128 KiB — that headroom is for the model, view wrapper, theme and the stored form's indentation around the page (your inventory item 2, which you marked justified), not for the frame.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 15, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

You're right — the inconsistency was in the description, not the code. The diff ships MAX_PAGE_BYTES = 3 * 1024 * 1024 (equal to the page cap) with the comment "no headroom above the page is needed"; the description still carried the pre-shrink number (3 MiB + 128 KiB) and the "same room as a shipped template" rationale. The code is the number the PR argues for; the description was stale.

Fixed the description so it states one number:

  • The MAX_PAGE_BYTES bullet now reads 1,000,000 → 3 MiB (3 * 1024 * 1024), equal to the page cap, with the reason: the frame measures the raw page, equals the page cap, and nothing measures the composed document, so no headroom is needed.
  • The "Other limits on the path" frame-composed item no longer claims a composed-size margin ("~3.16 MB under the ceiling"); it says compose() is never size-checked and the frame cap equals the page cap, so a page the store accepts is always one the frame composes.
  • The Reproduction summary and the Tests bullets match the kept test (a cap-size page is accepted by the frame; the frame cap equals the page cap).

The package cap stays page cap + 128 KiB (3,276,800) — that headroom is for the model, view wrapper, theme and the stored form's indentation around the page (your inventory item 2), not the frame. No code change this round; this was a description-only reconciliation on head ace97dafe4da5db4c7c743872229871a0deaeb89.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Superseded by #20790, which Fixes #20634.

It raises the same three caps (page, package and frame) and adds what a page of that size needs:

  • The package cap is 2 x the page cap + 128 KiB. The stored package is JSON, which writes a quote or a line break as two bytes, so a script-heavy page under the page cap can fail a package cap of page + 128 KiB. The Opus review on this PR flagged the same thing.
  • The member dashboard route runs the credential scrub and the framing check off the event loop. The scrub takes about 0.2 s at 3 MiB.
  • Two scans that go quadratic on a page of that size are made linear: the no-script binding fill and the PEM private-key part of the credential scrub. Their matches are unchanged.
  • Tests for the stored-package and frame boundaries, and for a page at the cap going through preview, apply and draw.

Closing this one so the issue has a single PR. The branch is left as it is.

@github-actions github-actions Bot removed the readiness: checking Automated validation is still running label Oct 15, 2026
@bolichen97
bolichen97 deleted the fix/20634-raise-dashboard-page-caps branch November 6, 2026 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dashboard package: raise the 128 KiB page cap and 256 KiB package cap for hand-written pages

1 participant