Skip to content

feat: expose typed browser PDF building and documentation - #73

Open
bendersej wants to merge 12 commits into
mainfrom
build-pdf-contract
Open

bendersej wants to merge 12 commits into
mainfrom
build-pdf-contract

Conversation

@bendersej

@bendersej bendersej commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Agents can generate and revise PDFs through the existing JavaScript, React and WebMCP adapters. The browser editor compiles and publishes the result automatically; successful tool responses include a native preview image and metadata.

buildPdf({ action: "build", code }) // optional name, fonts and serialized or procedural image assets
buildPdf({ action: "status", jobId })
buildPdf({ action: "cancel", jobId })
getDocumentation({ topic: "build_pdf" })

P149 extends the same contract with optional Google Fonts selections (family, optional weight/style) and image assets authored as sandboxed procedural code (shader: { code, width, height, textures? }). getDocumentation adds English graphics/shader recipes and a bounded local font search. Native form widgets are authored in Typst metadata; there is no additional endpoint or lifecycle parameter. The iframe wire keys and generated camelCase SDK mapping retain their existing conventions. Runtime boundaries, current browser proof and videos live in simple-pdf#662.

Each accepted build starts a fresh attempt. No idempotency key, base job, caller timing or inspection options. Inputs discriminate on action; results discriminate on status. Compilation failures return repair diagnostics, while preview errors remain separate from successful publication. The authoring additions leave existing operation shapes intact; synchronization with newer master also adds forbidden:recipient_link_used to SUBMIT errors.

The provider-compatible schema validates and infers the canonical action union. Existing bridge key normalization remains intact; strict new SDK methods reject wire aliases before conversion, and invalid input stays distinct from iframe transport failures.

Validation: 132 SDK tests and 15 React tests; type checks, all nine public API reports, exports and all seven unchanged bundle caps pass. Local editor contract freshness passes. The paired editor's real candidate-host journey exercises build/repair/cancel, native preview images, ambiguous-key rejection, targeted deletion and edit protection. All three published-SDK compatibility journeys remain. Final cold Astra review: 10/10, no required fixes or polish. Historical browser evidence remains in SimplePDF/simple-pdf#657. The P149 generated-artifact update at c02c98e separately passed 132 SDK tests, types, build, exports, lazy chunks and all six embed API reports; cold Astra reviewed those exact staged blobs without findings.

Notes

A changeset prepares minor package releases. The production freshness gate remains blocked until the editor deploys the new manifest; no gate is bypassed, package published or PR merged. Release ordering is the operator's decision.

Review outcomes

Change Before After
O1 ✅
Typed browser authoring
Generated contract
Existing PDF editing actions Build and documentation actions with compact discriminated unions across JavaScript and React
O2 ✅
Canonical provider validation
Generator
Existing operation validators derive from the editor contract New action union keeps provider-compatible JSON while enforcing the same runtime and inferred input type
O3 ✅
Native preview image delivery
WebMCP adapter
Annotated-page image projection Successful build previews use the same projection without duplicate base64 text
O4 ✅
Preserved existing bridge behavior
Bridge
Established key normalization and transport errors All existing operations preserve both; new strict methods reject ambiguous aliases before normalization
O5 ✅
Unchanged page inspection
Generated contract
Page-only inspection of the current PDF Page inspection stays unchanged; SUBMIT additionally exposes master’s recipient-link refusal; build preview identity is internal to the editor
O6 ✅
Expressive authoring through the same build call
Generated contract
No browser-authoring API on package master Generated font and procedural-image unions accompany build/status/cancel; documentation exposes matching discovery and recipes

Master contract synchronization — 25 November 2026

Pin f05cda2 follows the editor's merge of master 1ed540a85. Only forbidden:recipient_link_used is added to the generated error vocabulary and SUBMIT error list, with the matching protocol report. Builder arguments and results are unchanged. All 132 core tests, types, build, export/API checks and the merged local-editor manifest comparison pass. Publication still follows the editor release; the production-manifest check is not bypassed.

@bendersej

Copy link
Copy Markdown
Member Author

Code review: 6/10 at 7df6752

Fresh Astra review found provider-facing root-union incompatibility, SDK validation stripping unintended keys, guidance naming the wrong tool surface, minified public function names/debugging regressions, and incorrectly typed test stubs. Fixes are underway; new router/converter regressions fail on this head.

Since the previous review: first posted cold Astra review, full diff against main 18f06e7; merges cleanly.

Required fixes: derive an object-root tool advertisement while retaining strict union dispatch; preserve strict objects; correct naming/guidance; preserve public names and debuggability; fix typed action stubs.
Polish: share image extraction and test multi-page metadata; correct release-note format.
Agents: Astra SDK 6/10; Astra editor independently confirmed strictness loss.
Your call: production contract freshness remains blocked until the editor deployment; no publishing or bypass proposed.

@bendersej

Copy link
Copy Markdown
Member Author

Cold Astra review — 10/10

Reviewed c479a47 against origin/main (18f06e7). Goal: expose the browser PDF build and documentation contract through the existing typed adapters.

Required fixes: none. Polish: none. The review/fix rounds corrected strict nested schemas, provider object-root advertisements, wire-key preservation, new error-category handling, default documentation input, guide readiness, and image projection. Regression tests failed before the fixes and pass afterward.

Ownership remains compact: the editor owns the manifest; generation owns strict types/schemas and the small bridge vocabulary; the existing bridge owns transport and naming; WebMCP owns image blocks. No independent runtime examples or duplicate contract owner were introduced. The thin vocabulary keeps the full operation table out of the root bundle.

Validation: 132 passing SDK tests, core and React types/exports, API reports, zero new React Doctor diagnostics. All seven bundle caps pass. Root is 7,687 B gzip versus 9,223 B on main; opt-in WebMCP is 4,990 B versus 4,684 B, below its existing 5,120 B limit. No per-interaction I/O or renders were added.

Agent roster: independent cold SDK reviews and security review used gpt-6.2-astra, high reasoning, fresh context. No Claude reviewers. Final cold reviewer found no remaining required fixes or polish after verification. Review followed code-review.

Release dependency: production contract-freshness CI cannot pass before the editor deploys the new manifest. This review does not authorize publishing or deployment.

@bendersej

Copy link
Copy Markdown
Member Author

Code review: 10/10 at 809ae21

The SDK exposes the compact action/status contract in JavaScript, React, AI-tool and WebMCP adapters. Strict schemas reject extras, raw WebMCP preserves wire keys, and native previews carry one image plus metadata. The nested failure type includes only page-inspection and shared gateway errors. Merges cleanly onto main 18f06e7.

Since the previous posted review (7df6752..809ae21):

  • c479a47 fix: preserve strict PDF build contracts across SDK adapters
  • cbea5cc feat: simplify PDF building to opinionated job outcomes
  • 694a09b fix: sync inspection conflict with editor error catalog
  • a9d7f70 fix: expose reachable build states and diagnostic fields
  • 809ae21 fix: narrow build preview errors to the page inspection contract

Required fixes: none. Polish: none.

Validation: 133 SDK + 15 React tests, TypeScript, six SDK/three React API entries, exports and all seven existing gzip caps pass. The SDK pin equals the paired editor manifest. Two fresh Astra-low agents proved the authoring loop through the editor's native tools; recordings are in SimplePDF/simple-pdf#657.

Owner/shape review: the editor manifest owns shapes and error vocabulary; the existing generator derives names, validators and bindings. Existing adapters own execution/projection. No alternate contract dialect, new upload flow or compatibility shim. Maintainability, readability, simplicity, security and edge cases have no outstanding findings.

Agents: cold Astra SDK 10/10; independent final cold Astra source review 10/10. No Claude reviews.

Your call: nothing for this implementation step. Production contract freshness requires the new editor manifest; this PR remains draft and no package was published.

@bendersej

Copy link
Copy Markdown
Member Author

Code review: 10/10 at c624e51

The generated SDK restores the original page-only annotated inspection shape. All existing operation entries match the editor master; only build and documentation operations are added by the feature. First-page preview identity remains internal to the editor.

131 SDK and 15 React tests pass, alongside types, generated API reports, exports and all seven unchanged size caps. Two redundant inspection cases were removed.

Since the previous review (809ae21..c624e51):

  • c624e51: restore page-only inspection contract, generated bindings/API reports and documentation.

Required fixes: none.
Polish: none.
Agents: fresh cold Astra sign-off: 10/10, including independent manifest and SDK comparison.
Your call: nothing for implementation. Production manifest freshness still depends on releasing the editor contract; no package publication.

@bendersej

Copy link
Copy Markdown
Member Author

Code review: 9/10 at c624e51

Merges cleanly onto origin/main 18f06e7. The SDK manifest and generated snapshots match the editor, including all 17 unchanged existing operations. Regeneration produces no diff. Runtime projection, strict camelCase bindings and native image results have no required fixes.

Since the previous review (c624e51): no intervening commit; an additional cold review of the same head.

Required fixes: none.
Polish: remove three obsolete job_id properties from annotated-page test fixtures; remove the stale hardcoded count of URL-fetching operations from the README. Both corrections are in the working tree.
Agents:

  • Cold Astra SDK review: 9/10, fixture polish only.
  • Independent Astra security review: security PASS; README count correction.

Your call: production contract freshness still requires the editor's new manifest to be deployed. Local contract freshness, SDK/React builds, 131 SDK tests, 15 React tests and both API report checks pass. No package was published; do not revert the new snapshots to satisfy the old production manifest.

@bendersej

Copy link
Copy Markdown
Member Author

Code review: 10/10 at 6b00391

Merges cleanly onto origin/main 18f06e7. Fresh cold Astra review found no remaining required fixes or polish. The editor manifest, SDK pin, generated bindings and API reports agree; all 17 original operation records retain their original contract. Independent regeneration in a temporary package reproduced every generated source file byte-for-byte.

Since the previous review (c624e51..6b00391):

  • 6b00391: remove obsolete build identity from page fixtures and the README's stale operation count.

Required fixes: none.
Polish: none.
Agents:

  • Cold Astra SDK review: initial 9/10; fixture correction verified by 21 targeted WebMCP tests.
  • Fresh cold Astra full review: SDK 10/10.
  • Independent Astra security review: security PASS.

Validation: 131 SDK and 15 React tests, SDK/React builds, generated API reports (6/3 entries) pass. Local /embed/json contract freshness passes. Regeneration changes no snapshots.

Your call: production contract freshness remains a release dependency: simplepdf.com does not yet expose the two new operations. No gate was bypassed and no package published. The PR remains draft.

@bendersej

Copy link
Copy Markdown
Member Author

Code review: 8/10 at 6b00391

Fresh cold review of the full diff; merges cleanly onto origin/main 18f06e7. This supersedes the preceding 10/10 verdict. The public tool validator does not enforce the same discriminated input as its executor. No code was changed in this read-only pass.

Since the previous review (6b00391): no intervening commits.

Required fixes: preserve the provider-friendly object-root JSON advertisement while refining the published buildPdf inputSchema with canonical BuildPdfInput validation. Reproduced through the actual built public modules: {action:'build'} and {action:'status',jobId:'example',code:'='} both pass SIMPLEPDF_TOOLS.buildPdf.inputSchema and fail BuildPdfInput. The independent reviewer verified canonical refinement rejects both while Zod and TanStack JSON-schema conversion remain byte-identical. Fix the generator, then regenerate; do not hand-edit outputs.

Polish: none in the SDK itself. Companion PR #657 must clarify callable-guide casing and exercise the candidate SDK against the real editor; its released-package fixture and synthetic build reply do not cover that path.

Agents:

  • Fresh Astra SDK reviewer: 8/10, exported-validator mismatch independently reproduced.
  • Fresh Astra editor reviewer: 8/10 on companion PR.
  • Fresh Astra security reviewer: no validated boundary bypass; main-thread admission cost reported separately.

All 17 existing operation descriptors remain equal to the bases. The SDK pin equals the paired editor manifest apart from deployment metadata; fresh generation reproduced every output byte-for-byte. SDK React Doctor reports zero diagnostics. Exact-head CI passes all 6 API reports and 7 size budgets (root 7,701 / 10,240 B, lazy WebMCP 4,845 / 5,120 B); its sole failing step compares the new manifest with production, which lacks the two new operations. The paired editor's full standard E2E passed 1,197, skipped 30, zero retries/failures, but does not replace the missing candidate-SDK authoring row.

Retrospective: the bridge and generator remain the right owners. The next guard should require advertised runtime validators and execution validators to agree for each discriminated action, alongside a real candidate-host build.

Your call: no design decision needed; fix the generator validation before merge. Keep the draft and production freshness gate. No publication performed.

@bendersej

Copy link
Copy Markdown
Member Author

Cold code review — idempotency removal only

Goal: let callers build PDFs with complete source, without managing retry keys. Reviewed editor commit a98a65437 and SDK commit 720d4f9 against their immediate parents; this is not a new whole-PR verdict.

Score: 10/10. Required fixes: none. Polish: none. Maintainability, readability, simplicity, security and edge cases pass for this delta. Existing whole-PR findings remain open.

The existing controller remains the owner. Deleted payload hashing/canonicalization, key lookup and expired-key state; retained job expiry/ownership/caps and publication/edit protection. Schemas and SDK outputs derive from the same manifest. Each build creates a fresh attempt, while status/cancel target an existing job. No new production layer or option.

Validation: 20 targeted Chromium E2E checks passed in 42.3 s, including the isolated inspection budget (14 pages: 2,937 ms; first page: 622 ms; zero long tasks). Native WebMCP: 58 completed builds. WebKit: 11 examples through the Playwright image. Controller: 11 tests; contract/discovery: 34; SDK: 132; React: 15. Types, lint, production build, generated-asset freshness and local contract parity passed. Complete standard suite was not rerun for this removal. The earlier concurrent performance attempt exceeded its budget; the final run had no other browser workload.

Performance: compact input schema 941 → 896 bytes. The deleted serialization/encoding/hash operation measured median 0.04 / 59.89 / 118.51 ms for 0 / 10 / 20 MiB synthetic assets (Node 24.22.3, five samples after warm-up). These are operation timings, not end-to-end browser latency. No additional E2E rows; SDK adds one removed-field rejection case. Exact-delta React Doctor: zero diagnostics.

Agent verdicts: independent Astra-high reviewer identified stale docs and unconditional status reads (corrected); a second fresh Astra-high reviewer validated the final delta at 10/10. Both PRs merge cleanly against refreshed bases 99eed373c / 18f06e7.

@bendersej

Copy link
Copy Markdown
Member Author

Code review: 10/10 at 628edb2

The complete SDK diff has no remaining required fixes or polish. Both the public validator's inferred union and runtime validation match the canonical contract. Existing camelCase WebMCP calls retain their behavior. Strict new SDK inputs refuse wire aliases, and transport failures retain their established error.

Since the previous review (720d4f9..628edb2): fix: enforce build action unions without changing legacy bridge keys.

Verification: 132 SDK tests; 15 React tests; types, generated API reports, exports and seven unchanged size caps pass. The real browser targeted-deletion and ambiguous-cancel journeys failed before their fixes and passed afterward. The dead-iframe test also failed before the specific input-error classification and passed after it. Candidate authoring now runs through actual SDK files and editor traffic.

Required fixes: none.
Polish: none.
Agents: Astra SDK merge review 7 → 9/10 (schema/key conversion, API reports, fixture origin); Astra SDK cold review reproduced alias collision before hitting its usage limit; Astra final blocker review 8 → 10/10 (transport-error distinction); fresh Astra release-gate review 10/10 for the full SDK diff. No Claude review used.
Your call: release the editor contract before publishing this SDK, or choose another explicit release order. Production freshness is still deliberately enforced. No merge, deployment or package publication was performed.

@bendersej
bendersej marked this pull request as ready for review November 24, 2026 21:11
@bendersej

Copy link
Copy Markdown
Member Author

Code review: 10/10 at c02c98e

The generated P149 font and procedural-image additions retain the compact build/status/cancel contract, strict unions, established camelCase SDK mapping and native image projection. Cold Astra reviewed the exact staged artifacts before this commit. No source fix or polish remains in this SDK delta.

Since the previous review: c02c98e feat: expose sandboxed graphics and Google font selection adds the generated contract, schemas, tools, API reports and matching README guidance. Runtime evidence is in SimplePDF/simple-pdf#662.

Validation: 132 SDK tests; types, build, exports, lazy chunks and six embed API reports pass. The production-manifest freshness/release-order gate still requires the paired editor deployment; no check or publication was bypassed.

Required fixes: none.
Polish: none.
Agents: cold Astra high, generated-artifact delta 10/10.
Your call: editor deployment and subsequent SDK publication remain operator-controlled.

@bendersej

Copy link
Copy Markdown
Member Author

Code review: parity verified at f05cda2

Final Opus integration verification closes the SDK evidence requests: all three generated files, including the protocol report, are committed; the submodule is clean; both master and the prior feature pin are ancestors. All 132 tests and six API checks pass without the snapshot-update flag, alongside build, exports and local editor manifest parity.

Since the previous review: f05cda2 adds only master’s forbidden:recipient_link_used error vocabulary and SUBMIT declaration. Builder inputs/results are unchanged.

Required fixes: none.
Polish: none.
Agents: actual Opus 5.5 — committed/local SDK parity verified; no separate numeric SDK score assigned in this integration pass. Independent Codex — matching editor/SDK manifests verified.
Your call: production freshness remains blocked until the editor deploys BUILD_PDF/GET_DOCUMENTATION and the new SUBMIT vocabulary. This is the existing release gate, not a local validation failure. Nothing was merged, deployed or published.

Paired final verification.

This branch has not been deployed

No deployments
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.

1 participant