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
{{ message }}
Repository navigation
Make the approval-ask id correlatable to a host-supplied id (or pin the deterministic askID as a public contract) #117
Closing — not needed. Superseded by the session-lease work (#60 / PR #119) plus the fact that the deterministic askID already rides the permission.ask event.
The original concern was that a host (Atrium) using its own signed, self-routing approval id has to reconcile it with mecatl's engine-minted askID. That assumed the host id was doing routing + authentication. With cross-process single-writer leasing in place (#60/#119), those jobs are covered without any engine change:
Routing → the lease decides which process owns a session's resume (ErrSessionLeasedElsewhere / TTL-failover); the id need not encode a route.
Authentication → the consumer's own boundary (for Atrium, TxToken at the gRPC seam + session-ownership) authorizes the resume.
Correlation → EvPermissionAsk already carries the AskID; the consumer persists it and passes it back to ResumeApproval(sess, ws, askID, verdict). driveFromAwaiting guards ask.AskID == askID, and since the id is a pure function of the persisted session it recomputes identically on whichever process holds the lease. No host-supplied-id hook and no side mapping table are required.
Whether a consumer keeps its own signed-approval-id scheme is the consumer's policy, layered above this seam — not a gap in the engine. Re-open only if a concrete need to inject the ask id (rather than read it off the event) appears.
Reopening. The closing premise does not hold, and the engine-import
implementation (stacklok/atrium#552) confirms it.
This was closed on the basis that the askID "is a pure function of the
persisted session [and] recomputes identically on whichever process holds the
lease." It is not. newAskID (engine/agent/dispatch.go:1122) suffixes :r<runSerial>, and runSerial (engine/agent/loop.go:528) is a package-level atomic.Int64 incremented per run from zero (serial: runSerial.Add(1), loop.go:776). It resets on every process start, so the askID embeds
process-local ordering. It does not recompute across a process boundary.
The session lease (#60 / #119) fixes routing — which process owns the resume
— not correlation. Those are separate, and the close conflated them. The
lease guarantees a single writer; it does nothing to make the askID recompute
identically on a different process or after a restart.
Consumer confirmation: Atrium cannot reuse the engine askID on resume. It
synthesizes its own <runID>:resume:<toolCallID> and rebuilds the awaiting PendingAsk by hand (resumeAskID, internal/modules/agentloop/app/converse_resume.go:239). The synthesized id only
needs self-consistency precisely because it can never match a persisted engine
id.
Make the run discriminator reconstructable from persisted state (for
example the run id, which the host already holds) instead of a process-global
counter — or ship the host-supplied-ask-id hook this issue originally
proposed. Either must preserve the CWE-863 replay guard the serial currently
provides (the Interrupt / re-mint scenario documented on newAskID).
If neither, document the askID as host-opaque and explicitly not
reconstructable across processes, so the next consumer does not hit the same
premise.
After digging into the code, the three options in the reopen comment collapse to
one feasible, principled fix. Recording it here so the issue reflects the
approach, not the open menu.
Why not "derive it in the engine" (option A). The engine has no persisted
run identity — runs are in-memory and runSerial (engine/agent/loop.go:528)
is a process-global atomic.Int64. The engine cannot, on its own, distinguish
"attempt #2 of this session after an Interrupt" from attempt #1 in a way that
survives a restart. Only the host, whose durable log is the system of record,
knows that.
The fix. The askID is <sessionID>:<n>:<callID>:r<serial>. Three of those
four components are already reconstructable from persisted session state — the r<serial> suffix is the only one that isn't, and it is the sole use of r.serial in the codebase (dispatch.go:507). So we let the host supply that
one component:
Add an opt-in field to RunOptions (loop.go:553) — a per-run
discriminator threaded onto the Run in startRun (loop.go:776).
newAskID (dispatch.go:1122) uses it as the trailing component when set,
falling back to today's r<serial> when unset. Format unchanged: <sessionID>:<n>:<callID>:<discriminator>.
Atrium passes its durable RunID. The askID then becomes fully
reconstructable from the event log, so Atrium drops its resumeAskID
synthesis and the awaiting-state hand-rebuild entirely.
This is the same shape as the PromptBuilder seam (#128): the host hits a gap,
the engine grows a pluggable RunOptions/Deps seam, no consumer is forced to
change.
Constraints the implementation/ADR must honor:
Preserve the <sessionID>: prefix — cmd/mecatuiisChildAsk classifies
main-vs-subagent on it (update.go:1193).
Preserve the CWE-863 guard the serial provides (the Interrupt/re-mint replay
scenario on newAskID): the host contract is that the discriminator is
unique per run-ATTEMPT and stable across processes for the SAME attempt.
Atrium's RunID satisfies this.
Discriminator must be colon-free (keep the grammar unambiguous).
No behavior change when the field is unset (mecatui, tests, in-memory hosts).
Plan. Solve this together with #148 in one engine PR under a single ADR
covering the ask-correlation design (the field plus the reconstructable askID) —
designing the surface once rather than adding PendingAsk.Call and then
reworking the id. Atrium adoption (pass RunID, delete resumeAskID, delete the
grammar parse) is a follow-up tracked in stacklok/atrium#581.
Follow-up from the Atrium side: implementing the adoption (stacklok/atrium#581), we found Atrium won't consume the RunOptions.AskIDDiscriminator seam — and the seam is still worth keeping.
Why Atrium doesn't need it: Atrium's cross-process resume is already handled by a host-owned deterministic id (resumeAskID = f(RunID, ToolCallID) from the durable gate-token claims), used for both halves of a resume. Atrium runs the engine with Store: nil and rebuilds the awaiting session wholesale from its event-log fold, so it never reloads engine-persisted ask state and never has to match the engine's original askID. The non-reconstructable process-global serial (the premise this issue correctly flagged) was a real property but not a real problem for this particular host.
What was load-bearing was the other half of #149: session.PendingAsk.Call (#148) — Atrium consumes that to drop its askID grammar-parse.
No action needed. The discriminator seam is sound, opt-in, and zero-cost, and remains useful for a durable host that DOES reload engine-persisted ask state (rather than reconstructing it). Keeping it. Recording this so the rationale isn't lost.
Activity
JAORMX commentedon Jun 22, 2026
Reopening. The closing premise does not hold, and the engine-import
implementation (stacklok/atrium#552) confirms it.
This was closed on the basis that the
askID"is a pure function of thepersisted session [and] recomputes identically on whichever process holds the
lease." It is not.
newAskID(engine/agent/dispatch.go:1122) suffixes:r<runSerial>, andrunSerial(engine/agent/loop.go:528) is a package-levelatomic.Int64incremented per run from zero (serial: runSerial.Add(1),loop.go:776). It resets on every process start, so theaskIDembedsprocess-local ordering. It does not recompute across a process boundary.
The session lease (#60 / #119) fixes routing — which process owns the resume
— not correlation. Those are separate, and the close conflated them. The
lease guarantees a single writer; it does nothing to make the
askIDrecomputeidentically on a different process or after a restart.
Consumer confirmation: Atrium cannot reuse the engine
askIDon resume. Itsynthesizes its own
<runID>:resume:<toolCallID>and rebuilds the awaitingPendingAskby hand (resumeAskID,internal/modules/agentloop/app/converse_resume.go:239). The synthesized id onlyneeds self-consistency precisely because it can never match a persisted engine
id.
What we want, smallest first:
independently of the design question here.
example the run id, which the host already holds) instead of a process-global
counter — or ship the host-supplied-ask-id hook this issue originally
proposed. Either must preserve the CWE-863 replay guard the serial currently
provides (the Interrupt / re-mint scenario documented on
newAskID).askIDas host-opaque and explicitly notreconstructable across processes, so the next consumer does not hit the same
premise.
Paired Atrium cleanup: stacklok/atrium#581.
JAORMX commentedon Jun 22, 2026
Direction: opt-in host-supplied per-run discriminator
After digging into the code, the three options in the reopen comment collapse to
one feasible, principled fix. Recording it here so the issue reflects the
approach, not the open menu.
Why not "derive it in the engine" (option A). The engine has no persisted
run identity — runs are in-memory and
runSerial(engine/agent/loop.go:528)is a process-global
atomic.Int64. The engine cannot, on its own, distinguish"attempt #2 of this session after an Interrupt" from attempt #1 in a way that
survives a restart. Only the host, whose durable log is the system of record,
knows that.
The fix. The askID is
<sessionID>:<n>:<callID>:r<serial>. Three of thosefour components are already reconstructable from persisted session state — the
r<serial>suffix is the only one that isn't, and it is the sole use ofr.serialin the codebase (dispatch.go:507). So we let the host supply thatone component:
RunOptions(loop.go:553) — a per-rundiscriminator threaded onto the Run in
startRun(loop.go:776).newAskID(dispatch.go:1122) uses it as the trailing component when set,falling back to today's
r<serial>when unset. Format unchanged:<sessionID>:<n>:<callID>:<discriminator>.RunID. The askID then becomes fullyreconstructable from the event log, so Atrium drops its
resumeAskIDsynthesis and the awaiting-state hand-rebuild entirely.
This is the same shape as the
PromptBuilderseam (#128): the host hits a gap,the engine grows a pluggable
RunOptions/Depsseam, no consumer is forced tochange.
Constraints the implementation/ADR must honor:
<sessionID>:prefix —cmd/mecatuiisChildAskclassifiesmain-vs-subagent on it (
update.go:1193).scenario on
newAskID): the host contract is that the discriminator isunique per run-ATTEMPT and stable across processes for the SAME attempt.
Atrium's RunID satisfies this.
Plan. Solve this together with #148 in one engine PR under a single ADR
covering the ask-correlation design (the field plus the reconstructable askID) —
designing the surface once rather than adding
PendingAsk.Calland thenreworking the id. Atrium adoption (pass
RunID, deleteresumeAskID, delete thegrammar parse) is a follow-up tracked in stacklok/atrium#581.
chore(release): prep engine/v0.1.0 — CHANGELOG stamp
JAORMX commentedon Jun 23, 2026
Follow-up from the Atrium side: implementing the adoption (stacklok/atrium#581), we found Atrium won't consume the
RunOptions.AskIDDiscriminatorseam — and the seam is still worth keeping.Why Atrium doesn't need it: Atrium's cross-process resume is already handled by a host-owned deterministic id (
resumeAskID = f(RunID, ToolCallID)from the durable gate-token claims), used for both halves of a resume. Atrium runs the engine withStore: niland rebuilds the awaiting session wholesale from its event-log fold, so it never reloads engine-persisted ask state and never has to match the engine's original askID. The non-reconstructable process-global serial (the premise this issue correctly flagged) was a real property but not a real problem for this particular host.What was load-bearing was the other half of #149:
session.PendingAsk.Call(#148) — Atrium consumes that to drop its askID grammar-parse.No action needed. The discriminator seam is sound, opt-in, and zero-cost, and remains useful for a durable host that DOES reload engine-persisted ask state (rather than reconstructing it). Keeping it. Recording this so the rationale isn't lost.