Skip to content

Unified search: FileDef parity on the server (HTML-backed file-meta)#5178

Merged
habdelra merged 2 commits into
mainfrom
cs-11470-unified-search-filedef-parity-server
Jun 10, 2026
Merged

Unified search: FileDef parity on the server (HTML-backed file-meta)#5178
habdelra merged 2 commits into
mainfrom
cs-11470-unified-search-filedef-parity-server

Conversation

@habdelra

Copy link
Copy Markdown
Contributor

What

Brings FileDef rows to parity with card rows in unified prefer-HTML search. A prefer-HTML search over FileDef now emits the identity-only file-meta + rendered-html shape (just like cards), rather than always returning a full live file-meta document.

Why this shape

Files are indexed as type: 'file' rows. The unified render projection is instance-only, so files never flow through the card path — they resolve through searchFiles. searchUnifiedFileMeta mirrors the card path's per-row prefer-HTML policy:

  • HTML present → identity-only file-meta (id + links.self + a rendered-html relationship, meta.identityOnly: true, no attributes) plus the rendered-html resource and its deduped css.
  • No HTML → the full live file-meta, honoring any sparse fieldset and link-expanded exactly as the data-only path.

A file renders natively (its own FileDef component, no ancestor coercion), so unlike a card it carries no renderType: the rendered-html has none and the identity-only file-meta's adoptsFrom is the file's own resolved type. The host hydrates it to a live FileDef with no @codeRef.

Surface

  • buildIdentityOnlyFileMeta — the file counterpart of buildIdentityOnlyCard.
  • isIdentityOnlyFileMetaResource — keys on meta.identityOnly, re-exported from resource-types.
  • searchUnified routes file-meta-targeting queries to searchUnifiedFileMeta.

No behavior change for callers that don't request render: a plain or dataOnly file-meta query is byte-identical to before.

Test plan

  • Contracts (unified-search-contracts-test.ts): the new builder produces an attribute-less identity-only file-meta with no renderType; the predicate keys on meta.identityOnly and does not cross over with the card predicate.
  • Endpoint (search-test.ts): a mixed-index realm with two .md files — one keeps its prerendered HTML, one has its fitted_html nulled. A type: FileDef prefer-HTML query returns an identity-only file-meta + rendered-html (no renderType) for the HTML file and a full live file-meta for the HTML-absent file, in one data array.
  • Full search-test.ts module green (21/21); the card mixed-index regression unaffected.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ea77238285

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/runtime-common/realm-index-query-engine.ts
A prefer-HTML unified search over FileDef rows now emits the same
identity-only + rendered-html shape that card rows already do, instead of
falling through to a full live file-meta document.

Files are indexed as `type: 'file'` rows, which the instance-only `render`
projection skips, so they resolve through `searchFiles`. `searchUnifiedFileMeta`
applies the per-row prefer-HTML policy to each file: HTML present →
identity-only `file-meta` + `rendered-html` (+ deduped `css`); no HTML → the
full live `file-meta` (honoring any sparse fieldset, link-expanded like the
data-only path). A file renders natively, so its `rendered-html` carries no
`renderType` and the identity-only `file-meta`'s `adoptsFrom` is its own
resolved type.

- buildIdentityOnlyFileMeta: the file counterpart of buildIdentityOnlyCard
- isIdentityOnlyFileMetaResource: keys on meta.identityOnly, re-exported from
  resource-types
- searchUnified routes file-meta queries to searchUnifiedFileMeta

Tests: contract coverage for the new builder/predicate, and a mixed-index
endpoint test (one .md keeps its HTML, one is nulled) asserting the HTML file
yields identity-only file-meta + rendered-html and the HTML-absent file yields
a full live file-meta.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@habdelra
habdelra force-pushed the cs-11470-unified-search-filedef-parity-server branch from ea77238 to 6c24316 Compare June 10, 2026 08:25
@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Host Test Results

  1 files  ±    0    1 suites  ±0   8m 30s ⏱️ - 1h 41m 48s
193 tests  - 2 809  192 ✅  - 2 795  1 💤  - 14  0 ❌ ±0 
193 runs   - 2 828  192 ✅  - 2 814  1 💤  - 14  0 ❌ ±0 

Results for commit 4665e8f. ± Comparison against earlier commit 6c24316.

Realm Server Test Results

    1 files  ±0      1 suites  ±0   10m 38s ⏱️ -42s
1 596 tests ±0  1 596 ✅ ±0  0 💤 ±0  0 ❌ ±0 
1 687 runs  ±0  1 687 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 4665e8f. ± Comparison against earlier commit 6c24316.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates unified prefer-HTML search so FileDef-backed file rows (type: 'file' / file-meta) can follow the same “HTML-backed row emits identity-only resource + rendered-html” policy that card rows use, while preserving byte-identical behavior for non-render (plain/dataOnly) file-meta queries.

Changes:

  • Add an identity-only file-meta builder (buildIdentityOnlyFileMeta) and a corresponding type guard (isIdentityOnlyFileMetaResource), re-exported from resource-types.
  • Route file-meta-targeting unified searches through a new searchUnifiedFileMeta() path that emits identity-only file-meta + rendered-html (+ deduped css) when HTML is present, and full live file-meta when HTML is absent.
  • Add contract + endpoint tests covering mixed HTML-present/HTML-absent file rows and verifying no renderType is emitted for files.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/runtime-common/unified-search.ts Adds buildIdentityOnlyFileMeta to construct identity-only file-meta resources paired with rendered-html.
packages/runtime-common/resource-types.ts Re-exports isIdentityOnlyFileMetaResource from the document-shape module.
packages/runtime-common/realm-index-query-engine.ts Introduces searchUnifiedFileMeta() and routes file-meta unified searches through it.
packages/runtime-common/card-document-shape.ts Adds isIdentityOnlyFileMetaResource guard keyed on meta.identityOnly.
packages/realm-server/tests/unified-search-contracts-test.ts Adds unit tests for the new builder and predicate (and their non-overlap with card predicates).
packages/realm-server/tests/server-endpoints/search-test.ts Adds endpoint tests for mixed HTML/non-HTML file rows in prefer-HTML and for dataOnly equivalence with plain live queries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/runtime-common/realm-index-query-engine.ts Outdated
`searchUnifiedFileMeta` resolved its file HTML via the card-side render type,
which `resolveRenderType` defaults to `filter.on`. For a FileDef subclass row
that could select an ancestor's HTML variant and stamp the ancestor as the
identity-only file-meta's `adoptsFrom`, mismatching the file's HTML against its
identity.

Drop the render type before the file lookup so `fileEntryToPrerenderedCard`
always selects each file's own most-derived `types[0]` — the type
`buildIdentityOnlyFileMeta` stamps as `adoptsFrom`. The endpoint test now
asserts a `.md` row's `adoptsFrom` is its subclass `MarkdownDef`, not the
`FileDef` ancestor the query targeted.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@habdelra
habdelra requested a review from a team June 10, 2026 13:10
@habdelra
habdelra changed the base branch from cs-11433-unified-search-_search-renderdataonly-members-emit-rendered to main June 10, 2026 15:44
@habdelra
habdelra merged commit 9cc1f2d into main Jun 10, 2026
119 of 122 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants