GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fork seam check: refuse spare seam copies (#311 items 7/8) (#621) · scuttletoby/t3code@ad3c0ae

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .github
    • fork-seams.json
    • scripts
      • fork-seam-check.cjs
      • fork-seam-check.test.cjs
  • docs/fork
    • updates.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/fork-seams.json‎

Copy file name to clipboardExpand all lines: .github/fork-seams.json
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
]
4848
},
4949
"apps/server/src/serverSettings.ts": {
50-
"why": "Every settings write goes through upstream's patch and write paths here. The fork swaps in its patch (fork/serverSettingsPatch.ts, under upstream's name, so a project's MCP profile a client left out is kept) and calls its save check (fork/serverSettingsWriteCheck.ts) once in each write path. The load decodes the file after fork/settingsFileRead.ts (old auto-update names renamed, an unusable interval left out so it reads as its default). The lines from \"import { renameRetiredAutoUpdateKeys }\" on predate this list and record main as it was when every upstream file began to count (#277); they are to move into apps/server/src/fork/ (follow-up), and the file cannot grow meanwhile.",
50+
"why": "Every settings write goes through upstream's patch and write paths here. The fork swaps in its patch (fork/serverSettingsPatch.ts, under upstream's name, so a project's MCP profile a client left out is kept) and calls its save check (fork/serverSettingsWriteCheck.ts) once in each write path. The load decodes the file after fork/settingsFileRead.ts (old auto-update names renamed, an unusable interval left out so it reads as its default). The lines from \"import { renameRetiredAutoUpdateKeys }\" on predate this list (#277): the load's decode of the file, which the fork report shares and which needs upstream's private decoders here, and the fallback when the file cannot be read. Each listed copy is one the fork adds over upstream; the run from upstream refuses a spare one (#311).",
5151
"added": [
5252
"// Fork: upstream's patch keeping a project's MCP profile a client left out, and the save check.",
5353
"import { applyServerSettingsPatchKeepingForkProjectKeys as applyServerSettingsPatch } from \"./fork/serverSettingsPatch.ts\";",
@@ -59,7 +59,6 @@
5959
"import { renameRetiredAutoUpdateKeys } from \"./cloud/autoUpdateSettings.ts\";",
6060
") {",
6161
"}",
62-
"};",
6362
"/**",
6463
"* The load's decode of a settings file's text: parse, rename retired keys, fill policy defaults,",
6564
"* decode. Pure, so the fork's read-only report (`__fork-report`) decodes exactly as a load does.",
@@ -80,9 +79,6 @@
8079
"const decoded = decodeSettingsFileText(raw, managed.withDefaults);",
8180
"// The file may hold an opt-out we can no longer read; never resume threads or update on a",
8281
"// guess, even when an admin policy defaults them on (a locked policy value still applies).",
83-
"settings = {",
84-
"...managed.defaults,",
85-
"continueThreadsAfterServerUpdate: false,",
8682
"automaticUpdates: false,"
8783
]
8884
},
Collapse file

‎.github/scripts/fork-seam-check.cjs‎

Copy file name to clipboardExpand all lines: .github/scripts/fork-seam-check.cjs
+95-8Lines changed: 95 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,60 @@ function findLostLines(config, { atBase, atHead, upstream, afterRebase = false,
540540
return { reasons, ceilings, rises, notes };
541541
}
542542

543+
/**
544+
* Spare listed "added" copies: room for a line nobody announced. From upstream, a copy the head does
545+
* not add over the base is refused (after a rebase: a note, and `lowered.added` keeps the copies in
546+
* use). A pull request that drops copies lists exactly main's copies less those in `ownFiles`.
547+
*/
548+
function findSpareSeamLines(
549+
files,
550+
{ atBase, atHead, upstream, afterRebase = false, ownFiles, lowered },
551+
) {
552+
const ceilings = [];
553+
const notes = [];
554+
const times = (count) => (count === 1 ? "" : ` ${count}×`);
555+
for (const [file, seam] of Object.entries(files)) {
556+
const base = atBase(file);
557+
const head = atHead(file);
558+
if (base === undefined || head === undefined) continue; // Refused (or noted) elsewhere.
559+
const listed = lineCounts(seam.added.join("\n"));
560+
const baseCounts = lineCounts(base);
561+
const headCounts = lineCounts(head);
562+
if (upstream) {
563+
const used = new Map();
564+
const spare = [];
565+
for (const [line, count] of listed) {
566+
const over = Math.max(0, (headCounts.get(line) ?? 0) - (baseCounts.get(line) ?? 0));
567+
used.set(line, Math.min(count, over));
568+
if (over >= count) continue;
569+
spare.push(
570+
`${file}: "added" lists \`${line}\`${times(count)}, but the fork adds ${over === 0 ? "no copy" : `${over}×`} over upstream; ${over === 0 ? 'remove it from "added"' : `list it ${over}×`} (a spare copy lets a later change add the line unannounced).`,
571+
);
572+
}
573+
if (spare.length > 0) {
574+
lowered?.added.set(file, used);
575+
(afterRebase ? notes : ceilings).push(...spare);
576+
}
577+
continue;
578+
}
579+
if (ownFiles === undefined) continue;
580+
const own = Object.hasOwn(ownFiles, file)
581+
? lineCounts(ownFiles[file].added.join("\n"))
582+
: new Map();
583+
for (const [line, count] of listed) {
584+
const dropped = (baseCounts.get(line) ?? 0) - (headCounts.get(line) ?? 0);
585+
if (dropped <= 0) continue;
586+
const want = Math.max(0, count - dropped);
587+
const has = own.get(line) ?? 0;
588+
if (has === want) continue;
589+
ceilings.push(
590+
`${file}: this change drops${times(dropped)} \`${line}\`, which main's list has${times(count)} under "added": ${want === 0 ? "remove it from" : `list it ${want}× under`} "added" in this change's ${CONFIG} (its list has ${has === 0 ? "none" : `${has}`}; a spare copy lets a later change add the line unannounced, too few fails the next run from upstream).`,
591+
);
592+
}
593+
}
594+
return { ceilings, notes };
595+
}
596+
543597
/**
544598
* Listed seam and pending paths that neither the base nor the head has: nothing there to guard.
545599
* Upstream renamed (or removed) the file, so the list names both paths until the base moves on, and
@@ -881,10 +935,9 @@ const MOVED_WHY =
881935
'Was "pending": fork-follow moved it here once it had no fork line left, as its "lost" entry still counts upstream lines it loses. No seam line: a fork line goes in a file of the fork\'s own.';
882936

883937
/**
884-
* `text` with `lowered` ({ pending, lost } Maps of counts, `hidden` Set of upstream files) applied, as
885-
* { text, changes }, or undefined when nothing changes. Only lowers; a count at 0 removes the entry; a
886-
* "pending" file with no fork line left moves to "files"; each hidden file stops being a fork file
887-
* (its own "forkFiles" entry goes, or a `!` entry excludes it). Parsed again before it is returned.
938+
* `text` with `lowered` (pending/lost/added Maps, `hidden` Set) applied, as { text, changes }, or
939+
* undefined. Only lowers: a 0 count or spare "added" copy goes, an emptied "pending" file moves to
940+
* "files", a hidden file stops being a fork file ("forkFiles" entry or `!`). Parsed again after.
888941
*/
889942
function lowerList(text, lowered) {
890943
const raw = JSON.parse(text);
@@ -946,6 +999,26 @@ function lowerList(text, lowered) {
946999
`${file}: "forkFiles" ${what} (upstream has it; a pull request's run took it for a fork file)`,
9471000
);
9481001
}
1002+
// Spare "added" copies go, the first listed copies stay: only narrows what a change may add.
1003+
for (const [file, used] of lowered.added ?? []) {
1004+
if (!Object.hasOwn(raw.files ?? {}, file)) continue;
1005+
const seam = raw.files[file];
1006+
const kept = new Map();
1007+
const removed = [];
1008+
const added = seam.added.filter((item) => {
1009+
const line = item.trim();
1010+
const count = (kept.get(line) ?? 0) + 1;
1011+
kept.set(line, count);
1012+
if (count <= (used.get(line) ?? Infinity)) return true;
1013+
removed.push(line);
1014+
return false;
1015+
});
1016+
if (removed.length === 0) continue;
1017+
changes.push(
1018+
`${file}: "added" ${seam.added.length} -> ${added.length} lines (spare: ${removed.map((line) => `\`${line}\``).join(", ")})`,
1019+
);
1020+
seam.added = added;
1021+
}
9491022
// Appended through defineProperty: a file named `__proto__` stays an own key.
9501023
for (const file of moved) {
9511024
Object.defineProperty(raw.files, file, {
@@ -1059,7 +1132,7 @@ function main(argv) {
10591132
const lowered =
10601133
parsed.loweredList === undefined
10611134
? undefined
1062-
: { pending: new Map(), lost: new Map(), hidden: new Set() };
1135+
: { pending: new Map(), lost: new Map(), added: new Map(), hidden: new Set() };
10631136
const unlisted = findUnlistedChanges(config, {
10641137
changed,
10651138
atBase,
@@ -1082,9 +1155,17 @@ function main(argv) {
10821155
afterRebase: parsed.afterRebase,
10831156
lowered,
10841157
});
1158+
const spare = findSpareSeamLines(config.files, {
1159+
atBase,
1160+
atHead,
1161+
upstream,
1162+
afterRebase: parsed.afterRebase,
1163+
ownFiles,
1164+
lowered,
1165+
});
10851166
// A ceiling above the count is fixed by lowering it, not by moving lines: its own hint. A count
10861167
// that rose with a rebase names the operator's step in its own text.
1087-
const ceilings = [...unlisted.ceilings, ...lost.ceilings];
1168+
const ceilings = [...unlisted.ceilings, ...lost.ceilings, ...spare.ceilings];
10881169
const rises = [...unlisted.rises, ...lost.rises];
10891170
// A pull request's run dates an announcement by the commit whose list judges it (main's): its
10901171
// own author sets its own date, and fork-checks' base can be older than the list's commit.
@@ -1122,7 +1203,12 @@ function main(argv) {
11221203
)
11231204
: [];
11241205
const from = parsed.configRef ? `--config-ref ${configRef}` : upstream ? "the head" : "the base";
1125-
const notes = [...findListedGone(config, { atBase, atHead }), ...unlisted.notes, ...lost.notes];
1206+
const notes = [
1207+
...findListedGone(config, { atBase, atHead }),
1208+
...unlisted.notes,
1209+
...lost.notes,
1210+
...spare.notes,
1211+
];
11261212
for (const note of notes) console.log(printable(`Note: ${note}`));
11271213
if (editsList) {
11281214
console.log(
@@ -1184,7 +1270,7 @@ function main(argv) {
11841270
}
11851271
if (ceilings.length > 0) {
11861272
console.error(
1187-
`Lower each "pending" ceiling and "lost" count named above (or remove the entry, or set the value its line names) in ${CONFIG}: in this change's list where the line says so, otherwise with a pull request to main.`,
1273+
`Lower each "pending" ceiling and "lost" count, and drop each spare "added" copy, named above (or remove the entry, or set the value its line names) in ${CONFIG}: in this change's list where the line says so, otherwise with a pull request to main.`,
11881274
);
11891275
}
11901276
if (late.length > 0) {
@@ -1216,6 +1302,7 @@ module.exports = {
12161302
findListedGone,
12171303
findLostLines,
12181304
findSeamBreaches,
1305+
findSpareSeamLines,
12191306
findStaleSeamLines,
12201307
findUnlistedChanges,
12211308
forkFileTest,

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.