From 653df49e45d0499f79dd39a8e800a96fe32b89bd Mon Sep 17 00:00:00 2001 From: evanchooly Date: Sun, 22 Nov 2026 16:50:22 -0500 Subject: [PATCH 1/2] File discovery findings as issues from the scheduled job --- .github/workflows/operator-discovery.yml | 83 ++++++++++- audits/README.md | 19 ++- audits/catalog/publication-policy.json | 21 ++- audits/discover.sh | 2 +- .../dev/morphia/audits/coverage/AuditJson.kt | 3 + .../dev/morphia/audits/generate/Candidates.kt | 5 +- .../morphia/audits/generate/CaseGenerator.kt | 3 + .../audits/publish/DiscoveryFindings.kt | 115 +++++++++++++++ .../dev/morphia/audits/publish/PublishMain.kt | 50 +++++-- .../dev/morphia/audits/publish/Publisher.kt | 6 + .../audits/offline/DiscoveryFindingsTest.kt | 131 ++++++++++++++++++ 11 files changed, 418 insertions(+), 20 deletions(-) create mode 100644 audits/src/main/kotlin/dev/morphia/audits/publish/DiscoveryFindings.kt create mode 100644 audits/src/test/kotlin/dev/morphia/audits/offline/DiscoveryFindingsTest.kt diff --git a/.github/workflows/operator-discovery.yml b/.github/workflows/operator-discovery.yml index 0b3c6e076df..44db02ae436 100644 --- a/.github/workflows/operator-discovery.yml +++ b/.github/workflows/operator-discovery.yml @@ -1,16 +1,28 @@ name: Operator Example Discovery -# Report-only: inventories the documented operator examples at the head of mongodb/docs, generates -# a candidate with its gaps, and integrates it under both mappers. It uploads the reports and never -# commits, promotes or files issues; a changed inventory is a proposal to review, not a failure. +# Inventories the documented operator examples at the head of mongodb/docs, generates a candidate +# with its gaps, and integrates it under both mappers, uploading every report. It never commits or +# promotes. The Publish job then files its findings as issues in this repository: each binding the +# generated cases lack, each example that appeared upstream with no test, and a failing integration. +# An issue's marker keeps reruns from filing it twice; a closed issue is not reopened. on: workflow_dispatch: + inputs: + publish: + description: File the findings as issues (otherwise only report what would be filed) + type: boolean + default: true schedule: - cron: '17 6 * * 1' permissions: contents: read +# Overlapping runs would publish from two journals at once. +concurrency: + group: operator-discovery + cancel-in-progress: false + jobs: Discover: runs-on: ubuntu-latest @@ -51,3 +63,68 @@ jobs: ${{ runner.temp }}/discovery/*.diff ${{ runner.temp }}/discovery/candidate/ retention-days: 90 + + Publish: + needs: Discover + # Discovery's reports are uploaded even when its integration fails, and that failure is a finding. + if: ${{ !cancelled() }} + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + issues: write + steps: + - name: Checkout + uses: actions/checkout@v7 + + - name: Setup Java + uses: actions/setup-java@v6 + with: + java-version: '17' + distribution: temurin + cache: maven + + - name: Download reports + uses: actions/download-artifact@v7 + with: + name: operator-discovery + path: ${{ runner.temp }}/discovery + + # The journal names each finding's issue, which is read by number. The issue listing can lag + # a recent write by minutes, so without it a rerun soon after a run could file a finding twice. + - name: Restore the previous journal + env: + GH_TOKEN: ${{ github.token }} + run: | + for run in $(gh run list -R "$GITHUB_REPOSITORY" --workflow operator-discovery.yml -L 20 \ + --json databaseId --jq ".[].databaseId | select(. != $GITHUB_RUN_ID)"); do + if gh run download "$run" -R "$GITHUB_REPOSITORY" -n operator-publications -D "$RUNNER_TEMP/previous" 2>/dev/null \ + && [ -f "$RUNNER_TEMP/previous/journal.json" ]; then + cp "$RUNNER_TEMP/previous/journal.json" "$RUNNER_TEMP/journal.json" + echo "Journal from run $run" + break + fi + rm -rf "$RUNNER_TEMP/previous" + done + + - name: File findings + env: + AUDITS_GITHUB_TOKEN: ${{ github.token }} + PUBLISH: ${{ github.event_name == 'schedule' || inputs.publish }} + run: | + flag=$([ "$PUBLISH" = "true" ] && echo --publish || true) + ./mvnw -B -ntp -q -Daudits -pl audits compile exec:java \ + -Daudits.mainClass=dev.morphia.audits.publish.PublishMainKt \ + -Dexec.args="discovery $RUNNER_TEMP/discovery $PWD/audits/catalog/documented-examples.json $PWD/audits/catalog/publication-policy.json $RUNNER_TEMP/journal.json ${{ github.repository }} $flag" \ + | tee "$RUNNER_TEMP/publications.json" + + - name: Upload publications + uses: actions/upload-artifact@v7 + if: always() + with: + name: operator-publications + path: | + ${{ runner.temp }}/publications.json + ${{ runner.temp }}/journal.json + if-no-files-found: ignore + retention-days: 90 diff --git a/audits/README.md b/audits/README.md index 4fe1af4989e..9acafd38dfc 100644 --- a/audits/README.md +++ b/audits/README.md @@ -49,7 +49,19 @@ Every command below runs through the exec plugin from the repository root, after ## Weekly discovery `.github/workflows/operator-discovery.yml` runs `audits/discover.sh` every Monday against the head -of mongodb/docs, read-only. Open the run's summary and its `operator-discovery` artifact: +of mongodb/docs, then its Publish job files the findings as issues in this repository: + +- **Bind `` for generated operator tests** (`enhancement`, `aggregation`, `proposed`): an + MQL node that documented examples need and `dsl-bindings.json` lacks, with the examples it blocks. +- **Cover the documented `` example "…"** (`Task`, `proposed`): an example that appeared + upstream since the committed inventory, with no test. +- **Generated operator cases fail integration** (`bug`), naming the failing tests. + +Each issue carries a hidden marker, so a rerun updates the publisher's section of an open issue +instead of filing it again, and keeps any edits outside that section. The journal of filed issues +carries over from run to run. A closed issue is a decision and is not reopened. A manual run can +set `publish` off to see what it would file. Open the run's summary and its `operator-discovery` +artifact: - **The inventory matches**: nothing changed upstream that the inventory sees. - **`inventory.diff` is not empty**: examples were added, renamed or removed. Accept it locally: @@ -122,8 +134,9 @@ never-locked fixtures come from `fetch.py references`, `fetch.py pages` and ## Publishing findings -`PublishMainKt ` only prints what -it would file. Add `--publish` to file issues, which needs `gh` authenticated with write access to +`PublishMainKt `, or +`PublishMainKt discovery ` +for a discovery run's findings, only prints what it would file. Add `--publish` to file issues, which needs `gh` authenticated with write access to issues (or `AUDITS_GITHUB_TOKEN`). The journal makes reruns idempotent: keep it, and never point a trial run at MorphiaOrg/morphia. Use the disposable sandbox repository instead. diff --git a/audits/catalog/publication-policy.json b/audits/catalog/publication-policy.json index a01dd4e43ed..a1839d29460 100644 --- a/audits/catalog/publication-policy.json +++ b/audits/catalog/publication-policy.json @@ -1,7 +1,24 @@ { "labels" : { - "MISSING_API" : [ "enhancement", "proposed" ], - "VERSION_ANNOTATION" : [ "bug" ] + "INTEGRATION_FAILURE" : [ + "bug" + ], + "MISSING_API" : [ + "enhancement", + "proposed" + ], + "MISSING_BINDING" : [ + "enhancement", + "aggregation", + "proposed" + ], + "NEW_EXAMPLE" : [ + "Task", + "proposed" + ], + "VERSION_ANNOTATION" : [ + "bug" + ] }, "milestone" : null, "schemaVersion" : 1 diff --git a/audits/discover.sh b/audits/discover.sh index 39244d74d8b..fb527ec2670 100755 --- a/audits/discover.sh +++ b/audits/discover.sh @@ -47,7 +47,7 @@ def load(name): path = os.path.join(out, name) return json.load(open(path)) if os.path.exists(path) else None inventory = load("documented-examples.json") -gaps = load("candidate/gaps.json") or [] +gaps = (load("candidate/gaps.json") or {}).get("gaps", []) attestation = load("candidate/attestation.json") candidate = load("candidate/candidate.json") lines = [f"# Operator example discovery at mongodb/docs `{inventory['commit'][:10]}`", ""] diff --git a/audits/src/main/kotlin/dev/morphia/audits/coverage/AuditJson.kt b/audits/src/main/kotlin/dev/morphia/audits/coverage/AuditJson.kt index 8fe1de0bc0b..e8d865de17d 100644 --- a/audits/src/main/kotlin/dev/morphia/audits/coverage/AuditJson.kt +++ b/audits/src/main/kotlin/dev/morphia/audits/coverage/AuditJson.kt @@ -25,6 +25,7 @@ import dev.morphia.audits.generate.Candidate import dev.morphia.audits.generate.CurrentPages import dev.morphia.audits.generate.DslBindingCatalog import dev.morphia.audits.generate.ExampleInventory +import dev.morphia.audits.generate.GenerationGaps import dev.morphia.audits.generate.GenerationReview import dev.morphia.audits.naming.ExampleNameRegistry import dev.morphia.audits.naming.NameProposal @@ -195,6 +196,8 @@ object AuditJson { fun generationReview(json: String): GenerationReview = read(json, GenerationReview::class.java) + fun generationGaps(json: String): GenerationGaps = read(json, GenerationGaps::class.java) + fun exampleInventory(json: String): ExampleInventory = read(json, ExampleInventory::class.java) fun publicationJournal(json: String): PublicationJournal = diff --git a/audits/src/main/kotlin/dev/morphia/audits/generate/Candidates.kt b/audits/src/main/kotlin/dev/morphia/audits/generate/Candidates.kt index bf410e0d24c..85fb51838a6 100644 --- a/audits/src/main/kotlin/dev/morphia/audits/generate/Candidates.kt +++ b/audits/src/main/kotlin/dev/morphia/audits/generate/Candidates.kt @@ -143,7 +143,10 @@ object Candidates { Files.write(target, bytes) } Files.writeString(out.resolve(DESCRIPTOR), AuditJson.write(candidate)) - Files.writeString(out.resolve(GAPS), AuditJson.write(generation.gaps)) + Files.writeString( + out.resolve(GAPS), + AuditJson.write(GenerationGaps(gaps = generation.gaps)), + ) return candidate } diff --git a/audits/src/main/kotlin/dev/morphia/audits/generate/CaseGenerator.kt b/audits/src/main/kotlin/dev/morphia/audits/generate/CaseGenerator.kt index 5da8d45e7f0..f68d5d49631 100644 --- a/audits/src/main/kotlin/dev/morphia/audits/generate/CaseGenerator.kt +++ b/audits/src/main/kotlin/dev/morphia/audits/generate/CaseGenerator.kt @@ -33,6 +33,9 @@ data class GenerationGap( val detail: String, ) +/** The gaps of one generation, as `candidate` writes them to `gaps.json`. */ +data class GenerationGaps(val schemaVersion: Int = 1, val gaps: List) + /** A reviewed exclusion of a generated case, by its qualified name. */ data class Exclusion(val name: String, val reason: String) diff --git a/audits/src/main/kotlin/dev/morphia/audits/publish/DiscoveryFindings.kt b/audits/src/main/kotlin/dev/morphia/audits/publish/DiscoveryFindings.kt new file mode 100644 index 00000000000..7f543bd53c8 --- /dev/null +++ b/audits/src/main/kotlin/dev/morphia/audits/publish/DiscoveryFindings.kt @@ -0,0 +1,115 @@ +package dev.morphia.audits.publish + +import dev.morphia.audits.generate.Attestation +import dev.morphia.audits.generate.ExampleInventory +import dev.morphia.audits.generate.ExampleStatus +import dev.morphia.audits.generate.GapKind +import dev.morphia.audits.generate.GenerationGap + +/** + * The publishable findings of one discovery run (`audits/discover.sh`): each binding the generated + * cases lack, each example that appeared upstream with no test since [committed] was accepted, and + * a failing integration. Keys are stable across runs, so a recurring finding updates its issue. + */ +object DiscoveryFindings { + private val unbound = Regex("""^\S*: (.+) has no binding$""") + private val failed = Regex("""^\[ERROR] (\S+) -- Time elapsed: .* <<< (FAILURE|ERROR)!$""") + + fun findings( + committed: ExampleInventory, + current: ExampleInventory, + gaps: List, + attestation: Attestation?, + integrationLog: String?, + ): List = + (bindings(current, gaps) + + examples(committed, current, gaps) + + listOfNotNull(integration(current, attestation, integrationLog))) + .sortedBy { it.key } + + /** One finding per unbound node, listing the examples it blocks. */ + private fun bindings(current: ExampleInventory, gaps: List): List = + gaps + .filter { it.kind == GapKind.UNBOUND } + .groupBy { unbound.find(it.detail)?.groupValues?.get(1) ?: it.detail } + .map { (node, blocked) -> + Finding( + "${FindingType.MISSING_BINDING}:$node", + FindingType.MISSING_BINDING, + "Bind $node for generated operator tests", + "Generated operator tests cannot be written for these documented examples " + + "(mongodb/docs `${current.commit.take(10)}`) because $node has no entry in " + + "`audits/catalog/dsl-bindings.json`. If Morphia has an API for it, add the " + + "binding; if not, the API comes first.\n\n" + + blocked.joinToString("\n") { + "- ${it.context} `${it.operator}`: ${it.title.trim()} (`${it.detail}`)" + }, + ) + } + + /** Examples without a handwritten owner that the committed inventory did not have. */ + private fun examples( + committed: ExampleInventory, + current: ExampleInventory, + gaps: List, + ): List { + fun key(context: String, operator: String, title: String) = + "$context/$operator/${title.trim()}" + val known = + committed.pages + .flatMap { page -> + page.examples.map { key(page.context, page.operator, it.title) } + } + .toSet() + val gapOf = gaps.associateBy { key(it.context, it.operator, it.title) } + return current.pages.flatMap { page -> + page.examples + .filter { it.status != ExampleStatus.OWNED } + .filter { key(page.context, page.operator, it.title) !in known } + .map { example -> + val key = key(page.context, page.operator, example.title) + val state = + gapOf[key]?.let { "Generation reports ${it.kind}: ${it.detail}" } + ?: if (example.status == ExampleStatus.UNOWNED) + "It is generated when its family is in `audits/catalog/generation-review.json`." + else "It is ${example.status}: ${example.detail}" + Finding( + "${FindingType.NEW_EXAMPLE}:$key", + FindingType.NEW_EXAMPLE, + "Cover the documented ${page.operator} example \"${example.title.trim()}\"", + "mongodb/docs `${current.commit.take(10)}` documents this ${page.context} example " + + "at `${page.source.path}`, and no test covers it.\n\n$state\n\n" + + "Accept the new inventory (see audits/README.md, Weekly discovery) and " + + "regenerate, or cover it by hand.", + ) + } + } + } + + private fun integration( + current: ExampleInventory, + attestation: Attestation?, + log: String?, + ): Finding? { + if (attestation == null || attestation.passed()) return null + val tests = + log.orEmpty() + .lines() + .mapNotNull { failed.find(it.trim())?.groupValues?.get(1) } + .distinct() + .sorted() + return Finding( + FindingType.INTEGRATION_FAILURE.name, + FindingType.INTEGRATION_FAILURE, + "Generated operator cases fail integration", + "Scheduled discovery at mongodb/docs `${current.commit.take(10)}` integrated the regenerated " + + "candidate and it failed: " + + attestation.results.entries.joinToString { "${it.key} exited ${it.value}" } + + ".\n\n" + + (if (tests.isEmpty()) "No failing test was named; see the run's `integration.log`." + else "Failing tests:\n" + tests.joinToString("\n") { "- `$it`" }) + + "\n\nDiagnose from the run's `operator-discovery` artifact; a case the page or server makes " + + "unverifiable is excluded in `audits/catalog/generation-review.json` with its evidence.", + ) + } +} diff --git a/audits/src/main/kotlin/dev/morphia/audits/publish/PublishMain.kt b/audits/src/main/kotlin/dev/morphia/audits/publish/PublishMain.kt index 14aa3d09bfc..eefbc9b05a7 100644 --- a/audits/src/main/kotlin/dev/morphia/audits/publish/PublishMain.kt +++ b/audits/src/main/kotlin/dev/morphia/audits/publish/PublishMain.kt @@ -5,19 +5,44 @@ import java.nio.file.Files import java.nio.file.Path private const val USAGE = - "Usage: PublishMainKt [--publish]" + """Usage: PublishMainKt [--publish] + PublishMainKt discovery [--publish]""" /** - * Files a validated coverage report's findings as issues in OWNER/REPO. Without `--publish` it only - * reports what it would do and never spawns a mutating command. `AUDITS_GITHUB_TOKEN`, when set, is - * the token `gh` uses; otherwise `gh` uses its stored credentials. Prints each publication. + * Files findings as issues in OWNER/REPO: a validated coverage report's, or, with `discovery`, + * those of an `audits/discover.sh` output directory against the committed example inventory. + * Without `--publish` it only reports what it would do and never spawns a mutating command. + * `AUDITS_GITHUB_TOKEN`, when set, is the token `gh` uses (CI maps its job token to it); otherwise + * `gh` uses its stored credentials. Prints each publication. */ fun main(args: Array) { - require(args.size == 4 || args.size == 5 && args[4] == "--publish") { USAGE } - fun read(path: String) = Files.readString(Path.of(path)) + fun read(path: Path) = Files.readString(path) + val discovery = args.firstOrNull() == "discovery" + val positional = if (discovery) 6 else 4 + require(args.size == positional || args.size == positional + 1 && args.last() == "--publish") { + USAGE + } + val publish = args.size == positional + 1 val (owner, repository) = - args[3].split('/').also { require(it.size == 2) { USAGE } }.let { it[0] to it[1] } - val publish = args.size == 5 + args[positional - 1] + .split('/') + .also { require(it.size == 2) { USAGE } } + .let { it[0] to it[1] } + val findings = + if (discovery) { + val out = Path.of(args[1]) + val optional = { name: String -> + out.resolve(name).takeIf { Files.exists(it) }?.let(::read) + } + DiscoveryFindings.findings( + AuditJson.exampleInventory(read(Path.of(args[2]))), + AuditJson.exampleInventory(read(out.resolve("documented-examples.json"))), + AuditJson.generationGaps(read(out.resolve("candidate/gaps.json"))).gaps, + optional("candidate/attestation.json")?.let(AuditJson::attestation), + optional("candidate/integration.log"), + ) + } else Publisher.findings(AuditJson.report(read(Path.of(args[0])))) + val (policy, journal) = if (discovery) args[3] to args[4] else args[1] to args[2] val gateway = GhGateway( GhTarget(owner, repository), @@ -26,7 +51,12 @@ fun main(args: Array) { ) gateway.checkVersion() val publications = - Publisher(gateway, AuditJson.publicationPolicy(read(args[1])), Path.of(args[2]), publish) - .publish(Publisher.findings(AuditJson.report(read(args[0])))) + Publisher( + gateway, + AuditJson.publicationPolicy(read(Path.of(policy))), + Path.of(journal), + publish, + ) + .publish(findings) println(AuditJson.write(publications)) } diff --git a/audits/src/main/kotlin/dev/morphia/audits/publish/Publisher.kt b/audits/src/main/kotlin/dev/morphia/audits/publish/Publisher.kt index e0f305c3afc..725d513a433 100644 --- a/audits/src/main/kotlin/dev/morphia/audits/publish/Publisher.kt +++ b/audits/src/main/kotlin/dev/morphia/audits/publish/Publisher.kt @@ -17,6 +17,12 @@ enum class FindingType { MISSING_API, /** A Morphia declaration whose server-version annotation is missing or wrong. */ VERSION_ANNOTATION, + /** An MQL node that generated cases need and the DSL bindings do not cover. */ + MISSING_BINDING, + /** A documented example that appeared upstream and no test covers. */ + NEW_EXAMPLE, + /** Generated cases that fail integration under a mapper. */ + INTEGRATION_FAILURE, } /** diff --git a/audits/src/test/kotlin/dev/morphia/audits/offline/DiscoveryFindingsTest.kt b/audits/src/test/kotlin/dev/morphia/audits/offline/DiscoveryFindingsTest.kt new file mode 100644 index 00000000000..6a58bd61154 --- /dev/null +++ b/audits/src/test/kotlin/dev/morphia/audits/offline/DiscoveryFindingsTest.kt @@ -0,0 +1,131 @@ +package dev.morphia.audits.offline + +import dev.morphia.audits.coverage.AuditJson +import dev.morphia.audits.generate.Attestation +import dev.morphia.audits.generate.DocumentedExample +import dev.morphia.audits.generate.DocumentedPage +import dev.morphia.audits.generate.ExampleInventory +import dev.morphia.audits.generate.ExampleStatus +import dev.morphia.audits.generate.GapKind +import dev.morphia.audits.generate.GenerationGap +import dev.morphia.audits.generate.GenerationGaps +import dev.morphia.audits.publish.DiscoveryFindings +import dev.morphia.audits.publish.FindingType +import dev.morphia.audits.repairs.FormSource +import java.nio.file.Files +import java.nio.file.Path +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.Test + +class DiscoveryFindingsTest { + private val commit = "d".repeat(40) + + private fun inventory(vararg examples: DocumentedExample) = + ExampleInventory( + sourceRepository = "mongodb/docs", + commit = commit, + pages = + listOf( + DocumentedPage( + "aggregation/expressions", + "bitOr", + FormSource( + commit, + "content/manual/manual/source/reference/operator/aggregation/bitOr.txt", + ), + "blob", + emptyList(), + examples.toList(), + ) + ), + skipped = emptyList(), + summary = emptyMap(), + ) + + private val owned = + DocumentedExample( + "Two Integers", + ExampleStatus.OWNED, + owner = "aggregation/expressions/bitOr/x", + ) + private val old = DocumentedExample("Old Unowned", ExampleStatus.UNOWNED, "oldUnowned") + private val added = DocumentedExample("Added Upstream ", ExampleStatus.UNOWNED, "addedUpstream") + + private fun gap(title: String, detail: String) = + GenerationGap("aggregation/expressions", "bitOr", title, GapKind.UNBOUND, detail) + + @Test + fun findingsNameMissingBindingsNewExamplesAndFailedIntegration() { + val gaps = + listOf( + gap("Old Unowned", "/pipeline/0: stage \$match has no binding"), + gap("Added Upstream ", "/pipeline/1: stage \$match has no binding"), + ) + val findings = + DiscoveryFindings.findings( + inventory(owned, old), + inventory(owned, old, added), + gaps, + Attestation( + candidateSha256 = "0", + baseRevision = "b", + tests = emptyList(), + results = mapOf("critter" to 1, "reflection" to 0), + ), + "[ERROR] dev.morphia.test.generated.expressions.TestAdd.addThings -- Time elapsed: 0.6 s <<< FAILURE!\n", + ) + assertEquals( + listOf( + "INTEGRATION_FAILURE", + "MISSING_BINDING:stage \$match", + "NEW_EXAMPLE:aggregation/expressions/bitOr/Added Upstream", + ), + findings.map { it.key }, + ) + val binding = findings.single { it.type == FindingType.MISSING_BINDING } + // One finding for the node, listing every example it blocks. + assertTrue("Old Unowned" in binding.body && "Added Upstream" in binding.body, binding.body) + val example = findings.single { it.type == FindingType.NEW_EXAMPLE } + assertTrue("UNBOUND" in example.body && "bitOr.txt" in example.body, example.body) + val integration = findings.single { it.type == FindingType.INTEGRATION_FAILURE } + assertTrue( + "`dev.morphia.test.generated.expressions.TestAdd.addThings`" in integration.body, + integration.body, + ) + } + + @Test + fun aQuietRunHasNoFindings() { + val findings = + DiscoveryFindings.findings( + inventory(owned, old), + inventory(owned, old), + emptyList(), + Attestation( + candidateSha256 = "0", + baseRevision = "b", + tests = emptyList(), + results = mapOf("critter" to 0, "reflection" to 0), + ), + null, + ) + assertEquals(emptyList(), findings.map { it.key }) + } + + @Test + fun theCommittedPolicyLabelsEveryFindingType() { + val root = + generateSequence(Path.of("").toAbsolutePath()) { it.parent } + .first { Files.isDirectory(it.resolve("audits/catalog")) } + val policy = + AuditJson.publicationPolicy( + Files.readString(root.resolve("audits/catalog/publication-policy.json")) + ) + assertEquals(FindingType.entries.toSet(), policy.labels.keys) + assertEquals( + GenerationGaps(gaps = listOf(gap("t", "d"))), + AuditJson.generationGaps(AuditJson.write(GenerationGaps(gaps = listOf(gap("t", "d"))))), + ) + } +} From d01abec804771fbfaca255aab3ef0ce04aa638e2 Mon Sep 17 00:00:00 2001 From: evanchooly Date: Sun, 22 Nov 2026 17:00:25 -0500 Subject: [PATCH 2/2] Bring the audit progress file up to date --- design/operator-audits-progress.md | 139 +++++++++++++++++++++++------ 1 file changed, 113 insertions(+), 26 deletions(-) diff --git a/design/operator-audits-progress.md b/design/operator-audits-progress.md index 9041937e55f..9713a9c7b8b 100644 --- a/design/operator-audits-progress.md +++ b/design/operator-audits-progress.md @@ -1,31 +1,67 @@ # Operator audit implementation progress -Current branch: `audits-curated-repairs`; PR base: `audits-descriptive-names` (#4530). -Stack (PR head branches): #4512 `audits-pipeline-design` → #4513 `audits-source-inventory` → -#4514 `audits-coverage-contracts` → #4515 `audits-example-identities` → #4516 `audits-pinned-sources` → -#4517 `audits-snooty-adapter` → #4518 `audits-capability-normalization` → -#4519 `audits-bson-comparison` → #4520 `audits-shell-semantics` → #4521 `audits-scenario-programs` → -#4522 `audits-scenario-extraction` → #4523 `audits-published-expectations` → -#4524 `audits-legacy-scenarios` → #4525 `audits-section-assembly` → #4529 `audits-binding-manifest` → -#4530 `audits-descriptive-names` → curated repair inventory (in progress). -Each PR targets its predecessor; #4512 targets `master`. -Use `git worktree list` to locate the checkout on this machine. - -## Current status at a glance - -- Published infrastructure: #4512 foundation, #4513 API inventory, #4514 coverage contracts, - #4515 persisted names, #4516 pinned acquisition, #4517 structured docs and #4518 capability - discovery. Discovery is deliberately PARTIAL where upstream evidence is unresolved. -- #4519 strict BSON comparison is published and all five exact-head checks pass at - `27a3fa7c1db2d22a6b0fc6e1c3d0f53f0e45f257`; local review is complete. -- This branch adds shell BSON literals: 215 audit tests pass in both requested configurations, - including 27 literal tests. Two existing Python integrations skip without explicit properties. - Three local review rounds are complete; the final round found no remaining correctness issues. - Check publication/CI with `gh pr view audits-shell-semantics`; its base is #4519. -- Still required: complete ordered scenarios and result streams, independently reviewed current - coverage expectations, actual descriptive-name backport, curated repair/lock migration, typed - executable generation, monitoring, enabled gh issue publication and obsolete-path cleanup. - No core fixture/test naming migration or lock retirement has occurred. No merges are authorized. +Stack (PR head branches, each targeting its predecessor; the oldest targets `master`): #4512–#4530 +built the pipeline (see the checkpoints below); #4531–#4544 the curated repairs and form +migration (step 4); #4545 `audits-case-rules` → #4546 `audits-printed-constraints` → +#4547 `audits-legacy-references` → #4548 `audits-cutover-expressions` → #4549 `audits-cutover-stages` → +#4550 `audits-cutover-queries` → #4551 `audits-cutover-corrections` → #4552 `audits-int32-parameters` → +#4553 `audits-ordered-maps` → #4554 `audits-documented-collections` → #4555 `audits-gh-gateway` → +#4556 `audits-publisher` → #4557 `audits-candidates` → #4558 `audits-generator` → +#4559 `audits-monitoring` → #4560 `audits-retire` → #4561 `audits-since-audit` → +#4564 `audits-discovery-issues`. Nothing is merged; merging is the user's. +Use `git worktree list` to locate the checkouts on this machine. + +## Current status at a glance (2026-11-22) + +Every step of the plan (0–7) has been started. What stands: + +- **On the runner:** 346 legacy cases (345 converted, 1 migrated), plus 1 generated case. + Core gate: 662 tests under each mapper; audits: 448. +- **Generation:** inventory of mongodb/docs `e4b0c153` (197 pages read; 300 examples owned, + 32 unowned, 11 unnamed), reviewed DSL bindings checked against core's API, and the + candidate → integrate → promote path. One expressions case is generated, and three are + excluded with evidence. +- **Monitoring:** a weekly discovery workflow that re-inventories the docs, regenerates, + integrates, and files its findings as issues in this repository. +- **README:** an operating guide; the component detail moved to + [operator-audits-reference.md](operator-audits-reference.md). + +### Remaining work + +Waiting on reviews or decisions: +- **Independent review of #4553–#4564.** All were self-reviewed only: the reviewer was at its + weekly limit until 2026-11-26, and Codex and Copilot were out of quota. Run review rounds after + the reset. +- **`SinceAudit` (#4561):** the user keeps or deletes it. If it is declined, re-target #4564 + onto #4560. +- **#4563:** the user's reminder to report the `$bitOr` and `$dateDiff` page errors upstream. + Do not report them ourselves. + +Step 5, generation and cutover: +- **A resolver for tested code snippets** (`.. input:: /code-examples/...`). 103 pages, most + stage pages among them, are skipped without it. It is the largest unlock. +- **Bindings for the gaps** the weekly job files as issues (today `$match`, `$serializeEJSON`, + `$deserializeEJSON`, `$toObject`, `$reduce` `valueAs`). +- **Find and update generation.** Only aggregation pipelines are generated. +- **Reviewed names** for the 11 examples with generic titles. +- **The remaining legacy fixtures:** 210 directories. + - 98 are locked; 96 are unresolved in `form-review.json`. + - 28 are legacy-only in `cutover.json`, the `$graphLookup` pair among them (#4562, an + unordered-array comparison). + - 81 never-locked fixtures have no pinned reference. +- **Deferred cutover features:** documented projections (`findOptions`), indexes, alternative + commands, and `$topN`/`$bottomN`/`$fill` key order. + +Step 6, monitoring: +- **An accepted production baseline for capability discovery.** It is needed before + `MISSING_API`/`VERSION_ANNOTATION` findings can be published. +- **A capability-driven server matrix.** Integration runs only MongoDB 8.2. + +Step 7, retiring old paths: +- **Core's legacy fixture loader:** retire it after the remaining fixtures convert. +- **The legacy RST extractor:** retire it after the structured parser owns example extraction, + snippets included. +- **The frozen legacy documentation tables:** a separate documentation migration. Design: [mongodb-operator-audits.md](mongodb-operator-audits.md). The reviewed plan is committed as `3c78eb7b4cccf5c661bc2183d25cf3984ddda3ad`. @@ -2447,3 +2483,54 @@ no product-documentation changes. Legacy operator AsciiDoc tables are intentiona - `CandidatesTest` (5 cases): determinism and agreement with the tree, promotion, every refusal, rollback, and integration with a fake runner. - Review: the independent reviewer is at its weekly limit (resets 2026-11-26); self-reviewed. + +## Step 5 slice 7: inventory, bindings and generator (2026-11-22) + +- #4558, branch audits-generator. +- **Inventory.** `fetch.py current` lists every operator page at one mongodb/docs commit, and + `GenerateMainKt inventory` writes `audits/catalog/documented-examples.json`. + - Owners are matched by title, then by action text. + - Statuses are OWNED, UNOWNED, UNNAMED and AMBIGUOUS. Unowned examples keep their source text. + - `FormMigration.pageExamples` and `documented(label, shape, blocks)` were factored out for it. +- **Bindings.** `audits/catalog/dsl-bindings.json` has four forms: positional, named, projection + and fields. `DslBindings.verify` checks them against `MorphiaApiInventory` of core, captured + with core's Maven classpath plus `core/target/classes`. +- **Generator.** `CaseGenerator` emits one class per operator, between `spotless:off` and + `spotless:on`, plus one scenario per case, and `gaps.json`. `generation-review.json` names the + families and the exclusions. +- **First run.** `$add` passes. Three cases are excluded: + - `$bitOr`: the page prints `$bitAnd`'s results; + - `$dateDiff`: the page prints `1` for a long; + - `$filter` `$$IDX`: needs a server newer than 8.2. +- `FormMain manifest` now goes through `Candidates.manifest`, so generated cases survive a + manifest rewrite. + +## Step 6c: scheduled discovery (2026-11-22) + +- #4559, branch audits-monitoring. `.github/workflows/operator-discovery.yml` runs weekly and on + demand. It makes a sparse git clone of the docs, which avoids `GITHUB_TOKEN`'s API rate limit. +- It then runs `audits/discover.sh`: in a throwaway worktree, `fetch.py local`, `inventory`, + `candidate`, then `integrate`. It writes `summary.md` and uploads the reports for 90 days. +- A local run reproduced the committed inventory byte for byte and passed integration. + +## Step 7: README and SinceAudit (2026-11-22) + +- #4560, branch audits-retire. The README became an operating and troubleshooting guide, and the + component sections moved verbatim to `design/operator-audits-reference.md`. +- The README now accounts for the legacy paths still in use. Step 0 had already removed the + live-HTML discovery, the old publisher and writers, and the dead property files. +- #4561, branch audits-since-audit, is optional. It removes `SinceAudit`, its model, + `audit-classes.txt` and `asm-tree`. + +## Step 6d: discovery findings as issues (2026-11-22) + +- #4564, branch audits-discovery-issues. The workflow's Publish job (`issues: write`, with the + job token passed as `AUDITS_GITHUB_TOKEN`) runs `PublishMainKt discovery`. It files three + finding types: + - MISSING_BINDING, one per unbound node; + - NEW_EXAMPLE, an example new since the committed inventory; + - INTEGRATION_FAILURE. +- A sandbox test found that GitHub's listing lags new issues: a run with a fresh journal filed + duplicates. The job now restores the previous run's journal and runs in a concurrency group. + The duplicate-marker guard refused once the listing caught up. +- Filed alongside: #4562 (unordered-array comparison) and #4563 (the docs-error reminder).