Repository navigation
docs(architecture): teach the exported DataSource, and the App Router client boundary - #8358
Conversation
… client boundary Two defects on one page, kept separate. objectui#8160 — the "Custom Data Source Interface" section declared a local six-method `DataSource` with an optional `getMetadata()` and no `getObjectSchema()`. The exported `DataSource` in `@object-ui/types` has six REQUIRED members: find, findOne, create, update, delete, getObjectSchema, and declares no `getMetadata` at all. A stand-in annotated with the page's interface and handed to `ObjectView` (whose `dataSource` prop is typed `DataSource`) was rejected with TS2741. The page now imports the exported type instead of re-declaring it, names the six required members through a `Pick` the compiler checks, and proves the six suffice by assigning them to the whole interface. The example implementation is annotated `: DataSource`, so the former `// ... implement other methods` elision cannot come back: leaving a required member out stops the block compiling. objectui#8161 — Example 2's `app/layout.tsx` and `app/[object]/page.tsx` fences carried no `'use client'`. Under the App Router every module under `app/` is a server component by default, and the `@object-ui/*` packages ship no `'use client'` banner of their own, so the boundary must be declared in the consumer's files. Both fences now carry the directive, with a sentence saying why rather than only the line to copy. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr
|
ACCEPT (#8160 + #8161, one PR by triage's routing) — reviewed on the tree at head #8160 — verified from the diff and the tree:
#8161 — verified separately, as its own criterion:
Gate totals and one honest correction: the dispatch said 631 of 631 blocks judged; the dev re-measured 632 of 632 on the UNCHANGED tree first and reported the difference as corpus movement between the last landing and today, not as this diff's. That is the right way to handle a number that does not match its brief. Also declared rather than quietly counted: The observation handed back — that no Next: CI convergence → flip ready → post-flip guard → auto-merge SQUASH → queue confirmation → landing probe (the imported Generated by Claude Code |
|
Armed: PR #8358 flipped ready at 2026-09-07T14:40:51Z on head Generated by Claude Code |
|
LANDED: merged at 2026-09-07T14:57:31Z as One control correction, because the reading matters more than the expectation. The Armed note said the probe's control would be Generated by Claude Code |
Fixes #8160
Fixes #8161
Two defects on one page (
docs/ARCHITECTURE.md), collapsed into one PR so the two never race the same file. They are not a family fold: the defect forms differ, so each card keeps its own acceptance criterion and its own evidence below. Neither card inherits the other's.The two truths — what the page taught vs. what the tree exports
packages/types/src/data.ts)interface DataSourceDataSource, exported by@object-ui/typesfind,findOne,create,update,delete)getObjectSchemagetMetadatagrep -rn "getMetadata" packages/types/src/returns nothinggetObjectSchemaObjectViewProps.dataSource: DataSource(packages/plugin-view/dist/ObjectView.d.ts:75) — required, and the real type'use client'anywhere on the page'use client'banner either, so the consumer's file is the only place the boundary can be declaredRequired-member census, re-derived rather than quoted:
Six. Every other member of
DataSourcecarries?.Card #8160 — before / after, with the probe
The probe is the gate's own harness:
compileSnippets()fromscripts/check-doc-snippet-types.mjs, so the stand-in is judged against the builtdist/*.d.tsexactly as a reader who copies the page would be. The interface text is read off disk, never retyped.Before — a stand-in annotated with the page's verbatim interface, handed to
ObjectView:The card's measured diagnostic reproduces exactly. The card's reading stands.
After — the same probe against what the page now teaches, again read verbatim off disk:
Route 甲 as dispatched: the page now imports the exported type instead of re-declaring it. Route 乙 was not needed and is not taken — a self-consistent minimal subset does exist (the six required members), so no new public contract had to be invented.
What the page now teaches, and why each line is load-bearing rather than decorative:
type MinimalDataSource = Pick[DataSource, 'find' | 'findOne' | 'create' | 'update' | 'delete' | 'getObjectSchema']— names the six, and the names are compiler-checked.export const adapter: DataSource = minimal— proves the six suffice. It goes red the moment a seventh member becomes required.Both halves are checked, not asserted. Negative control on that claim — swapping the page's old
getMetadataback into thePick:So the
Pickis not silentlyany: the exact spelling the page used to teach is the exact spelling the compiler now rejects.The elision decision, under the four axes
The
// ... implement other methodselision in the example fence — the same shape #5174's batch 37 repaired in the root README with an ambientdeclare class ... implements DataSource. The choice here was between that ambient-class treatment, a hand-written members table, and a fully written example annotated: DataSource. Taken: the annotated full example.ObjectViewProps.dataSource: DataSource, required. The reader's real task is producing a value that satisfies it, and the thing that fails them is a missing member, not an unclear shape. Adeclare classteaches the shape but hands back nothing runnable; the annotated literal is copy-paste-able and still complete. The members-table option was rejected on this axis too, but for a sharper reason: a hand-copied signature table is exactly the drift hazard this gate's own header records against itself (objectui#7448 — "a pointer to the list now rather than a copy of its length"). Signatures are inferred from the contract in the new example, so there is no second copy to drift.@object-ui/typesalready owns; the repair deletes the second contract rather than syncing it. Nothing on the page restates a signature any more, so there is no maintenance coupling left to forget.check:doc-snippetsfails naming this file. Contract tightening over consumer tolerance, and the declaration is enforced rather than merely written — no??-style fallback anywhere near it. The ambientdeclare classscores nearly as well here, and loses only on the business-need axis above.MinimalDataSourceis a local alias inside a documentation block, not a published type, and route 乙 (a new exported "minimal adapter" contract) is explicitly declined. No staged window, no dual spelling: the wrong interface is deleted in this PR rather than deprecated beside the right one.No axis conflicts here — all four point the same way, so nothing is escalated.
Card #8161 — the re-derived zero, with a live control
The card's own control is dead, and the PM's finding is confirmed. The card offered: "
git grep -n 'use client' origin/main -- docs/ARCHITECTURE.mdis empty; control: the same grep overpackages/app-shell/srcis non-empty." Re-run, with exit codes captured by redirect (never through a pipe —| headcloses the read end and hands the producer a SIGPIPE-flavoured 0):packages/app-shell/srcreturns the same reading as the subject, so it could never distinguish "the grep works and the page has none" from "the grep is broken". As written, the card's zero was unbacked.Live control, same grep invocation, a population that actually fires:
apps/site/app— 8 files, includingapps/site/app/components/InteractiveDemo.tsxandapps/site/app/playground/page.tsx; 75 files repo-wide. Against that control the zero ondocs/ARCHITECTURE.md(exit=1, 0 lines) is a reading. The card's conclusion survives; only its control had to be replaced.The dead control also turned out to be a fact worth teaching rather than merely a broken instrument.
'use client'occurs zero times not just inpackages/app-shell/srcbut in the built output of every package these fences import:That is precisely why the consumer's
app/files have to carry the directive, and it is now the substance of the explanatory sentence.The teaching choice: which file carries the directive
Triage left this open — layout, page, or both. Taken: both, with one sentence of prose above the pair rather than a comment inside each fence.
Under the same four axes, briefly: the business-need axis settles it on measurement, not taste. Each fence needs it for an independent reason —
app/[object]/page.tsxcalls theuseDataSource()hook, andapp/layout.tsxrendersThemeProvider/AppShell, whose React context cannot be created on the server. Marking only the page would leave the layout broken; marking only the layout does not make a child module a client module (the directive is per-module, not inherited). On the AI-error axis, a reader or agent copying one fence in isolation gets a correct file either way, which a single shared directive would not deliver. On long-term sanity, the prose states the underlying rule — every module underapp/is a server component by default — so the reader can generalise instead of pattern-matching a line. Scope stays flat: prose plus one line per fence, no new page section.Example 3: Embedded Widgetdeliberately does not get the directive: its fence declares noapp/file path and the directive is App-Router-specific. The explanatory sentence is scoped to Example 2 for the same reason.'use client'is just a string-expression statement to the TypeScript program — nothing incheck:doc-snippets(or any other gate) validates a React Server Components boundary. #8161's evidence is the grep re-derivation above plus thedistcensus, and that is the whole of it. Do not read this PR's green gates as coverage of the directive.Controls
Positive control for the doc gate, on the committed tree, with trap-based restore. Mutation proven on disk before any gate result was read; restore proven by blob hash and an empty
git diff HEAD:Breaking one member name in the repaired fence makes the gate go red naming
docs/ARCHITECTURE.md; unmodified, it is green in the same run. The repaired fence is genuinely load-bearing.Harness controls (printed by the gate itself on every run):
resolutionlands onpackages/types/dist/index.d.ts(a built artifact, not source);sentinelproduces TS2305;positiveproduces 0;undeclaredandroot-declaredeach produce TS2307.Gate totals — re-measured, and one number differs from the dispatch
The semantic total is 632, not the 631 the dispatch carried from the last landing — one block joined the corpus between that landing and today's
origin/main(411a132c0). It reads 632 identically before and after this change, so the difference is not this PR's: the corpus moved under the dispatch note, not under this diff. No regression either way; this PR replaces two fences with two fences, so the block count is flat at 790 (632 to compile, 158 declared fragments).Gates — every exit code by redirect, never through a pipe
pnpm check:doc-snippetspnpm check:doc-examplespnpm check:doc-fencesnode scripts/check-doc-links.mjspnpm check:doc-typestypeliterals, all registeredpnpm exec vitest run scripts/__tests__/pnpm lint:root--ignore-pattern 'docs/**', so it does not read the changed filepnpm check:control-bytesnode scripts/check-changeset-presence.mjsnode scripts/check-governed-queue-guard.mjs --test docs/ARCHITECTURE.mdThe build closure the doc gate prescribes (
--build-filter, 34 packages) was built first:turbo run build --concurrency=2, 35/35 tasks successful. Without it the gate exits 2 ("could not run"), which is not a verdict about any document.An independent control-byte self-scan over the changed file, beyond the gate:
grep -naP '[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]' docs/ARCHITECTURE.mdexits 1 with no output.Left draft deliberately.
docs/ARCHITECTURE.mdis not a governed surface (the guard says so above), so this is an ordinary PR on the normal route — the draft state is a seat convention here, not a governed-surface hold.Generated by Claude Code