You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore(gates): drop the test-file size pin map, keep the merge-base ratchet
The exact-length pin map duplicated what the merge-base already records and
made every shrink a two-file edit. The gate now has one rule: a test file over
the 1,000-line tripwire may be no longer than at the merge-base with
origin/main, and no new test file may cross the tripwire.
@@ -79,56 +46,12 @@ function countLines(file: string): number {
79
46
returnlines;
80
47
}
81
48
82
-
/** The ratchet decision, separated from the filesystem so the tests below can plant each red. */
83
-
functionratchetFindings(
84
-
measured: ReadonlyMap<string,number>,
85
-
pinned: Readonly<Record<string,number>>,
86
-
tripwire: number,
87
-
): string[]{
88
-
constfindings: string[]=[];
89
-
for(const[file,lines]of[...measured].sort()){
90
-
constpin=pinned[file];
91
-
if(pin===undefined){
92
-
if(lines>tripwire){
93
-
findings.push(
94
-
`${file} is ${lines} lines, over the ${tripwire}-line tripwire and not pinned: split it `+
95
-
`along the source module it mirrors (docs/agents/testing.md) rather than pinning it.`,
96
-
);
97
-
}
98
-
continue;
99
-
}
100
-
if(lines<=tripwire){
101
-
// Pins exist only for files over the tripwire: one on a smaller file grows the map for
102
-
// nothing (900 pinned at 900 would satisfy equality and history alike) and defeats the
103
-
// only-shrink kill criterion.
104
-
findings.push(
105
-
`${file} is ${lines} lines, at or under the ${tripwire}-line tripwire, but has a pin (${pin}): remove it — pins are only for files over the tripwire.`,
106
-
);
107
-
continue;
108
-
}
109
-
if(lines>pin){
110
-
findings.push(
111
-
`${file} grew to ${lines} lines (pinned ${pin}): extract instead of adding to a file over the tripwire.`,
112
-
);
113
-
}elseif(lines<pin){
114
-
findings.push(
115
-
`${file} shrank to ${lines} lines (pinned ${pin}): lower its pin in this PR so the ratchet keeps the gain.`,
116
-
);
117
-
}
118
-
}
119
-
for(constfileofObject.keys(pinned)){
120
-
if(!measured.has(file)){
121
-
findings.push(`${file} is pinned but does not exist: remove its pin.`);
122
-
}
123
-
}
124
-
returnfindings;
125
-
}
126
-
127
49
/**
128
50
* Line counts of the given repo paths at the merge-base with origin/main, following renames, in
129
51
* one `git cat-file --batch` spawn. `undefined` = the file did not exist there.
`${file} is pinned at ${pin} but was ${base} lines at the merge-base: a pin may not be raised above its file's base length.`,
133
+
`${file} is ${lines} lines, ${base} at the merge-base: a test file over the tripwire may not grow; split it along the source module it mirrors (docs/agents/testing.md).`,
223
134
);
224
135
}
225
136
}
226
137
returnfindings;
227
138
}
228
139
229
-
test('no test file over the tripwire grows, and every pin matches its file exactly',()=>{
140
+
test('no test file over the tripwire is longer than at the merge-base, and no new file crosses it',()=>{
'a.test.ts grew to 1201 lines (pinned 1200): extract instead of adding to a file over the tripwire.',
260
-
'b.test.ts is 900 lines, at or under the 1000-line tripwire, but has a pin (1500): remove it — pins are only for files over the tripwire.',
261
-
'c.test.ts is 1001 lines, over the 1000-line tripwire and not pinned: split it along the source module it mirrors (docs/agents/testing.md) rather than pinning it.',
262
-
// The arbitrary-new-pin bypass: equality (900 == 900) and history (900 <= base) both pass,
263
-
// so this rule is the one that rejects it.
264
-
'e.test.ts is 900 lines, at or under the 1000-line tripwire, but has a pin (900): remove it — pins are only for files over the tripwire.',
265
-
'gone.test.ts is pinned but does not exist: remove its pin.',
'a.test.ts is 1230 lines, 1200 at the merge-base: a test file over the tripwire may not grow; split it along the source module it mirrors (docs/agents/testing.md).',
283
165
]);
284
-
// Raising the pin alone (before growing into it) is already red.
'small.test.ts is 1001 lines, 900 at the merge-base: a test file over the tripwire may not grow; split it along the source module it mirrors (docs/agents/testing.md).',
302
171
]);
303
-
// Allowed: shrink with a lowered pin, a pin that disappears, an unchanged file.
172
+
// Allowed: unchanged, shrunk (with no gate edit), under the tripwire, or new and small.
0 commit comments