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
Three cleanups in durable's service-result code, from the reviews of #235. None changes behavior.
Settle output through a shared holder. The JSON and Go type a settle decoded reach serviceStep through a mutable holder (settledJSON) that the result transform writes as a side effect. Each settle path, and Recover after replay, must remember to call take(), or the next step journals a previous settle's bytes. Passing the raw JSON and type back through the settle's own outcome would remove the coupling.
typeName runs on every settle.decodedAsRecorded and the live settle rebuild the full type spelling, a recursive reflect walk, once per Record or call. Caching it per reflect.Type (for example in a sync.Map) makes it one walk per type.
fullTypeName re-spells reflect type names. About 140 lines (chanTypeName, signatureName, structTypeName, interfaceTypeName, qualifiedName) re-implement reflect.Type.String with import paths, for result types a service rarely returns. Check whether PkgPath()+"."+Name() for named types, plus a smaller fallback, keeps the import-path tests from fix(durable): dispatch effects from Start, Tick and RunService #235 passing.
Two passes over the tail.checkNotNewer and checkFormats each walk the whole tail and always run together (Recover, StateAt, Steps). One pass tracking the running maximum could refuse both a newer-than-supported format and a decrease, so a new reader can't call one and forget the other.
StartEffects built twice per checkpoint.parkedServices and endedServices each call h.inst.StartEffects() on every due checkpoint, under the step lock. Computing it once in appendStep and passing it to both would halve that.
Copies of the recover-to-error guard.marshalEffect adds a fifth copy of the defer/recover pattern already in marshalPayload, errorMessage, decodePayload and applyEffect, and the copies already word the panic differently. decodedAsRecorded also repeats decodedAsPassed's nil and generic-form acceptance and its error text. A shared recoverErr helper, and one type check that takes a reflect.Type or a recorded name, would remove both.
Three constants for one format bump, and repeated locked-step shells.dispatchedStepsFormat, tickDriversFormat and decodedResultsFormat all mean format 2. lockedFireStep, lockedTickStep and lockedServiceStep repeat the same release and failOnPanic shell; one helper would do.
fooddelivery's float64 case.recordRefund type-switches on float64 to take the JSON-generic result, and int64(v) loses precision above 2^53. Registering DecodeAs[int64] for Refunded in the durable wiring would show the decoder path instead. That example module doesn't import durable today, so this needs a small rig change.
Three copies of the step tail.tickStep, fireStep and serviceStep each take the actor-driven parent Fires, check for a context refusal, call recordParentFires, build the Record from drainClock plus those entries, and call recordStep. The context rule already differs: Tick and Fire use refusedByContext, RunService uses stepCanceled. One recordDriven(ctx, rec, effects, cancelCheck) helper would keep them in step.
Settled and parked as two maps. Every writer must update both (forgetServices, armMirror.forget, markSettled, armMirror.settle), and comments explain why they can't disagree. A single map[string]serviceMark shared by the Handle and the mirror would make that structural.
absorbParentFire repeats absorbServices inline (forgetServices, then svc.Absorb). It could call the helper, so service bookkeeping lives in one place.
A dead marshal error path.recordServiceOutcome now wraps bytes that marshalPayload already produced and an error message already normalized, so its json.Marshal can't fail in practice. The same goes for parkResult's marshal. The h.fail branches after them in serviceStep and parkResult have no test and suggest failures that can't happen.
Live steps copy the whole dispatched set. Each live Fire, Tick or RunService with an effect reads the instance's whole lifetime dispatched set, and MemStore and FileStore copy it on every call, just to test one or two ids. Recover's cached copy (maps.Clone) adds another copy. The cost grows with the instance's life. A membership check for only the ids in the step, for example an optional DispatchedAmong(ctx, id, ids) on DispatchStore, would be far cheaper. That's new API, so it's a design question.
Recover repeats checkJournal inline.StateAt and Steps call checkJournal (checkNotNewer then checkFormats), while Recover calls the pair itself, with its own error prefix. A new format rule added to checkJournal would skip Recover. Have Recover call it (taking the verb for the message), and merge the two tail walks into one pass.
One name per journal format.tickDriversFormat and dispatchedStepsFormat are both 2 and gate the same bump; one constant documenting both behaviors avoids splitting the replay and dispatch gates by accident. errorMessage is now only called by normalizedErrorMessage and can fold into it.
absorbParentFire and absorbSettle re-spell the forget, timer and service order that absorbDrivers already has; three copies can drift from replayArm and replayRunners.
Five near-copies of the absorb sequence.absorbDrivers, absorbSettle, absorbParentFire, absorbRunners and absorbServices each repeat forget settles, arm timers, hand to services and hand to actors, with a step left out or reordered; replayArm and replayRunners repeat it on replay. One absorb that takes which drivers to feed would keep the order in one place.
hasSpawnEffect repeats the SpawnActor scan that declaredActors and parentFires.attempt already do.
absorbActors feeds the actor system one effect at a time, taking the collector lock and calling AbsorbFor for every effect, including ones the actor system ignores (ScheduleAfter, StartService, domain effects). Skipping non-actor effects first would avoid that.
absorbRunners is a one-line wrapper used only by absorbDrivers.
Activity
reka18 commentedon Nov 17, 2026
Two more from a later review of #235, same kind:
checkNotNewerandcheckFormatseach walk the whole tail and always run together (Recover, StateAt, Steps). One pass tracking the running maximum could refuse both a newer-than-supported format and a decrease, so a new reader can't call one and forget the other.StartEffectsbuilt twice per checkpoint.parkedServicesandendedServiceseach callh.inst.StartEffects()on every due checkpoint, under the step lock. Computing it once inappendStepand passing it to both would halve that.reka18 commentedon Nov 17, 2026
Three more from the next review of #235:
marshalEffectadds a fifth copy of the defer/recover pattern already inmarshalPayload,errorMessage,decodePayloadandapplyEffect, and the copies already word the panic differently.decodedAsRecordedalso repeatsdecodedAsPassed's nil and generic-form acceptance and its error text. A sharedrecoverErrhelper, and one type check that takes areflect.Typeor a recorded name, would remove both.dispatchedStepsFormat,tickDriversFormatanddecodedResultsFormatall mean format 2.lockedFireStep,lockedTickStepandlockedServiceSteprepeat the same release andfailOnPanicshell; one helper would do.float64case.recordRefundtype-switches onfloat64to take the JSON-generic result, andint64(v)loses precision above 2^53. RegisteringDecodeAs[int64]forRefundedin the durable wiring would show the decoder path instead. That example module doesn't importdurabletoday, so this needs a small rig change.reka18 commentedon Nov 17, 2026
Two more from the next review of #235:
tickStep,fireStepandserviceStepeach take the actor-driven parent Fires, check for a context refusal, callrecordParentFires, build the Record fromdrainClockplus those entries, and callrecordStep. The context rule already differs: Tick and Fire userefusedByContext, RunService usesstepCanceled. OnerecordDriven(ctx, rec, effects, cancelCheck)helper would keep them in step.forgetServices,armMirror.forget,markSettled,armMirror.settle), and comments explain why they can't disagree. A singlemap[string]serviceMarkshared by the Handle and the mirror would make that structural.reka18 commentedon Nov 17, 2026
Two more from the next review of #235:
absorbParentFirerepeatsabsorbServicesinline (forgetServices, thensvc.Absorb). It could call the helper, so service bookkeeping lives in one place.recordServiceOutcomenow wraps bytes thatmarshalPayloadalready produced and an error message already normalized, so itsjson.Marshalcan't fail in practice. The same goes forparkResult's marshal. Theh.failbranches after them inserviceStepandparkResulthave no test and suggest failures that can't happen.reka18 commentedon Nov 17, 2026
One more from the next review of #235:
maps.Clone) adds another copy. The cost grows with the instance's life. A membership check for only the ids in the step, for example an optionalDispatchedAmong(ctx, id, ids)on DispatchStore, would be far cheaper. That's new API, so it's a design question.reka18 commentedon Nov 17, 2026
One more from the last review of #235:
RecoverrepeatscheckJournalinline.StateAtandStepscallcheckJournal(checkNotNewerthencheckFormats), whileRecovercalls the pair itself, with its own error prefix. A new format rule added tocheckJournalwould skipRecover. HaveRecovercall it (taking the verb for the message), and merge the two tail walks into one pass.reka18 commentedon Nov 17, 2026
From the review of slim #235 (fe94eea):
tickDriversFormatanddispatchedStepsFormatare both 2 and gate the same bump; one constant documenting both behaviors avoids splitting the replay and dispatch gates by accident.errorMessageis now only called bynormalizedErrorMessageand can fold into it.absorbParentFireandabsorbSettlere-spell the forget, timer and service order thatabsorbDriversalready has; three copies can drift fromreplayArmandreplayRunners.reka18 commentedon Nov 17, 2026
From the second review of slim #235 (a2bd493):
absorbDrivers,absorbSettle,absorbParentFire,absorbRunnersandabsorbServiceseach repeat forget settles, arm timers, hand to services and hand to actors, with a step left out or reordered;replayArmandreplayRunnersrepeat it on replay. One absorb that takes which drivers to feed would keep the order in one place.hasSpawnEffectrepeats theSpawnActorscan thatdeclaredActorsandparentFires.attemptalready do.reka18 commentedon Nov 17, 2026
From the fourth review of slim #235 (c393fd3):
absorbActorsfeeds the actor system one effect at a time, taking the collector lock and callingAbsorbForfor every effect, including ones the actor system ignores (ScheduleAfter,StartService, domain effects). Skipping non-actor effects first would avoid that.absorbRunnersis a one-line wrapper used only byabsorbDrivers.