Skip to content

fix(plugin-approvals): inbox search finds a request by the title, process label, object label and requester its row shows - #36976

Merged
objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/issue-36959-approvals-inbox-search-labels
Nov 24, 2026
Merged

objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/issue-36959-approvals-inbox-search-labels

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Yibo Wang · project thread

Fixes #36959

Clause-②: no — the q parameter's accept set is unchanged; what it matches widens to the labels the row already shows the same caller.
Metadata-protocol: none — nothing an author writes changes.

维护者速读

  • 审批人在审批收件箱的搜索框里输入列表上看到的文字(记录标题、流程名称、申请人姓名、对象名称),以前一条都搜不到,现在能搜到对应的申请。
  • 属于审批收件箱的体验修复,替每天要在长队列里找申请的审批人解决「搜索框看起来是坏的」的问题。
  • 出错时最坏情况是某个名称仍然搜不到(只会少搜,不会搜出调用者本来看不到的内容);纯服务端改动,撤回这次合并即可恢复原状。
  • 无。

What changes

ApprovalService.buildRequestWhere (packages/plugins/plugin-approvals/src/approval-service.ts) now adds served-text arms to the free-text $or, beside the four machine-column arms and the gated snapshot arm (both unchanged). A new servedTextArms works out the labels first, as this caller is served them, and turns each one into the machine values that name it:

  • process label: for a flow where readerLabels picks a translation for the reader, process_name IN the flows whose picked label holds the term. For the other flows, process_label (the stored column, which is what those rows serve) holds the term AND process_name IN those flows. So a reader who is shown a translation is never found by the stored text they are not shown.
  • object label: readerLabels' pick, else the schema label (the same pair object_label is set from), giving object_name IN.
  • requester name: resolveUserNames (the resolver behind submitter_name) over the scope's submitters, giving submitter_id IN.
  • record title: recordsTitledWith, per subject object, giving object_name = O AND record_id IN. The title is the shared titleAsServed over the caller's served fields from servedFields, which is the same resolveReadableSnapshotFields answer, asked as the caller, that redactPayloads and the served record_title use. With a schema, the driver read is first narrowed to records where a served title field holds the term; the served title still decides. pickTitle's candidate list is now one shared titleCandidates.

The flows, objects, records and submitters to resolve come from one read of the requests under the query's own non-text filter (tenant, object, record, submitter, status; status is now set before the arms), newest first, capped at 5,000 with a warn when the cap is hit. Every arm carries a non-empty set. Anything that cannot be resolved adds no arm, so a failure narrows the search and never widens it. freeTextMayMatchSnapshot and its narrowing are unchanged. Matching stays case-sensitive ($contains), like the existing arms.

The placeholder ("Search record, process, requester…") is now accurate, so ApprovalsInboxPage.tsx and the i18n packs are untouched.

Read first (by risk):

  1. approval-service.ts, servedTextArms: the process-label split (picked flows vs. the stored column narrowed to unpicked flows) is where the invariant could leak.
  2. approval-service.ts, recordsTitledWith: the candidate filter by served fields and the titleAsServed post-filter.
  3. approval-inbox-search-display-text.integration.test.ts: the "a term the caller is not served finds nothing" block.

Two-minute check: pnpm --filter @objectstack/plugin-approvals exec vitest run --maxWorkers=2 src/approval-inbox-search-display-text.integration.test.ts. Expect 21 tests to pass.

Tests

New src/approval-inbox-search-display-text.integration.test.ts runs the real ApprovalService on a real ObjectQL over SqlDriver (better-sqlite3, in-memory, real DDL), in the filer's shape: security wired (so the snapshot arm is dropped) and an approver who can read every field. It covers:

  • each of the filer's terms finds its row: titles (Polar, Cargo, 上海, 拜访, UI测试), process labels (大额, 出差申请审批), requester names (Dev, Admin, Sam Submitter) and the object label (商机). Also checked with the object filter set, and countRequests agrees;
  • machine-name control: crm_ still finds every row and large_opportunity finds its row. With no field-visibility source wired, titles still match through the snapshot arm;
  • visibility pins: a title field the caller may not read, or reads masked, finds nothing (the control with the field readable does). A zh-CN reader who is served the translated process label is found by the translation and not by the stored label; a reader with no locale gets the reverse.

approval-free-text-scope.test.ts: the expected column sets now include process_label, and the "never empty" arm count goes from 4 to 5. Its four properties are unchanged.

Red on main (the service at the base commit, the new test file)

git restore --source=0212714711 -- approval-service.ts (count of servedTextArms 5 to 0), then the file: Tests 16 failed | 5 passed (21). Every filer term failed (titles, process labels, requester names, object label, object-filtered, count, the readable control and the translated-label case). The five that passed are the fixture-serves check, the two machine controls, the unwired-titles check and the masked-title pin, which passes on main only because nothing matched. Restored with git checkout HEAD --: git diff HEAD empty, blob equals HEAD.

Ablations (scripts/ablation-replace.mjs, restore verified by blob == HEAD and an empty diff)
  • Title arm ignores the caller's served fields (recordsTitledWith(object, ids, undefined, q)), anchor 1 to 0: Tests 2 failed | 19 passed. The failures are both masked-title pins.
  • Stored process label no longer narrowed to unpicked flows (arms.push({ process_label: { $contains: q } })), anchor 1 to 0: Tests 1 failed | 20 passed. The failure is the translated-label pin.

The subject is imported from source (./approval-service.js), so no dist/ leg applies.

Acceptance notes

  • Case: matching stays case-sensitive ($contains is case-exact on every backend), so polar does not find Polar Cargo, which matches the existing machine arms. A case-insensitive search would be its own change ($icontains is ASCII-only).
  • A record title that comes only from a deleted record's snapshot is not searched by the new path; in an unwired deployment the snapshot arm still covers it.
  • A row whose stored process_label is blank serves a fallback label (the config snapshot or a prettified machine name) that is not searched. The display-label backfill fills that column at boot.
  • Cost: each search with a term adds one bounded scope read (5,000 rows, three machine columns), one sys_user read for the scope's submitters, and one title read per subject object in scope.

Verification

All local readings were taken at head 2fb0426373.

Package test and typecheck
  • pnpm --filter @objectstack/plugin-approvals exec vitest run --maxWorkers=2 (whole package): Test Files 128 passed (128), Tests 1920 passed (1920), exit 0.
  • pnpm --filter @objectstack/plugin-approvals typecheck: exit 0. check:test-typecheck: OK; the test layer compiles under tsconfig.test.json with the ledger unchanged.
  • The dependency closure was built first: pnpm --filter '@objectstack/plugin-approvals^...' build, lock VERDICT command-exit 0.
Derived gate families (dispatch-gates --commands, 72 derived)
  • 68 exit 0. That includes check:engine-double-contract, check:nul-bytes, check:cross-package-test-inputs, check:test-source-alias, check:issue-citations, check:doc-authoring, check:empty-changeset, check:adr-0087-registration and check:type-check-coverage.
  • 4 NOT MEASURED (exit 3, prerequisite refused). check-plugin-teardown-shape --self-test needs a pinned commit the shallow clone lacks. check:dual-build-cjs-loads and check:i18n need a full build this run did not do. check:type-check-debt lost its closure build to the shared verify lock (queue-timeout). CI runs all four.
  • dispatch-gates --ran reconciliation: 72 derived, 68 run, 4 NOT-MEASURED (derived from recorded exit 3), 0 UNRUN.
  • overlap-check: clean against origin/main, with 0 overlapping open PR heads.

Generated by Claude Code

… object label and requester a row shows

Claude-Session: https://claude.ai/code/session_01WGufziG2t1d9cfRQJDrHkB
Co-authored-by: Claude <noreply@anthropic.com>
…curity-wired shape

Claude-Session: https://claude.ai/code/session_01WGufziG2t1d9cfRQJDrHkB
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/l documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/plugin-approvals, touching 12 documentable anchor(s).

18 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 57445a699810a0545d8b3a7649a77327d47fb18b.

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

What this run could not see
  • 1 anchor(s) matched too much of the corpus to be a work list: created_at (literal, 49 pages)
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 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; 124 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 — 6 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 57445a699810a0545d8b3a7649a77327d47fb18b → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json 57445a699810a0545d8b3a7649a77327d47fb18b

⚠️ 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 57445a699810a0545d8b3a7649a77327d47fb18b → 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#3 · os-support-ai · session_01WGufzesUz1Y8VZuKJRhVL8

席位核对 — ACCEPT · repo:objectstack#3 · head 2fb0426 · 2026-11-24T13:21Z

L1 read of #36976 (card #36959, p1) at 2fb042637378ff461bd0101f54ed9f4bb908c55b. Clause-② no and Metadata-protocol none, both true: the q accept set is unchanged and only what it matches widens, on a non-spec surface. NOT governed, 537 changed lines. l1-face is clean. No contract review is owed by surface. I read the visibility invariant myself, below, and judged that it does not need one.

Against the card. buildRequestWhere keeps its four machine arms and the snapshot arm, unchanged with freeTextMayMatchSnapshot. It adds servedTextArms: the process label, object label, requester name and record title, each resolved first, the way this caller is served it, into an $in over machine values. The filer's terms are pinned on real ObjectQL over SqlDriver: 商机 matches, 出差 finds a row once although it sits in two of its labels, the object filter is set, and countRequests agrees with the list. The machine-column controls still match.

The invariant (read hardest). A request is never found by text the same caller is not served.

  • Title. recordsTitledWith reads under SYSTEM_CTX and decides with titleAsServed(rec, displayField, readable), where readable is servedFields asked as the caller. That is the same function, read the same way, as the serve path's titlesAsServed (resolveSubjectDisplays), so it is no wider than what is served. The pushed-down $contains is limited to title candidates in the served set and is only a superset filter: a record whose name wins pickTitle is not found through a title field that holds the term. The deleted-record snapshot fallback is not searched, which narrows and is stated.
  • Process label. A picked translation matches via process_name $in. The stored process_label $contains is limited to flows with no pick, so a reader shown the translation is not found by the stored text. This is pinned, and the ablation reds it.
  • Object label and requester. These use the same pair and the same resolver (readerLabels, then objectLabelOf, and resolveUserNames) that set object_label and submitter_name.
  • Scope. The scope read takes machine columns only and is never served. The participant narrowing still applies to the whole predicate afterwards. A failed read or an unresolved label adds no arm, so the search narrows and never widens. Every arm's value set is non-empty, and the $or keeps its machine arms.
  • The masked and unreadable title pins have a readable control. Moving status above the free-text block feeds the scope read and leaves the final predicate unchanged.

Changeset. It names @objectstack/plugin-approvals at patch, and each sentence holds, including the case-sensitivity and deleted-record sentences.

Nits (none block).

  • N1. The scope window is SERVED_TEXT_SCOPE_CAP = 5,000, newest first, with a warn. In a tenant past that, labels of older requests are not searched. The machine arms still are. It is stated in the body and the code. A follow-up card is worth filing if a tenant reaches it.
  • N2 (SQL first). Labels are resolved in the app, not by a join, and the reason is given: each label is computed at serve time (translation picks, the user-name resolver, field-level redaction), so none is a column the predicate can test as served. Titles and the stored process label still push down. Accepted.
  • N3. Each search adds a scope read, a sys_user read and one title read per subject object. The body states this, and it is bounded.
  • N4. Matching stays case-sensitive ($contains), like the existing arms. It is out of scope and noted.
  • The deviation (three pushes before the first overlap-check, which then read clean) is a process slip only.

Mechanical. All-checks: 37 success · 16 expected skips · 0 failed · 0 pending. Floor checks are green, mergeable_state is clean, and Fixes #36959 delivers the card.

Every open finding is a nit. ACCEPT, ordinary queue landing.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufziG2t1d9cfRQJDrHkB

Landing: 2026-11-24T13:22Z · area ux-C · p1 · head 2fb042637378ff461bd0101f54ed9f4bb908c55b

Probe Reading
L1 席位核对 ACCEPT at this head, comment 7132732342 (visibility invariant read in-seat; nits N1–N4 need no action)
L2 not owed: Clause-②: no, Metadata-protocol: none, no packages/spec/src/**, no governed path
Checks 37 success, 16 skipped, 0 failed on this head
mergeable_state clean
check-governed-merges NOT governed, 537 changed lines ≤ 3000; one PR on the card
landing-k OK — K = 0 < 15 (merge-base 02127147, 8 first-parent commits behind main; no translations/ file in the PR)

State: ready + auto-merge (merge queue).

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/l tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants