Skip to content

feat(storage,mcp): an upload link for a file field of a record not yet created - #33123

Merged
objectstack-fleet[bot] merged 8 commits into
mainfrom
claude/project-thread-vlkibi
Nov 13, 2026
Merged

objectstack-fleet[bot] merged 8 commits into
mainfrom
claude/project-thread-vlkibi

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Tesla · project thread

Fixes #32686

Clause-②: yes (widening) — nothing narrowed: create_upload_link accepts objectName + field with no recordId (where the storage service serves it) and answers fileIds; a file id from such a link is accepted in that field on create_record / update_record by the user who uploaded it, in one record, within an hour of the upload, while no record has held it (once a record has held and released it, it is an ordinary released file). Every existing call answers as before; the only new refusals fall on the new class of file.
Metadata-protocol: none — no metadata author key is added, removed or retyped; the binding rides sys_file.metadata, the storage row column the upload link's own state already uses.
Skills-docs: updated here — the served agent skill (packages/mcp/src/skill-md.ts) teaches the two-call flow where the host serves it; content/docs/ai/connect-mcp.mdx § Files gains the paragraph, and content/docs/permissions/system-context.mdx rows 47e/47f name the new caller-scoped verb and the one file a system write can no longer claim (claim amendment 6856718179). The Console's skill mirror renders no file tools, so it is unchanged (its parity test is green).

维护者速读

  • 改了什么:上传链接可以只指定对象和文件字段、不指定记录。用户用链接上传后,智能体再调用 create_record,把链接返回的 fileIds[0] 填进该字段,必填文件字段的记录就能建出来(报销明细 + 必填电子发票:两次智能体调用 + 一次浏览器上传)。required 规则不变。
  • 为什么改:以前链接必须先有记录,而记录又必须先有文件,智能体建不出带必填文件字段的记录。
  • 权限与边界:签发时要求该用户能创建该对象的记录、能写该字段、字段不是只读;仍是登录用户、单人、10 分钟过期、一次性(MCP cannot read or attach files: no tool downloads an attachment (e.g. a policy PDF to analyse) and none attaches one (e.g. a photographed invoice) to a record #30892 裁决 B)。上传后的文件只绑定给上传者、该对象该字段、一条记录、一小时内;别人的写入、系统写入、别的字段或对象、第二条记录、超时都会在字段上被拒并说明原因;在被记录占用之前只有上传者能下载。
  • 风险与回滚:只放宽(新增调用形态),已有调用和已有文件的判法不变;回滚即 revert。上传后从未被任何记录引用的文件目前不会被回收(与控制台上传后放弃保存同类),已作为范围外发现交席位立卡。
  • 先看:packages/services/service-storage/src/pre-record-upload.ts(绑定与判定)、record-file-access.ts 的 createUploadLinkForNewRecordAs 与 fileForNewRecordThroughLink、file-reference-lifecycle.ts 的 applyCopyOnClaim 新分支;验收在 packages/qa/dogfood/test/showcase-mcp-record-files.dogfood.test.ts 末尾的新 describe。
  • 需要你做的:无,席位落地。

Ruling

Maintainer ruling A on #32686, recorded by triage 6844207600: 「以上原则同意」 (decision batch #1, 32686 A):

An upload link can be issued before the record exists (naming the table and field). The user uploads, then the agent creates the record referencing the file id. The required rule is unchanged for agents and people. The #30892 ruling B constraint still holds: a signed-in user, one user, expiring.

Designed together with #32747 (A); this card goes first and implements one file per link (see "How #32747 adds to this").

What changes

Minting a link that names no record (RecordFileAccess.createUploadLinkForNewRecordAs, record-file-access.ts). The caller must be a signed-in user (the system context is refused, as for every caller-scoped record-file verb), the field must be a file or image field of the object, and three permission answers must hold for that user:

  1. the object's create verdict, security.explain({ object, operation: 'create' }, caller) — the verdict create_record's own door asks — else 403 PERMISSION_DENIED "You cannot upload a file for a new X: you cannot create X records.";
  2. the field is among security.getWritableFields(object, caller), else 403 FIELD_NOT_ACCESSIBLE;
  3. the field is not readonly, else 403 FIELD_NOT_ACCESSIBLE.

This is stricter than the Console form, whose upload (presign → PUT → complete) needs only a session and whose save is judged afterwards; here the save is still judged in full (the create runs under the user's permissions and validations), and the link is refused up front when the save could not succeed on permissions alone. An attachments link still needs its record. A kernel with no security service enforces no object permission on the create either, so there is nothing to ask there.

The link is the same single-use, ten-minute, one-user sys_file row as a record link (#30892 ruling B), with no record_id in its state. Its row id is the file id the upload will be stored under, so the mint can answer it: fileIds: [id].

The upload (consumeUploadLink → fileForNewRecordThroughLink). The field's own accept and maxSize are judged when the file arrives and before the link is spent (no record write judges them yet); a file the field cannot take is refused 400 ERR_FILE_CONSTRAINT, nothing stored, and the link still works. Then the link is spent as before, the bytes are stored, and the reserved row becomes the committed file, owned by the uploader, with a binding in sys_file.metadata:

{ "kind": "pre_record_upload", "object": "expense_line", "field": "invoice", "user_id": "…", "organization_id": "…", "claim_until": "<upload + 1h>" }

The PUT answers { fileId, size, field }; the page says the file was received and to go back to the assistant (new received copy in all eleven page locales), not that it was attached.

Which write may take the file (pre-record-upload.ts#preRecordReferenceRefusal, asked from applyCopyOnClaim in file-reference-lifecycle.ts after the read check, before anything is copied or claimed):

The write While no record holds it Once a record holds it, within the hour After the hour
the uploader, into the bound object + field taken refused (one record) refused (expired) while no record holds it
the uploader, another field or object refused, naming the field it was uploaded for refused (one record) refused, naming the field
another user refused, in the words of a file they cannot open refused, same words refused, same words, while no record holds it
a system or context-less write refused, same words copied, as any record's file refused while no record holds it
the record that holds it, rewriting its own value — taken (claims nothing) taken

Once the hour has passed and a record holds the file, it is that record's file like any other: no row above applies, and the read check and copy-on-claim judge it.

Every refusal is the ADR-0114 field refusal (400 VALIDATION_FAILED, fields[] entry invalid_value on the field) and refuses the whole write. Another writer gets the existing words for a file they cannot open, so the answer says nothing about whose upload it is; the uploader's own refusals say why (the field it was uploaded for, already in another record, or no record took it within 60 minutes) and end "Ask for a new upload link for this field and upload the file again." A damaged binding (the kind present, a value missing) reads as bound to nobody, so it refuses rather than reading as an ordinary file.

Downloads (judgeFileRead, storage-service-plugin.ts). For this new class only — a bound file no record holds, and the pending row its link reserved — only the uploader may download it (the owner arm, unchanged, answers them); everyone else is denied. Once a record holds it, it is that record's file and the existing rules judge it. Every other file is judged exactly as before.

MCP (create_upload_link, mcp-http-tools.ts). Where the bridge carries createUploadLinkForNewRecord, recordId is optional in the listed schema, the description says how, and a call with field and no recordId answers { url, expiresAt, singleUse, objectName, field, fileIds, instructions }. With no record, attachments: true is refused before the bridge is asked. A bridge without the member keeps recordId required. The served SKILL.md teaches the flow only where the host says the bridge serves it (newRecordUploadLinks, data:write).

Runtime (domains/mcp.ts). McpRecordFileService.createUploadLinkForNewRecordAs? (optional: a storage plugin that predates it serves record links only); the bridge member answers the link as an absolute URL on the request's origin with its fileIds, and reads no record first (there is none; the storage service asks the create verdict). The skill route passes newRecordUploadLinks.

No new error code. Refusals reuse PERMISSION_DENIED, FIELD_NOT_ACCESSIBLE, VALIDATION_ERROR, VALIDATION_FAILED and ERR_FILE_CONSTRAINT.

How #32747 adds to this

The answer already carries fileIds as an array, and the skill already says "the array, for a multi-file field". #32747 adds one optional input (a file count, or multiple: true on a multi-file field) and nothing else: the mint reserves one row per file and answers one id per file in the same fileIds; the PUT door accepts up to that many files; each stored file carries the binding above, unchanged; the create names the array. No key is renamed or retyped and no existing call changes, so it is purely additive.

Orphans: what reclaims a file uploaded and never referenced

  • A link never used is its pending row, which sys_file's lifecycle retention (7 days, status: 'pending') already reaps.
  • A file uploaded and never put in a record is a committed row with no holder. Nothing reclaims it: the lifecycle reaps only deleted_at (30 days) and pending rows, the same as for a file uploaded through the Console form and never saved (stranded-orphan-inventory.ts calls these rows immortal). After its hour the binding makes it usable by no write, so it is inert, but its bytes stay. Reported to the seat as an out-of-scope finding for a card of its own; not fixed here (ADR-0057 §3.3: no bespoke sweeper).

Tests

  • packages/services/service-storage/src/record-file-access.integration.test.ts, new describe "[Decision] How should an MCP agent create a record whose required file field must be filled (e.g. an expense line with a required e-invoice)? #32686 — a link that names no record" (13 cases over a real ObjectQL kernel and the storage routes): the measured case (an expense_line with a required invoice is refused without it; mint; the create before the upload is refused as never completed; upload; the create naming the id is taken and the file is claimed; the spent link answers 404); the page says "received"; another user refused (unreadable words, file stays unclaimed); a system write refused; another field and another object refused naming the bound field; one record (a second record refused, the first keeps it, the holder's own rewrite admitted); expiry; the update path; downloads (uploader 200, another reader 403, then 200 through the record once claimed); control: a Console-style upload (presign → raw PUT → complete) and save is taken as before and carries no binding; minting refusals (system context, non-file field, read-only field, no field); the create verdict and field writability as a security service answers them; maxSize refused on arrival with the link not spent.
  • packages/services/service-storage/src/pre-record-upload.test.ts (new, 13 cases): the rule arm by arm, including the other-user arm alone (the integration pin is guarded twice, see the ablations), a damaged binding, a file with no binding, and which rows are uploader-only.
  • packages/mcp/src/mcp-file-tools.test.ts, new describe (7 cases): the no-record call, a call with recordId still asking the record link, attachments with no record refused unasked, the minting refusal relayed with its code, the listed schema (recordId optional only where served), a bridge without the member refusing, and the skill paragraph's placement.
  • packages/runtime/src/mcp-record-file-bridge.test.ts (2 cases): the member's absolute URL and fileIds, no record read; no member without the service verb.
  • Acceptance — packages/qa/dogfood/test/showcase-mcp-record-files.dogfood.test.ts, new describe over a real showcase boot with the security, storage and MCP plugins (3 cases): create_record without the e-invoice is refused; agent call 1 create_upload_link { objectName: 'dogfood_expense_line', field: 'invoice' } over POST /api/v1/mcp; the browser opens the link page (200, "received", names nothing) and uploads through PUT /api/v1/storage/upload-links/:token; agent call 2 create_record { …, invoice: fileIds[0] } is taken, the record holds the file, sys_file names the record, and read_file reads the PDF's text back. Then another signed-in user's create naming a member's upload is refused and cannot download it, while the member's create takes it; and a member who cannot create showcase_task gets no link (403 PERMISSION_DENIED) and nothing is reserved.
Ablations (each committed first, mutated through scripts/ablation-replace.mjs in WRAP mode, restored to the HEAD blob)

Every mutation landed (anchor 1 → 0, blob changed) and every restore read blob == HEAD and git diff HEAD is empty; git status after each set showed no file an ablation touched. The storage suites read src/ directly; the dogfood suite aliases @objectstack/runtime to src/, so no dist rebuild was owed for the runtime leg.

# Mutation Pin Observed
1 other user admitted: not_yours only for writerUserId === null, and the uploader-only download arm deleted another user's write refused red (expected null to match object { status: 400 … })
2 as 1, the not_yours arm alone same green: the read check refuses first (by design, the rule is asked after it)
3 as 1, the download arm alone same green: the not_yours arm refuses
4 as 2, against the unit pin pre-record-upload.test.ts "refuses another user" red (expected null to deeply equal { kind: 'not_yours' })
5 system write admitted (writerUserId !== null && …) a system write is refused red
6 slot check off (if (false)) another field / object refused red
7 one-record check off (return null for a held file) goes into one record red
8 expiry check deleted expires red
9 uploader-only download arm deleted downloads red
10 create verdict ignored (if (false)) asks the create verdict red (expected null to match object { code: 'PERMISSION_DENIED' … })
11 field writability ignored same case red
12 readonly ignored minting refusals red (… { code: 'FIELD_NOT_ACCESSIBLE' … })
13 accept/maxSize check before the spend deleted maxSize refused on arrival red (expected 200 to be 400)
14 page copy back to "attached" the page says received red
15 the reserved link row no longer uploader-only unit pin red
16 MCP: recordId optional everywhere the listed schema red (expected [ 'objectName' ] to include 'recordId')
17 MCP: no-record attachments not refused attachments with no record red
18 runtime: fileIds dropped from the member's answer the bridge member red
19 runtime: the bridge member not served dogfood acceptance red: Invalid arguments for tool create_upload_link: … expected string, received undefined at recordId (also the reading at origin/main)

Acceptance notes

Verification

Readings at head a9a6589d (after merging origin/main 7c36f524, which touched none of this PR's files; the four typecheck runs and the gates were taken at 0678c15b, the same tree for these packages), every heavy command under scripts/pm/os-verify-lock.sh (VERDICT command-exit 0 on each), exit codes captured before any pipe:

  • Build: pnpm turbo run build --concurrency=2 --filter='@objectstack/dogfood^...' after the merge, 70/70 tasks.
  • @objectstack/service-storage test (whole package): Test Files 82 passed (82), Tests 1540 passed. typecheck exit 0.
  • @objectstack/mcp test (whole package): Test Files 63 passed (63), Tests 1104 passed. typecheck exit 0.
  • @objectstack/runtime src/mcp-record-file-bridge.test.ts: 7 passed. typecheck exit 0 (with NODE_OPTIONS=--max-old-space-size=8192, see the notes).
  • @objectstack/dogfood test/showcase-mcp-record-files.dogfood.test.ts: Test Files 1 passed, Tests 18 passed (15 existing + 3 new). typecheck exit 0 (same heap note).
  • Lint: eslint --no-inline-config over the 17 changed TypeScript files exit 0; the server lane's whole-tree pnpm lint (eslint . --no-inline-config) exit 0 at a9a6589d.
  • Derived gates: node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack → 106 families at the final diff (83 before the docs pages joined, 27 more after, plus the four roster gates that keep a roster under one of these paths: check:changeset-fixed, check:error-code-casing, check:filter-alias-parity, check:route-ledger-census, all exit 0), each run with </dev/null. Two exited 3 on the first pass and 0 on a rerun: node scripts/check-plugin-teardown-shape.mjs --self-test (its pinned fixture 621a4876 was outside the shallow clone; 0 after git fetch origin 621a487607881c66b2899b7e3477115229a156b4 --depth=1), and pnpm check:dual-build-cjs-loads (PREREQUISITE: 11 packages had no dist/; 0 after check:type-check-debt's closure build had built every package, and again 0 at the merged head: 123 require entry points across 72 packages load). Every other family exited 0. Reconciliation --ran: 106 derived famil(ies) accounted for — 106 run, 0 NOT-MEASURED (a DERIVED zero — all 106 recorded an exit code and none of them is 3).
  • Rework head 2aaea77a (seat contract review 6857928485, findings F1 and F3–F6): one commit on 7f41ed5f, which itself is changeset-only 042bdb52 and docs-only 7f41ed5f on a9a6589d. At 2aaea77a: service-storage 82/82 files (1547 tests), dogfood showcase-mcp-record-files 18/18, typecheck 0, eslint on changed files 0, 101 derived gates + 3 roster exit 0 (--ran 101 run, 0 NOT-MEASURED), 11 ablation legs all red and restored. origin/main touches none of this PR's files; no merge.
  • CI: the seat reads the check-runs on the landing head.

🤖 Generated with Claude Code

https://claude.ai/code/session_01L9qibwGvonkT2ydXH6AKHm

…reated

An upload link can now name an object and a file field with no record.
The user uploads through it; the bytes land as a committed file bound to
that user, object and field for one hour, and the agent's create (or
update) naming the file id takes it. Another user's or a system write,
another object or field, a second record, or a write after the window is
refused at the field. While no record holds it, only the uploader may
download it.

Minting checks the object's create verdict and the field's writability.
The create_upload_link tool makes recordId optional when the bridge serves
this, and answers fileIds as an array.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibwGvonkT2ydXH6AKHm
…ot yet created

The binding's rule arm by arm, the tool's no-record form and its schema,
the bridge member, and the acceptance flow over a real showcase boot: two
agent calls and one upload create a record whose file field is required.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibwGvonkT2ydXH6AKHm
The MCP guide's file tools section teaches the two-call flow, and the
system-context table names the new caller-scoped verb and the one file a
system write can no longer claim.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibwGvonkT2ydXH6AKHm
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibwGvonkT2ydXH6AKHm
@github-actions github-actions Bot added size/xl 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 Nov 13, 2026
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 3 package(s): @objectstack/mcp, @objectstack/runtime, @objectstack/service-storage, touching 70 documentable anchor(s).

69 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 5c005e0e42e207b073843b255248877b84442342.

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

What this run could not see
  • 1 cross-cutting symbol(s) contributed no route anchor: recordId (4 routes)
  • 2 anchor(s) matched too much of the corpus to be a work list: organization_id (symbol, 40 pages), PERMISSION_DENIED (literal, 52 pages)
  • 5 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 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 — 41 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 5c005e0e42e207b073843b255248877b84442342 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 5a41ed07ab4ad2211d114132a2f680545a1d0f26 — the merge of head 2aaea77af4ce68f15c26c1643eeb3330f9629d99 into base 5c005e0e42e207b073843b255248877b84442342, 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 5a41ed07ab4ad2211d114132a2f680545a1d0f26 && git checkout 5a41ed07ab4ad2211d114132a2f680545a1d0f26
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 5c005e0e42e207b073843b255248877b84442342 2aaea77af4ce68f15c26c1643eeb3330f9629d99 && git checkout -B drift-repro 5c005e0e42e207b073843b255248877b84442342 && git merge --no-ff 2aaea77af4ce68f15c26c1643eeb3330f9629d99

node scripts/docs-audit/affected-docs.mjs --json 5c005e0e42e207b073843b255248877b84442342

⚠️ 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 5c005e0e42e207b073843b255248877b84442342 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

The release level follows the metadata protocol alone, and this change
leaves it untouched.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibwGvonkT2ydXH6AKHm
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#7 · os-tesla · session_01L9qibzuZJBQY4wUQFJbkfx

Contract review

Served-tier: TIER_DEFAULT
Head-sha: a9a6589d427ab6f71b0d06f0a1fe0f1dd4764276
Local-runs: none
Regen-provenance: 7f41ed5 — changeset-only 042bdb5 and docs-only 7f41ed5 on a9a6589 (prose faces)

① Derived judgments

  • create_upload_link with objectName + field and no recordId (mcp-http-tools.ts#registerFileTools, record-file-access.ts#createUploadLinkForNewRecordAs): right. This is ruling A's "link before the record exists, naming the table and field". recordId is optional only where the bridge serves the member, and a bridge without it keeps the old schema.
  • fileIds: [link.id] in the answer: right. The agent creates the record naming the file id, as ruling A says. The array shape leaves storage + mcp: one upload link on a multiple: true file field accepts several files (same user, record, field, one use, same expiry) — ruled A #32747 additive: N files need N reserved rows and N ids under the same key, and nothing here forecloses that.
  • A bound file id accepted in a required file field on create and update (file-reference-lifecycle.ts#applyCopyOnClaim → pre-record-upload.ts#preRecordReferenceRefusal): right. required is untouched. The file is a committed row before the create names it, and the create still runs under the user's permissions and validations. The update path is in the card's option A (create_record / update_record).
  • New refusals (mint: system context PERMISSION_DENIED, create verdict PERMISSION_DENIED, writability and readonly FIELD_NOT_ACCESSIBLE, non-file or missing field VALIDATION_ERROR; upload: ERR_FILE_CONSTRAINT before spend; write: VALIDATION_FAILED/invalid_value for not_yours / other_slot / spent / expired; MCP: attachments with no record): right. They fall only on the new class. Ruling B of MCP cannot read or attach files: no tool downloads an attachment (e.g. a policy PDF to analyse) and none attaches one (e.g. a photographed invoice) to a record #30892 holds: requireUserContext admits a signed-in user only, the link is single-use and lasts 10 minutes for one user, and the binding is for one user and expires after 1 hour.
  • Narrowed download for bound files (storage-service-plugin.ts#judgeFileRead, isUploaderOnlyFile after the owner arm): right while no record has held the file. It is wrong after a release; see ③ F1.

② Semver level

  • At a9a6589d the changeset graded service-storage, mcp and runtime as minor under Metadata-protocol: none. That is wrong under ruling A on changeset levels: minor only when the metadata protocol changes (added / narrowed / semantic), patch otherwise; release notes grouped by what the reader must do (maintainer ruling A, 2026-10-21) #25105 (none means patch), and Check Changeset failed. At 042bdb52 all three are patch and the changeset reads Clause-②: yes (widening) / Metadata-protocol: none. Right: Check Changeset succeeded on 042bdb52, and its run on 7f41ed5f is in progress.
  • Clause-②: yes: right. The diff widens a published accept set (a new MCP call shape, a new file id class accepted on writes) and narrows nothing an existing call reaches.
  • Metadata-protocol: none: right. No packages/spec file is touched and no authorable key changes. The binding rides the sys_file.metadata data column. The changed TS types (McpFileBridge, McpRecordFileService) gain only optional members, and ICallerRecordFileService / UploadLinkOutcome are not exported from service-storage's index. @objectstack/dogfood is private.
  • The changeset prose agrees with the code, except for the "with a reason" wording (F4).

③ Boundary flags

  • Mint permission. createUploadLinkForNewRecordAs asks security.explain({object, operation:'create'}, caller), which uses the enforcement path's own resolution and is the verdict REST's create door asks (rest-server.ts). It also asks getWritableFields and the field's readonly. That is stricter than the console, whose presign needs only a session, and the create is still judged in full afterwards. A user without create permission gets no link and no reserved row; the dogfood pin asserts 403 PERMISSION_DENIED and an unchanged pending count. With no security service, no create is permission-gated either.

  • User B and A's id. For a create or update, findReferenceableFile calls judgeFileRead, which denies ('refused'), and not_yours also refuses even without authorizeRead. Both doors, /files/:id/url and /files/:id, go through authorizeDownload → judgeFileRead and deny. A system or context-less write (referencingCallerOf gives null for isSystem) gets not_yours while the file is unheld. Another object or field gets other_slot, and a second record within the hour gets spent. The 1-hour window is checked at the write (Date.now() against claim_until). accept/maxSize are checked by assertFileConstraints before updateFileIfUnchanged spends the link, and the link is left unspent on refusal.

  • Unbound behaviour. It is unchanged. preRecordBindingOf returns null without the pre_record_upload kind. isPreRecordLinkRow excludes every link row that carries a record_id. openLinkStateOf still refuses an attachments link without a record and an empty record_id. consumeUploadLink's record-link branch only gains a recordId parameter. The console-style control pin (presign, PUT, complete, save, no binding) covers this.

  • F1 · should-fix · the binding outlives the claim. claimFile never clears sys_file.metadata, and releaseOwnership clears only ref_*. Once the holding record lets the file go (the field is cleared or replaced, or the record is deleted), the row is unheld and bound again. Three things follow:

    This contradicts the PR body, pre-record-upload.ts's header and row 47f ("once a record holds it, it is that record's file like any other"). The fix: retire the binding at first claim, or ignore it when released_ref_* is set, and add a pin.

  • F2 · should-fix · orphan reclamation. A bound file that is uploaded and never claimed stays a committed row forever. The lifecycle reaps only deleted_at (30 days) and pending (7 days), the same gap as a console upload that is never saved. After the hour no write can use the file, but its bytes stay. The PR body and the record-file-access.ts module comment state this honestly, and verify-file-references reports the file as unreferenced_file. The out-of-scope finding is not yet a card (no hit in the search), and the ruling made reclamation part of this review: file the card before landing. The binding (unheld, claim_until past) gives a reaper an exact predicate.

  • F3 · nit · the reserved row before upload. fileIds[0] is published at mint and is the pending link row. A system or context-less write naming it passes, because preRecordReferenceRefusal sees no binding and the incomplete-upload check is guarded by caller &&. It claims the row, and the later upload lands into that record. This posture already exists for every pending row (row 47f), but only this class publishes the id. Treating isPreRecordLinkRow as bound in preRecordReferenceRefusal closes it.

  • F4 · nit · docs and prose wording. The connect-mcp.mdx paragraph and the changeset say every refusal comes "with the reason". Another user's write and a system write get the unreadable-file words, by design. "Refused after the hour" and "in one record" hold only while no record holds the file, and after the hour copy-on-claim applies. Row 47e's shared sentence ("read the record … as that user") does not describe the new verb, which reads no record and asks the create verdict. The plugin-endpoints.mdx PUT sentence at 7f41ed5f is true (stored under the answered id for that field); it says "the user's create" where update also works.

  • Row 47f edit: true for an uploaded, unheld bound file (system write → not_yours → field refusal), and needed. Without it, "a system write claims … any file" would be false. "Until a record holds it" is imprecise given F1. It goes beyond the amendment's named row (47e only); the dev disclosed this, and the claim record should name 47f.

  • F5 · nit · error envelopes. The storage refusals carry ADR-0112/0114 code + status, and the tests assert both (refusedAt, the minting toMatchObject, ERR_FILE_CONSTRAINT, MCP PERMISSION_DENIED/403). Two pins are weaker. The bound-file download refusal is pinned on status only: 403 in the integration test and not.toBe(200) in dogfood, with no FILE_DOWNLOAD_DENIED. The two MCP-local argument refusals carry no code, matching the tool's existing pre-bridge refusals.

  • Negative pins. Reading the code: the other-user write is guarded twice (the read check, then not_yours), so ablations 2 and 3 going green is correct, and each arm fails alone (ablation 4 unit, ablation 9 downloads). The system-write, slot, spent, expiry, create-verdict, writability, readonly, accept/maxSize, MCP schema and bridge-member pins each have a single guard and go red when it is removed. The release case of F1 has no pin.

  • Gates (check-runs as read). a9a6589d was superseded. Check Changeset failed there (minor under Metadata-protocol: none), 21 lanes were cancelled, and the Lint & Repo Gates / TypeScript Type Check aggregates failed only because their lanes were cancelled. 042bdb52 (also superseded): Check Changeset success, 16 success, 20 cancelled, and the same 2 aggregates failed because their lanes were cancelled. 7f41ed5f (the current head): 6 success, 15 skipped, 15 in progress (including Check Changeset, every Lint and Type Check lane), 6 queued (Build Core, Build Docs, Dogfood Regression Gate, Live E2E UI, Plan Test Core shards, Test UI). No code gate has a verdict on the current head yet, so the merge still waits on them.

  • F6 · nit. The PR body's Clause-②: line carries no (widening) arm, while the changeset at 042bdb52 does, and Check Changeset reads "direction arm: none declared". This is harmless because only a narrowing arm is consumed, but the two should match.

Implemented-by: claude/project-thread-vlkibi
Reviewed-by: session_01L9qibzuZJBQY4wUQFJbkfx

VERDICT: PASS

… the file go

A record that releases a file it took through a link with no record keeps
it as any released file: its readers read it by that record's rule, and
the uploader's restore or another record takes it as before. Before the
upload, the id the link answered takes no write but its uploader's. The
docs, changeset and table rows say which refusals carry a reason, and
that the one-record rule and the hour hold while no record holds the file.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibwGvonkT2ydXH6AKHm
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#7 · os-tesla · session_01L9qibzuZJBQY4wUQFJbkfx

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 2aaea77af4ce68f15c26c1643eeb3330f9629d99
Local-runs: none

① Derived judgments

  • Delta review of record 6857928485 (head a9a6589d, verdict PASS, prose faces 042bdb52/7f41ed5f). Scope: git diff 7f41ed5f 2aaea77a, one commit, 10 files. The code moved in pre-record-upload.ts only, with comments in file-reference-lifecycle.ts and record-file-access.ts. The tests moved in pre-record-upload.test.ts, record-file-access.integration.test.ts and the dogfood file. The prose moved in the changeset, connect-mcp.mdx, plugin-endpoints.mdx and system-context.mdx rows 47e/47f. Every judgment in 6857928485 that this delta does not touch stands.
  • preRecordReferenceRefusal, with heldHere moved to the top: right. The answer is identical for every input; it was !binding || heldHere → null before.
  • A binding is ignored once released_ref_* is set (released, neverHeld): right. A file a record has held and let go is judged by files: an authorization gap in the file lifecycle after a file is released, within one organization (detail withheld) #26046 as any released file. claimFile clears released_ref_* when a second record takes the file, so while that record holds it the held-file rule applies again (spent / not_yours within the hour).
  • The pending link row (isPreRecordLinkRow && neverHeld) refuses a system or context-less writer and any writer other than owner_id with not_yours: right. Each of them gets the unreadable-file words. The uploader still falls to the incomplete-upload check, and record-link rows are untouched (record_id present → null, pinned).
  • The new question, whether the uploader can now put a released file into a second record within the hour: yes, and consistent with ruling A. The sequence is R1 takes it, R1 clears the field, R2 takes it. The file is in at most one record at any time: spent still refuses a second record while the first holds it. The move is files: an authorization gap in the file lifecycle after a file is released, within one organization (detail withheld) #26046's re-claim of a released file, which every released file allows its releasing record's readers. The same holds for a reader of R1 re-claiming it, and for other fields or objects after the release. Ruling A's constraints are a pre-record link for one signed-in user that expires; they govern the window before any record held the file, and once a record holds it, it is that record's file. The rework states this in the changeset, connect-mcp.mdx and row 47f. storage + mcp: one upload link on a multiple: true file field accepts several files (same user, record, field, one use, same expiry) — ruled A #32747 stays additive: no key or shape changed.

② Semver level

  • The changeset is unchanged in level: patch for service-storage, mcp and runtime, with Clause-②: yes (widening) and Metadata-protocol: none. Right. The delta narrows only the new class and adds no published key. Check Changeset succeeded on 2aaea77a.

③ Boundary flags

  • F1 (was should-fix): resolved.
  • F2 (was should-fix): resolved outside the diff. storage: a committed upload that no record ever names is never reclaimed (new path: MCP pre-record upload links) #33125 is open: "a committed upload that no record ever names is never reclaimed (new path: MCP pre-record upload links)".
  • F3 (was nit): resolved. The integration pin shows a system write and another user refused before the upload, the row still pending and unclaimed, and the upload and the uploader's create still taken. Removing the new arm makes the system insert succeed, so the pin goes red.
  • F4 (was nit): resolved, with one residue (nit).
    • These now match the code: the changeset paragraph, the connect-mcp.mdx paragraph, row 47e (the new verb asks the create verdict and the field's writability), row 47f (the pre-upload id, a system write copying a held file, a released file judged as any) and the plugin-endpoints.mdx PUT row ("create or update").
    • Residue: connect-mcp.mdx says "Within the hour, a second record naming it while the first holds it is refused too". That is unqualified, but a system write copies a held file (writerUserId === null → null). The sentence is true for every MCP or user write, which is the page's audience, and row 47f states the system case.
  • F5 (was nit): resolved. The integration pin asserts error.code: 'FILE_DOWNLOAD_DENIED' beside the 403. The dogfood pin now asserts 403 and FILE_DOWNLOAD_DENIED in place of not.toBe(200).
  • F6 (was nit): open. The PR body's Clause-②: line still has no (widening) arm, while the changeset has one. It is harmless because only a narrowing arm is consumed, but the two should match. Also still open: the 47f edit is not named in the claim amendments 6856718179 and 6857811650.
  • Unbound behaviour after the rework: unchanged. neverHeld only shrinks the uploader-only set. The pending-row arm fires only on a no-record link row, and heldHere is semantics-preserving. Nothing changed outside pre-record-upload.ts's two predicates. I found no new hole: a released bound file gets exactly the reach of any released file, and an unheld, never-held bound file keeps every refusal it had.
  • Gates (check-runs on 2aaea77a, as read): 13 success (including Check Changeset), 15 skipped, and 14 in progress (Build Core, Build Docs, Live E2E UI, Plan Test Core shards, every Lint lane, every Type Check lane). No failure, and Test Core has not started. The code gates have no verdict on this head yet, so the merge waits on them.

Implemented-by: claude/project-thread-vlkibi
Reviewed-by: session_01L9qibzuZJBQY4wUQFJbkfx

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#7 · os-tesla · session_01L9qibzuZJBQY4wUQFJbkfx

维护者速读 · PR #33123 @ 2aaea77a · 2026-11-13T16:58Z

  • 改了什么:上传链接可以只指定对象和文件字段、不指定记录。用户上传后,智能体用返回的 fileIds[0] 调 create_record(或 update_record),就能建出带必填文件字段的记录,例如报销明细加必填电子发票,只需两次智能体调用加一次浏览器上传。required 规则不变。
  • 为什么改:以前链接必须先有记录,记录又必须先有文件,智能体因此建不出这类记录(你的裁决 A,6844207600)。
  • 权限与边界:签发链接时,要求该用户能创建该对象、能写该字段、字段不是只读。链接仍是登录用户、单人、10 分钟过期、一次性(MCP cannot read or attach files: no tool downloads an attachment (e.g. a policy PDF to analyse) and none attaches one (e.g. a photographed invoice) to a record #30892 裁决 B)。上传的文件在还没有被任何记录占用前,只能由上传者在一小时内放进该对象该字段的一条记录,也只有上传者能下载。别人的写入、系统写入、别的字段、第二条记录、超时,都在字段上被拒。被记录占用并释放之后,它就是一份普通文件。
  • 风险与回滚:这是一处放宽,只新增了调用形态。已有调用和已有文件的判法不变,回滚就是 revert。上传后一直没被引用的文件目前不会回收,与控制台上传后放弃保存是同一类问题,已立卡 storage: a committed upload that no record ever names is never reclaimed (new path: MCP pre-record upload links) #33125。
  • 先看:pre-record-upload.ts(绑定与判定);record-file-access.ts 的 createUploadLinkForNewRecordAs;验收在 showcase-mcp-record-files.dogfood.test.ts 末尾新增的 describe。
  • 需要你做的:无,席位落地。
  • 席位意见:落地。两轮契约复审,首轮的应修项(绑定比占用活得久)已修好,增量复审 PASS;CI 全绿;没有碰受管面,改动 1448 行。

席位核对

  • 形态: draft → main,正文第 4 行 Fixes #32686,合并后应当关卡,正文其余地方没有挨着别的 open 卡号的闭合关键词。Clause-②: yes (widening)、Metadata-protocol: none,Skills-docs: updated here(served skill-md.ts、connect-mcp.mdx、system-context.mdx 47e/47f、plugin-endpoints.mdx 的 PUT 行,四页的句子都对照代码核过,见复审记录 ③)。changeset 32686-upload-before-record.md 三个包都是 patch(Metadata-protocol none 的等级轴;minor 已在 042bdb52 改正)。没有改 content/docs/releases/。文件面 = 认领 6855856900 加修订 6856718179、6857811650 与 47f 那一行的修订。
  • 前提实测: 卡上三个读数,dev 在 origin/main 2c98485d 上重新测过(报告 6857711797);派发前的形状提案 out/32686-proposed-shape.md 由席位对照裁决 A 核过。
  • 门禁 check-runs @ 2aaea77a: 57 个,40 success、17 skipped、0 失败(Lint & Repo Gates、TypeScript Type Check、Test Core 1–8/8、Dogfood Regression Gate、Check Changeset 都是 success)。本地:service-storage 82/82 文件,dogfood 18/18,101 个派生门禁加 3 个 roster 门禁 exit 0(--ran 0 NOT-MEASURED),返工后 11 条消融全部转红并已恢复。
  • 契约复审: 首轮 6857928485 在 a9a6589d 上 PASS(TIER_DEFAULT,declaration 面;042bdb52/7f41ed5f 只动 changeset 与文档,记了 Regen-provenance),应修 F1、F2,nit F3–F6。增量复审 6858877271 在 2aaea77a 上 PASS:F1、F3、F4、F5 已修,F2 立卡 storage: a committed upload that no record ever names is never reclaimed (new path: MCP pre-record upload links) #33125,F6 由席位改了 PR 正文的 Clause-② 行。
  • 接受的偏差: connect-mcp.mdx 里「第二条记录被拒」没有写出系统写入会拿到副本这一情形(nit,47f 已写明);同一会话为读取复审记录用了一次非检索的 gh 读,没有写入。
  • 范围外去向: 孤儿文件永不回收 → filed storage: a committed upload that no record ever names is never reclaimed (new path: MCP pre-record upload links) #33125;dev 私下报的另一项 → 已转安全席位私下处理,不在此处展开。
  • 落地条款: 维护者常设落地令 「按 pm-dispatch 审过的pr你可以自主落地」 (2026-10-30T14:20Z)。非受管面(check-governed-merges --pr 33123: 0/21 命中),1448 行 ≤ 3000。K = 1(PRBASE 5c005e0e,取自 Test Core 计划的 Affected-set diff base;origin/main 5b2ec820),< 15,无需先 merge main。没有新的语种包。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation 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.

[Decision] How should an MCP agent create a record whose required file field must be filled (e.g. an expense line with a required e-invoice)?

2 participants