Skip to content

fix(service-print)!: the record print downloads the PDF and stores no attachment - #39076

Merged
os-zhuang merged 10 commits into
mainfrom
claude/issue-38894-print-download-only
Dec 2, 2026
Merged

os-zhuang merged 10 commits into
mainfrom
claude/issue-38894-print-download-only

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Part of #38894 — this PR is the service and route half of the ruling (a print writes no attachment and the route answers the PDF). The delivery half, the REST action door relaying a file and the console saving it (ruling A, record 7344041246), merged first in #39141 (0fff9ae00b); this branch carries it through a merge of origin/main.

Clause-②: yes (narrowing)
Metadata-protocol: none
Skills-docs: none — no published skill teaches the print service or its door (git grep over skills/ for print/records, printRecordToFile and service-print: zero hits; control: attachment has hits)

维护者速读

  • 用户点"生成 PDF"(或直接调用打印接口)拿到的是 PDF 下载,记录上不再存附件;只能查看、不能编辑这条记录的人也能打印。
  • 按维护者在该卡上的裁决做:生成 PDF 是导出而不是存档,这取代了旧打印存档卡里"把 PDF 存到记录上"的那一半。
  • 若出错:只影响打印本身(点按钮会看到报错、拿不到文件),不会写坏任何数据,改动可以整体撤回;AI 助手那条入口仍然拿不到文件,会报错。
  • 要你做的:审批并合入本 PR。按钮报错的空窗已经关闭:让动作入口把文件交给浏览器下载的那一半已先合入主干。

What changes

  • IPrintService.printRecordToFile becomes printRecordToPdf and returns the PDF itself (pdf, size, filename, contentType: 'application/pdf'). It no longer calls the files service, writes no sys_attachment row, and carries no source / print_page marker.
  • Permission: the READ check (plus the existing re-probe) is now the whole gate. The edit/attach gate (assertMayAttach) and the FILES_DISABLED refusal are gone, so a user who can read but not edit the record can print it.
  • POST /api/v1/print/records and the print door member answer 200 with the PDF bytes: Content-Type: application/pdf, Content-Disposition: attachment; filename="ascii-fallback"; filename*=UTF-8''percent-encoded (RFC 6266 / RFC 5987), Cache-Control: no-store, X-Content-Type-Options: nosniff. Refusals keep the JSON error envelope.
  • A request's own filename is refused VALIDATION_ERROR / 400 before anything is rendered when it is over 255 characters (PRINT_FILENAME_MAX_CHARS) or holds a lone UTF-16 surrogate. The header builder is also total: a lone surrogate in any other name (a record's display value) is written as U+FFFD instead of throwing.
  • @objectstack/service-storage is no longer a dependency of service-print (and the plugin no longer wires the attachments service).
  • A declared print action delivers the PDF. With feat(runtime): the REST action door delivers a target's attachment, and the console saves it as a download #39141 on main, the REST action door relays a non-JSON 2xx answer that carries Content-Disposition: attachment byte for byte and the console saves it, so a declared type: 'api' action that targets the route (showcase GenerateInvoicePdfAction, HotCRM Print Quote) downloads the PDF under the print's file name. MCP run_action still answers a file 502. The changeset, content/docs/ui/print-pages.mdx, both route-ledger notes, the plugin jsdoc and the showcase action's jsdoc say so.
  • Showcase: the print action's jsdoc, successMessage and its zh-CN translation, and the comments on the invoice page and object no longer promise an attachment; the jsdoc says the console downloads the PDF through the REST action door. The action's wiring is unchanged.
  • Contract prose only: packages/spec/src/contracts/print-door-service.ts and packages/runtime/src/domains/print.ts jsdoc now say "download". No type moves.
  • BREAKING changeset with FROM / TO for the service, the wire answer and an app that declares a print action, the HotCRM migration line (quote_print_presented becomes an explicit "mark presented" action), and one ADR-0087 marker.

Risk-first reading order:

  1. packages/services/service-print/src/print-service.ts — the removed attach path and validateRequest; the read check and the session revoke in finally must remain.
  2. packages/services/service-print/src/print-routes.ts — sendPdf and pdfContentDisposition (header quoting, encoding, the lone-surrogate replacement).
  3. .changeset/38894-print-downloads-no-attachment.md — what an upgrading app reads about a declared print action (REST door downloads, MCP 502).

Tests

  • Unit (print-routes.test.ts): the success case is a 200 PDF with the four headers. A non-ASCII name 报价单 "Q1".pdf gives filename="___ _Q1_.pdf" plus a UTF-8 filename*. A name holding a lone surrogate (\ud83d.pdf, a\udc00.pdf) is VALIDATION_ERROR / 400 with nothing minted, read or rendered. pdfContentDisposition writes a lone surrogate as %EF%BF%BD and keeps a paired one. The engine double traps every insert/update/delete/upsert (expectNothingWritten).
  • Unit (print-door-member.test.ts): the door member answers the same PDF bytes as the mounted route.
  • Unit (print-service.test.ts): "read access is the whole permission; nothing is stored"; a 255-character name prints and a 256-character one is refused; a paired surrogate prints (control) and a lone one is refused, both before anything starts; a display value holding a lone surrogate names the file with U+FFFD.
  • Dogfood, real stack (print-service-archive):
    • an auditor who can read but not edit prints;
    • no sys_attachment row is written;
    • two prints write nothing;
    • an attacher prints and still writes nothing;
    • a caller who cannot read the record (hidden by RLS) is refused RECORD_NOT_FOUND / 404.
  • Dogfood print-service-named-page / print-service-render: a render failure is forced by dropping the renderer's connections and asserts a status of 500 or above.
  • Conformance, end to end (action-door-attachment-38894.conformance.test.ts, both transports): the real PrintServicePlugin mounts its route; a declared print action (recordIdParam plus bodyExtra, as the showcase declares it) sent to POST /api/v1/actions/c38894_doc/print_pdf answers 200 with the PDF bytes, Content-Type: application/pdf, the route's own Content-Disposition: attachment; filename="__ INV-1.pdf"; filename*=UTF-8''%E5%8F%91%E7%A5%A8%20INV-1.pdf, no-store and nosniff; the print service received exactly the assembled request, as the caller. Only the renderer (printRecordToPdf) is replaced, since no browser runs there.

Acceptance notes

  • Delivery: decided and landed. The maintainer ruled A (record 7344041246): the REST action door relays a file and the console saves it; the MCP door keeps refusing. feat(runtime): the REST action door delivers a target's attachment, and the console saves it as a download #39141 shipped it and merged first (0fff9ae00b), so main never had the 502 window. This branch merged origin/main at a0a9d699 (K = 39; no conflict) and then restated every text that described the window (commit 3510e8a6).
  • Files touched outside the claimed surface, each forced by the change:
    • print-service-plugin.ts and its two tests (the attachments wiring was removed);
    • package.json and pnpm-lock.yaml (the dependency was dropped);
    • packages/runtime/src/domains/print.ts (jsdoc) and packages/runtime/src/route-ledger.ts (the print row's note);
    • packages/services/service-print/src/print-route-ledger.ts (the row's note);
    • content/docs/permissions/system-context.mdx (row 47d);
    • the showcase print action's texts (four files);
    • packages/qa/dogfood/test/authz-conformance.matrix.ts (row text);
    • four dogfood tests;
    • the changeset;
    • packages/qa/http-conformance/src/action-door-attachment-38894.conformance.test.ts (one end-to-end pin added to feat(runtime): the REST action door delivers a target's attachment, and the console saves it as a download #39141's suite, as the dispatch ordered).
  • packages/spec/src/contracts/print-door-service.ts was edited for jsdoc only. The result type lives in service-print, not spec.
  • The Content-Disposition builder duplicates service-storage's, which is not exported. Sharing it is a possible follow-up, not done here.
  • The print-service-render dogfood is SKIPPED locally because no console is built: NOT MEASURED locally, so CI is the reading.

Verification

Two-minute check: pnpm --filter @objectstack/service-print exec vitest run --maxWorkers=2 src/print-routes.test.ts — expect all tests to pass, including "a file name holding a lone UTF-16 surrogate: VALIDATION_ERROR / 400, before anything is minted or rendered".

Readings at 3510e8a
  • os-regen-merge.sh: merge a0a9d699, no conflict, no os-regen path taken from main; @objectstack/spec check:generated after the build: all 14 generated artifacts up to date (no regeneration commit). The sibling's body is intact at the head (isRelayableAttachmentAnswer, saveAttachmentAnswer: same counts at origin/main and HEAD).
  • @objectstack/service-print vitest run: 9 files / 143 tests passed. typecheck: exit 0.
  • @objectstack/http-conformance: action-door-attachment-38894 + hono-print-door: 2 files / 14 tests passed (2 new, one per transport). typecheck (tsc + check:test-typecheck): exit 0.
  • @objectstack/runtime: route-ledger.conformance, own-door-bridge, api-action-forward: 3 files / 193 tests passed.
  • showcase test/invoice-generate-pdf-action.test.ts: 4 passed.
  • Local gate subset narrowed to this round's delta (changeset, docs, ledgers, the test file): 24 commands, all exit 0. dispatch-gates --ran: 115 of 139 derived families left to CI (declared narrowing).
  • No ablation this round: the reconciliation changes no tested behaviour (texts plus one added pin).
  • Earlier readings (ablations of sendPdf, the edit gate, the lone-surrogate refusal and the header builder; the four print dogfood files) were taken at 2125d13975 and are in the contract review 7340628991; no print code changed since.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QSeKYnrQ7UMtHofKQVjcH2

@github-actions github-actions Bot added size/xl dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 3 package(s): @objectstack/runtime, @objectstack/service-print, @objectstack/spec, touching 35 documentable anchor(s). ⚠️ 3 changed file(s) yielded no anchor (packages/runtime/src/domains/print.ts, packages/services/service-print/README.md, packages/services/service-print/package.json), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

27 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json a294369cbc7032b85818b4e79ab999af9e7be230.

⛔ 10 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 3 changed file(s) yielded no anchor (packages/runtime/src/domains/print.ts, packages/services/service-print/README.md, packages/services/service-print/package.json) — pages documenting those are invisible to this run
  • 1 anchor(s) matched too much of the corpus to be a work list: VALIDATION_ERROR (literal, 40 pages)
  • 2 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 71 of 255 client-bound route-ledger rows — the other 184 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 184: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 60 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 189 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json a294369cbc7032b85818b4e79ab999af9e7be230 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 50f2cf2ebe427ac208088bd1930c7cf9b7b63ae3 — the merge of head 3510e8a666f1249b078b59c568dffee19e06831d into base a294369cbc7032b85818b4e79ab999af9e7be230, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 50f2cf2ebe427ac208088bd1930c7cf9b7b63ae3 && git checkout 50f2cf2ebe427ac208088bd1930c7cf9b7b63ae3
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin a294369cbc7032b85818b4e79ab999af9e7be230 3510e8a666f1249b078b59c568dffee19e06831d && git checkout -B drift-repro a294369cbc7032b85818b4e79ab999af9e7be230 && git merge --no-ff 3510e8a666f1249b078b59c568dffee19e06831d

node scripts/docs-audit/affected-docs.mjs --json a294369cbc7032b85818b4e79ab999af9e7be230

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs a294369cbc7032b85818b4e79ab999af9e7be230 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2

Contract-review-claim: session_01QSeKYnrQ7UMtHofKQVjcH2 · head f184414 · 2026-12-02T08:03Z

First contract review, on the dev's report 7338187928. CI is green at this head and the dogfood battery (opt-in) passed.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: f184414b5bfd71df55b27fe420503e92945df75b
Local-runs: probe — the brief orders the dev's two ablations re-run and the header and binary claims measured; scratch worktree at the head, removed afterwards (commands and exits under ④)
Scope: packages/spec/src/contracts/print-door-service.ts + packages/services/service-print/src/print-service.ts, packages/services/service-print/src/print-routes.ts, packages/services/service-print/src/print-service-plugin.ts, packages/services/service-print/src/index.ts, packages/services/service-print/package.json, packages/services/service-print/README.md, packages/services/service-print/src/print-service.test.ts, packages/services/service-print/src/print-routes.test.ts, packages/services/service-print/src/print-door-member.test.ts, packages/services/service-print/src/print-service-plugin.test.ts, packages/services/service-print/src/print-service-plugin.revoke-log.test.ts, packages/runtime/src/domains/print.ts, packages/qa/dogfood/test/authz-conformance.matrix.ts, packages/qa/dogfood/test/print-service-archive.dogfood.test.ts, packages/qa/dogfood/test/print-service-named-page.dogfood.test.ts, packages/qa/dogfood/test/print-service-render.dogfood.test.ts, packages/qa/dogfood/test/print-door-impersonation.dogfood.test.ts, pnpm-lock.yaml

Faces: the Clause-②: yes (narrowing) declaration (PR body and changeset) and the published-schema face (packages/spec/src/contracts/print-door-service.ts). Inputs read: card #38894 with the ruling 7336681739, the claim 7336726260 and the dev report 7338187928; PR #39076 body and the diff from merge-base 431f88021e to the head (21 files, 4 commits); the head's 84 check-runs (all success or skipped, the three dogfood battery shards success). Code outside the diff was read, not reviewed: packages/runtime/src/action-execution.ts (forwardApiAction), packages/runtime/src/domains/own-door-bridge.ts, packages/adapters/hono/src/index.ts, packages/plugins/plugin-hono-server/src/adapter.ts and door-table-member.ts, ui/packages/app-shell/src/utils/apiActionDoor.ts, ui/packages/app-shell/src/hooks/useConsoleActionRuntime.tsx, examples/app-showcase/src/ui/actions/index.ts, docs/adr/0087-metadata-protocol-upgrade-contract.md, scripts/check-adr-0087-registration.mjs.

① Derived judgments

  1. No attachment, no marker: holds. printRecordToPdf runs principal, engine status, request validation, page, the caller's read, the re-probe, mint, render, and the revoke in finally; it returns { pdf, size, filename, contentType }. print-service.ts no longer imports @objectstack/service-storage, getAttachments is gone from PrintServiceDeps and from the plugin wiring, and no engine write verb is called on any path. No source or print_page field is added anywhere; packages/platform-objects is untouched. Precision for the record: "stores nothing" means no sys_file and no sys_attachment. A print still signs a session in and out for the caller, as before, and the docs say so.
  2. Read access is still enforced, and an RLS-hidden record is still RECORD_NOT_FOUND / 404. readAsCaller is unchanged: engine.findOne with the caller's context, a 403 from the read mapped to recordNotFoundError, a null row the same. It runs before the mint. The dogfood test proves it on the real showcase stack with a control (the caller-scoped read is null, the system read is not) and asserts no mint and no render.
  3. Content-Disposition is sound, with one hole. Measured through pdfContentDisposition for eight hostile names: CR/LF, tab and every non-ASCII character become _ in the quoted fallback, " and \ become _, the value is always printable ASCII with exactly two quotes, and filename*=UTF-8'' round-trips the original name with '()* percent-encoded (RFC 5987). No header injection is possible. The hole: a name holding a lone surrogate (JSON "\ud83d.pdf") passes validateRequest, the print runs in full (mint, render, revoke), then encodeURIComponent throws URIError inside sendPdf, outside the try. The door answers 500 INTERNAL_ERROR "No response from handler" from the adapter, not a VALIDATION_ERROR before the render and not one of the door's own fault sentences. See should-fix 1.
  4. The 255-character refusal is sound. It counts code points (Array.from), sits in validateRequest at step ③ (before the page read, the record read and the mint), and answers VALIDATION_ERROR / 400. Measured: 255 accepted, 256 refused; the worst case (255 four-byte characters) gives a 3612-byte header value, well inside common header limits. The default name is at most 104 characters.
  5. The door member and the mounted route answer the same bytes. By construction: createDoorTableMember runs the same registerPrintRoutes on a HonoHttpServer that never listens, and the adapter's send hands a Uint8Array to c.body as an ArrayBuffer. The unit test compares status, type, disposition, cache header and bytes across both faces. My probe sent bytes that are not valid UTF-8 (25 50 44 46 2d 0a 25 e2 e3 cf d3 0a ff fe 00 80 c0 0d 0a): identical on both faces.
  6. The hosted path passes a binary body unchanged. handleOwnDoorBridgeRequest returns { handled: true, result } holding the member's own Response; @objectstack/hono toResponse returns it as it is when res instanceof Response (packages/adapters/hono/src/index.ts line 907). No layer reads the body. No test drives a PDF answer through the dispatcher end to end (the http-conformance print file covers 401, 503 and 501 only): nit 2.
  7. No caller is left on the old name or on attachmentId. Whole-repo grep (packages, ui/, examples/, apps/, packages/qa, changelogs excluded) for printRecordToFile and PrintedRecordFile: no code hit. Two prose hits remain: content/docs/permissions/system-context.mdx line 199 (should-fix 2) and the historical .changeset/pre/35049-print-filename-display-name.md. No file reads a print answer's attachmentId or fileId.
  8. The spec change is jsdoc only. packages/spec/src/contracts/print-door-service.ts and packages/runtime/src/domains/print.ts are byte-identical to the merge-base once comments are stripped (TypeScript printer, removeComments). The new prose agrees with the code: 200 with the PDF body, refusals in the error envelope.

② Semver level

  • Level: right. '@objectstack/service-print': patch. AGENTS.md Post-Task step 3: Metadata-protocol: none takes patch, and a non-protocol breaking change ships patch with its BREAKING banner and ADR-0087 disposition. Metadata-protocol: none is true: nothing an author can write changes. The package is in the fixed group, so spec and runtime move with it.
  • BREAKING banner: present. FROM → TO: present for IPrintService.printRecordToFile → printRecordToPdf and PrintedRecordFile → PrintedRecordPdf; the wire change (201 JSON → 200 application/pdf) is stated under "The door's answer". One-line migration: present for keeping the PDF on the record, and the sentence that HotCRM's quote_print_presented no longer fires on a print is there.
  • ADR-0087: exactly one marker, not-required (runtime-export-retired @objectstack/service-print#PrintedRecordFile, @objectstack/service-print#IPrintService.printRecordToFile). The category is right: ADR-0087's 2026-10-12 addendum (D9) covers an export retired from a published entry and a member retired from a type that stays exported, with no metadata to rewrite; both operands are named on FROM lines; the category is in CATEGORIES.
  • Declaration lines: Clause-②: yes (narrowing) and Metadata-protocol: none are line-initial in the PR body and in the changeset.
  • Skills-docs: present in the PR body, none — …, and true: git grep over skills/ and .claude/skills/ for print/records, printRecordTo, service-print and PrintServicePlugin has zero hits; skills/objectstack-ui/rules/pages.md teaches declaring print and says nothing about attaching a PDF.
  • Must-fix 1: the changeset misstates what ships and omits the largest consumer break. Its banner says "The record page's "generate PDF" is now a download". At this head the only record-page road to the print, a declared type: 'api' action, is answered 502 by the action doors (verified under ③), so the record page's "Generate PDF" is an error, not a download. The changeset never mentions the action doors or 502, and gives no FROM → TO for an app that declares a print action, which is the one road the docs taught until this PR. The changeset ships as CHANGELOG.md and is what an upgrading app reads; HotCRM's Print Quote would be upgraded on a sentence that is false for it.
  • Docs: content/docs/ui/print-pages.mdx is accurate claim by claim (200 PDF and its headers, read as the whole permission, the refusal table without step 5, the 502 for a declared action). The README is accurate. Left stale: content/docs/permissions/system-context.mdx line 199 (should-fix 2).

③ Boundary flags

  • The 502 gap is real, and it is a declared residual everywhere except the changeset. forwardApiAction (packages/runtime/src/action-execution.ts) reads the target's answer as text, and a 2xx that does not parse as JSON becomes the door's own 502 with apiActionNonJsonAnswerError. The console sends every declared, object-bound, same-origin type: 'api' click through that door (findDeclaredApiAction and sendApiActionThroughDoor in apiActionDoor.ts, called from useConsoleActionRuntime.tsx and RecordDetailView.tsx). Stated in: the PR body (speed-read bullet 3, "What changes", "Acceptance notes"), print-pages.mdx, the dev report. Not stated in: the changeset (must-fix 1).
  • What exactly happens on that road: the print runs in full first (session minted and revoked, Chromium render), then the door discards the PDF and answers 502. Nothing is stored, so the failure is loud and leaves no state behind. Each click costs one render.
  • Consumers that break:
    • showcase GenerateInvoicePdfAction (examples/app-showcase/src/ui/actions/index.ts): 502 whenever a print engine is configured. Its jsdoc ("attach it to the invoice", "a record they may not edit (attaching needs it)"), its successMessage, the zh translation PDF 已附加到发票。, and the comments at invoice-document.page.ts line 9 and invoice.object.ts line 63 are now false. Declared by the dev as left for the follow-up.
    • HotCRM's Print Quote action: 502. HotCRM's quote_print_presented flow: never fires (declared, ruled).
    • The MCP action door: the same 502. A caller that used the action over MCP to archive a PDF loses that with no replacement.
    • Undeclared: the console's direct-fetch road. A type: 'api' click that names no declared object action (an inline page action:button, an object-less declared action, a standalone action row) is fetched by the browser, and useConsoleActionRuntime.tsx reads a non-JSON 2xx as {} and reports success. The user sees the success toast and gets no file. This silent case is in none of the PR's texts.
    • Any external HTTP caller reading { fileId, attachmentId }: declared in the changeset.
  • Security-relevant change: who may print widens to every reader of the record. The files opt-in and the attach gate (assertMayAttach: attachment create plus edit access to the parent) are gone. The ruling does not say who may print; it rules that nothing is attached, and those two gates guarded the attachment. Dropping them is the consequence, not an extra decision, and the PR's speed-read states it to the maintainer in plain words. No data reaches a reader beyond what they already read: the page is rendered under a session minted for the caller, the file name is built from the caller's own read, and the same print page is already printable from the reader's browser. The allowExport axis is the bulk-export grant on GET /data/:object/export and is not engaged by a one-record print. The human-principal refusal and the impersonation refusal are intact. Two notes, not findings: a render can now be asked by any reader on any object with a print page, with no rate limit added; and the PDF's size is no longer bounded by the upload limit, only by the 30 s render budget. The maintainer's approval of this PR is where the widening is confirmed.
  • Dev open question (how a declared action delivers a file, options A–D): already escalated to the maintainer; none of the options is in this diff and this record does not choose one. One fact for option A: Content-Disposition is not in DEFAULT_CORS_EXPOSE_HEADERS (plugin-hono-server/src/adapter.ts), so a cross-origin console could not read the file name.
  • Landing order (seat and maintainer): AGENTS.md Post-Task step 4 says a removal that breaks ui/ ships with the ui/ fix or does not ship. Type Check UI is green, so the letter holds; in substance the console's only print road breaks at run time until the follow-up lands. The 502 is not a finding against this diff; the texts that misstate it are (must-fix 1 and 2).
  • Must-fix 2 (PR body, no head change): the body claims more than the head delivers. Speed-read bullet 1 says a user who clicks "Generate PDF" on the record page now downloads the PDF; bullet 3 says that click errors. Bullet 1 is false at this head. And Fixes #38894 closes a card whose ruled outcome is "the record-page "generate PDF" action downloads the PDF", which this PR alone does not deliver; the dev report itself is needs_decision and flags the keyword.
  • Dev's surface breach: each extra file is forced by the change (plugin wiring, the dropped dependency and lockfile lines, the tests that asserted the old attachment, the matrix row). Accepted.
  • Dev's out-of-scope finding (duplicate Content-Disposition builder): acknowledged; no card needed for correctness.
  • SQL push-down check: no new id materialisation and no in-app join. The diff removes a service call; the one read stays findOne by id.
  • Author: objectstack-fleet[bot]. PR is draft, auto-merge not armed, claim 7338965508 names this head.

④ Design judgment

  • packages/spec/src/contracts/print-door-service.ts (the hits file): holds. Comment-only; the prose now matches the door (200 PDF, JSON refusals) and drops the sentence that a console action reaches the door as a type: 'api' action, which is correct at this head.
  • The narrowing against the ruling: it takes away (a) the archive, ruled; (b) the JSON answer, ruled ("the rendered PDF goes back to the caller as the download"); (c) the files opt-in and attach gate, the consequence of (a); (d) the declared-action road, not ruled. The ruling's sentence is that the record-page action downloads; here it answers 502. The diff is the service and route half of the ruling, done correctly; the user-facing half is open.
  • Minimal: yes. Renaming the verb with its result is the right call: a stale caller fails at its own call instead of reading undefined. The attach path, the storage dependency and the FILES_DISABLED code are removed rather than left dormant. The additions are sendPdf, the header builder and the 255 bound. No option of the open decision was pre-built.
  • Tests assert the substance: the engine double traps every write verb; the dogfood suite counts sys_file and sys_attachment before and after on the real stack, proves the read-only auditor prints (with controls that the auditor reads and cannot edit), and proves the RLS-hidden 404 with no mint.
  • Local runs (scratch worktree /tmp/l2-39076 at the head; every command and its exit):
    • record-recognisers.mjs --template --paths …: exit 1 on the first try (the path list was empty because FETCH_HEAD in the shared checkout had been moved by another session), exit 0 on the rerun. Every reading after that names the sha.
    • git worktree add /tmp/l2-39076 f184414b…: exit 0. pnpm install --offline --frozen-lockfile --ignore-scripts: exit 0.
    • service-print vitest run: exit 1 twice before any build (unresolved @objectstack/spec/meta-spelling, then @objectstack/metadata-core: no dist in a fresh worktree, not a fault of the head).
    • pnpm --filter @objectstack/spec build: exit 0. turbo run build --filter='@objectstack/service-print...': exit 0 (8 tasks, replayed from the shared worktree cache).
    • service-print vitest run --maxWorkers=2 at the head: exit 0, 9 files / 139 passed. Matches the dev.
    • Probe file src/l2-probe.test.ts (untracked, deleted after): exit 0, 4 passed; readings in ① 3, 4 and 5.
    • Ablation 1 (sendPdf replaced by a 201 JSON sendOk): exit 1, 4 failed / 135 passed (three in print-routes.test.ts, one in print-door-member.test.ts). Matches the dev. Restored; blob 35cf3c35 equals the head's.
    • Ablation 2 (files opt-in and an edit read re-added after the caller's read): exit 1, 3 failed / 136 passed in print-service.test.ts. Restored; blob 78dcfbba equals the head's. The dev reports 5 red with his variant; mine differs in shape, and both variants turn the suite red.
    • turbo run build --filter='@objectstack/dogfood^...': exit 0 (79 tasks, all cached). The four print dogfood files at the head: exit 0, 3 files passed and 1 skipped, 17 tests passed and 8 skipped (print-service-render needs a built console; CI's battery shards are the reading for it).
    • Ablation 2b (an edit gate asked of the real engine, print-service-archive.dogfood.test.ts): exit 1, 1 failed / 11 passed; the red test is "a reader who can read the invoice but may not edit it prints it". Restored; blob equals the head's.
    • Comment-stripped comparison of the spec and runtime files: exit 0, identical.
    • git worktree remove --force /tmp/l2-39076: exit 0; git status in the worktree was clean before removal; scratch logs deleted.

Findings

Must-fix

  1. .changeset/38894-print-downloads-no-attachment.md: remove or correct "The record page's "generate PDF" is now a download", and add the action-door consequence with its FROM → TO: a declared type: 'api' action whose target is /api/v1/print/records used to answer the stored file's ids and is now answered 502 by the REST and MCP action doors; a click the console fetches directly is reported as success with no file; a browser gets the PDF only by calling the route itself. Say that no declared-action road delivers the file yet. (A changeset-only edit: the delta round is the changeset.)
  2. PR body (seat-owned, no head change): correct speed-read bullet 1 so it does not say the record-page click downloads; replace Fixes #38894 with Part of #38894 unless the console delivery lands in this same PR.

Should-fix

  1. print-service.ts validateRequest / print-routes.ts pdfContentDisposition: a filename holding a lone surrogate costs a full render and then answers 500 "No response from handler". Refuse an ill-formed name at step ③ (VALIDATION_ERROR / 400), or make the builder total (toWellFormed), and pin it with a test. The default-name path has the same exposure if a display value ever holds one.
  2. Texts that now contradict the contract: content/docs/permissions/system-context.mdx line 199 names the removed printRecordToFile and says a record is "archived"; print-service-plugin.ts class jsdoc (in a hunk this PR edits) still says an app declares a type: 'api' action whose target is the door; print-routes.ts PRINT_RECORDS_ROUTE comment says the console's declared actions name it; print-route-ledger.ts line 51 and packages/runtime/src/route-ledger.ts line 751 say "archive it on the record" and that a console type: 'api' action targets it.
  3. The showcase's GenerateInvoicePdfAction and its texts (listed under ③) must travel with the follow-up card, named there, or be corrected here; the seat files the card before ACCEPT.

Nits

  1. print-door-member.test.ts: the "binary tail" payload is valid UTF-8 (Buffer.from of a string encodes U+00FF as c3 bf), so a text round-trip would pass it. Use raw bytes that are not valid UTF-8.
  2. No test drives a PDF answer through the runtime dispatcher's /print domain; the two halves are pinned separately.
  3. The 255 bound is tested at 259 only; 255 accepted and 256 refused are unpinned.
  4. print-service-archive.dogfood.test.ts: the last "control" (the attacher's own sys_attachment insert refused) no longer controls anything a print does.
  5. scripts/check-route-envelope.mjs line 282: the comment says every body is written by sendOk / sendError / sendServerFault; the success body is now res.send.
  6. print-pages.mdx: the section "Print from the console" now describes no console road.
  7. The unit pin for "edit access is never asked" is findOne called once; the dogfood auditor test is the real proof.

Implemented-by: claude/issue-38894-print-download-only
Reviewed-by: session_01QSeKYnrQ7UMtHofKQVjcH2

VERDICT: FAIL

…ut the action-door gap

A request filename holding a lone UTF-16 surrogate is refused
VALIDATION_ERROR / 400 before any render, and the download header builder
is total (a lone surrogate becomes U+FFFD). The changeset, the print docs,
the route ledgers, the plugin and route comments, the system-context table
and the showcase's print action texts now state that a declared type:'api'
print action is answered 502 by the REST and MCP action doors, and that the
console's direct-fetch road reports success with no file.

Claude-Session: https://claude.ai/code/session_01QSeKYnrQ7UMtHofKQVjcH2
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2

Contract-review-claim: session_01QSeKYnrQ7UMtHofKQVjcH2 · head 2125d13 · 2026-12-02T09:01Z

Delta of record 7339311892 (FAIL), on the fix round reported in 7340216795. The seat patched the PR body with the dev's measured text (Part of #38894; read-back identical, 9872 bytes).

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 2125d139757fe3030f159474dfb3efc58741593d
Local-runs: probe — the delta brief orders ablations 1 and 2 re-run and the fix round's refusal and header builder measured; scratch worktree at the head by explicit sha, removed afterwards (commands and exits under ④)
Scope: packages/spec/src/contracts/print-door-service.ts + packages/services/service-print/src/print-service.ts, packages/services/service-print/src/print-routes.ts, packages/services/service-print/src/print-service-plugin.ts, packages/services/service-print/src/print-route-ledger.ts, packages/services/service-print/src/index.ts, packages/services/service-print/package.json, packages/services/service-print/README.md, packages/services/service-print/src/print-service.test.ts, packages/services/service-print/src/print-routes.test.ts, packages/services/service-print/src/print-door-member.test.ts, packages/services/service-print/src/print-service-plugin.test.ts, packages/services/service-print/src/print-service-plugin.revoke-log.test.ts, packages/runtime/src/domains/print.ts, packages/runtime/src/route-ledger.ts, packages/qa/dogfood/test/authz-conformance.matrix.ts, packages/qa/dogfood/test/print-service-archive.dogfood.test.ts, packages/qa/dogfood/test/print-service-named-page.dogfood.test.ts, packages/qa/dogfood/test/print-service-render.dogfood.test.ts, packages/qa/dogfood/test/print-door-impersonation.dogfood.test.ts, examples/app-showcase/src/ui/actions/index.ts, examples/app-showcase/src/system/translations/index.ts, examples/app-showcase/src/ui/pages/invoice-document.page.ts, examples/app-showcase/src/data/objects/invoice.object.ts, pnpm-lock.yaml

Delta of record 7339311892 (FAIL at f184414b5b), on the fix round the dev reported in 7340216795 and the PR body the seat patched. Same faces: the Clause-②: yes (narrowing) declaration and the published-schema face. What moved since the reviewed head: two fix commits (e385bd27cf, e6f2f8d211: 14 files) and two clean merges of origin/main (1ecc795a8f, 2125d13975). The PR's own diff against the new merge-base 356b8744af is 28 files. Unchanged since the reviewed head, blob for blob: the spec file, packages/runtime/src/domains/print.ts, service-print/src/index.ts, package.json and every dogfood file. The first record's judgments on those stand (no attachment and no marker, the read gate and the RLS-hidden 404, the member and the mount answering the same bytes, the hosted path, the spec file being jsdoc only). The lockfile's PR diff is still the three removed service-storage lines.

① Derived judgments

  1. Lone surrogate: refused 400 at validation, before any render. Closed. validateRequest (step ③) now refuses a request filename for which hasLoneSurrogate is true, with VALIDATION_ERROR / 400. Measured through the real HonoHttpServer table over the real PrintService: JSON "\ud83d.pdf", "a\udc00.pdf", a lone high before a pair and a lone low after a pair all answer 400 in the error envelope with no mint and no render; a paired surrogate ("😀.pdf") answers 200 with filename*=UTF-8''%F0%9F%98%80.pdf.
  2. The header builder is total. Closed. pdfContentDisposition passes the name through toWellFormedText first, and safeFileBase does the same for a display value. Measured: a record whose display value holds a lone surrogate prints 200 with filename="Q_-7.pdf"; filename*=UTF-8''Q%EF%BF%BD-7.pdf and the bytes unchanged. Over 20,000 generated strings of surrogates, quotes, backslash, CR, LF and CJK, the builder never throws, the value stays printable ASCII with exactly two quotes, and the two helpers agree with the engine's own toWellFormed on every string. The quoting judged sound in the first record is untouched.
  3. Stale texts: all five corrected, and each now says what the code does.
    • content/docs/permissions/system-context.mdx row 47d names printRecordToPdf and says the PDF is handed back to the requesting user and nothing is stored.
    • print-service-plugin.ts class jsdoc says a declared type: 'api' action cannot carry the download yet and why.
    • The PRINT_RECORDS_ROUTE comment no longer says the console's declared actions name it.
    • print-route-ledger.ts and packages/runtime/src/route-ledger.ts notes say the door answers the PDF, stores nothing, and that the action door answers such a forward 502.
    • Whole-repo grep at the head for printRecordToFile, PrintedRecordFile, "archive it on the record", "archives the PDF", "PDF is attached" and the old zh string: no hit outside changelogs and changesets.
  4. Showcase: texts corrected, wiring untouched. In examples/app-showcase/src/ui/actions/index.ts the only non-comment line that changed is successMessage; type, target, method, recordIdParam, bodyExtra, locations and refreshAfter are as they were, and enable: { files: true } stays on the invoice. The jsdoc now warns that the action does not deliver the PDF yet. The zh message and the two comments (page, object) no longer promise an attachment. test/invoice-generate-pdf-action.test.ts: 4 passed.
  5. print-pages.mdx additionally states the MCP door's 502, the direct-fetch success with no file, that no declared console action delivers the download yet, and both filename refusals. Each claim matches the code read for the first record.

② Semver level

  • Must-fix 1 (changeset): closed. The banner now reads "a print no longer attaches the PDF to the record, and no declared console action delivers the file yet"; the sentence that the record page's "generate PDF" is a download is gone. A new section, "Apps that declare a print action", states: the REST and MCP action doors answer a non-JSON 2xx with their own 502, naming the showcase's GenerateInvoicePdfAction and HotCRM's Print Quote, with the print rendered and then discarded; the console's direct-fetch road reports success with no file; and a FROM → TO line for such an app (it used to answer the stored file's ids and leave the PDF on the record; it now errors or, on the direct-fetch road, reports success with no file), with the interim fix (call the route directly with the same body, or hide the action). Each statement matches forwardApiAction and useConsoleActionRuntime.tsx as read for the first record.
  • Unchanged and still right: patch, the BREAKING banner, both declaration lines line-initial, the two FROM → TO lines for the verb and the type, the HotCRM quote_print_presented sentence, exactly one ADR-0087 marker (runtime-export-retired, the same two operands). The filename bullet now also names the well-formed-text refusal.
  • The dev's question — the frontmatter does not name @objectstack/runtime: acceptable as it is; the line need not be added.
    • .changeset/config.json puts @objectstack/runtime, @objectstack/spec and @objectstack/service-print in one fixed group, so the patch bump versions and publishes all three whichever is named.
    • No gate asks for more: check-changeset-fixed.mjs checks group membership only, and Check Changeset was green on the reviewed head, where the spec and runtime jsdoc edits were already unnamed.
    • Metadata-protocol: none, so no level rides on which package is named.
    • The only thing a second line would change is whose CHANGELOG.md prints the entry. The runtime edit is one ledger note; a runtime consumer has nothing to do, and the BREAKING text belongs under the package whose door it describes.
    • Practice in the tree is mixed (836 of 1579 changesets name one package; 托管云端「打印报价」报 Route Not Found: /print/records:打印服务未启用(18.6.0) #36840's named three), so neither spelling is a deviation. Adding the line would be harmless; it is not owed.
  • Skills-docs: none still present in the PR body and still true (the fix round touched no skill and no skill teaches the print door).

③ Boundary flags

  • Must-fix 2 (PR body): closed. The first line is Part of #38894, naming the half that stays open on the card; no closing keyword remains in the body. Speed-read bullet 1 now says a direct caller gets the PDF and the record-page button errors until the delivery is decided; bullet 3 agrees and adds the direct-fetch case. The readings block names this head.
  • The 502 gap is now stated in every text that ships: the changeset, print-pages.mdx, both route ledgers, the plugin jsdoc and the showcase action. It remains what it was: a landing-order question for the seat and the maintainer, not a finding against this diff. The card stays open for the record-page half.
  • Dev open question 1 (how a declared action delivers a file, options A–D): with the maintainer; not chosen here. Dev open question 2 (the runtime frontmatter line): answered under ②, leave as is.
  • Dev's out-of-scope note on printPageUrl, corrected on one point. The note says each segment it encodes is reached only after a lookup found that exact string. That holds for object, recordId and page; it does not hold for app, which nothing looks up. Measured: a request whose app holds a lone surrogate answers 500 INTERNAL_ERROR with the door's own sentence, with no mint and no render. This is unchanged from main (the function is not in the diff), costs nothing, and discloses nothing: nit 6, for a follow-up or the seat's nit carrier.
  • Security: nothing new. The added refusal only narrows what a request may carry; the first record's reading of the read-only widening stands and still waits on the maintainer's approval.
  • SQL push-down check: the fix round adds no read, no id materialisation and no in-app join.
  • Merges: two merges of origin/main, no force-push; neither resolved a conflict in a print path.
  • State: author objectstack-fleet[bot]; draft; auto-merge not armed; claim 7340272726 on the PR.

④ Design judgment

  • The fix has the right shape. Two layers, each where it belongs: a name the caller typed is refused before anything is spent, and a name the caller did not type (a record's display value) cannot be refused on their behalf, so the builder is made total instead. toWellFormedText is spelled out by hand for the ES2020 library and is measured equal to the native method.
  • Minimal: the code change is one regular expression, two small helpers, one refusal and one call in each of safeFileBase and pdfContentDisposition. Nothing of the open decision was pre-built, and the showcase wiring was left for it.
  • The spec hits file is byte-identical to the reviewed head; the first record's judgment stands.
  • Tests assert the substance: four new tests pin the refusal in both suites (with a paired-surrogate control), the total builder, the default-name path, and the bound at 255 accepted / 256 refused (the first record's nit 3, now closed).
  • Local runs (scratch worktree /tmp/l2-39076d at 2125d13975, every command and its exit):
    • git fetch origin claude/issue-38894-print-download-only: exit 0; the branch ref resolved to the head sha. git worktree add /tmp/l2-39076d 2125d139…: exit 0. pnpm install --offline --frozen-lockfile --ignore-scripts: exit 0. turbo run build --filter='@objectstack/service-print...': exit 0 (7 tasks, all cached).
    • service-print vitest run --maxWorkers=2 at the head, five runs: four exit 0 with 9 files / 143 passed; one exit 1 with 143 passed and one unhandled error whose text began Error: targetInfo:. Not reproduced in the four other runs; I did not capture its source. The Chromium driver files are not in this diff. Reported as observed, not attributed.
    • Probe file src/l2-probe.test.ts (untracked, deleted after): exit 0, 4 passed; readings in ① 1 and 2 and in ③.
    • Ablation 1 (sendPdf replaced by a 201 JSON sendOk): exit 1, 4 failed / 139 passed (three in print-routes.test.ts, one in print-door-member.test.ts). Restored; blob c278c82c equals the head's.
    • Ablation 2 (files opt-in and an edit read re-added after the caller's read): exit 1, 3 failed / 140 passed in print-service.test.ts. Restored; blob 110124f5 equals the head's.
    • Ablation 3 (the lone-surrogate refusal disabled): exit 1, 2 failed / 141 passed, one per suite. Restored.
    • Ablation 4 (toWellFormedText removed from the builder): exit 1, 1 failed / 142 passed. Restored.
    • turbo run build --filter='@objectstack/dogfood^...': exit 0 (79 tasks, all cached). The four print dogfood files at the head: exit 0, 3 files passed and 1 skipped, 17 tests passed and 8 skipped (print-service-render needs a built console; CI's battery is the reading).
    • Ablation 2b (an edit gate asked of the real engine, print-service-archive.dogfood.test.ts): exit 1, 1 failed / 11 passed; the red test is the read-only auditor's print. Restored; blob equals the head's. The dev reports 5 red with a broader variant; both turn the file red.
    • examples/app-showcase vitest run test/invoice-generate-pdf-action.test.ts: exit 0, 4 passed.
    • git status clean and git diff HEAD empty before git worktree remove --force /tmp/l2-39076d: exit 0; scratch logs deleted.
  • Check-runs at the head (REST, read 2026-12-02T09:14Z, after the last one completed): 81 check-runs, 70 success, 11 skipped, none failed, none pending. Among the green: both Check Changeset runs, Lint · CI, release & engine gates (the ADR-0087 registration gate), Type Check UI, every Test Core and Test UI shard, and the dogfood battery with its three shards. The skipped ones are the opt-in and queue-only jobs (18.x upgrade harness, packed-tarball smoke, queue verdicts, Temporal conformance and the like).

Findings

Must-fix: none open. Both of the first record's are closed (changeset; PR body).

Should-fix: none open. All three of the first record's are closed (lone surrogate; stale texts; showcase texts).

Nits (no effect on correctness or the contract; accepted as they stand, carried by the seat)

  1. print-door-member.test.ts: the "binary tail" payload is valid UTF-8, so a text round-trip would pass it. My probes with bytes that are not valid UTF-8 pass on both faces.
  2. No test drives a PDF answer through the runtime dispatcher's /print domain end to end.
  3. print-service-archive.dogfood.test.ts: the last "control" no longer controls anything a print does.
  4. scripts/check-route-envelope.mjs line 282: the comment still says every body is written by sendOk / sendError / sendServerFault.
  5. The unit pin for "edit access is never asked" is findOne called once; the dogfood auditor test is the real proof.
  6. A lone surrogate in app answers 500 from printPageUrl before the mint (unchanged from main); a 400 at validation would be the tidier answer.

Implemented-by: claude/issue-38894-print-download-only
Reviewed-by: session_01QSeKYnrQ7UMtHofKQVjcH2

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2

L1 ACCEPT · PR #39076 (#38894) · head 2125d139757fe3030f159474dfb3efc58741593d · read 2026-12-02T09:16Z

席位核对 · ACCEPT

ACCEPT · repo:objectstack@os-justin · head 2125d139757fe3030f159474dfb3efc58741593d

  1. Shape. Draft, base main. The first line reads Part of #38894 and names the open half: how a declared console action delivers the PDF waits on the maintainer. No closing keyword. On landing, pm:dispatched stays on Print: the PDF a print attaches carries no print-origin marker, so an app that reacts to a print must key on the file name, which #36801 changed #38894 until that half ships (landing rule B).
  2. Ruling delivered (service and route half). Ruling 7336681739 is delivered: a print writes no attachment and no marker, and POST /api/v1/print/records and the door member answer the PDF.
  3. Contract record. Delta PASS 7340628991 at this head (CONTRACT_REVIEW_TIER), on the FAIL 7339311892. Both must-fix items and all three should-fix items are closed and measured; ablations 1, 2 and 2b reproduce; the two new guards ablate red.
  4. Changeset, read sentence by sentence. The changeset no longer claims that the record page downloads. It states the REST and MCP 502 and the direct-fetch success with no file, gives FROM → TO for apps declaring a print action and the HotCRM line, and keeps BREAKING, both declaration lines and one runtime-export-retired marker. The runtime frontmatter question is settled by the record: the fixed group carries it, and no line is owed.
  5. Gates (check-runs at this head). 81 runs: 70 success, 11 skipped, 0 failed, 0 pending. Lint & Repo Gates and TypeScript Type Check: success. Dogfood battery (opt-in) and all three shards: success.
  6. Accepted deviations. These files are outside the claimed surface, each forced by the change: plugin wiring, package.json/lock (the service-storage dependency is dropped), the authz matrix row, the dogfood print tests, the system-context page, both route-ledger notes and the showcase texts. The seat approved the last three for the fix round.
  7. Out of scope / nits carried. Six nits are listed in the record. The most notable: a lone surrogate in app reaches printPageUrl and answers 500, which is unchanged from main.
  8. Landing. This is a declared narrowing (Clause-②: yes (narrowing)), so it is handed to the maintainer and the seat does not enqueue it. git merge-tree against current main is clean. Seat recommendation: hold until the maintainer rules on how an action delivers a file. Landing this alone turns the showcase GenerateInvoicePdfAction and HotCRM's Print Quote into a 502 until that follow-up ships.

Clause-②: yes (narrowing) · Metadata-protocol: none

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 2125d139757fe3030f159474dfb3efc58741593d
Local-runs: probe — the delta brief orders ablations 1 and 2 re-run and the fix round's refusal and header builder measured; scratch worktree at the head by explicit sha, removed afterwards (commands and exits under ④)
Scope: packages/spec/src/contracts/print-door-service.ts + packages/services/service-print/src/print-service.ts, packages/services/service-print/src/print-routes.ts, packages/services/service-print/src/print-service-plugin.ts, packages/services/service-print/src/print-route-ledger.ts, packages/services/service-print/src/index.ts, packages/services/service-print/package.json, packages/services/service-print/README.md, packages/services/service-print/src/print-service.test.ts, packages/services/service-print/src/print-routes.test.ts, packages/services/service-print/src/print-door-member.test.ts, packages/services/service-print/src/print-service-plugin.test.ts, packages/services/service-print/src/print-service-plugin.revoke-log.test.ts, packages/runtime/src/domains/print.ts, packages/runtime/src/route-ledger.ts, packages/qa/dogfood/test/authz-conformance.matrix.ts, packages/qa/dogfood/test/print-service-archive.dogfood.test.ts, packages/qa/dogfood/test/print-service-named-page.dogfood.test.ts, packages/qa/dogfood/test/print-service-render.dogfood.test.ts, packages/qa/dogfood/test/print-door-impersonation.dogfood.test.ts, examples/app-showcase/src/ui/actions/index.ts, examples/app-showcase/src/system/translations/index.ts, examples/app-showcase/src/ui/pages/invoice-document.page.ts, examples/app-showcase/src/data/objects/invoice.object.ts, pnpm-lock.yaml

Delta of record 7339311892 (FAIL at f184414b5b), on the fix round the dev reported in 7340216795 and the PR body the seat patched. Same faces: the Clause-②: yes (narrowing) declaration and the published-schema face. What moved since the reviewed head: two fix commits (e385bd27cf, e6f2f8d211: 14 files) and two clean merges of origin/main (1ecc795a8f, 2125d13975). The PR's own diff against the new merge-base 356b8744af is 28 files. Unchanged since the reviewed head, blob for blob: the spec file, packages/runtime/src/domains/print.ts, service-print/src/index.ts, package.json and every dogfood file. The first record's judgments on those stand (no attachment and no marker, the read gate and the RLS-hidden 404, the member and the mount answering the same bytes, the hosted path, the spec file being jsdoc only). The lockfile's PR diff is still the three removed service-storage lines.

① Derived judgments

  1. Lone surrogate: refused 400 at validation, before any render. Closed. validateRequest (step ③) now refuses a request filename for which hasLoneSurrogate is true, with VALIDATION_ERROR / 400. Measured through the real HonoHttpServer table over the real PrintService: JSON "\ud83d.pdf", "a\udc00.pdf", a lone high before a pair and a lone low after a pair all answer 400 in the error envelope with no mint and no render; a paired surrogate ("😀.pdf") answers 200 with filename*=UTF-8''%F0%9F%98%80.pdf.
  2. The header builder is total. Closed. pdfContentDisposition passes the name through toWellFormedText first, and safeFileBase does the same for a display value. Measured: a record whose display value holds a lone surrogate prints 200 with filename="Q_-7.pdf"; filename*=UTF-8''Q%EF%BF%BD-7.pdf and the bytes unchanged. Over 20,000 generated strings of surrogates, quotes, backslash, CR, LF and CJK, the builder never throws, the value stays printable ASCII with exactly two quotes, and the two helpers agree with the engine's own toWellFormed on every string. The quoting judged sound in the first record is untouched.
  3. Stale texts: all five corrected, and each now says what the code does.
    • content/docs/permissions/system-context.mdx row 47d names printRecordToPdf and says the PDF is handed back to the requesting user and nothing is stored.
    • print-service-plugin.ts class jsdoc says a declared type: 'api' action cannot carry the download yet and why.
    • The PRINT_RECORDS_ROUTE comment no longer says the console's declared actions name it.
    • print-route-ledger.ts and packages/runtime/src/route-ledger.ts notes say the door answers the PDF, stores nothing, and that the action door answers such a forward 502.
    • Whole-repo grep at the head for printRecordToFile, PrintedRecordFile, "archive it on the record", "archives the PDF", "PDF is attached" and the old zh string: no hit outside changelogs and changesets.
  4. Showcase: texts corrected, wiring untouched. In examples/app-showcase/src/ui/actions/index.ts the only non-comment line that changed is successMessage; type, target, method, recordIdParam, bodyExtra, locations and refreshAfter are as they were, and enable: { files: true } stays on the invoice. The jsdoc now warns that the action does not deliver the PDF yet. The zh message and the two comments (page, object) no longer promise an attachment. test/invoice-generate-pdf-action.test.ts: 4 passed.
  5. print-pages.mdx additionally states the MCP door's 502, the direct-fetch success with no file, that no declared console action delivers the download yet, and both filename refusals. Each claim matches the code read for the first record.

② Semver level

  • M1: closed (changeset). The banner now reads "a print no longer attaches the PDF to the record, and no declared console action delivers the file yet"; the sentence that the record page's "generate PDF" is a download is gone. A new section, "Apps that declare a print action", states: the REST and MCP action doors answer a non-JSON 2xx with their own 502, naming the showcase's GenerateInvoicePdfAction and HotCRM's Print Quote, with the print rendered and then discarded; the console's direct-fetch road reports success with no file; and a FROM → TO line for such an app (it used to answer the stored file's ids and leave the PDF on the record; it now errors or, on the direct-fetch road, reports success with no file), with the interim fix (call the route directly with the same body, or hide the action). Each statement matches forwardApiAction and useConsoleActionRuntime.tsx as read for the first record.
  • Unchanged and still right: patch, the BREAKING banner, both declaration lines line-initial, the two FROM → TO lines for the verb and the type, the HotCRM quote_print_presented sentence, exactly one ADR-0087 marker (runtime-export-retired, the same two operands). The filename bullet now also names the well-formed-text refusal.
  • The dev's question — the frontmatter does not name @objectstack/runtime: acceptable as it is; the line need not be added.
    • .changeset/config.json puts @objectstack/runtime, @objectstack/spec and @objectstack/service-print in one fixed group, so the patch bump versions and publishes all three whichever is named.
    • No gate asks for more: check-changeset-fixed.mjs checks group membership only, and Check Changeset was green on the reviewed head, where the spec and runtime jsdoc edits were already unnamed.
    • Metadata-protocol: none, so no level rides on which package is named.
    • The only thing a second line would change is whose CHANGELOG.md prints the entry. The runtime edit is one ledger note; a runtime consumer has nothing to do, and the BREAKING text belongs under the package whose door it describes.
    • Practice in the tree is mixed (836 of 1579 changesets name one package; 托管云端「打印报价」报 Route Not Found: /print/records:打印服务未启用(18.6.0) #36840's named three), so neither spelling is a deviation. Adding the line would be harmless; it is not owed.
  • Skills-docs: none still present in the PR body and still true (the fix round touched no skill and no skill teaches the print door).

③ Boundary flags

  • M2: closed (PR body). The first line is Part of #38894, naming the half that stays open on the card; no closing keyword remains in the body. Speed-read bullet 1 now says a direct caller gets the PDF and the record-page button errors until the delivery is decided; bullet 3 agrees and adds the direct-fetch case. The readings block names this head.
  • The 502 gap is now stated in every text that ships: the changeset, print-pages.mdx, both route ledgers, the plugin jsdoc and the showcase action. It remains what it was: a landing-order question for the seat and the maintainer, not a finding against this diff. The card stays open for the record-page half.
  • Dev open question 1 (how a declared action delivers a file, options A–D): with the maintainer; not chosen here. Dev open question 2 (the runtime frontmatter line): answered under ②, leave as is.
  • Dev's out-of-scope note on printPageUrl, corrected on one point. The note says each segment it encodes is reached only after a lookup found that exact string. That holds for object, recordId and page; it does not hold for app, which nothing looks up. Measured: a request whose app holds a lone surrogate answers 500 INTERNAL_ERROR with the door's own sentence, with no mint and no render. This is unchanged from main (the function is not in the diff), costs nothing, and discloses nothing: nit 6, for a follow-up or the seat's nit carrier.
  • Security: nothing new. The added refusal only narrows what a request may carry; the first record's reading of the read-only widening stands and still waits on the maintainer's approval.
  • SQL push-down check: the fix round adds no read, no id materialisation and no in-app join.
  • Merges: two merges of origin/main, no force-push; neither resolved a conflict in a print path.
  • State: author objectstack-fleet[bot]; draft; auto-merge not armed; claim 7340272726 on the PR.

④ Design judgment

  • The fix has the right shape. Two layers, each where it belongs: a name the caller typed is refused before anything is spent, and a name the caller did not type (a record's display value) cannot be refused on their behalf, so the builder is made total instead. toWellFormedText is spelled out by hand for the ES2020 library and is measured equal to the native method.
  • Minimal: the code change is one regular expression, two small helpers, one refusal and one call in each of safeFileBase and pdfContentDisposition. Nothing of the open decision was pre-built, and the showcase wiring was left for it.
  • The spec hits file is byte-identical to the reviewed head; the first record's judgment stands.
  • Tests assert the substance: four new tests pin the refusal in both suites (with a paired-surrogate control), the total builder, the default-name path, and the bound at 255 accepted / 256 refused (the first record's nit 3, now closed).
  • Local runs (scratch worktree /tmp/l2-39076d at 2125d13975, every command and its exit):
    • git fetch origin claude/issue-38894-print-download-only: exit 0; the branch ref resolved to the head sha. git worktree add /tmp/l2-39076d 2125d139…: exit 0. pnpm install --offline --frozen-lockfile --ignore-scripts: exit 0. turbo run build --filter='@objectstack/service-print...': exit 0 (7 tasks, all cached).
    • service-print vitest run --maxWorkers=2 at the head, five runs: four exit 0 with 9 files / 143 passed; one exit 1 with 143 passed and one unhandled error whose text began Error: targetInfo:. Not reproduced in the four other runs; I did not capture its source. The Chromium driver files are not in this diff. Reported as observed, not attributed.
    • Probe file src/l2-probe.test.ts (untracked, deleted after): exit 0, 4 passed; readings in ① 1 and 2 and in ③.
    • Ablation 1 (sendPdf replaced by a 201 JSON sendOk): exit 1, 4 failed / 139 passed (three in print-routes.test.ts, one in print-door-member.test.ts). Restored; blob c278c82c equals the head's.
    • Ablation 2 (files opt-in and an edit read re-added after the caller's read): exit 1, 3 failed / 140 passed in print-service.test.ts. Restored; blob 110124f5 equals the head's.
    • Ablation 3 (the lone-surrogate refusal disabled): exit 1, 2 failed / 141 passed, one per suite. Restored.
    • Ablation 4 (toWellFormedText removed from the builder): exit 1, 1 failed / 142 passed. Restored.
    • turbo run build --filter='@objectstack/dogfood^...': exit 0 (79 tasks, all cached). The four print dogfood files at the head: exit 0, 3 files passed and 1 skipped, 17 tests passed and 8 skipped (print-service-render needs a built console; CI's battery is the reading).
    • Ablation 2b (an edit gate asked of the real engine, print-service-archive.dogfood.test.ts): exit 1, 1 failed / 11 passed; the red test is the read-only auditor's print. Restored; blob equals the head's. The dev reports 5 red with a broader variant; both turn the file red.
    • examples/app-showcase vitest run test/invoice-generate-pdf-action.test.ts: exit 0, 4 passed.
    • git status clean and git diff HEAD empty before git worktree remove --force /tmp/l2-39076d: exit 0; scratch logs deleted.
  • Check-runs at the head (REST, read 2026-12-02T09:14Z, after the last one completed): 81 check-runs, 70 success, 11 skipped, none failed, none pending. Among the green: both Check Changeset runs, Lint · CI, release & engine gates (the ADR-0087 registration gate), Type Check UI, every Test Core and Test UI shard, and the dogfood battery with its three shards. The skipped ones are the opt-in and queue-only jobs (18.x upgrade harness, packed-tarball smoke, queue verdicts, Temporal conformance and the like).

Findings

No must-fix, no should-fix.

The first record's M1, M2 and S1–S3 are closed (changeset; PR body; lone surrogate; stale texts; showcase texts).

Nits (no effect on correctness or the contract; accepted as they stand, carried by the seat)

  1. print-door-member.test.ts: the "binary tail" payload is valid UTF-8, so a text round-trip would pass it. My probes with bytes that are not valid UTF-8 pass on both faces.
  2. No test drives a PDF answer through the runtime dispatcher's /print domain end to end.
  3. print-service-archive.dogfood.test.ts: the last "control" no longer controls anything a print does.
  4. scripts/check-route-envelope.mjs line 282: the comment still says every body is written by sendOk / sendError / sendServerFault.
  5. The unit pin for "edit access is never asked" is findOne called once; the dogfood auditor test is the real proof.
  6. A lone surrogate in app answers 500 from printPageUrl before the mint (unchanged from main); a 400 at validation would be the tidier answer.

Implemented-by: claude/issue-38894-print-download-only
Reviewed-by: session_01QSeKYnrQ7UMtHofKQVjcH2

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2

维护者速读

  • 是什么:按你的裁决,记录页"生成 PDF"不再把文件挂成附件,打印服务直接把 PDF 返回给调用方。这个 PR 是服务和接口那一半。
  • 为什么要你批:这是声明的收窄(Clause-②: yes (narrowing)):printRecordToFile 改名为 printRecordToPdf,返回值去掉了 attachmentId,接口从返回 JSON 改为返回 PDF 文件。
  • 风险:
    • 经过动作通道的打印按钮(示例应用的"生成发票 PDF"、HotCRM 的"打印报价单")在下载方式定下来并做完之前会报 502。直接调用接口能拿到 PDF。
    • 只能看、不能改记录的人现在也能打印。这是不挂附件带来的结果,打印内容不超出他已能看到的数据。另外,PDF 大小不再受上传限制。
    • 契约复审 PASS,CI 81 项全绿,实测(dogfood battery)通过。
  • 要你做什么:
    • 审批本 PR,head 2125d139757fe3030f159474dfb3efc58741593d。契约复审 PASS 见评论 7340628991,席位 ACCEPT 见本评论上一条。
    • 席位建议先不合:等你定下"动作怎么交付下载"(推荐 A:动作通道放行文件下载、控制台存成文件),和那一半一起上线,避免中间出现打印按钮 502 的空窗期。

Head-sha: 2125d139757fe3030f159474dfb3efc58741593d

@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Dec 2, 2026
@objectstack-fleet
objectstack-fleet Bot requested a review from os-zhuang December 2, 2026 09:21
@os-zhuang
os-zhuang marked this pull request as ready for review December 2, 2026 11:19
@os-zhuang
os-zhuang added this pull request to the merge queue Dec 2, 2026
@os-zhuang
os-zhuang removed this pull request from the merge queue due to a manual request Dec 2, 2026
…'s PDF, and pin it end to end

The action door now relays a non-JSON attachment answer and the console
saves it, so a declared type:'api' print action downloads the PDF. The
changeset, print-pages.mdx, both route-ledger notes, the plugin jsdoc and
the showcase action's jsdoc now say so; MCP run_action still answers a
file 502. The REST door conformance suite drives a declared print action
through POST /api/v1/actions/... into the real print route and asserts
the PDF arrives with the route's Content-Disposition: attachment.

Claude-Session: https://claude.ai/code/session_01QSeKYnxn6m1nQaRrNvdiLw
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2

Contract-review-claim: session_01QSeKYnrQ7UMtHofKQVjcH2 · head 3510e8a · 2026-12-02T19:22Z

Delta record after PASS 7340755868. The same reviewer reads it at CONTRACT_REVIEW_TIER (faces: schema, narrowing), over the merge of main after #39141 and the text reconciliation (dev report 7354599560 on #38894).

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 3510e8a666f1249b078b59c568dffee19e06831d
Local-runs: probe — the brief asks whether the print route composes with #39141's relay and console reader without double handling or contradiction, which no single CI test states; scratch worktree under the session scratchpad (pr-39076/wt) at the head by explicit sha, removed afterwards (commands and exits under ④)
Scope: packages/spec/src/contracts/print-door-service.ts + packages/services/service-print/src/print-service.ts, packages/services/service-print/src/print-routes.ts, packages/services/service-print/src/print-service-plugin.ts, packages/services/service-print/src/print-route-ledger.ts, packages/services/service-print/src/index.ts, packages/services/service-print/package.json, packages/services/service-print/README.md, packages/services/service-print/src/print-service.test.ts, packages/services/service-print/src/print-routes.test.ts, packages/services/service-print/src/print-door-member.test.ts, packages/services/service-print/src/print-service-plugin.test.ts, packages/services/service-print/src/print-service-plugin.revoke-log.test.ts, packages/runtime/src/domains/print.ts, packages/runtime/src/route-ledger.ts, packages/qa/http-conformance/src/action-door-attachment-38894.conformance.test.ts, packages/qa/dogfood/test/authz-conformance.matrix.ts, packages/qa/dogfood/test/print-service-archive.dogfood.test.ts, packages/qa/dogfood/test/print-service-named-page.dogfood.test.ts, packages/qa/dogfood/test/print-service-render.dogfood.test.ts, packages/qa/dogfood/test/print-door-impersonation.dogfood.test.ts, examples/app-showcase/src/ui/actions/index.ts, examples/app-showcase/src/system/translations/index.ts, examples/app-showcase/src/ui/pages/invoice-document.page.ts, examples/app-showcase/src/data/objects/invoice.object.ts, pnpm-lock.yaml

Record written 2026-12-02T19:45Z. Delta of record 7340755868 (PASS at 2125d13975), on the round the dev reported in 7354599560 (read as claims and checked). Same faces: the Clause-②: yes (narrowing) declaration and the published-schema face.

What moved since the reviewed head, on the first-parent line:

  • Merge a0a9d69912 of origin/main at 0fff9ae00b, the commit that landed feat(runtime): the REST action door delivers a target's attachment, and the console saves it as a download #39141. It is a clean merge: git merge-tree --write-tree of the two parents gives tree 037e0211, the merge commit's own tree, so it holds no hand resolution. Two files were touched by both sides and merged by git alone: content/docs/permissions/system-context.mdx (row 47d is as the PR wrote it; main added two unrelated lines) and content/docs/ui/print-pages.mdx.
  • Reconciliation 3510e8a666: 7 files, +86 / -33. Six are texts (the changeset, print-pages.mdx, the two route-ledger notes, the plugin jsdoc, the showcase action's jsdoc) and one is a test (feat(runtime): the REST action door delivers a target's attachment, and the console saves it as a download #39141's conformance suite gains one case, run on both transports).
  • No print code moved. Blob for blob against the reviewed head: the spec file, print-service.ts, print-routes.ts, index.ts, package.json, README.md, packages/runtime/src/domains/print.ts, every service-print test, every dogfood file, the three other showcase files and the lockfile's PR diff are unchanged. The earlier records' judgments on them stand.
  • The PR's diff against the new merge-base 0fff9ae00b is 29 files (28 as before, plus the conformance test).

Code outside the diff, read and not reviewed: #39141's packages/runtime/src/action-forward-attachment.ts, forwardApiAction in action-execution.ts, the api branch of action-dispatch.ts, and the console's apiActionDoor.ts, useConsoleActionRuntime.tsx and RecordDetailView.tsx.

① Derived judgments

  1. The narrowing holds through the action door. The print route still writes nothing and still asks read access alone; feat(runtime): the REST action door delivers a target's attachment, and the console saves it as a download #39141 adds no storage and no gate of its own to a print.
    • The door's gates before the forward are the ones it ran before: the sign-in floor, requiredPermissions, the activation switch, the param contract and a caller-scoped load of the subject row. None asks edit access or enable.files, so a read-only user is not refused at the door for something the route no longer asks.
    • A caller who cannot read the record is refused either way: by the door for a perRecord action such as the showcase's (forwardsOnDeniedSubjectLoad is false for it), by the route's RECORD_NOT_FOUND / 404 otherwise.
    • The relay stores nothing: the bytes are buffered, answered and dropped. The door's invocation row is the row it writes for every action, as it did when this action answered JSON.
  2. The route's answer is exactly the one answer the door relays, and nothing is handled twice.
    • isRelayableAttachmentAnswer asks a 2xx with a body, a Content-Disposition of type attachment, and a non-JSON Content-Type. sendPdf answers 200, application/pdf and pdfContentDisposition, which always starts attachment;.
    • The door keeps four headers of the target's answer: Content-Type, Content-Disposition, Cache-Control, X-Content-Type-Options. They are the four sendPdf writes; nothing sendPdf sets is dropped, and it sets no credential header for the rotation relay to carry.
    • Measured by the new pin on both transports: the bytes are equal, and each of the four headers arrives once with the route's value (nosniff is not doubled by the standalone transport's own security headers).
    • A refusal stays a refusal: the route's JSON error envelope carries no disposition, is not relayable, and goes back under its own status. Measured (probe): the unauthenticated 401, on the member and on the mount.
    • The forward sends accept: application/json and the forward mark header; the route reads neither and answers the PDF all the same (probe).
  3. The hosted door composes too. A kernel with no http.server answers the print through IPrintDoorService.handlePrintDoor, whose Response the /print domain returns as it is. Measured (probe): that member's answer passes isRelayableAttachmentAnswer, readForwardAttachment returns its bytes unchanged (a payload that is not valid UTF-8) with the same four headers, and apiActionAttachmentResponse answers them back. A PDF of exactly 32 MiB is relayed and one byte more is not, which is the door's 502 the texts name.
  4. The console saves what the route names. attachmentFilename reads filename* first, then filename. Measured over the route's own pdfContentDisposition: INV-0001.pdf, 报价单.pdf, 发票 INV-1.pdf, a name with an apostrophe, parentheses and a percent sign, a name with a semicolon and a name with a double quote are each saved under the name the route was given. Over 20,000 generated names, 19,633 round-trip exactly, 267 are blank or control-only names (saved as _ or download), and 100 hold the literal token ;filename*=, which the reader misreads (nit 10). None of the 100 can come from a record's display value.
  5. The published-schema face is untouched. packages/spec/src/contracts/print-door-service.ts is byte-identical to the reviewed head, and feat(runtime): the REST action door delivers a target's attachment, and the console saves it as a download #39141 changed no file under packages/spec/src. The action door's answer set is not declared in spec, so the widening it made has no schema to disagree with this PR's.
  6. The merge left one contradiction, and the next commit removed it. At a0a9d69912 print-pages.mdx held both sides' paragraphs: the PR's "the action doors relay JSON answers only" and main's "the route above answers JSON, which the action reads as data". At the head both are gone, replaced by one paragraph that matches the code. Whole-repo grep at the head for the window's wording ("relay JSON answers only", "does not deliver the PDF", "no declared console action", "until the console delivers", "reports success with no file", "answered 502 there") and for the retired names: no hit outside changelogs and changesets.

② Semver level

  • Unchanged and still right: '@objectstack/service-print': patch, the BREAKING banner, both declaration lines line-initial, the two FROM → TO lines for the verb and the type, the HotCRM quote_print_presented sentence, exactly one ADR-0087 marker with the same two operands. The frontmatter question answered in record 7340755868 stands: @objectstack/runtime is in the same fixed group, and @objectstack/http-conformance is private.
  • The changeset tells the truth after feat(runtime): the REST action door delivers a target's attachment, and the console saves it as a download #39141. Each new statement, against the code:
    • "the REST action door relays a target's non-JSON 2xx answer that carries Content-Disposition: attachment byte for byte": forwardApiAction with relayAttachment, asked only when door === 'rest'.
    • "the door answers the route's bytes with its Content-Type: application/pdf and Content-Disposition: attachment, and the console saves the file under the name that header gives": the pin, and ① 4.
    • "A PDF larger than the door's 32 MiB bound is the door's 502": API_FORWARD_ATTACHMENT_MAX_BYTES, and ① 3.
    • "MCP run_action still answers a file with its own 502": only the REST door asks for files.
    • The FROM → TO for an app that declares such an action ("a click now downloads the PDF, and nothing is on the record") is what a declared, object-bound, same-origin action does on both console hosts, since the list runtime and the record page send it through the same door client.
  • What the texts leave out is true elsewhere in the same release and is graded below as nits 7 to 9: the host door, one console road, and the cross-origin name. None of the three is stated falsely here.
  • Skills-docs: none still present in the PR body and still true: git grep over skills/ at the head for the print route, the package and the verb has no hit.

③ Boundary flags

  • The 502 window is closed, and every text that named it now says so. feat(runtime): the REST action door delivers a target's attachment, and the console saves it as a download #39141 is on main; this PR is not, so main never held a print route that answers a file behind a door that refuses one. The changeset, print-pages.mdx, both ledger notes, the plugin jsdoc and the showcase action agree with each other and with the code.
  • PR body: matches the head. The first line says the delivery half merged first; the maintainer's speed-read says the button's error window is closed; the open-decision note reads "decided and landed"; the readings name this head. Its one loose phrase is in nit 12.
  • Dev open question (the first line still reads Part of #38894; A switch it to a closing keyword, B close the card by hand): the seat's call, and neither spelling now misstates the card. M2 of the first record was owed because half the ruling was still open; that half has landed. If the seat takes A, the record-page residual in nit 8 should have a card of its own first, so closing Print: the PDF a print attaches carries no print-origin marker, so an app that reacts to a print must key on the file name, which #36801 changed #38894 does not drop it.
  • Residuals that remain after both PRs, none introduced by this round: MCP run_action and the host door answer a print action 502; an api click the record page fetches itself still reports success with no file (feat(runtime): the REST action door delivers a target's attachment, and the console saves it as a download #39141 declared it, and the file is held by another claim); a cross-origin console saves the file as download.
  • Security: nothing new. The relay carries the caller's own credential to the route, as the forward always did; the route judges the caller itself, impersonation included. A file name reaches the browser through safeFilename, which replaces path separators and drops control characters. Nit 10 crosses no boundary: the only name that can trigger it is one the requester chose.
  • SQL push-down check: the round adds no read, no id materialisation and no in-app join. The door's subject-row load and the print's own read are two primary-key reads on two doors, as before this round.
  • Merges: one merge of origin/main, no force-push, no conflict. main has moved two commits past the merge-base; neither touches a print path, the action door, the console's door client or the conformance file.
  • Approval on record: review 6153833083 by os-zhuang is APPROVED with commit_id a0a9d69912, the merge commit, one commit behind this head. That commit is the one whose print-pages.mdx contradicted itself (① 6). Whether the approval covers this head is the queue's rule and the seat's to read, not judged here.
  • State: author objectstack-fleet[bot]; not draft; auto-merge not armed; mergeable_state clean; claim 7356086649 on the PR.

④ Design judgment

  • The round has the right shape. It changes no behaviour: six texts are brought to what main now does, and one pin is added where the two PRs meet. Nothing was built on the print side to make the delivery work, because nothing was needed: the route already answered the one shape the door relays.
  • The pin asserts the substance. It composes the real PrintServicePlugin, whose route is mounted for real, declares the action as the showcase does (recordIdParam plus bodyExtra, perRecord), sends it to POST /api/v1/actions/..., and asserts the bytes, the four headers by value, and that the print service was asked exactly the assembled request as the caller. Both ablations below turn it red, so it binds the route's answer to the door's rule from this PR's side.
  • The spec hits file is byte-identical to the reviewed head; the first record's judgment stands.
  • Showcase: only the jsdoc paragraph changed; the wiring and successMessage are as reviewed. refreshAfter: true now refreshes a record a print no longer changes, which is harmless.
  • Local runs (scratch worktree at 3510e8a666, every command and its exit):
    • git fetch origin claude/issue-38894-print-download-only main: exit 0; the branch ref resolved to the head sha. git worktree add --detach at the explicit sha: exit 0. pnpm install --offline --frozen-lockfile --ignore-scripts: exit 0. turbo run build for the conformance package's dependencies and service-print's closure: exit 0 (50 tasks).
    • http-conformance vitest run of action-door-attachment-38894 and the print-door conformance file at the head: exit 0, 2 files / 14 passed.
    • Ablation A1 (sendPdf replaced by a 201 JSON answer): exit 1, 2 failed / 8 passed; the two red tests are the new pin on each transport. Restored; blob c278c82c equals the head's.
    • Ablation A2 (pdfContentDisposition answers inline instead of attachment): exit 1, 2 failed / 8 passed; the same two tests, each reading the door's 502. Restored; blob c278c82c equals the head's.
    • Probe in ui/packages/app-shell (untracked, deleted after): the console's attachmentFilename and isAttachmentAnswer over the route's pdfContentDisposition: exit 0, 3 passed; readings in ① 4 and nit 10.
    • Probe in service-print (untracked, deleted after): the member and the mount through isRelayableAttachmentAnswer, readForwardAttachment and apiActionAttachmentResponse: exit 0, 5 passed; readings in ① 2 and 3.
    • service-print vitest run --maxWorkers=2 at the head: exit 0, 9 files / 143 passed.
    • git status clean and git diff HEAD empty before git worktree remove --force: exit 0; the scratch directory and its logs deleted.
    • Not re-run: the earlier rounds' ablations of the edit gate, the lone-surrogate refusal and the header builder, and the print dogfood files. Their subjects are byte-identical to the head they were measured at.
  • Check-runs at the head (REST, read just before this record was written, after the last one had completed): 81 check-runs, 70 success, 11 skipped, none failed, none pending. Among the green: both Check Changeset runs, Lint · CI, release & engine gates, Lint · docs & code guards, Governed Surface Queue Guard, Type Check UI, the dogfood regression gate and the dogfood battery with its three shards. The skipped ones are the opt-in and queue-only jobs (18.x upgrade harness, packed-tarball smoke, queue verdicts, Temporal conformance, published UI artifacts and the like).

Findings

No must-fix, no should-fix.

The first record's M1, M2 and S1–S3 stay closed; this round reopens none.

Nits (no effect on correctness or the contract; accepted as they stand, carried by the seat)

Carried from record 7340755868, unchanged: nits 1, 3, 4, 5 and 6. Nit 2 is narrower but still open: the new pin forwards to the kernel's own http.server mount on both transports, so no test yet drives a print through the dispatcher's /print domain behind the action door (my probe covers the member's answer through the relay functions).

New this round:

  1. The texts name MCP as the door that answers a print action 502. The host door dispatchAction answers the same 502; feat(runtime): the REST action door delivers a target's attachment, and the console saves it as a download #39141's changeset and actions.mdx say so, and server code has the in-process printRecordToPdf.
  2. The texts no longer mention the one console road that still loses the file: an api click the record page fetches itself (not a declared object-bound action) reads the PDF as an empty answer and reports success (RecordDetailView.tsx, unchanged by feat(runtime): the REST action door delivers a target's attachment, and the console saves it as a download #39141 and declared in its changeset). At the reviewed head this changeset said so of the whole direct-fetch road; feat(runtime): the REST action door delivers a target's attachment, and the console saves it as a download #39141 closed it for the shared runtime only. One sentence in the changeset would cover it; a prose-only edit.
  3. "The console saves it under the name that header gives" holds for a same-origin console. A cross-origin console cannot read Content-Disposition (it is not in the CORS exposed headers) and saves the file as download; feat(runtime): the REST action door delivers a target's attachment, and the console saves it as a download #39141 declared this.
  4. Outside this diff, for a follow-up card against app-shell: the console's attachmentFilename is not aware of quoted strings, so a file name that itself holds ;filename*= is read from inside the route's quoted ASCII fallback. Measured: 报价; filename*=UTF-8''evil.exe; y.pdf is saved as evil.exe, and 报价;filename*=x.pdf under its ASCII fallback. Only a request's own filename can hold the token (a display value has * replaced), and the requester may name the file anything already. The route's header is well formed.
  5. print-pages.mdx no longer carries the defineAction sample that main has; the prose names recordIdParam and bodyExtra instead. Now that the action delivers, the sample would serve an author.
  6. The new pin's comment and the PR body say only the renderer is replaced. The stub replaces the whole printRecordToPdf verb (validation, the page lookup, the read check, the session and the render). What the pin proves is the route and the door; the read gate behind the action door is pinned on the route by the dogfood suite, not here.

Implemented-by: claude/issue-38894-print-download-only
Reviewed-by: session_01QSeKYnrQ7UMtHofKQVjcH2

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2

L1 ACCEPT · PR #39076 (#38894, ruling 7344041246) · head 3510e8a666f1249b078b59c568dffee19e06831d · read 2026-12-02T19:48Z

Seat check · ACCEPT

ACCEPT · repo:objectstack@os-justin · head 3510e8a666f1249b078b59c568dffee19e06831d

  1. What moved since the last ACCEPT (head 2125d13975):

    No print code moved. Dev report: 7354599560 on Print: the PDF a print attaches carries no print-origin marker, so an app that reacts to a print must key on the file name, which #36801 changed #38894.

  2. Contract review. Delta record 7356709230 at this head, CONTRACT_REVIEW_TIER, by the same reviewer as 7340755868. It reads No must-fix, no should-fix.

  3. Shape. l1-face flags two items, both answered here:

    • (a) shape: the PR is already ready, as at the first hand-off.
    • (b) changeset: packages/runtime (2 files) and packages/spec (1 file) have no changeset line. All three hunks are comment or jsdoc text only: domains/print.ts header, a route-ledger.ts note, and the IPrintDoorService jsdoc in print-door-service.ts. They restate the door's new answer and change no type or runtime behaviour. Check Changeset is green. Accepted as a deviation; no patch bump is owed for prose.
  4. Changeset, read sentence by sentence. True at this head:

    • the door's 200 PDF answer and its three headers;
    • "nothing is stored";
    • read access as the whole permission;
    • no storage dependency;
    • the renamed verb and result (FROM → TO);
    • the REST action door relaying the bytes with the 32 MiB bound;
    • MCP run_action still answering 502.

    The record's nit 7 (the host door's dispatchAction also answers 502) and nit 8 (an api click the record page fetches itself still reports success with no file) are omissions, not false sentences.

  5. Gates at this head.

    • CI: 70 success, 11 expected skip, 0 failed. Dogfood battery (opt-in) succeeded (check run 143645924988).
    • landing-k: K = 3.
    • check-governed-merges: NOT governed, 1,288 lines.
    • The title's ! and the (narrowing) arm make this a maintainer merge: the seat neither arms nor queues it.
  6. Part of #38894 is kept. The seat closes Print: the PDF a print attaches carries no print-origin marker, so an app that reacts to a print must key on the file name, which #36801 changed #38894 after this merges, once the review nits (7–12 and carried nit 2) are filed as review follow-ups of PR #39076. Nit 10 (the console's attachmentFilename is not quoted-string aware; the requester's own filename only, no boundary crossed) goes to app-shell in that card.

  7. Approval on record. os-zhuang APPROVED at a0a9d69912, one commit behind this head. The commit after it is text plus one test pin.

Clause-②: yes (narrowing) · Metadata-protocol: none

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2

L1 ACCEPT · PR #39076 (#38894, ruling 7344041246) · head 3510e8a666f1249b078b59c568dffee19e06831d · read 2026-12-02T19:50Z

Re-posted from comment 7356776403 under the record heading the hand-off guard reads; no content changed.

席位核对

ACCEPT · repo:objectstack@os-justin · head 3510e8a666f1249b078b59c568dffee19e06831d

  1. What moved since the last ACCEPT (head 2125d13975):

    No print code moved. Dev report: 7354599560 on Print: the PDF a print attaches carries no print-origin marker, so an app that reacts to a print must key on the file name, which #36801 changed #38894.

  2. Contract review. Delta record 7356709230 at this head, CONTRACT_REVIEW_TIER, by the same reviewer as 7340755868. It reads No must-fix, no should-fix.

  3. Shape. l1-face flags two items, both answered here:

    • (a) shape: the PR is already ready, as at the first hand-off.
    • (b) changeset: packages/runtime (2 files) and packages/spec (1 file) have no changeset line. All three hunks are comment or jsdoc text only: domains/print.ts header, a route-ledger.ts note, and the IPrintDoorService jsdoc in print-door-service.ts. They restate the door's new answer and change no type or runtime behaviour. Check Changeset is green. Accepted as a deviation; no patch bump is owed for prose.
  4. Changeset, read sentence by sentence. True at this head:

    • the door's 200 PDF answer and its three headers;
    • "nothing is stored";
    • read access as the whole permission;
    • no storage dependency;
    • the renamed verb and result (FROM → TO);
    • the REST action door relaying the bytes with the 32 MiB bound;
    • MCP run_action still answering 502.

    The record's nit 7 (the host door's dispatchAction also answers 502) and nit 8 (an api click the record page fetches itself still reports success with no file) are omissions, not false sentences.

  5. Gates at this head.

    • CI: 70 success, 11 expected skip, 0 failed. Dogfood battery (opt-in) succeeded (check run 143645924988).
    • landing-k: K = 3.
    • check-governed-merges: NOT governed, 1,288 lines.
    • The title's ! and the (narrowing) arm make this a maintainer merge: the seat neither arms nor queues it.
  6. Part of #38894 is kept. The seat closes Print: the PDF a print attaches carries no print-origin marker, so an app that reacts to a print must key on the file name, which #36801 changed #38894 after this merges, once the review nits (7–12 and carried nit 2) are filed as review follow-ups of PR #39076. Nit 10 (the console's attachmentFilename is not quoted-string aware; the requester's own filename only, no boundary crossed) goes to app-shell in that card.

  7. Approval on record. os-zhuang APPROVED at a0a9d69912, one commit behind this head. The commit after it is text plus one test pin.

Clause-②: yes (narrowing) · Metadata-protocol: none

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2

维护者速读(更新 · 2026-12-02T19:51Z)

Head-sha: 3510e8a666f1249b078b59c568dffee19e06831d

@os-zhuang
os-zhuang added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit 5161056 Dec 2, 2026
81 checks passed
@os-zhuang
os-zhuang deleted the claude/issue-38894-print-download-only branch December 2, 2026 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation needs:dogfood-battery pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue size/xl tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants