Repository navigation
fix(core): an unresolved { $record } lookup-filter comparand is refused by name before any driver sees it - #34330
Conversation
…arand by name
The lookupFilters { $record: 'path' } comparand reads the record a form is
editing, which only that form's record picker knows. An unresolved one now
answers INVALID_FILTER / 400 from the engine's token pass, naming the field,
the $record path and its position, instead of reaching the driver.
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QsR2jUZKdq3PK2Sab53cT3
…nd driver-sql; spec describes state the server half Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jUZKdq3PK2Sab53cT3
…cribes Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jUZKdq3PK2Sab53cT3
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jUZKdq3PK2Sab53cT3
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jUZKdq3PK2Sab53cT3
📓 Docs Drift CheckThis PR changes 2 package(s): 18 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 8 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 182 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 b04cd1b5f693ef891679515e31daac1a8f076f4a && git checkout b04cd1b5f693ef891679515e31daac1a8f076f4a
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 1089e9e4e0be108b5c676ee6c803ac9de72317f9 4fe8f01a373ccc488034c73d0c4f649fedf8328c && git checkout -B drift-repro 1089e9e4e0be108b5c676ee6c803ac9de72317f9 && git merge --no-ff 4fe8f01a373ccc488034c73d0c4f649fedf8328c
node scripts/docs-audit/affected-docs.mjs --json 1089e9e4e0be108b5c676ee6c803ac9de72317f9
|
|
domain:server#5 · zhuangjianguo · session_01QsR2jUZKdq3PK2Sab53cT3 Request: review · PR #34330 · area S6 · Fixes #34199 · head
Generated by Claude Code |
|
domain:server#5 · zhuangjianguo · session_01QsR2jRMKz5NhWVrE4E1U5x Review claim · head 8f73e23 · 2026-11-16T07:53Z (review-c, S6; L1 ACCEPT read + L2 CONTRACT_REVIEW_TIER record, spec schema face) |
|
domain:server#5 · zhuangjianguo · session_01QsR2jRMKz5NhWVrE4E1U5x Contract reviewServed-tier: PR #34330 for card #34199. Read: the card body and its three comments (triage 6904303501, claim 6908067742, dev report 6910077961), the PR body, file list and net diff against The rest of the diff is the lane seat's ACCEPT at ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
M1 (must-fix) — The by-name refusal fires on a filter driver-memory serves on S1 (should-fix) — The N1 (nit) — N2 (nit) — The comment on the N3 (nit) — The area request 6910632534 says "patch changeset"; the tree and the PR body say Implemented-by: VERDICT: FAIL |
|
domain:server#5 · zhuangjianguo · session_01QsR2jRMKz5NhWVrE4E1U5x Review — FAILHead-sha: What holds:
Owed (each earns a delta):
Nits:
Not governed: the area lands this PR once the record reads clean. |
…s comparand
A { $record } inside a no-$ object beneath a field is a deep-equality
comparand or a nested-relation condition, and passes through as before;
the refusal reads the field's own value and its operators' values only.
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QsR2jUZKdq3PK2Sab53cT3
… describes say what holds on every path Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jUZKdq3PK2Sab53cT3
…cribes Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jUZKdq3PK2Sab53cT3
|
domain:server#5 · zhuangjianguo · session_01QsR2jUZKdq3PK2Sab53cT3 Hand-off · PR #34330 · area S6 clocks out (maintainer order 09:01Z) · Fixes #34199 · head State: fix round 2 pushed; draft. CI at hand-off: 13 success, 11 skipped, 17 in progress, 0 failure. Answers L2 record 6910769567 and L1 verdict 6910778263 (both FAIL at 8f73e23).
Generated by Claude Code |
|
repo:objectstack#1 · os-project-manager · session_01FEkQ5kgF3mo9f7LXuv5hac Final head for review · PR #34330 · 2026-11-16T09:59ZArea o1-C (seat repo:objectstack#1) took this PR over from domain:server#5 (takeover claim 6913113980 on #34199). Head-sha: Generated by Claude Code |
|
review#1 · os-mickey · session_01ASNY8Ywba8ySbMdWvra2vS Contract-review-claim: session_01ASNY8Ywba8ySbMdWvra2vS · head 1d58fb8 · 2026-11-16T10:01Z |
|
review#1 · os-mickey · session_01ASNY8Ywba8ySbMdWvra2vS Contract reviewServed-tier: PR #34330 for card #34199, fix round 2. A delta against FAIL 6910769567 (head The rest of the diff is the lane seat's ACCEPT at Earlier findings, by id: M1: closed. ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
M2 (must-fix) — The walk reads the value position of a legacy S2 (should-fix) — The N4 (nit) — The refusal message prints Implemented-by: VERDICT: FAIL |
|
repo:objectstack#1 · os-project-manager · session_01FEkQ5mww9UksbwbjvM4aYn 席位核对 · PR #34330 · L1-b · 2026-11-16T10:22ZHead-sha: L1 delta · REWORK · area o1-C 定稿评论 6913243699 所钉 head;对照 L1 6910778263(FAIL @ 已过(本 L1 亲核):
REWORK 项(下一轮一并修,修后 L1 只读 delta):
门禁 check-runs:区线程读数 58 success / 12 skipped / 0 failure;本轮必移 head,新 head 再核,本 head 不入账。 |
…that judged it
The token pass walked the value position of a legacy tuple as a filter node,
so ['attachment', '=', { meta: { $record: 'x' } }] was refused where the same
deep-equality literal in the object spelling comes back by reference. An array
whose first member is a string other than and / or is a comparison: its third
member is a comparand, not a node. CONTROL pins for the tuple spelling; the
refusal's $record echo is bounded to 60 characters; the describe and the
changeset name the time column the temporal door also covers.
Claude-Session: https://claude.ai/code/session_01FEkQ5kgF3mo9f7LXuv5hac
Co-Authored-By: Claude <noreply@anthropic.com>
…ording Claude-Session: https://claude.ai/code/session_01FEkQ5kgF3mo9f7LXuv5hac Co-Authored-By: Claude <noreply@anthropic.com>
|
repo:objectstack#1 · os-project-manager · session_01FEkQ5kgF3mo9f7LXuv5hac Final head of round 3 for review · PR #34330 · 2026-11-16T13:47ZHead-sha: Generated by Claude Code |
|
review#1 · os-mickey · session_01ASNY8Ywba8ySbMdWvra2vS Contract-review-claim: session_01ASNY8Ywba8ySbMdWvra2vS · head 16c765b · 2026-11-16T13:49Z |
|
repo:objectstack#1 · os-project-manager · session_01FEkQ5mww9UksbwbjvM4aYn 席位核对 · PR #34330 · L1-b · 2026-11-16T13:50ZHead-sha: L1 delta · ACCEPT(内容面;门禁在本 head 尚未读到) · area o1-C 定稿评论 6918248375 所钉 head;对照 L1 REWORK 6913751345(@
落地条款:非受管路径,由区线程自行落地;须同时具备本 ACCEPT、review#1 的 CONTRACT_REVIEW_TIER delta PASS(M2/S2/N4)、本 head 全 check 绿。os-regen 同步合入后,merge-only 的 delta 发我即可,我只核 references 是否与生成结果一致。 |
|
review#1 · os-mickey · session_01ASNY8Ywba8ySbMdWvra2vS Contract reviewServed-tier: PR #34330 for card #34199, fix round 3. A delta against FAIL 6913428090 (head The rest of the diff is the lane seat's ACCEPT at Earlier findings, by id: M2: closed. ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
S3 (should-fix) — Both describes and the changeset still say the picker does not resolve Implemented-by: VERDICT: PASS |
Conflict in packages/spec/src/data/field.zod.ts resolved by hand: main's picker sentences (the value, orEmpty and lookupFilters describes as the picker change rewrote them) taken whole, and this branch's server sentence kept in each of the value and lookupFilters describes, with no PLANNED tail. Generated references are regenerated from the merged source in the next step. Claude-Session: https://claude.ai/code/session_01FEkQ5kgF3mo9f7LXuv5hac Co-Authored-By: Claude <noreply@anthropic.com>
The os-regen driver kept one side of the three references in the merge; os-regen-merge.sh step 2 took main's side, and gen:schema + gen:docs re-derive them from the merged field.zod.ts: main's picker sentences plus this branch's server sentences. Claude-Session: https://claude.ai/code/session_01FEkQ5kgF3mo9f7LXuv5hac Co-Authored-By: Claude <noreply@anthropic.com>
The picker now resolves { $record } in a record form, so the last paragraph
no longer says the marker stays on a picker half that does not resolve it.
Claude-Session: https://claude.ai/code/session_01FEkQ5kgF3mo9f7LXuv5hac
Co-Authored-By: Claude <noreply@anthropic.com>
|
repo:objectstack#1 · os-project-manager · session_01FEkQ5kgF3mo9f7LXuv5hac Final head for landing · PR #34330 · 2026-11-16T14:59ZSupersedes announce 6918248375 (head
Generated by Claude Code |
|
review#1 · os-mickey · session_01ASNY8Ywba8ySbMdWvra2vS Contract-review-claim: session_01ASNY8Ywba8ySbMdWvra2vS · head 4fe8f01 · 2026-11-16T15:01Z |
|
repo:objectstack#1 · os-project-manager · session_01FEkQ5mww9UksbwbjvM4aYn 席位核对 · PR #34330 · L1-b · 2026-11-16T15:02ZHead-sha: L1 merge delta · ACCEPT · 区线程 dev 报告 6919979987(#34199)所钉 head;对照 L1 ACCEPT 6918307839(@
落地条款:非受管路径,由区线程自行落地;仍须 review#1 对本 head 的 delta PASS。 |
|
review#1 · os-mickey · session_01ASNY8Ywba8ySbMdWvra2vS Contract reviewServed-tier: PR #34330 for card #34199, round 4: a delta against PASS 6918401040 (head The rest of the diff is the lane seat's ACCEPT at Earlier findings, by id (every id before S3 stood closed in records 6913428090 and 6918401040, and nothing in this delta reopens one): S3: closed. No must-fix, no should-fix. ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
Implemented-by: VERDICT: PASS |
|
repo:objectstack#1 · os-project-manager · session_01FEkQ5kgF3mo9f7LXuv5hac Landing · PR #34330 · 2026-11-16T15:04Z
State change: ready for review + auto-merge (merge queue). On MERGED, Generated by Claude Code |
Requested by Steedos · project thread
Fixes #34199
Clause-②: no
Metadata-protocol: semantic
Skills-docs: none —
git grep '$record'finds no teaching of the{ $record }comparand underskills/orcontent/docs/data-modeling/; this PR adds nothing an author writes, and the teaching moves with the picker card (#34197), as PR #34078 recorded.维护者速读
resolveFilterTokens)遇到"作为字段比较值"的未解析{ $record: "路径" }时按名拒绝,返回INVALID_FILTER/ 400,消息写明字段、$record路径和位置;藏在深层比较对象里的{ $record }不碰,对象写法和数组写法([字段, 操作符, 值])都和 main 一样放行。$record只有编辑表单里的选择器能替换;以前它漏到驱动层,驱动用含糊的话拒绝(内存驱动说"不支持的操作符",SQL 驱动连字段都不说)。engine.find实测,本分支与 main 逐字相同(8 个用例)。回滚即撤销本 PR。packages/core/src/utils/filter-tokens.ts(findRecordReferenceComparand的数组分支与位置规则、resolveFilterTokens开头两行)、packages/core/src/utils/filter-tokens.test.ts([#34199]describe 的拒绝表与 CONTROL 表)、packages/spec/src/data/field.zod.ts(合并冲突手工解决处:两段 describe 中 main 的选择器句子 + 本 PR 的服务端句子)。pnpm --filter @objectstack/core exec vitest run src/utils/filter-tokens.test.ts,预期 79 个用例全绿,其中[#34199]下 21 个。What changes
resolveFilterTokens(packages/core/src/utils/filter-tokens.ts), the engine's one token pass (engine-top-level.tsresolveWhereFilterTokens, every read and write verb) and the analytics service's: before the fast path,findRecordReferenceComparandwalks the filter's node grammar and refuses a{ $record }object (an own$recordkey, malformed or not) only where it is a field's comparand: the field's own value (the eq shorthand{ f: { $record } }) or the value of an operator on that field ({ f: { $gt: { $record } } }), under any$and/$or/$notnesting.INVALID_FILTER/ 400; the message names the field, the$recordpath (echoed as JSON, bounded to 60 characters like the sibling comparand doors) and the position, e.g.A { "$record": "account.cb_market" } comparand on field "cb_market" at filter.cb_market reached the server unresolved, and is refused rather than compared.main: a{ $record }inside a no-$object beneath a field ({ attachment: { meta: { $record: 'x' } } }: a deep-equality comparand or a nested-relation condition, which only the field's declaration tells apart and this field-agnostic resolver never reads), a member of an operator's list ($in: ['NA', 'EU', { $record }]), a$key in a node position that is not a combinator ({ $record: 'x' }at the root), and a legacy[field, op, value]tuple: an array whose first member is a string other thanand/or(the splitparseFilterASTlowers by) is a comparison whose third member is a comparand, so['attachment', '=', { meta: { $record: 'x' } }]comes back by reference like its object spelling. An['and' | 'or', …]array is walked from its second member; any other array as a list of nodes. (Round 3, L2 M2: round 2 walked the tuple's value as a node and refused this shape naming fieldmeta; the analytics service hands the pass itswhereunlowered.)hasFilterToken, so the refusal does not depend on a string token being present; a filter with no placeholder still comes back by reference. The resolver's own walk is byte-identical tomain's.valuebeside one namedfieldis namedvalue, and a list member is never read as a field name.packages/spec/src/data/field.zod.ts, describe text only), worded to what holds on every path: thevaluedescribe says an unresolved{ $record }"is refused (INVALID_FILTER), never read as null"; thelookupFiltersdescribe adds that it is refused "by name, naming the field and the path, when it arrives as the eq shorthand on a column other than a date, datetime or time column; any other operator, and eq on a date, datetime or time column, is refused earlier, in generic words" (round 3, L2 S2:temporalComparandKindanswers for all three kinds). Round 4 merged main, whose picker change (PR feat(fields): lookup picker resolves { $record } lookupFilters values and sends orEmpty #34253) rewrote both describes and dropped their[PLANNED — not enforced]tails; the merge keeps main's picker sentences whole and adds only this PR's server sentences (review#1 S3): thevaluedescribe appends "A { $record } that reaches a server unresolved is refused (INVALID_FILTER), never read as null.", and thelookupFiltersdescribe replaces main's "refused, never read as null." with the by-name sentence above. This restates seat ruling 6900252552 §3 on lookup picker: a lookupFilters value cannot read the form record or today, so a picker cannot offer only the price books valid on the quote date or matching the customer's market #34009 ("An unresolved$recordfails loudly (INVALID_FILTER) instead of returning wrong rows"); no schema shape, key or error code changes. Regenerated:content/docs/references/{data/field,data/object,system/migration}.mdx.packages/spec/src/data/field.test.ts: the eq-shorthand pin's title and comment now name the engine's token pass as the refuser (claim surface amended by the area); its assertion is unchanged..changeset/34199-record-reference-refused-by-name.md(@objectstack/coreand@objectstack/spec, minor, asMetadata-protocol: semanticrequires). Round 3: the "no filter that answered rows now refuses" sentence now says why (the pass judges only a field's comparand, never a value inside one); the "Unchanged" row names both spellings of the deep comparand and their CONTROLs; the temporal carve-out names date, datetime and time. Round 4: the last paragraph says thevalueandlookupFiltersdescribes state the server half, and their picker sentences are not changed by this entry (no PLANNED marker, no "does not resolve").Tests
packages/core/src/utils/filter-tokens.test.ts, top-level describe[#34199] resolveFilterTokens — an unresolved { $record } comparand refuses by name(21 cases):INVALID_FILTER/ 400 naming the field, the$recordpath and the position (7 + 3): the eq shorthand, an operator comparand, an ordering comparand, inside$orbeside a literal, under$not, beside a string token, a column namedvaluebeside one namedfield; an object node inside an['or', …]array (filter[2].cb_market); a 500-character$recordvalue, echoed bounded; a malformed reference.{ attachment: { meta: { $record: 'x' } } }), inside a nested-relation condition, as an$inlist member, at the root, as the third member of a tuple, and (round 3) the deep comparand in the array spelling['attachment', '=', { meta: { $record: 'x' } }], the same tuple under anand-array, and inside a tuple of a legacy list of tuples.$nowanchor resolve as before; a deep{ $record }beside a string token is resolved around and kept as written.packages/drivers/driver-sql/src/sql-driver-record-reference-refusal.test.ts(SQLite in-process) andpackages/drivers/driver-memory/src/memory-record-reference-refusal.test.ts: through the token seam the shorthand and the operator form are refused by name and the driver'sfindis never called; a caller that passes no seam is still refused by the driver itself; CONTROL:{ attachment: { meta: { $record: 'x' } } }comes through the seam by reference and the driver answers as before; CONTROL: an ordinary filter and{current_user_id}answer the same rows as before. Unchanged in round 3.scripts/ablation-replace.mjs --deleteon the lineif (head !== 'and' && head !== 'or') return undefined;; core's test imports the module fromsrc, so no build sits between mutation and run): anchor x1 to x0, blob244045f6cd22toace6143a5a76; core 3 failed / 76 passed, exactly the three new array-spelling CONTROLs, each withUnresolvedRecordReferenceError: A { "$record": "x" } comparand on field "meta" at filter[2].meta(andfilter[2][2].meta,filter[1][2][0].meta); restored, blob == HEAD (244045f6cd22) andgit diff HEADempty. Round 2's ablation of the position rule stands as recorded there.Acceptance notes
AnalyticsServicePluginover a realObjectQLengine onSqliteWasmDriver, ObjectQL face,service.querybesideengine.find; three legs swapping onlyfilter-tokens.ts, core rebuilt each time, restored and rebuilt after): the array spelling of the deep comparand, on ajsonand on afilecolumn, answers byte-identically on this head and onmain(35c9a305f0): onjsonthe engine's no-operator-object door (INVALID_FILTER/ 400, "puts an object with no operator key (keys "meta") … as the value of a json field"), onfilethe analytics normalizer'sUnsupported filter operator "meta" on field "doc"(analytics) and the SQL driver's unbindable-comparand refusal (engine.find). Round 2's head answered the analytics array spelling with this pass's own refusal naming fieldmeta: refused there too on these two column kinds, but by the wrong door, and on a column wheremainanswers rows (L2's driver-memory reading) it would have been a narrowing. Not measured through analytics on driver-memory (service-analytics does not depend on it). A literal CONTROL (['cb_market', '=', 'export']) answered["a"]on every leg.mainanswered the analytics normalizer's and the SQL driver's generic sentences; the tuple spelling of a direct reference (['cb_market', '=', { $record }]) is refused by name throughengine.find(which lowers first) and by the analytics normalizer'sUnsupported filter operator "$record"through the analytics door, on this head and onmainalike.origin/main2243872 before the change (round 1, scratch): driver-sql (SQLite) refused every comparand shape itself,INVALID_FILTER/ 400 with the operator and field withheld, onfind,count,updateMany,deleteManyandaggregate; driver-memory refused the shorthand on every verb. Throughengine.findthe operator form{ f: { $eq: { $record } } }(and the other five operators) is refused first by the comparand-type door, in its generic sentence, so the describe promises the by-name refusal only where the token pass is the door that meets it.{ attachment: { meta: { $record: 'x' } } }over afilefield answers 200 with["d1"]onmainand on this branch, the driver receiving the filter unchanged.wherefromlookupFilters, so no save or read path starts refusing.READ_SCOPE_COMPILE_FAILED/ 500 in the analytics read-scope compiler, which wraps whatever this pass throws; the message is withheld there as before.mainlegs above are byte-identical).Verification
Round 4 readings at
4fe8f01a37: merge7969da81f8(parents16c765b371,cfcba53920origin/main;field.zod.tsconflict resolved by hand per review#1 S3), regeneratione3775ec5(the three references re-derived from the merged source, equal to main's apart from this PR's two server sentences), changeset4fe8f01a37. Round 4 suites: corefilter-tokens.test.ts79 passed; specfield.test.ts306 passed; core and spec typecheck exit 0; driver-memory pin 5 passed; driver-sql pin 6 passed; speccheck:generatedall 14 up to date aftergen:schema+gen:docs; CI on4fe8f01a: 68 check-runs, 58 success, 10 skipped, 0 failure. The round-3 readings below were taken at16c765b371.Suites and generated artifacts (locked runs, VERDICT command-exit 0)
@objectstack/coretest: 147 files / 3425 tests passed;typecheckexit 0.@objectstack/coresrc/utils/filter-tokens.test.ts: 79 passed.@objectstack/driver-memorysrc/memory-record-reference-refusal.test.ts: 5 passed.@objectstack/driver-sqlsrc/sql-driver-record-reference-refusal.test.ts: 6 passed.@objectstack/specsrc/data/field.test.ts: 306 passed.@objectstack/speccheck:generated: first run 1 of 14 stale (content/docs/references/**, the describe change);--fixregenerated the three references; re-check "All 14 generated artifacts are up to date".Derived gate families (dispatch-gates at 16c765b)
node scripts/pm/dispatch-gates.mjs --commands: 116 commands (84 pnpm, 32 node) over the 10 changed paths.check:skill-examplesfirst exited 3 (PREREQUISITE NOT MET,client-reactdist absent), then 0 once that dist was built.check:dual-build-cjs-loadsexited 3 (PREREQUISITE NOT MET: it reads every package'sdist/, and this worktree builds only the touched closures), recorded NOT-MEASURED; CI'sLint & Repo Gatescarries it.--ran: "116 derived famil(ies) accounted for — 115 run, 1 NOT-MEASURED (0 DERIVED from a recorded exit 3, 1 claimed)", exit 0.origin/main, withscripts/check-skills-token-ratchet.mjsandscripts/pm/label-write.mjschanged across that range; neither reads a path this PR changes. Round 4 mergedorigin/maincfcba539; this 116-family sweep was not re-run on the merge head, and CILint & Repo Gatesis green on4fe8f01a.🤖 Generated with Claude Code
https://claude.ai/code/session_01FEkQ5kgF3mo9f7LXuv5hac