Repository navigation
fix(service-storage): scope the sys_file / sys_upload_session update and delete doors to the acting organization (#13178) - #13527
Conversation
…and delete doors to the acting organization (#13178) The four un-repaired halves of the two inserts #12745 and #12928 fixed: `updateFile`, `deleteFile`, `updateSession` and `deleteSession` now take the same optional `StorageWriteContext` the create doors take, and the upload routes pass it -- two of them had already resolved the session and discarded it. On these verbs the context SCOPES rather than stamps (`applyTenantScope`, not `injectTenantOnInsert`), so another organization's row stops being reachable while `organization_id IS NULL` rows stay in reach -- which is what keeps the pre-#12928 population, deliberately not backfilled, from being stranded. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F3jdziLbAPGeceVNmSox5L
📓 Docs Drift CheckThis PR changes 1 package(s): 7 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 5 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 6 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older
|
|
PM review — ACCEPT, with landing held until CI converges (25 success · 2 skipped · 6 still running · 0 red at time of writing; What I verified myself, on the diff and on
|
…over (objectui#13497) (#13527) <!-- claude-projects-attribution: {"github_login":"os-tesla"} --> _Requested by **Tesla** · [project thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoTQxYKRxtUGN5xTm23ThWwo)_ Fixes #13497 Part of #25677 Clause-②: no Metadata-protocol: none ⛔ **Governed surface (`.github/workflows/**`, Tier H).** This PR stays a draft until an APPROVED review from an authorized approver (os-zhuang or hotlong) is on record; the merge-queue leg of the Governed Surface Queue Guard refuses it otherwise. No agent seat approves it; the dispatch seat lands it after the approval. ## 维护者速读(草稿) - **改了什么:** 把 `dependabot-auto-merge.yml` 的唯一 job 关掉(`if: false`),只改这一个文件,文件头写明原因和怎么恢复。 - **为什么改:** 这个 job 用 GITHUB_TOKEN 把 Dependabot PR 放进合并队列。GitHub 不会为 GITHUB_TOKEN 触发的事件启动 workflow,所以这个合并组永远没有检查在跑,要等约 63 分钟超时才被踢出;排在它后面的所有 PR(包括 objectui→objectstack 合并的各张卡)都干等。Dependabot 每次 rebase 都会重来一次。今天 10:54Z 又一次:#13438 的合并组 0 个 run,排在后面的 #13515 合并组 5/5 已绿,在等它。 - **风险与代价(含回滚):** 合并之后到 cutover 归档之前,Dependabot PR 不再被自动批准、入队或评论;要落某个 Dependabot PR 就手动入队。没有新增 secret,没有缩短队列超时,没有删任何 required check。回滚 = 把 job 的条件改回 `github.actor == 'dependabot[bot]'`(文件头写了),或者 revert 这个 PR。 - **席位意见:** - **你要做的(一个动作):** 读完 diff 后在本 PR 点 Approve。 ## What changes One file, `.github/workflows/dependabot-auto-merge.yml`: - The `dependabot` job's condition becomes `if: false`, with a one-line pointer to the header. - A new header block says why the job is off, what the ruling ruled out, and how to turn it back on (restore `github.actor == 'dependabot[bot]'`, and fix the GITHUB_TOKEN enqueue first). - Every step is left as it was. Nothing else in the repository changes. ## Why The job's last step enqueues with `gh pr merge --auto --squash --match-head-commit` under `GITHUB_TOKEN`. GitHub starts no workflow run for an event that `GITHUB_TOKEN` caused, so the merge group gets no `merge_group` runs, its required checks never report, and it holds the head of the queue until the check timeout removes it. The card's measurements (the third removal, still pending when the card was filed, is read from #13438's timeline): | enqueued (`added_to_merge_queue`, by `github-actions[bot]`) | removed (`removed_from_merge_queue`) | held | |---|---|---| | 2026-10-24 05:31Z | 06:35Z | 64 min | | 2026-10-24 23:16Z | 2026-10-25 00:19Z | 63 min | | 2026-10-25 02:34Z | 03:34Z | 60 min | A fourth cycle was live while this PR was written: Dependabot force-pushed #13438 at 10:40:58Z, `github-actions[bot]` enqueued it at 10:54:47Z, and at 11:55Z its merge group (`gh-readonly-queue/main/pr-13438-…`, head `6523401e4b`) had **0** workflow runs, while the group right behind it (#13515, enqueued by the fleet App) had **5 of 5** runs at `success`, waiting. The triage ruling on #13497 (comment 6393154205) chose the cheaper of the card's two ways, because this repository is archived at the #25677 cutover: stop enqueuing Dependabot pull requests from Actions, by dropping the enqueue step or disabling the workflow until cutover. ⛔ No App or PAT secret, no shorter queue timeout, no dropped required checks. ### Why the whole job, not just the enqueue step Both forms were measured against the tests that read this workflow: | Form | `scripts/__tests__/dependabot-merge-gate.test.ts` | |---|---| | Delete the "Enqueue for merge" step only | **2 failed** / 33 passed: "has no `gh pr merge` that is not behind a green gate" (its anti-vacuity count reads 0) and "runs the gate script and tells it which SHA to judge" (no `--match-head-commit` left) | | `if: false` on the job (this PR) | 35 passed | Dropping only the step would mean rewriting those two pins as well. It would also keep the gate running on every Dependabot rebase in the cutover window: one runner polling for up to 40 minutes, only to approve a pull request that nothing enqueues. With the job off, the workflow stays as it is, and the tests that pin it don't change. ## Verification (local, head `b3d92a46a4`) | Gate | Exit / verdict | |---|---| | `node scripts/check-governed-queue-guard.mjs --test .github/workflows/dependabot-auto-merge.yml` | 3 = GOVERNED (`.github/workflows/**` x1), as expected | | `node scripts/check-changeset-presence.mjs` | 0, no changeset owed | | `check-control-bytes`, `check-action-ref-convention`, `check-pre-install-import-graph` (`--self-test` and run), `check-shell-escape-residue`, `check-governed-queue-guard --self-test`, `check-required-check-set --self-test`, `check-bash32-floor`, `check-new-cross-file-line-citations`, `check-doc-links` | 0 each | | vitest, the four `scripts/__tests__` files that name this workflow | 0 (159 tests) | | vitest, all of `scripts/__tests__` (under `os-verify-lock`) | 1: 5863 passed, 3 failed, all `Test timed out in 15000ms` in files that do not read this workflow (`check-i18n-dead-keys`, `check-vi-mock-inherit`, `dollar-dialect-alias-census`); the same three files re-run alone on this head: 0 (259 tests) | | YAML parse of the edited file | job `if` is the boolean `false`; 10 steps, unchanged | What can't be tested on this PR: the workflow triggers only on a Dependabot pull request, so this PR can't run the changed job. The check comes after the merge: the next Dependabot force-push should produce a skipped `dependabot` job and no `added_to_merge_queue` event. ## Acceptance notes - Prose elsewhere still says this workflow approves and enqueues: `content/docs/guide/ci-cd-pipeline.md` (workflow table row and the "Dependabot Auto-Merge" section), `AGENTS.md` (the governed-surface list and the merge-queue paragraph), the `dependabot-auto-merge.yml` reason in `scripts/check-action-ref-convention.mjs`, and header comments in `scripts/dependabot-merge-gate.mjs` and `scripts/check-governed-queue-guard.mjs`. Not changed here: the card's scope is the workflow, and the repository is archived at cutover. These are reported to the dispatch seat. - Fixing this doesn't clear the current queue head. The #13438 entry enqueued at 10:54:47Z stays until its timeout, or until a maintainer removes it from the queue. - [x] Adds no product-specific widget, dialog, hook or string (see AGENTS.md › Product-neutral renderer) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Session: `https://claude.ai/code/session_01DqwYJmM7nGqhoj84ZUJ9Cz` Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: os-zhuang <jack@objectstack.ai>
Fixes #13178
Repairs the four half-repairs the maintainer's 2026-08-30 ruling (第 5 场总监席决裁批 #7, verbatim 「批 #7 同意」) narrowed this card to: the
updateanddeletesiblings of the two inserts #12745 and #12928 already fixed. Nothing else in the census's 24 context-less call sites, and nothing in the 175, is touched.How the four sites were located
The ruling's own execution note forbids copying its line numbers, so they were re-derived against today's tree. Input: the census
os-dev-report(comment 5468253235), which names each site by file, verb and object — never relied on for a line number. Resolution, run in the worktree at merge basebcef1cfac:That enumerates all eight engine calls the store issues, which is what makes the pairing checkable rather than asserted: the two
insertcalls carry an options bag and the fourupdate/deletecalls did not.metadata-store.tsupdateFilesys_filemetadata-store.tsdeleteFilesys_filemetadata-store.tsupdateSessionsys_upload_sessionmetadata-store.tsdeleteSessionsys_upload_sessionAll four were still unfixed at merge base — verified by that enumeration, not assumed from the census.
What #12745 / #12928 did, and how this matches
Both landed the same three-part shape (
c94be6291d,2ff01cf7fa): an optionalStorageWriteContextparameter on the store method;writeOptionsFor(context)folded onto the engine options bag; and the acting organization threaded at the route. This PR is that shape on the remaining four verbs — same helper, same{ context: { tenantId } }spelling, same "absent means absent" rule where a caller with no organization produces the byte-identical pre-repair call.One thing genuinely differs, and it is documented rather than glossed. Write-side tenancy in the SQL driver is two mechanisms wearing one option: on insert
injectTenantOnInsertSTAMPS the tenant column fromoptions.tenantId; on update and deleteapplyTenantScopeSCOPES the statement with it. So the same bag buys a value on one verb and a reach on the other. Consequences, both measured in the new suite:organization_id IS NULLrow stays reachable, because the driver's term is(organization_id = :tenantId OR organization_id IS NULL)— Freshobjectstack devboot: tenant admin sees ZERO rows in sys_position / sys_permission_set / sys_business_unit over REST (Setup Access Control renders empty) #2734's global-row fail-open. That is load-bearing here: multi-org:sys_upload_sessionis never org-stamped either —StorageMetadataStore.createSessioninserts without a context #12928 was ruled forward-stamp-only, so the entire pre-multi-org:sys_upload_sessionis never org-stamped either —StorageMetadataStore.createSessioninserts without a context #12928 session population is NULL by decision and strict equality would have stranded it mid-upload.Because the meaning differs, the engine-absent
Mapstand-in is deliberately NOT changed.createFile's stand-in records a value so a later read can return it; there is no value to record on these verbs, only a reach to enforce, and enforcing a tenant wall over a process-local Map would stand up a second isolation mechanism outside the driver that owns the real one.Scope fences, discharged
auditMissingTenantis untouched —packages/drivers/driver-sql/**has no diff in this PR at all. The reading thatisSystemwrites return at thebypassTenantAuditguard one step before the posture gate is the class-level diagnosis, and it is not acted on here.isSystemwrites belong in this control scope at all is a question this PR neither answers nor leans on.packages/specchange, no ADR, no release notes, no test skipped or re-baselined.Paths touched, declared in full
packages/services/service-storage/src/metadata-store.tspackages/services/service-storage/src/storage-routes.tspackages/services/service-storage/src/tenant-audit-update-delete-half-repairs.test.tsscripts/engine-double-contract.pinned.jsonNew pinned coverage is GOOD … the ledger just has to learn about it); written with--write,0 lost.changeset/tenant-audit-update-delete-half-repairs.mdminor— argued in the changeset bodyDocs-drift advisory — read, and NOT falsified
The drift run flags
content/docs/permissions/attachments-access.mdxas carrying bothsys_fileandsys_upload_session. I read the page in full (141 lines). It is accurate as written and nothing was changed.Its three subjects are the
sys_attachmentparent-derived access model (create / read / delete on the join row), the download gate, and the ADR-0057 storage-byte lifecycle. This PR touches none of them: nosys_attachmentpath, no download endpoint, no reap guard. The two doors it changes are upload-side writes on the metadata rows.The decisive reading is an absence, so it is measured rather than asserted:
grep -icE "organization|tenant|multi-tenant|org "over that page returns 1, and the single hit is the phrase "org logos" in a list of non-attachments file examples. The page makes no tenancy claim at all, so there is nothing on it for an organization-scoping change to contradict. Its nearest sentence — the upload entry points "stampowner_idon the newsys_file" — is about the insert and aboutowner_id, both untouched.The four release-owned pages in the same advisory were read but not edited (they are read-only in a code PR). A targeted cross-grep for any claim pairing these two tables with organization or tenant scoping returns zero rows across
content/docs/releases/*.mdx. The one v17 line naming asys_file/sys_upload_sessionwrite is the #5216 durability correction ("a write that never landed stops reporting success"), which this PR does not touch. No release page is wrong, so there is nothing to file as a docs-only card.Verification
Union re-run after the final commit, at
e02648ef1b. Every heavy run went throughscripts/pm/os-verify-lock.sh; the verdicts quoted are the lines that entry point printed, never a bare$?behind a pipe.pnpm --filter @objectstack/service-storage test— 32 files, 506 tests, all pass (21 of them new).tsc --noEmit --pretty false -p packages/services/service-storage/tsconfig.json— 51 errors, exactly thecheck-type-check-coverageledger entry, and 0 of them in any of the three touched files. That entry's note says the margin is gone and the next new error reds on arrival, so this is the load-bearing number.--listFilesconfirms all three files are inside the program — the count is a measurement of them, not a program that excludes them.node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack(change set taken from the merge base by the script itself). Green:engine-double-contract,where-matcher,objectql-double-limit,query-options-erasure,type-check-coverage,cross-package-test-inputs(both invocations),test-source-alias,type-source-resolution,route-envelope,undeclared-dep-imports,logger-receiver-detach,nul-bytes,i18n,i18n-stale-fill,doc-authoring,published-files,slot-lookup,page-declaration-shape,ci-filter-parity,comment-mask-adoption,keyed-text-bounds,plugin-teardown-shape,shard-attestation,changeset-gate-self-tests,objectui-changeset,pm-half-states,adr-0087-registration,changeset-no-major,empty-changeset,release-rehearsal-clone,docs-audit/affected-docs.pnpm lint(eslint . --no-inline-config, repo-wide) — exit 0, no findings, held the lock 67s.pnpm check:i18n— OK, 9 packages, all bundles in sync,service-storageamong them, after its ten-package build closure.engine-double-contract(ledger taught the new pins) andquery-options-erasure(afindOnequery bag was erased toany; typed asDriverQueryinstead, test surface back to 240 at the ceiling).Ablation
Implementation committed first; the mutation stripped
...optionsfrom all four sites, under anEXIT INT TERMtrap with an absolute repo root../metadata-store.js), so the suite reads it from source.@objectstack/driver-sqlis source-aliased by this package's vitest config; nothing mutated resolves throughdist/.git diff HEADempty,git status --porcelainempty over the whole tree.Not measured — stated as not-measured, not folded into green
check:type-check-debt(the ratchet invocation) was not run — it re-runs tsc for every ledger entry and needs the whole workspace closure built, which does not fit the container's foreground ceiling under lock contention. Declared narrowing: the only ledger entry a three-fileservice-storagediff can move was measured directly, with the gate's own invocation shape, and is the 51 above. The rest of the ledger has no path in this diff.check:dual-build-cjs-loadsneeds the Build Core artifacts; left to CI.check-test-completenessandscripts/pm/check-half-states.mjsboth exited with their ownPREREQUISITE NOT METcode (3) — no test log, no token. Neither is a finding.ObjectQLprovescontext.tenantIdreachesDriverOptions.tenantIdon both verbs, and a realSqlDriveron live SQLite proves what that option then does. A single full-stack fixture would be stronger and is not here.organization_idlives in the out-of-tree enterprise middleware, so "the write now carries its tenant" is a statement about the call site.Authored by Claude Code, session
session_01F3jdziLbAPGeceVNmSox5L(recorded in prose because a body edit normalises the footer link).Generated by Claude Code
Generated by Claude Code