feat(docs): make guide regeneration reproducible#370
Open
Tim Beyer (TimBeyer) wants to merge 12 commits into
Open
feat(docs): make guide regeneration reproducible#370Tim Beyer (TimBeyer) wants to merge 12 commits into
Tim Beyer (TimBeyer) wants to merge 12 commits into
Conversation
The docs pipeline (source→KB→recipes/fragments→guides) assumed the knowledge base + recipes were a sufficient upstream to reproduce a guide from scratch. A controlled experiment disproved it: composing the Node and React Web guides from scratch with the existing guides withheld reached only ~75–80% fidelity and diverged structurally (Node 14→10 sections, 3 category moves; React Web collapsed 5 Required render sections to 3). Two gaps, neither "the KB is thin": - The per-SDK editorial mapping (which facts become which section, in what order, under which Required/Common/Optional/Advanced category, the quick-start proof, the milestone split) lived only inside finished guides and was re-invented — and drifted — on every compose. - A few behavioral facts the KB never captured, forcing the writer to read source for behavior it is contractually barred from tracing. Fix: a fourth artifact, the per-SDK blueprint (documentation/authoring/ blueprints/<sdk>.md). It memoizes editorial judgment the way the KB memoizes comprehension. Prose, not a DSL (the consumer is the guide-writer LLM; the value is the reasoning). Clean three-way ownership: recipe = SDK-neutral archetype shape, blueprint = per-SDK arrangement, KB = facts. - Blueprints for all six KB-backed SDKs (node, web, react-web, both Next.js, react-native); section counts match each guide exactly. - KB enrichment for the behavioral holes: pre-consent resolution chain, preview-panel package specifier, resolveOptimizedEntry mutation contract, page.* ownership, SSR cache boundary, ellipsis expansions. - Wired the blueprint into the guide-writer agent and all four commands (author/refresh/iterate/review); trimmed the integration recipe to the three-way split; updated CONTRIBUTING + authoring/KB READMEs. Verified: re-running the Node from-scratch reproduction with the blueprint + enriched KB matched the original 14/14 sections, 0 category moves, 0 dropped, ~93–95% fidelity, no behavioral source-tracing. pnpm knowledge:check passes (685 pointers, 8 fact files). Scoped-out follow-up (documented, not fixed): native iOS/Android guides have no KB file/blueprint/feeds-guides edge — Swift/Kotlin needs a different symbol-resolution strategy. Decision + supplemental guides also lack KB edges. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Each per-SDK blueprint opened with ~20 lines of identical boilerplate re-explaining what a blueprint is, what it owns, and what it does not — six files defining themselves rather than doing their job. That obscured the real question the boilerplate never answered clearly: how a blueprint differs from a recipe. Move the definition to one canonical place, mirroring how the knowledge base already works (_template.md + README define the artifact; per-SDK files carry only a one-line disclaimer + payload): - Add blueprints/_template.md — the skeleton plus the recipe/blueprint/KB split stated ONCE, with the operative test "if I change this, how many guides move?" (all → recipe, one → blueprint, an SDK fact → knowledge base). - Strip the repeated ## Context from all six blueprints; each now starts at ## What proves it works with a one-line lead pointing at _template.md. Net -159/+23. App Router keeps its SDK-specific server/client-boundary note. - README: blueprint section now points at _template.md instead of re-listing the headings; Files tree lists _template.md. Recipe vs. blueprint, made explicit: the recipe is the SDK-neutral archetype shape shared by every integration guide (edit it → all guides move); the blueprint is one SDK's filled-in arrangement of its facts into that shape (edit it → one guide moves). Template and filled-in copy, exactly like the KB's _template.md and its per-SDK files. pnpm knowledge:check passes; format:check clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
98284f3 to
5838c8b
Compare
|
|
||
| You are the docs writer for the Optimization SDK Suite. Author or revise the requested guide under | ||
| `documentation/guides/`. You compose from two source-of-truth layers: | ||
| `documentation/guides/`. You compose from three source-of-truth layers: |
Collaborator
There was a problem hiding this comment.
Nobody expects the Spanish inquisition!
Collaborator
|
Can I assume there's no model-agnostic way to handle some of these concerns? I'm also wondering what authoring or updating a guide looks like from a contributor's perspective, how we'd tell the agent to do the thing, etc. |
Collaborator
Author
|
What exactly do you mean with "model-agnostic"? |
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a complete authoring system for Optimization SDK integration guides.
The system makes the costly part of documentation work reusable: SDK behavior is derived from the implementation once, recorded with source pointers, and then consumed by writers and reviewers. It also captures the SDK-specific editorial decisions that previously existed only in finished guides, so a new guide does not need an expert to reconstruct the reader journey from scratch.
The merged result is deliberately human-facing. Technical writers can shape the teaching sequence and required outcomes in ordinary Markdown. Agents help draft and verify the guide, but do not own the editorial contract or certify their own work.
Why
The existing SDK knowledge base answers behavioral questions, and the guide recipes describe shared guide patterns. That still left an important gap: neither artifact said how one SDK's facts should become a complete reader journey—what to teach, in which order, with which proof, and at what depth.
Historically, those decisions were embedded in the accepted guide itself. That worked for maintenance, but made genuinely new guides hard to reproduce without an SDK expert or an existing document to imitate.
This PR adds the missing editorial layer and connects it to the existing knowledge, authoring, and review workflows.
What this PR merges
A four-part authoring model
Interface details remain cheap and self-verifying: writers and technical reviewers may inspect the current public types in
packages/**/src. Behavioral claims come from the verified SDK knowledge base instead of being re-traced through the implementation for every guide.Six SDK blueprints are included, plus a canonical blueprint template. Every blueprint uses the same human-readable schema:
Together, the six blueprints define 88 planned guide sections.
The authoring workflow
For normal guide maintenance:
For a genuinely new guide, the same inputs provide the initial structure and technical foundation. New guides should expect a deeper drafting and review loop because no accepted reader experience exists yet.
The three authoring roles have distinct authority:
If a behavioral claim cannot be supported by the knowledge base, it is escalated to knowledge authoring instead of being guessed or re-derived ad hoc.
Validation and tooling
This PR adds
pnpm guides:check, backed byscripts/validate-guide-authoring.ts. It validates:The existing knowledge validator is extended alongside the new authoring model. CI now runs the guide validator as part of the documentation integrity checks.
Contributor guidance, the guide authoring skill, Claude agents and commands, and project-scoped Codex agents all use the same workflow. The Codex setup includes dedicated writer, newcomer-reviewer, technical-verifier, and knowledge-author roles, plus an advisory hook that runs the relevant validators when documentation-system files change.
Guide and knowledge alignment
The integration recipe, shared copy, existing SDK guides, and relevant knowledge files are aligned with the new contracts. Missing behavioral facts discovered during the work were added to the knowledge base with source pointers.
The accepted guides remain the publication baseline. Generated experiment drafts are not merged as replacements.
What this means for contributors
Reproducibility means reaching the same excellent, performable reader outcome—not reproducing identical prose.
Validation
pnpm guides:checkpnpm knowledge:checkESCALATEmarkerspnpm exec eslint scripts/validate-guide-authoring.tspnpm format:checkgit diff --checkImplementation history: how we got here
This section records the experiments and intermediate designs that informed the merged system. It is not a description of additional machinery being merged.
1. Identify the missing layer
Initial clean-room exercises withheld existing guide prose and attempted to compose Node and React Web guides from the knowledge base, recipes, and shared copy. They recovered much of the content but lost SDK-specific structure, category choices, proof points, and depth.
That showed the knowledge base was not the main gap. The missing information was editorial: how verified facts become one SDK's reader journey. Blueprints were introduced to capture that judgment separately from both facts and final prose.
After adding the first blueprints and filling genuine knowledge gaps, clean-room drafts converged much more closely on the expected section inventory and ordering.
2. Test whether stricter evidence bookkeeping improved depth
The next iterations tried to make blueprint obligations mechanically auditable with Evidence IDs, evidence atoms, coverage ledgers, and writer-produced receipts.
Fast/mini and Luna clean-room runs still produced shallow or technically incorrect guides. More importantly, writers could claim that an obligation was covered even when the procedure or example was incomplete. The receipts added apparent certainty without becoming an independent source of truth.
That experiment established that the writer cannot also be the acceptance authority. Independent newcomer and technical reviews provide the meaningful quality gate.
3. Return the authoring inputs to human language
The final iteration removed the Evidence-ID and receipt machinery and reduced blueprints to compact technical-writer briefs using Purpose, Must teach or show, and Fact sources.
A final isolated Terra run generated the Next.js App Router guide without access to the accepted guide, sibling guide prose, prior drafts,
dist, or.rslib. It could use current package source for interfaces, the SDK knowledge base for behavior, the authoring inputs, concepts, and the reference implementation.The result was a coherent 4,551-word draft covering all 15 planned sections, and the fixture validator passed. Independent review still found publish-blocking gaps and code errors, including an incomplete managed-fetching handoff, non-performable live-update verification, invalid analytics and Custom Flag examples, and incorrect preview readiness handling.
Those obligations and facts were already present in the maintained inputs. No missing behavioral knowledge fact was identified in the final run. Adding more model-specific prompt clauses would therefore have increased complexity without addressing the failure mode.
Resulting decisions
The implementation history led to the final boundaries used by this PR: