Repository navigation
Commit f3fea0a
refactor(service-automation): move 14 delete-bearing AutomationEngine bodies into their seam modules (#25725)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XPa8wo37pD4eagmNazfkued)_
Part of #25222 (slice 8a of the `engine.ts` split; #25222 remains open
for slice 8b, `resumeInternal`).
Clause-②: no
Metadata-protocol: none
Claim 6391244018 (`domain:server` seat 1). Ruling-ref: 6384677413
(ruling B: slice 8 after the census reader, landed as #25660) and
6348891160 (the series' `.d.ts` bar). Resumed from the trial commit
`claude/project-thread-nirtwt@6305caf` that Release 6385919610 handed
over, rebuilt onto `main` `f6ba1343b` and re-proved there.
## What moved
Move-only. The bodies of 14 `AutomationEngine` methods move, token for
token, to the end of the seam module that already holds their section.
No new module. Each class method keeps its name, docblock, signature and
position, and calls its body with a host literal of exactly the members
the body reads.
- `dispatch-claims.ts`: `pruneInProcessDispatchClaims`
- `run-resume.ts`: `persistSuspendedRun`, `forgetSuspendedRun`,
`evictConsumedSuspension`, `takeSubflowParentStrand`
- `plugin-extension-api.ts`: `unregisterNodeExecutor`,
`unregisterTrigger`, `unregisterConnector`
- `flow-definitions.ts`: `unregisterConnectorProvider`, `withdrawFlow`,
`hydrateFlowActivations`, `toggleFlow`
- `consumed-suspension-restore.ts`: `journalConsumedSuspension`,
`restoreOneConsumedSuspension`
Shape B, as in slices 1 to 7. Methods go to the host as late-bound
closures, so a spy set on the instance is still the one called. `store`
and `flowActivationStore` go through getters, because
`setSuspendedRunStore` and `setFlowActivationStore` reassign them. Every
other field goes by value: a grep for `this.FIELD =` over the package
source finds only the constructor's `this.logger = logger` among them,
so the value passed is the field, including where an async body reads it
after an `await`. The five async stubs drop `async` and return the
promise the moved function makes. `forgetSuspendedRun` keeps its
`durableRecordAlreadyConsumed = false` default in both places.
`engine.ts` exports nothing new: the bodies read only names already
exported (`IN_PROCESS_DISPATCH_CLAIM_TTL_MS`,
`MAX_CONSUMED_SUSPENSIONS`, `buildRunTrigger`, and types).
The six bodies Release 6385919610 names as stays (`execute`,
`bubbleToParent`, `registerFlow`, `activateFlowTrigger`,
`deactivateFlowTrigger`, `declineOntoDisabledSubflows`) stay, for its
reasons. Slice 8b (`resumeInternal`) is a later PR.
## Rebuilt onto current `main`
The trial sat on `9dac9eb8d6`. Since then `main` changed `engine.ts`
(#25703 adds the constructor-read field `credentialResolver`) and
`flow-definitions.ts` (#25643, #25703). The rebuild is a cherry-pick of
`6305caf7` onto `f6ba1343b` with one textual conflict: both sides
appended members to `FlowDefinitionsHost` (`credentialResolver` from
`main`, ten members from the trial); both are kept. None of the 14
bodies reads `credentialResolver` (measured below), so no host gains it.
## One reader the trial missed: `flow-activation-ledger.test.ts`
The trial's readings did not include vitest. On the rebuilt tree one
test went red: the pin "the only writers of the activation projection
are hydration and toggleFlow" cuts the engine's sources into members and
asks which member writes `flowLedgerDisabled`. It cut on a
four-space-indented line, which is a member's name in `engine.ts` but an
ordinary statement inside a top-level function, so once
`hydrateFlowActivations` and `toggleFlow` moved, the pin cut them
mid-body and named a chunk carrying neither name. The pin now cuts a
seam module only where a line starts in column 0, and keeps its
`engine.ts` split (second commit, test file only). Control: with
`this.flowLedgerDisabled.add(name);` injected into the moved
`withdrawFlow` body, the pin goes red and names `withdrawFlow`; the file
was restored by `git checkout HEAD --` and its hash matched the HEAD
blob `f711ccad`.
## Move proof (TypeScript AST, base `f6ba1343b`, head `035ed1efa`)
- All 14 moved functions are token-identical to their base method: AST
leaf tokens (kind and text) of the body, the parameters (the head's
`this` parameter dropped), the return type and the `async` modifier.
Body token counts: 41, 106, 103, 33, 30, 64, 103, 22, 22, 74, 129, 266,
134, 731.
- Negative controls: a one-token on-disk edit in a scratch copy (`rec.at
< cutoff` to `rec.at <= cutoff` in `pruneInProcessDispatchClaims`) reads
DIFFERENT, and so does an in-memory one-token change to `toggleFlow`.
- Hosts: for each of the 14, the set of `this.X` reads in the moved body
equals the `Pick` keys of its `this` type, which equals the keys of the
class stub's host literal, and the stub calls the function of its own
name. No moved body reads `credentialResolver`.
- Every line deleted from `engine.ts` (590) is found among the modules'
added lines, except the five `async` signature lines the stubs drop and
the 12 lines of the four rewritten import comments.
## Readers, byte-identical at both ends
Taken in two worktrees, base `f6ba1343b` and head (re-taken on the final
head):
- `check-startup-registry-verdict`: 46 seams across 3,491 files, 39
read-only, both ends; `--list` identical apart from `engine.ts` line
numbers, so `registerFlow`'s line is unchanged; `--self-test` identical.
- Tenant-audit census: `check-tenant-audit-census.mjs` and its
`--self-test` identical (238 write call sites certified, 162 decidable,
23 prose figures, every `UNTYPED_RECEIVERS` row matched);
`tenant-audit-census.mjs` human output identical; `--json` identical
apart from its `ref` field, the measured commit.
- `check-system-context-census` and its `--self-test` identical (149
elevation read sites in 77 files, 129 symbols); `isystem-census.mjs
--json` identical.
- `check-platform-checklist` (986 of 996 symbol anchors, the 10 on the
#16898 residual), `check-adr-symbol-anchors` (2,384 anchors across 142
records), `check-adr-anchors`, and spec `check:liveness` (1,187
classified): each output identical.
## `.d.ts` and bundles
- `dist/index.d.ts` is raw byte-identical at both ends, sha256
`a5cbe3bbb8aff2805674e1d9f119946199697e469a3e8a5b9bc7eb4fc08bc7cb`
(`index.d.cts` the same bytes), so the ruling's normalised identity
holds trivially.
- ESM and CJS export lists: 39 names each, the same list in both
bundles, identical at both ends, with each export's `typeof` and
function name unchanged.
## Tests and gates (head `035ed1efa`)
- `@objectstack/service-automation` vitest: Test Files 201 passed (201),
Tests 2636 passed (2636), the same at base `f6ba1343b`. Package
`typecheck` (`tsc --noEmit` and `check:test-typecheck`) passes; ESLint
over the package is clean.
- `dispatch-gates --commands` derives 60 families on the 7 paths; all 60
exit 0, and `--ran` reconciles 60 derived, 60 run, 0 NOT-MEASURED from
recorded exit codes. Two needed a prerequisite first, not a fix:
`check-plugin-teardown-shape --self-test` needed its pinned fixture
commit fetched into this shallow clone, and `check:dual-build-cjs-loads`
needed the workspace's `dist/` trees.
- `check-governed-merges --branch`: 0 of 7 paths on the register, NOT
governed; 1,582 changed lines, under 3,000.
- `skip-changeset`: nothing published changes (the `.d.ts` bytes and the
export lists are identical).
## Acceptance notes
- Two comments in moved bodies point by position at text that is now in
another file: `unregisterTrigger`'s "see `forgetSuspendedRun`'s catch
above" (now in `run-resume.ts`) and `persistSuspendedRun`'s "the
docblock above argues it" (the docblock stays on the class method in
`engine.ts`). Moved unedited, as slices 1 to 7 did with theirs.
- `main` moved after the base (#25710, #25720); neither touches
`packages/services/service-automation`.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01UMkNEokXPqZh51HTHCnyph)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 43edf90 commit f3fea0a
7 files changed
Lines changed: 932 additions & 650 deletions
File tree
- packages/services/service-automation/src
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
8 | 9 | | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
18 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
19 | 32 | | |
20 | 33 | | |
21 | 34 | | |
| |||
201 | 214 | | |
202 | 215 | | |
203 | 216 | | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1030 | 1030 | | |
1031 | 1031 | | |
1032 | 1032 | | |
1033 | | - | |
| 1033 | + | |
1034 | 1034 | | |
1035 | | - | |
| 1035 | + | |
| 1036 | + | |
1036 | 1037 | | |
1037 | 1038 | | |
1038 | 1039 | | |
| |||
1051 | 1052 | | |
1052 | 1053 | | |
1053 | 1054 | | |
1054 | | - | |
1055 | | - | |
1056 | | - | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
1057 | 1063 | | |
1058 | 1064 | | |
1059 | 1065 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
8 | 9 | | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
14 | 17 | | |
15 | 18 | | |
16 | 19 | | |
| |||
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
50 | 55 | | |
51 | 56 | | |
52 | 57 | | |
| |||
72 | 77 | | |
73 | 78 | | |
74 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
75 | 90 | | |
76 | 91 | | |
77 | 92 | | |
| |||
392 | 407 | | |
393 | 408 | | |
394 | 409 | | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
0 commit comments