Skip to content

feat(threads): inherit access mode for subagents and bot threads - #547

Merged
nixuuu merged 3 commits into
devfrom
feat/inherited-access-mode
Nov 12, 2026
Merged

nixuuu merged 3 commits into
devfrom
feat/inherited-access-mode

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Bots currently choose permissions when starting threads, and Full access is downgraded for subagents. New subagents now inherit the parent's effective permissions, including Full access where the computer allows it. Bots use the owner's default thread permissions or a per-bot override; models no longer choose a creation mode.

Changes

  • Add Settings → Threads → Subagents: Same as parent by default, or a fixed mode capped by the parent. Resolve and record the mode in the gateway creation transaction. Existing children keep their mode; lowering the parent's default limits new children immediately, and a running turn's narrower permissions remain a ceiling.
  • Default bot thread permissions to Inherit default, with all five explicit overrides. Apply the configured choice to direct starts, forks, schedules, and linked-computer starts. Remove model-facing creation parameters; legacy spawn_thread.permission_mode can only narrow access.
  • Enforce owner scoping before execution and replay. Persist the worker's authenticated Full access capability and clamp automated creation to Full auto where bypass is unavailable. Scheduled new threads retain their sandbox ceiling. Show clamp explanations and recorded permissions in web/mobile thread details.
  • Add gateway integration coverage for inheritance, parent changes, fixed settings, escalation, owner scoping, worker ceilings, bot defaults/overrides, and mode propagation into Codex, Claude, and Grok native adapters. Add migration coverage and update Polish docs.

Contracts and migration

Additive protobuf fields only: ThreadDefaults.subagent_permission_mode, Thread.permission_mode_note, and NewThreadSchedule.permission_mode_note; generated code is included. Worker link protocol is unchanged.

Migration 0125_inherited_access_mode converts missing/legacy inherited bot settings to user_default, preserving explicit choices, including Ask first retained by migration 0090. It also includes clamp explanations in the lightweight thread-settings projection used by lists and details. Registration and schema expectations are updated.

Rebased onto origin/dev at f7ad51ccc, including #562 (migration 0124_thread_range_lock_order) and #566. This PR adds 0125_inherited_access_mode; registration and schema expectations list 0124 followed by 0125.

Related: #562

Mobile changes are TypeScript/JavaScript only. No dependencies, Expo/EAS configuration, or native files change.

Verification

The initial implementation passed local bun install --frozen-lockfile, bun run gen:check, bun run typecheck, bun run lint, bun run format:check, and git diff --check. Subsequent fixes use CI logs for runtime evidence; only nice -n 19 formatting/lint on changed files and git diff --check run locally while measurement continues. Current-head CI results are shown by the PR checks.

After the maintainer opened the local verification window, bun install and bun run gen:check passed on head ef33469656f17e4255f35e519cb1d37e4c9c3ee4. Focused tests passed: 20 tests, 0 failures, 135 assertions across full-access-mode.test.ts, bot-approval-rules.test.ts, bot-approval-review.test.ts, and inherited-access-upgrade.test.ts. The full local check:tmp was intentionally omitted at the maintainer's request because CI runs the full suite. Web/Linux builds and static checks passed in current-head CI; other CI results are shown by the PR checks. Adapter coverage feeds the child mode received over the worker link into native permission adapters; it does not claim a live provider run.

Real-browser review passed in light and dark at desktop (1280/1440 px) and phone (390 px) widths: Settings → Threads → Subagents, saved mode after reload, bot Inherit default and fixed override after saving/reopening, Full access confirmation, and the child clamp explanation beside its effective mode. Long project, bot, parent, and child names wrap or truncate cleanly; no horizontal page overflow. The dark phone dropdown was checked after transitions settled: its background is opaque and its copy remains legible. The isolated gateway used a scripted worker; no live model or external account was contacted. Review servers and their test database were stopped, and the browser tab was closed.

Expo/EAS runtime fingerprints generated with expo-updates fingerprint:generate are unchanged against origin/dev, using the same checkout path and dependencies for both snapshots: iOS 74705db3a68907bc28379bb9b1080a227bc0755b, Android 7d38be8f5c9bf842d62060c75820a206f99c87e3. No native/config/dependency changes are included.

Copy audit — docs/copy.md §8

Before → after Reason
“Same as the bot’s approvals” → “Inherit default”; “Uses your default permissions from Settings → Threads.” Match the owner's new-thread default and identify where to change it.
No subagent permission control → “Subagents”, “Permissions”, “Same as parent”; “New subagents keep their mode when the parent’s permissions change.” / “A fixed mode can limit access, up to the parent’s current permissions.” Describe inheritance, persistence, and the fixed-mode ceiling beside the control.
No bot Full access override → “Full access”; “Thread tools run without asking or a sandbox, where the computer allows it.” Use the existing mode name and confirmation; name the computer restriction.
No clamp explanation → “This computer limits Full access to Full auto. Choose another mode or enable Full access on this computer.” / “The parent’s mode limits subagent permissions. Change permissions in the parent thread to allow more access.” / “Scheduled threads limit Full access to Full auto. Keep this mode or choose one that asks.” State the effective limit and a next action; show it with the saved mode in thread details.
Schedule standing-rule labels mentioning Ask first/Read only → “creating schedules” / “updating schedules” Permissions now come from owner configuration, so the old qualifier was misleading.

Static audit: sentence case, existing glossary terms, short descriptions, and active wording; controls use the shared kit, and actions retain existing verb labels. Clamp explanations include a next action, avoid internal protocol names, and convey meaning in text rather than color alone. Existing Full access confirmations remain. No new empty states or humorous copy. The permission descriptions and clamp explanation serve separate purposes. Visual audit passed in light/dark on desktop and phone widths, including long names, narrow picker overlays, and the clamp hint; labels and descriptions stay readable without horizontal page overflow.

@nixuuu
nixuuu force-pushed the feat/inherited-access-mode branch from 5de400f to 79e0b72 Compare November 12, 2026 09:33
@nixuuu
nixuuu force-pushed the feat/inherited-access-mode branch 2 times, most recently from d8520db to 2557aa8 Compare November 12, 2026 10:29
Include clamp notes in the lightweight thread settings projection. Align migration and harness expectations with owner-selected defaults, and restore bot test settings even after an assertion fails.
@nixuuu
nixuuu force-pushed the feat/inherited-access-mode branch from 2557aa8 to ef33469 Compare November 12, 2026 11:55
@nixuuu
nixuuu merged commit 6d7a904 into dev Nov 12, 2026
10 checks passed
@nixuuu
nixuuu deleted the feat/inherited-access-mode branch November 12, 2026 12:05
nixuuu added a commit that referenced this pull request Nov 12, 2026
Settings → Diagnostics repeated the computer hostname once per mirrored
thread, making dozens of rows indistinguishable. Thread sync now shows
one row per linked computer, using its display name and complete thread
totals. Expanding a row loads only threads that need attention, with
titles, remaining records, pause reasons and links. When reachable
computers are caught up, one calm status replaces the list and zero
counters.

Fixes: #543

The additive RPC returns local computer summaries separately from
bounded attention pages. Every join is owner scoped; message bodies are
never read. A migration records the last committed range time without
inventing historical timestamps. Web and mobile share grouping/status
copy, poll summaries every 5 seconds while visible/foreground, and fetch
detail pages only for expanded computers. Mobile changes are JS-only;
native configuration and dependencies are unchanged. The Diagnostics
page only loses its obsolete subtitle; its layout and other sections are
unchanged.

Validation:
- Generated contracts with `bun run gen`.
- Changed-file oxfmt and oxlint passed at `nice -n 19`.
- Added gateway gRPC integration coverage for aggregation, attention
pagination, failure-only threads, identical computer/thread IDs across
owners, title isolation, message-body exclusion, committed timestamps
and duplicate ranges.
- Rebased on `dev` through #554, including #546 and #547. Resolved the
generated-contract conflict by regenerating the merged proto; `bun run
gen:check` passed again. Migration registry and schema expectations
contain 0124, 0125 and 0126 in order. `bun install` passed locally.
- Latest focused migration run passed: 25 tests / 105 assertions across
`packages/db/test/inherited-access-upgrade.test.ts`,
`packages/db/test/thread-sync-upgrade.test.ts` and
`packages/db/test/schema.test.ts`. The #547 test now checks the
contiguous 0124 → 0125 upgrade before applying later migrations,
preserving every explicit owner choice. Earlier gateway/schema run
passed 26 tests / 157 assertions. The full `check:tmp` was deliberately
left to GitHub CI during the host measurement window.
- Manual Chromium review of the real Settings → Diagnostics route
against an isolated gateway/database with synthetic presence: caught up,
catching up, paused with reason, unreachable; 126 threads across three
computers; long names/titles; light/dark; desktop 1280×800 and phone
390×844. Verified 25+5 attention pagination, qualified thread link
targets, automatic transition to the calm caught-up state, icon
refresh/tooltip and absence of zero counters. Fixed a phone overflow
found during this review. No web UI tests added.
- EAS CLI 27.4.1, production profile: fingerprints match `origin/dev`
exactly on both platforms (iOS
`6ddec9ef559ee0095ac33e94ff9418a942053b17`; Android
`5f6eae3ab278f1cd543e9ed763f923a319b65ec9`). Compared against a clean
archive with its own matching dependency install.

Copy audit (§8):
- Repeated hostname + “Up to date” → display name + “2 of 42 catching up
· 1 paused · 15 records to go”: identifies the computer and actionable
work.
- “Remaining / 0 to go” and “Threads / 0 / 0” → “All threads are up to
date” with last sync time: removes empty metrics.
- Two explanatory descriptions → “Sync with linked computers.”; removed
“Check sync progress without opening thread content.”
- “Refresh” → icon button labelled/tooltipped “Refresh sync status”.
Pause reasons use the existing shared vocabulary; recovery says
“Retrying automatically.” or “Check the linked computer.”
- Reviewed sentence case, length, plurals, glossary, actions, error
recovery and textual status cues. No humour or new glossary terms.
Short, typical and long-name/title layouts checked in Chromium at
desktop and phone widths in light and dark modes.
nixuuu added a commit that referenced this pull request Nov 12, 2026
The same thread now exposes its home connector access and scheduled
tasks from either linked computer. A dedicated display DTO omits
credentials, headers, endpoints and account errors. Connector grants,
schedule creation, edits and cancellation run at home with owner and
revision checks. Worker grants affect every thread on that worker;
inherited All workers and account administration show a compact
home-management hint.

Verified panel responses survive a restart and remain visible as stale
when the home or panel read is unavailable. The archived sidebar now
pages local rows together with committed linked metadata: the previous 7
vs 31 counts came from intentionally local-only archive reads.

The three-gateway move regression now reconnects with a saved thread
cursor and requires a removal from the old home. The runtime exemption
for mirror subscriptions and range acknowledgments is already present in
the rebased dev branch; individual thread operations still follow their
redirects, and ACKs retain peer/subscription/cursor validation.

Gateway-to-gateway regression coverage exercises safe metadata, schedule
create/list/edit/cancel, home enforcement after grant changes, owner
isolation, cached stale reads, restart/unlink and archive
totals/pagination. Mobile changes are JavaScript/TypeScript only; native
configuration and dependencies are unchanged.

Validation:
- `bun install`, `bun run gen:check`, package-db typecheck and
changed-file oxfmt/oxlint passed. No full local `check:tmp` was run, as
requested; CI runs the full checks and test shards.
- Focused gateway-to-gateway panel tests, schema and upgrade tests
passed. The three-gateway move regression passed 20 consecutive runs.
After rebasing onto migration 0126, the panel/schema/inherited-access
tests passed; the staged sync upgrade exposed an ordering assumption,
was repaired and passed its focused rerun (17 assertions).
- Real-browser review used two linked gateways in light/dark at desktop
and phone widths. Both views show Connectors and Scheduled tasks. Remote
grant revoke/restore was reflected at home; remote schedule
create/edit/cancel worked. Disconnecting home retained connectors and
schedules with explicit stale/unreachable text and disabled actions.
Both archive counts were 38 (7 + 31), including offline. Short, typical
and long labels remained readable without horizontal overflow; removed a
duplicate offline hint that compressed schedule rows on phones.
- Native fingerprints match the tested dev base (`a79d316c`) for both
platforms: iOS `6ddec9ef559ee0095ac33e94ff9418a942053b17`; Android
`5f6eae3ab278f1cd543e9ed763f923a319b65ec9`. Mobile changes remain JS/TS
only. Subsequent rebases include JS/TS-only mobile changes from dev;
fresh CI runs on the final head.

Copy audit (§8): hidden sections → visible Connectors and Scheduled
tasks; Manage → scoped connector-access dialog with “Changes apply to
every thread on this worker.” This states the grant's actual scope.
Stale metadata → explicit last-known-details status; account-wide
changes → “Manage accounts on <computer>”. New actions use verbs,
sentence case and text status cues; no humorous copy. Existing controls
provide keyboard/focus behavior and name truncation. Browser review
covered short, typical and long names in light/dark at desktop and phone
widths, including offline states and dialog scrolling.

Related: #543, #539

Migration coordination: rebased onto `580a4815`, including #562 = 0124,
#547 = 0125, #560 = 0126 and #557 = 0127. This PR registers
`0128_thread_panel_cache`; the loader and schema expectations list 0124
through 0128 in order. The staged thread-sync upgrade test reads the
migration tail dynamically after the explicit 0126 stage, including 0127
and 0128, checks that durable sync state survives, and verifies that
repeating the full migration is a no-op. It does not assume 0128 is the
latest migration. Focused schema and staged/inherited-access upgrade
tests passed again after this rebase (25 tests, 107 assertions); all 6
remote-panel integration tests also passed (63 assertions). `bun
install` and `gen:check` passed. An initial panel test launch resolved a
workspace package to another checkout; refreshing installation corrected
the local alias before the successful rerun.
nixuuu added a commit that referenced this pull request Nov 12, 2026
An update or restart can surface an authentication failure as “Pair
again” even when the saved computer identity has not changed. Reconnect
now treats RPC authentication failures as retryable and requires
repeated, locally verified TLS pin mismatches before requesting new
trust. A successful handshake with the saved identity clears stale
pairing state.

## Investigation

- The dial catch classified **every**
`ConnectError(Code.Unauthenticated)` as a pin mismatch. That includes
invalid certificate validity, a peer rejecting the client pin, and hello
validation; on a manual route it persisted `pairing_required`, and on
LAN it deleted the route. This behavior exists in the original linking
implementation (#13), before the reported release range.
- Reviewed `v0.2.0-nightly.120..v0.2.0-nightly.137` and the `.133` →
`.137` diff, including #547, #548, #559, #562, #565, #566 and #546. The
full desktop hello grew from 32 capabilities to 33 in #559; both
releases reject more than 32 as `Unauthenticated: Invalid computer
identity` after pinned TLS succeeds. Merged #574 fixes this capability
overflow, including compatibility with the older validator. This branch
is rebased onto that fix in `dev`. Full source evidence:
#573 (comment).
- Identity and the 20-year certificate are persisted in
`computer_identity`; the private key uses the existing encrypted secrets
key. Desktop keeps the same Canopy data directory, database,
app/keychain name and `secrets.enc` across versions and channel changes.
Keychain/decryption failure stops startup rather than replacing the
identity. Reinstalling while preserving that data preserves trust;
deleting it creates a new identity.
- Production starts computer links, including loading identity and
peers, before opening Network access. There is no demonstrated
listener-before-store race in that path. The new readiness guard also
makes an early or stopping link service explicitly return `Unavailable`.
- `manual` means entered by the user, including a LAN/Tailscale address;
it is separate from the network's address type. A bad manual path must
not override another route or an incoming connection proving the saved
pin. The capability-count rejection is source-proven for the reported
version pair's full desktop configuration; incident logs would still be
needed to attribute every earlier report or explain successful
re-pairing.

## Changes

- Use a local `CertificatePinMismatch` signal emitted only after TLS
proof of possession and validation of a different self-signed
certificate. Override ConnectError's inherited structural
`Symbol.hasInstance` check so ordinary RPC errors cannot impersonate
this local class. Without this override the new LAN test correctly
caught a real route-deletion bug, not test timing. Invalid/expired
certificates remain rejected without declaring an identity change.
- Exhaust routes first. Require the same different certificate at the
same manual route in two consecutive failed rounds. A matching pinned
TLS connection or ready incoming link outweighs stale addresses. Only a
verified pin mismatch removes a discovered LAN route. Saved pins are
never replaced automatically.
- Clear confirmation evidence after pinned TLS verification, a
successful handshake, explicit pairing, route edits and unlink. Existing
successful handshake recovery also clears a persisted `pairing_required`
after restart.
- Use the shared reason “{name}'s identity changed. Pair again to trust
it.” for linked computer availability and app updates, including the
relay's name when its identity changed. Remove the contradictory
automatic-retry explanation for that state. Add stable auth-failure
classifications to diagnostics without logging certificates, keys,
addresses or RPC payloads.
- Document persistence and recovery. No proto changes, protocol bump or
migration.

## Regression coverage

Added gateway↔gateway integration scenarios using independent databases
and real TLS listeners:

1. Repeated startup `Unauthenticated` on manual and LAN routes preserves
trust and resumes; verify the LAN route remains after each attempt. RPC
error text cannot impersonate a local pin mismatch, and failed TLS
connections cannot confirm a manual route's identity change.
2. An early listener returns `Unavailable` for both `Pair` and `Connect`
until ready.
3. Both gateway/core restarts reuse persisted identities/certificates
and reconnect; a protocol-1 `.133` hello without new capabilities links
with a `.137` hello and resumes after upgrading.
4. A real new key requires confirmed pairing, receives no RPC, never
replaces the pin, and has consistent availability/update explanations.
5. A persisted stale pairing state heals after restart; a valid
alternate route outweighs a stale manual address with another key.

The older-version scenario exercises the compatible wire
hello/capability set, not archived app binaries. Installer and OS
keychain behavior was inspected in source, not exercised on
macOS/Windows.

## Validation

- After maintainer clearance, ran only the two authorized test files,
sequentially, at `nice -n 19`, using `TMPDIR=/var/tmp` and `bun run
check:tmp`: `linked-pairing-recovery.test.ts` **10 pass**,
`linked-capability-compatibility.test.ts` **3 pass**. Both
temp-directory checks passed. The original LAN failure reproduced before
the fix (8 pass / 1 fail); the strengthened assertion confirmed deletion
immediately after the first auth failure.
- Changed-file formatting and lint passed; `git diff --check` is clean.
Earlier dependency install and repository formatting/lint checks passed
before the original push.
- CI validates generation, full typechecking, all test shards and builds
for the rebased head. Browser verification remains pending; the UI
change reuses existing components and only changes status explanations.

## Copy audit (§8)

“{name} must be paired again” / “Link it again…” / “unavailable, trying
again automatically” → “{name}'s identity changed. Pair again to trust
it.” The text states the verified problem and the explicit trust action,
uses two short sentences and avoids TLS jargon. The compact action badge
remains “Pair again”. Names are interpolated as whole values and
existing wrapping/layout remains in place; short/long-name checks at
desktop/phone widths have not been run yet.

Related: #13
nixuuu added a commit that referenced this pull request Nov 12, 2026
…#577)

The maintainer asked to remove two rows from the thread summary panel:

- **Access mode** ("Full access" with the "No sandbox" badge). The
composer footer already shows the mode and lets you change it. The
clamped-mode note from #547 still shows when the gateway lowered the
mode, because it explains a change the user didn't make.
- **"Current branch" / "History"** under each linked pull request. On
web it only carried a tooltip ("Linked automatically / manually").
Mobile showed both texts, so it now matches web.

Both changes are on web and mobile and are JS-only.

Copy audit (docs/copy.md §8): only removals. No new or changed text.
nixuuu added a commit that referenced this pull request Nov 15, 2026
## Change

When a thread defaults to Ask first but its current message runs in Full
auto or Full access, **Same as parent** incorrectly starts subagents in
Ask first. Subagents now inherit the effective calling-turn mode while
later changes to the parent's default, fixed owner settings, and worker
capability limits still cap new children.

Migration `0151_turn_thread_permission_mode` records the thread default
at dispatch separately from the turn's effective permissions. The
snapshot and worker command are written under the same admission lock;
model and effort defaults are resolved from that locked thread as well.
Turns started before the migration keep the conservative permission
ceiling until they finish. Includes Polish documentation and
gateway/worker integration regressions.

Fixes: #547

## Verification

- Reproduced before the fix: an Ask first thread with a Full auto turn
created an Ask first child.
- Local: **56 tests passed** through selective `check:tmp` runs: 23
schema tests and 33 tests across `subagent-permission-inheritance`,
`full-access-mode`, `thread-permission-mode`, `agent-bus`, and
`models-steer`. Temp-directory cleanup passed.
- Gateway package typecheck, lint and formatting on edited TypeScript
files, and `git diff --check` passed.
- Integration coverage uses scripted workers and checks both persisted
API permissions and the mode delivered over the worker link. Full
repository checks and builds remain for CI.
- No UI text changes; copy audit is not applicable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant