You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "Astro-Han (via GitHub)" <gi...@apache.org> on 2026/08/21 08:19:14 UTC
[PR] fix: make the Host's chat default the single authority for a Session's permission mode [maka]
Astro-Han opened a new pull request, #3396:
URL: https://github.com/apache/maka/pull/3396
## Summary
A new Session always started in `ask`, whatever the user had chosen last time, because three places each claimed authority over the starting permission mode and none of them was the Host policy the user actually configures. This PR makes `chatDefaults.permissionMode` in Runtime Policy the single authority: clients omit `permissionMode` on create unless the user explicitly overrode it for that Session, and a per-Session override never writes back to the default.
With one authority in place, three concepts lose their last consumer and are removed:
- the desktop session-creation permission fallback, a renderer-side mirror of the Host default;
- `resolveCreateSessionInput`, which existed only to re-derive a mode the Host already knows;
- the `execute` permission mode, which had no semantics of its own — it compiled to the same profile as `ask`, displayed as `ask`, and produced the same execution boundary — and five sites that folded it away.
Removing `execute` narrows a wire enum, so `RUNTIME_HOST_COMPATIBILITY_EPOCH` goes to 30. Records written before the removal decode through a single retired-mode fold (`decodePersistedPermissionMode`) rather than scattered per-site compatibility code; `execute` stays accepted as a CLI input alias.
Refs #3385
## Verification
- `npm run typecheck --workspaces` — clean
- `npm run format:check` and `biome lint` on touched files — clean
- Focused suites for every touched package, run from `dist`: `packages/runtime` session-manager (222/222), `packages/core` permission + scheduled-task, `packages/storage` session-store + agent-graph-schedule, `packages/cli` run-command + activation-command, `apps/desktop` main-process suites — all pass
- Not run: repository-wide tests, left to CI
## Rollout
`RUNTIME_HOST_COMPATIBILITY_EPOCH` 29 → 30. Mismatched peers are refused at connect, so a client and Host across this bump must be upgraded together — the routine handling for this epoch, unchanged from the 29 bumps before it.
Persisted records that still carry `execute` are folded to `ask` on read in every decoder that reaches them: Session headers, Agent Run headers, and — added in this PR — the scheduled-task store, whose read path previously did a bare `JSON.parse(...) as ScheduledTask` with no decoding at all.
## Review focus
The composer persistence change lives in `apps/desktop/src/renderer`, which has no unit-test surface — the desktop suites cover the main process only. It is verified by hand, not by a test, and no E2E was added for it. Worth a second pair of eyes on whether that gap should block.
## AI use
- [ ] No generative tool made a substantive contribution
- [x] Generative tooling made a substantive contribution
Tool(s) and scope: Claude Code wrote the code, tests, and this description. The human contributor reviewed the final diff and commit messages and owns the submission. Affected commits carry `Generated-by: Claude Code`.
## Checklist
- [x] Tests cover the change and fail without it
- [x] Lint, format, typecheck and the affected suites pass locally
Does this PR entail a change in behavior?
- [x] Yes — described under Summary above
- [ ] No
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix: make the Host's chat default the single authority for a Session's permission mode [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on PR #3396:
URL: https://github.com/apache/maka/pull/3396#issuecomment-5370127226
All three blockers are addressed on `942f7179e`.
**1. Subagent tool result fold.** Correct, and fixed: `decodeCanonicalToolResultContent` now canonicalizes `permissionMode` at its single exit, with legacy-record tests.
I did **not** apply the same fold to `decodeToolResultPreviewContent`, and returned it to strict `isPermissionMode` instead. It decodes live open facts from a connected peer, never a stored record — its own header says "Never use for transcript recovery" — and the compatibility epoch already refuses a peer old enough to send a retired mode. Folding there would mask a handshake that should not have succeeded. This keeps one rule across the PR: persistence decoders fold, wire and input validators reject. Tests cover both directions.
**2. Desktop assertion.** Fixed and squashed into the commit that introduced it, so no broken intermediate state remains.
**3. Epoch.** Rebased. `main` has moved twice more since your note — 32 went to #3399 and 33 to the sandbox failure reason — so this change now takes **34**, with every prior epoch note preserved.
That rebase surfaced a related problem: `protocol.test.ts` pinned the sandbox-failure epoch with `assert.equal(..., 33)`, which fails on *every* subsequent bump, not just this one. Changed to `assert.ok(... > 32)`, matching the two assertions above it in the same file, and added the same-shaped floor assertion for this change.
Separately, the missed fold in (1) is a symptom rather than a one-off: retired-value folding is hand-written per decoder with nothing enforcing it, and has now been independently re-implemented five times. Tracked in #3413, deliberately out of scope here.
Verification on the new head: full `build`, `typecheck --workspaces`, and `format:check` clean; every touched workspace run in full — core 585, storage 849, runtime 2999, runtime-host 1046, cli 357, desktop 1019, no failures.
_🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix: make the Host's chat default the single authority for a Session's permission mode [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on PR #3396:
URL: https://github.com/apache/maka/pull/3396#issuecomment-5374780023
Accepted and fixed on `83d008cf7`.
You are right, and checking why I made that change showed it was unnecessary in the first place. Settings already has a dedicated default-permission-mode picker writing `chatDefaults` (`general-settings-page.tsx:441`). The reason a new task still started in Auto despite it was not that the setting was unreachable — it was that Session creation never honoured it, which is what the earlier commits in this branch fix. Making the composer write the setting was solving a problem that had already been solved one layer down, and it cost the draft-local override boundary to do it.
The draft-local choice is restored, with the create path corrected in the same move:
- `newTaskPermissionChoice` is back as per-draft state; the picker writes only it, never `chatDefaults`.
- Display falls back `choice ?? host chatDefaults ?? 'ask'`.
- Creation sends the field **only** when the draft choice is set. Note this is stricter than the pre-PR behaviour, which always sent the resolved value including the Host-default fallback — that was the original form of the same overreach.
On the test: `app-shell-session-settings-actions.test.ts` predates this PR (added in #1714), but your point about what it protects stands. Added `sends a composer permission choice once without writing it to the Host default` to the first-send suite: it asserts the choice reaches `newTasks.create` and that `settings.update` is never called. The `settings.update` half is admittedly weak at this seam, since the wiring that would call it lives in `app-shell.tsx`, which has no unit-test surface in this app — that renderer gap is called out under Review focus and is unchanged.
I also reworded the commit that introduced the write-back so it no longer states a contract this branch does not end up honouring; it now covers only the duplicate-copy collapse it actually leaves behind.
Verification on the new head: full `build`, `typecheck --workspaces`, `format:check` clean; every touched workspace run in full — core 600, storage 862, runtime 3003, runtime-host 1063, cli 357, desktop 1034, no failures. Epoch remains 37, ahead of current main's 36.
_🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix: make the Host's chat default the single authority for a Session's permission mode [maka]
Posted by "hqhq1025 (via GitHub)" <gi...@apache.org>.
hqhq1025 commented on code in PR #3396:
URL: https://github.com/apache/maka/pull/3396#discussion_r3835329189
##########
packages/cli/src/runtime-host-cli-context.ts:
##########
@@ -26,6 +27,32 @@ import {
} from '@maka/runtime-host/protocol';
import { resolveMakaClientDataRoot } from '@maka/storage';
+/**
+ * The mode a new Session starts in belongs to the Host: `session.create`
+ * falls back to `chatDefaults.permissionMode` in the Runtime Policy whenever a
+ * client omits the field, so that policy value is the single authority.
+ *
+ * The CLI reads it rather than assuming Auto, because its pickers and its
+ * status indicator name the mode a new Session will *actually* get. Assuming
+ * Auto against a Host configured for full access would understate the
+ * boundary, which is the one direction that must never happen.
+ *
+ * Falls back to `ask` when the policy cannot be read: an unreachable policy
+ * must not stop the CLI from starting, and understating our own knowledge is
+ * safe here — the Host still applies its own default to the Session it
+ * creates.
+ */
+export async function readHostChatDefaultPermissionMode(
+ connection: Pick<RuntimeHostConnection, 'request'>,
+): Promise<ChatDefaultPermissionMode> {
+ try {
+ return (await connection.request('runtime.policy.query', {})).policy.chatDefaults
+ .permissionMode;
+ } catch {
+ return 'ask';
Review Comment:
[P1] Do not present an unknown Host boundary as Auto
This catch returns `ask` even though Session creation later omits `permissionMode` and lets the Host apply its real default. If the policy query fails transiently while the Host default is `bypass`, the TUI displays Auto and the first prompt runs with Full access. That is the unsafe direction, despite the comment calling it safe. Propagate an unknown/unavailable state or block fresh creation until the authoritative default can be read; do not invent `ask` for display.
##########
packages/cli/src/runtime-host-session-driver.ts:
##########
@@ -135,8 +137,14 @@ class RuntimeHostMakaSessionDriverImpl implements RuntimeHostMakaSessionDriver {
// elevations (the picker, a resumed Session's boundary) update
// `#permissionMode` only; `startNewSession` falls back to this so Full
// access never leaks into a fresh Session (#3020).
- readonly #defaultPermissionMode: PermissionMode;
- #permissionMode: PermissionMode;
+ //
+ // `undefined` means the client has no claim on the starting mode and the
+ // Host resolves it from its Runtime Policy `chatDefaults`. That is a
Review Comment:
[P1] Reset the TUI to an authoritative prospective mode
Allowing the driver default to be undefined is correct for Host-owned creation, but `startNewSession()` then makes `getPermissionMode()` undefined and `pi-tui-runner.ts:2106` coalesces that to the previous Session’s mode. `/new` therefore keeps a stale label, including Auto while a newly changed Host default creates Full access. Preserve omission for create, but refresh and return a separate display-only prospective mode on `/new`.
##########
apps/desktop/src/renderer/app-shell-chat-actions.ts:
##########
@@ -388,7 +393,7 @@ export function createAppShellChatActions(deps: {
}
: {}),
...(pendingNewChatThinkingLevel ? { thinkingLevel: pendingNewChatThinkingLevel } : {}),
- permissionMode: newChatPermissionMode,
+ ...(newChatPermissionChoice ? { permissionMode: newChatPermissionChoice } : {}),
Review Comment:
[P1] Consume the per-draft override after one task
`useNewTaskChoice` keeps values indefinitely by Host/project key and exposes no clear/consume operation. After task A is created with Full access, opening task B on the same target leaves `newChatPermissionChoice === "bypass"`, so this line explicitly overrides the Host default again. Clear the permission choice after a successful first send or give each draft a distinct identity; retain it on failed sends. Add a two-consecutive-task test because the current one-call action test cannot observe this leak.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix: make the Host's chat default the single authority for a Session's permission mode [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #3396:
URL: https://github.com/apache/maka/pull/3396#discussion_r3832734373
##########
packages/storage/src/session-store.ts:
##########
@@ -1062,6 +1062,10 @@ export function normalizeSessionHeader(
header: SessionHeader,
sessionId: string = header.id,
): SessionHeader {
+ // A retired mode decodes to its live equivalent rather than failing the
+ // header: such a record is old, not malformed, and rejecting it would make
+ // the Session unopenable.
+ const permissionMode = decodePersistedPermissionMode(header.permissionMode);
Review Comment:
Fixed, by deleting the field rather than folding it: it had no reader, so `SubagentSessionRuntime.permissionCeiling` leaves the type and the guard now tolerates the key on stored records instead of validating it. Legacy child-header tests added in `subagent-session-parent.test.ts`.
_🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
##########
apps/desktop/src/renderer/app-shell.tsx:
##########
@@ -565,11 +562,31 @@ function AppShellContent({
const desktopConversationCopy = getDesktopConversationCopy(uiLocale);
const terminalPanelCopy = desktopConversationCopy.terminalPanel;
const workbarCopy = desktopConversationCopy.workbar;
+ /**
+ * What a new task starts in, read straight from the Host that would run it.
+ *
+ * There is no draft-local copy: before a Session exists, "the mode this
+ * task will start in" and "the configured default" are the same fact, and
+ * a second copy of it could only be the stale one. Picking a mode here
+ * therefore writes the setting — which is also why the choice survives to
+ * the next new task instead of lasting one draft.
+ */
const newTaskPermissionMode =
Review Comment:
Fixed. `newChatPermissionMode` is deleted outright — the create input was its only consumer — so ordinary first-send creation omits the field. The assertion now requires the field to be absent, with a comment explaining why forwarding the offered default would make a cached snapshot the authority.
_🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
##########
packages/storage/src/scheduled-task-store.ts:
##########
@@ -577,7 +578,7 @@ class SqliteScheduledTaskStore implements ScheduledTaskStore {
if (typeof row.record_json !== 'string') {
throw new Error(`Invalid scheduled task at row ${index + 1}`);
}
- return JSON.parse(row.record_json) as ScheduledTask;
+ return decodePersistedScheduledTask(JSON.parse(row.record_json) as ScheduledTask);
Review Comment:
Fixed: the claim read path now decodes its embedded task through the same `decodePersistedScheduledTask`, so `listPendingFires()` and the catalog table agree.
_🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
##########
packages/cli/src/runtime-host-tui-context.ts:
##########
@@ -76,12 +80,13 @@ export async function createRuntimeHostTuiContext(
? await resolveResumeTarget(connection, catalog, input.resumeSessionId)
: resolveTarget(catalog);
const modelChoices = projectRuntimeHostModelChoices(catalog);
+ const hostDefaultPermissionMode = await readHostChatDefaultPermissionMode(connection);
const driverInput: RuntimeHostMakaSessionDriverInput = {
connection,
cwd: input.cwd,
llmConnectionSlug: target.connection.slug,
model: target.model,
- permissionMode: 'ask',
+ permissionMode: hostDefaultPermissionMode,
Review Comment:
Fixed. The driver no longer receives the snapshot, so creation omits the field. The value survives as `prospectivePermissionMode` for display and skill prediction only, and the launcher shows it instead of a hardcoded `ask`. It is derived through `createGenesisExecutionBoundary` + `executionBoundaryDisplayMode` so a prospective and a live Session cannot label the same permissions differently.
_🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
##########
packages/cli/src/activation-command.ts:
##########
@@ -205,14 +212,19 @@ export function parseMakaActivateArgs(argv: readonly string[]): ParseMakaActivat
if (parsedMaxSteps !== undefined && (!Number.isInteger(parsedMaxSteps) || parsedMaxSteps < 1)) {
return { kind: 'error', message: '--max-steps must be a positive integer' };
}
- const permissionMode = values.get('permission-mode');
+ // `execute` stays accepted as an alias for `ask`: this is a public
+ // subcommand whose callers live outside this repo, and the two named the
+ // same boundary for as long as both existed. It is not offered in the error
+ // message, so nothing new learns to send it.
+ const requestedPermissionMode = values.get('permission-mode');
+ const permissionMode = requestedPermissionMode === 'execute' ? 'ask' : requestedPermissionMode;
Review Comment:
Fixed: the help text now reads `explore|ask|bypass`. `execute` remains accepted as an unadvertised alias.
_🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix: make the Host's chat default the single authority for a Session's permission mode [maka]
Posted by "hqhq1025 (via GitHub)" <gi...@apache.org>.
hqhq1025 commented on code in PR #3396:
URL: https://github.com/apache/maka/pull/3396#discussion_r3832620440
##########
packages/storage/src/session-store.ts:
##########
@@ -1062,6 +1062,10 @@ export function normalizeSessionHeader(
header: SessionHeader,
sessionId: string = header.id,
): SessionHeader {
+ // A retired mode decodes to its live equivalent rather than failing the
+ // header: such a record is old, not malformed, and rejecting it would make
+ // the Session unopenable.
+ const permissionMode = decodePersistedPermissionMode(header.permissionMode);
Review Comment:
[P1] Fold the nested legacy permission ceiling as well. Older child Session headers can contain `subagentRuntime.permissionCeiling: "execute"` (the field is explicitly retained for decode compatibility), but `isSubagentSessionRuntime` still validates it with strict `isPermissionMode`. This top-level fold therefore does not make those headers readable: normalization rejects the whole child Session as malformed. Canonicalize or remove the decode-only nested value while normalizing the persisted header, and add a legacy child-header test.
##########
packages/cli/src/runtime-host-tui-context.ts:
##########
@@ -76,12 +80,13 @@ export async function createRuntimeHostTuiContext(
? await resolveResumeTarget(connection, catalog, input.resumeSessionId)
: resolveTarget(catalog);
const modelChoices = projectRuntimeHostModelChoices(catalog);
+ const hostDefaultPermissionMode = await readHostChatDefaultPermissionMode(connection);
const driverInput: RuntimeHostMakaSessionDriverInput = {
connection,
cwd: input.cwd,
llmConnectionSlug: target.connection.slug,
model: target.model,
- permissionMode: 'ask',
+ permissionMode: hostDefaultPermissionMode,
Review Comment:
[P1] Do not install the queried policy snapshot as an explicit driver default. The launcher still passes `permissionMode: "ask"` to the TUI renderer, so a Host configured for `bypass` is displayed as Auto/protected while this driver creates the next Session with full access. The snapshot also becomes stale across `/new`, and a query failure is converted to `ask` and then sent explicitly, defeating Host ownership. Keep the prospective mode as display state, omit the create field absent a real user override, and refresh/adopt the authoritative mode when a Session is created.
##########
packages/storage/src/scheduled-task-store.ts:
##########
@@ -577,7 +578,7 @@ class SqliteScheduledTaskStore implements ScheduledTaskStore {
if (typeof row.record_json !== 'string') {
throw new Error(`Invalid scheduled task at row ${index + 1}`);
}
- return JSON.parse(row.record_json) as ScheduledTask;
+ return decodePersistedScheduledTask(JSON.parse(row.record_json) as ScheduledTask);
Review Comment:
[P1] Decode the ScheduledTask copy embedded in pending fire claims too. A fire claimed before upgrade is stored separately in `workflow_scheduled_task_fires`; that read path below still uses a bare cast, so its embedded Agent task keeps `permissionMode: "execute"`. Recovery later forwards that retired value into Session creation and records the fire as failed. I reproduced this on the current head: the catalog task decoded to `ask` while `listPendingFires()` returned `execute`.
##########
packages/cli/src/activation-command.ts:
##########
@@ -205,14 +212,19 @@ export function parseMakaActivateArgs(argv: readonly string[]): ParseMakaActivat
if (parsedMaxSteps !== undefined && (!Number.isInteger(parsedMaxSteps) || parsedMaxSteps < 1)) {
return { kind: 'error', message: '--max-steps must be a positive integer' };
}
- const permissionMode = values.get('permission-mode');
+ // `execute` stays accepted as an alias for `ask`: this is a public
+ // subcommand whose callers live outside this repo, and the two named the
+ // same boundary for as long as both existed. It is not offered in the error
+ // message, so nothing new learns to send it.
+ const requestedPermissionMode = values.get('permission-mode');
+ const permissionMode = requestedPermissionMode === 'execute' ? 'ask' : requestedPermissionMode;
Review Comment:
[P2] Update the public help text with this parser change. `maka activate --help` still advertises `explore|execute|bypass`, while parsing and errors now advertise `explore|ask|bypass`. Keeping `execute` as an unadvertised compatibility alias is reasonable, but the current help teaches new callers to keep producing the retired spelling.
##########
apps/desktop/src/renderer/app-shell.tsx:
##########
@@ -565,11 +562,31 @@ function AppShellContent({
const desktopConversationCopy = getDesktopConversationCopy(uiLocale);
const terminalPanelCopy = desktopConversationCopy.terminalPanel;
const workbarCopy = desktopConversationCopy.workbar;
+ /**
+ * What a new task starts in, read straight from the Host that would run it.
+ *
+ * There is no draft-local copy: before a Session exists, "the mode this
+ * task will start in" and "the configured default" are the same fact, and
+ * a second copy of it could only be the stale one. Picking a mode here
+ * therefore writes the setting — which is also why the choice survives to
+ * the next new task instead of lasting one draft.
+ */
const newTaskPermissionMode =
Review Comment:
[P1] The real first-send caller still converts this Host default snapshot into an explicit Session override. `createAppShellChatActions` always sends `permissionMode: newChatPermissionMode`, and main forwards it whenever no product mode is present. If another client lowers the Host from `bypass` to `ask` before this catalog refreshes, Desktop can still create a full-access Session from the stale value. Ordinary creation must omit `permissionMode`; the current first-send test assertion that requires `bypass` on the request should be deleted/replaced.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix: make the Host's chat default the single authority for a Session's permission mode [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han merged PR #3396:
URL: https://github.com/apache/maka/pull/3396
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] fix: make the Host's chat default the single authority for a Session's permission mode [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #3396:
URL: https://github.com/apache/maka/pull/3396#discussion_r3835411796
##########
apps/desktop/src/renderer/app-shell-chat-actions.ts:
##########
@@ -388,7 +393,7 @@ export function createAppShellChatActions(deps: {
}
: {}),
...(pendingNewChatThinkingLevel ? { thinkingLevel: pendingNewChatThinkingLevel } : {}),
- permissionMode: newChatPermissionMode,
+ ...(newChatPermissionChoice ? { permissionMode: newChatPermissionChoice } : {}),
Review Comment:
Fixed. `useNewTaskChoice` gained a clear operation and the choice is consumed on a successful create (left in place on failure, so a retry keeps it). Confirmed your diagnosis at the source: the key is `JSON.stringify(["new-task", profileId, hostId, projectId])` with no draft identity at all. Added a two-consecutive-task test asserting task A sends `bypass` and task B sends nothing.
_🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
##########
packages/cli/src/runtime-host-cli-context.ts:
##########
@@ -26,6 +27,32 @@ import {
} from '@maka/runtime-host/protocol';
import { resolveMakaClientDataRoot } from '@maka/storage';
+/**
+ * The mode a new Session starts in belongs to the Host: `session.create`
+ * falls back to `chatDefaults.permissionMode` in the Runtime Policy whenever a
+ * client omits the field, so that policy value is the single authority.
+ *
+ * The CLI reads it rather than assuming Auto, because its pickers and its
+ * status indicator name the mode a new Session will *actually* get. Assuming
+ * Auto against a Host configured for full access would understate the
+ * boundary, which is the one direction that must never happen.
+ *
+ * Falls back to `ask` when the policy cannot be read: an unreachable policy
+ * must not stop the CLI from starting, and understating our own knowledge is
+ * safe here — the Host still applies its own default to the Session it
+ * creates.
+ */
+export async function readHostChatDefaultPermissionMode(
+ connection: Pick<RuntimeHostConnection, 'request'>,
+): Promise<ChatDefaultPermissionMode> {
+ try {
+ return (await connection.request('runtime.policy.query', {})).policy.chatDefaults
+ .permissionMode;
+ } catch {
+ return 'ask';
Review Comment:
Fixed by deleting the catch — the query now throws, like every other catalog read on that path. You are right that the comment had the direction backwards, and it was mine. With no true value to show, not starting beats displaying Auto over a Bypass Host. This also removed the need for an "unknown" display state in the TUI, which is why the rest of the fix stayed small.
_🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
##########
packages/cli/src/runtime-host-session-driver.ts:
##########
@@ -135,8 +137,14 @@ class RuntimeHostMakaSessionDriverImpl implements RuntimeHostMakaSessionDriver {
// elevations (the picker, a resumed Session's boundary) update
// `#permissionMode` only; `startNewSession` falls back to this so Full
// access never leaks into a fresh Session (#3020).
- readonly #defaultPermissionMode: PermissionMode;
- #permissionMode: PermissionMode;
+ //
+ // `undefined` means the client has no claim on the starting mode and the
+ // Host resolves it from its Runtime Policy `chatDefaults`. That is a
Review Comment:
Fixed as you suggested: the driver now holds the Host chat default as display-only state (`prospectivePermissionMode`), refreshes it on `startNewSession()`, and `getPermissionMode()` falls back to it when no Session exists. The runner no longer coalesces to the current label — its floor is the launch reading, which is a Host value rather than the previous Session's. Creation still omits the field; the `#3020` test now asserts the fresh Session carries no `permissionMode` at all, which is a stronger statement of what that test protects.
While there: `#defaultPermissionMode` is deleted. No caller ever set it, so it was always `undefined` and the leak it documented is actually prevented by omission.
_🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org