Repository navigation
Commit 8898b4e
feat(gates): a line ceiling on every file already in facade form (#34103)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbNTugWasvhTMrtCZiFGrZYK)_
Part of #33949. This PR is ruling item 2 (the narrow line ceiling). Item
1 (eight codemod splits, one at a time) stays open on the card, and
split 1 (objectql `registry.ts`) follows as its own PR.
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:给已拆成 facade 形态的 3 个文件(protocol.ts、objectql
engine.ts、sql-driver.ts)加了行数上限,上限 = 今天 main 上的行数 + 100;门禁复用现有的
`check:facade-delegation-only`,没有新脚本、没有新 workflow。
- 为什么改:落实 #33949 裁决第 2 条「窄形式上限」。拆过的文件近 5 天又长了 150 到 180
行,没有上限就会重新长回热点文件。
- 风险与回滚:只改了门禁脚本和它的登记表,不发布任何包。超限时是 CI 报错,不改运行时行为。回滚就是 revert 本 PR。
- 先看:`scripts/facade-delegation-registry.json` 的 `ceilings` 三行(数字);再看
`scripts/check-facade-delegation-only.mjs` 里的 `CEILING_MARGIN`(为什么是
100)和 `checkCeilings`。
- 两分钟验证:`node
scripts/check-facade-delegation-only.mjs`,预期最后几行显示每个文件「11605 lines,
ceiling 11705 (100 left)」这样的余量,退出码 0。
- 需要你做的:无,席位落地。
## What changes
`scripts/check-facade-delegation-only.mjs` reads a third list in
`scripts/facade-delegation-registry.json`, `ceilings`, one row per
registered facade FILE:
| file | baseLines @ 63db724 | maxLines |
|:--|--:|--:|
| `packages/metadata-protocol/src/protocol.ts` | 11,605 | 11,705 |
| `packages/objectql/src/engine.ts` | 6,754 | 6,854 |
| `packages/drivers/driver-sql/src/sql-driver.ts` | 9,971 | 10,071 |
Each row is `{ file, baseLines, baseCommit, maxLines, ruling }`. The
gate refuses:
- a facade file over its `maxLines`. The message tells the author to put
the new code in a new module, and says raising a ceiling is
maintainer-only: it needs a maintainer ruling, cited as the row's
`ruling`, with `baseLines` and `baseCommit` re-measured;
- a registered facade file with no ceiling row, so the PR that registers
the next facade sets its ceiling in the same edit;
- a ceiling on a file that is not a registered facade. The ruling: a
file not yet split takes no ceiling;
- `maxLines` outside `baseLines` to `baseLines + CEILING_MARGIN`. A
ceiling is the measured count plus the margin, never a number picked to
fit;
- a malformed field, an unknown key, or two rows for one file.
**The margin is 100 lines, flat (`CEILING_MARGIN`).** Two readings on
63db724 set it:
- **In-flight work.** The largest net addition any open PR makes to a
facade file is +25 lines: `engine.ts`, summed across PRs #34043, #34025,
#33897 and #33652. `protocol.ts` gets +9 (#33885) and `sql-driver.ts`
none. That was measured over all 73 open PRs (53 carry files) through
the REST files list. So 100 does not red a PR that was reviewed before
the ceiling existed.
- **Regrowth.** Over the last five days `protocol.ts` grew +178 (11,427
to 11,605) and `engine.ts` +157 (6,597 to 6,754), all of it delegation
stubs and docblocks. At that rate 100 lines is about three days. A file
that starts growing again meets its ceiling within a week, not after
another thousand lines.
One number fits every file because the growth comes per member (a stub
plus its docblock), not in proportion to the file's size.
There is no new script, workflow or `package.json` chain. CI already
runs `pnpm check:facade-delegation-only` (`--self-test`, then the gate)
in `Lint & Repo Gates`, step `facade-delegation-only`.
## Tests
The self-test grows from 38 to 44 batteries (`SELF_TEST_BATTERY_FLOOR`
38 to 44):
- C1: over the ceiling is RED. The test checks the count and the
overage, the new-module fix line and the `⛔ MAINTAINER-ONLY` raise
wording.
- C2: at the ceiling is GREEN, with or without a last newline, and the
count is reported.
- C3: no ceiling row is RED.
- C4: a ceiling on an unsplit file is RED.
- C5: above base plus margin, or below base, is RED.
- C6: a bad count, commit or ruling, an unknown key, a duplicate row, or
a registry with no `ceilings` array is RED.
Existing fixtures get a roomy ceiling by default, so the H/A/E/N rows
still judge delegation alone.
<details><summary>Ablation (each leg through
scripts/ablation-replace.mjs, restore proven blob == HEAD, `git diff
HEAD` empty)</summary>
```text
anchor if (wellFormed && lines > row.maxLines) {
-> if (wellFormed && lines > row.maxLines && false) {
ok mutation landed: anchor 1 -> 0, blob 5ea4924 -> 957d6dcf8e4e
✗ C1 a facade file over its line ceiling → RED telling the author to use a new module, raising MAINTAINER-ONLY
ok restored: blob == HEAD (5ea4924)
anchor if (byFile.has(file)) continue;
-> if (byFile.has(file) || true) continue;
ok mutation landed: anchor 1 -> 0, blob 5ea4924 -> 456d3858653f
✗ C3 a registered facade file with no ceiling row → RED
expected a problem matching /^pkg\/src\/facade\.ts registered as a facade but carries no line ceiling/, got []
ok restored: blob == HEAD (5ea4924)
anchor if (!classesOfFile.has(row.file)) {
-> if (false) {
ok mutation landed: anchor 1 -> 0, blob 5ea4924 -> e075b61ce296
✗ C4 a ceiling on a file that is not a registered facade → RED (a file not yet split takes none)
ok restored: blob == HEAD (5ea4924)
anchor (row.maxLines < row.baseLines || row.maxLines > row.baseLines + CEILING_MARGIN)) {
-> (row.maxLines < row.baseLines)) {
ok mutation landed: anchor 1 -> 0, blob 5ea4924 -> 56eae464ba7a
✗ C5 a ceiling above its base plus the margin, or below its base → RED
ok restored: blob == HEAD (5ea4924)
```
The first C3 attempt used the replacement `continue;`, which is a
substring of the anchor. The tool refused it as a no-op ("the
replacement count moved 15 -> 15, a rise of 0, not the declared 1"). It
was re-run with a replacement unique in the file.
</details>
<details><summary>The real files against a lowered ceiling (scratch
registry, protocol.ts maxLines 11604)</summary>
```text
✗ check-facade-delegation-only: 1 problem(s). A registered facade keeps delegations only (ruling 6624258595 item 3) and stays within its line ceiling (ruling 6897467376 item 2).
✗ packages/metadata-protocol/src/protocol.ts is 11605 lines, over its line ceiling of 11604 by 1 (measured 11600 at 63db724, plus the margin; ruling 6897467376).
fix: a file in facade form does not grow: put the new code in a new module (a facet file beside the facade, or a module of its own) and import it from there, instead of adding lines here. Raising a ceiling is ⛔ MAINTAINER-ONLY: it needs a maintainer ruling (ruling 6897467376 item 2), recorded in the row as its `ruling`, with `baseLines` and `baseCommit` re-measured.
exit 1
```
</details>
## Acceptance notes
- **Days to the ceiling.** At the measured regrowth (about 35 lines a
day on `protocol.ts` and about 31 on `engine.ts`), the first ceiling is
reached in about three days. That is the ruling working as written: new
code goes to a new module, or the maintainer raises the ceiling. Seats
adding facade members should expect to see it soon.
- **Workflow comment.** The `lint.yml` comment above the
`facade-delegation-only` step describes the delegation rule only. It is
left untouched because workflows are a governed surface outside this
PR's file surface. The script header is the authority, and it now
documents the ceiling.
- **Split 1.** Split 1 (`packages/objectql/src/registry.ts`) registers
its facade with its post-split ceiling in its own PR, as the header now
requires.
## Verification
Head `cfb690a278` (the branch merged with origin/main `27c2f1ea32`);
every reading below is from that tree.
<details><summary>Local gates (dispatch-gates derivation, 31 families,
each exit code captured before any pipe)</summary>
```text
node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack --ran ran.txt
✓ dispatch-gates --ran: 31 derived famil(ies) accounted for — 31 run, 0 NOT-MEASURED (a DERIVED zero — all 31 recorded an exit code and none of them is 3).
exit 0 for every derived command, among them:
pnpm check:facade-delegation-only (self-test 44 cases pass; 3 files within their line ceiling)
pnpm check:ratchet-remedy-authority (286 scripts swept; 14 mark the expanding remedy ⛔ MAINTAINER-ONLY)
pnpm check:watch-hint-literal, check:nul-bytes, check:parse-guard, check:entry-guard, check:scripts-symbol-anchors
pnpm check:pm-dispatch-gates (fast tier: 2205 cases pass, 352.7s)
pnpm lint exit 0
```
</details>
No changeset: the diff is `scripts/**` only, which ships in no package's
`files[]`, so it is labelled `skip-changeset`.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QsR2jTkZnXtRhuEiiyidvJ)_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01QsR2jTkZnXtRhuEiiyidvJ
Co-authored-by: Claude <noreply@anthropic.com>1 parent 31eb2ae commit 8898b4e
2 files changed
Lines changed: 215 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
45 | | - | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
142 | 143 | | |
143 | 144 | | |
144 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
145 | 176 | | |
146 | 177 | | |
147 | 178 | | |
| |||
151 | 182 | | |
152 | 183 | | |
153 | 184 | | |
154 | | - | |
155 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
156 | 188 | | |
157 | 189 | | |
158 | 190 | | |
| |||
199 | 231 | | |
200 | 232 | | |
201 | 233 | | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
202 | 256 | | |
203 | 257 | | |
204 | 258 | | |
| |||
208 | 262 | | |
209 | 263 | | |
210 | 264 | | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
211 | 278 | | |
212 | 279 | | |
213 | 280 | | |
| |||
680 | 747 | | |
681 | 748 | | |
682 | 749 | | |
683 | | - | |
| 750 | + | |
684 | 751 | | |
685 | | - | |
| 752 | + | |
686 | 753 | | |
687 | 754 | | |
688 | 755 | | |
689 | 756 | | |
690 | 757 | | |
| 758 | + | |
691 | 759 | | |
692 | 760 | | |
693 | | - | |
694 | | - | |
695 | | - | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
696 | 765 | | |
697 | | - | |
| 766 | + | |
698 | 767 | | |
699 | 768 | | |
700 | 769 | | |
| |||
799 | 868 | | |
800 | 869 | | |
801 | 870 | | |
802 | | - | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
803 | 920 | | |
804 | 921 | | |
805 | 922 | | |
| |||
851 | 968 | | |
852 | 969 | | |
853 | 970 | | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
854 | 977 | | |
855 | | - | |
| 978 | + | |
856 | 979 | | |
857 | 980 | | |
858 | 981 | | |
859 | 982 | | |
860 | 983 | | |
861 | | - | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
862 | 991 | | |
863 | | - | |
864 | | - | |
| 992 | + | |
| 993 | + | |
865 | 994 | | |
866 | 995 | | |
867 | 996 | | |
| |||
1064 | 1193 | | |
1065 | 1194 | | |
1066 | 1195 | | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
1067 | 1238 | | |
1068 | 1239 | | |
1069 | 1240 | | |
| |||
1164 | 1335 | | |
1165 | 1336 | | |
1166 | 1337 | | |
1167 | | - | |
| 1338 | + | |
1168 | 1339 | | |
1169 | 1340 | | |
1170 | 1341 | | |
| |||
1176 | 1347 | | |
1177 | 1348 | | |
1178 | 1349 | | |
1179 | | - | |
| 1350 | + | |
1180 | 1351 | | |
1181 | 1352 | | |
1182 | 1353 | | |
| |||
1204 | 1375 | | |
1205 | 1376 | | |
1206 | 1377 | | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
1207 | 1381 | | |
1208 | | - | |
| 1382 | + | |
1209 | 1383 | | |
1210 | 1384 | | |
1211 | 1385 | | |
| |||
0 commit comments