AstrBot-Desktop/docs/reports/p02-policy-guards.md
YokiiroBW 34a563c65b feat(connection): validate auto-connect and guard operations switches
Add configuration-only auto-connect rules, runtime operations slot lock
while tasks are active, and duplicate server-instance warnings without
silent Profile merge. Surface policy status to the settings UI and cover
the new boundaries with Rust and Vitest checks.
2026-07-20 00:49:15 +08:00

2 KiB

P02 policy and operations-switch increment

Date: 2026-07-20

Source state

  • Branch: feat/p02-dual-connections
  • Base feature commit: bcc08cf feat(connection): add persistent dual slot assignment
  • Scope: auto-connect validation, operations switch protection, duplicate server-instance warnings

Completed scope

  • Profile create/update accepts non-secret autoConnect and autoConnectSlot.
  • Auto-connect rules: auto-connect requires a slot; no slot when auto-connect is false; at most two auto-connect Profiles; distinct slots.
  • RuntimeGuards tracks in-process operations tasks and locks operations slot assign/clear while any task remains.
  • Companion slot remains mutable while operations work is active.
  • Duplicate server_instance_id values surface as warnings only; Profiles stay separate.
  • connection_policy_status returns lock status, active task count, and warnings.
  • Profile UI shows auto-connect controls, operations lock messaging, and duplicate-instance banners.

Security boundary

  • No Token, password, API Key, Cookie, Authorization header, or NAS credential field was added.
  • Auto-connect configuration does not open REST/SSE sessions in this increment.
  • Operations begin/end task controls are not exposed as product IPC yet.
  • Slot assignment still grants no local-tool permission.
  • PD-0009 through PD-0012 remain unresolved; real Gateway activation is not claimed.

Verification

  • Frontend Prettier, ESLint, TypeScript, 6 Vitest tests, and Vite production build: passed.
  • Playwright Chromium: passed 1/1.
  • Rust fmt and Clippy (-D warnings): passed.
  • cargo test --workspace: passed; 63 normal tests, 2 ignored.
  • cargo check --workspace --all-targets: passed.
  • Changed-file secret scan: passed.

Not rerun for this checkpoint:

  • real Tauri development startup;
  • Windows release or NSIS build;
  • Forgejo Actions;
  • real AstrBot Gateway compatibility;
  • real UNC file transaction.

Next concrete step

Implement formal credential enrollment/update/delete entirely in Rust with opaque references only.