Repository navigation
feat(service-analytics, plugin-security, driver-odata): compile, resolve at the record, and refuse the SharedRecordIds leaf (ADR-0155 step 5) - #35945
Conversation
…lves it at the record, OData refuses it (ADR-0155 step 5) - service-analytics: the native read-scope compiler compiles a placed read-form leaf to its sys_record_share subquery, built from the leaf's fixedInnerReadOf description with every value bound, and refuses any other leaf in D4's envelope (INTERNAL_ERROR / 500, logged once). The native strategy declines a leaf scope unless the host answers fixedReadLeafClassOf with null for each leaf on a known dialect. The engine-bound merges admit the brand, the /analytics/sql echo prints the subquery, and a leaf in a query's where is refused in either spelling. - plugin-security: explain resolves each leaf in the sharing read filter at the judged record, one sys_record_share read per batch, so the published rowFilter is [recordId] in the share arm or leaves it out, and never carries the leaf. - driver-odata: find and count refuse the leaf before any request. - spec: parseFilterAST refuses a leaf in an array-form in / nin with INTERNAL_ERROR / 500 instead of INVALID_FILTER / 400. - objectql: export fixedReadLeafClassOfEngine and driverEvaluatesFixedReadLeaf from the seam module. Claude-Session: https://claude.ai/code/session_01L9qibyXo4gSy8DJPNz4ANz Co-authored-by: Claude <noreply@anthropic.com>
…ord the explainer test's engine double check:logger-receiver-detach read sink.log as a log channel passed as a callback; the field holds a logger object, so it is named logger. check:engine-double-contract asked the ledger to record the findOne double that explain-fixed-read-leaf.test.ts pins. Claude-Session: https://claude.ai/code/session_01L9qibyXo4gSy8DJPNz4ANz Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 5 package(s): 38 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 13 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 178 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 # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin c3cf43a657651ad1cec7ecd0108a4d8fd86a0194 && git checkout c3cf43a657651ad1cec7ecd0108a4d8fd86a0194
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 7de1bad5cbf752608dc6426621ace86c852b21af 74cac048492c37f8be30631dbef4b0d5ab441ade && git checkout -B drift-repro 7de1bad5cbf752608dc6426621ace86c852b21af && git merge --no-ff 74cac048492c37f8be30631dbef4b0d5ab441ade
node scripts/docs-audit/affected-docs.mjs --json 7de1bad5cbf752608dc6426621ace86c852b21af
|
|
repo:objectstack#7 · os-tesla · session_01L9qibyQBB3KuDoNobNq9LH L1: REWORK at
|
…class answer in this release The analytics bullet now says the shipped default: AnalyticsServicePlugin wires no fixedReadLeafClassOf answer, so on every host today the native path declines a scope carrying the leaf and the engine path answers. Claude-Session: https://claude.ai/code/session_01L9qibyXo4gSy8DJPNz4ANz Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#7 · os-tesla · session_01L9qibyXo4gSy8DJPNz4ANz Contract-review-claim: session_01L9qibyXo4gSy8DJPNz4ANz · head 103f93b · 2026-11-20T22:16Z L1 7051798358 asked for this review to start on the code while its prose item lands; this head carries that item. The CONTRACT_REVIEW_TIER review runs as an isolated sub-agent of this card thread; its record and the filled brief follow on this PR. |
… explainer's wire check pins of their own An ablation of the where guard left the array-form in spelling refused by parseFilterAST, so each spelling is now its own test and names the where face's evaluator. The unbranded array-form 400 and the explainer's no-leaf-on-the-wire check move out of the tests whose earlier assertions failed first under ablation. Claude-Session: https://claude.ai/code/session_01L9qibyXo4gSy8DJPNz4ANz Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#7 · os-tesla · session_01L9qibyXo4gSy8DJPNz4ANz Contract reviewServed-tier: PR #35945, card #35874 (ADR-0155 plan step 5). Read with Head. The review was done file by file at Scope decision. Inputs read: the card body and its five comments (triage 7042520953, ruling 7047007471, claim 7048435857, dev report 7051244258, claim amendment 7051811974); the PR body, its three issue comments (L1 7051798358 among them) and its file list; ADR-0155 D-0, D1, D2, D4, D5, D6, Q2 with its census and costs, Consequences, Open items and the plan; ruling record 6942854600; the check-runs on the head. ① Derived judgmentsGate verdicts (check-runs, read at 2026-11-20T22:39Z):
Accept-set and public-surface changes the diff implies:
② Semver level
Clause-②: yes — correct, and present on both the PR body and the changeset. It carries no arm, which is right: no accept set narrows (every changed input was already refused) and none widens for an author. Not breaking, so no ADR-0087 disposition is owed. The changeset states the shipped default (the platform's own analytics plugin wires no class answer), which was L1's required item 1. One sentence of the changeset is not what the code does: " ③ Boundary flags
④ Design judgmentNo must-fix. Two findings owe a delta review; both sit in fault states no producer reaches today, and both are places where the code does not do what its own contract sentence says. S1 (should-fix) —
S2 (should-fix) — the explainer admits a leaf by the key it sits under, not by its role, so it resolves leaves the seam and the analytics compiler refuse.
What I tried to break and could not:
Nits, none moving the head:
Implemented-by: VERDICT: PASS |
|
repo:objectstack#7 · os-tesla · session_01L9qibyXo4gSy8DJPNz4ANz The filled brief the CONTRACT_REVIEW_TIER sub-agent reviewed under (record above): Contract review brief — PR #35945 @
|
…dmit it in the explainer by role parseFilterAST moved only the shape door's refusal of a condition carrying a fixed-read leaf to D4's envelope. A leaf as an in / nin list member, or as a scalar operator's comparand (!=, > and the rest), passed the shape door and met the type door outside the try: INVALID_FILTER / 400, with a message printing the head of the leaf's JSON. Either door's refusal of such a condition is now INTERNAL_ERROR / 500, naming the leaf and its table only. An unbranded copy keeps 400. The jsdoc and the message no longer claim the leaf is refused in every position (an array-form = is passed on by reference, as before). The explainer admitted a leaf by the key it sat under: any $in under a key named id, at any depth, inside a relation condition or a composed ReadableIds scope too. It now walks roles, as the engine's seam and the analytics compiler do: only an operator map's $in under id, in the explained object's own filter, holds a leaf it resolves; any other leaf is refused in D4's envelope. Pins: spec, a list member and two scalar operators at 500 and their unbranded copies at 400; objectql, both through the engine's find; the explainer, a leaf inside a relation condition and inside a composed scope. Claude-Session: https://claude.ai/code/session_01L9qibyXo4gSy8DJPNz4ANz Co-authored-by: Claude <noreply@anthropic.com>
…g lands, whichever release that is The clause said the platform's analytics plugin wires no answer "in this release". The wiring is being built now and may ship in the same release, so the clause now states what this change ships (the hook unwired, the native path declining, the engine path answering) and that it holds until the wiring lands. Claude-Session: https://claude.ai/code/session_01L9qibyXo4gSy8DJPNz4ANz Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#7 · os-tesla · session_01L9qibyQBB3KuDoNobNq9LH L1 delta: ACCEPT at
|
|
repo:objectstack#7 · os-tesla · session_01L9qibyXo4gSy8DJPNz4ANz Contract reviewServed-tier: DELTA review from The delta is a fast-forward of two commits, 6 files, +172 / −60 (
Every other file of the earlier record's ① Derived judgmentsGate verdicts (check-runs on this head, read at 2026-11-21T00:14Z): 60 success, 13 skipped, none failed, none cancelled, none in progress. The Accept-set and public-surface changes in the delta:
No export, schema key or operator is added or removed by the delta. ② Semver levelUnchanged and correct: Clause-②: yes — still correct, with no arm. Both lines are on the changeset, and The three reworded changeset bullets now say what the code does:
③ Boundary flags
④ Design judgment
No must-fix, no should-fix. What I tried to break in the delta and could not:
Nits carried from the earlier record, none moving the head:
Implemented-by: VERDICT: PASS |
|
repo:objectstack#7 · os-tesla · session_01L9qibyXo4gSy8DJPNz4ANz Landing · 2026-11-21T00:16Z · head
|
| Probe | Reading |
|---|---|
check-governed-merges.mjs --pr 35945 |
NOT governed: 0 of 22 paths hit the register; 1,766 changed lines ≤ 3,000 |
landing-k.mjs --pr 35945 |
K = 0 < 15; no new locale pack; no shared book moved |
overlap-check.mjs |
clean against origin/main; #35954 (stacked on this branch) and #34817 merge cleanly |
| Reviews on this head | L1 delta ACCEPT 7053458192 (after REWORK 7051798358); L2 CONTRACT_REVIEW_TIER PASS 7052365884 (S1, S2) and delta PASS 7053910455 on this head, S1: closed, S2: closed, no must-fix, no should-fix (nits N1–N4 carried); brief 7052376691 |
| Check-runs on this head | 60 success, 13 skipped by their own selectors, 0 failure |
State: needs:contract-review removed; ready + auto-merge armed by this stroke. On merge, #35874 closes by Fixes; its close-out follows. B1 (the analytics hook's wiring) is #35946 / PR #35954, stacked here; #33787 is Blocked-by it.
#35945 merged as a squash, so the stacked base's add of the shared test file met main's add. Main's copy equals the stack base's, so the branch's copy is kept. The PR's own delta is unchanged (patch-id 4593e0103a). Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibwJEh7hMPPvagWM1g7
Requested by Tesla · project thread
Fixes #35874
Refs #33787
Clause-②: yes
The explainer's published sharing-layer
rowFilterchanges content (ADR-0155 Q2 costs: the share arm is the judged record's id when a grant admits it and is left out otherwise, and never the leaf), and the analytics merges admit theSharedRecordIdsbrand at a second door.packages/specchanges too (B6):parseFilterASTanswers a leaf it refuses in the array form (anin/nincomparand, anin/ninlist member, a scalar operator's comparand) withINTERNAL_ERROR/ 500 instead ofINVALID_FILTER/ 400.Metadata-protocol: none
维护者速读
Read first (by risk)
packages/plugins/plugin-security/src/explain-fixed-read-leaf.ts: the leaf resolved at the record and the copy-on-write substitution that drops an emptied$orarm. This is the Clause-② content change.packages/services/service-analytics/src/read-scope-sql.ts:findUnservedFixedReadLeaf(the role-aware walk) andfixedReadLeafSubquerySql(every value bound, thetenantScope: 'none'check).packages/services/service-analytics/src/strategies/native-sql-strategy.ts:readScopeCarriesUncompilableFixedReadLeaf, the fail-closed decline.Two-minute check
pnpm --filter @objectstack/service-analytics exec vitest run --maxWorkers=2 src/__tests__/fixed-read-leaf-native-compile.test.ts. Expect 31 passed: 11 conformance rows matched live on SQLite, 4 refused, and the native statement agreeing with the engine path.What changes
compileScopedFilterToSql). A read-form leaf placed as{ id: { $in: leaf } }on the scope's own object compiles to"id" IN (SELECT "record_id" FROM "sys_record_share" WHERE "object_name" = ? AND "recipient_type" = ? AND "recipient_id" = ? AND ...), closed by the blank-id guard onrecord_id(not null, not the empty string). It is built from the leaf's ownfixedInnerReadOfdescription, binds every value, and puts no tenant scope on the subquery (① ruled A). Any other leaf is refused in D4's envelope (INTERNAL_ERROR/ 500, logged aterroronce per service logger): one placed elsewhere, under$nin, on another object, or in its write form.NativeSQLStrategy.canHandledeclines a scope carrying a leaf unless the host'sAnalyticsServiceConfig.fixedReadLeafClassOfanswersnull(neither of D4's two classes) for every leaf and the dialect is known. A missing hook, a throwing hook, or any other answer also declines. The engine path then answers. This change ships the hook unwired:AnalyticsServicePluginpasses no answer, so the native path declines a scope carrying the leaf and the engine path answers, until [Decision] ADR-0155 step 5: how the analytics native compiler asks the engine seam which objects decline the share-grant leaf #35946 wires it.withReadScope, the related-object scope and the plugin's label read passadmitFixedReadLeavestoassertReadScopeComparandsRunnable, which refuses an unplaced leaf first and then admits the placed one.ObjectQLStrategy.generateSqlprints the subquery.where(compile surface 2). A leaf anywhere in a query'swhere, in either spelling, is refused in the envelope before either strategy runs.resolveFixedReadLeavesAtRecordreplaces each leaf in a copy of the sharing read filter with[recordId]or[], from onesys_record_shareread underfixedInnerReadOf(leaf), keyed by the judged ids. A batch makes one read per leaf, keyed by every id. An emptied$orarm is dropped, and an$orleft with one arm is that arm. A leaf it cannot resolve is refused, logged once, and so is a leaf anywhere but{ id: { $in: leaf } }in the object's own filter: the walk reads roles, as the engine's seam and the analytics compiler do, so a leaf inside a relation condition or a composedReadableIdsscope is refused. A failing share read is the read filter failing: the record is not visible, and norowFilteris published.findandcountrefuse the leaf before any request,INTERNAL_ERROR/ 500.parseFilterASTrefuses a leaf that either of its doors refuses withINTERNAL_ERROR/ 500: the shape door (an array-formin/nincomparand) or the type door (anin/ninlist member, a scalar operator's comparand such as!=or>). The message names the leaf and its table, not the recipient. An unbranded copy keepsINVALID_FILTER/ 400.index.tsexportsfixedReadLeafClassOfEngineanddriverEvaluatesFixedReadLeaffromfixed-read-leaf-seam.ts.engine.tsis untouched.Compile surfaces (one conclusion each)
compileScopedFilterToSql: changed here. Compiles the placed read form and refuses the rest. Pinned againstSHARED_RECORD_IDS_CASE_SETlive on SQLite: 11 cases answer exactly their rows, the 2 write-form cases are refused 500, and the 2 composed cases are refused 500 with no composition run.lowerAnalyticsWhere: changed here. At 17ed9e7, before this change:{ id: { $in: leaf } }answeredINVALID_FILTER/ 400 and printed the recipient; a bare{ id: leaf }and an array-form=were lowered to{ kind: 'relation', member: 'id', condition: { object, recipient } }. Now every spelling answers 500 with no recipient. No producer writes a leaf into awhere: the leaf enters analytics only as the read scope.assertReadScopeComparandsRunnable: changed here. Admits the brand only for a caller that passesadmitFixedReadLeaves. Without it the answer isREAD_SCOPE_COMPILE_FAILED/ 500, as before (pinned).beforeFindhook onsys_record_share, it declines and the engine's seam refuses 500.ObjectQLStrategy.generateSqlthroughcompileScopedFilterToSql: changed here. Prints the subquery (pinned). It does not consult the class recognition: it describes the statement and runs nothing.matchUnderDeclaredColumns: changed here. Leaves are resolved before the match, inapplyRecordAttribution.driver-odata: changed here. The refusal sits besiderefuseReadableIds.driver-mongodbtranslateFilter: out of scope (frozen under [裁决] driver-memory / driver-mongodb 投入冻结 —— 维护者 2026-08-05 口径(跨单锚点) #5499). Its R1 is the step-2 seam:fixed-read-leaf-seam.ts#passFixedReadLeavesrefuses any leaf bound for a driver whosesupports.fixedReadLeavesdoes not list it, before the driver is asked.driver-memory: out of scope (ADR-0155 step 4 (driver-memory): evaluate the share-grant leaf in process, on reads and the predicate update path #35873 on hold). The same seam refusal applies.formulamatchesFilterConditionand objectqlapplyHaving/matchesHaving: already compliant. The engine's having door refuses a leaf beforeapplyHavingruns (engine-delete-and-aggregate.ts:atFixedReadLeafDoor(this, () => assertListComparandShapes(object, 'aggregate', query.having, 'having'))).matchesFilterConditionsees a sharing read filter only through the explainer, which now resolves the leaf first. The write tenant wall's call matches tenant checks only.driver-sql/ Turso: already compliant (step 3, 643fe3b).Acceptance notes
service-analyticshas no runtime dependency on@objectstack/objectql, and no route that adds no package edge lets the plugin ask the seam. So this PR ships the hook (AnalyticsServiceConfig.fixedReadLeafClassOf) and the fail-closed decline, and leaves the hook unwired inAnalyticsServicePlugin. Until [Decision] ADR-0155 step 5: how the analytics native compiler asks the engine seam which objects decline the share-grant leaf #35946 wires it, the native path declines a scope carrying a leaf on every host and the engine path answers, with the right rows. Nothing writes the leaf before step 6, so nothing changes today. [Decision] ADR-0155 step 5: how the analytics native compiler asks the engine seam which objects decline the share-grant leaf #35946 carries the wiring fork, and it lands before step 6.admitFixedReadLeavestoassertReadScopeComparandsRunnable: the two merges, the label read, andcompileScopedFilterToSql. The last is the native compiler's own door. It admits only what it compiles, and Q2 ruled that the native compiler compiles the leaf. This reads as Q2's ruled consequence, so no ADR amendment is needed. The seat may file a pointer note.the authoring lowering refuses the leafinshared-record-ids.test.ts, which pinned exactly that branch. The new pin asserts 500, the message, no recipient, and that the unbranded copy keeps 400. Neither the spec refusal nor the where-face refusal is logged: neither function holds a logger (the same precedent asdriver-odata'srefuseReadableIds).textid([Decision] ADR-0155 O2: the share-grant subquery on PostgreSQL for an object whose id is not text (integer, uuid) #35906, open): mirrors step 3'sdriver-sql. No cast on the subquery.INVALID_FILTER/ 400, and its message prints the leaf's inputs. Step 2 pinned that as the refusal those callers had before the leaf. No caller here can reach it with a branded leaf.Tests
The five new or changed test files ran at 65d8e8f, the rebased head. The service-analytics file and its typecheck ran again at 646a10e, after the sink field was renamed. Other runs are marked.
New and changed test files
service-analytics src/__tests__/fixed-read-leaf-native-compile.test.ts: Test Files 1 passed, Tests 27 passedplugin-security src/explain-fixed-read-leaf.test.ts: Tests 7 passeddriver-odata src/odata-driver.test.ts: Tests 34 passedobjectql src/engine-fixed-read-leaf-seam.test.ts: Tests 68 passedspec src/data/shared-record-ids.test.ts: Tests 30 passedPackage suites and typecheck
typecheck: spec, objectql, service-analytics, plugin-security and driver-odata all exit 0.typecheckpassed, objectqltypecheckpassed, and the plugin-security suite passed: 285 files, 7079 tests (45 skipped).Ablation (committed first, restored to the HEAD blob)
scripts/ablation-replace.mjsreplacedfind'srefuseFixedReadLeaf(query.where);inodata-driver.tswith a marker. The anchor went from 1 to 0 and the blob from d5cb1fece2b0 to a4af98f3458f. On-disk marker count 1; the refusal call count fell from 2 to 1.findcase red, everycountcase green.findreturned rows ({ code: undefined, status: undefined }) instead of refusing, which is B5's pre-change behaviour: the predicate was left out of the$filtersent.git diff HEADempty.Verification
node scripts/pm/dispatch-gates.mjs --commandsover the diff at 646a10e: 112 derived families. 110 exit 0. 2 exit 3, PREREQUISITE NOT MET, read as NOT MEASURED:check:dual-build-cjs-loadsneeds every workspace package'sdist/, andcheck:i18nneeds the workspace CLI built.--ranreconciliation: 112 derived, 110 run, 2 NOT-MEASURED, 0 UNRUN.check:logger-receiver-detachread the refusal sink'slogfield as a log channel passed as a callback, so the field is nowlogger.check:engine-double-contractneeded--writeto record the new explainer test'sfindOnedouble inscripts/engine-double-contract.pinned.json.node scripts/pm/overlap-check.mjs: clean against origin/main 17ed9e7 and fix(audit): a search the server widens never names a column the caller may not query #34817, which sharesobjectql/src/index.ts.Generated by Claude Code