Skip to content

test(service-storage): give the attachment read-visibility harness real Filter Protocol semantics - #3792

Merged
os-zhuang merged 1 commit into
mainfrom
claude/attachment-harness-filter-semantics
Jul 28, 2026
Merged

os-zhuang merged 1 commit into
mainfrom
claude/attachment-harness-filter-semantics

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Problem

packages/services/service-storage/src/attachment-read-visibility.test.ts faked its engine with a matcher that understood implicit equality and $in — and nothing else. No $and, no $or, no $not.

Every assertion in the file could therefore only check the shape of the filter computeParentVisibilityFilter emits, never the rows that filter selects. That is a poor bargain for a predicate whose entire job is narrowing: it pairs a discriminator with an id list per branch, and anything that widens $or loosens that pairing while leaving every shape assertion green.

Changes

  • Real Filter Protocol semantics in the harness matcher, mirroring memory-matcher.ts and matches-filter.ts: every key inside one filter object ANDs, a $or array ORs its branches, and a branch's contents still AND. $and / $not handled too; field specs support $eq/$ne/$in/$nin.
  • Unimplemented operators now throw instead of being silently ignored. A test double that quietly under-implements the protocol is precisely the failure mode this PR closes, so incompleteness is loud.
  • A row-level assertion — the case the old harness structurally could not express. A fixture with a visible and an invisible record per parent type, plus a row whose parent_object belongs to one branch while its parent_id appears only in the other branch's id list. The emitted scope must return ['a1','a3']; nothing but a genuine per-branch AND excludes the other three.
  • A conformance block for the matcher itself, on the same 2x2 fixture and the same expectations as memory-matcher-or-semantics.test.ts, matches-filter-or-semantics.test.ts and sql-driver-or-filter.test.ts, so the four evaluators cannot drift apart — plus a case proving the matcher actually distinguishes a correctly paired scope from a widened one.

Proof the gate can go red

I temporarily flattened each $or branch's keys into key-level ORs in the matcher and re-ran. 9 tests failed, the row assertion loudest:

× the multi-parent $or admits only rows matching BOTH keys of one branch
  AssertionError: expected [ 'a1', 'a2', 'a3', 'a4', 'a5' ] to deeply equal [ 'a1', 'a3' ]

Every row in the fixture, where two should match. The injection was reverted; a BUG INJECTION grep over the branch returns nothing.

Verification

  • @objectstack/service-storage: 212/212 passing, 17/17 files.
  • Baseline check: the 58 failures seen on a fresh worktree reproduce identically at pristine HEAD and are stale-dist artifacts (isFileIdToken / RAW_FILE_VALUES_CONTEXT_KEY exist in packages/spec/src but not in the Jul-25 dist). Rebuilding spec + platform-objects clears all of them.
  • The changed file is type-clean; pnpm --filter @objectstack/service-storage build succeeds with DTS.

Test-only — no runtime change, hence an empty-frontmatter changeset (releases nothing).

🤖 Generated with Claude Code

…al Filter Protocol semantics

`attachment-read-visibility.test.ts` faked its engine with a matcher that
understood implicit equality and `$in` and nothing else — no `$and`, no
`$or`, no `$not`. Every assertion could therefore only check the *shape* of
the filter `computeParentVisibilityFilter` emits, never the rows that filter
selects. That is a poor bargain for a predicate whose whole job is
narrowing: it pairs a discriminator with an id list per branch, and anything
that widens `$or` loosens that pairing while leaving shape assertions green.

- The matcher now implements the protocol for real, mirroring
  driver-memory's `memory-matcher.ts` and formula's `matches-filter.ts`:
  every key in a filter object ANDs, `$or` ORs its branches, a branch's own
  contents still AND. Unimplemented operators now throw rather than being
  ignored — a silently under-implemented test double is the failure mode
  this change exists to close.
- New case asserts the ROWS a multi-parent-type scope returns: rows whose
  discriminator matches a branch but whose id is absent from that branch's
  id list — including one borrowing the sibling branch's id — are excluded,
  pinning the per-branch pairing itself.
- A conformance block pins the harness against the same 2x2 fixture and
  expectations as `memory-matcher-or-semantics.test.ts`,
  `matches-filter-or-semantics.test.ts` and `sql-driver-or-filter.test.ts`,
  so the four cannot drift apart, plus a case proving the matcher tells a
  correctly paired scope from a widened one.

Test-only; no runtime change. service-storage: 212/212 green.

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectstack Ignored Ignored Jul 28, 2026 5:42am

Request Review

@github-actions github-actions Bot added 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 size/m labels Jul 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): packages/services.

6 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/automation/webhooks.mdx (via packages/services)
  • content/docs/kernel/runtime-services/audit-service.mdx (via packages/services)
  • content/docs/kernel/runtime-services/index.mdx (via packages/services)
  • content/docs/kernel/runtime-services/settings-service.mdx (via packages/services)
  • content/docs/plugins/packages.mdx (via packages/services)
  • content/docs/protocol/kernel/i18n-standard.mdx (via packages/services)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

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

1 participant