Skip to content

fix(objectql): a free-text search resolves only over the fields the caller may query - #25705

Merged
objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/issue-25672-search-readable-fields
Oct 25, 2026
Merged

objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/issue-25672-search-readable-fields

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #25672

Clause-②: yes (widening)
Metadata-protocol: none

Declaration

This PR declares an acceptance widening. A member's GET /api/v1/data/sys_user?search=… was refused with 403 and is now served with 200. On a published REST door, the same input's answer moves from refuse to accept. One search for published text that already denied that refusal found none. ADR-0061 D5 says only that field-level security "applies automatically" to search, which does not settle whether the expansion narrows or refuses. So this PR declares the widening rather than quoting. Every refusal that stays (an explicit filter or searchFields on a hidden field) is unchanged. Metadata-protocol: none and patch are kept: no authorable metadata key or schema changes.

What

A free-text search now resolves only over the fields the caller may query. expandSearchOnAst (packages/objectql/src/engine.ts) asks the registered security service's getQueryableFields(object, context) and passes the answer to expandSearchToFilter as queryableFields. search-filter.ts then withholds every resolved field outside that set. The answer is read through the engine's existing SECURITY_SERVICE_SOURCE_SLOT, and the context is the one the middleware will see. This applies to find, findOne, count and aggregate.

  • One readability source. getQueryableFields is the published complement of what the field-read predicate guard refuses (same computeQueryGuardFieldPerms derivation), and searchAll already narrows with it. The engine adds no second field-permission rule.
  • The guard is unchanged. It still judges every predicate the caller wrote.
  • Named fields are not withheld. A field the caller names in searchFields (either spelling) reaches the guard and is refused with 403, as before.
  • Narrowing happens after resolution. A declared set that is entirely hidden stays empty and does not fall through to the auto-default.
  • Empty set. A set withheld down to nothing answers the existing metadata-protocol / objectql: a search term on an object with no searchable field is dropped silently, so the read answers every row (an empty auto-default search set is not refused) #24284 refusal (400 INVALID_FIELD, param: search), with a message that names field-level security as the cause.
  • No answer, no narrowing. No context, no service, no method, or an undefined answer leaves the set as it is, and the guard decides as today.

Proof (fresh boot, pnpm dev:crm -- --fresh, a non-admin org member vs the seeded admin)

Request Member Admin
GET /api/v1/data/sys_user?search=Mia 200, Mia Member 200, same row
?search=admin@objectos (email) 200, Dev Admin n/a
console shape populate=primary_business_unit_id&top=25&search=Adm&filter=["banned","!=",true] 200, Dev Admin 200, same row
?filter=["ban_reason","=","x"] 403 PERMISSION_DENIED (guard holds) n/a
?search=x&$searchFields=ban_reason 403 naming ban_reason n/a
?search=x&searchFields=name,role 403 naming role n/a
?search=user n/a 200, both users (matched on role: the admin's set is unchanged)
  • Ablation. I replaced { ...expandOptions, queryableFields } with { ...expandOptions } via scripts/ablation-replace.mjs (anchor 1 → 0, blob 7383042fc6ad → cf902b78f292), rebuilt, and ablation-dist-preflight --absent passed. Re-booted, the member's three searches answered 403 ... not readable by the caller: role, ban_reason, last_login_ip, the card's exact refusal. The admin rows matched the fixed run byte for byte, ids aside.
  • Restore. git checkout HEAD --, disk blob 7383042fc6ad = HEAD blob, git status --porcelain empty, rebuilt, and the preflight finds the marker in dist/core.{js,mjs}.
  • Generality. The second object is a unit-level proof (engine-search-queryable-fields.test.ts: an auto-default object loses its hidden private_note). The CRM example has no non-sys_user object with a member-hidden searchable field to drive over HTTP.

Tests (behaviour at 61177d0f12; the head 9b04a57b68 changes only the changeset declaration line)

  • pnpm --filter @objectstack/objectql exec vitest run: 468/468 files, 8719/8719 tests.
  • pnpm --filter @objectstack/objectql typecheck: exit 0, test layer included.
  • plugin-security: 222 files, 4628 passed, 45 skipped. plugin-audit: 60 files, 985 passed. Both use the rebuilt objectql dist.
  • New: engine-search-queryable-fields.test.ts (each verb, generality, named-field pass-through, every no-answer road, blank term, all-withheld → 400) and 4 cases in search-filter.test.ts.

Gates

  • dispatch-gates --commands: 73 derived, all run, all exit 0.
  • --ran reconciliation: 73/73 with exit codes, 0 NOT-MEASURED.
  • Two families (check-engine-split-ratio, check-plugin-teardown-shape --self-test) first refused on the shallow clone and passed after git fetch --unshallow.
  • eslint --no-inline-config on the four touched files: exit 0.

Acceptance notes

  • packages/platform-objects/src/identity/sys-user.object.ts is untouched: the general route made the narrower one unnecessary, so there is no overlap with feat(plugin-auth): multi-org Create User joins the administrator's current organization #25626.
  • count narrows with the same set, so the paged total agrees with records for a member.
  • getQueryableFields withholds masked fields too, matching the guard: a member's search no longer matches on a field they see masked, where it used to 403.

Generated by Claude Code

@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling labels Oct 24, 2026
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/objectql, touching 10 documentable anchor(s).

15 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/api/data-flow.mdx (via findOne (symbol, a method of class ObjectQL))
  • content/docs/automation/hook-bodies.mdx (via findOne (symbol, a method of class ObjectQL))
  • content/docs/automation/webhooks.mdx (via findOne (symbol, a method of class ObjectQL))
  • content/docs/data-modeling/queries.mdx (via expandSearchToFilter (symbol, a top-level function))
  • content/docs/kernel/contracts/data-engine.mdx (via findOne (symbol, a method of class ObjectQL))
  • content/docs/kernel/contracts/index.mdx (via findOne (symbol, a method of class ObjectQL))
  • content/docs/kernel/events.mdx (via findOne (symbol, a method of class ObjectQL))
  • content/docs/permissions/attachments-access.mdx (via findOne (symbol, a method of class ObjectQL))
  • content/docs/permissions/field-level-security.mdx (via findOne (symbol, a method of class ObjectQL))
  • content/docs/permissions/record-view-auditing.mdx (via findOne (symbol, a method of class ObjectQL))
  • content/docs/permissions/rls.mdx (via findOne (symbol, a method of class ObjectQL))
  • content/docs/permissions/system-context.mdx (via findOne (symbol, a method of class ObjectQL))
  • content/docs/protocol/objectql/query-syntax.mdx (via expandSearchToFilter (symbol, a top-level function), findOne (symbol, a method of class ObjectQL))
  • content/docs/protocol/objectql/schema.mdx (via findOne (symbol, a method of class ObjectQL))
  • content/docs/ui/react-pages.mdx (via findOne (symbol, a method of class ObjectQL))

⛔ 7 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v15.mdx (via findOne (symbol, a method of class ObjectQL))
  • content/docs/releases/v16.mdx (via findOne (symbol, a method of class ObjectQL))
  • content/docs/releases/v17/17-0.mdx (via findOne (symbol, a method of class ObjectQL))
  • content/docs/releases/v17/17-5.mdx (via findOne (symbol, a method of class ObjectQL))
  • content/docs/releases/v17/17-6.mdx (via findOne (symbol, a method of class ObjectQL), getQueryableFields (literal, a string literal in resolveSearchQueryableFields))
  • content/docs/releases/v17/17-7.mdx (via findOne (symbol, a method of class ObjectQL))
  • content/docs/releases/v17/index.mdx (via findOne (symbol, a method of class ObjectQL))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 1 anchor(s) matched too much of the corpus to be a work list: ObjectQL (symbol, 72 pages)
  • 2 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 54 of 206 client-bound route-ledger rows — the other 152 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 152: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 55 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 97 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 — 19 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 3b8ea15c21caad40686ccb811e2b0b4bd4fef9ca → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json 3b8ea15c21caad40686ccb811e2b0b4bd4fef9ca

⚠️ 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 3b8ea15c21caad40686ccb811e2b0b4bd4fef9ca → 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

席位核对

REWORK · domain:server seat 2 · sunhaolin · session_01JVTd3PprStGa26aez5omLB · 2026-10-25T03:34Z · head 61177d0f12

  • Behaviour: passes the seat's review. The free-text search expansion asks the security service's getQueryableFields (the guard's own derivation) and withholds every resolved field outside it; the field-read guard is unchanged; a field the caller names is still refused; an all-withheld set answers the existing metadata-protocol / objectql: a search term on an object with no searchable field is dropped silently, so the read answers every row (an empty auto-default search set is not refused) #24284 refusal. CI on this head: 34 success, 7 skipped, 0 red.
  • Owed, the declaration: a member's ?search= on sys_user was refused and is now served, so the same input's result changed toward accept on a published REST door. A Clause-②: no that removes a refusal must quote the published text that already denied it; without the quote it reads as a missing declaration. Either quote that text or declare Clause-②: yes, which owes this seat's TIER_DEFAULT review record.
  • Next: the seat's review record and landing after the rework.

Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 9b04a57b6881136ddef8c6c6955facdd183407f2
Local-runs: none
Scope: packages/objectql/src/engine.ts, packages/objectql/src/search-filter.ts, packages/objectql/src/engine-search-queryable-fields.test.ts, packages/objectql/src/search-filter.test.ts + packages/plugins/plugin-security (getQueryableFields, computeQueryGuardFieldPerms, read-only), packages/objectql/package.json exports

① Derived judgments

  • Widened, right: a caller's free-text search on an object with searchable fields the caller cannot read was refused 403 by the field-read guard and is now served 200 over the readable fields only. The readable set is the security service's getQueryableFields, the same derivation the guard refuses by, so no hidden field reaches a predicate and nothing the guard protects is exposed.
  • Unchanged, right: an explicit filter, $searchFields or searchFields naming a hidden field is still refused 403; an administrator's resolved set and rows are unchanged; no answer from the security service leaves the set as before.
  • Moved refusal, right: a set withheld down to nothing answers the existing metadata-protocol / objectql: a search term on an object with no searchable field is dropped silently, so the read answers every row (an empty auto-default search set is not refused) #24284 refusal (400 INVALID_FIELD, param: search) instead of the guard's 403; an existing code, no new one.
  • Public surface: ExpandSearchOptions.queryableFields is added in search-filter.ts, which neither package entry (., ./core) re-exports; it is not on the published surface. The widening is the REST door's accept set alone.

② Semver level

Clause-②: yes (widening) in the body and the changeset; Metadata-protocol: none (no authorable key or schema moves); patch on @objectstack/objectql, as AGENTS.md step 3 sets for a non-protocol widening. Check Changeset reads the declaration on the head.

③ Boundary flags

  • The no it replaced quoted no published text; the dev's one search found ADR-0061 D5, which does not settle narrowing versus refusing, so yes is the honest declaration.
  • Masked fields are withheld too, matching the guard: a member's search no longer matches on a field they see masked, where it used to 403. Consistent with the guard; noted, not owed.
  • sys-user.object.ts is untouched, so no overlap with PR feat(plugin-auth): multi-org Create User joins the administrator's current organization #25626.

Implemented-by: session_018sBs7EHHJdB92hpDWae2e2
Reviewed-by: session_01JVTd3PprStGa26aez5omLB

VERDICT: PASS


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

席位核对

ACCEPT · domain:server seat 2 · sunhaolin · session_01JVTd3PprStGa26aez5omLB · 2026-10-25T03:39Z · head 9b04a57b68 · claim 6387490945 · REWORK (this PR, the declaration round)

  • Shape: draft, base main, author objectstack-fleet[bot], assignee sunhaolin, Fixes #25672, Clause-②: yes (widening) and Metadata-protocol: none line-initial in the body and the changeset, patch on @objectstack/objectql. 5 files in packages/objectql/src/; not governed.
  • Rework, read on the diff 61177d0f12..9b04a57b68: one line of the changeset, the declaration; no code change. Body applied by the seat through the relay, 5,429 bytes read back identical.
  • Review owed by the yes declaration: this seat's TIER_DEFAULT record, comment 6393040969, VERDICT: PASS on this head.
  • Behaviour (unchanged from the REWORK record): the free-text search resolves only over the fields the caller may query, from the security service's own derivation; the field-read guard is unchanged; named hidden fields are still refused; an all-withheld set answers the existing metadata-protocol / objectql: a search term on an object with no searchable field is dropped silently, so the read answers every row (an empty auto-default search set is not refused) #24284 refusal.
  • CI on head 9b04a57b68 at this read: 17 success, 13 skipped, 15 in progress, 0 red. The seat lands when they conclude green.
  • Writes: mcp_calls 0; the dev's relay writes were pr_create and the report comment.

Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

Contract review

Served-tier: TIER_DEFAULT
Head-sha: e348f156ef284f6acaeb17627f5c350f492fa167
Local-runs: none
Scope: packages/objectql/src/engine.ts, packages/objectql/src/search-filter.ts, packages/objectql/src/engine-search-queryable-fields.test.ts, packages/objectql/src/search-filter.test.ts, .changeset/25672-search-readable-fields.md + none

① Derived judgments

The head moved from 9b04a57b68 by one merge of origin/main and nothing else. Measured by the seat: the PR's net diff against its merge base is line-for-line identical at both heads (5 files, +355 / −23). The judgments of record 6393040969 stand unchanged: the free-text search widening on the REST data door is right (the readable set is the guard's own derivation; no hidden field reaches a predicate), the named-field refusals and the administrator's results are unchanged, and the all-withheld set answers the existing #24284 refusal.

② Semver level

Unchanged: Clause-②: yes (widening), Metadata-protocol: none, patch on @objectstack/objectql.

③ Boundary flags

The Test Core (2/6) red on 9b04a57b68 was a 5 s timeout in plugin-security's delegated-organization-membership.test.ts parity case, a file with no search read; the dev measured it passing in under 1 s and the whole package 223/223 on this head's rebuilt closure. This head's own CI run is the reading.

Implemented-by: session_018sBs7EHHJdB92hpDWae2e2
Reviewed-by: session_01JVTd3PprStGa26aez5omLB

VERDICT: PASS


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

席位核对

ACCEPT · domain:server seat 2 · sunhaolin · session_01JVTd3PprStGa26aez5omLB · 2026-10-25T04:31Z · head e348f156ef · claim 6387490945 · supersedes ACCEPT 6393047756 (head 9b04a57b68)

  • What moved: one merge of origin/main, nothing else. Measured by the seat: the PR's net diff against its merge base is line-for-line identical at both heads (5 files, +355 / −23).
  • Review owed by the yes declaration: this seat's TIER_DEFAULT record on this head, comment 6393346560, VERDICT: PASS.
  • CI on head e348f156ef at this read: 34 success, 11 skipped, 0 red. The Test Core (2/6) timeout on 9b04a57b68 (a plugin-security parity case with no search read) did not recur.
  • Landing: the seat lands now through the relay (pr_ready + automerge_enable).

Generated by Claude Code

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review October 25, 2026 04:31
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge October 25, 2026 04:31
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Oct 25, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⛔ merge queue 构建失败 — 先分诊,再决定要不要重排

队列构建 40162354141 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集),
所以失败的测试可能在本 PR 没碰过的包里 —— 那不是重排能修的。每次盲目重排都会让排在后面的所有 PR 重建一轮。

分类:failure —— 按下面的日志分诊。

失败的 job(日志抽取,best effort):

  • Test Core (3/6) — 失败步骤: Run this shard's tests

    @objectstack/plugin-pinyin-search:test:  FAIL  src/boot-reconcile.integration.test.ts > #25634 the boot reconcile reads what changed since its last completed walk > a first boot walks every row; an un
      ↳ 失败原因: @objectstack/plugin-pinyin-search:test: Error: Test timed out in 5000ms.
    

↳ 失败原因 是判读的关键:超时(Test timed out in … / Hook timed out in …)多半是负载/时序,不是本 PR 的回归;
断言(AssertionError: …)才指向真实的行为改变。两者的 FAIL 行长得一模一样,只有这一行能区分。

⚠️ 断言这一侧有一类例外,判据是断言在测什么,不是它是不是 AssertionError。 断言的对象是产品行为(一个值、一个形状、一次拒收)⇒ 照上面读:真实的行为改变,去查,⛔ 不要重排掉;
断言的对象是这次实验自身的有效性前提(跑完的耗时、负载下的先后、任何只在时间预算内才成立的条件)⇒ 它跟超时是同一类,同样对负载敏感,重排一次是合法的判别手段。
识别是机械的:断言的消息或它比较的值本身点名了一段时长、一个时间戳、一个耗时计数。实测过的一对 —— AssertionError: SecurityPlugin.init() ran: expected false to be true 测的是产品行为(真回归);
AssertionError: this run took over a second, so second-precision stamps could have differed too: expected 1006 to be less than 1000 测的是实验前提:它守护的那条不变式当时是绿的,同一个 head 原样重排一次即成功。
穿着 AssertionError 外衣的时间测量,仍然是时间测量。(⛔ 这只改「怎么读一次红」,不改「哪些测试可以重排」——后者由别处管。)

跨 PR 相同签名(24h,按失败测试文件聚合):

  • src/boot-reconcile.integration.test.ts — 24h 窗口内只有本 PR 撞到过,暂不汇总(再有一个不同 PR 撞到就会自动开汇总 issue)。
  • ⚠️ 24h 评论账本没读完(超过 5 页仍未读到窗口尽头),所以上面的「不同 PR 数」是下界,不是全量。

历史信号:

  • 本 PR 过去 24h 无队列失败记录(首次)。
  • 过去 24h 队列共有 0 个失败构建(不含本次)。

分诊清单:

  1. 失败测试在本 PR 改动的包里 → 真回归,修 PR。
  2. 失败测试与本 PR 无关 → 看上面的「跨 PR 相同签名」;已有汇总 issue ⇒ flaky/环境问题实锤,去那张 issue 上谈,修好前重排只会再烧一轮全队列。
  3. 两者都不是 → 可能与同组 PR 语义冲突;等前面的 PR 落地或失败出队后再重排一次即可,不要连续重排。

Generated by Claude Code · merge-queue-triage workflow (#4859)

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

席位核对

Queue red, not this PR's · domain:server seat 2 · sunhaolin · session_01JVTd3PprStGa26aez5omLB · 2026-10-25T05:08Z · head e348f156ef


Generated by Claude Code

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

Labels

documentation Improvements or additions to documentation size/m tests tooling

Projects

None yet

2 participants