Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

docs(architecture): teach the exported DataSource, and the App Router client boundary - #8358

Merged
baozhoutao merged 1 commit into
mainfrom
claude/issue-8160-architecture-md-datasource-and-use-client
Sep 7, 2026
Merged

baozhoutao merged 1 commit into
mainfrom
claude/issue-8160-architecture-md-datasource-and-use-client

Conversation

@claude

@claude claude Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

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.

Notation: quoted TypeScript diagnostics use square brackets where the compiler prints angle brackets (DataSource[any] for the generic instantiation). GitHub's body sanitizer eats short tag-shaped fragments, including inside backticks.

The two truths — what the page taught vs. what the tree exports

the page taught (before) the tree exports (packages/types/src/data.ts)
interface source a locally re-declared interface DataSource DataSource, exported by @object-ui/types
required members 5 (find, findOne, create, update, delete) 6 — the same five plus getObjectSchema
getMetadata declared, optional does not exist: grep -rn "getMetadata" packages/types/src/ returns nothing
getObjectSchema absent required, and the doc comment on it says so: "Required for all DataSource implementations to support schema-aware components."
the consuming prop — ObjectViewProps.dataSource: DataSource (packages/plugin-view/dist/ObjectView.d.ts:75) — required, and the real type
App Router fences no 'use client' anywhere on the page the packages ship no 'use client' banner either, so the consumer's file is the only place the boundary can be declared

Required-member census, re-derived rather than quoted:

$ sed -n '350,935p' packages/types/src/data.ts | grep -oE '^  [a-zA-Z]+\('
  find(          findOne(       create(
  update(        delete(        getObjectSchema(

Six. Every other member of DataSource carries ?.

Card #8160 — before / after, with the probe

The probe is the gate's own harness: compileSnippets() from scripts/check-doc-snippet-types.mjs, so the stand-in is judged against the built dist/*.d.ts exactly 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:

--- harness controls ---
resolution -> packages/types/dist/index.d.ts
sentinel   -> TS2305        (a planted missing export is still caught)
positive   -> 0 diagnostic(s)
--- probe result ---
parseFailures: 0  semanticallyJudged: 1
  TS2741: Property 'getObjectSchema' is missing in type 'DataSource' but required in type 'DataSource[any]'.

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:

--- probe result ---
parseFailures: 0  semanticallyJudged: 1
  ZERO DIAGNOSTICS

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 getMetadata back into the Pick:

[AS-PUBLISHED (getObjectSchema)]                       0 diagnostic(s)
[NEGATIVE CONTROL (the page's old 'getMetadata')]      2 diagnostic(s)
    TS2344: Type '... | "getMetadata"' does not satisfy the constraint 'keyof DataSource[any]'.
    TS2741: Property 'getObjectSchema' is missing in type 'M' but required in type 'DataSource[any]'.

So the Pick is not silently any: 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 methods elision in the example fence — the same shape #5174's batch 37 repaired in the root README with an ambient declare 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.

  • 实际业务需求 — measured, not assumed: the consuming prop is 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. A declare class teaches 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.
  • 项目长远合理性 — contract-first. The page had become a second declaration of a contract @object-ui/types already 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.
  • 防 AI 写代码犯错 — this is the axis that decided it. The elision was a hole an agent fills by guessing; a guessed member set is exactly the batch-error shape the axis names. The annotation converts the hole into a loud compile-time refusal: an incomplete adapter stops the block compiling, and check:doc-snippets fails naming this file. Contract tightening over consumer tolerance, and the declaration is enforced rather than merely written — no ??-style fallback anywhere near it. The ambient declare class scores nearly as well here, and loses only on the business-need axis above.
  • 创业阶段不扩散需求 — nothing is exported, no capability surface grows. MinimalDataSource is 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.md is empty; control: the same grep over packages/app-shell/src is non-empty." Re-run, with exit codes captured by redirect (never through a pipe — | head closes the read end and hands the producer a SIGPIPE-flavoured 0):

[CARD-ZERO   docs/ARCHITECTURE.md]     exit=1  lines=0
[DEAD-CONTROL packages/app-shell/src]  exit=1  lines=0     <-- fires identically to the subject
[LIVE-CONTROL apps/site/app]           exit=0  lines=8
[REPO-WIDE]                            exit=0  lines=75

packages/app-shell/src returns 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, including apps/site/app/components/InteractiveDemo.tsx and apps/site/app/playground/page.tsx; 75 files repo-wide. Against that control the zero on docs/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 in packages/app-shell/src but in the built output of every package these fences import:

packages/app-shell/dist    -> 0 file(s)
packages/providers/dist    -> 0 file(s)
packages/plugin-view/dist  -> 0 file(s)
packages/react/dist        -> 0 file(s)

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.tsx calls the useDataSource() hook, and app/layout.tsx renders ThemeProvider / 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 under app/ 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 Widget deliberately does not get the directive: its fence declares no app/ file path and the directive is App-Router-specific. The explanatory sentence is scoped to Example 2 for the same reason.

⚠️ The gate cannot check this half, and does not claim to. Each fence compiles as an isolated module, so 'use client' is just a string-expression statement to the TypeScript program — nothing in check:doc-snippets (or any other gate) validates a React Server Components boundary. #8161's evidence is the grep re-derivation above plus the dist census, 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:

HEAD blob:      304a349efe11c085e8ef7ff54f691ec50b0828be
ON-DISK MUTATION PROOF: old-anchor before=1 after=0 ; injected-text count=1
mutated blob:   9d0e755c906e824d3b334b488120862bcf739942   (differs from HEAD blob)

=== GATE ON MUTATED TREE ===   MUTATED_EXIT=1
  [semantic]  docs/ARCHITECTURE.md:287:3   TS2344: '"getObjectSchemaX"' is not assignable to type 'keyof DataSource[any]'. Did you mean '"getObjectSchema"'?
  [semantic]  docs/ARCHITECTURE.md:295:14  TS2741: Property 'getObjectSchema' is missing in type 'MinimalDataSource' but required in type 'DataSource[any]'.
  Semantic phase: 632 of 632 block(s) judged, 1 failed.

restored blob:  304a349efe11c085e8ef7ff54f691ec50b0828be   (equals HEAD blob)
git diff HEAD lines after restore: 0
still-injected count after restore: 0

=== GATE ON RESTORED TREE ===  RESTORED_EXIT=0
  Semantic phase: 632 of 632 block(s) judged, 0 failed.

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): resolution lands on packages/types/dist/index.d.ts (a built artifact, not source); sentinel produces TS2305; positive produces 0; undeclared and root-declared each produce TS2307.

Gate totals — re-measured, and one number differs from the dispatch

dispatch said measured, both before and after this change
documents / covered / ungated 229 / 229 / 0 229 / 229 / 0 — unchanged
whole-repo semantic phase 631 of 631 632 of 632, 0 failed

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

gate exit note
pnpm check:doc-snippets 0 229/229/0 documents; 632 of 632 blocks judged, 0 failed
pnpm check:doc-examples 0 124 blocks, 90 ledger-declared failures unchanged
pnpm check:doc-fences 0 227 documents
node scripts/check-doc-links.mjs 0 valid across 17 scan roots
pnpm check:doc-types 0 188 files, 890 type literals, all registered
pnpm exec vitest run scripts/__tests__/ 0 120 files, 3575 tests passed
pnpm lint:root 0 32 warnings, 0 errors, all pre-existing; note this script passes --ignore-pattern 'docs/**', so it does not read the changed file
pnpm check:control-bytes 0 6638 tracked text files
node scripts/check-changeset-presence.mjs 0 no changeset owed — 1 file changed, 0 of it published source of a released package
node scripts/check-governed-queue-guard.mjs --test docs/ARCHITECTURE.md 0 NOT GOVERNED — none of the 5 governed surfaces matched

The 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.md exits 1 with no output.


Left draft deliberately. docs/ARCHITECTURE.md is 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

… 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
@claude

claude Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

ACCEPT (#8160 + #8161, one PR by triage's routing) — reviewed on the tree at head 4a5ff64ef against origin/main 37149ec4f, read 2026-09-07T14:39Z; domain:devx @ objectui seat, PM session session_01FhBNJcLRZLe8M87VcUgpKr. Merges clean. One file, +66/−17.

#8160 — verified from the diff and the tree:

  • The page no longer declares its own interface. It imports the exported DataSource and teaches the six required members through a Pick, then proves the six SUFFICE with export const adapter: DataSource = minimal — a line that goes red the moment a seventh member becomes required. That is route 甲, and route 乙 stayed unneeded because a self-consistent minimal subset exists.
  • Confirmed independently: getMetadata occurs in zero files under packages/types/src, so the method the page used to teach as optional is not on the interface at all; ObjectViewProps.dataSource is DataSource, required (ObjectView.tsx:268).
  • The Pick is load-bearing, not silently any: putting getMetadata back yields TS2344 plus TS2741, while the published spelling yields zero.
  • The elision is gone by ANNOTATION rather than an ambient class, and the reasoning holds: an annotated literal is copy-paste-able where a declare class hands the reader nothing runnable, and a hand-written members table would have re-created the drift hazard this very card is about. The page now restates no signature anywhere.

#8161 — verified separately, as its own criterion:

  • Both fences of Example 2 carry 'use client', each for an independent reason (the page calls a hook, the layout renders context providers), with one prose paragraph above the pair teaching the rule rather than the line. Example 3 correctly does not get it — it declares no app/ path.
  • The dead control is confirmed dead and its cause found: use client is zero in packages/app-shell/src because the packages carry no banner in source at all. The re-derivation uses a control that fires (apps/site/app, 8 files; 75 repo-wide).
  • The PR states plainly that 'use client' is uncheckable by any gate, rather than implying coverage. Correct: each fence compiles as an isolated module.

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: pnpm lint:root passes --ignore-pattern 'docs/**', so its green is not coverage of this diff. Positive control on the committed tree reds naming docs/ARCHITECTURE.md and is green unmodified in the same run, with the restore proven by blob hash.

The observation handed back — that no @object-ui/* package ships a 'use client' banner, which is why the card's control was dead and is a real constraint on every App Router consumer — is this seat's to file, and it is filed as a finding in the next stroke.

Next: CI convergence → flip ready → post-flip guard → auto-merge SQUASH → queue confirmation → landing probe (the imported DataSource, the Pick, and both 'use client' lines on re-fetched origin/main; control: getMetadata absent from the page) → LANDED here and on both cards, which close via their two Fixes lines.


Generated by Claude Code

@claude

claude Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Armed: PR #8358 flipped ready at 2026-09-07T14:40:51Z on head 4a5ff64ef after CI converged all green (28 checks, read 14:40:37Z); post-flip Governed Surface Queue Guard completed/success at 14:41:06Z; auto-merge SQUASH enabled; queued (timestamp in the REST timeline). Landing stroke on merge: probe on re-fetched origin/main — the imported DataSource, the Pick of the six required members, and 'use client' in both Example 2 fences; control: getMetadata absent from the page — then LANDED here and on #8160 and #8161, which close via their two Fixes lines. — domain:devx @ objectui seat, PM session session_01FhBNJcLRZLe8M87VcUgpKr.


Generated by Claude Code

Merged via the queue into main with commit 04597f3 Sep 7, 2026
30 checks passed
@baozhoutao
baozhoutao deleted the claude/issue-8160-architecture-md-datasource-and-use-client branch September 7, 2026 14:57
@claude

claude Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

LANDED: merged at 2026-09-07T14:57:31Z as 04597f3a5 (squash — one parent, via the merge queue). Content probe on re-fetched origin/main (read 14:57Z): import type { DataSource } from '@object-ui/types' present twice (the interface block and the example implementation), the Pick of the six required members present, 'use client' present 4 times (two directives plus the two prose mentions). Merge commit is an ancestor of origin/main. Both #8160 and #8161 closed via their Fixes lines.

One control correction, because the reading matters more than the expectation. The Armed note said the probe's control would be getMetadata ABSENT from the page (expected 0). It reads 1, and the single occurrence is line 284 — inside the explanatory comment on the Pick: "a member name that is not on the exported interface — getMetadata, say — fails this Pick rather than being read past." So the name survives deliberately, as the counter-example that teaches why the Pick is load-bearing, and the defect it used to name (a method the page taught as part of the interface) is gone. The control expectation was mine and it was wrong; the landing is correct. Recorded rather than quietly re-scored. — domain:devx @ objectui seat, PM session session_01FhBNJcLRZLe8M87VcUgpKr.


Generated by Claude Code

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.