Skip to content

refactor(apijson): split the api-json differential baseline into per-file fragments on a shared tools/referee/baseline store - #2084

Merged
HuiJun merged 26 commits into
developfrom
refactor/apijson-baseline-fragments
Nov 11, 2026
Merged

HuiJun merged 26 commits into
developfrom
refactor/apijson-baseline-fragments

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Every PR that touches internal/translate/export (or the metamodel it serializes) re-recorded the whole 1.3 MB docs/project/api-json-differential-baseline.json, so two such PRs in flight always conflicted in one generated file. This PR replaces it with a directory of per-source-file fragments, built on a new shared mechanism so the other referee baselines can follow (one PR each).

tools/referee/baseline (new, shared)

A generic fragment-directory store, documented in doc.go:

  • <dir>/<root>/<relative path>.json — one fragment per compared source file, carrying that file's own summary S and its rows map[string]R, rows written one per line in key order; fragments sorted by root then file; invalid paths (empty, absolute, .., a root containing /) and duplicate identities refused.
  • <dir>/index.json — the one shared file: the run's provenance (oracle.Record), the list of recorded files per root, and the aggregate A, which must be a fold of the fragments.
  • Write / Rewrite (re-record all roots, or only the named roots and re-fold the index; with nothing replaced it rebuilds the index alone), Read (every listed fragment present and filed under its own root/file, no unlisted .json), Check / CheckRoots (provenance, then missing/orphaned fragments, moved/added/removed rows and moved per-file summaries, then stale index figures — with a -reindex hint when only the index is stale), Verify (the Java-free half: the committed directory against itself).
  • Row type, per-file summary, aggregate and the adjudication/ratchet policy stay with each referee.

api-json migrated onto it

  • docs/project/api-json-differential-baseline.json → docs/project/api-json-differential/ (935 fragments in 9 roots + index.json). Rows are the same Metaclass.property scorecard rows, now recorded per source file as a 7-bucket count vector (presentEqual, presentDifferent, oursMissing, pilotMissing, absentBoth, indeterminate, pilotNondeterministic); the global scorecard, the per-root reports and every total are folds over them.
  • Attribution: a matched pair is filed under the file our writer declares the element in (the pilot writes an element into every file whose traversal reaches it); a pilot-only element under the pilot's file; each side's diagnostics (refusals, duplicates, ambiguous keys, unkeyable elements, library elements) under its own file. Ownerless trees our writer leaves without a sysx:sourceDocument (notes, unowned expressions) are filed with the element outside the tree that refers into it; fragmentsOf refuses any account filed under a file the root does not hold, and sameFigures holds the run's directly summed totals to the fold of the fragments before anything is written or checked, so no figure can leave the fragments and still enter the totals.
  • pilot-apijson-diff: -update records all roots; -update -roots a,b re-records only those roots and re-folds the index; -reindex rebuilds index.json from the committed fragments without the pilot (how an index.json both branches moved is resolved after their fragments merge); -check holds the whole tree, -check -roots a,b the named roots plus the committed rest.
  • Readers moved to the fragments: the provenance guard (TestCommittedBaselineStatesThisRepositorysProvenance), doc_counts_test.go / make docs-counts, the hygiene workflow test, scripts/ci-changed-areas.sh (+ its test), mkdocs.yml (exclude_docs). New Java-free tests: TestCommittedIndexSumsItsFragments, TestProbeFragmentCarriesTheWholeComparison, TestFragmentsRefuseAnAccountOutsideTheRootsFiles, TestKeyOursFilesOwnerlessTreesWithTheirReferrer.
  • Docs: docs/project/api-json-differential.md (layout, attribution, -update/-reindex/-check, conflict resolution, why index.json and the prose figures stay shared), AGENTS.md §6.2, changelog fragment.

Files that remain shared, and why

  • docs/project/api-json-differential/index.json — provenance (pilot pin, corpus digests, library input) and the aggregate figures are whole-corpus facts. Two branches that both move a verdict still meet here, but the conflict is mechanical: take either side, let the fragments merge, run -reindex (no Java) and commit.
  • docs/project/api-json-differential.md — states the aggregate figures and the ranked gaps; make docs-counts regenerates them from the index.

How it was verified

Coverage proof

Round trip (develop monolith vs this branch's fragments, -update on the same inputs):

  • The fresh build/pilot-apijson-diff/pilot-apijson-diff.json report is byte-identical to the one produced by develop's tool on the same tree (cmp clean).
  • Index provenance == monolith provenance; index totals/roots/exporter/normalizations/nondeterminism == monolith's; 935 listed fragments == 935 counted files; folded fragment rows (11,771 Metaclass.property rows × 7 buckets) == monolith scorecard; per-root element/property/diagnostic sums == monolith roots; 56/56 checks equal.
  • TestCommittedIndexSumsItsFragments re-proves the fold on every run, without Java.

Mutations — each run as go run -C tools ./cmd/pilot-apijson-diff -check -roots probes on a mutated docs/project/api-json-differential/, baseline restored intact afterwards (control runs exit 0 before and after):

  • moved row (one present-equal -> present-different)
pilot-apijson-diff: docs/project/api-json-differential does not reproduce (implementation movement: adjudicate each line in the referee's record, then re-record with go run -C tools ./cmd/pilot-apijson-diff -update):
  docs/project/api-json-differential/probes/alias-supertype-lru.sysml.json: row Feature.aliasIds moved: [-1,1,0,0,4,0,0] -> [0,0,0,0,4,0,0]
exit status 1
exit 1
  • added row
pilot-apijson-diff: docs/project/api-json-differential does not reproduce (implementation movement: adjudicate each line in the referee's record, then re-record with go run -C tools ./cmd/pilot-apijson-diff -update):
  docs/project/api-json-differential/probes/alias-supertype-lru.sysml.json: row Zzz.added removed: was [1,0,0,0,0,0,0]
exit status 1
exit 1
  • removed row
pilot-apijson-diff: docs/project/api-json-differential does not reproduce (implementation movement: adjudicate each line in the referee's record, then re-record with go run -C tools ./cmd/pilot-apijson-diff -update):
  docs/project/api-json-differential/probes/alias-supertype-lru.sysml.json: row Feature.aliasIds added: [0,0,0,0,4,0,0]
exit status 1
exit 1
  • missing fragment (probes/alias-supertype-lru.sysml.json deleted, still indexed)
pilot-apijson-diff: read docs/project/api-json-differential/probes/alias-supertype-lru.sysml.json: open docs/project/api-json-differential/probes/alias-supertype-lru.sysml.json: no such file or directory
exit status 1
exit 1
  • orphan fragment (probes/stray.sysml.json, not indexed)
pilot-apijson-diff: docs/project/api-json-differential/probes/stray.sysml.json is not listed in docs/project/api-json-differential/index.json: a fragment of a file the baseline no longer compares; remove it or re-record
exit status 1
exit 1
  • stale index figure (totals.files + 1)
pilot-apijson-diff: docs/project/api-json-differential does not reproduce (every fragment reproduces and only the index figures are stale: rebuild them with go run -C tools ./cmd/pilot-apijson-diff -reindex):
  docs/project/api-json-differential/index.json: summary.totals.files: 936 -> 935
exit status 1
exit 1
  • stale provenance (pilotTag)
pilot-apijson-diff: docs/project/api-json-differential/index.json no longer describes this repository:
  provenance.pilotTag: baseline records "2025-01", repository now has "2026-09"
    the repository's pilot pin has moved since this baseline was recorded: re-run the oracle against the new pin
exit status 1
exit 1
  • index lists a file no longer in the corpus (probes/ghost.sysml)
pilot-apijson-diff: read docs/project/api-json-differential/probes/ghost.sysml.json: open docs/project/api-json-differential/probes/ghost.sysml.json: no such file or directory
exit status 1
exit 1
exit 0

Local gate

Head 7a3affd = the split commits merged with develop @ daad0ae (through the go1.27.4 toolchain bump branch of #2126, 6814329, which contains it) (git merge --no-ff after each develop move: ddc4a54 → c010f23 → ade067f → bd58fde → c4f55e0 → 11bf2f6 → cd95e32 → 67efcea → 6f9622b → 1b94d85 → 6ff0288 → 1362cf6 → 98d8eca → daad0ae). The only conflicting file on each move was the deleted monolith docs/project/api-json-differential-baseline.json (modify/delete: develop re-recorded it, this branch removes it) — resolved by keeping the deletion and re-recording the fragments by tool on the merged tree, never by hand. make stdlib-snapshot unchanged.

Fragment movement, by tool (pilot-apijson-diff -update on each merged tree; the fold of the fragments equals develop's monolith on the same tree every time):

All corpus OPENSYSML_REQUIRE_* variables set:

gate result
go build ./... clean
go vet ./..., go vet -C tools ./... clean
gofmt -l . empty
make lint "Lint passed"
make changelog-check ok
go run -C tools ./cmd/derived-census -check ok
go run -C tools ./cmd/pilot-apijson-diff -check (this head, full, with the pilot) ok — 935 files, figures above reproduce
make docs-counts "Documentation counts and refereed figures are current"
go test -count=1 ./... 134 packages ok, 0 FAIL (with every corpus require variable)
go test -C tools ./... all ok (incl. referee/baseline, referee/apijson)
go test -count=1 ./tests/hygiene ok
python3 scripts/check-doc-ids.py clean
bash scripts/ci-changed-areas-test.sh all cases passed
.agents/skills/reviewing-pull-requests self-review against REVIEW.md 1 finding (the .gitattributes line above), fixed
Devin Review on f8da7ae 4 findings: 3 fixed (9b0a0dd), 1 dismissed (package doc.go)

Sibling baselines (report only, unchanged here)

  • docs/project/pilot-differential-baseline.json (1.0 MB): provenance + totals + roots[], each root holding files[] with one per-source-file verdict record (path, agreement, severityMismatch, openSysMLOnly, pilotOnly), plus a shared unmapped[] (1,334 entries) and errata. Same shape as api-json — per-file rows under corpus roots with whole-corpus provenance/totals — so it maps directly onto tools/referee/baseline (fragment = one file's verdict record; index.json = provenance, totals, unmapped, errata) and would benefit: it is re-recorded by the same export/metamodel PRs and conflicts the same way.
  • internal/semantic/metamodel/derived_census_baseline.json (849 KB): provenance, summary, totals (297 derived properties), silent[], structure digest and roots[] — but each root is a per-root record (file/element counts and a rules map of 290 derived-property verdicts for the whole root), with no per-file breakdown. It is per-root/per-rule, not per-source-file in nature: the mechanism fits only at root granularity (one fragment per corpus root, index.json = provenance/totals/silent/structure), which would still separate two PRs that move different roots but not two that move the same root. Splitting it per file would need the census itself to account per file first — report only, left as is here.

Checklist

  • make test and make lint pass locally
  • Tests added or updated for the change
  • Documentation extended where it already covers the surface
  • Changelog entry added as changes/unreleased/api-json-baseline-fragments.changed.md
  • baselines regenerated and make docs-counts run (no gate count moved; the baseline changed shape, not figures)
  • No internal work-item labels in the body, docs, or changelog

Link to Devin session: https://nasa-jpl-demo.devinenterprise.com/sessions/cd6e9286509a4dbf82d4bee0d9cd7aa7
Open in Devin Desktop: https://nasa-jpl-demo.devinenterprise.com/desktop/session/cd6e9286509a4dbf82d4bee0d9cd7aa7?variant=devin
Requested by: @HuiJun


Devin Review

devin-ai-integration Bot and others added 2 commits November 10, 2026 00:16
…aseline store

A referee baseline kept as one generated file conflicts on every merge of two
branches that re-record it. This package lays a baseline out as a directory:
one JSON fragment per compared source file (<root>/<relative path>.json, the
file's summary and its rows in key order) beside an index.json carrying the
provenance and the aggregate figures, which must be a fold of the fragments.
Write/Rewrite record all or the named roots, Read refuses a missing or
unlisted fragment, Check/CheckRoots name every moved, added or removed row,
missing or orphaned fragment and stale index figure or provenance line, and
Verify holds a committed directory to itself without the reference toolchain.
Row, summary and aggregate types and the ratchet policy stay with each referee.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
…file fragments

docs/project/api-json-differential-baseline.json (1.3 MB, re-recorded whole by
every change under internal/translate/export) becomes the directory
docs/project/api-json-differential/ on tools/referee/baseline: one fragment per
compared source file holding the file's summary and its Metaclass.property rows
as seven-bucket count vectors, and an index.json with the provenance and the
aggregate figures, each a fold over the fragments. The fold reproduces the
monolith exactly: same provenance, same 935 files, same 11,771 scorecard rows
and every total and per-root figure, and the fresh report is byte-identical.

The comparison now accounts per source file: a matched pair under the file our
writer declares the element in, a pilot-only element under the pilot's file,
each side's diagnostics under its own, an ownerless tree without a document
under the file of the element that refers into it; fragmentsOf refuses an
account outside the root's files and sameFigures holds the direct totals to
the fold. pilot-apijson-diff gains -update -roots (re-record named roots and
refold the index), -reindex (rebuild index.json from the committed fragments,
no pilot) and -check -roots; the provenance guard, doc-counts, the hygiene
workflow test, ci-changed-areas and mkdocs read the directory.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

devin-ai-integration Bot and others added 21 commits November 10, 2026 00:36
…aseline-fragments

Co-Authored-By: jason.han <hanhuijun@gmail.com>

# Conflicts:
#	docs/project/api-json-differential-baseline.json
Carries develop's Documentation.documentedElement movement (387 properties
oursMissing -> presentEqual across 108 files) into the per-file fragments
and the index; the fold equals develop's monolithic baseline.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
…aseline-fragments

Co-Authored-By: jason.han <hanhuijun@gmail.com>

# Conflicts:
#	docs/project/api-json-differential-baseline.json
Re-recorded with pilot-apijson-diff -update on the merged tree. 66 fragments
and index.json move; the folded totals equal develop's monolith at 67efcea
(104,420 matched, 2,024,875 present-equal, 143,814 present-different,
305,457 ours-missing, 80,960 pilot-missing, 2,220,557 absent-both,
35,136 indeterminate, 534 pilot-nondeterministic). Movement comes from
#1936: TransitionUsage.output, EventOccurrenceUsage/AcceptActionUsage/
SendActionUsage/TerminateActionUsage inherited features and inputs, and
six newly matched elements.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
Re-recorded with pilot-apijson-diff -update on the merged tree. Only the six
examples/self-model fragments and index.json move (1,278 rows, 1,007 newly
matched elements from #2043's self-model surfaces); the folded totals equal
develop's monolith at 1b94d85 (105,427 matched, 2,045,067 present-equal,
144,702 present-different, 308,336 ours-missing, 81,780 pilot-missing,
2,244,567 absent-both, 35,440 indeterminate, 534 pilot-nondeterministic).

Co-Authored-By: jason.han <hanhuijun@gmail.com>
examples/self-model/surfaces.sysml still named the removed monolith docs/project/api-json-differential-baseline.json as the ApiJsonDifferential oracle's baseline, which TestSelfModelGainedOraclesMatchTools rightly rejects; it now names docs/project/api-json-differential.

The edit changes the examples corpus digest, so the three baselines that record it are re-recorded by their tools (pilot-apijson-diff -update -roots examples, pilot-diff -update, derived-census -update): provenance only, no row, verdict or figure moves.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
pilot-apijson-diff -update on the merged tree: 69 fragments and index.json move with #2093's objective/body-constraint export and #2109's bare-comment fix (develop's monolith moved the same rows). Totals: 935 files, 105,427 matched; present-equal 2,045,864, present-different 143,898, ours-missing 308,343, pilot-missing 81,606, absent-both 2,244,653, indeterminate 35,440, pilot-nondeterministic 534 — equal to develop's monolith on this tree.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
.gitattributes listed docs/project/*-baseline.json only, so the fragments under docs/project/api-json-differential/ were shown as source in a diff and counted in the language statistics; the directory's JSON is now linguist-generated, and tests/hygiene holds the attribute line.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
tools/referee/baseline.Rewrite stamped the checkout's provenance on fragments it had not re-measured, so -reindex after a pilot pin move produced an index the provenance guard accepted; it now refuses every provenance movement outside the inputs named like the replaced roots, naming the refresh command. It also read the committed directory strictly, so two branches that each added or removed a file of one root could not re-record that root after merging; the replaced roots' index entries and files are now skipped and re-recorded whole, while the other roots stay strict. scripts/ci-changed-areas.sh claims tools/referee/baseline/ for the apijson differential job.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant