Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

Commit efead6c

Browse files
claude[bot]claude
andauthored
feat(ci): differential gate for newly added cross-file line citations, and retire two stored line-number ledgers (objectui#8875) (#8974)
Ruling C on objectui#8875, clauses 2, 3 and 5. Clause 1 (the convention text in AGENTS.md) is a governed surface and lands as a separate, human-merged PR. Clause 2 — a DIFFERENTIAL gate. `scripts/check-new-cross-file-line-citations.mjs` reports the cross-file line-address citations a pull request ADDS, against its merge base. The 540 existing citations are not its denominator and it sweeps none of them. An absolute count was refused on a measurement: PR #8887's line shifts flipped one citation from `drifted` to `resolves` by accident, moving the tree-wide false count 540 -> 539, an unearned green that belonged to nobody. It ships report-only (`ENFORCEMENT`), wired into its own workflow so it can see the markdown-, docs- and changeset-only pull requests `lint.yml` short-circuits. Its four synthetic controls are fatal in both modes — a differential gate that reports zero through a broken differ is indistinguishable from a clean branch. `unresolvable` (chiefly regenerated `dist/*.d.ts`) is a third verdict and is never counted false. Clause 3 — the two stored ledgers stop storing line numbers. `UNGATED_EXAMPLES` is re-keyed from `path:line symbol` to `path symbol #ordinal`, and the zh-only family citations in the designer-table parity gate become `{ file, anchor }` with the anchor asserted present in the file exactly once. Behaviour-preserving on today's tree, proven by before/after runs: the doc-example gate's whole report is byte-identical, and 89 of 89 ledger rows map onto the new keys with unchanged values. Clause 5 — the firing control the ruling asked to keep is intact, but not at the address the ruling gives. Reported on the card. Claude-Session: https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr Co-authored-by: Claude <noreply@anthropic.com>
1 parent ad66d79 commit efead6c

11 files changed

Lines changed: 1445 additions & 107 deletions
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Line Citation Gate
2+
3+
# The DIFFERENTIAL cross-file line-address citation gate (objectui#8875, ruling
4+
# clause 2). It reads what THIS pull request ADDED against its base — never a
5+
# tree-wide total. An absolute count was explicitly refused: PR #8887's line
6+
# shifts flipped one citation from `drifted` to `resolves` by accident, moving
7+
# the tree-wide false count 540 -> 539, and that unearned green belonged to
8+
# nobody. The 540 existing citations are not this gate's denominator.
9+
#
10+
# ── REPORT-ONLY, and the workflow does not decide that ───────────────────────
11+
# The enforcement state lives in the script (`ENFORCEMENT`), not here, so there
12+
# is one place to read it and one place to flip it. Report-only means findings
13+
# exit 0; a failed CONTROL still exits 1 in both modes, because a differential
14+
# gate reporting zero through a broken differ is indistinguishable from a clean
15+
# branch — the failure this card names one level up.
16+
#
17+
# ── Why its own workflow rather than a step in `lint.yml` ────────────────────
18+
# `lint.yml` decides inside the job whether the change "needs a full run", and
19+
# its exclusion list skips every expensive step on a markdown-only, docs-only or
20+
# changeset-only change. Those are precisely the changes that carry citations:
21+
# the ruling names 注释、消息串、文档、changeset、脚本 in that order. A gate
22+
# that cannot see the pull request shape most likely to trip it rebuilds the
23+
# hole it exists to close — the same conclusion `shell-escape-residue.yml`,
24+
# `docs-links.yml`, `control-bytes.yml` and `changeset-presence.yml` each
25+
# reached in their own headers. One gate, one home.
26+
#
27+
# Hence no `paths` and no `paths-ignore`, deliberately.
28+
#
29+
# ── Why `pull_request` only ──────────────────────────────────────────────────
30+
# This gate needs a BASE to be differential at all, and only a pull request has
31+
# one. It is therefore ⛔ not requirable while it is report-only, and
32+
# `scripts/dependabot-merge-gate.mjs` classifies it in `NOT_A_GATE` with that
33+
# reason. When `ENFORCEMENT` flips to `blocking` this workflow owes a
34+
# `merge_group` leg before the context may be required — a required check that
35+
# does not report on a queue build stalls the queue until the ruleset's
36+
# 60-minute timeout fails it (objectui#3523).
37+
#
38+
# It needs no install and no build: a checkout plus one `node` call over this
39+
# branch's own diff. Keep it that way; the import graph is node builtins plus
40+
# repo-relative modules only, which `pre-install-import-graph.yml` enforces.
41+
42+
on:
43+
pull_request:
44+
branches: [main, develop]
45+
workflow_dispatch:
46+
47+
concurrency:
48+
group: line-citation-gate-${{ github.event.pull_request.number || github.ref }}
49+
cancel-in-progress: true
50+
51+
permissions:
52+
contents: read
53+
54+
jobs:
55+
line-citation-gate:
56+
name: Line Citation Gate
57+
runs-on: ubuntu-latest
58+
timeout-minutes: 5
59+
60+
steps:
61+
# `fetch-depth: 0` is load-bearing, not caution: the gate resolves the
62+
# merge base with the target branch, and a shallow clone cannot. When it
63+
# cannot, the gate exits 2 naming PREREQUISITE NOT MET rather than
64+
# printing a zero — "the diff could not be computed" must never be
65+
# indistinguishable from "nothing was added" (objectstack#4928).
66+
- name: Checkout code
67+
uses: actions/checkout@v7
68+
with:
69+
fetch-depth: 0
70+
71+
- name: Setup Node.js
72+
uses: actions/setup-node@v7
73+
with:
74+
node-version: '22.x'
75+
76+
- name: Report cross-file line-address citations this pull request adds
77+
env:
78+
CITATION_GATE_BASE: origin/${{ github.event.pull_request.base.ref }}
79+
run: node scripts/check-new-cross-file-line-citations.mjs

‎content/docs/guide/ci-cd-pipeline.md‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ one has its own section below.
4141
| `shell-escape-residue.yml` | Shell Escape Residue Scan | Push / PR to `main`, `develop` — **no path filter**; merge-queue builds; manual | **Yes** — when a fenced block in `AGENTS.md`, `CLAUDE.md`, `skills/**` or `content/docs/**` carries the enumerated machine-produced shell escape, or a scan root fails to resolve |
4242
| `readme-exports.yml` | README Export Check | Push / PR to `main`, `develop` — **no path filter**; merge-queue builds; manual | **Yes** — when a `packages/**/README.md` imports a name from its own package that the package does not export, or the scan's population collapses |
4343
| `docs-route-eager-closure.yml` | Docs Route Eager Closure Check | Push / PR to `main`, `develop` — **no path filter**; merge-queue builds; manual | **Yes** — when a package named in `apps/site/app/components/registerCatalogBlocks.ts` is not already reachable from the docs route's module graph (exit 1), or when the gate's own gauge cannot be trusted (exit 2) |
44+
| `line-citation-gate.yml` | Line Citation Gate | PR to `main`, `develop` — **no path filter**; manual | No — **report-only** while it beds in; it exits 0 whatever it finds, and exits 1 only when one of its own synthetic controls fails. It declares no `merge_group` trigger, so it cannot be a required context in its current state |
4445
| `governed-surface-guard.yml` | Governed Surface Queue Guard | PR to `main`, `develop` (incl. `ready_for_review`) — **no path filter**; merge-queue builds | **Yes on a queue build only** — a governed-surface diff with no authorized approval record (on any commit) is refused there; on the pull request itself it is deliberately green and prints an early warning |
4546
| `performance-budget.yml` | Bundle Analysis | Push / PR touching `packages/**`, `apps/console/**`, `pnpm-lock.yaml` | **Yes** — the console entry gzip budget |
4647
| `lockfile-integrity.yml` | Lockfile Integrity Check | PR to `main`, `develop` touching `pnpm-lock.yaml` or the gate's own two files; manual | No — **deliberately not a blocking context** ([#8326](https://github.com/objectstack-ai/objectui/issues/8326)); it names the packages and the Dependabot merge gate classifies it `NOT_A_GATE` |
@@ -1597,6 +1598,78 @@ workflow runs as its own first step because a rotted predicate must redden rathe
15971598
governed diff through, and the wiring is pinned by
15981599
`scripts/__tests__/check-governed-queue-guard.test.ts`.
15991600

1601+
## Line Citations (`line-citation-gate.yml`)
1602+
1603+
**Triggers:** Pull requests to `main`/`develop`, with **no path filter**, plus manual dispatch. It
1604+
appears in the checks list as **Line Citation Gate**.
1605+
1606+
**What it runs:** `node scripts/check-new-cross-file-line-citations.mjs` — one `node` call over the
1607+
pull request's own diff. No install, no build.
1608+
1609+
**Report-only.** This step **exits 0 regardless of what it finds**. It is not a required context, it
1610+
declares no `merge_group` trigger, and `scripts/dependabot-merge-gate.mjs` classifies it
1611+
`NOT_A_GATE` for that reason. The one thing that does make it exit 1 is a failure of its own
1612+
synthetic controls — a differential gate reporting zero through a broken differ is indistinguishable
1613+
from a clean branch, so the instrument is checked on every run.
1614+
1615+
### What it reads, and the word that decides its shape
1616+
1617+
The maintainer ruled the class on 2026-09-10, verbatim: 「跨文件的「某文件第几行」引用,
1618+
这种完全没必要吧,是否应该避免」. A cross-file line address points somewhere the reader is not
1619+
looking, and nothing tells them when it moves. Five spellings are read, written here with `NNN`
1620+
standing in for the digits **on purpose** — a real address in this paragraph would be one more
1621+
citation for the gate to report, which is the shape of the problem rather than a description of it:
1622+
1623+
| spelling | example, digits elided |
1624+
|---|---|
1625+
| the dominant form | `NAME.ts:NNN` |
1626+
| the GitHub permalink form | `NAME.ts#LNNN` |
1627+
| the address written first | `line NNN of NAME.ts` |
1628+
| the address written second | `NAME.ts line NNN` |
1629+
| the **continuation** form, which carries no filename at all | a bare `:NNN` beside an address written on a neighbouring line |
1630+
1631+
The continuation form is the one no basename-anchored probe can see, and it is why a one-syntax
1632+
count is not a reading. Measured on this tree: 1,267 such citations, 540 of them already false.
1633+
1634+
The gate is **differential**. It reads only what a pull request **adds**, against its merge base with
1635+
the target branch. The 540 existing citations are **not** its denominator and it does **not** sweep
1636+
them in: shifting an already-false address by a hunk delta moves a wrong pointer to a differently
1637+
wrong place while making the diff look diligent.
1638+
1639+
An absolute count was refused on a measurement rather than on taste. PR #8887's line shifts flipped
1640+
one citation from `drifted` to `resolves` by accident, moving the tree-wide false count 540 → 539 —
1641+
an unearned green that belonged to nobody, and one a total-reading gate would have scored as
1642+
progress.
1643+
1644+
### The three verdicts, and the one that must not collapse
1645+
1646+
Every added citation is a finding — the convention is that the address is not written, not that it
1647+
is written accurately — but each carries the verdict a reader would reach by following it:
1648+
1649+
| verdict | meaning |
1650+
|---|---|
1651+
| `false` | the cited line does not carry what the citing prose says it does |
1652+
| `resolving` | it does, today |
1653+
| `unresolvable` | nothing can ever decide it — chiefly citations into regenerated `dist/*.d.ts`, which are untracked and rebuilt, plus bare basenames that name several tracked files at once |
1654+
1655+
`unresolvable` is **never** counted as `false`. Calling an undecidable citation wrong is an
1656+
assertion, and the split is pinned by a synthetic control so it cannot quietly regress.
1657+
1658+
### What flips it to blocking
1659+
1660+
`ENFORCEMENT` in the script is the whole switch, and its test reads the landed value, so the flip
1661+
cannot happen without the pin moving with it. It flips once the gate reads zero new citations across
1662+
the in-flight population and the convention text has landed in `AGENTS.md` — an author failed by a
1663+
rule is owed a document to be failed against. When it does flip, this workflow owes a `merge_group`
1664+
leg before the context may be required: a required check that never reports on a queue build stalls
1665+
the queue until the ruleset's 60-minute timeout fails it.
1666+
1667+
### The related report
1668+
1669+
`pnpm census:cross-file-line-citations` is the tree-wide census the differential gate was derived
1670+
from. It runs in no workflow, prints the whole population with its per-directory split, and is the
1671+
right instrument for asking how large the existing class is — never for deciding a pull request.
1672+
16001673
## Lockfile Integrity (`lockfile-integrity.yml`)
16011674

16021675
**Triggers:** Pull requests to `main`/`develop` that touch `pnpm-lock.yaml`,

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"census:body-dialect": "node scripts/body-dialect-census.mjs",
5454
"census:tsconfig-test-parity": "node scripts/tsconfig-test-parity-census.mjs",
5555
"census:cross-file-line-citations": "node scripts/cross-file-line-citation-census.mjs",
56+
"check:new-line-citations": "node scripts/check-new-cross-file-line-citations.mjs",
5657
"check:control-bytes": "node scripts/check-control-bytes.mjs",
5758
"check:action-ref-convention": "node scripts/check-action-ref-convention.mjs",
5859
"check:published-dist": "node scripts/check-published-dist-tooling.mjs",

‎scripts/__tests__/check-doc-example-types.test.ts‎

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,12 +339,71 @@ describe('the real ledger', () => {
339339
expect(row.card, key).toMatch(/^objectui#\d+$/);
340340
}
341341
});
342+
343+
/**
344+
* objectui#8875 clause 3. The key used to be `path:line symbol`, and the line
345+
* number in it was not decoration — it was a STORED literal compared for
346+
* equality, so an edit anywhere above a documented symbol invalidated every
347+
* row below it in that file and reddened `main` on a branch that had not
348+
* touched a single example. PR #8895 added three imports to
349+
* `packages/types/src/objectql.ts` and did exactly that; objectui#8614 is the
350+
* same failure one card earlier.
351+
*
352+
* The maintainer ruled the class on 2026-09-10 — 跨文件的「某文件第几行」引用,
353+
* 这种完全没必要吧,是否应该避免 — and the repair the ruling names is to stop
354+
* storing the number, ⛔ not to recompute it after every shift. So the shape
355+
* is pinned in BOTH directions: the key generator may not produce one, and the
356+
* ledger may not carry one.
357+
*/
358+
it('keys carry no line address, in either direction', () => {
359+
const LINE_ADDRESS = /\.[A-Za-z]+:\d+/;
360+
361+
for (const key of Object.keys(UNGATED_EXAMPLES)) {
362+
expect(
363+
key,
364+
`${key} embeds a line address. objectui#8875 clause 3 retired that key shape: a stored ` +
365+
`line number is a snapshot of a moving quantity, so an unrelated edit above the block ` +
366+
`invalidates the row and reddens a branch that changed nothing. Key by ` +
367+
`\`path symbol #ordinal\` — see \`ledgerKey\`.`,
368+
).not.toMatch(LINE_ADDRESS);
369+
expect(key, `${key} is not in the \`path symbol #ordinal\` shape`).toMatch(/ #\d+$/);
370+
}
371+
372+
// The generator, not only today's ledger: a ledger cleaned by hand while the
373+
// generator still emits addresses would go red on the next collected block
374+
// instead of here.
375+
for (const block of census.blocks) {
376+
expect(ledgerKey(block), 'ledgerKey emitted a line address').not.toMatch(LINE_ADDRESS);
377+
}
378+
379+
// Anti-vacuity. A regex that matched nothing would pass both loops above on
380+
// an empty tree, so it is shown FIRING on the shape it is written to reject.
381+
//
382+
// ⛔ ASSEMBLED, not written out. A literal address here would itself be a
383+
// cross-file line citation, and the differential gate landed alongside this
384+
// change would report it as newly added — correctly. A control for a shape
385+
// does not need to be an instance of the thing the shape names.
386+
const RETIRED_KEY_SHAPE = ['packages/types/src/objectql.ts', ':', '1618', ' ObjectFormSchema'].join('');
387+
expect(RETIRED_KEY_SHAPE).toMatch(LINE_ADDRESS);
388+
});
389+
390+
it('the ordinal discriminates the symbols that document more than one example', () => {
391+
// The ordinal is not ceremony: five symbols in this tree carry several
392+
// `@example` blocks, and `path symbol` alone would collapse them onto one
393+
// key — silently, by making several rows the same row. Keys are checked for
394+
// uniqueness against the block count so that collapse cannot happen quietly.
395+
const generated = census.blocks.map((b) => ledgerKey(b));
396+
expect(new Set(generated).size).toBe(census.blocks.length);
397+
expect(new Set(census.blocks.map((b) => `${b.file} ${b.symbol}`)).size).toBeLessThan(
398+
census.blocks.length,
399+
);
400+
});
342401
});
343402

344403
// ── the card's own acceptance criterion ──────────────────────────────────────
345404

346405
describe('objectui#7974 — the defect this gate was filed for', () => {
347-
const key = 'packages/mobile/src/useSpecGesture.ts:69 useSpecGesture';
406+
const key = 'packages/mobile/src/useSpecGesture.ts useSpecGesture #1';
348407

349408
it('its example is IN the compiled tier — the gate reaches the block the card named', () => {
350409
const census = exampleCensus({ root: repoRoot });

‎scripts/__tests__/check-i18n-designer-table-parity.test.ts‎

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,47 @@ describe('the documented zh-only families', () => {
192192
for (const family of ZH_ONLY_FAMILIES) {
193193
expect(family.prefix, 'a family must be a prefix').toMatch(/\.$/);
194194
expect(family.reason.trim().length, `${family.prefix} has no reason`).toBeGreaterThan(20);
195-
expect(family.citation, `${family.prefix} has no citation`).toMatch(/^[\w./-]+:\d+(-\d+)?$/);
195+
expect(family.citation, `${family.prefix} has no citation`).toBeTruthy();
196+
expect(family.citation.file, `${family.prefix} cites no file`).toMatch(/^[\w./-]+$/);
197+
expect(
198+
family.citation.anchor.trim().length,
199+
`${family.prefix} cites no anchor text`,
200+
).toBeGreaterThan(8);
201+
// objectui#8875 clause 3: the citation used to be `path:line`, a STORED
202+
// line number pointing into another file. It was one unrelated edit away
203+
// from naming the wrong line, and nothing here ever followed it, so the
204+
// drift would have been silent. An anchor is text, so it can be CHECKED —
205+
// which the next assertion does.
206+
expect(
207+
`${family.citation.file} ${family.citation.anchor}`,
208+
`${family.prefix} still cites a line address`,
209+
).not.toMatch(/\.[A-Za-z]+:\d+/);
196210
}
197211
});
198212

199-
it('every citation names a file that exists in this repo', () => {
213+
it('every citation resolves: the file exists and the anchor text is in it, exactly once', () => {
200214
for (const family of ZH_ONLY_FAMILIES) {
201-
const file = family.citation.slice(0, family.citation.lastIndexOf(':'));
202-
expect(fs.existsSync(path.join(repoRoot, file)), `${family.citation} names no file`).toBe(true);
215+
const full = path.join(repoRoot, family.citation.file);
216+
expect(fs.existsSync(full), `${family.citation.file} names no file`).toBe(true);
217+
218+
const source = fs.readFileSync(full, 'utf8');
219+
const occurrences = source.split(family.citation.anchor).length - 1;
220+
expect(
221+
occurrences,
222+
`${family.prefix} cites "${family.citation.anchor}" in ${family.citation.file}, which ` +
223+
`contains it ${occurrences} time(s). A citation that locates nothing — or several ` +
224+
`things — is the failure objectui#8875 retired the line numbers for; it is not fixed ` +
225+
`by writing a number back.`,
226+
).toBe(1);
203227
}
228+
229+
// Anti-vacuity: the same reader, on a string that is deliberately absent,
230+
// must return zero. Without it a broken read would agree with every anchor.
231+
const control = fs.readFileSync(
232+
path.join(repoRoot, ZH_ONLY_FAMILIES[0].citation.file),
233+
'utf8',
234+
);
235+
expect(control.includes('zzz-this-anchor-does-not-exist')).toBe(false);
204236
});
205237

206238
it('every family still subtracts at least one real key', () => {

0 commit comments

Comments
 (0)