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
bug: event-rule conditions receive the raw context store instead of the user context #511
area: coreTouches core library / runtime source codepriority: mediumShould be addressed in the normal course of developmentstatus: implementedBuilt and deployed, but not yet fully tested/verifiedtype: bugSomething is broken or not behaving as expected
A conditional event rule's condition(ctx) receives the whole AsyncLocalStorage store ({ instanceID, context: { actor }, currentWrapper, … }), while a conditional call rule's condition(ctx, meta) receives the user context ({ actor }). docs/EVENTS.md says event rules take "the same condition shape permission rules accept", so the same condition function behaves differently depending on which rule type it's attached to.
Where
src/lib/handlers/event-manager.mjs:257 (resolveLevel) and :282 (per-emit re-resolve) pass this.slothlet.contextManager?.tryGetContext?.() ?? null, which is the store.
src/lib/builders/api_builder.mjs:1159 and :3100 (the call-side checks, e.g. permissions.global.checkAccess) pass tryGetContext?.()?.context ?? null, which is the user context.
Repro
constapi=awaitslothlet({
base,permissions: {defaultPolicy: "deny",events: {default: "deny",rules: [{caller: "remote.renderer",event: "jobs.*",effect: "allow",condition: (ctx)=>ctx?.actor?.id==="u1"}]}}});awaitapi.slothlet.context.run({actor: {id: "u1"}},()=>api.slothlet.event.resolveLevel("remote.renderer","jobs.done"));// → "deny": ctx is the store, so ctx.actor is undefined (ctx.context.actor is "u1").// The same condition on a call rule, checked with global.checkAccess inside the same run(), sees ctx.actor.
Expected
Pass tryGetContext()?.context ?? null at both event-manager sites so event and call conditions see the same ctx. Existing event conditions that read ctx.context.* would need to move to ctx.*. That makes this a behavior change worth a changelog note, though it matches the documented contract.
Found by
Building the channel principal for CLDMV/slothlet-vine#33. That branch's e2e test works around it with ctx.actor ?? ctx.context?.actor.
area: coreTouches core library / runtime source codepriority: mediumShould be addressed in the normal course of developmentstatus: implementedBuilt and deployed, but not yet fully tested/verifiedtype: bugSomething is broken or not behaving as expected
Activity
Shinrai commentedon Sep 29, 2026
Landed on
nextin #514 (7654b712). Ships in the next release (3.22.0); this closes when it reachesmaster.release: v3.22.0 - type the composed api, self, and slothlet() from e…
cldmv-bot commentedon Oct 3, 2026
Closed in v3.22.0 — resolved by #514.