Roles: capability-based, admin and member #638
Closed
opened 2026-10-20 08:19:21 +00:00 by kayg
·
40 comments
No Branch/Tag specified
main
port/tasks-float-2
fix/train-1116-2
fix/train-1116-3
fix/train-1116-1
fix/flake-1134
fix/server-1182
dev
port/notes-float-3c
docs/auto-update-ig
feat/dav-transport
port/tasks-float-1
wip/mail1011-sv-order-1116
fix/flake-1179
fix/flake-1178
fix/guards-1153-fsio-split
fix/guards-1153-notes-split-we
fix/guards-1153-notes-lib
fix/guards-1153-notes-home
fix/guards-1153-ui-primitives
fix/guards-1153-primitives-e2e
fix/guards-1153-visibility-doc
feat/paper-grey-1116
fix/flake-1165
fix/flake-1119
docs/imap-766-plan-v2
fix/e2e-unique-ports
t3/paged-search-reconcile-final
wip/mail1011-final-1115
docs/tasks-float-port
perf/editor-first-paint-1c
feat/imap-notes-fetch
feat/imap-notes-projection
feat/imap-notes-readonly
feat/imap-notes-auth
feat/imap-notes-server-foundation
wip/mail1011-txn-ownvocab-1115
wip/mail1011-txn-novocab-1115
perf/p1117-final-harness
perf/single-shot-repeats
port/tasks-matrix
wip/mail1011-txn-1115
fix/static-gates-1155
feat/files-s1-identity-r7
fix/files-r7-idle-loop
fix/daily-train-1152
port/notes-float
fix/editor-tables-test-types
port/notes-float-listscript
feat/tasks-actions
port/notes-float-phone-preload
perf/sound-comparator
port/notes-float-listscroll
port/notes-float-budgets
port/notes-float-suite-fix-b
port/notes-float-sidebar-fix
port/notes-float-trim
port/notes-float-3-lists
fix/attachments-meta-capability
docs/carddav-writes-v2-plan
feat/contacts-companion-pure
issue/carddav-read-perf-fix-r2
issue/carddav-read-r2
port/notes-float-devsync2
review/calendar-2
review/switcher-a-pills
port/notes-float-switcher-a
port/port-tables-2
review/switcher-ends
wip/whiteboard-s1-1114
port/port-tables
wip/mail1011-perfneutral
review/photo-tint
port/notes-float-shell
wip/local/collections-db
wip/local/mail-p1
wip/local/cold-growth-on-tiering
wip/local/tiering-v3-s1
wip/local/wal1051-cap
wip/local/tiering-v3-s1-resume
wip/local/index-position-startup-scan
port/notes-float-flat
port/notes-float-promote
wip/handover/mail1011-candidate
wip/handover/files-s1-candidate
port/notes-float-shell-only
port/notes-float-perf
feat/whiteboard-s1
feat/tiering-v5
fix/app-switch-hitch
wip/local/files-s1-dev-v4-final
feat/files-s1-dev-v4
fix/c2-glass-shared
feat/flat-lists
wip/handover/whiteboard-s1-resume
wip/att-lazy-861
feat/switcher-browse
wip/att-lazy-860
feat/tasks-float
recovered/flat-backup-candidate
perf/stalls-1054-kc
land/ai-toolbar
feat/collections-db
feat/collections-db-fixes
codex/mail-1011-redesign-20261111
fix/ai-toolbar
backup/macos-vm/st3-head
perf/trim-candidate-phonestack
feat/switcher-three
fix/1051-index-idle-checkpoint
perf/stalls-1054-kb
perf/stalls-1054-k
perf/stalls-1054-r3
fix/c2-contrast-tail
perf/stalls-1054-r3-preview
feat/collections-before
feat/tiering-v4
fix/timelog-caret
wip/local/tasks-actions
docs/tasks-writes-v2-plan
st3-r3
feat/pass8
review/calendar-2-before-1111
wip/tiering-v3-cold4
perf/stalls-1054-r2
fix/suite-A4
fix/suite-A5-probe
fix/suite-A6
fix/suite-A3
fix/suite-A2
fix/suite-A5
fix/suite-A1
wip/local/attachments-861-fix
feat/contrast
wip/local/ports-861
storage/wal-checkpoint-off-save-1051
wip/local/mail-1011-reconcile-20261110
feat/style-sheet-fixes
feat/money-round
perf/stalls-1054
wip/tiering-v3-cold5
t3/mail-1011-liveness
feat/iphone-fixes
feat/notes-approve
wip/local/shrow-work
feat/files-s1-identity
feat/quickfix
wip/tiering-v3-cold
wip/local/shared-row-swipes
backup/macos-vm/pfx-B
backup/macos-vm/pfx-C
backup/macos-vm/pfx-D
feat/contrast-r1
feat/tiering-v3-s2-tags
feat/folder-drop
t3/photos-s1
feat/tiering-v3-s1-namespace
wip/local/photos-s1
t3/photos-plan-slice-one
recovered/backup/p1b-61505
t3/paged-search-reconcile
t3/smooth-pane-transitions
t3/index-position-startup-scan
fix/private-staging-759b-r2
backup/macos-vm/hk/hk1009/pr877
backup/macos-vm/hk/hk1009/pr878
docs/undo-block-ids-plan
fix/undo-768
backup/macos-vm/hk/hk1009/pr875
backup/macos-vm/hk/hk1009/pr904
proto/block-identity-v7d
backup/macos-vm/hk/hk1009/pr846
backup/macos-vm/hk/hk1009/pr860
backup/macos-vm/hk/hk1009/pr861
backup/macos-vm/hk/hk1009/pr849
backup/macos-vm/hk/hk1009/pr848
backup/macos-vm/hk/hk1009/pr853
backup/macos-vm/hk/hk1009/pr957
backup/macos-vm/hk/hk1009/pr893
backup/macos-vm/hk/hk1009/pr889
backup/macos-vm/hk/hk1009/pr902
docs/imap-notes-plan
docs/quota-plan-2
fix/parallel-test-flakes
docs/calendar-backend-v2-plan
feat/calendar-ical-converter
backup/macos-vm/hk/hk1009/pr808
docs/contacts-import-v2-plan
issue/610-pm-midnight
feat/calendar-v2-s1-containment
backup/macos-vm/hk/hk1009/pr854
backup/macos-vm/hk/hk1009/pr845
backup/macos-vm/hk/hk1009/pr917
docs/dav-recorder-v2-plan
plan/previews-865
plan/save-log-durable-entry
backup/macos-vm/hk/hk1009/pr934
fix/e2e-data-on-ram
backup/macos-vm/hk/hk1009/pr888
feat/appwindow3
feat/appwindow2
feat/appwindow
feat/money-p1
feat/keys-sheet
review/calendar-2-themes
feat/smooth-cursor
fix/float-style
review/calendar-2-float
release/2026-11-06-hotfix
archive/port/rows-drop-code
archive/port/rows-actions
archive/port/rows
scratch/tasks-894-ui-gates
review/calendar-2-night-wip
recovered/flaky/toast-reduced
release/2026-11-05
archive/flaky/rows-drop-fixed
archive/flaky/rows-actions
archive/flaky/rows
sim/bm15-final
sim/bm15-bis-932
sim/bm15-bis-909
sim/bm15
sim/bm15-bis-887
perf/tiering-option-b
fix/sw-lazy-precache
archive/plan/save-log-durable-entry
mock/money-fix2
archive/fix/e2e-data-on-ram
mock/appearance-all
mock/pill-press
mock/pill-press-mac
backup/macos-vm/appearance-after
mock/auto-swipes
mock/mail-actions
backup/macos-vm/mock/mail-actions
mock/money-static
archive/review/standards-917
perf/tiering-761-fix
mock/type-audit
mock/third-pane
feat/contacts-import-v2-s1
perf/executor-hot-path
archive/port/hidden-blocks
archive/port/devices
scratch/executor-on-894
scratch/executor-spans2
scratch/executor-spans
archive/port/rows-drop
feat/tiering-761-d-scale
feat/tiering-761-c-index
feat/tiering-761-b-reader
archive/review/sharing-pr3-review-9fec3d1f
perf/ports-lazy-budgets
feat/tiering-761-a-migration
archive/review/sharing-pr3-review
archive/review/sharing-pr3-review-code
archive/plan/previews-865
archive/port/port-attachments-3
archive/port/contacts-merge
fix/motion-audit-859
fix/motion-audit-859-mac
archive/port/port-pickers
archive/port/port-tables-2
archive/port/port-tables
recovered/local/sharing-s1-pr2-room-snapshot-candidate
archive/fix/parallel-test-flakes-code-minipc01
docs/imap-766-readonly-slice
feat/dav-recorder-v3
research/788-diagnosis
archive/fix/parallel-test-flakes
archive/perf/pr792-cold-index-edit
docs/sharing-slice-1
recovered/feat/dav-recorder-v2
recovered/feat/dav-recorder-v2-edd7bbb
spike/imap-766-s0-cases
archive/fix/undo-768
recovered/feat/dav-recorder
recovered/feat/dav-recorder-901acd4
feat/contacts-import
perf/cold-growth-on-764
perf/cold-growth-on-tiering
recovered/feat/tasks-set-status
feat/tasks-move-reorder
feat/tasks-delete-promote-duplicate
feat/carddav-writes
perf/quota-on-tiering
perf/quota-simple
perf/cold-growth-on-quota-stack
recovered/perf/cold-growth-on-tiering
feat/calendar-identity
feat/calendar-event-parser
feat/calendar-props-maps
port/glass-when-ring
recovered/feat/tiering-761-s1-wip-8132a84
recovered/feat/tiering-761-s1-wip-9da4094
recovered/feat/tiering-761-s1-wip-724512c
recovered/feat/tiering-761-s1-wip-66e667e
recovered/feat/tiering-761-s1
wip/6by32-01-tier-761-s1-pause-20261030
spike/imap-766-s0
wip/6by32-02-calternal-pause-20261030
wip/8by64-01-review-688-pause-20261030
wip/6by32-01-verify-744-pause-20261030
wip/6by32-01-verify-742-pause-20261030
fix/private-staging-759b
wip/6by32-01-review-748-pause-20261030
wip/6by32-01-review-733c-pause-20261030
wip/6by32-01-review-733b-pause-20261030
review/calendar-month
wip/local/bm15-trash
plan/759b-staging
review/767b-tests
review/preview-2026-10-29
docs/tiering-731-plan
wip/c6b02-review-733d
wip/c6b02-bm1-full-a
docs/deploy-plan
fix/storage-owner-liveness-642
fix/storage-fix-7
feat/tiering-731
wip/tiering-731-first-attempt
perf/idle-honest-2
fix/storage-private-tmp-642-dev
fix/storage-exact-file-quarantine-642
perf/one-flush-save
review/calendar-static
review/indexing-ring
review/when-field-2
proto/block-identity-2-review
proto/block-identity-review
review/when-field
issue/tasks-create-ids
issue/tasks-create
review/combined
review/task-polish
review/top-buttons
review/q1-q5
archive/integ325-293
archive/integ325-ci
issue/calendar-adr
archive/old/train/2026-10-23bk2
archive/old/train/2026-10-23bk
issue/469-mockup-9a
issue/smart-tasks-mockup
issue/469-menus
issue/652-signout-flake
issue/652-history-fix7
issue/652-history-fix6
archive/old/issue/spring-check-perf
issue/spring-check-perf
issue/659-rename-fast
archive/old/train/2026-10-21ar
issue/search-hardening-3
issue/652-history-fix5
issue/660-port-sheets-glass
issue/652-history-fix4
issue/652-history-fix3
issue/652-history-fix2
issue/652-history-flake
train/2026-10-21an
issue/settings-admin-port
issue/search-port
train/2026-10-20am
issue/storage-split-fix2
issue/storage-split
archive/old/issue/folder-ids-fix
train/2026-10-20al
archive/old/issue/folder-ids
train/2026-10-20ak
issue/tables-mockup
train/2026-10-19aj
train/2026-10-19ai
issue/469-merge-fixes
issue/sidebar-band
archive/old/issue/608-settings-spec
train/2026-10-19ah
issue/swipe-offscreen
train/2026-10-19ag
archive/old/issue/590-nlp-adr
archive/old/issue/587-event-after-write-2
train/2026-10-19af
archive/old/issue/587-event-after-write
issue/469-pill-room-c
issue/469-pill-room
train/2026-10-19ae
issue/469-narrow-handle
issue/397-ios-swipe-2
issue/469-desk-fixes
archive/old/issue/auto-update-adr
issue/469-filter-gap
issue/469-port-1b
issue/442-opacity-flake
issue/327-web-fast-3
archive/old/issue/469-port-1
issue/469-port-1
issue/327-web-fast-2
archive/old/issue/327-web-fast
archive/old/issue/425-stt-bench-vq1
archive/old/issue/445-no-bleed
archive/old/issue/400-swipe-mockup-2
issue/426-client-review
issue/426-client-2
issue/426-client
archive/old/issue/476-safe-area-lab
archive/old/issue/445-top-light
issue/471-blocks-mockup
archive/old/issue/448-links-app-2
archive/old/issue/448-links-app
archive/old/issue/398-cold-links
issue/434-442-small-2
issue/434-442-small
archive/old/issue/398-unload
archive/old/issue/445-bottom-band
issue/445-bottom-band
issue/351-rem-3
issue/351-rem-2
issue/351-rem
archive/old/issue/327-first-note
issue/395-width-phone
archive/old/issue/327-typing
issue/396-ios-edges
issue/397-ios-swipe
archive/old/issue/327-notes-index
issue/345-347-contrast-empty-2
archive/old/issue/44-arenas
issue/44-arenas
archive/integ325
archive/old/issue/327-perf-harness
archive/old/issue/44-thp
issue/44-thp
archive/old/issue/285-sticky-pills
archive/old/issue/44-trim-3
issue/44-trim-3
archive/old/issue/165-cards
archive/old/issue/165-picker-2
archive/old/issue/212-multi-select
No results found.
Labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
kayg/calternal#638
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Store role capability sets in auth.db. Check named capabilities inside the people actions, in the same transaction as each change. Promote the earliest existing account on migration and the first new owner. Prevent removing the final people.manage holder. List people through a single visibility function. Add ADR 0058 and tests for migration, capability checks and the last admin.
Starting on branch issue/people-roles-invites, base
b5a3aac970.Store role capability sets in auth.db. Check named capabilities inside the people actions, in the same transaction as each change. Promote the earliest existing account on migration and the first new owner. Prevent removing the final people.manage holder. List people through a single visibility function. Add ADR 0058 and tests for migration, capability checks and the last admin.
The requested CLAUDE.md and scripts/fj are absent from this worktree. Read the ADRs and vocabulary, and used the existing read-only legacy scripts/fj to create these issues. ADR 0058–0060 are free on both named refs. Existing data will stay in place; migrations are forward-only. No PR, merge or deploy.
Finding: crates/engine/src/execute.rs replays idempotent results before invoking the action handler. A handler-only capability check would not apply to a saved result after role demotion. Add a reusable authorization hook before replay, with a second check inside each shared-data write transaction. Invite creation returns an id only; copying a link is a read action, so plaintext invite secrets do not enter the per-user action result database.
The first local test command failed before compiling product code: linker
ccnot found. The shared scratchpad/env.sh supplies the Nix compiler and OpenSSL paths. Subsequent local heavy commands use that environment and the required build-slot wrapper, with cargo -j4.The new role tests first failed with unknown_action for people.list and people.role, confirming the missing API. Roles now have a database capability set. The migration keeps all current users, credentials, recovery tokens and installations, and assigns the earliest user as admin. The first account created after an empty migration is admin. Role changes use an immediate write transaction and count people.manage holders before a demotion.
The existing-database migration test found an error that fresh-database tests missed: SQLite refuses ALTER TABLE ADD COLUMN with REFERENCES and a non-null default on a populated users table. Kept the original users table and used reference-check triggers for the role column. Retested a copy built from schema v2 with two users, a passkey, a recovery token and an Installation. All rows survived; the oldest user became admin and the other became member. The schema v1 migration also passes. Migration takes an immediate write lock before reading user_version, so a concurrent CLI startup cannot run a stale migration step.
Role checks passed: auth library 14 tests, people integration 2 tests, core library 11 tests, engine library 13 tests. The generated server action contract also passed. Roles commit:
0690820.Invite commit:
5ba9b3a. New tests pass for copy-again after reopening Auth, encrypted secrets, exact 0600 key permissions, lost-key startup refusal, seven-day default expiry, expiry edits, revocation during a passkey ceremony, used links, generic failure responses, quota applied to the new member, and a two-redeemer race with exactly one successful passkey enrollment. The winner has their own Home. The action contract passes.The production upload test passes: two distinct uploads of 1 MiB plus one byte race against an allowance for one file; exactly one is saved. After lowering quota to zero, a 1 MiB file and a saved note still succeed, and another large upload gets the plain storage_quota error. The upload action verifies actual staged size before checking quota and holds a per-person guard through placement.
Correction to the earlier roles count: the core library run had 7 passing tests, not 11. The other counts were correct. Full final gate output will follow on all three issues.
The shipping-registry isolation gate passes with real auth.db person, invite and group ids. For every registered people.* and groups.* action, it compares the entire returned result or error category for a real id and a made-up id, using a member without management capabilities, another real member, an unknown caller, and anonymous HTTP requests. Private person names, group names and invite plan metadata carry a marker; no unauthorized result contains it. The existing all-action Home, attachment and room isolation tests still pass.
Group tests pass for shared visibility, multiple groups, membership removal, manager changes, denial of manager escalation, and refusing local writes to oidc groups. Invite tests also verify that redemption joins the configured group and applies quota, that another people.invite holder cannot copy the creator's link, and that knowing a hidden group id cannot authorize inviting into it.
The realistic migration test starts with real passkey enrollment, a live session, recovery and pending enrollment tokens. It makes a schema-v2 copy and opens it with the migration. Credential and session bytes are unchanged; the old session and passkey still sign in, and recovery and enrollment tokens still start their ceremonies. The oldest user is admin, the second is member with unlimited quota. Format and clippy gates have exit code 0; the full workspace test gate is running.
Finished and pushed branch issue/people-roles-invites. Head:
89770f6188.Roles are capability sets. The first owner and oldest existing user are admin. The last admin is protected, including racing demotions. Access checks run before saved results and in shared-data transactions. The realistic schema-v2 copy retains usable passkeys, sessions and recovery tokens.
Three commits:
0690820(roles),5ba9b3a(invites),89770f6(groups). ADRs 0058, 0059 and 0060 record the decisions. Backup instructions include system/invite.key. No PR, merge or deploy. The worktree is clean. No evidence or generated run artifacts were committed.All gates have exit code 0. Workspace tests: 610 passed, 0 failed, 2 existing ignored tests (the live Unsplash test and reload_speed). Local heavy commands ran through the required build-slot wrapper with cargo -j4 and the shared compiler environment.
Gate output follows verbatim:
Independent read-only audit started. Branch: issue/people-roles-invites. Head:
89770f6188. Base origin/dev:b5a3aac970. I will run temporary defensive tests, report evidence here, and remove the tests. No commits or pushes.P1: groups.list bypasses the shared person visibility rule. A custom role containing only groups.manage sees every group member, including a hidden account for which Auth::can_see_person returns false. Evidence: crates/auth/src/group_list.rs:8 and :29-35; roles.rs:30-47. Failing scratch test: crates/auth/tests/zz_audit_people.rs::audit_05_groups_manager_must_obey_single_person_visibility_rule. It creates an unrelated hidden member, assigns the caller groups.manage without people.manage, confirms can_see_person is false, and fails because the response contains the hidden id. Gate output: groups.list exposes a person denied by Auth::can_see_person. Filter returned members through the shared visibility rule or make the intended capability grant explicit and consistent.
P2: not every wrong invite token gets the generic invite response. Removing the cin_ prefix routes the candidate into legacy setup validation before the invite hash lookup. Both replies are 400, but one is setup_token_invalid and the other invite_invalid, with different messages and different work paths. Evidence: crates/auth/src/setup.rs:258-262 and crates/auth/src/invite_redeem.rs:15-35. Failing scratch test: crates/auth/tests/zz_audit_people.rs::audit_03_malformed_token_must_have_same_generic_response. The test strips the prefix from a real unused invite and compares the error bodies after removing the per-request id. Wrong, used, revoked and expired candidates retaining cin_ do match.
P2: invite lookup does not meet the required keyed-hash or constant-time comparison contract. It stores plain BLAKE3(token), then performs SQLite BLOB equality. Evidence: crates/auth/src/token.rs:23-25; invite_create.rs:85; invite_redeem.rs:17-29. Failing scratch test: crates/auth/tests/zz_audit_people.rs::audit_03_invite_lookup_must_use_keyed_hash confirms that the stored lookup value equals an independently computed unkeyed BLAKE3 digest. The generated secret still has 256 random bits and is encrypted with AES-GCM; this finding is a contract gap, not a demonstrated token recovery attack.
P2: quota rejects an existing attachment even though deduplication would add no bytes. With quota 1,048,577 bytes, the first upload of a file of that size returns 201. Uploading identical bytes with a fresh idempotency key returns 413 storage_quota instead of the existing 200 Already uploaded response. Evidence: crates/attachments/src/actions.rs:93-98 checks quota before place() can detect existing content in crates/attachments/src/place.rs:79. Failing scratch test: crates/calternal/tests/zz_audit_shipping.rs::audit_06_duplicate_upload_at_quota_must_not_spend_bytes_twice.
Verbatim failure:
assertion
left == rightfailed: an already uploaded attachment uses no additional storageleft: 413
right: 200
The separate eight-way upload test passes: exactly two different files fit a two-file allowance, the other six are refused. Notes still save above quota. Real note delete, Trash, restore and permanent delete have correct usage accounting.
Evidence correction and timing follow-up: the prefix dispatch is at crates/auth/src/setup.rs:230-234; the unkeyed digest is at crates/auth/src/token.rs:16-17 and its invite write is at invite_create.rs:84. The earlier comments used incorrect line numbers for these locations.
An isolated in-process timing probe made 80 requests per failure kind. Verbatim measurements:
wrong: median 205969 ns, p95 315316 ns
expired: median 229116 ns, p95 331870 ns
malformed-prefix: median 73084 ns, p95 141063 ns
revoked: median 230615 ns, p95 323672 ns
used: median 236326 ns, p95 329379 ns
Malformed-prefix candidates take a visibly shorter path as well as returning a different generic message. These shared-host observations demonstrate the code path difference; they do not establish remote exploitability.
Clock testing used an LD_PRELOAD shim on only the audit test process. It did not change the host clock. Advancing eight days expires a default invite; resetting or rolling back the wall clock makes the unused invite valid again. This is recorded as the existing wall-clock policy, not an additional defect because irreversible expiry after a clock rollback was not specified.
CLAUDE.md and scripts/fj are absent from this checkout and its tracked base. I found and read /home/kayg/Developer/calternal-v0-ro/CLAUDE.md for reference; it describes the older v0 project, so its unrelated workflows are not applied to this branch. The new ADRs and current source govern this audit. Final reporting will use the existing /home/kayg/Developer/calternal-v0-ro/scripts/fj wrapper.
Temporary audit test sources and fixture, preserved here before cleanup. These files were removed from the worktree after their final runs. The helper common module is the existing crates/auth/tests/common/mod.rs at head
89770f6188. The v2 fixture below comes directly from origin/dev:crates/auth/src/db.rs. The clock shim affected only the test process. Every cargo command ran inside the required local build slot with -j4.zz_audit_people.rs
zz_audit_shipping.rs
zz_audit_clock.rs
v2.sql
clock.c
Final gate evidence for head
89770f6188. Temporary audit tests are removed and git status is clean. No commits, pushes, merges or deployments. Full gate output follows verbatim. Commands used the required build-slot.sh wrapper, cargo -j4, and serial test execution. Compiler setup used the existing Nix compiler and OpenSSL paths.cargo fmt --check: no output, exit 0.
git diff --check origin/dev..HEAD: no output, exit 0.
cargo test -j4 -p calternal-auth --test zz_audit_people -- --test-threads=1
cargo test -j4 -p calternal --test zz_audit_shipping -- --test-threads=1
Isolated clock process: cargo test -j4 -p calternal-auth --test zz_audit_clock -- --include-ignored --nocapture --test-threads=1
cargo clippy -j4 --workspace --all-targets -- -D warnings
cargo test -j4 --workspace -- --test-threads=1
Independent defensive audit finished at head
89770f6188, baseb5a3aac970. Merge verdict: request changes.P1 — Hidden people leak through groups.list. A caller with only groups.manage sees accounts denied by Auth::can_see_person. Evidence: crates/auth/src/group_list.rs:8 and :29. Failing scratch test: crates/auth/tests/zz_audit_people.rs::audit_05_groups_manager_must_obey_single_person_visibility_rule.
P2 — Invite lookup uses unkeyed BLAKE3 and SQLite equality, meeting neither required comparison option. Evidence: crates/auth/src/token.rs:16 and crates/auth/src/invite_redeem.rs:22. Failing scratch test: crates/auth/tests/zz_audit_people.rs::audit_03_invite_lookup_must_use_keyed_hash. This establishes a contract gap; no token recovery attack was demonstrated.
P2 — A damaged invite prefix changes the error code, message and timing class. Evidence: crates/auth/src/setup.rs:231. Failing scratch test: crates/auth/tests/zz_audit_people.rs::audit_03_malformed_token_must_have_same_generic_response. Both statuses are 400; measured medians were 73 microseconds for malformed versus 206–236 for other failures.
P2 — Identical large uploads at quota return 413 instead of 200 Already uploaded, although they add no bytes. Evidence: crates/attachments/src/actions.rs:93, before deduplication at crates/attachments/src/place.rs:79. Failing scratch test: crates/calternal/tests/zz_audit_shipping.rs::audit_06_duplicate_upload_at_quota_must_not_spend_bytes_twice.
Authorization for all 13 new actions, expired sessions, eight-way redemption and upload races, competing admin demotions, key handling, normal token log/history checks, quota accounting, real-passkey migration, idempotence and migration rollback passed. Shipping isolation covers every new action. Clock rollback restores unused invites under the current wall-clock policy.
Scratch sources and detailed evidence are in earlier comments. Scratch tests removed; worktree clean. No commits, pushes, merges or deployments.
Final branch gates: cargo fmt --check and workspace Clippy passed. Workspace tests: 610 passed, zero failed, two ignored. Full verbatim gate output is in the preceding evidence comment. Final audit result lines, verbatim:
Starting people-fix on branch issue/people-roles-invites, base
89770f6188. Reading the audit and fixing all four findings with permanent regression tests. The supplied scripts/fj and CLAUDE.md are absent in this worktree; reading the existing contract from calternal-v0-ro and using the repository API for comments.Finding 1 fixed: groups.manage selected every group, and group_list.rs returned its members without roles::can_see. Group members now pass through the same function used by Auth::can_see_person and people.list. The permanent groups_manager_must_obey_single_person_visibility_rule test passes. A shipping registry sweep also checks returned names and person ids against Auth::can_see_person for member, groups.manage-only and admin callers, including nested results. Read actions run before writes can remove the seeded memberships.
Finding 2 fixed: invite_create.rs used token::hash, which is unkeyed BLAKE3. Invite lookup now uses BLAKE3 keyed mode with a context-derived key from system/invite.key. The indexed result is verified with openssl::memcmp::eq, including a dummy fixed-size comparison on a miss. The encrypted copy remains available for copy again. A forward schema migration marks old lookup indexes; startup rebuilds them atomically from authenticated encrypted copies. The permanent unkeyed-hash audit test passes. Testing migration rollback, restart, copy and redemption next.
Finding 3 fixed: setup::check previously rejected a damaged invite prefix before the database lookup. Malformed candidates now reach invite validation, which hashes, queries and compares before applying the format and lifecycle checks. Valid legacy setup/recovery token syntax keeps its existing flow. Permanent tests compare the public error body (except the per-request request_id), status and median timing class for malformed, wrong, expired, revoked and used invites. The first targeted run passed all five. The clock probe is now a deterministic unit test with an explicit time input, without a process clock shim.
Finding 4 fixed: attachments.add previously called UploadPolicy::admit before place checked the content index. It now checks actual indexed content before quota. A per-person placement lock covers deduplication through placement, so simultaneous identical uploads do not race quota. The permanent duplicate test passes at quota. Expanding it to eight identical concurrent requests, quota reduced below usage, and a stale index entry whose file has been deleted. The existing distinct-content quota race also passes.
Further regression from the workspace gate: a 52-character candidate can have valid legacy setup syntax while still being a malformed invite. Preserving a separate legacy failure would leave a format-based error difference. The setup route now checks both stores before every token refusal and returns the same generic error for all failed candidates. Valid setup, enrollment and recovery tokens still work; invalid legacy tokens intentionally share the generic response. Permanent malformed tests now include a removed prefix, damaged prefix, empty value, invalid encoding, Unicode and a legacy-shaped candidate. This supersedes the earlier note about preserving the legacy failure flow.
The earlier targeted results also confirm that old invite indexes upgrade atomically: corrupt ciphertext causes startup refusal without updating any lookup row; restoring it allows upgrade, repeated reopen, copy again and real passkey redemption. Eight simultaneous identical uploads produce one 201 and seven 200 responses; usage is unchanged by duplicates, including after lowering quota to zero. Removing the indexed file makes the next upload return 413 storage_quota.
Finished people-fix and pushed issue/people-roles-invites. Head:
e54af7a96e.All four audit findings are fixed. Group members use the shared person visibility rule. Invite indexes use keyed BLAKE3 with a separate derived key and constant-time verification; old indexes upgrade atomically from encrypted copies. Every failed token candidate checks both stores and returns the same generic failure, including malformed candidates with legacy setup syntax. Duplicate uploads are checked before quota under a placement lock.
The scratch probes are permanent regression tests. The process clock shim was replaced with a deterministic time-input test. The shipping registry sweep checks returned person ids and names against Auth::can_see_person. Migration rollback, restart, copy again and redemption pass. Eight identical uploads make one file and return seven Already uploaded responses. Stale index entries do not bypass quota.
All gates have exit code 0: 631 tests passed, 0 failed, 2 existing ignored. Local heavy commands used the required build-slot wrapper with cargo -j4. Worktree clean. No PR, merge or deployment. No evidence or generated artifacts were committed.
Gate output follows verbatim:
Starting read-only people re-audit on branch issue/people-roles-invites at
e54af7a96e(fix base89770f6). I will recreate the audit probes, test additional variants, compare against the base in a temporary worktree, and run the requested workspace gates. No commits or pushes.Base comparison evidence: the exact recreated original probes fail at
89770f6188in detached temporary worktree /tmp/people-reaudit/base-89770f6. Product files were not edited. All cargo commands used the required build-slot wrapper and -j4.P1 visibility: audit_05_groups_manager_must_obey_single_person_visibility_rule fails with 'groups.list exposes a person denied by Auth::can_see_person'.
P2 lookup: audit_03_invite_lookup_must_use_keyed_hash fails with 'lookup is an unkeyed BLAKE3 digest; SQLite blob equality is not constant time'.
P2 failure response: audit_03_malformed_token_must_have_same_generic_response fails: setup_token_invalid versus invite_invalid, with distinct messages.
P2 quota: audit_06_duplicate_upload_at_quota_must_not_spend_bytes_twice fails: left 413, right 200.
Base auth run: 0 passed, 3 failed; exit 101. Base upload run: 0 passed, 1 failed; exit 101. Fixed-head and new-variant results follow separately.
Fixed-head evidence at
e54af7a96e: all six temporary auth probes passed (0 failed).P1 hidden-person disclosure: the original groups.manage-only probe now passes. New variant people.list shows a shared person before group removal and hides both their id and name after removal; groups.list agrees with Auth::can_see_person.
P2 unkeyed lookup: the original independent plain-BLAKE3 comparison now passes. Code inspection confirms a context-derived keyed BLAKE3 index and openssl::memcmp::eq after indexed lookup. New missing/replaced-key probe: a missing key refuses startup without generating a replacement; a different valid-length key cannot redeem or copy the existing link. Stored hash stays unchanged, and restoring the original key restores both operations. A different key is accepted at startup once all lookup rows are v1, but fails closed for existing links; automated rotation is not specified.
P2 failure responses: the original malformed-prefix response comparison now passes. New timing probe alternates request order, excludes 20 warmups per kind, and measures 200 requests per kind with rate limiting raised for the test. All 400 responses have identical error fields after removing request_id.
Verbatim measurements:
malformed-prefix: n=200 median=266346ns p95=472343ns p99=804955ns
revoked: n=200 median=264314ns p95=530130ns p99=1366282ns
The medians differ by about 0.8%, with overlapping distributions. This shared-host in-process sample does not show the old large timing-class split and cannot prove remote timing indistinguishability. Workspace gates and upload evidence follow.
Temporary re-audit probe sources, preserved before cleanup. Original probes are copied from audit comment 60567, with formatting and filenames changed; the upload harness omits the unrelated isolation module. The common auth helper and product code are unchanged. Additional variants follow the originals. No evidence is committed.
zz_reaudit_people.rs
zz_reaudit_shipping.rs
P2 quota-before-dedupe: fixed at
e54af7a96e. The original scratch probe uploads 1,048,577 bytes into an exactly matching quota: first upload 201, identical bytes under a fresh idempotency key 200. The same probe fails on89770f6with 413 instead of 200.New cross-person variant passed: Alice uploads the bytes; Bob with zero quota receives 413 storage_quota for both Alice's bytes and unrelated bytes. After Bob gets room for one file, Alice's bytes return 201 and create Bob's own file, with the full 1,048,577 bytes counted against Bob. Only Bob's subsequent duplicate returns 200. No cross-person dedupe disclosure was observed.
Shipping scratch target: 3 passed, 0 failed (the two audit probes plus the existing contract test). The scratch harness emitted one dead-code warning because it omits the unrelated isolation module; scratch tests are now removed before the clean workspace gates. Auth scratch target: 6 passed, 0 failed. Both scratch files and the temporary base worktree are removed; no product files changed, no commits or pushes. Requested workspace gates now running.
Finished gate evidence for re-audit head
e54af7a96e. Scratch tests and the detached base worktree are removed. The worktree is clean. All local heavy commands ran through the required build-slot wrapper with cargo -j4. Gate output follows verbatim.Read-only re-audit complete. Head:
e54af7a96e. Merge verdict: approve.All four original probes fail with their expected defects on
89770f6. New variants pass. No additional findings. Existing-test review found no removed coverage: expectations track the unified errors/schema, and quota refusal still uses distinct content.Gates: fmt and clippy pass; workspace tests 631 passed, 0 failed, 2 existing ignored. Verbatim gate output and probe sources are in preceding comments. Scratch tests and temporary worktree deleted; worktree clean. No commits, pushes, merges or deployments.
Landed in train AL, #643.
Train AL ran the full suite: fmt, clippy, workspace tests, the build, svelte-check, and every Playwright project in parallel shards.
Failures, each checked (this train changes no web code:
git diff origin/dev..HEAD -- apps packagesis empty):phone-edges:121(chromium-390): the whole file, 432 of 432, alone.contrast:152:Target crashed(browser crash under load); 3 of 3 alone.pill-room:309(webkit-1440): a 1 px glyph offset, 3 of 6 alone. It is pre-existing and environmental, since this train has no client changes; tracked separately.Contents (server only):
Independent audit found 1 P1 and 3 P2; all fixed and re-audited (approve). 631 workspace tests.
kayg 2026-10-20: the Settings Admin/People/Groups/invite mockup is "not good enough but okay to merge because production needs that functionality". Porting it into apps/web as-is; a design pass follows later.
Started work for #638/#639 on branch
issue/settings-admin-port. Baseorigin/devSHA:df0ace56faa4eee5493f3fb4d19798eb4215be2e; branch HEAD before merge:be7f266f62f146d5e97f2fcbb3581299cfd7ceca. I am merging the storage split and tracing the server and web paths.Findings with source evidence:
crates/auth/src/http.rs/api/v1/auth/mereturnsid,name, andusernameonly;apps/web/src/lib/admin.svelte.tsinfers admin fromusage_byteson the caller’speople.listrow.crates/auth/src/invite_redeem.rsconsumes the invite, creates the user, and applies group grants but records no live event; the current invite e2e reloads the admin page after redemption. The event recorder writes to one user journal at a time, so the invite event will be sent only to people managers verified throughroles::can_see(ADR 0060).Clippy finding while verifying the implementation: it reported
clone_on_copyatcrates/auth/src/http.rs:193becauseUserIdisCopy. I removed the redundant clone and am rerunning the lint gate.Browser evidence: the new live People row assertion passed in
admin-chromium-1440. Inadmin-chromium-390, it also passed; the run then failed at the existing Groups assertion inapps/web/e2e/admin-invite.spec.ts:70because the exact-name member button was absent after the group showed1 person. I am checking the phone markup and will adjust the spec if the assertion does not match the mobile UI.Resolved the phone e2e finding: on the long mobile Settings page, Groups stays mounted after the group is created, so it was already expanded and the old unconditional click closed it.
apps/web/e2e/admin-invite.spec.tsnow checksaria-expandedbefore toggling; the membership assertion remains in place.Completed #638/#639. Branch:
issue/settings-admin-port; head SHA:6eca08a23876b034bcc188bea84ceea906ddad3a.Gate output:
The e2e run explicitly included setup and both Chromium admin projects because
pwenv.shhad no saved admin state. Pushed the feature branch; no PR was opened.Landed in train AN, #651.
Train AN ran the full suite at
eca2f3d: fmt, clippy, workspace tests, the build, svelte-check, every Playwright project in parallel shards: cr1440 298, cr390 233+197, wk1440 136+162, wk390 141+180+112 all passed. The small shard failed only admin-contrast.spec, picked up by the contrast project's broad pattern (it needs the admin session). Fixed the pattern at2865763, added the four admin projects to the train script (they had not been run), and reran at2865763: small 19 passed / 4 skipped, admin 39 passed (chromium and webkit, 1440 and 390).Contents:
Closing during the 26 Oct handover cleanup: Landed in train AN (#651).