Unified search: FileDef parity on the server (HTML-backed file-meta)#5178
Conversation
There was a problem hiding this comment.
💡 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".
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>
ea77238 to
6c24316
Compare
Host Test Results 1 files ± 0 1 suites ±0 8m 30s ⏱️ - 1h 41m 48s Results for commit 4665e8f. ± Comparison against earlier commit 6c24316. Realm Server Test Results 1 files ±0 1 suites ±0 10m 38s ⏱️ -42s Results for commit 4665e8f. ± Comparison against earlier commit 6c24316. |
There was a problem hiding this comment.
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-metabuilder (buildIdentityOnlyFileMeta) and a corresponding type guard (isIdentityOnlyFileMetaResource), re-exported fromresource-types. - Route file-meta-targeting unified searches through a new
searchUnifiedFileMeta()path that emits identity-onlyfile-meta+rendered-html(+ dedupedcss) when HTML is present, and full livefile-metawhen HTML is absent. - Add contract + endpoint tests covering mixed HTML-present/HTML-absent file rows and verifying no
renderTypeis 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.
`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>
What
Brings FileDef rows to parity with card rows in unified prefer-HTML search. A prefer-HTML search over
FileDefnow emits the identity-onlyfile-meta+rendered-htmlshape (just like cards), rather than always returning a full livefile-metadocument.Why this shape
Files are indexed as
type: 'file'rows. The unifiedrenderprojection is instance-only, so files never flow through the card path — they resolve throughsearchFiles.searchUnifiedFileMetamirrors the card path's per-row prefer-HTML policy:file-meta(id +links.self+ arendered-htmlrelationship,meta.identityOnly: true, noattributes) plus therendered-htmlresource and its dedupedcss.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: therendered-htmlhas none and the identity-onlyfile-meta'sadoptsFromis the file's own resolved type. The host hydrates it to a liveFileDefwith no@codeRef.Surface
buildIdentityOnlyFileMeta— the file counterpart ofbuildIdentityOnlyCard.isIdentityOnlyFileMetaResource— keys onmeta.identityOnly, re-exported fromresource-types.searchUnifiedroutes file-meta-targeting queries tosearchUnifiedFileMeta.No behavior change for callers that don't request
render: a plain ordataOnlyfile-meta query is byte-identical to before.Test plan
unified-search-contracts-test.ts): the new builder produces an attribute-less identity-only file-meta with norenderType; the predicate keys onmeta.identityOnlyand does not cross over with the card predicate.search-test.ts): a mixed-index realm with two.mdfiles — one keeps its prerendered HTML, one has itsfitted_htmlnulled. Atype: FileDefprefer-HTML query returns an identity-onlyfile-meta+rendered-html(norenderType) for the HTML file and a full livefile-metafor the HTML-absent file, in onedataarray.search-test.tsmodule green (21/21); the card mixed-index regression unaffected.