Repository navigation
refactor(service-automation): AutomationEngine becomes a delegating facade over eight facet modules (steps 2 and 3 of the engine split) - #38889
Conversation
…nto eight facet modules behind one-call stubs (wip) Claude-Session: https://claude.ai/code/session_01QSeKYka8mG8XtvFU8AvP9X Co-authored-by: Claude <noreply@anthropic.com>
… line ceiling and its seven exceptions Claude-Session: https://claude.ai/code/session_01QSeKYka8mG8XtvFU8AvP9X Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QSeKYka8mG8XtvFU8AvP9X Co-authored-by: Claude <noreply@anthropic.com>
…aps a facet body deletes from, and the regenerated service-automation shard Claude-Session: https://claude.ai/code/session_01QSeKYka8mG8XtvFU8AvP9X Co-authored-by: Claude <noreply@anthropic.com>
…odules that now hold the engine bodies they name Claude-Session: https://claude.ai/code/session_01QSeKYka8mG8XtvFU8AvP9X Co-authored-by: Claude <noreply@anthropic.com>
…commit on this branch Claude-Session: https://claude.ai/code/session_01QSeKYka8mG8XtvFU8AvP9X Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 2 package(s): 55 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 19 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 182 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 190e3d63723078f53b7c0639955d46c6245e7085 && git checkout 190e3d63723078f53b7c0639955d46c6245e7085
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 3c617a28ea51f0d4a2d11f180dc3ee57106a7151 8b19bf8bbfdf745e0130172a7174c8a725102c9e && git checkout -B drift-repro 3c617a28ea51f0d4a2d11f180dc3ee57106a7151 && git merge --no-ff 8b19bf8bbfdf745e0130172a7174c8a725102c9e
node scripts/docs-audit/affected-docs.mjs --json 3c617a28ea51f0d4a2d11f180dc3ee57106a7151
|
|
repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2 Contract reviewServed-tier: Read-only by the lane seat: the diff from merge base to this head (17 files, +5,369/-2,567), the PR body's move evidence, card #38667 with the maintainer's ruling 7305055957 and dev report 7307158011, and the head's check-runs. The diff is on the declaration face only: no file under ① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
|
repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2 L1 ACCEPT · PR #38889 (#38667, steps 2+3) · head 席位核对 · ACCEPTACCEPT · repo:objectstack@os-justin · head
|
|
repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2 维护者速读
Head-sha: Approval requested for PR #38889 at the head above: the seat's L1 ACCEPT is 7309148209 and the contract review PASS ( |
repo:objectstack@os-justin · os-justin · session_01QSeKYnrQ7UMtHofKQVjcH2
Fixes #38667
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
Steps 2 and 3 of the card, on top of step 1 (#38846, merged). Per the maintainer's ruling on this card (7305055957: 「A: keep the facade (Recommended)」), the 2,000-line target is dropped and the facade form holds.
AutomationEngineinpackages/services/service-automation/src/engine.tsbecomes a delegating facade: the bodies of 145 members move into static methods of eight facet classes, each body exactly as it stood (not re-indented, not formatted, not edited), with athisparameter added where the body reads the engine. Every member stays on the class with its signature and (when public) its docblock as a one-call stub,return XFacet.m.call(xHost.of(this), …), so the published declaration, an instance spy and a subclass override are what they were. A private member's docblock moved with its body. The engine's state (all 74 fields) stays on the class.engine.tsgoes from 9,813 to 7,735 lines.The shape is the objectql
registry.tssplit's: each facet module declares theAutomationEnginemembers its bodies read as an interface typed by indexed access on the class (AutomationEngine['x']), so a member renamed or retyped on the class is a compile error in the facet; each method'sthisis thePickof that interface it reads.engine-facet-hosts.tsholds one host per facet per engine (aWeakMap, built on first use), filled by the factory the class's one static block installs: a method goes as a closure that calls it on the engine at call time, a field as a getter, and the five fields a body assigns (nodeTypeVocabularySealed,packagedFlowSource,packagedFlowDefaults,packagedFlowDefaultSource,flowCredentialSource) also with a setter. Facet modules importengine.tsfor types only, so there is no evaluation cycle;index.tsre-exports nothing from them.Every moved member and its new file
*marks a public member (its docblock stays on the class); every other member is private and its docblock moved with its body. "Host" is the number of engine members the facet's bodies read.engine-dispatch-facet.tsreadScheduledWorkPolicy,slotKeyedRunStore,missedRunLimit,recordMissedRun,noteRunStartedengine-extensions-facet.tsresolveTriggerBinding,activateFlowTrigger,triggerRun,deactivateFlowTrigger,getActiveTriggerBindings,assertSameOriginOrFree,connectorInstance,resolveConnectorAction,resolveConnectorActionInputSchema,resolveConnectorActionEffect,organizationLocale,getConnectorOrigin,getConnectorDegradedReason,getConnectorDegradedHold,registerConnectorProvider,unregisterConnectorProvider,getRegisteredConnectorProviders,getConnectorDescriptors,getRegisteredNodeTypes,getActionDescriptors,getRegisteredTriggerTypes,knownNodeTypes,getUnknownNodeTypeAudit,sealNodeTypeVocabulary,getSealedNodeTypeVocabulary,warnUnknownNodeTypesengine-flow-slots-facet.tsflowArmHolder,loaderOwnerOf,placeFlowSlot,bindPackagelessActivation,flowActivationBinds,moveFlowRecords,flowKeyNow,sharedFlowNameRefusal,resolveFlowKey,bareFlowKey,servedBareFlowKey,isDisabledHolderSlot,isDisabledSoleHolder,flowSlotPackage,flowSlotName,flowSlotKeysOf,loneSharedFlowKey,settleFlowName,isSharedFlowKey,executeSlot,setPackagedFlowSource,setPackagedFlowDefaultSource,packagedFlowOwner,inboundHookSlot,disabledHolderHookRefused,packagedFlowSlotOwner,isPackagedFlow,refuseUnpackagedDefaultActive,isShippedFlowName,packagedFlowDefault,refreshPackagedFlowDefaults,flowNameRefusal,connectorNameRefusal,resolveConnectorInstanceFor,codeRegisteredInstance,flowCallerPackage,armedFlowPackage,flowHolder,durableFlowHolder,flowHolderPackage,flowDispatchHolderengine-registration-facet.tsjudgeFlowRegistration,dryRun,registerFlow,unregisterFlow,withdrawFlow,withdrawFlowSlot,withdrawFlowKey,recordFlowRefusal,getFlowRegistration,recordFlowShadowing,getShadowedFlows,listFlows,getFlow,getRunFlow,flowKeyOfRun,getFlowSlot,getHeldFlow*,registrationChecks,validateFlowExpressions,getValueType,validateNodeInputSchemasengine-connector-doors-facet.tssetFlowCredentialSource,pullConnectorSource,requireConnectorCredentialDoor,attachConnectorCredentialPubSub,resyncConnectorCredentialPubSub,listConnectorCredentialRefs,setConnectorCredential,clearConnectorCredential,requireConnectorConnectionDoor,getConnectorConnection,beginConnectorConnection,completeConnectorConnection,revokeConnectorConnection,holdsFlowCredential,resolveFlowCredential,flowCredentialHoldingsengine-enablement-facet.tsisFlowEnabled,describeDisabledFlow,subflowTargets,resolvedFlowCallKey,declineOntoDisabledSubflows,declineOntoSuspendingSubflowNotice,declineOntoRegionSuspendingCall,declineOntoSubflowRetriedCallout,toggleFlow,toggleFlowSlot,getFlowVersionHistory,rollbackFlowengine-run-facet.tsgetFlowBodyChecksum,execute,failRunBeforeFirstNode,executeKey,runRegion*,retryExecution,recordLog,compactStepsForHistoryengine-resume-facet.tspersistSuspendedRun,claimAdvance,resolveSuspendedNodeType,resolveDeclaredResumeAuthority,resolveSuspensionChainForCancel,hasSuspendedRun,unresumableSuspensionCause,recoverStoredFlow,heldFlowVersion,suspendedMapParentOf,suspensionOf,refuseInvalidScreenInput,buildSubflowResumeSignal,bubbleToParent,refuseRestore,getSuspendedScreen*engine-facet-hosts.tsFacetHostholder and the eight host instancesThe cut: run (
getFlowBodyChecksumwith the run checksum from #38825,execute,executeKey,runRegion,retryExecution, the run log), resume (suspension persistence and claims, resume authority, the suspension chain, screen input, bubbling to the parent, restore refusals), registration (registerFlow, judging, withdrawing, refusals, shadowing, reading flows back, the registration-time checks), plus flow slots, dispatch, extensions (triggers, connectors, providers, resolvers, the node-type vocabulary), connector doors and enablement (subflow guards, toggles, version history, rollback).getRunFlowChecksumwas already a one-call delegation torun-flow-checksum.tsand stays as it was.Stay on the class. All fields; the 127 members that were already delegations at the base (the #25222 per-call host stubs and plain forwards: the facade gate accepts them as they are, and converting them is not part of this card per the ruling); and seven members with
exceptionsrows (card #38667), each with its reason in the registry:constructor: state-owning, it writes the engine's fields from its arguments.flowSlots,flowLedgerDisabled,flowCallKey: fields whose initializers hold arrows over the engine's own state; they run at construction, or are the value itself.resolveCanonicalDescriptor,resolveResumeAuthority,walkSuspensionChain: their bodies read private statics of the class (MAX_ALIAS_HOPS,RESUME_AUTHORITY_WHEN_UNDECLARED,MAX_SUSPENSION_CHAIN_DEPTH,LINKED_RUN_PREFIXES), which a module outside the class cannot read.The facade gate (ask 3)
scripts/facade-delegation-registry.jsongains afacadesrow forAutomationEngine(card #38667), aceilingsrow forengine.ts(baseLines7735 atbaseCommit53e745f,maxLines7835 =CEILING_MARGIN100, ruling 6897467376) and the sevenexceptionsrows above. The gate's self-test holdsDECLARED_WATCH_HINTSequal to the registry's facade files, soscripts/check-facade-delegation-only.mjsgains the one path string; nothing else in the gate changes.Gate citations of the moved code, edited outside the package (declared)
scripts/facade-delegation-registry.json: the rows above.scripts/check-facade-delegation-only.mjs: oneDECLARED_WATCH_HINTSstring.scripts/tenant-audit-census.mjs: 14UNTYPED_RECEIVERSrows (engine: false), one per facet file and receiver: the engine's own in-memoryMap/Setfields a facet body calls.delete(...)on. Inside the class the census read the field's type; throughAutomationEngine['x']on the host it cannot.docs/audits/2026-08-tenant-audit-write-call-sites.counts/services/service-automation.md: the shard regenerated bynode scripts/tenant-audit-census.mjs --write. Two of those deletes,this.flowRefusals.delete(name)andthis.sharedSlotTriggerWarned.delete(name)inengine-registration-facet.ts, are now placed as engine writes by the census'sname: stringparameter rule (they are in-memory map deletes, not data-engine writes), so the shard counts 42 write sites where it counted 40. A precision limit of the census through the host, noted here, not worked around: the bodies are moved unedited.packages/spec/liveness/flow.jsonandconnector.json: 10 citations re-pointed to the module that now holds the body they name (engine-run-facet.ts#retryExecutionand the retry-backoff keys;engine-extensions-facet.ts#getConnectorDescriptors); no verdict changes. The ledger ships in@objectstack/spec, so the changeset names that package with apatchtoo.Net growth past a pure move (package source: 9,813 lines in
engine.tsbefore; 7,735 + 4,659 in the facets + 61 in the hosts module after, +2,642)engine.ts(git diff --numstat: +469 -2,547): 145 one-line forwarding calls; the static host block (266 lines); a 12-line import block for the facets and hosts; the rest are stub signatures re-spelled (asyncdropped so each stub returns the facet's own promise;registrationChecksandvalidateFlowExpressionstake their destructured option bag asoptionsand hand it on). Import specifiers only the moved bodies read are pruned.this:line where the parameter list is multi-line. The signatures exist on both sides by design (the class keeps the contract).thislinesengine-dispatch-facet.tsengine-extensions-facet.tsengine-flow-slots-facet.tsengine-registration-facet.tsengine-connector-doors-facet.tsengine-enablement-facet.tsengine-run-facet.tsengine-resume-facet.tsengine-facet-hosts.ts: 61 lines, new.Tests
No test file changed.
service-automation typecheck and suite at 91b6bff: 301 files, 4,468 tests pass
Dependency closure built (
os-verify-lock.sh -c "pnpm --filter '@objectstack/service-automation^...' build --concurrency=2", VERDICT command-exit 0);pnpm --filter @objectstack/service-automation typecheck(tsc pluscheck:test-typecheck) VERDICT command-exit 0;pnpm --filter @objectstack/service-automation exec vitest run --maxWorkers=2:Test Files 301 passed (301),Tests 4468 passed (4468), VERDICT command-exit 0. The same 301 files and 4,468 tests asmain. Taken at 91b6bff, whose package source is the head's: the head's one later commit changes only the registry'sbaseCommit.Move verifier: 145 facet methods identical to the base member
A throwaway verifier (not committed) parses
engine.tsat main (f3f3265) and every facet module, and compares each facet method with the base member of the same name: body text, parameters (the addedthisaside), return type, type parameters,async, and for a private member its docblock.145 facet methods: 145 identical to the base member (body, parameters, return type, type parameters, async; a private member's docblock), 0 problem(s). Negative control: one token changed inengine-run-facet.tsredsgetFlowBodyChecksum: body.Published declaration, built at main (f3f3265) and at the head
dist/index.d.ts(anddist/index.d.cts, identical to it in both builds): 156 top-level declarations before and after, none added or dropped, the export list equal as a set (130 names), each module's import specifiers equal as sets. 152 declarations byte-identical,AutomationEngineamong them. The other 4 (SysAutomationRun,SysSyncRun,SysFlowDispatch,SysFlowCredential, Zod-inferred object shapes) are equal once the order the printer lists a string-literal union's members in is set aside ("code" | "secret" | "user" | "record"vs"user" | "secret" | "record" | "code": the same members). Positive controls on copies of the head build: renaming oneAutomationEnginemember, and changinggetFlowBodyChecksum(flow: unknown)to(flow: string), each redAutomationEngine.Facade gate
node scripts/check-facade-delegation-only.mjs: exit 0,AutomationEngine: 351 members — 273 delegations, 71 fields, 7 named exception(s) (#38667),engine.ts: 7735 lines, ceiling 7835 (100 left; ruling 6897467376),8 facade class(es) in 6 file(s) hold delegations only, 28 named exception(s).--self-test: 44 cases pass.Derived gate families at 8b19bf8
node scripts/pm/dispatch-gates.mjs --commands(no paths; derived from the tree of objectstack-ai/objectstack at 8b19bf8) named 100 commands; all 100 were run there, each exit code captured before any pipe, and--ranreconciled the record:100 derived famil(ies) accounted for — 98 run, 2 NOT-MEASURED (2 DERIVED from a recorded exit 3).Among the 98 at exit 0:
check:facade-delegation-onlyand the gate's--self-test,check-tenant-audit-censusand its self-test (with the 14 rows and the regenerated shard),pnpm --filter @objectstack/spec run check:liveness(red before the 10 citations were re-pointed, green after),check:platform-checklist,check:adr-anchors,check:system-context-census,check:dispatcher-error-vocabulary,check:pm-dispatch-gates,check-plugin-teardown-shapeand its self-test, and the changeset gates.NOT MEASURED (each exited 3, prerequisite not met: they read the built
dist/of every workspace package, and this container built only this package's dependency closure; CI runs them):pnpm check:dual-build-cjs-loadspnpm check:published-readme-exportsOutside the derived set:
node scripts/check-platform-checklist.mjs --changed-from origin/mainexit 0 (15 anchors judged, 0 lost).scripts/pm/overlap-check.mjs: merges cleanly into origin/main 3c617a2 (4 commits past this branch's base; they touch spec form/view conversions and the CLI, none of this PR's files).Acceptance notes
engine.tsis 7,735 lines, not below 2,000: the maintainer ruled the facade form holds and the 2,000-line target is dropped for this card (7305055957). What remains is the public docblocks (the published contract), the 74 documented fields, the stubs, the 127 earlier delegations with their docblocks, and the host block.plugin.tsis untouched: no helper of it moves with the engine's.engine.tsby more than 100 lines.Verification
Read first, by risk:
engine.ts, thestaticblock at the end of the class: every field a body assigns needs its setter there (five do), or the write lands on nothing; the eight host interfaces type-check that every member a body reads is there.engine-facet-hosts.ts: the host is built once per engine and cached, so a body'sthisis the same object across calls.engine-run-facet.tsexecuteKey: its one barethis(startConditionHolds.call(this, …)) now hands the run host, which carriesevaluateCondition, the one memberstartConditionHoldsreads.Two-minute check:
pnpm --filter @objectstack/service-automation test(expect 301 files, 4,468 tests passing) andnode scripts/check-facade-delegation-only.mjs(expect theAutomationEngineline: 351 members, 273 delegations, 71 fields, 7 named exceptions, andengine.ts: 7735 lines, ceiling 7835).Generated by Claude Code