From c3bde0bf77c5617438a09da96dfdae0541525b53 Mon Sep 17 00:00:00 2001 From: Timothy Date: Sat, 29 Aug 2026 21:16:16 +0200 Subject: [PATCH] fix(820): `.spec.ts` and setupTests.ts are TESTS, and three doc claims outlived their code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fifth review round. It recommends KEEPING the guard as narrowed, and blocks on two things, both one-line-shaped and both real. THE FALSE GREEN. `isProductionSource` excluded `*.test.ts` and nothing else, while vitest's own include is `**/*.{test,spec}.*` (`web/vite.config.ts`) — so a `*.spec.ts` file was a TEST to the runner and PRODUCTION to this predicate. Measured by the reviewer at the previous head: strip `Complete<>` from `MultiCollectionsScreen.toItemRequest` (the only production site for `MultiCollectionItemRequest`, and the exact pre-#807 form), add a `.spec.ts` holding a `Complete` fixture, and typecheck plus all 1309 tests stayed green with the real builder unprotected. `src/setupTests.ts` did the same. This is the bypass an earlier round blocked on, closed only for the `.test.` spelling — and the guarantee is stated in four places, so it had to be true in every spelling vitest accepts. Both bypasses now redden; witnessed. THE DOC CLAIMS. The record's residue paragraph still said the guard "derives the write wrappers from the SPA AST, so reverting a wrapper now reddens" — machinery deleted last commit, and the claim measured false. Already fixed in 2cb7bd0d6, which the review predates; what survived it was the paragraph five lines above, opening "Since #820 the WRAPPER half is checked". It is the SCHEMA half. Also a duplicated clause in the frontmatter `mechanics:` left by the narrowing — the copy that gets mirrored out of context — and a stale ordinal in the guard-inventory prose. ALSO CLOSED, from the same review: - An `allOf` schema emits as an intersection, which `scanOptionalSchemaMembers` skipped silently. That is the one non-object shape that HIDES members rather than having none, so it now throws, matching what the surrounding code already did for computed and duplicate keys. The 54 enum-shaped schemas it legitimately skips have nothing to drop; a fixture pins both halves. - The Python cross-check floored the TS parse but not its own table, so an empty Python table would collect zero parametrised cases and pass having compared nothing. It was covered only by the neighbour file's floor — borrowing the property rather than holding it. - The population ratio floor was 0.9 against an actual 0.985, admitting a silent ~22-file narrowing. Now 0.95. - Recorded the residual this guard shares with its sibling: every population here derives from `trackedSources.tracked`, so a narrowing inside the Vite plugin cancels out of every comparison, and it is the sibling guard that polices that. Verified: web 1311 tests green, scripts/tests 1241 green (2 skipped), typecheck + eslint + ruff clean, decisions-validate OK, inventory counts machine-checked. Decisions-Edit: yes Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01UYNbVwgVszv6Pum7ZuGd75 --- .../testing/full-replace-asserts-field-list.md | 4 ++-- docs/guard-inventory.md | 6 +++--- .../test_complete_annotation_dispositions.py | 11 +++++++++++ web/src/api/completeAnnotationScan.test.ts | 10 ++++++++++ web/src/api/completeAnnotationScan.ts | 12 ++++++++++++ web/src/api/completeAnnotations.guard.test.ts | 15 +++++++++------ 6 files changed, 47 insertions(+), 11 deletions(-) diff --git a/docs/decisions/records/testing/full-replace-asserts-field-list.md b/docs/decisions/records/testing/full-replace-asserts-field-list.md index b78358ee0..206e513ab 100644 --- a/docs/decisions/records/testing/full-replace-asserts-field-list.md +++ b/docs/decisions/records/testing/full-replace-asserts-field-list.md @@ -7,7 +7,7 @@ supersedes: none superseded-by: none rule: 'Any path that writes a WHOLE entity or a WHOLE child collection — a PUT-replace handler, a hand-built request object, a test comparer standing in for one — derives its field list from the authoritative type and asserts SET EQUALITY against it, rather than enumerating the fields by hand. A hand-written list is correct on the day it is written and structurally unable to report the day it stops being: the field that drifts is the one nobody wrote a line for, so no amount of care in the existing lines can reach it. The failure is silent by construction — a full replace with a field omitted returns HTTP 200 and destroys that field''s value (#754 drifted from a 28-property DTO by one and cleared it; the symptom arrived hours later as missing pixels). SECOND CLAUSE, separable from the first: where a replaced child row carries state keyed to its identity — progression, ordering, an enumerator position — the handler RECONCILES BY ID rather than delete-and-reinsert, because reinsertion silently resets state a client never asked to touch (#252: a schedule PUT reset fill-group progression; #500: a dedup fix became permanent data loss because the add filter and the remove filter used different keys, so the two halves must agree on the key). Delete-and-reinsert is acceptable ONLY where no such state exists, and that emptiness is a fact about today''s schema that a later feature can silently invalidate — so record it where the handler is, dated, rather than leaving it to be re-derived. The canonical worked example is `ToolCatalogTests.Every_Write_Tool_Should_Declare_Exactly_Its_OpenApi_Request_Body_Fields`, which reads the accepted fields from the generated OpenAPI document and compares both directions. ON THE SPA SIDE the same rule is enforced by the TYPE SYSTEM rather than by a test: a full-replace body is built as `Complete` (`web/src/api/completeRequest.ts`), a mapped type that makes every member of a generated request type required, so a builder that omits one fails `npm run typecheck`. Annotate BOTH the API-wrapper parameter (so later callers inherit it) AND each construction site including every `.map` callback return type, because the excess-property check that catches a PHANTOM field fires only on a fresh literal in a contextually typed position and a generic `.map` callback is not one. Do not infer from "most builders already typecheck" that the gap is closed: a member is omittable exactly when it is absent from the schema `required` array in the ASP.NET-produced OpenAPI document, and two live cases (#807) sat unchecked inside a large majority of checked ones.' signals: 'full replace asserts its field list · hand-maintained mirror drifts by one field · reconcile by id not delete and reinsert · 200 and the field is gone · add filter and remove filter must share a key · fill-group progression reset by a PUT · derive the comparer from the DTO · a lossless round-trip test that is itself a hand-copied list · anti-vacuity PIN not a floor on a reflective walk · stale exemption must still name a real property · a complete comparer over a hand-written fixture · universal negative in a record is a trap · the SPA builds a full-replace body as `Complete` · a member is omittable only when it is absent from the OpenAPI `required` array · excess-property checking does not fire inside a generic `.map` callback · a comment warning about a silent reset is not a check · `weight` · `qsvPreferNativeDecoder` · paths: `ErsatzTV.Tests/Application/ProgramSchedules/ScheduleItemResponseRoundTripTests.cs`, `ErsatzTV.Mcp.Tests/ToolCatalogTests.cs`, `ErsatzTV.Application/ProgramSchedules/Commands/ReplaceProgramScheduleItemsHandler.cs`, `web/src/api/completeRequest.ts`, `web/src/api/completeRequest.guard.test.ts` · issues: #807, #779, #773, #757, #754, #500, #252' -mechanics: 'Detector G of `docs/defect-shapes-773.md` §4. Enforced per-site by a reflective comparison over the DTO plus a written-down count pin, not by a repo-wide check — see the record body for why a global one is not proposed. The exemption set is empty today; the machinery guarding exemptions remains for the first one that earns its place. ON THE SPA SIDE the same rule is carried by the type system (`Complete`, `spa.full-replace-complete` in `docs/spa-conventions.md` §4b), and since ersatztv#820 its APPLICATION is checked rather than assumed: `web/src/api/completeAnnotations.guard.test.ts` derives the droppable schemas from the generated `v1.d.ts` and the annotations from the SPA AST, asserts set equality between the droppable SCHEMAS and a reviewed disposition table, requires a PRODUCTION annotation naming each schema that can drop a member (a test-file annotation does not discharge it), forbids one on the schemas where annotating is a bug, cross-checks its disposition values against this file''s table from the Python side, and is per-SCHEMA rather than per-site or per-wrapper — a wrapper-level rule was built and REMOVED before merge after four review rounds each defeated it, requires a production annotation per droppable schema, forbids one on the server-computed schemas, and rejects a `Complete` over a hand-written mirror rather than a generated alias. Before it, `scripts/tests/test_optional_request_members.py`''s COVERED disposition ASSERTED the annotation existed and nothing verified it. Residual: the per-CONSTRUCTION-SITE population is not derived (sites in code, #777), so the phantom direction still rests on the §4b site rule and on review.' +mechanics: 'Detector G of `docs/defect-shapes-773.md` §4. Enforced per-site by a reflective comparison over the DTO plus a written-down count pin, not by a repo-wide check — see the record body for why a global one is not proposed. The exemption set is empty today; the machinery guarding exemptions remains for the first one that earns its place. ON THE SPA SIDE the same rule is carried by the type system (`Complete`, `spa.full-replace-complete` in `docs/spa-conventions.md` §4b), and since ersatztv#820 its APPLICATION is checked rather than assumed: `web/src/api/completeAnnotations.guard.test.ts` derives the droppable schemas from the generated `v1.d.ts` and the annotations from the SPA AST, asserts set equality between the droppable SCHEMAS and a reviewed disposition table, requires a PRODUCTION annotation naming each schema that can drop a member (a test-file annotation does not discharge it), forbids one on the schemas where annotating is a bug, cross-checks its disposition values against this file''s table from the Python side, and is per-SCHEMA rather than per-site or per-wrapper — a wrapper-level rule was built and REMOVED before merge after four review rounds each defeated it. It also rejects a `Complete` over a hand-written mirror rather than a generated alias. Before it, `scripts/tests/test_optional_request_members.py`''s COVERED disposition ASSERTED the annotation existed and nothing verified it. Residual: the per-CONSTRUCTION-SITE population is not derived (sites in code, #777), so the phantom direction still rests on the §4b site rule and on review.' --- **This is `testing.guard-derives-population-from-source` applied to a write path, and it is worth its @@ -161,7 +161,7 @@ it exists, and at each construction site, which is what keeps TypeScript's exces (the *phantom* direction) alive. That is the rule, not a claim about how much of the tree currently follows it. The two halves are -enforced UNEQUALLY, and the split is the thing to know. Since #820 the WRAPPER half is checked: +enforced UNEQUALLY, and the split is the thing to know. Since #820 the SCHEMA half is checked: `web/src/api/completeAnnotations.guard.test.ts` derives the droppable schemas from the generated types and the annotations from the SPA AST, and fails when a schema that can drop a member is named by no PRODUCTION `Complete<…>`. It is per-SCHEMA: it catches the annotations being deleted, not one diff --git a/docs/guard-inventory.md b/docs/guard-inventory.md index ba9ca6099..dfc5d1fa6 100644 --- a/docs/guard-inventory.md +++ b/docs/guard-inventory.md @@ -70,8 +70,8 @@ with have sat in these gaps. Treat anything not named here as unassessed, not as hand-written covered set), `ErsatzTV.Mcp.Tests/ToolCatalogTests.cs`, `web/src/api/pageSizeCallSites.guard.test.ts`, `web/src/api/completeRequest.guard.test.ts`, `web/src/api/completeAnnotations.guard.test.ts` - (ersatztv#820 — the sixth entry, and the second time this hand-written list has had to be - extended by hand), and the pair + (added by ersatztv#820 — the second time this hand-written list has had to be extended by hand), + and the pair `web/vite-plugins/trackedSourceFiles.test.ts` + its `.realgit.test.ts` sibling, which together prove the population `pageSizeCallSites.guard.test.ts` derives (split because the `realgit` half needs the git BINARY, which the Docker web-build stage has not got). Note what that costs: this @@ -172,7 +172,7 @@ The audit #806 asked for, recorded whichever way it came out, because "we looked | `test_pr_changed_files.py` | `.gitea/workflows/*.y*ml` | **yes** — "no OTHER workflow writes the review-verdict status", and since ersatztv#748 "every tracked workflow declares a `permissions:` block", with NO exemption list (the one `ci-image.yml` briefly needed was deleted when #744 landed, per #835) | converted. Not on #806's list: an untracked `.yaml` dropped in `.gitea/workflows/` reddened two guards while absent from the index — the issue's list of files to assess was a starting point, not the population | | `test_workflow_persist_credentials.py` | `.gitea/workflows/*.yml` + `*.yaml` | **yes** — every `actions/checkout` in every workflow must drop the persisted credential | derived from the index from the start (#835). Shipped with NO exemption list, which is why it waited for #744: the one non-compliant checkout would otherwise have bought a permanent entry that keeps passing after its reason expires | | `web/src/api/pageSizeCallSites.guard.test.ts` | `import.meta.glob` over `web/src/**/*.{ts,tsx,mts,cts}`, INTERSECTED with the git index | **yes** — an unregistered discovered site fails | converted under #819. The population is the glob INTERSECTED with the git index, and the walk/index divergence is asserted in BOTH directions WITHIN a shared scope: a key the index does not carry is dropped, and a tracked, on-disk, in-scope path that never reached the scanner FAILS rather than shrinking the population silently (that direction catches a dotfile, which the glob cannot match, and a disk/index spelling divergence, which `core.ignorecase` and NFD/NFC normalisation make permanent). The SCOPE itself cancels out of that equality — both sides call one `isInScopeSourcePath` — so narrowing it moves both sets together and no assertion comparing the two sides can see it. That is closed separately, by re-deriving the predicate from its two components over the whole tracked index (`the shared scope predicate is EXACTLY its two documented components`). Two mechanisms carry that. FIRST, the scope predicate is proved by a CLOSED-FORM restatement — it may share no helper, at any depth, with the predicate it checks, since anything shared sits on both sides of the comparison and cancels. FOUR earlier attempts were each measured going green while removing real files: a table of example paths (four of `src/`'s eight directories, missed a 23-file narrowing), a decomposition delegating its filename half to `isScannableSourceFileName` (11 files), one still sharing a `basename` helper (15 files, and blind to a planted call site), and one still sharing the tracked-file array every comparison was derived from (8 files, also blind). SECOND — because that last one showed a restatement cannot police the population it reads — the plugin runs a separate `git ls-files --others` query and the guard requires every in-scope walked path to appear in `tracked ∪ others`; narrowing `tracked` cannot suppress that, since it adds nothing to `others`. SIX residuals, NOT a claim of closure, each with its direction MEASURED by planting a real `pageSize` call site rather than reasoned about. FAIL-NOISY (they redden a checkout; they cannot hide a call site): (2) a scope term matching no tracked path today survives until the day it first matches one; (4) the WIRING in `listSourceFiles`, indistinguishable on a clean checkout where the walk set and the index set agree on every in-scope key (they are not literally equal — the index also carries `.css`, which the glob never yields), so no assertion COMPARING THE TWO POPULATIONS can tell which is passed; (5) `ABSENT_FROM_DISK` emptied. BLIND — each hid a planted `pageSize: 100` with the whole suite green: (1) a COORDINATED edit of the scope predicate and BOTH closed-form restatements, which is three sites and not two, since a second restatement guards `expectedTrackedSources` (measured: the two-site edit reddens, the three-site edit does not) — tolerated because a three-site policy edit is review-visible in a way a one-line slip is not; and (3) a misdescription by the plugin's THREE outputs — not only a mispartition of `tracked`/`others`, which preserves the union any consumer compares, but a FATTENED `absentFromDisk`, which subtracts real files from the hole-detection direction. The fattening is now caught wherever it overlaps a file the walk found (a walked path is on disk by construction, so it can never be legitimately absent); restricted to paths the walk cannot see anyway — a dotfile, a case-divergent name — it stays invisible from the consuming side and is answerable only by testing the derivation directly, and the real-git tests that do so catch an UNCONDITIONAL misdescription, not one keyed on a path pattern. Neither blind residual is tolerated for being harmless. A sixth is specific to WATCH mode and is stale in BOTH directions, so it belongs to neither group: the virtual module has no backing file, so the index is read once per dev-server lifetime while the glob refreshes. A file CREATED mid-session reddens the cross-check misleadingly (noisy); a file already UNTRACKED when the watcher started keeps that classification when staged mid-session, so its call sites are never scanned — MEASURED green across both phases while `npx vitest run` on the same tree reports `UNREGISTERED`, i.e. blind, and a window that did not exist before #819 because the population was then the walk. A watch-mode green is therefore not authoritative for this guard; restarting the watcher clears the noisy case and opens the blind one, so the remedy is `npm test -- --run`. Invalidating the module from `configureServer` was implemented, measured and REJECTED: it fixes the created-mid-session red and additionally blinds the create-then-stage sequence, while the already-untracked-then-staged sequence is blind either way, since `git add` fires no watcher event in either design. The index is read by `web/vite-plugins/trackedSourceFiles.ts` in Vite's own Node context and handed to the app project as the virtual module `virtual:etv-tracked-source-files`. That is what reaches the index without admitting `@types/node` to `tsconfig.app.json` — the obstacle that deferred this, since wiring those types in was tried and reverted (it leaked Node's `setTimeout` into the app project and broke three unrelated tests). The plugin throws rather than falling back to the unfiltered walk when git fails, reports zero files, or cannot learn the Vite root. Residual, stated: a file tracked but DELETED in the working tree is subtracted deliberately, since an unstaged deletion is a normal developer state and a guard red on one gets ignored (#806); it is distinguished from the hole cases above by an on-disk existence check, not conflated with them | -| `web/src/api/completeAnnotations.guard.test.ts` | TWO derived populations: the `Complete<…>` annotations across `web/src/**/*.{ts,tsx,mts,cts}` INTERSECTED with the git index, and the droppable SCHEMAS parsed out of the generated `src/api/generated/v1.d.ts` | **partial, and the split is stated** — set equality holds for the SCHEMA population (a new optional member fails until dispositioned) and every tracked in-scope path must be supplied by the glob; there is NO closed-form restatement of the scope predicate, so a coordinated edit to it is caught by five named path pins rather than by a completeness proof | ersatztv#820. Turns `test_optional_request_members.py`'s `COVERED` disposition — worded "the builder is annotated `Complete`", a claim about ANOTHER LANGUAGE'S source that nothing checked — into a check, and makes `docs/spa-conventions.md` §4b's prohibitions executable as asserted ABSENCES. It found one live defect: `playouts.ts` declared two request types as hand-written mirrors SHADOWING generated schemas of the same name, so their `Complete<>` was checking a local copy rather than the contract. **NARROWED after four BLOCKED review rounds, and the narrowing is the point.** It originally also derived the write WRAPPERS and required the annotation on the wrapper parameter. Every blocker across those rounds came out of that one mechanism — the obligation attached to the wrong population; reachability mistaken for protection (`Complete` is shallow, so a wrapper annotation never reached a nested schema); body discovery keyed on a parameter NAME, then on parameter-versus-local; and finally an `export function` -> `export const` refactor that removed real protection while both the AST scan and its supposedly independent regex cross-check stayed blind TOGETHER, because both keyed on the same token. Five defects from one mechanism is the `process.enumerate-workaround-behaviors-before-deleting` signal to remove it rather than patch a sixth time, and ~250 lines went with it. WHAT IS NOT COVERED, listed because the earlier version of this row stated residuals in the direction that was actually covered: (1) the obligation is per-SCHEMA, not per-SITE and not per-WRAPPER — deleting the `Complete<>` from an API wrapper stays green as long as some production file still names that schema, so the wrapper half of §4b rests on review; (2) it is a TOKEN-PRESENCE check, so a dead `export type X = Complete` that nothing uses discharges the obligation as well as a live builder does — it catches deletion, which is the failure actually observed in #807, not substitution; (3) the PHANTOM direction needs a fresh literal in a contextually typed position and is not checked at all (sites-in-code, #777); (4) a MUST-NOT-ANNOTATE violation inside a `*.guard.test.ts` is not seen, since that file class is excluded to keep `completeRequest.guard.test.ts`'s synthetic `Complete<{…}>` fixtures out of the resolver. The disposition VALUES are cross-checked against the authoritative Python table by `scripts/tests/test_complete_annotation_dispositions.py` — without it, flipping one row from `ANNOTATED` to `CREATE` silently retired the requirement, which cold review demonstrated. Nine mutations were witnessed by hand across development, NOT re-executed per suite, so this guard claims no standing `MUTATION` grade — the same footing as `pageSizeCallSites.guard.test.ts` | +| `web/src/api/completeAnnotations.guard.test.ts` | TWO derived populations: the `Complete<…>` annotations across `web/src/**/*.{ts,tsx,mts,cts}` INTERSECTED with the git index, and the droppable SCHEMAS parsed out of the generated `src/api/generated/v1.d.ts` | **partial, and the split is stated** — set equality holds for the SCHEMA population (a new optional member fails until dispositioned) and every tracked in-scope path must be supplied by the glob; there is NO closed-form restatement of the scope predicate, so a coordinated edit to it is caught by five named path pins rather than by a completeness proof | ersatztv#820. Turns `test_optional_request_members.py`'s `COVERED` disposition — worded "the builder is annotated `Complete`", a claim about ANOTHER LANGUAGE'S source that nothing checked — into a check, and makes `docs/spa-conventions.md` §4b's prohibitions executable as asserted ABSENCES. It found one live defect: `playouts.ts` declared two request types as hand-written mirrors SHADOWING generated schemas of the same name, so their `Complete<>` was checking a local copy rather than the contract. **NARROWED after four BLOCKED review rounds, and the narrowing is the point.** It originally also derived the write WRAPPERS and required the annotation on the wrapper parameter. Every blocker across those rounds came out of that one mechanism — the obligation attached to the wrong population; reachability mistaken for protection (`Complete` is shallow, so a wrapper annotation never reached a nested schema); body discovery keyed on a parameter NAME, then on parameter-versus-local; and finally an `export function` -> `export const` refactor that removed real protection while both the AST scan and its supposedly independent regex cross-check stayed blind TOGETHER, because both keyed on the same token. Five defects from one mechanism is the `process.enumerate-workaround-behaviors-before-deleting` signal to remove it rather than patch a sixth time, and ~250 lines went with it. WHAT IS NOT COVERED, listed because the earlier version of this row stated residuals in the direction that was actually covered: (1) the obligation is per-SCHEMA, not per-SITE and not per-WRAPPER — deleting the `Complete<>` from an API wrapper stays green as long as some production file still names that schema, so the wrapper half of §4b rests on review; (2) it is a TOKEN-PRESENCE check, so a dead `export type X = Complete` that nothing uses discharges the obligation as well as a live builder does — it catches deletion, which is the failure actually observed in #807, not substitution; (3) the PHANTOM direction needs a fresh literal in a contextually typed position and is not checked at all (sites-in-code, #777); (4) a MUST-NOT-ANNOTATE violation inside a `*.guard.test.ts` is not seen, since that file class is excluded to keep `completeRequest.guard.test.ts`'s synthetic `Complete<{…}>` fixtures out of the resolver. The disposition VALUES are cross-checked against the authoritative Python table by `scripts/tests/test_complete_annotation_dispositions.py` — without it, flipping one row from `ANNOTATED` to `CREATE` silently retired the requirement, which cold review demonstrated. Nine mutations were witnessed by hand across development, NOT re-executed per suite. A fifth residual, shared with its sibling: every population here is derived from `trackedSources.tracked`, so a narrowing inside `web/vite-plugins/trackedSourceFiles.ts` would cancel out of every comparison — this guard never reads the plugin's separate `others` query, and relies on `pageSizeCallSites.guard.test.ts` and `trackedSourceFiles.test.ts` policing the plugin, so this guard claims no standing `MUTATION` grade — the same footing as `pageSizeCallSites.guard.test.ts` | | `test_ci_release_path_scan_job.py` | `.gitea/workflows/*.y*ml` + `scripts/**` | **no** — a fixture assembling a tmp harness, asserted about behaviour not membership | takes its file LIST from the index anyway, for hermeticity not completeness: `shutil.copytree` copied whatever was on disk, including untracked files and `scripts/__pycache__`, into a tree whose behaviour the probes then measure. Content still comes from the working tree. The copy is not a git repo, so the two files this step RUNS may not use the helper — see the fixture docstring | | `test_ci_dropped_step_guard.py` | the parsed workflow document (its OWN subject only — the release-path `scan` job runs it in a non-git copy, so it may not derive from the index) | **no filesystem population at all** | unchanged by #806; the SCOPE residual it left open — `MARKED_JOBS` as a hand-written mirror of the required contexts on `main` — was closed by #787, which derives it from `.gitea/required-status-contexts.json` and reconciles that snapshot against the server in `scripts/check-required-contexts.sh`. The cross-workflow half of that claim lives in `test_ci_status_context_uniqueness.py`, which CAN use the index | diff --git a/scripts/tests/test_complete_annotation_dispositions.py b/scripts/tests/test_complete_annotation_dispositions.py index de63cb068..cc6370020 100644 --- a/scripts/tests/test_complete_annotation_dispositions.py +++ b/scripts/tests/test_complete_annotation_dispositions.py @@ -116,6 +116,17 @@ def test_the_TS_table_is_parseable_at_all() -> None: assert set(ts.values()) <= {"ANNOTATED", "MUST-NOT-ANNOTATE", "CREATE", "TRIGGER", "RESPONSE-ONLY"} +def test_the_PYTHON_table_is_non_empty_too() -> None: + """The TS side has a floor; without one here the comparisons are still vacuous from the other end. + + Every check below iterates the Python table. An empty one collects zero parametrised cases and + makes the missing-schema check pass over an empty set — green, having compared nothing. The + neighbour file has its own floor, but a guard that depends on a neighbour's floor for its own + anti-vacuity is borrowing the property rather than holding it. + """ + assert len(_python_dispositions()) >= 5 + + def test_the_inline_body_exemption_stays_small_and_shaped() -> None: """The exemption above is a shape test; this bounds how much it can be carrying.""" exempt = sorted(s for s in _python_dispositions() if not _comparable(s)) diff --git a/web/src/api/completeAnnotationScan.test.ts b/web/src/api/completeAnnotationScan.test.ts index a007215b9..e81637428 100644 --- a/web/src/api/completeAnnotationScan.test.ts +++ b/web/src/api/completeAnnotationScan.test.ts @@ -143,6 +143,16 @@ describe('scanOptionalSchemaMembers — unreadable shapes FAIL rather than silen expect(() => scanOptionalSchemaMembers(wrap(' "A": { ["computed"]?: string };'))).toThrow(/computed key/); }); + it('throws on an INTERSECTION schema (`allOf`) rather than dropping its members', () => { + // The one non-object shape that can HIDE members instead of having none. The 54 enum-shaped + // schemas skipped in the real file are string unions and literals, which have nothing to drop. + expect(() => scanOptionalSchemaMembers(wrap(' "A": ComponentA & ComponentB;'))).toThrow(/intersection/); + }); + + it('still skips an enum-shaped schema quietly, which has no members to drop', () => { + expect(scanOptionalSchemaMembers(wrap(' "A": "x" | "y";')).size).toBe(0); + }); + it('ignores a `schemas` member on an interface that is not `components`', () => { // The unconstrained form let a `declare module` block overwrite a real schema with an empty // optional list — a droppable schema removed from the population with nothing reddening. diff --git a/web/src/api/completeAnnotationScan.ts b/web/src/api/completeAnnotationScan.ts index f0dd0873d..e56b923bd 100644 --- a/web/src/api/completeAnnotationScan.ts +++ b/web/src/api/completeAnnotationScan.ts @@ -214,6 +214,18 @@ export function scanOptionalSchemaMembers(dtsText: string): Map application guard (#820)', () => { ).toEqual([]); }, 20000); - - - it('scans nearly ALL tracked TypeScript, so a scope edit cannot quietly drop a quarter of it', () => { // Named pins catch a narrowing that happens to hit one of five files; cold review dropped 65 of // 257 files with every pin and floor still green. This bounds the whole population instead. @@ -375,7 +378,7 @@ describe('Complete application guard (#820)', () => { // both sides of a comparison cancels out of it, which is the #819 finding recorded at length in // the pageSize guard. It is a different and cruder expression — every tracked TypeScript file — // so the two can actually disagree. The legitimate gap between them is only `/generated/` and - // `*.guard.test.ts`, a few per cent, hence the 90% floor. + // `*.guard.test.ts`, about 1.5% today, hence the 95% floor. const trackedTypeScript = trackedSources.tracked.filter((p) => /\.(ts|tsx|mts|cts)$/.test(p)); const scanned = trackedInScopeSources().length; expect(trackedTypeScript.length).toBeGreaterThan(200); @@ -384,7 +387,7 @@ describe('Complete application guard (#820)', () => { `only ${scanned} of ${trackedTypeScript.length} tracked TypeScript files reached the scanner. ` + `The scope predicate excludes \`/generated/\` and \`*.guard.test.ts\` and nothing else, so a ` + `larger shortfall means it was narrowed.` - ).toBeGreaterThan(0.9); + ).toBeGreaterThan(0.95); }, 20000); it('keeps the modules carrying the motivating defects inside the scanned population (scope pin)', () => {