Skip to content

GO-7383 Make schema and validation prose caller-facing - #12

Merged
requilence merged 1 commit into
mainfrom
go-7383-concise-user-prose
Sep 16, 2026
Merged

requilence merged 1 commit into
mainfrom
go-7383-concise-user-prose

Conversation

@requilence

Copy link
Copy Markdown
Contributor

What

The JSON Schema description values and the validation messages are what an API caller — and an LLM authoring a document — actually read. They had grown into essays citing internal spec paragraphs (§6.2), corpus statistics ("1,760 corpus type documents"), constraint codes (C13), and Go symbols the caller cannot reach.

None of it is actionable outside this repository, and callers pay for all of it in tokens on every schema fetch.

223 descriptions rewritten across the six published schemas: 93,920 → 35,757 characters (61% smaller).

Rationale worth keeping moved into Go comments — visible to readers of this repo, free for callers.

Also

readerFor() is gone from the codec's document-kind surface. Its verdicts named UnmarshalPropertyDictionary and friends, so a caller who sent the wrong shape was told to call a Go function they have no access to.

Guards

Compression is where a true statement quietly becomes false, so two tests hold the line:

  • format/v2/schema/prose_test.go — bounds every description (200 chars; 600 at a schema root; 800 for named grammar slots, keyed by <file>::<pointer>) and rejects section marks, SPEC references, constraint codes, .md filenames, corpus evidence and em dashes.
  • internal/prose/userfacing_test.go — the same rules over Go string literals via go/ast, so a validation message cannot reintroduce what a description gave up. Comments are exempt by design; moving a citation out of a served string and into the comment above it is the intended fix.

Five existing tests asserted on the old prose (one required the literal text §6.2); they encode the new contract now.

Verification

go build ./..., go test ./... and gofmt -l are clean.

The compression was reviewed by three independent adversarial passes over before/after pairs, which caught ~20 statements that the rewrite had made false — e.g. a description promising raw numbers on two enum-only slots, and a dataview rule inverted for type documents. Those were corrected before this commit.

Note for the reviewer

anytype-heart depends on this. Its matching branch currently pins replace github.com/anyproto/any-block => ../any-block_prose, so this needs to merge first and the pin be swapped for a real version before that side can land.

The JSON Schema descriptions and the validation messages are what an API
caller and an LLM authoring a document actually read. They had grown into
essays that cited internal spec paragraphs, quoted corpus statistics, and
named Go symbols the caller has no access to — none of which a reader
outside this repository can act on, and all of which they pay for in
tokens on every schema fetch.

Rewrite 223 descriptions across the six published schemas: 93,920 -> 35,757
characters, 61% smaller. Rationale that is worth keeping moves into Go
comments, which readers of this repository can see and callers do not pay
for.

Also drop readerFor() from the codec's document-kind surface: its verdicts
named UnmarshalPropertyDictionary and friends, so a caller who sent the
wrong shape was told to call a Go function they cannot reach.

Two guards keep it that way, because compression is where a true statement
becomes false:

- format/v2/schema/prose_test.go bounds every description (200 chars, 600
  at a schema root, 800 for named grammar slots) and rejects section marks,
  SPEC references, constraint codes, .md filenames, corpus evidence and
  em dashes.
- internal/prose/userfacing_test.go applies the same rules to Go string
  literals via go/ast, so a message cannot reintroduce what a description
  gave up. Comments are exempt by design.

Five tests asserted on the old prose and encode the new contract instead.
@requilence
requilence merged commit e108b5e into main Sep 16, 2026
2 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant