iz
Clone
0 watching0 forksRustAGPL-3.0567.3 KiB3950aceTahinli27 days ago34 commits
iz architecture
iz is the family's task board: columns, cards with one level of subtasks, dependencies, assignees,
projects (tags), deadlines with meeting times and reminders, comments, attachments with in-page viewers
(images, media, PDF, spreadsheets, slides), an activity trail, and admin-defined mail rules with a durable
outbox. Read docs/contracts.md and docs/conventions.md first.
Status: design for the rebuild. ~/Documents/Code/Rust/old_iz is a feature reference only.
docs/reference/old-inventory.md is the parity checklist (sections 2, 5, 8, 11) and its section 9 lists ~65
defects that must not be carried over.
1. Goals
- Feature parity with old iz (inventory sections 2 and 11 "rebuild-critical rules").
- Better than old iz: CSRF everywhere; local sessions and back-channel logout instead of per-request
introspection; avatars scoped to members; every write that has several steps is one transaction (card +
links + assignees created atomically); real IANA time zones (DST-correct reminders); server-side length
limits on every text field; sign-out button; security headers and CSP; every page and every mail translated;
retention for activity and mail ledger;
/healthzchecks the DB.
Not goals now (docs/backlog.md): inbound mail / reply-by-mail, several boards or workspaces, custom fields,
time tracking, Gantt views, editing spreadsheets or slides.
2. Crates and modules
iz/
crates/
iz-core/ domain, store, migrations, config, secret, token, time + zones, authz, board rules, mail rule engine, sniff, sheet/slides readers
iz-web/ binary `iz`: pages, OIDC client, directory mirror, attachments (local or in), SMTP worker, reminders, live, CLI
iz-core
error.rs,time.rs,zones.rs(jiffwith the bundled tz database: parse an IANA zone, local ↔ UTC),config.rs,settings.rs,secret.rs,token.rsauthz.rs(section 6),limits.rs(every text and size limit as a named constant)board.rs(pure rules: overdue, done/blocked, key generation, ordering positions, cycle detection),clock.rs(deadline + meeting time rules, inventory 2.4)rules/(mail rule engine: triggers, audiences, decisions; pure where possible),mail_text.rs(subjects and bodies for every mail kind, both languages)sniff.rs,sheet.rs(calamine: xlsx only; values only;.odsand.xlsbare refused, not previewed; paging 50 rows × 12 columns; correct offsets for ranges not starting at A1),slides.rs(pptx text outline viazip+quick-xml, size and entry limits against zip bombs)store/:members.rs,sessions.rs,board.rs,tasks.rs,deps.rs,comments.rs,attachments.rs,activity.rs,tags.rs,rules.rs,outbox.rs,reminders.rs,audit.rs,settings.rs,snapshot.rs,migrate.rs
iz-web
main.rs,boot.rs,state.rs,admin_cli.rs,auth.rs,throttle.rs,client_ip.rsoidc/(same client asin, contracts.md 2),directory.rs,family.rs,avatar.rsfiles/(local.rs,in_store.rs= client of contracts.md 5 with a cached client-credentials token,serve.rs= Range, disposition, byte headers likein's architecture section 7)pages/(board.rs,task.rs(task modal and its tabs),new_task.rs,people.rs,tags.rs,rules.rs,logs.rs,settings.rs,viewer.rs)mail/(SMTP vialettre, outbox worker with lease, batching, retries),reminders.rs(worker),live.rs,audit.rs,views/,i18n/,assets.rsassets/nav.js,assets/board.js(drag and drop, card menu, filters with debounce, date and time picker, dropdowns, file drop zone, escape-key stack),assets/player.js,assets/offline.html,assets/sw.js
3. Data model
One workspace and one board per instance (as in old iz). Tables keep a board_id so a second board is a
feature, not a migration.
members (mirror of im's directory plus iz state)
subPK,email,name,im_admin,disabled,locale,zoneinfo(IANA),picture_version,im_updated_atroleTEXT NOT NULL CHECK IN ('admin','member','viewer','none') —none= in the directory but no access;im_adminalways acts asadminthemeCHECK IN ('system','light','dark'),uiCHECK IN ('instrument','ledger'),locale_overrideNULLfirst_seen_at,last_sign_in_atNULL- New directory members get the role in setting
default_role(defaultmember). Adding someone who is not inimhappens inim(invite); iz only assigns roles.
sessions, seen_logout_jti: as in in.
boards: id, name, key_prefix (2–6 uppercase letters, setting; default IZ), created_at.
columns: id, board_id, name (1–60), position INTEGER, is_done 0/1; exactly one done column per
board (partial unique index). Admin can add, rename, reorder, delete (only when empty) columns.
tags (projects): id, board_id, name (1–60, unique per board, case-insensitive), position, is_default
(one per board), color NULL (from a fixed palette).
tasks: id, board_id, key (UNIQUE per board, PREFIX-<n> from a per-board counter: readable and never
reused), parent_id NULL (one level, enforced by trigger and by store), title (1–200), description (≤20 000),
column_id, tag_id NOT NULL, deadline NULL (date), meeting_at NULL (UTC instant), position REAL (the Manual order, section 5),
created_by, created_at, updated_at, done_at NULL, deleted_at NULL.
task_assignees (task, sub) PK. task_watchers (task, sub) PK — watchers receive "board" audience mail
for that task only if they opted in (used by the rules engine's watchers audience).
dependencies: blocked_id, blocking_id, created_at, cleared_at NULL; PK (blocked, blocking);
CHECK blocked ≠ blocking. Cycle check over live, uncleared edges inside the same transaction as the insert.
comments: id, task_id, author, body (1–10 000), created_at, edited_at NULL, deleted_at NULL.
Authors may edit and delete their own comments (new: old iz had neither).
attachments: id, task_id, comment_id NULL, name, mime (sniffed), size, sha256, uploaded_by,
created_at, location CHECK IN ('local','in','moving'). local = bytes in data_dir/attachments/<2 hex>/<id>;
in = bytes are object <id> in in's store; moving = being copied between the two.
transitions: id, task_id, from_column NULL, to_column, actor, at.
activity: id, task_id NULL, actor NULL (NULL = system), subject NULL, kind (enum with CHECK; migration
0007 added task_reordered and task_restored), detail JSON, at. Rendered into sentences in the viewer's
language at read time.
mail_rules: id, board_id, name, trigger (enum CHECK, 12 triggers from inventory 2.9), column_id
NULL (only for status, CHECK), tag_id NULL (new: limit a rule to one project), audience CHECK IN
('assignees','board','creator','watchers'), include_details, enabled, subject_template (≤120), created_at.
mail_outbox: as old iz mail_send (inventory 4) with kind CHECK IN ('rule','notice','reminder','test'),
lease, attempts, backoff, batching window, unique (rule_id, event_id, task_id, recipient). mail_decisions:
as old iz. Recipients are always active members with role ≠ viewer/none, never disabled.
reminders: task_id, sub, due_at, sent_at NULL; PK (task_id, sub). Rebuilt for a task in the same
transaction as any change to its meeting time, assignees, done state or deletion.
audit_log: append-only; rows older than 365 days (AUDIT_RETENTION_DAYS, iz-core/src/store/audit.rs) are deleted by
the sweeper in batches of 500, one statement each, so the writer is never held for a long purge. settings: per
conventions. Settings: SMTP sender (password sealed), limits, batching window,
reminder minutes (0–1440), allowed attachment types, attachment limit (1–500 MiB), attachment location
(local|in), default_role, key_prefix, retention days for activity and mail ledger (default 365),
base URL.
4. Routes
Pages (session; Viewer may read, writes need Member, admin pages need Admin; all forms CSRF):
| Path | What |
|---|---|
GET / |
board (inventory 2.2): columns, cards, filters (tag, assignee, sort = manual (default), deadline, created or title, q), overdue/blocked chips, card menus, drag and drop; ?task=<key> opens the task modal, ?new=1 the new-task modal |
POST /tasks, /tasks/{id}/edit, /tasks/{id}/move, /tasks/{id}/delete, /tasks/{id}/assign, /tasks/{id}/unassign, /tasks/{id}/tag, /tasks/{id}/parent, /tasks/{id}/links, /tasks/{id}/links/remove, /tasks/{id}/watch |
task writes |
POST /tasks/{id}/comments, /comments/{id}/edit, /comments/{id}/delete |
comments |
POST /tasks/{id}/files (multipart, streamed), /files/{id}/delete; GET /files/{id} |
attachments |
GET /tasks/{key}/files/{id}/view (also inside the modal via ?file=) |
viewers: image, video, audio, PDF, sheet, slides |
GET /people/{sub} |
person card with counts and recent activity (members only, same board) |
GET /tags + POSTs |
projects (admin) |
GET /columns + POSTs |
columns (admin) |
GET /rules + POSTs |
mail rules (admin), sentence rendering, enable switch, edit |
GET /logs |
admin: outbox (retry), decisions, activity (filters, keyset paging) |
GET /settings + POSTs |
profile/preferences (all); members & roles (an im administrator's role is shown, not offered for change), sender (check, test), limits, attachment storage (+ migration status), message to members, server (admin); POST /settings/backup "Back up now" (admin, CSRF, audited, 303 back with a notice, 422 with an alert when [backup] is off); the Backups card shows the recorded outcome of the runs (section 8); the Recently deleted card lists tasks deleted in the last 30 days (title, key, when, who) with POST /settings/deleted/{id}/restore (admin, CSRF, audited as task.restore, activity task_restored; section 5) |
GET /avatar/{sub} |
photo proxy with disk cache, only for members of this board |
OIDC client routes, /-/alive, live streams, /healthz, /assets/* |
POST /tasks/{id}/move carries the column the client last saw, the sort the board showed and, for a drop, the
place (position). A stale move is refused (moved_already), a move into the done column with open subtasks is
refused (subtasks_open), as in old iz. The place is used only under sort=manual: then a drop in the same column
is a reorder (Reordered, activity task_reordered), and a drop in another column lands at the place. Under any
other sort the place is ignored: a card moved to another column goes to the end of it, and a drop within its own
column changes nothing.
5. Rules (from inventory section 11, kept exactly)
- Overdue: done is never overdue; with a meeting time, overdue when the meeting time ≤ now; with a day only, overdue when the day is before today in the viewer's zone.
- Done: entering the done column stamps
done_at; leaving it clears it; a card with open subtasks cannot enter. - Subtasks: one level; a parent with children cannot become a subtask; deleting a parent deletes its children.
- Order: the default sort is Manual (
position, then id). Each column's cards take theirpositionfrom the neighbours they are placed between; a column is renumbered (1, 2, 3, ...) only when two neighbours are less than 1e-9 apart. Under deadline, created or title the only drag is to another column, which lands at its end. - Restore: a deleted task can be restored for 30 days after its deletion (
RESTORE_DAYS); there is no purge, so older deletions are final. One transaction clearsdeleted_aton the task and on the subtasks that share its deletion stamp. A task whose column was retired goes to the first column that is not done (and losesdone_atthere). A subtask whose parent is still deleted is refused. Reminders are rebuilt. Links cleared by the deletion and the files of the task (removed with it) do not come back. Only administrators (Administer). - Dependencies: no cycles over live edges; soft clear; a finished blocker stops blocking; deleting a blocker
frees its dependents and fires
unblocked. - Viewers: read-only, never assigned, never mailed. Members with role
noneor disabled: no access, not mailed. - Mail: per-recipient claim by unique key; 5 attempts with 5/10/20/40-minute backoff, then abandoned; 1-minute
hold without a sender (no attempt spent); 5-minute lease; batching window per settings with a ceiling of 4
windows; a decision row for every verdict; the actor of an event is not mailed about it (setting
mail_actor, default off). - Reminders: one per assignee,
reminder_minutesbefore the meeting time, in the recipient's zone in the text; rebuilt on every relevant change; none for past meetings.
6. Authorization
authz::authorize(actor, action) with actor = Anonymous | Member { sub, role, im_admin, disabled } and
action from: ReadBoard, WriteTask, Comment, EditComment { author }, UploadFile,
DeleteFile { uploader }, Administer, ViewPerson { sub }. Roles: Admin ⊇ Member ⊇ Viewer. An im
administrator (im_admin) acts as Admin whatever the stored role is, none included; the store applies the same
rule in its own queries (sessions, assignees, reminders, mail recipients) and the members page does not offer
their role for change (a forged change is refused too). A disabled account is denied everything (404 for pages,
the sign-in card for /), and so is a member with role none who is not an im administrator. Deleting a file:
uploader while still a Member, or Admin. Truth-table tested.
7. Attachments
- Limits: per-file limit and allowed extensions from settings; MIME from sniffing; streamed to a temp file with the limit enforced while reading; hashed while streaming.
location = local: bytes indata_dir/attachments.location = in: after the local write commits, thefilesworker PUTs toin(contracts.md 5, external id = attachment id) and flips the row toin, then deletes the local copy. Reads stream from wherever the row says; ifinis unreachable the response is a translated 503 page, and local bytes are still served for rows not yet moved.- Switching the setting starts a background migration in either direction, with progress on the settings page.
- Deleting: row deleted in a transaction that records the blob for deletion; the worker deletes the bytes
(local or
in) afterwards and retries until done.
8. Workers
directory mirror, family list, mail outbox, reminders, attachment mover, sweeper (sessions, JTIs, retention of
activity and mail ledger, audit rows past AUDIT_RETENTION_DAYS = 365 in batches of 500, orphaned temp files), optional backup. The backup worker is also woken by "Back up now" on the settings page:
BackupTrigger on AppState holds an atomic busy flag (set by a request or a scheduled run, cleared when the run ends)
and a Notify. At most one run is pending or running; a request made meanwhile starts nothing. All stop with the stop flag.
The backup worker wakes every minute. A scheduled run is due when no backup_last_attempt is recorded or the last
attempt is at least interval_hours old (backup::is_due); the attempt is recorded before the set is written, so a
restart does not reset the timer and a failing run waits for the next interval. A "Back up now" request runs at once.
Every backup run, scheduled or requested, records its outcome in settings: backup_last_attempt (when the run
started), backup_last_success (when a set was published; never cleared) and backup_last_error (a short text,
empty after a success). The error text names the kind of failure and never a path or a database message. The
Backups card on the settings page shows the last success and attempt in the viewer's zone, the error of a failed
latest attempt in an alert, and a warning when backups are on and no success is within two days. /healthz does
not report backups.
9. Live
Topics: Board(board_id) (any card change, columns, tags), Task(task_id) (modal contents), Person(sub),
Admin(Section) (outbox, decisions, activity, settings, members), Account(sub) (preferences, revocation).
Board page fingerprint is cheap (max updated_at + counts), so a burst of changes is one refresh.
10. CLI
iz (or iz serve) runs the server. iz export --out DIR writes the board as JSON with its attachments and a
manifest, and never writes outside DIR. iz restore --from SET verifies a backup set (manifest, digests, the
database's integrity_check and contiguous migrations) before it replaces the database and attachments in the
configured data directory, and keeps the files it replaces. iz fsck checks the database and the attachment bytes
read-only. Every command except export refuses while a server holds data_dir/iz.lock. Backups are written by
the [backup] worker (VACUUM INTO plus attachment copies, manifest.json and manifest.mac, see iz_core::manifest).
A set's manifest is authenticated: manifest.mac is the HMAC-SHA256 of the exact bytes of manifest.json, keyed by
HMAC-SHA256(iz.key, "iz backup manifest v1"). verify_set checks the MAC in constant time before it parses the
manifest or reads a listed file, so a set changed in place (file and manifest together) is refused. export writes
the same pair, and restore and export need the existing iz.key (they never create one). A set written before
the MAC existed is refused.
11. Build order
- Scaffold (workspace, core basics, store + 0001, boot, healthz, assets, shell, nav.js, i18n, headers, 404).
- OIDC client, sessions, back-channel logout, members mirror, roles, avatars, switcher.
- Board: columns, tags, tasks, keys, ordering, move rules, filters, search, drag and drop.
- Task modal: fields, deadline and meeting time, assignees, subtasks, dependencies, comments, activity, delete.
- Attachments (local), viewers (image, media, PDF, sheet, slides), then
instorage and migration. - Mail: sender settings, outbox worker, rules engine and pages, notices, reminders, logs page.
- Admin pages (members, tags, columns, limits, server), audit, live topics, sweeper, backup, export, deploy unit, README.