Skip to content

test(corpus): construct-cover subset of examples/ behind OPENSYSML_CORPUS_SUBSET - #2163

Merged
devin-ai-integration[bot] merged 3 commits into
developfrom
feat/construct-cover-subset
Nov 12, 2026
Merged

devin-ai-integration[bot] merged 3 commits into
developfrom
feat/construct-cover-subset

Conversation

@devin-ai-integration

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

Copy link
Copy Markdown
Contributor

What and why

The tests that walk every model under examples/ (the committed models and the downloaded training, pilot and specification-example roots, 880 files) are a third of the suite's -race time, and each re-parses and re-exports the corpus on its own. Most check a property of the implementation on whatever syntax a model exhibits, so what they need is the corpus's variety of constructs, not its 880 files.

This adds a committed, regenerable construct-cover subset and a switch that makes the sweeps iterate it:

  • tests/testutil/constructcover parses a file with internal/syntax/parser and derives its syntactic features by a reflective walk of the tree: source kind, diagnostics/clean, every concrete node type, every parent-field→child-type edge, every Kind-style enum value and keyword/operator string field value, every set bool flag. Cover is a deterministic greedy set cover (most uncovered features first; a committed file beats a downloaded one, then the lesser path).

  • tests/corpus/testdata/construct_cover.txt: 95 of the 880 files covering all 814 features (19 committed, 6 training, 41 pilot, 29 spec-examples), one examples/-relative path per line, sorted, under a # header naming the recorder and the counts. Recorded by go test ./tests/corpus -run TestConstructCover -update-construct-cover; two recordings are byte-identical.

  • TestConstructCover (always on, tests/corpus, in the corpus shard that every tier runs) re-derives the feature set over the whole corpus (parse only, ~0.5 s with the corpora present), fails naming each uncovered feature and a file that has it with the re-record command, fails when a listed file is gone, and skips/requires absent roots exactly as TestCorpusRoundTrip does (it reuses corpusRoundTripFiles).

  • tests/testutil/corpussubset is the one helper every sweep calls. It reads OPENSYSML_CORPUS_SUBSET: unset → every file; construct-cover → the committed list; any other value → the sweep fails. A file outside examples/ (tests/testdata, docs/manual/examples, a package's testdata) is always iterated.

    const EnvVar = "OPENSYSML_CORPUS_SUBSET"; const ConstructCover = "construct-cover"; const ListPath = "tests/corpus/testdata/construct_cover.txt"
    func Load(repoRoot string) (Subset, error)        // from the environment; an unknown value is an error
    func Must(tb Fataler, repoRoot string) Subset      // Load for a test (Fataler = Helper()+Fatalf, so the package does not import testing)
    func (Subset) Whole() bool                         // nothing filtered
    func (Subset) Name() string                        // the variable's value
    func (Subset) Wants(rel string) bool               // an examples/-relative slash path
    func (Subset) WantsPath(examplesDir, path string) bool   // any spelling; a path outside examplesDir is always wanted
    func (Subset) WantsAny(examplesDir string, paths []string) bool  // a directory-unit sweep: iterate the directory when any file is listed
    func (Subset) Filter(rel []string) []string
    func (Subset) FilterPaths(examplesDir string, paths []string) []string
    func (Subset) Recording(flag string) error         // non-nil under a subset: recorders refuse to record a partial sweep
    func ReadList(path string) ([]string, error)       // the list file; rejects an unsorted or empty list

What the switch does to each sweep (docs/project/construct-cover-subset.md has the full account):

  • File-unit sweeps iterate the listed files: library_root_name_test.go, compile_differential_test.go, rounded_census_test.go, formatting_test.go, referenced_document_test.go, modelsync_test.go, shared_index_test.go, examples_test.go (each listed example still opened with all its directory siblings), find_errors_test.go, typecheck_expr_corpus_test.go, api_json_mapping_qualified_name_test.go (feeds TestExamplesCorpusInvariants and the API JSON sweep), settled_collections_test.go, element_properties_agreement_test.go, incremental_test.go (the loose examples and each downloaded root as a per-file set; a committed demo directory replayed whole when any of its files is listed).
  • Directory-unit sweeps (TestParallelBatchValidationMatchesSerial, TestCommandLineLoadMatchesWorkspace, the "directory together" models of TestSettledCollectionsAreWhatReconcilingWouldFind) iterate a directory when any of its files is listed and load the whole directory; loading a partial directory changed what they compare (the CLI resolves siblings, the workspace does not).
  • Per-file ratchets (TestCorpusRoundTrip, TestCorpusAPIJSONRoundTrip, TestPilotCorporaDiagnostics, TestSpecExamplesDiagnostics) compute verdicts for the visited files only and compare them against the expectation; an unvisited recorded line is left unchecked, a recorded file that is gone still fails, and the recorded root sizes are still checked against the whole corpus so a partial download fails as before. The pilot and spec gates still open each root whole (the files import across each other, so a file's counts depend on its siblings) and diagnose only the listed files.
  • TestSymbolStructureMatchesGraphStructure records per-root totals, not per-file verdicts, so under the subset each root's unmatched and per-property different/symbol-missing/symbol-extra counts must not exceed the recorded ones (a property the block omits must not disagree at all); the exact comparison needs the whole corpus.
  • Every recorder (-update-corpus-roundtrip, -update-api-json-roundtrip, -update-pilot-corpora, -update-spec-examples, -update-structure-differential, -update-construct-cover) fails with Recording while the variable is set.
  • TestTrainingExamplesSemanticErrors ignores the variable: it asserts the whole training corpus clean in one batch load, which is cheap, and an assertion over part of a corpus asserts nothing. Documented in its comment and in docs/project/training-examples.md. So does TestDifferentialTrainingCorpus (internal/exec/solve): its input is the training models that declare conditions, a semantic selection the syntactic cover does not preserve (none of the six listed training files declare one, so the gate would have checked nothing), and the whole run takes ~2 s.

Four of the 24 files named in the brief do not sweep examples/ per file and are unchanged: cmd/sysml/markup_tool_missing_test.go renders one document from examples/self-model as one model; tests/kpar/kpar_test.go and meta_test.go read the OMG .kpar archives under testdata/omg (the examples/… strings are archive member names); tools/oracle/errata/errata_test.go materializes the errata overlay over a whole pilot corpus root and hashes the tree.

Shared contract: kept as stated (variable, values, list path, one sorted examples/-relative path per line). An empty value is unset, as #2162 relies on (pr.yml sets the variable to the empty string outside the queue tier); TestUnsetIteratesEverything pins it. One note: the list carries a # comment header (recorder command and counts), which ReadList skips; a consumer that reads the file directly should skip # lines. scripts/race-shard.sh --sweeps, CI tiers and workflows are untouched (PR 3).

Measured corpus: 56 committed + 100 training + 213 pilot + 511 spec-examples = 880 files at the current pins (the brief's ~920 counted spec-examples at ~550).

Measured wall time of the five big sweeps, no -race, 8-core VM, corpora present (go test -count=1 -run '^Test…$' package time):

Sweep whole corpus OPENSYSML_CORPUS_SUBSET=construct-cover
TestSettledCollectionsAreWhatReconcilingWouldFind (tests/export) 106.9 s 60.9 s
TestSymbolStructureMatchesGraphStructure (internal/translate/export) 171.1 s 62.3 s
TestCorpusAPIJSONRoundTrip (tests/corpus) 111.2 s 61.8 s
TestElementPropertiesAgreeWithTheAPIJSONExport (tests/grpc) 161.5 s 45.6 s
TestCorpusRoundTrip (tests/corpus) 50.5 s 34.9 s

The subset runs share a fixed cost (each indexes the standard library into an empty XDG_CACHE_HOME, and the fixtures outside examples/ are still swept), so the saving grows with the per-file cost, which -race multiplies.

How it was verified

  • go test -count=1 ./tests/corpus (all gates, OPENSYSML_REQUIRE_* set) with the variable unset and with construct-cover; OPENSYSML_CORPUS_SUBSET=bogus fails each sweep with unknown subset; every -update-* recorder refuses under the subset.
  • Every wired sweep run under construct-cover (packages above), plus the five timings above in both modes.
  • Unit tests: tests/testutil/corpussubset (unset/listed/unknown/unsorted/empty list, FilterPaths, WantsAny), tests/testutil/constructcover (feature names, diagnostics, greedy order and committed preference, Uncovered).
  • gofmt -l ., go vet ./..., make lint, the two-line comment gate, python3 scripts/check-doc-ids.py, python3 scripts/check-doc-links.py, python3 scripts/changelog.py check, go test -count=1 ./tests/hygiene, go test -C tools ./referee/apijson, and go test -count=1 -timeout 60m ./... (whole suite, corpora present and required, no -race) on this head.

Checklist

  • make test and make lint pass locally (the suite without -race; the race tier runs in CI)
  • Tests added or updated for the change
  • Documentation extended where it already covers the surface (see CONTRIBUTING.md)
  • Changelog entry added as changes/unreleased/<slug>.<section>.md, not as an edit to CHANGELOG.md
  • baselines regenerated and make docs-counts run if a gate count moved (compliance rows need nothing: the census is counted at docs build)
  • No internal work-item labels (waves, slices, F4, K5) in the body, docs, or changelog

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


🟢 Devin Review found nothing to fix · View findings · Follow Devin's work

Devin Review

…RPUS_SUBSET

A committed, regenerable subset of the models under examples/ that exhibits
every syntactic feature the whole corpus does (95 of 880 files, 814 features),
recorded by TestConstructCover -update-construct-cover and checked against the
whole corpus on every run. OPENSYSML_CORPUS_SUBSET=construct-cover makes every
examples/ sweep iterate it through tests/testutil/corpussubset; the per-file
ratchets check only the visited files and every recorder refuses under it.

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 2 commits November 12, 2026 01:56
…BSET

Its input is the training models that declare conditions, a semantic
selection the syntactic construct cover does not preserve: none of the
listed training files declares one, so under the subset the gate checked
nothing. The whole run takes seconds, so it sweeps the whole corpus.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
CONTRIBUTING.md names the subset and points at docs/project/construct-cover-subset.md
for the measured subset size and feature count, as the other gates' counts are kept.

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

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@HuiJun
HuiJun added this pull request to the merge queue Nov 12, 2026
@devin-ai-integration
devin-ai-integration Bot removed this pull request from the merge queue due to a manual request Nov 12, 2026
@devin-ai-integration
devin-ai-integration Bot added this pull request to the merge queue Nov 12, 2026
Merged via the queue into develop with commit 042643b Nov 12, 2026
34 checks passed
@devin-ai-integration
devin-ai-integration Bot deleted the feat/construct-cover-subset branch November 12, 2026 08:02
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