File-browser: make Owner column, per-file lock, and folder item-counts real (deferred from #311) #315
Closed
opened 2026-08-26 15:04:26 +00:00 by Cordy
·
4 comments
No Branch/Tag specified
main
b12v07
b11v07
b10v07
ci-rc-publish
fx15-s3dry
b9v07
b8v07
bench742
b7v07
legal-texts-v0.2
b6v07
b5v07
b4v07
b3v07
sx1139
st742
b2v07
ix1102
fu1098
zp1097
wd1099
tr1100
qf1077
nc1070
ci1
rp1072
lk1073
ab1071
fi1074
si1070
ra1054
wo1056
oc1057
tf1055
sv1063
fg1059
st1058
fs929
mu1039
ls1033
cf975
lf835
dx1023
ml896
a11y2
av1022
r913
r7
r6
r5
r45
r23
r1
b10
b9
fix-b5
fix-b4
fix-b3
fix-b2
fix-b1
fix-922
fix-923
fix-911
fix-343b
batch-a
v0.6.413
v0.6.412
v0.6.411
v0.6.410
v0.6.409
v0.6.408
v0.6.407
v0.6.406
v0.6.405
v0.6.404
v0.6.403
v0.6.402
v0.6.401
v0.6.400
v0.6.399
v0.6.398
v0.6.397
v0.6.396
v0.6.395
v0.6.394
v0.6.393
v0.6.392
v0.6.391
v0.6.390
v0.6.389
v0.6.388
v0.6.387
v0.6.386
v0.6.385
v0.6.384
v0.6.383
v0.6.382
v0.6.381
v0.6.380
v0.6.379
v0.6.378
v0.6.377
v0.6.376
v0.6.375
v0.6.374
v0.6.373
v0.6.372
v0.6.371
v0.6.370
v0.6.369
v0.6.368
v0.6.367
v0.6.366
v0.6.365
v0.6.364
v0.6.363
v0.6.362
v0.6.361
v0.6.360
v0.6.359
v0.6.358
v0.6.357
v0.6.356
v0.6.355
v0.6.354
v0.6.353
v0.6.352
v0.6.351
v0.6.350
v0.6.349
v0.6.348
v0.6.347
v0.6.346
v0.6.345
v0.6.344
v0.6.343
v0.6.342
v0.6.341
v0.6.340
v0.6.339
v0.6.338
v0.6.337
v0.6.336
v0.6.335
v0.6.334
v0.6.333
v0.6.332
v0.6.331
v0.6.330
v0.6.329
v0.6.328
v0.6.327
v0.6.326
v0.6.325
v0.6.324
v0.6.323
v0.6.322
v0.6.321
v0.6.320
v0.6.319
v0.6.318
v0.6.317
v0.6.316
v0.6.315
v0.6.314
v0.6.313
v0.6.312
v0.6.311
v0.6.310
v0.6.309
v0.6.308
v0.6.307
v0.6.306
v0.6.305
v0.6.304
v0.6.303
v0.6.302
v0.6.301
v0.6.300
v0.6.299
v0.6.298
v0.6.297
v0.6.296
v0.6.295
v0.6.294
v0.6.293
v0.6.292
v0.6.291
v0.6.290
v0.6.289
v0.6.288
v0.6.287
v0.6.286
v0.6.285
v0.6.284
v0.6.283
v0.6.282
v0.6.281
v0.6.280
v0.6.279
v0.6.278
v0.6.277
v0.6.276
v0.6.275
v0.6.274
v0.6.273
v0.6.272
v0.6.271
v0.6.270
v0.6.269
v0.6.268
v0.6.267
v0.6.266
v0.6.265
v0.6.264
v0.6.263
v0.6.262
v0.6.261
v0.6.260
v0.6.259
v0.6.258
v0.6.257
v0.6.256
v0.6.255
v0.6.254
v0.6.253
v0.6.252
v0.6.251
v0.6.250
v0.6.249
v0.6.248
v0.6.247
v0.6.246
v0.6.245
v0.6.244
v0.6.243
v0.6.242
v0.6.241
v0.6.240
v0.6.239
v0.6.238
v0.6.237
v0.6.236
v0.6.235
v0.6.234
v0.6.233
v0.6.232
v0.6.231
v0.6.230
v0.6.229
v0.6.228
v0.6.227
v0.6.226
v0.6.225
v0.6.224
v0.6.223
v0.6.222
v0.6.221
v0.6.220
v0.6.219
v0.6.218
v0.6.217
v0.6.216
v0.6.215
v0.6.214
v0.6.213
v0.6.212
v0.6.211
v0.6.210
v0.6.209
v0.6.208
v0.6.207
v0.6.206
v0.6.205
v0.6.204
v0.6.203
v0.6.202
v0.6.201
v0.6.200
v0.6.199
v0.6.198
v0.6.197
v0.6.196
v0.6.195
v0.6.194
v0.6.193
v0.6.192
v0.6.191
v0.6.190
v0.6.189
v0.6.188
v0.6.187
v0.6.186
v0.6.185
v0.6.184
v0.6.183
v0.6.182
v0.6.181
v0.6.180
v0.6.179
v0.6.178
v0.6.177
v0.6.176
v0.6.175
v0.6.174
v0.6.173
v0.6.172
v0.6.171
v0.6.170
v0.6.169
v0.6.168
v0.6.167
v0.6.166
v0.6.165
v0.6.164
v0.6.163
v0.6.162
v0.6.161
v0.6.160
v0.6.159
v0.6.158
v0.6.157
v0.6.156
v0.6.155
v0.6.154
v0.6.153
v0.6.152
v0.6.151
v0.6.150
v0.6.149
v0.6.148
v0.6.147
v0.6.146
v0.6.145
v0.6.144
v0.6.143
v0.6.142
v0.6.141
v0.6.140
v0.6.139
v0.6.138
v0.6.137
v0.6.136
v0.6.135
v0.6.134
v0.6.133
v0.6.132
v0.6.131
v0.6.130
v0.6.129
v0.6.128
v0.6.127
v0.6.126
v0.6.125
v0.6.124
v0.6.123
v0.6.122
v0.6.121
v0.6.120
v0.6.119
v0.6.118
v0.6.117
v0.6.116
v0.6.115
v0.6.114
v0.6.113
v0.6.112
v0.6.111
v0.6.110
v0.6.109
v0.6.108
v0.6.107
v0.6.106
v0.6.105
v0.6.104
v0.6.103
v0.6.102
v0.6.101
v0.6.100
v0.6.99
v0.6.98
v0.6.97
v0.6.96
v0.6.95
v0.6.94
v0.6.93
v0.6.92
v0.6.91
v0.6.90
v0.6.89
v0.6.88
v0.6.87
v0.6.86
v0.6.85
v0.6.84
v0.6.83
v0.6.82
v0.6.81
v0.6.80
v0.6.79
v0.6.78
v0.6.77
v0.6.76
v0.6.75
v0.6.74
v0.6.73
v0.6.72
v0.6.71
v0.6.70
v0.6.69
v0.6.68
v0.6.67
v0.6.66
v0.6.65
v0.6.64
v0.6.63
v0.6.62
v0.6.61
v0.6.60
v0.6.59
v0.6.58
v0.6.57
v0.6.56
v0.6.55
v0.6.54
v0.6.53
v0.6.52
v0.6.51
v0.6.50
v0.6.49
v0.6.48
v0.6.47
v0.6.46
v0.6.45
v0.6.44
v0.6.43
v0.6.42
v0.6.41
v0.6.40
v0.6.39
v0.6.38
v0.6.37
v0.6.36
v0.6.35
v0.6.34
v0.6.33
v0.6.32
v0.6.31
v0.6.30
v0.6.29
v0.6.28
v0.6.25
v0.6.24
v0.6.23
v0.6.22
v0.6.21
v0.6.20
v0.6.19
v0.6.18
v0.6.17
v0.6.16
v0.6.15
v0.6.14
v0.6.12
v0.6.11
v0.6.10
v0.6.9
v0.6.8
v0.6.7
v0.6.6
v0.6.5
v0.6.4
v0.6.3
v0.6.2
v0.6.1
v0.6.0
v0.5.7
v0.5.6
v0.5.5
v0.5.4
v0.5.3
v0.5.2
v0.5.1
v0.5.0
v0.4.12
v0.4.11
v0.4.10
v0.4.9
v0.4.8
v0.4.7
v0.4.6
v0.4.5
v0.4.4
v0.4.3
v0.4.2
v0.4.1
v0.3.30
v0.3.29
v0.3.28
v0.3.27
v0.3.26
v0.3.25
v0.3.24
v0.3.23
v0.3.22
v0.3.21
v0.3.20
v0.3.19
v0.3.18
v0.3.17
v0.3.16
v0.3.15
v0.3.14
v0.3.13
v0.3.12
v0.3.11
v0.3.10
v0.3.9
v0.3.8
v0.3.7
v0.3.6
v0.3.5
v0.3.4
v0.3.3
v0.3.2
v0.3.1
v0.3.0
v0.2.7
v0.2.6
v0.2.5
v0.2.4
v0.2.3
v0.2.2
v0.2.1
v0.2.0
v0.0.3
v0.0.2
Labels
Clear labels
No items
No 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: Cordy/Cairn#315
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?
Deferred from the file-browser redesign (#311, PR2
internal/api/listmeta.go). The mockup depicts three pieces of per-item data that do not exist in the current model, so PR2 shipped only the two signals that are truthfully sourceable (shared,hold) and left these out rather than fabricate them. This issue is the placeholder to deep-dive later.What's missing and why
1. Owner (the Owner column + avatar)
storage.FileInfo(internal/storage/storage.go) isName / Path / Size / ModTime / IsDir / ContentType / ETag— there is no uploader/creator field, and by design the storage backend is the single source of truth with no DB-backed file index. So "who owns this file" is simply not recorded anywhere today. In a personal home the answer is trivially the viewer (which is why the column is hidden there); in a shared space it's genuinely unknown.document.body.setAttribute("data-space","personal")default inweb/static/index.html. That default should come out as part of this work, once owner data exists, sodata-spacereflects the real context (personal/space/shares) again.2. Per-file lock (the
lockchip)There is no per-file lock concept in Cairn. The only lock is
internal/statestore/lock.go— an instance boot-guard that stops two instances sharing one backend. The mockup'slockchip has nothing to bind to. Would need a real per-path lock subsystem (WebDAVLOCK? advisory app-level locks?) with a decision on semantics and enforcement.3. Folder item-counts (the "12 items" name sub-line)
Requires counting each subdirectory's children. On the main file-listing path that's a
Listper folder = N+1 backend round-trips on every navigation — a real latency/load regression on an object store. Needs either a cheap count source, a bounded/opt-in fetch, or a cached index before it's safe to turn on.Not blocking
The redesign is complete and live without these;
sharedandholdchips already ship. This is a "when we want to invest" feature, not a bug. Owner is the highest-value of the three and the one that would also let us retire thedata-space="personal"default.Refs: #311 (PR2/PR3),
internal/api/listmeta.go,internal/storage/storage.go,internal/statestore/lock.go.Status check after the v0.6.8x–v0.6.101 UI epic:
3. Folder item-counts — DONE (shipped in the file-browser fidelity round,
internal/api/listcounts.go).fillItemCountssets anitemschild count on directory entries, one extraListper subfolder, capped at 100 counted folders per listing so a huge directory cannot turn one browse into a listing storm; entries past the cap keep no count and render as the plain kind. Covered bylistcounts_test.go.1. Owner column — NOT done.
storage.FileInfostill carries no uploader/creator (listmeta.gostill deliberately omits it), and thedata-space="personal"default that hides the Owner column is still in place. The open design question stands: where creator metadata lives given no-DB + S3/Garage, and what happens for files created out-of-band (WebDAV, direct backend).2. Per-file lock — NOT done. Still no per-path lock subsystem; the only lock remains the instance boot-guard in
internal/statestore/lock.go.Remaining scope of this issue = owner metadata (and retiring the
data-spacedefault with it) + the per-file lock decision.Owner column — design ratified with Nikola (2026-09-01)
Research first: classic Nextcloud/ownCloud keep a DB file index (
oc_filecache) whose production pathology (100 GB+ tables, per-file SELECTs, million-file loads choking) is the strongest argument for Cairn's no-DB stance. oCIS rebuilt on our philosophy and landed on per-node metadata beside the data — xattrs first, then messagepack sidecars, because xattrs have hard size limits and break on shared filesystems (lesson: one mechanism for both drivers, never xattrs). S3 constraint:ListObjectsV2never returns user metadata, sox-amz-meta-*or per-file sidecars are a HEAD/GET per file — the N+1 that must not exist on the listing path. Conclusion: read cost must scale with folders browsed, never files stored.Decisions
D1 — Semantics. Owner = the original uploader/creator of a file or folder, recorded at creation, display-only in v1. Within a space, the space-owner additionally holds ownership over all contents (already expressed by the space model; nothing extra stored per file). Peering deliveries: owner = the recipient; if the recipient is a space, the space-owner. Transferable ownership and owner-as-permission-anchor are explicitly future work and must not be blocked by the data shape.
D2 — Storage: per-folder manifest. One hidden object per directory,
.cairn-meta.json, mapping child name →{owner, at}. One extra GET per listing regardless of file count. Lives inside the directory it describes, so folder rename/move carries it for free. Written at the trash layer's level in the stack (below scope, above encrypt) → ciphertext at rest on S3, and invisible/unwritable from every user surface (listing, WebDAV, shares, peering) with reserved-name enforcement. A folder's own record lives in its parent's manifest. Read-modify-write serialised per folder in-process — safe under the single-replica + statestore-lock topology; no CAS needed on Garage.D3 — Unknown owners: honest em dash + free inference. No record → server-side inference fills what is structurally certain: paths under
/home/<user>→ that user; space contents → the space-owner. Only genuinely ambiguous files (pre-existing shared-space content, out-of-band backend writes) render "—". No backfill sweep, nothing invented.D4 — Lifecycle. Move preserves the record (entry migrates between manifests). Copy records the copier. Delete removes the entry; the trash sidecar gains an
ownerfield so restore (user or admin) re-records the original owner. Renames into a trash tree drop the source entry; renames out are handled by the restore path. A failed manifest write never fails the user's operation — owner is best-effort display metadata (unlike holds); log and continue.D5 — API.
GET /api/v1/filesitems gainowner,omitempty, filled in the existing enrichment pass (with shared/hold/items): one manifest GET per listing, inference applied server-side so the UI never re-implements the rules. Missing/unreadable manifest degrades to pure inference; listing never fails over a badge.D6 — UI. Owner column live in space and shares contexts, hidden in the personal home — and this is the moment the intentional
data-space="personal"default from #311 is retired sodata-spacereflects real context. Cell = avatar initial + username per the design system (13.5px/500 name treatment); Details panel gains an Owner line; i18n in all four locales.D7 — Testing. Unit-level: manifest round trip, full lifecycle (move/copy/delete/restore), inference rules, concurrent-upload serialisation, invisibility/unwritability of
.cairn-meta.json(same shape as the.trashtests), and a guard asserting exactly one manifest read per listing regardless of item count.Future-proofing.
{owner, at}is a struct, not a bare string: transfer (#D1 future) becomes "write a new value + audit line"; permission-anchoring reads the same record. No migration needed later.Per-file lock remains the open remainder of this issue and gets its own design pass after owner ships.
Per-file lock — design ratified with Nikola (2026-09-02)
Owner and item-counts shipped earlier (v0.6.102–v0.6.105); this settles the last piece. Context that reframed the issue: Cairn already fakes WebDAV locks —
internal/davadvertises class 2 and "grants" every LOCK with a token, enforcing nothing (documented MVP choice; Finder/MS Office refuse class-1 servers). So Office clients believe they hold locks today and last-save-wins on concurrent edits. Research anchors: Nextcloud's split between invisible transactional locking and the user-facingfiles_lockapp (three lock types: user/app/token; manual locks indefinite by default; a CVE where unlock permission checks were wrong), RFC 4918 enforcement essentials (423 + precondition bodies, If header, Lock-Token, Timeout/refresh), and the finding that desktop Office co-authoring is SharePoint/OneDrive-only — over WebDAV, Word's exclusive-lock dance IS the feature, and it only works against real enforcement. Co-editing (WOPI + editor server) is acknowledged as a separate future epic (Nikola will raise it himself; deliberately no issue filed).Decisions
L1 — Scope: manual + real DAV locks in one system. Two lock types from day one:
user(manual, row menu, indefinite) anddav(created by real LOCK handling: token, RFC timeout, refresh, auto-expiry). The documented fake is retired, not built beside. Theapptype is reserved for the future co-editing epic.L2 — Semantics. A lock protects one FILE's content from other people's writes: Write/Delete/Rename(src or dst)/Copy-onto refused with
storage.ErrLockedfor everyone but the holder; Open/Stat/List never blocked. Distinct from legal holds (admin compliance instrument protecting existence, subtree-scoped, does not stop editing). Files only in v1 — folder locking mimics the hold authority model and stays out.L3 — Unlock rights: holder + admin + space-owner (for paths inside their space, resolved via
SpacesAPI.owner). Admin/space-owner break-lock is an explicit, audited unlock — there is NO silent admin write-through in the storage layer (one exact permission check in one place; the files_lock CVE lesson).L4 — Expiry.
userlocks indefinite by default with an optional instance cap setting (off by default).davlocks always expire per RFC Timeout (instance cap ~1h, floor 30s), reaped lazily; refresh via LOCK+If extends.L5 — Storage. Tenth statestore-managed file
locks.json: path →{owner, type, token?, at, expires?}; resolved backend paths; full in-memory index (enforcement is a map lookup, zero extra I/O, scales independent of file count); synchronous write-through — a lock that fails to persist fails the request (opposite of ownermeta's best-effort, on purpose: a lock is a promise).L6 — Enforcement. New
lockguardstorage decorator directly above ownermeta: sees backend paths + ctx user; trash's delete-rename passes through it, so deleting a locked file is refused for free. Holder renaming their file carries the lock; delete removes it.writeErrmaps ErrLocked → 423.L7 — WebDAV. LOCK → real
davlock (opaquelocktoken:UUID, Lock-Token header, lockdiscovery body, Timeout honoured/capped); refresh supported; conflicting lock → 423 +no-conflicting-lock; UNLOCK validates Lock-Token (bad token → 403); writes hit the shared guard, ErrLocked → 423 +lock-token-submitted; PROPFIND reportsactivelock. Holder identity exempts ordinary writes (no If-token demanded on PUT — identity is the stronger check we actually have). DAV-created locks can be lifted from the web UI.L8 — UI. Row menu Lock/Unlock (permission-aware), the existing
data-t="lock"chip binds with "Locked by X" title, refused writes surface the 423 message as a toast, listing enrichment gainslocked/lockOwnerbeside shared/hold (in-memory lookups in the existing pass). i18n ×4, en-GB.L9 — Audit. lock, unlock, and break-lock all written to the audit log.
L10 — Future, designed-for but not built. (a)
applocks for the co-editing epic. (b) Nikola's space-owner extension: an instance setting ("Space owners may lock folders in their spaces", off by default) with an admin-dashboard row and a proper space-owner UX for locking folders/subtrees — folder-lock semantics (ancestor checks, rename rules, DAV depth-infinity) designed when that ships.Testing: store grant/deny/persistence/expiry; guard verb × identity matrix incl. trash path and lock-follows-rename; DAV grant/refresh/conflict/UNLOCK-validation/PUT-423; API permission matrix incl. space-owner; mutation check on the guard predicate.
All three parts are now shipped:
internal/storage/filelock(statestore-backedlocks.json+ guard decorator between trash and ownermeta),storage.ErrLocked→ 423,POST/DELETE /api/v1/lockwith holder/admin/space-owner unlock andlock/unlock/break-lockaudit events,locked/lockOwnerlisting enrichment, real WebDAV LOCK/UNLOCK (tokens, Timeout 30s–1h, refresh,no-conflicting-lock/lock-token-submittedpreconditions, activelock in PROPFIND, no downgrade of a manual lock by a DAV LOCK), and the UI (row-menu Lock/Unlock on files, "Locked" chip with holder tooltip, toasts, i18n ×4).Deployed to both dogfoods.
Deferred, on record: L4's admin-configurable expiry cap for user locks (needs a settings field + admin row — currently user locks are simply indefinite); the space-owner folder-locking instance setting (L2 note); permission-aware hiding of the Unlock menu entry (server enforces the permission matrix; the client always shows Unlock on a locked row and surfaces the 403). App-type locks remain reserved for the co-editing epic (L10).
Closing.