Repository navigation
Commit a34eb07
tenant-audit census: shard the ledger per package and drop live totals from the page (#34650)
Fixes #33942
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:租户审计普查(tenant-audit
census)的台账按包拆成分片(每个包一个文件,带该包自己的小计和全部调用点),页面正文不再写任何实时总数,总数改由门禁每次运行时打印。另外把三处还按「单文件台账」描述普查的注释改成了现在的样子(合并驱动台账、`.gitattributes`
注释、`service-settings` 里一条 JSDoc)。
- 为什么改:以前每个新增写调用点的 PR 都要改同一页和同一个台账里的总数,任意两个这样的 PR 必然冲突;现在两个 PR
在不同包里加写调用点,各改各的分片文件,互不冲突。
-
风险与回滚:只动仓内脚本、文档和一条包内注释(`config-change-audit.ts`,纯注释,不改行为,不进任何导出),不发布行为变化;门禁仍然逐字节核对每个分片(每个包的小计之和就是原总数,所以原来能拦的现在都拦);回滚就是还原本
PR。
-
先看:`scripts/check-tenant-audit-census.mjs`(分片缺失/多余/漂移三条新规则与正文不得写实时总数),`scripts/tenant-audit-census.mjs`(分片渲染与
`--write` 保留已提交的规模块),`scripts/tenant-audit-census-replay.mjs`(两分支回放)。
- 两分钟验证:`node scripts/check-tenant-audit-census.mjs` —— 预期打印一张总数表(写调用点
322 等)和一行 `cite: 3 / 322`,最后一行 `✓ check-tenant-audit-census: OK -- 322
write call sites certified across 18 package shard(s)`。
- 需要你做的:无,席位落地。
## What changes
The tenant-audit census used to commit its population totals in three
places that every PR adding a write call site rewrote: the page's
generated region, the ledger
`docs/audits/2026-08-tenant-audit-write-call-sites.counts.md` (its `##
Totals` table, plus a dated corpus-scale line re-dated on every
`--write`), and about two dozen hand-written numbers in the page prose.
Any two such PRs conflicted.
- **Shard key: the package.** The ledger's rows and totals move into one
file per package,
`docs/audits/2026-08-tenant-audit-write-call-sites.counts/services/PACKAGE.md`
and `.../plugins/PACKAGE.md` (18 shards today), for every package
holding a write call site or an undefended subtraction. Each shard
carries that package's rows, its undefended subtractions and its totals:
every field of `census.totals` plus the undefended counts. **No total
across packages is committed anywhere**, the same cure the strictness
ledger's `.counts/` shards and the liveness `state-counts/` shards
already use.
- **Second artefact.** The old ledger file stays at its path as the
index: method text and the dated corpus-scale block. It holds no
population figure and no list of shards (a list would be one more line
every first-site-in-a-new-package PR rewrites).
- **Page.** The generated region keeps the subtraction method and the
dated corpus-scale block and drops every population figure. The
hand-written prose states no live total. History sentences keep their
figures only where dated: the 2026-08-31 over-claim now quotes the
figures of the day it was caught (84 / 17 / 67 at a population of 215,
read from the page as first committed in 4ecafc7), and the 51-verdict
and 225 → 227 fixes carry their dates. The deviation table's "this
census" column now names the gate's printed figure instead of a number.
One stale claim went with the rewrite: "exactly one write call site …
targets either" opt-out object (the table read 7).
- **The gate prints the totals.** `node
scripts/check-tenant-audit-census.mjs` prints every census total (the
same `totalsRows` each shard renders) and a `cite:` line on every run,
red or green.
- **`--write` keeps the corpus-scale block.** The page region and the
index keep their committed scale values and date unless `--write
--refresh-scale` asks to re-measure them. The gate never compared those
values (the 2026-08-31 split). Re-dating them on every run was the last
line two sharded branches would both rewrite. `--refresh-scale` is a new
flag name: the seat may rename it.
- **Gate semantics.** Check A (drift) now covers the index, every
expected shard, a package with sites and no shard, and a shard for a
package the census finds nothing in, all as `[census-drift]` with the
same `Fix: --write`. Because each total is a sum of per-package totals,
a moved total is a drifted shard. Check B changes from "every prose
number equals the census" to "the prose states no live total": the 12
shapes those numbers used to take must match nothing (`[prose-total]`).
Checks C and the empty-census and no-region refusals, and the
enforced/unenforced split, are unchanged.
- **Descriptions brought up to the sharded shape** (L1 round 1, R1). The
`docs/audits/**` and `content/docs/permissions/**` entries of
`NOT_DRIVER_MANAGED` in `scripts/regen-artifacts.mjs` and the
`.gitattributes` comment block beside the system-context row now name
the index, the per-package shards and a page region that holds no
population figure. The JSDoc in
`packages/services/service-settings/src/config-change-audit.ts` now
points at that package's shard instead of a "hand-written prose count"
the page no longer has. Comments and ledger prose only; no row, route or
code changes.
- `scripts/tenant-audit-census-replay.mjs` is the card's proof (below).
It is a measurement, not a CI gate.
## Tests
<details><summary>Two-branch replay (sharded head) and its control
(origin/main)</summary>
```text
$ node scripts/tenant-audit-census-replay.mjs --base acc85f8
replay: replay-a (packages/services/service-job) --write touched 1 file(s):
rewrote docs/audits/2026-08-tenant-audit-write-call-sites.counts/services/service-job.md
replay: replay-b (packages/plugins/plugin-sharing) --write touched 1 file(s):
rewrote docs/audits/2026-08-tenant-audit-write-call-sites.counts/plugins/plugin-sharing.md
replay: git merge-tree --write-tree replay-a replay-b :: exit 0
replay: merged tree --write :: exit 0; git status --porcelain after it: (empty)
replay: merged tree gate :: exit 0; ✓ check-tenant-audit-census: OK -- 324 write call sites certified across 18 package shard(s) ...
replay: packages/services/service-job/src/tenant-audit-replay-probe.ts certified by its package shard: yes
replay: packages/plugins/plugin-sharing/src/tenant-audit-replay-probe.ts certified by its package shard: yes
replay: ✓ outcome clean, expected clean
$ node scripts/tenant-audit-census-replay.mjs --base 082f9c2 --expect conflict # origin/main, unsharded
replay: replay-a (packages/services/service-job) --write touched 2 file(s):
rewrote content/docs/permissions/tenant-audit-census.mdx
rewrote docs/audits/2026-08-tenant-audit-write-call-sites.counts.md
replay: replay-b (packages/plugins/plugin-sharing) --write touched 2 file(s): (the same two)
replay: git merge-tree --write-tree replay-a replay-b :: exit 1
replay: CONFLICT in 2 path(s):
content/docs/permissions/tenant-audit-census.mdx
docs/audits/2026-08-tenant-audit-write-call-sites.counts.md
replay: ✓ outcome conflict, expected conflict
```
The replay runs in a throwaway `git clone --shared` with no merge driver
registered, which is the condition GitHub's server-side merge runs
under. It never touches this worktree's refs.
</details>
<details><summary>Gate self-test and gate (before and after: identical
totals)</summary>
`node scripts/check-tenant-audit-census.mjs --self-test` passes 29
cases, and the generator's own 101 classifier cases are unchanged. The
gate prints `Write call sites 322`, decidable 227, run time 95,
tenancy-enabled 220, declared off 7, threading a context 251, provably
none 12 / 3, unreadable 59 / 32, elevated 181 / 0 / 129, placement 255 /
57 / 5 / 5, object name 141 / 86 / 10 / 85, undefended 1 / 0. Every
figure equals the region and ledger it replaces on `origin/main`.
Tests changed because the artefact moved. Each case is named here:
- `A DRIFT`: "an edited count inside the page region" became "an edited
line inside the page region", because the region holds no count. "an
edited total inside the ledger" became "an edited total inside a shard".
The row-deletion case now deletes from a shard. Two cases are new: a
package with sites and no shard, and a shard for a package with no
sites. The floor goes from 5 to 7.
- `B PROSE`: the four cases now write a live total back into the prose
in three former shapes (unreadable-share sentence, deviation row, `Cite
N / M`) and expect `[prose-total]`. The fourth is a control: a dated
history figure is not a finding.
- `⭐ THE SPLIT`: the control "a population count in the same table" now
moves a shard's total beside a moved scale count, because the page table
holds no population figure. The other eight cases are unchanged.
</details>
<details><summary>Ablation: one per new shard rule, on disk, with the
real gate CLI</summary>
| mutation (on disk, then restored and proven by `git diff HEAD` empty)
| gate |
| :--- | :--- |
| `services/service-job.md` total `6` changed to `5` (via
`ablation-replace.mjs`, anchor hit 1) | exit 1, `[census-drift] ...
services/service-job.md is not what the tree produces. First difference
at line 17` |
| `services/service-job.md` deleted | exit 1, `[census-drift] the census
has write call sites in the package ... services/service-job.md is the
shard for, and that shard is not committed` |
| an orphan `plugins/plugin-no-such-package.md` added | exit 1,
`[census-drift] ... plugin-no-such-package.md is committed ... but the
census finds no write call site` |
| `**59 of the 322 sites are spelled that way**` written back into the
prose | exit 1, `[prose-total] ... "sites whose options argument is
unreadable"` |
`--write --refresh-scale` was run once and reverted. It rewrites only
the dated line and the scale values in the page and the index.
</details>
## Acceptance notes
- Two PRs that add a write call site in the **same** package still
conflict on that package's shard. The card's bar is different packages.
Two PRs that each add the **first** site in two new packages create two
new files and do not conflict.
- `--write` no longer re-dates the corpus-scale block. Its date now
means "last re-measured", and `--refresh-scale` is the way to refresh
it.
- `.github/workflows/lint.yml` names the page in a comment, and its two
commands are unchanged.
- The prose figure "Across 117 declared objects" is kept as is: it is
unenforced corpus scale under the 2026-08-31 ruling, and the self-test
builds its fixture from it.
## Verification
Round 1 ran at `1277945da8`: `node scripts/pm/dispatch-gates.mjs
--commands` derived 67 families, all 67 exited 0 (four first answered
exit 3 because `@objectstack/formula`, `client`, `client-react` and
`lint` were unbuilt, and were re-run after building them).
Round 2 (L1 R1, the three description fixes) ran at `e237ebe91b`. The
new paths raise the derived set to 99 families. All 99 ran with stdin
from `/dev/null`, each exit code captured before any pipe, and all 99
exited 0; `--ran` reconciliation answered 99 derived, 99 run, 0
NOT-MEASURED. `check:dual-build-cjs-loads` first answered exit 3
(PREREQUISITE NOT MET, no `dist/` in apps and connectors) and was re-run
after a full `pnpm build --concurrency=2`; the re-run code is the one
recorded. The head was then synced with `main` by the relay
(`870f898cf1`, a merge commit; this PR's own diff is unchanged), and
`node scripts/check-tenant-audit-census.mjs`, its `--self-test` and
`pnpm check:merge-driver` were re-run there: all exit 0, 322 sites
across 18 shards.
<details><summary>Highlights</summary>
```text
node scripts/check-tenant-audit-census.mjs :: exit 0
node scripts/check-tenant-audit-census.mjs --self-test :: exit 0
pnpm check:merge-driver :: exit 0
pnpm check:pm-dispatch-gates :: exit 0
pnpm check:docs-audit-scope :: exit 0
pnpm check:scripts-symbol-anchors :: exit 0
pnpm check:system-context-census :: exit 0
pnpm check:dual-build-cjs-loads :: exit 0
pnpm check:doc-authoring :: exit 0
pnpm check:self-test-wired :: exit 0
```
</details>
The CI families are cited from this PR's check-runs. No changeset: the
diff is repo tooling (root `scripts/`), docs (`content/docs`,
`docs/audits`), `.gitattributes`, and one JSDoc comment on a
module-local constant in `@objectstack/service-settings`, which changes
no emitted code, type or behaviour. It carries `skip-changeset`.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmRH4UCX1tvddXMS7cq)_
<!-- signed: repo:objectstack#2 · os-steve ·
session_01ADHkmRH4UCX1tvddXMS7cq -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>1 parent fa8f30b commit a34eb07
26 files changed
Lines changed: 2079 additions & 816 deletions
File tree
- content/docs/permissions
- docs/audits
- 2026-08-tenant-audit-write-call-sites.counts
- plugins
- services
- packages/services/service-settings/src
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
| 108 | + | |
109 | 109 | | |
110 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
111 | 113 | | |
112 | 114 | | |
113 | 115 | | |
| |||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
0 commit comments