Skip to content

feat(service-analytics, plugin-security, driver-odata): compile, resolve at the record, and refuse the SharedRecordIds leaf (ADR-0155 step 5) - #35945

Merged
objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/project-thread-thptm0
Nov 21, 2026
Merged

objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/project-thread-thptm0

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Requested by Tesla · project thread

Fixes #35874
Refs #33787

Clause-②: yes
The explainer's published sharing-layer rowFilter changes 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 the SharedRecordIds brand at a second door. packages/spec changes too (B6): parseFilterAST answers a leaf it refuses in the array form (an in / nin comparand, an in / nin list member, a scalar operator's comparand) with INTERNAL_ERROR / 500 instead of INVALID_FILTER / 400.
Metadata-protocol: none

维护者速读

  • 问题:共享记录权限改造(把共享授权从限量名单改成数据库子查询)的第 5 步,用户无感。
  • 这一步做什么:分析报表能直接编译这种子查询,权限解释器逐条记录判断共享,OData 数据源遇到它明确拒绝。
  • 不做会怎样:切换上线后,仪表盘、分析查询和“为什么我能看到这条记录”的解释会报错或给出不一致的结果;本步改动可整体撤回。
  • 要你做的:无。接线问题(分析服务怎样问引擎“这个对象能否用子查询”)已拆到 [Decision] ADR-0155 step 5: how the analytics native compiler asks the engine seam which objects decline the share-grant leaf #35946,要在第 6 步之前裁定;在那之前,所有环境的分析查询照旧走引擎路径。

Read first (by risk)

  1. 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 $or arm. This is the Clause-② content change.
  2. packages/services/service-analytics/src/read-scope-sql.ts: findUnservedFixedReadLeaf (the role-aware walk) and fixedReadLeafSubquerySql (every value bound, the tenantScope: 'none' check).
  3. 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

  • service-analytics, the native compiler (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 on record_id (not null, not the empty string). It is built from the leaf's own fixedInnerReadOf description, 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 at error once per service logger): one placed elsewhere, under $nin, on another object, or in its write form.
  • service-analytics, the decline. NativeSQLStrategy.canHandle declines a scope carrying a leaf unless the host's AnalyticsServiceConfig.fixedReadLeafClassOf answers null (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: AnalyticsServicePlugin passes 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.
  • service-analytics, the merges and the echo. withReadScope, the related-object scope and the plugin's label read pass admitFixedReadLeaves to assertReadScopeComparandsRunnable, which refuses an unplaced leaf first and then admits the placed one. ObjectQLStrategy.generateSql prints the subquery.
  • service-analytics, the query's where (compile surface 2). A leaf anywhere in a query's where, in either spelling, is refused in the envelope before either strategy runs.
  • plugin-security, the explainer. resolveFixedReadLeavesAtRecord replaces each leaf in a copy of the sharing read filter with [recordId] or [], from one sys_record_share read under fixedInnerReadOf(leaf), keyed by the judged ids. A batch makes one read per leaf, keyed by every id. An emptied $or arm is dropped, and an $or left 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 composed ReadableIds scope is refused. A failing share read is the read filter failing: the record is not visible, and no rowFilter is published.
  • driver-odata. find and count refuse the leaf before any request, INTERNAL_ERROR / 500.
  • spec (B6). parseFilterAST refuses a leaf that either of its doors refuses with INTERNAL_ERROR / 500: the shape door (an array-form in / nin comparand) or the type door (an in / nin list member, a scalar operator's comparand such as != or >). The message names the leaf and its table, not the recipient. An unbranded copy keeps INVALID_FILTER / 400.
  • objectql. index.ts exports fixedReadLeafClassOfEngine and driverEvaluatesFixedReadLeaf from fixed-read-leaf-seam.ts. engine.ts is untouched.

Compile surfaces (one conclusion each)

  1. compileScopedFilterToSql: changed here. Compiles the placed read form and refuses the rest. Pinned against SHARED_RECORD_IDS_CASE_SET live 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.
  2. lowerAnalyticsWhere: changed here. At 17ed9e7, before this change: { id: { $in: leaf } } answered INVALID_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 a where: the leaf enters analytics only as the read scope.
  3. assertReadScopeComparandsRunnable: changed here. Admits the brand only for a caller that passes admitFixedReadLeaves. Without it the answer is READ_SCOPE_COMPILE_FAILED / 500, as before (pinned).
  4. The native decline: changed here (above). Pinned three ways: with the seam's answer, the native statement runs and agrees with the engine path; with no hook, it declines with the same rows; with a beforeFind hook on sys_record_share, it declines and the engine's seam refuses 500.
  5. The dry-run echo, ObjectQLStrategy.generateSql through compileScopedFilterToSql: changed here. Prints the subquery (pinned). It does not consult the class recognition: it describes the statement and runs nothing.
  6. The explainer, matchUnderDeclaredColumns: changed here. Leaves are resolved before the match, in applyRecordAttribution.
  7. driver-odata: changed here. The refusal sits beside refuseReadableIds.
  8. driver-mongodb translateFilter: 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#passFixedReadLeaves refuses any leaf bound for a driver whose supports.fixedReadLeaves does not list it, before the driver is asked.
  9. 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.
  10. formula matchesFilterCondition and objectql applyHaving / matchesHaving: already compliant. The engine's having door refuses a leaf before applyHaving runs (engine-delete-and-aggregate.ts: atFixedReadLeafDoor(this, () => assertListComparandShapes(object, 'aggregate', query.having, 'having'))). matchesFilterCondition sees a sharing read filter only through the explainer, which now resolves the leaf first. The write tenant wall's call matches tenant checks only.
  11. driver-sql / Turso: already compliant (step 3, 643fe3b).

Acceptance notes

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 passed
  • plugin-security src/explain-fixed-read-leaf.test.ts: Tests 7 passed
  • driver-odata src/odata-driver.test.ts: Tests 34 passed
  • objectql src/engine-fixed-read-leaf-seam.test.ts: Tests 68 passed
  • spec src/data/shared-record-ids.test.ts: Tests 30 passed
Package suites and typecheck
  • Suites at the pre-rebase tree: spec 865 files passed, 1 skipped (27797 tests); objectql 624 files, 14169 tests; service-analytics 221 files, 5643 tests (after the surface-2 change); plugin-security 285 files, 7075 tests; driver-odata 9 files, 1455 tests.
  • typecheck: spec, objectql, service-analytics, plugin-security and driver-odata all exit 0.
  • After the rebase, at 65d8e8f: rebuilt the platform-objects and objectql dists and reran the five files above. plugin-security typecheck passed, objectql typecheck passed, and the plugin-security suite passed: 285 files, 7079 tests (45 skipped).
Ablation (committed first, restored to the HEAD blob)
  • Mutation: scripts/ablation-replace.mjs replaced find's refuseFixedReadLeaf(query.where); in odata-driver.ts with 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.
  • Predicted: every find case red, every count case green.
  • Observed: 12 failed, 22 passed. find returned rows ({ code: undefined, status: undefined }) instead of refusing, which is B5's pre-change behaviour: the predicate was left out of the $filter sent.
  • Restore: blob back to d5cb1fece2b0, equal to HEAD; git diff HEAD empty.
  • A first attempt was refused by the tool before it ran any command: its replacement text was a substring of the anchor, so the replacement count could not rise.

Verification

  • node scripts/pm/dispatch-gates.mjs --commands over the diff at 646a10e: 112 derived families. 110 exit 0. 2 exit 3, PREREQUISITE NOT MET, read as NOT MEASURED: check:dual-build-cjs-loads needs every workspace package's dist/, and check:i18n needs the workspace CLI built. --ran reconciliation: 112 derived, 110 run, 2 NOT-MEASURED, 0 UNRUN.
  • At 65d8e8f two gates went red, both from this diff, and both are fixed in 646a10e. check:logger-receiver-detach read the refusal sink's log field as a log channel passed as a callback, so the field is now logger. check:engine-double-contract needed --write to record the new explainer test's findOne double in scripts/engine-double-contract.pinned.json.
  • Line budget: 1632 changed lines (+1611 / −21) in 22 files, under 3,000.
  • 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 shares objectql/src/index.ts.

Generated by Claude Code

…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>
@github-actions github-actions Bot added size/xl documentation Improvements or additions to documentation protocol:data tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 20, 2026
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 5 package(s): @objectstack/driver-odata, @objectstack/objectql, @objectstack/plugin-security, @objectstack/service-analytics, @objectstack/spec, touching 90 documentable anchor(s). ⚠️ 1 changed file(s) yielded no anchor (packages/objectql/src/index.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

38 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 7de1bad5cbf752608dc6426621ace86c852b21af.

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

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/objectql/src/index.ts) — pages documenting those are invisible to this run
  • 9 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 — 178 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 7de1bad5cbf752608dc6426621ace86c852b21af → packageMentionDocs.

Which tree this was computed on

This run read content/docs from c3cf43a657651ad1cec7ecd0108a4d8fd86a0194 — the merge of head 74cac048492c37f8be30631dbef4b0d5ab441ade into base 7de1bad5cbf752608dc6426621ace86c852b21af, 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 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

⚠️ 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 7de1bad5cbf752608dc6426621ace86c852b21af → 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#7 · os-tesla · session_01L9qibyQBB3KuDoNobNq9LH

L1: REWORK at 646a10ecf607fbf227a09e2f36e149fa5c039130 (2026-11-20T22:08Z). One changeset clause, the ablation record, and one claim amendment

Scope. Two commits, 22 files against merge base 17ed9e7bfd (+1,611 / −21). The claim is 7048435857 and the dev report is 7051244258. The card thread asked me three questions; each is answered below.

The three questions

  1. B6: no caller input reaches a 5xx through the new refusals. Confirmed.
    • Every new 500 path recognises the leaf by its brand alone: isFixedReadLeaf, then readLeaf in shared-record-ids.ts. It requires all of:

      • a frozen plain object,
      • every own key a data property,
      • exactly one symbol key, Symbol.for('objectstack.filter.sharedRecordIds'), non-enumerable and true,
      • and nothing else.

      JSON cannot produce that.

    • parseFilterAST reaches refuseFixedReadLeafAtParse only inside the catch after the shape door has already refused, and it re-throws the original refusal when no branded leaf is found. So an unbranded array-form in / nin keeps its exact 400. The PR pins that.

    • The analytics where guard (refuseFixedReadLeafInWhere) and the OData refuseFixedReadLeaf use the same brand test. A ComposedReadableIds scope is descended only through its own symbol brand.

    • So every new 500 is reachable only by in-process code that built a branded leaf. ✔

  2. B1 split to [Decision] ADR-0155 step 5: how the analytics native compiler asks the engine seam which objects decline the share-grant leaf #35946, and Fixes #35874: accepted, on the step-3 precedent.
  3. The deviations.
    • scripts/engine-double-contract.pinned.json is one row, mandated by the gate. I accept it, but it needs a record (required item 3).
    • The where guard in filter-normalizer.ts is inside the surface (service-analytics/src/**). It closes the same class of gap, is pinned on five spellings, and has a changeset bullet. Accepted.
    • The three unlogged refusals (parseFilterAST, the analytics where face, OData) are at doors that hold no logger. The engine seam logs its own refusal once, and the refuseReadableIds precedent applies. Accepted.
    • The objectql full suite was not re-run after the rebase. CI at this head (58 success, 11 skipped, 0 failed) includes Test Core and its shards, so CI stands in for it. Accepted.

What else I checked

  • The OData find and count both refuse before any request is sent. The one ablation in the report (the find refusal removed: 11 find cases go red and return rows, count stays green) shows the pins discriminate on that driver. ✔
  • The changeset is patch on five packages, with Clause-②: yes and Metadata-protocol: none. The published rowFilter now holds only the two shapes it held before, and never the leaf; the explainer pins assert the serialized decision carries no recipient. ✔

Required

  1. The changeset's analytics bullet hides the shipped default. It says the native path compiles the leaf "only when the host answers AnalyticsServiceConfig.fixedReadLeafClassOf with null", and that "a host that wires no answer keeps today's behaviour". The platform's own AnalyticsServicePlugin is such a host in this release. Read as written, the bullet tells an operator that native SQL now answers sharing-scoped reads. Fix: add one clause, for example "AnalyticsServicePlugin wires no answer in this release ([Decision] ADR-0155 step 5: how the analytics native compiler asks the engine seam which objects decline the share-grant leaf #35946), so on every host today the native path declines a scope carrying the leaf and the engine path answers".
  2. Ablations: a record, no new head. One leg covers one of seven changed compile surfaces. Run each mutation, and post the reds and the clean restores as a report amendment:
    • (a) Native compile, leaf dropped. In compileScopedFilterToSql, compile the leaf as no restriction. The live case-set rows on SQLite should go red: the one that returns n3 too, and n5.
    • (b) Native compile, inner read walled. Add a tenant predicate to the subquery. The nested-under-tenant case and g7 should go red, as they did in step 3.
    • (c) Decline forced off. Make readScopeCarriesUncompilableFixedReadLeaf answer false. The no-hook and beforeFind-hook decline pins should go red.
    • (d) B6 removed. Delete the refuseFixedReadLeafAtParse call. The branded array-form pins should go red (they answer 400), and the unbranded 400 pin should stay green.
    • (e) where guard removed. Skip refuseFixedReadLeafInWhere on both faces. The five-spelling pins should go red.
    • (f) Explainer resolution skipped. Pass the leaf through unresolved. The two rowFilter shape pins and the no-recipient pin should go red.
  3. A claim amendment on ADR-0155 step 5: the rest of the census — storage refusal for the share-grant leaf, the analytics compilers, the explainer record pass #35874 for the file outside the surface: scripts/engine-double-contract.pinned.json, one row (explain-fixed-read-leaf.test.ts, findOne, pinned 1), required by check:engine-double-contract. It is not a governed path; it only needs to be on record, as on audit seal: publish refuses a sealed object that has neither a tenant_id field nor a chainField #34352.

For the seat (not L1's to rule)

Before landing

  • A delta L1 after item 1, and records for items 2 and 3.
  • CI green on that head.
  • The CONTRACT_REVIEW_TIER L2 PASS, same head (packages/spec/src/**, Clause-②: yes).

Generated by Claude Code

…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>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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.

@objectstack-fleet objectstack-fleet Bot added the needs:contract-review Marker only — PR awaits its at-tier Contract review PASS; no check reads it, the record decides label Nov 20, 2026
… 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>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibyXo4gSy8DJPNz4ANz

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 81da4605fae7b790a0ecf701d1e68f2435433b5d
Local-runs: none
Scope: packages/spec/src/data/filter.zod.ts + packages/objectql/src/fixed-read-leaf-seam.ts, packages/objectql/src/index.ts, packages/plugins/plugin-security/src/explain-fixed-read-leaf.ts, packages/plugins/plugin-security/src/explain-engine.ts, packages/plugins/plugin-security/src/security-plugin-explain-access.ts, packages/plugins/plugin-security/src/security-plugin.ts, packages/services/service-analytics/src/read-scope-sql.ts, packages/services/service-analytics/src/analytics-service.ts, packages/services/service-analytics/src/plugin.ts, packages/services/service-analytics/src/strategies/native-sql-strategy.ts, packages/services/service-analytics/src/strategies/objectql-strategy.ts, packages/services/service-analytics/src/strategies/filter-normalizer.ts, packages/services/service-analytics/src/strategies/types.ts, packages/drivers/driver-odata/src/odata-driver.ts

PR #35945, card #35874 (ADR-0155 plan step 5). Read with git show and git diff only.

Head. The review was done file by file at 103f93b7ac (22 files, +1,611 / −21 against merge base 17ed9e7bfd). The head moved during it to 81da4605fa, one commit on top. git diff 103f93b7ac 81da4605fa --stat is tests only: explain-fixed-read-leaf.test.ts, fixed-read-leaf-native-compile.test.ts and shared-record-ids.test.ts, +36 / −18. Every file in Scope: is byte-identical on the two heads. I read the delta: it splits existing pins into pins of their own and adds none for the shapes S1 and S2 name, so every judgment below holds at 81da4605fa.

Scope decision. hits is filter.zod.ts alone. I widened to every non-test source file in the diff, for two reasons. The card declares Clause-②: yes for the explainer's published rowFilter and for the analytics merges, so those are contract faces in their own right. And the filter.zod.ts jsdoc describes one refusal that five other doors in this diff also make (the engine seam's public readers, the analytics scope and where doors, the explainer, OData), so each is the code that sentence is checked against. The remainder is the lane seat's at TIER_DEFAULT: the five test files, .changeset/35874-fixed-read-leaf-census-rest.md and scripts/engine-double-contract.pinned.json.

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 judgments

Gate verdicts (check-runs, read at 2026-11-20T22:39Z):

  • At 81da4605fa, this record's head: not yet answered. 8 success, 10 skipped, 18 in progress, none failed. The runs started about a minute before this record was written.
  • At 103f93b7ac: 58 success, 17 skipped, 3 cancelled, none failed. Type Check · workspace, · source gates, · consumer gates and · debt ledger, every Lint · family, Check Changeset, PR-body guards, Spec property liveness, Governed Surface Queue Guard, Build Core, Test UI (16 of 16) and Test Core shards 2 to 8 and 10 are green. Test Core (1/10) and (9/10) were cancelled by the push of 81da4605fa, so they gave no verdict there; the third cancel is a superseded Check Changeset beside two green ones.
  • At 646a10ecf6, whose source files are the ones in Scope: unchanged: every Test Core shard was green.
  • So no gate has failed on any head of this diff, and the full test verdict on this record's head is still owed. The delta review reads it on the head that carries the fixes.

Accept-set and public-surface changes the diff implies:

  1. @objectstack/spec parseFilterAST: a refusal changes envelope, the accept set does not move. When the shape door refuses a lowered condition that carries a branded leaf, the answer is INTERNAL_ERROR / 500 instead of INVALID_FILTER / 400. Right in direction: D4 says the refusal "is not INVALID_FILTER: the fault is a composition's". An unbranded copy keeps 400 (the original refusal is re-thrown when no branded leaf is found). No operator, no export and no schema key is added; VALID_AST_OPERATORS is untouched (D1). The new imports (./fixed-read-leaf, ./readable-ids) close no runtime cycle: readable-ids.ts imports filter.zod for a type only. Incomplete as written: see S1.
  2. @objectstack/objectql: two function exports and one type (fixedReadLeafClassOfEngine, driverEvaluatesFixedReadLeaf, FixedReadLeafClass). Right: the card's carry-forward asks for exactly this public face, both are read-only, and engine.ts does not grow. Neither has a consumer in this release (the analytics plugin is unwired, [Decision] ADR-0155 step 5: how the analytics native compiler asks the engine seam which objects decline the share-grant leaf #35946), which L1 accepted on the step-3 precedent; I agree, because the hook fails closed.
  3. @objectstack/service-analytics: one optional config hook (AnalyticsServiceConfig.fixedReadLeafClassOf) and optional members on DatasetScopedStrategyContext. Right: absent, throwing, undefined or a class all decline; only null compiles. compileScopedFilterToSql is the one name the package index re-exports from read-scope-sql.ts, and its accept set widens by exactly one shape: a read-form leaf as the $in comparand of id on the object the scope reads. Every other leaf is refused 500 before a clause compiles.
  4. Analytics merges admit the brand at a second door (assertReadScopeComparandsRunnable under admitFixedReadLeaves). Right: Q2's ruled row, word for word. Without the option the answer is READ_SCOPE_COMPILE_FAILED / 500 as before.
  5. Analytics query where: a leaf in any spelling is refused 500 before either strategy. Right, and it closes a real gap: before, a bare { id: leaf } was lowered as a relation condition built from the leaf's fields, which is D5's "read as an ordinary comparand".
  6. @objectstack/plugin-security: ExplainEngineDeps (exported) gains two optional members; the sharing layer's published rowFilter changes content. Right: Q2's cost line says the share arm is the judged record's id when a grant admits it and is left out otherwise, and that the leaf is never published. A host that builds the deps without the resolver gets the refusal, not a silent match. The object-level readFilter is composed from the row-level-security parts only (explain-engine.ts around line 3524), so no second path publishes the leaf.
  7. @objectstack/driver-odata: find and count refuse the leaf before any request. Right: R1 behind R2 for this storage row. findOne goes through find; the driver has no other verb that takes a where.

② Semver level

patch on five packages (spec, objectql, service-analytics, plugin-security, driver-odata), Metadata-protocol: none. Correct under AGENTS.md's rule: nothing a metadata author can write changes, and a non-protocol change ships patch, new exports included. The five packages are exactly the five the diff moves.

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: "parseFilterAST now refuses a leaf in an array-form in / nin with INTERNAL_ERROR / 500 … The new message names the leaf and its table, not the recipient." That holds for the leaf as the direct comparand only (S1).

③ Boundary flags

  • B1, the open question (how the analytics plugin asks the seam): escalated, correctly. It is decision card [Decision] ADR-0155 step 5: how the analytics native compiler asks the engine seam which objects decline the share-grant leaf #35946, open and the maintainer's, and plugin-sharing: a member with more than 5000 share grants on one object silently loses access to the grants past 5000 (list misses rows, GET answers 404) #33787 is blocked on it. Shipping the hook unwired is safe here: with no hook every scope that carries a leaf declines to the engine path, and no producer writes the leaf before step 6. I checked the one way that could fail open: the decline reads readScopedObjects, and AnalyticsService builds that list and the getReadScope map from the same objects set (analytics-service.ts around line 2071), so no object's scope is compiled that the decline did not read.
  • D4's admission, reconciled without an ADR edit: accepted. D4 anchors "the analytics merges" at assertReadScopeComparandsRunnable. The native compiler reaches the spec door only through that same function, so the callers that name a brand to @objectstack/spec's assertListComparandShapes are still two: the engine's door and that function. Q2 separately rules that the native compiler compiles the leaf. The optional pointer note is the seat's.
  • B6 (the array form), decided to the envelope: right decision, not carried through. See S1.
  • Three refusals are unlogged (parseFilterAST, the analytics where door, OData), against D4's "logged at error once per evaluator … wherever it occurs". Accepted as a deviation (N2).
  • Compile surface 2 goes beyond B6: accepted, it is inside the claimed surface and is the same class of gap.
  • scripts/engine-double-contract.pinned.json outside the claim surface: on record as claim amendment 7051811974. Not a governed path.
  • The dormant 400 at the spec comparand door for callers that name no brand: out of this diff, pinned by step 2. Noted, the seat's to file.
  • PostgreSQL non-text id ([Decision] ADR-0155 O2: the share-grant subquery on PostgreSQL for an object whose id is not text (integer, uuid) #35906): the native subquery adds no cast, as step 3's driver-sql adds none. D-0 says a card that cannot keep the same rows on such an object stops and the case goes to the maintainer; [Decision] ADR-0155 O2: the share-grant subquery on PostgreSQL for an object whose id is not text (integer, uuid) #35906 is that case and is open. Nothing writes the leaf yet, so this head changes no rows there.
  • L1 required item 2 (the six ablations): the brief says the record is posted on ADR-0155 step 5: the rest of the census — storage refusal for the share-grant leaf, the analytics compilers, the explainer record pass #35874. The card held five comments when I read it, the last being 7051811974, and none is an ablation record. This review used no ablation result and its findings do not depend on one; the seat should check where that record went before landing.
  • SQL push-down (Prime Directive 5): no finding. The analytics native path pushes the leaf down as id IN (SELECT …), one statement, no EXISTS, no join, every value bound, no tenant scope on the inner read (① ruled A). The explainer's read of sys_record_share is keyed by the ids it judges and is the shape Q2 rules for that row ("one indexed read under the fixed predicate, keyed by the record ids it judges"); it materialises no caller-wide id list. OData and the two refusal doors read nothing.

④ Design judgment

No 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) — parseFilterAST moves only the direct-comparand shapes to the envelope; a leaf as a list member or under a scalar operator still answers INVALID_FILTER / 400 and prints the head of the recipient.

  • The jsdoc of refuseFixedReadLeafAtParse says the envelope covers "the leaf as an array-form in / nin comparand or list member, the shapes the door reads as a non-list". The shape door does not refuse a list member: assertFieldListComparands only checks that $in / $nin hold an array with no null member (filter-comparand-shape.ts, the nullMember arm). So [['id', 'in', [leaf]]] passes the try, and the type door, which runs outside it, refuses the member as "a plain object" with INVALID_FILTER / 400 (filter-comparand-type.ts#judgeLiteralComparand → comparandTypeRefusal).
  • That message carries preview(value), the first 40 characters of JSON.stringify(leaf): {"object":"account","recipient":"u-secr…. The jsdoc gives "the shape door's printed the leaf's inputs, a principal's id among them" as the reason the 400 was the wrong answer to relay. The same is still true one line below the try.
  • The same holds for ['id', '!=', leaf], ['id', '>', leaf] and the other scalar operators: the shape door passes them and the type door answers 400 with the preview.
  • It reaches the first consumer. The engine's array branch calls parseFilterAST before collectFixedReadLeaves (engine-top-level.ts around lines 1035 to 1047), so find('account', { where: [['id', 'in', [leaf]]] }) answers 400. The object spelling of the same misplacement, { id: { $in: [leaf] } }, goes through the engine's own door, where collectFixedReadLeaves refuses it 500. Two spellings, two envelopes: the split the card asked this step to decide ("the array-form in/nin carrying a leaf still answers 400 from parseFilterAST").
  • No pin covers it. The new test asserts three shapes, all with the leaf as the direct comparand.
  • Fix, either way: (a) make the leaf refusal cover every refusal parseFilterAST raises for a condition that carries a branded leaf (the type door too), and pin the list member and one scalar operator at 500 with no recipient in the message; or (b) keep the code, correct the jsdoc and the changeset bullet to "direct comparand", and name the list-member and scalar-operator 400 as a residual beside the one the PR body already names. (a) is what D4 asks for.
  • While there: the exported parseFilterAST jsdoc still says a shape refusal is "the INVALID_FILTER / 400 envelope" with no exception, and the new message says parseFilterAST "admits [the leaf] in no position", though an array-form = is lowered by reference and passed on, as the same jsdoc says two sentences later.

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.

  • explain-fixed-read-leaf.ts#resolvableLeavesOf admits a leaf whenever it is the $in of a key named id whose leaf names the explained object, at any depth and under any parent: inside a relation condition ({ manager: { id: { $in: leaf } } }, a self-relation), inside a list, or inside a composed ReadableIds scope (it never compares the leaf with the scope's own object, and passes the explained object down).
  • The module header says the opposite: "a leaf anywhere but the $in comparand of id on the explained object" is refused, "never read as an ordinary comparand". D1 limits the position to the object's own where.
  • The other two walkers in this program read roles. The engine's collectFixedReadLeaves refuses { manager: { id: { $in: leaf } } } (its visitField scans every non-$in operand), and the analytics findUnservedFixedReadLeaf in this same diff refuses it as misplaced and tracks the scope object through a composed scope.
  • Effect: for such a filter the find the explanation describes answers 500, while the explainer substitutes [recordId] at the misplaced position, matches it in process and publishes a rowFilter and a verdict. That is D5's rule broken in a fault state ("evaluates the leaf exactly, or refuses it loudly").
  • Reach: none today (no producer, and the producer places the leaf at the top level). It matters because the explainer is the one evaluator with no seam in front of it (D4), so its own walk is the only position check it has.
  • Fix: walk nodes and operator maps as findUnservedFixedReadLeaf does (a field key's plain-object value is an operator map; only its $in may hold a leaf; a composed scope is judged against its own object, or refused outright here), and pin one nested-relation shape beside the $nin pin.

What I tried to break and could not:

  • The spec refusal's reach. isFixedReadLeaf requires a frozen plain object whose only symbol key is the non-enumerable brand, so no JSON, structured clone or request reaches the 500. The walk cuts cycles on the current path and descends a composed scope through its own brand.
  • The native subquery. Built from fixedInnerReadOf(leaf) alone, identifiers through quoteIdent, every value through bind, the blank-id guard on the projected column, and a compile-time check that tenantScope is still 'none'. It is the statement driver-sql builds for the same leaf (sql-driver-internal-helpers.ts#fixedReadLeafSubquery), minus Oracle, which the strategy declines as an unnamed dialect.
  • The decline. It fails closed on every path: no hook, a throwing hook, undefined, a class object, an unknown dialect. Every caller of compileScopedFilterToSql passes object, so the object half of the position rule is always judged.
  • The explainer's two failure channels. The refusal is thrown synchronously, before settle is entered, so it propagates; the resolver's rejection lands in settle and becomes the read-filter fault, with no rowFilter published. The batch memo is keyed by leaf identity and reads the union of the batch ids, so a record asked outside the batch is still answered.
  • The $or collapse. An emptied arm is dropped only when the arm it came from carried a leaf; an $or whose every arm emptied keeps its $in: [] arms, which still match nothing.

Nits, none moving the head:

  • N1 (nit) — the spec message has no [evaluator] prefix, where @objectstack/core's fixedReadLeafRefusal gives every other door one. It names parseFilterAST in its text, which satisfies D4's "naming the evaluator". Leave, or fold into S1's edit.
  • N2 (nit) — three refusals are unlogged where D4 says "logged … wherever it occurs". The doors hold no logger, the thrown 500 propagates, and refuseReadableIds in the same driver is the standing precedent under the same sentence of ADR-0139 D3. Accepted deviation.
  • N3 (nit) — for [Decision] ADR-0155 step 5: how the analytics native compiler asks the engine seam which objects decline the share-grant leaf #35946: the hook's jsdoc prescribes fixedReadLeafClassOfEngine(engine, leaf) ?? null, which never consults driverEvaluatesFixedReadLeaf, the second export this diff publishes for that purpose. D4 says the native compiler compiles "only where the seam would hand it to a driver", and the seam also requires the driver's declaration. The native compiler is its own evaluator, so I read this as the wiring card's to settle, not a fault here. A follow-up note on [Decision] ADR-0155 step 5: how the analytics native compiler asks the engine seam which objects decline the share-grant leaf #35946.
  • N4 (nit) — packages/spec/src/data/data-engine.zod.ts (outside the diff) catches whatever parseFilterAST throws and turns it into a schema issue, so at that door the new 500 is still answered as a validation refusal. No request reaches it with a brand. A follow-up, if anyone wants that door in D4's envelope too.

Implemented-by: claude/project-thread-thptm0
Reviewed-by: session_01L9qibyXo4gSy8DJPNz4ANz

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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 @ 103f93b7acbd25caeea71ae5e6758644f55a564e (card #35874)

You review at CONTRACT_REVIEW_TIER. Render ONE ## Contract review record on this head — its shape is
node scripts/pm/record-recognisers.mjs --template --paths packages/spec/src/data/filter.zod.ts — with a PASS or FAIL verdict, and post it as ONE comment
on the PR or its card.

Inputs — these and nothing else:
· card #35874: its body and EVERY comment (rulings and earlier records included)
· PR #35945: its body, its file list, and the net diff against main at 103f93b7acbd25caeea71ae5e6758644f55a564e
· the check-runs on 103f93b7acbd25caeea71ae5e6758644f55a564e: their conclusions ARE the gate verdicts
⛔ Not the dispatch order, ⛔ not the dispatching seat's own conclusions — this brief is adversarial by design.

Scope — the paths reviewFace returns as hits on this PR's file list: packages/spec/src/data/filter.zod.ts;
plus every file IN THIS DIFF that directly implements or enforces them — the gate that enforces a rule, the code
a jsdoc or schema line describes, the validator a skill teaches — reviewed for agreement with the contract.
Widen it freely, ⛔ never below hits; the record's Scope: line names the implementing files apart from hits.
The rest of the diff (tests, unrelated modules, lockfiles, generated output, changesets) is the lane seat's
ACCEPT at TIER_DEFAULT, exactly as a standalone PR of those files.
④ judges the hits files and those implementing files ONLY:
lockfiles, generated output, changesets and prose elsewhere in the PR are not reviewed;
code outside the diff is READ to judge them, never reviewed.

⛔ READ-ONLY. No worktree, no checkout, no build, no test run, no gate re-run, no ablation: the check-runs
on the head already answered every derived gate family, and a local run costs more than it returns.
If ONE probe is unavoidable, the record's Local-runs: line says probe — REASON; otherwise none.
Scratch space is /tmp/claude-0/-home-user/1cb35bdc-0d81-5349-bc14-73d1d05fc076/scratchpad/pr-35945/ alone; nothing there you did not write this round is read.

Judge, in the record's own sections:
① Derived judgments — every accept-set and public-surface change the diff implies, each named right or wrong.
② Semver level — the changeset (or skip-changeset) matches what the diff publishes, and the Clause-②: line.
③ Boundary flags — every dev flag and every open_questions entry answered, or escalated.
On every face, SQL push-down: a new id materialisation or in-app join where SQL could push down is a
finding unless a reason is given (AGENTS.md, Prime Directive 5: SQL first).
④ Design judgment — for EVERY hits file: does the change hold against the code it cites and the
scenario it is accepted against? A skill file against the card's eval prompt and the spec it teaches
on main; a schema file against the ruling or ADR it implements and its first consumer; an ADR
against its first consumer and its execution plan. For EVERY implementing file in the diff: does the
code agree with the contract, sentence by sentence? Read the cited code in the live tree, and try to
break the design.
Grade each finding must-fix, should-fix or nit — a nit has no effect on correctness or the contract.
A must-fix is a FAIL; a must-fix or should-fix earns a delta review of its fix; nits alone end the round.
Spell a must-fix or should-fix with its id and grade, S1 (should-fix) — …, and a clean round as
No must-fix, no should-fix.: the queue guard reads a graded finding as OPEN on this head and
refuses the record; the delta record names those it closes by id alone, S1: closed.
A nit is fixed only on the prose faces, or left as an accepted deviation or a follow-up card: a fix
anywhere else moves the head, and this record no longer covers it.
⛔ Judge the tree, never the PR body's account of it.
Sign Implemented-by: with the dev's branch and Reviewed-by: with your session id — the value is the FIRST
thing after each colon.

Context for this round (facts, not conclusions):
· The card declares Clause-②: yes for two faces beyond hits: the explainer's published sharing-layer rowFilter content (packages/plugins/plugin-security/src/explain-fixed-read-leaf.ts, explain-engine.ts; ADR-0155 Q2 costs: "The card that lands it declares that under its own Clause-②") and the analytics merges admitting the SharedRecordIds brand (packages/services/service-analytics/src/read-scope-sql.ts). The objectql index gains two exports (packages/objectql/src/index.ts, fixed-read-leaf-seam.ts). Decide whether each belongs in your Scope:.
· Governing text: docs/adr/0155-sharing-scope-share-grants-lower-to-an-engine-internal-semi-join-leaf.md (D-0, D1, D2, D4, D5, Q2's census rows, plan step 5); ruling record 6942854600 on #33787; maintainer ruling 7047007471 on #35874.
· L1 on this PR: comment 7051798358 (REWORK at 646a10e; item 1 is the changeset commit that made this head; item 2 is an ablation record posted on #35874; item 3 a claim amendment on #35874).
· The dev's B1 open question was split to decision card #35946 (open, maintainer's); #33787 carries Blocked-by: #35946.
· Fetch the head read-only as git fetch origin pull/35945/head:refs/review/pr-35945 and read with git show / git diff origin/main...refs/review/pr-35945.
· Write your record to the scratch space as record.md; the card thread posts it. ⛔ Do not post anything yourself.

…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>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibyQBB3KuDoNobNq9LH

L1 delta: ACCEPT at 74cac048492c37f8be30631dbef4b0d5ab441ade (2026-11-20T23:45Z), with CI still owed

This follows my REWORK 7051798358 at 646a10ecf6. The range is four commits, a fast-forward: 103f93b7ac and 74cac04849 (the changeset), 81da4605fa (test-only pin splits) and 3a1aae104c (delta L2 7052365884 S1/S2).

What I checked

  • Item 1: met. The changeset now says: "This change ships the hook unwired: AnalyticsServicePlugin passes 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." That stays true whichever release feat(spec,objectql,service-analytics): IObjectQLEngine.fixedReadLeafClassOf, wired into the analytics native path (ADR-0155 D4) #35954 ships in. It also settles landing condition 1 of my L1 on feat(spec,objectql,service-analytics): IObjectQLEngine.fixedReadLeafClassOf, wired into the analytics native path (ADR-0155 D4) #35954 (7052812138): the two changesets no longer contradict each other in the same release. ✔
  • Item 2: met (record 7052432230 on ADR-0155 step 5: the rest of the census — storage refusal for the share-grant leaf, the analytics compilers, the explainer record pass #35874, at 81da4605fa). All six legs went red with blob-equal restores. For leg (d), the spec dist/ was rebuilt, and ablation-dist-preflight --absent checked all 608 files.
    • (a) Leaf compiled as no restriction: 12 red, including 9 case-set rows, the binds pin, native-vs-engine agreement and the echo.
    • (b) Tenant predicate inside the subquery: 7 red, including g7, the exact-SQL binds pin and the agreement pin.
    • (c) Decline forced off: exactly the 2 decline pins red.
    • (d) B6 removed: the branded pins answer 400, and the unbranded 400 pin stays green.
    • (e) where guard skipped: all 5 spelling pins red.
    • (f) Explainer unresolved: 8 of 8 red.
    • Where the result departed from my prediction, the nested n3/n5 and nested-under-tenant rows stayed green under (a) and (b). They are composed scopes that the analytics door refuses 500 before the native compiler runs, and their own 500 pins hold them. I accept that. Splitting three masked assertions into their own its in 81da4605fa is the right repair. ✔
  • Item 3: met. Claim amendment 7051811974 covers scripts/engine-double-contract.pinned.json. ✔
  • S1 (3a1aae104c, filter.zod.ts).
    • normalizeFilterComparandTypes now runs inside the same try. So a branded leaf as a list member, or as a scalar operator's comparand, gets the 500 that names no recipient, instead of the type door's 400, which printed one.
    • The gate is still refuseFixedReadLeafAtParse, which finds only a symbol-branded leaf, then re-throws the original refusal. So my answer to question (1) in 7051798358 still holds: no caller input reaches a 5xx.
    • The ablation (the type door moved back outside the try) turns the type-door pin red and leaves the unbranded pin green. ✔
  • S2 (explain-fixed-read-leaf.ts).
    • The walk now reads roles. A node's keys are combinators or fields, a field's plain-object value is an operator map, and only an operator map's $in on id of the named object admits a leaf. A relation condition's inner { id: { $in: leaf } }, a composed scope's leaf, a list member and a bare value are each refused 500, logged once, with no read under the leaf's predicate.
    • A leaf under $not is admitted. I checked that resolving it there is still correct: substitute replaces the leaf with [recordId] or [], so $not keeps its meaning, and only emptied $or arms are dropped.
    • The ablation (the old key-based walk) turns exactly the 2 new pins red. ✔
  • Gates: 112 of 112 derived families exit 0, including check:dual-build-cjs-loads and check:i18n, which were NOT MEASURED in round 1.
  • CI at 74cac04849: 14 success, 12 skipped, 24 in progress, 0 failed at my read. Not yet green.

Before landing

  • CI green on 74cac04849.
  • The same-head CONTRACT_REVIEW_TIER delta L2 PASS. It is running.

Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibyXo4gSy8DJPNz4ANz

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 74cac048492c37f8be30631dbef4b0d5ab441ade
Local-runs: none
Scope: packages/spec/src/data/filter.zod.ts + packages/plugins/plugin-security/src/explain-fixed-read-leaf.ts

DELTA review from 81da4605fae7b790a0ecf701d1e68f2435433b5d (the earlier record of this session on that head: PASS, S1 and S2 open, nits N1 to N4) to this head. PR #35945, card #35874 (ADR-0155 plan step 5).

The delta is a fast-forward of two commits, 6 files, +172 / −60 (git diff 81da4605fa 74cac04849 --stat):

  • 3a1aae104c changes packages/spec/src/data/filter.zod.ts and packages/plugins/plugin-security/src/explain-fixed-read-leaf.ts, with three test files.
  • 74cac04849 rewords the changeset.

Every other file of the earlier record's Scope: is byte-identical on the two heads, so its judgments on them stand and are not repeated. Read with git show and git diff only. I read the dev's account (comment 7053428791 on #35874) after the tree, and judged the tree.

① Derived judgments

Gate verdicts (check-runs on this head, read at 2026-11-21T00:14Z): 60 success, 13 skipped, none failed, none cancelled, none in progress. The CI and Lint & Type Check workflow runs both concluded success. Green: every Test Core shard (10 of 10) and every Test UI shard (16 of 16), Build Core, the four Type Check · families, every Lint · family, Check Changeset, PR-body guards, Spec property liveness and Governed Surface Queue Guard. The test verdict the earlier record said was owed is now answered.

Accept-set and public-surface changes in the delta:

  1. parseFilterAST: the envelope change now covers both of its doors. A condition that carries a branded leaf and is refused by the shape door or by the type door answers INTERNAL_ERROR / 500. Right: this is D4's "not INVALID_FILTER", applied to every refusal the function raises for such a condition. The accept set does not move: every changed input was already refused, and an unbranded copy keeps INVALID_FILTER / 400 at both doors.
  2. The explainer refuses more. A leaf inside a relation condition, a list, a bare field value or a composed ReadableIds scope is now refused 500 where the earlier head resolved it. Right: D1's position rule, and the same answer the engine's seam and the analytics compiler give. No producer writes any of those shapes.

No export, schema key or operator is added or removed by the delta.

② Semver level

Unchanged and correct: patch on the same five packages, Metadata-protocol: none.

Clause-②: yes — still correct, with no arm. Both lines are on the changeset, and Check Changeset is green on this head.

The three reworded changeset bullets now say what the code does:

③ Boundary flags

④ Design judgment

  • S1: closed. normalizeFilterComparandTypes now runs inside the same try as the shape door, so refuseFixedReadLeafAtParse answers for either door's refusal. The refuseFixedReadLeafAtParse jsdoc now assigns each shape to the door that refuses it, and no longer claims the shape door refuses a list member. The exported parseFilterAST jsdoc names the exception in both places it promised 400. The message no longer says "admits in no position". Pinned at the spec face (list member, !=, > under and, each 500 with no recipient; unbranded copies of the list member and of != still 400) and through the engine's find, where the array spelling and the object spelling now answer the same 500.
  • S2: closed. resolvableLeavesOf now walks roles: a node's keys are combinators and fields, a field's plain-object value is an operator map, and only that map's $in under id, naming the explained object, in the read form, is resolved. Every other leaf is walked as a value and refused, anything inside a composed ReadableIds scope included. That matches the module header sentence and the other two walkers. Pinned for a self-relation condition and for a composed scope: 500, the path, no recipient, one log line over two calls, and no read under the leaf's predicate.

No must-fix, no should-fix.

What I tried to break in the delta and could not:

  • The widened try. The catch re-throws the original refusal whenever no branded leaf is found, so every author refusal of both doors keeps its own envelope and message. A leaf-carrying condition refused for an unrelated author fault now answers 500 naming the leaf; the jsdoc says so, and only in-process code can build such a condition.
  • The role walk against substitute. Every leaf resolvableLeavesOf admits sits at a node-level id.$in, which is a position substitute replaces; every leaf it does not admit throws before any read, so substitute never meets an unresolved leaf.
  • $and / $or holding a non-list, and any other $ key at node level: walked as values, so a leaf there is refused, not skipped.

Nits carried from the earlier record, none moving the head:

Implemented-by: claude/project-thread-thptm0
Reviewed-by: session_01L9qibyXo4gSy8DJPNz4ANz

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibyXo4gSy8DJPNz4ANz

Landing · 2026-11-21T00:16Z · head 74cac048492c37f8be30631dbef4b0d5ab441ade

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.

@objectstack-fleet objectstack-fleet Bot removed the needs:contract-review Marker only — PR awaits its at-tier Contract review PASS; no check reads it, the record decides label Nov 21, 2026
@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 21, 2026 00:16
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 21, 2026
Merged via the queue into main with commit 0a3dd40 Nov 21, 2026
77 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-thptm0 branch November 21, 2026 00:52
os-tesla pushed a commit that referenced this pull request Nov 21, 2026
#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
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 protocol:data 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.

ADR-0155 step 5: the rest of the census — storage refusal for the share-grant leaf, the analytics compilers, the explainer record pass

1 participant