GeezerVison is showing github.com — fork seams: green from upstream on main; a PR's own list is format-ch… · scuttletoby/t3code@9d5eeba
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .github/fork-seams.json +170-10Lines changed: 170 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 90 | 90 | ": { unit: tracked.unit, slice: ownedSlice };", | 91 | 91 | "})," | 92 | 92 | ] | | 93 | + }, | | 94 | + "apps/server/src/cli/connect.ts": { | | 95 | + "why": "A server held with `serve --hold-work` shares the live server's environment id, so `t3 connect --disconnect` refuses before the relay delete (cloud/holdWorkConnect.ts).", | | 96 | + "added": [ | | 97 | + "import * as HoldWorkConnect from \"../cloud/holdWorkConnect.ts\";", | | 98 | + "// Fork: a held copy shares the live server's environment id; refuse before the relay delete.", | | 99 | + "yield* HoldWorkConnect.refuseCliUnlinkWhileHeld(", | | 100 | + "(yield* ServerConfig.ServerConfig).serverRuntimeStatePath,", | | 101 | + ");" | | 102 | + ] | | 103 | + }, | | 104 | + "apps/server/src/cloud/CloudLink.ts": { | | 105 | + "why": "unlink's error type takes the hold-work refusal (cloud/holdWorkConnect.ts); the one upstream line is split so the fork's error sits on its own line.", | | 106 | + "added": [ | | 107 | + "readonly unlink: () => Effect.Effect<", | | 108 | + "EnvironmentCloudRelayConfigResult,", | | 109 | + "// Fork: a server held with `serve --hold-work` refuses (cloud/holdWorkConnect.ts).", | | 110 | + "CloudLinkInternalError | ManagedLimits.ManagedPolicyRefusedError", | | 111 | + ">;" | | 112 | + ] | 93 | 113 | } | 94 | 114 | }, | 95 | 115 | "//pending": "Upstream files whose fork lines predate counting every upstream file, each with its ceiling: the most fork lines it may hold against upstream (counted from upstream, as fork-follow runs the check). To move into fork files or pin as seams; lower a ceiling when lines move out and take a file off when none are left. A pull request may change them but not grow them.", | | 106 | 126 | "apps/server/src/cloud/selfUpdate.ts": 4, | 107 | 127 | "apps/server/src/config.ts": 2, | 108 | 128 | "apps/server/src/mcp/McpHttpServer.ts": 10, | 109 | | - "apps/server/src/mcp/OrchestratorMcpService.ts": 41, | | 129 | + "apps/server/src/mcp/OrchestratorMcpService.ts": 35, | 110 | 130 | "apps/server/src/mcp/toolkits/environment/handlers.test.ts": 63, | 111 | 131 | "apps/server/src/mcp/toolkits/project/handlers.test.ts": 48, | 112 | | - "apps/server/src/orchestration-v2/EffectWorker.ts": 31, | | 132 | + "apps/server/src/orchestration-v2/EffectWorker.ts": 28, | 113 | 133 | "apps/server/src/orchestration-v2/ProjectionStore.ts": 7, | 114 | 134 | "apps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.test.ts": 435, | 115 | 135 | "apps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.ts": 152, | | 132 | 152 | "apps/server/src/serverRuntimeState.ts": 4, | 133 | 153 | "apps/server/src/terminal/Manager.ts": 2, | 134 | 154 | "apps/server/vite.config.ts": 2, | | 155 | + "apps/web/src/cloud/linkEnvironment.test.ts": 34, | 135 | 156 | "apps/web/src/components/ChatMarkdown.permissions.browser.test.tsx": 277, | 136 | | - "apps/web/src/components/ChatMarkdown.tsx": 71, | | 157 | + "apps/web/src/components/ChatMarkdown.tsx": 63, | 137 | 158 | "apps/web/src/components/chat/MarkdownFileLink.logic.ts": 74, | 138 | 159 | "apps/web/src/components/chat/MarkdownFileLink.tsx": 148, | 139 | 160 | "apps/web/src/components/media/mediaContent.ts": 8, | 140 | 161 | "apps/web/src/components/settings/IntervalSecondsField.tsx": 4, | 141 | | - "apps/web/src/components/settings/SettingsPanels.tsx": 2, | 142 | | - "apps/web/src/components/settings/scopedSettings.test.ts": 57, | 143 | | - "apps/web/src/components/settings/scopedSettings.ts": 5, | | 162 | + "apps/web/src/components/settings/SettingsPanels.tsx": 4, | | 163 | + "apps/web/src/components/settings/scopedSettings.test.ts": 153, | | 164 | + "apps/web/src/components/settings/scopedSettings.ts": 9, | 144 | 165 | "apps/web/src/components/settings/settingsSearch.ts": 25, | 145 | | - "apps/web/src/components/settings/useScopedSettings.ts": 14, | | 166 | + "apps/web/src/components/settings/useScopedSettings.ts": 27, | 146 | 167 | "apps/web/src/index.css": 2, | 147 | 168 | "apps/web/src/markdown-links.test.ts": 1, | 148 | 169 | "apps/web/src/markdownFileHostPath.ts": 1, | | 157 | 178 | "packages/provider-core/src/server/managedProvider.test.ts": 39, | 158 | 179 | "packages/provider-core/src/server/managedProvider.ts": 8, | 159 | 180 | "packages/provider-core/src/server/snapshot.ts": 2, | 160 | | - "packages/shared/package.json": 28, | 161 | | - "packages/shared/src/cliRelease.test.ts": 43, | | 181 | + "packages/shared/package.json": 32, | | 182 | + "packages/shared/src/cliRelease.test.ts": 38, | 162 | 183 | "packages/shared/src/cliRelease.ts": 11, | 163 | 184 | "packages/shared/src/usageLimits.ts": 12, | 164 | 185 | "vite.config.ts": 2 | | 206 | 227 | "packages/shared/src/waitFor*", | 207 | 228 | "scripts/lib/release-repository.ts", | 208 | 229 | "scripts/release-repository.test.ts" | 209 | | - ] | | 230 | + ], | | 231 | + "//lost": "Seam and pending files that lost upstream lines, counted from upstream (as fork-follow runs the check): \"lines\", the upstream lines not kept in order and indentation; \"gone\", those whose text is gone. Held exactly, like a ceiling; an unlisted file counts 0. Lower a count when a line comes back, and keep each one small: a line counted here may move unseen.", | | 232 | + "lost": { | | 233 | + "packages/shared/src/serverSettings.ts": { | | 234 | + "lines": 1, | | 235 | + "gone": 1 | | 236 | + }, | | 237 | + "apps/server/src/serverSettings.ts": { | | 238 | + "lines": 10, | | 239 | + "gone": 8 | | 240 | + }, | | 241 | + "apps/server/src/cloud/CloudLink.ts": { | | 242 | + "lines": 1, | | 243 | + "gone": 1 | | 244 | + }, | | 245 | + "apps/desktop/src/electron/ElectronShell.ts": { | | 246 | + "lines": 1, | | 247 | + "gone": 1 | | 248 | + }, | | 249 | + "apps/server/src/background/BackgroundPolicy.ts": { | | 250 | + "lines": 1, | | 251 | + "gone": 1 | | 252 | + }, | | 253 | + "apps/server/src/cli/server.ts": { | | 254 | + "lines": 4, | | 255 | + "gone": 4 | | 256 | + }, | | 257 | + "apps/server/src/mcp/McpHttpServer.ts": { | | 258 | + "lines": 1, | | 259 | + "gone": 1 | | 260 | + }, | | 261 | + "apps/server/src/mcp/OrchestratorMcpService.ts": { | | 262 | + "lines": 4, | | 263 | + "gone": 4 | | 264 | + }, | | 265 | + "apps/server/src/orchestration-v2/EffectWorker.ts": { | | 266 | + "lines": 2, | | 267 | + "gone": 1 | | 268 | + }, | | 269 | + "apps/server/src/orchestration-v2/ProjectionStore.ts": { | | 270 | + "lines": 1, | | 271 | + "gone": 1 | | 272 | + }, | | 273 | + "apps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.test.ts": { | | 274 | + "lines": 1, | | 275 | + "gone": 1 | | 276 | + }, | | 277 | + "apps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.ts": { | | 278 | + "lines": 5, | | 279 | + "gone": 5 | | 280 | + }, | | 281 | + "apps/server/src/orchestration-v2/ThreadLaunchService.ts": { | | 282 | + "lines": 7, | | 283 | + "gone": 3 | | 284 | + }, | | 285 | + "apps/server/src/orchestration-v2/ThreadManagementService.ts": { | | 286 | + "lines": 1, | | 287 | + "gone": 1 | | 288 | + }, | | 289 | + "apps/server/src/processRunner.ts": { | | 290 | + "lines": 2, | | 291 | + "gone": 2 | | 292 | + }, | | 293 | + "apps/server/src/scheduling/DueHint.ts": { | | 294 | + "lines": 1, | | 295 | + "gone": 1 | | 296 | + }, | | 297 | + "apps/server/src/server.ts": { | | 298 | + "lines": 6, | | 299 | + "gone": 6 | | 300 | + }, | | 301 | + "apps/server/src/serverRuntimeStartup.ts": { | | 302 | + "lines": 6, | | 303 | + "gone": 2 | | 304 | + }, | | 305 | + "apps/server/src/serverRuntimeState.ts": { | | 306 | + "lines": 1, | | 307 | + "gone": 1 | | 308 | + }, | | 309 | + "apps/server/src/terminal/Manager.ts": { | | 310 | + "lines": 1, | | 311 | + "gone": 1 | | 312 | + }, | | 313 | + "apps/web/src/components/ChatMarkdown.permissions.browser.test.tsx": { | | 314 | + "lines": 9, | | 315 | + "gone": 9 | | 316 | + }, | | 317 | + "apps/web/src/components/ChatMarkdown.tsx": { | | 318 | + "lines": 2, | | 319 | + "gone": 1 | | 320 | + }, | | 321 | + "apps/web/src/components/chat/MarkdownFileLink.logic.ts": { | | 322 | + "lines": 22, | | 323 | + "gone": 20 | | 324 | + }, | | 325 | + "apps/web/src/components/chat/MarkdownFileLink.tsx": { | | 326 | + "lines": 32, | | 327 | + "gone": 28 | | 328 | + }, | | 329 | + "apps/web/src/components/media/mediaContent.ts": { | | 330 | + "lines": 1, | | 331 | + "gone": 1 | | 332 | + }, | | 333 | + "apps/web/src/components/settings/IntervalSecondsField.tsx": { | | 334 | + "lines": 1, | | 335 | + "gone": 1 | | 336 | + }, | | 337 | + "apps/web/src/components/settings/scopedSettings.ts": { | | 338 | + "lines": 3, | | 339 | + "gone": 3 | | 340 | + }, | | 341 | + "apps/web/src/components/settings/useScopedSettings.ts": { | | 342 | + "lines": 5, | | 343 | + "gone": 5 | | 344 | + }, | | 345 | + "apps/web/src/remoteOpen.test.ts": { | | 346 | + "lines": 2, | | 347 | + "gone": 2 | | 348 | + }, | | 349 | + "apps/web/src/remoteOpen.ts": { | | 350 | + "lines": 1, | | 351 | + "gone": 1 | | 352 | + }, | | 353 | + "packages/contracts/src/editor.ts": { | | 354 | + "lines": 5, | | 355 | + "gone": 5 | | 356 | + }, | | 357 | + "packages/provider-core/src/server/managedProvider.ts": { | | 358 | + "lines": 10, | | 359 | + "gone": 8 | | 360 | + }, | | 361 | + "packages/shared/src/cliRelease.ts": { | | 362 | + "lines": 1, | | 363 | + "gone": 1 | | 364 | + }, | | 365 | + "packages/shared/src/usageLimits.ts": { | | 366 | + "lines": 1, | | 367 | + "gone": 1 | | 368 | + } | | 369 | + } | 210 | 370 | } |
Collapse file Copy file name to clipboardExpand all lines: .github/scripts/fork-seam-check.cjs +40-1Lines changed: 40 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -362,6 +362,18 @@ function findHiddenUpstreamFiles(upstreamFiles, isForkFile, atHead) { | 362 | 362 | ); | 363 | 363 | } | 364 | 364 |
| | 365 | +const KINDS = ["files", "pending", "forkFiles", "lost"]; | | 366 | +const SEAM_KEYS = ["why", "added"]; | | 367 | + | | 368 | +/** Refuses a key the check does not read (a misspelt block guards nothing); "//…" is a comment. */ | | 369 | +function refuseUnknownKeys(object, known, where) { | | 370 | + for (const key of Object.keys(object)) { | | 371 | + if (!key.startsWith("//") && !known.includes(key)) { | | 372 | + throw new Error(`${CONFIG}: ${where}unknown key "${key}" (known: ${known.join(", ")})`); | | 373 | + } | | 374 | + } | | 375 | +} | | 376 | + | 365 | 377 | const isStringList = (value) => | 366 | 378 | Array.isArray(value) && value.every((item) => typeof item === "string" && item.trim() !== ""); | 367 | 379 |
| @@ -372,13 +384,15 @@ function parseConfig(text) { | 372 | 384 | if (typeof files !== "object" || files === null || Array.isArray(files)) { | 373 | 385 | throw new Error(`${CONFIG}: "files" must be an object`); | 374 | 386 | } | | 387 | + refuseUnknownKeys(config, KINDS, ""); | 375 | 388 | for (const [file, seam] of Object.entries(files)) { | 376 | 389 | if (typeof seam?.why !== "string" || seam.why.trim() === "") { | 377 | 390 | throw new Error(`${CONFIG}: ${file} needs a "why"`); | 378 | 391 | } | 379 | 392 | if (!Array.isArray(seam.added) || seam.added.some((line) => typeof line !== "string")) { | 380 | 393 | throw new Error(`${CONFIG}: ${file}: "added" must be a list of lines`); | 381 | 394 | } | | 395 | + refuseUnknownKeys(seam, SEAM_KEYS, `${file}: `); | 382 | 396 | } | 383 | 397 | if (config.forkFiles !== undefined && !isStringList(config.forkFiles)) { | 384 | 398 | throw new Error(`${CONFIG}: "forkFiles" must be a list of paths`); | @@ -431,6 +445,21 @@ function parseConfig(text) { | 431 | 445 | return { files, pending, forkFiles: config.forkFiles ?? [], lost }; | 432 | 446 | } | 433 | 447 |
| | 448 | +/** | | 449 | + * Why a pull request's own list cannot become main's (its format only: its rules are not in force | | 450 | + * here), or undefined. Merged, a malformed list crashes every later run, the fix's run included. | | 451 | + */ | | 452 | +function ownListProblem(text) { | | 453 | + const own = `this change's own ${CONFIG}`; | | 454 | + if (text === undefined) return `${own}: this change deletes it.`; | | 455 | + try { | | 456 | + parseConfig(text); | | 457 | + return undefined; | | 458 | + } catch (error) { | | 459 | + return `${own} is malformed: ${error instanceof Error ? error.message : error}`; | | 460 | + } | | 461 | +} | | 462 | + | 434 | 463 | const hasConfig = (rev) => entryAt(rev, CONFIG)?.type === "blob"; | 435 | 464 |
| 436 | 465 | /** Reads `<rev>:.github/fork-seams.json`; throws when that commit has none. */ | @@ -525,14 +554,24 @@ function main(argv) { | 525 | 554 | const from = parsed.configRef ? `--config-ref ${configRef}` : upstream ? "the head" : "the base"; | 526 | 555 | const notes = [...findListedGone(config, { atBase, atHead }), ...unlisted.notes, ...lost.notes]; | 527 | 556 | for (const note of notes) console.log(`Note: ${note}`); | 528 | | - if (!upstream && textAt(head, CONFIG) !== textAt(mergeBase, CONFIG)) { | | 557 | + const ownList = textAt(head, CONFIG); | | 558 | + const editsList = !upstream && ownList !== textAt(mergeBase, CONFIG); | | 559 | + const listProblem = editsList ? ownListProblem(ownList) : undefined; | | 560 | + if (editsList) { | 529 | 561 | console.log( | 530 | 562 | `Note: this change edits ${CONFIG}; it is judged by the list in ${from}, not its own. ` + | 531 | 563 | "A new seam or list entry takes effect once the owner merges it.", | 532 | 564 | ); | 533 | 565 | } | 534 | 566 | const counted = upstream ? "every upstream file" : "every upstream file it changes"; | | 567 | + if (listProblem !== undefined) { | | 568 | + console.error(listProblem); | | 569 | + console.error( | | 570 | + `Fix the list in this change: merged, it is main's list, and a malformed one stops every later pull request and fork-follow run.`, | | 571 | + ); | | 572 | + } | 535 | 573 | if (reasons.length === 0 && ceilings.length === 0) { | | 574 | + if (listProblem !== undefined) return 1; | 536 | 575 | console.log( | 537 | 576 | `Fork lines in upstream files: only the pinned seams (${counted}; list from ${from}).`, | 538 | 577 | ); | |
Collapse file Copy file name to clipboardExpand all lines: .github/scripts/fork-seam-check.test.cjs +58Lines changed: 58 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -345,13 +345,27 @@ test("a malformed config throws instead of guarding nothing", () => { | 345 | 345 | { files: SEAM, lost: { "a.ts": { lines: 2, gone: 3 } } }, | 346 | 346 | { files: SEAM, lost: { "a.ts": { lines: 2, gone: 1, why: "x" } } }, | 347 | 347 | { files: SEAM, lost: { "b.ts": { lines: 1, gone: 0 } } }, | | 348 | + // Unknown kinds: a misspelt block or seam key would silently guard nothing. | | 349 | + { files: SEAM, lsot: {} }, | | 350 | + { files: SEAM, Pending: { "p.ts": 1 } }, | | 351 | + { files: { "a.ts": { ...SEAM["a.ts"], add: ["x"] } } }, | 348 | 352 | ...["/abs", "../up", "**", "*", "!", "a/../b"].map((pattern) => ({ | 349 | 353 | files: {}, | 350 | 354 | forkFiles: [pattern], | 351 | 355 | })), | 352 | 356 | ]) { | 353 | 357 | assert.throws(() => parseConfig(JSON.stringify(bad)), JSON.stringify(bad)); | 354 | 358 | } | | 359 | + // Keys that start with "//" are comments, at the top and in an entry. | | 360 | + assert.doesNotThrow(() => | | 361 | + parseConfig( | | 362 | + JSON.stringify({ | | 363 | + "//": "c", | | 364 | + "//pending": "c", | | 365 | + files: { "a.ts": { ...SEAM["a.ts"], "//": "c" } }, | | 366 | + }), | | 367 | + ), | | 368 | + ); | 355 | 369 | assert.deepEqual(parseConfig(JSON.stringify({ files: SEAM })), { | 356 | 370 | files: SEAM, | 357 | 371 | pending: {}, | @@ -503,6 +517,50 @@ test("a pull request that widens or drops its own list is judged by main's list" | 503 | 517 | }); | 504 | 518 | }); | 505 | 519 |
| | 520 | +// A pull request is judged by main's list, so its own list was never parsed before merge: a | | 521 | +// malformed one (bad JSON, the old plain-number "lost", an unknown kind, or none) then made every | | 522 | +// later pull request and fork-follow run crash (exit 3), the pull request that fixes it included. | | 523 | +test("a pull request's own list is parsed for its format (never its rules) and refused when malformed", () => { | | 524 | + withRepo(({ git, commit, run, fromUpstream }) => { | | 525 | + const main = commit({ ...seams({ files: SEAM }), ...BASE }, "main"); | | 526 | + const heads = { | | 527 | + 'old plain-number "lost"': [ | | 528 | + seams({ files: SEAM, lost: { "a.ts": 3 } }), | | 529 | + /"lost": a\.ts needs/, | | 530 | + ], | | 531 | + "bad JSON": [{ [CONFIG]: '{"files": {' }, /JSON/], | | 532 | + "an unknown kind": [seams({ files: SEAM, lsot: {} }), /unknown key "lsot"/], | | 533 | + "no list": [{ [CONFIG]: null }, /this change deletes it/], | | 534 | + }; | | 535 | + for (const [what, [files, message]] of Object.entries(heads)) { | | 536 | + git("checkout", "-q", "-f", "-B", "pr", main); | | 537 | + const pr = commit(files, what); | | 538 | + for (const args of [ | | 539 | + [main, pr], | | 540 | + ["--config-ref", main, main, pr], | | 541 | + ]) { | | 542 | + const result = run(...args); | | 543 | + assert.equal(result.status, 1, `${what}: ${result.stdout}${result.stderr}`); | | 544 | + assert.match(result.stderr, /this change's own \.github\/fork-seams\.json/, what); | | 545 | + assert.match(result.stderr, message, what); | | 546 | + assert.match(result.stderr, /Fix the list in this change/, what); | | 547 | + assert.doesNotMatch(result.stderr, /a file of the fork's own/, what); | | 548 | + } | | 549 | + } | | 550 | + // A well-formed list passes, whatever its rules (main's list judges the change). | | 551 | + git("checkout", "-q", "-f", "-B", "pr", main); | | 552 | + const wide = { | | 553 | + files: { "a.ts": { why: "mine", added: ["anything: 1,"] } }, | | 554 | + pending: { "z.ts": 9 }, | | 555 | + }; | | 556 | + const fine = commit(seams(wide), "a wider list"); | | 557 | + assert.equal(run(main, fine).status, 0); | | 558 | + // From upstream the head's list is the one in force: malformed, it is still a crash. | | 559 | + const broken = commit(seams({ files: SEAM, lost: { "a.ts": 3 } }), "broken"); | | 560 | + assert.equal(fromUpstream(main, broken).status, 3); | | 561 | + }); | | 562 | +}); | | 563 | + | 506 | 564 | // Every upstream file on the command line, from upstream (no list there: the series' own list judges it) and | 507 | 565 | // from main with a list that predates "pending" and "forkFiles" (the first run after this change). | 508 | 566 | test("every upstream file counts on the command line, from upstream and from main", () => { | |
|