DOC-6939 Add schema_version and since to the AI outputs - #3764
Merged
Conversation
Two fields the applied AI team asked for, both now agreed. schema_version is their candidate improvement 1 and since is their observation 01, which they called their only hard blocker: they could not move to the feed without losing version filtering, because the Markdown metadata block carried since for command pages and the JSON did not. schema_version is a single integer, emitted in every per-page JSON record and in the Markdown metadata block, currently 1. It lives in one place, aiSchemaVersion in config.toml, so there is one thing to bump rather than four templates to keep in step. The semantics are the part that makes it useful, and they are the team's own definition: it increments only when the shape of a record changes -- a field added, removed or renamed, or a new value entering the role vocabulary -- and never when content changes. A version that moved with content would be a second content hash, and they were explicit that they would learn to ignore it. That distinction is written into both the config comment and the published documentation, because the field is worthless without it. Worth noting what does NOT bump it, since the temptation will be there: changing what a field contains is not a shape change. The page id changing from a filename to a path is a value change, so version 1 covers both. since comes straight from the command pages' frontmatter, present on 574 pages and absent elsewhere, matching what the Markdown metadata block already published. Section pages do not gain a spurious empty field. The transform declares both fields on its input and output interfaces rather than letting them ride through on a spread. They were already surviving, because the spread carries unknown keys at runtime, but nothing said so -- and a future refactor that replaced the spread with explicit field copying would have dropped the one field consumers gate their parsing on, silently. Verified on a full build and transform: schema_version is 1 on all 5,733 records and in the Markdown metadata block, since appears on exactly 574 records against 574 source files declaring it, and content_hash still verifies for all 5,687 content pages. Constraint: aiSchemaVersion in config.toml must increment only for a change to the record's shape -- a field added, removed or renamed, or a new role value -- and never for a content change or a change to what an existing field contains, or consumers stop trusting it and gate on content_hash alone Constraint: schema_version and since are declared on both interfaces in build/transform_json_sections.ts so they survive deliberately rather than incidentally -- the spread would carry them either way today, but replacing it with explicit copying would drop them without failing Ticket: DOC-6939 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
Contributor
🧠 Redis MemoryFound 5 related items from repository history:
Memory updated at c1cace7 |
Contributor
Contributor
Author
|
Thanks @dwdougherty ! |
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.
Adds
schema_versionandsinceto the AI-facing JSON and Markdown outputs — items C1 and C3 of DOC-6939. Both were agreed with the applied AI team rather than assumed.C3 —
sincewas their only hard blockerTheir observation 01: the Markdown metadata block carries
sincefor command pages, the JSON does not, so a consumer indexing or filtering on version information could not move to the feed without dropping that filter.It now appears in the JSON, straight from the command pages' frontmatter — on 574 records, matching exactly the 574 source files that declare it. Section pages don't gain a spurious empty field.
C1 —
schema_version, with the semantics that make it usefulA single integer, in every per-page JSON record and in the Markdown metadata block, currently 1. It lives in one place —
aiSchemaVersioninconfig.toml— so there's one value to bump rather than four templates to keep in step.The semantics are their own definition, and they're the point of the field:
rolevocabulary.content_hashfor content,schema_versionfor "your parser may need attention".That distinction is written into both the config comment and the published docs, because the field is worthless without it.
Worth stating what does not bump it, since the temptation will be there: changing what a field contains is not a shape change. The page
idgoing from a filename to a path (#3761) is a value change, so version 1 covers both that and this.Verification
Built and transformed the combined state, since #3761 landed first and the two had never been built together:
schema_version1on all 5,733, and in the Markdown metadata blocksincecontent_hashverifiescommands/setcomes out asid='commands/set',schema_version=1,since='1.0.0'.One thing hardened beyond the ask
The transform now declares both fields on its input and output interfaces. They were already surviving, because the object spread carries unknown keys at runtime — but nothing said so, and a future refactor replacing the spread with explicit field copying would have silently dropped the one field consumers gate their parsing on. Declaring them makes the survival deliberate rather than incidental.
What a reviewer should focus on
schema_versionis a contract-shaped field. Once published, consumers will gate behaviour on it, so the discipline about when it increments matters more than the field itself. TheConstrainttrailer and the config comment both state it.Not in this PR
C4 (redirect map), C5 (splitting interface-only metadata from semantic metadata) and C6 (a machine-readable marker on the code-examples legend) are still open, as is the decision on D5 — versioned pages serving an untransformed schema at the documented URL shape.
🤖 Generated with Claude Code
Note
Low Risk
Additive feed fields and documentation with no auth or runtime behavior changes; consumers must treat schema_version as a parser contract.
Overview
Adds
schema_versionandsinceto the AI-facing per-page JSON feed and Markdown metadata, driven by a singleaiSchemaVersionparam inconfig.toml(currently 1).schema_versionis documented as a shape-only contract: bump it when fields or role vocabulary change, not when page content changes (usecontent_hashfor that). It is emitted from all four Hugo templates (single/section× JSON/Markdown).sinceis added to JSON output when front matter defines it (command pages), matching what Markdown metadata already exposed, and omitted elsewhere so non-command records do not get an empty field.Published AI Agent Resources docs gain a schema-version section and table rows for both fields. The NDJSON transform types in
transform_json_sections.tsnow declareschema_versionandsinceon input/output so they survive explicit refactors, not only object spread.Reviewed by Cursor Bugbot for commit c1cace7. Bugbot is set up for automated code reviews on this repo. Configure here.