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]: cloneContextWith drops the isFile probe — one permission grant changes bash classification for the rest of the session #151
cloneContextWith drops the isFile probe when cloning a ToolPermissionContext. After any permission rule update (i.e. any "always allow"/"always deny" decision or managed rule change during a session), the resulting context has isFile === undefined, which silently changes downstream bash permission behavior for the rest of the session.
Source evidence
Audited against the 0.4.12 source preview (release/extraction.jsonsourceRevision9b9885e42a3cf1a3df1cfa52a46e4fdb034cfcee); line numbers refer to that revision.
isFile is part of the context and set at creation: packages/agent-modules/permission/src/context.ts:157.
cloneContextWith copies mode, rules, sandbox flags, paths, dirs, agent/session fields — but not isFile: packages/agent-modules/permission/src/context.ts:210-232.
Every applyPermissionUpdate (addRules/replaceRules/removeRules, context.ts:190-204) produces the clone, so the field is lost on the first rule mutation.
Consumer: packages/agent-modules/permission/src/tools/bash-permission.ts:579 — if (!bashCtx.isFile?.(resolved)) return false;. Once isFile is undefined, this local-script relaxation check permanently returns false, so a single permission grant mid-session changes how later bash commands are classified.
Expected behavior
Cloning a context preserves all probe callbacks; permission behavior should not change as a side effect of granting or revoking a rule.
Suggested fix
Add isFile: ctx.isFile to the object returned by cloneContextWith (packages/agent-modules/permission/src/context.ts:214-231). Consider a type-level guard so future context fields cannot be silently dropped again (e.g. satisfies over a Pick of the mutable fields plus an exhaustiveness check).
Environment
Found by source audit; not runtime-reproduced yet.
Closing for now to keep this batch of reports smaller — I kept the two highest-impact findings open (#150 permission enforcement, #152 context compaction trigger). Happy to reopen or refile if maintainers find this one useful; the analysis in the body stays valid against the cited revision.
Thanks for the report. Fixed and merged in #167 (commit e3724a13d72d61c9bdc68a1a72b5c020f065ba26).
cloneContextWith now preserves the host-owned isFile callback. Regression tests exercise addRules, replaceRules, and removeRules through the actual bash permission checker and verify that local-script classification remains unchanged after the update.
Validation: all 106 new regression cases pass; the full local verification profile passed on macOS arm64, and Linux/macOS/Windows CI plus the source audit passed on the PR head. Built-CLI smoke/startup and offline BYOK runtime tests also passed. This is a source fix on main; it does not imply a new package release.
Activity
KevinBarrus commentedon Sep 18, 2026
Closing for now to keep this batch of reports smaller — I kept the two highest-impact findings open (#150 permission enforcement, #152 context compaction trigger). Happy to reopen or refile if maintainers find this one useful; the analysis in the body stays valid against the cited revision.
KevinBarrus commentedon Sep 18, 2026
Reopening — closing them added nothing since closed issues stay fully visible. Keeping all five open for triage.
hetaoBackend commentedon Sep 18, 2026
Thanks for the report. Fixed and merged in #167 (commit
e3724a13d72d61c9bdc68a1a72b5c020f065ba26).cloneContextWithnow preserves the host-ownedisFilecallback. Regression tests exerciseaddRules,replaceRules, andremoveRulesthrough the actual bash permission checker and verify that local-script classification remains unchanged after the update.Validation: all 106 new regression cases pass; the full local verification profile passed on macOS arm64, and Linux/macOS/Windows CI plus the source audit passed on the PR head. Built-CLI smoke/startup and offline BYOK runtime tests also passed. This is a source fix on main; it does not imply a new package release.