Skip to content
Loom Docs
Esc
↑↓navigate↵open⌘Jpreview
Product
View as Markdown
On this page

Stewardship

Stewardship records who answers for a shared memory and how often it is reviewed.

Stewardship records who answers for a shared memory and how often it is reviewed. A namespace admin names a steward with stewardship.assign, and every viewer of the namespace reads who maintains what with stewardship.list and stewardship.get. This page covers the table, how a state is derived, what erasure removes and the rolling-upgrade rule. The caller’s side is in history and provenance.

A state describes attention, never truth. No read, rank, expiry, pin or authorization path reads a stewardship row or imports the modules that derive a state (tests/unit/test_stewardship_is_contained.py), so an overdue memory is served and ranked exactly as a current one.

The row

loom.stewardship_events is an append-only MergeTree sorted by (org, namespace, target_kind, target_key, agent, at). Each row is one event of one target:

Column Holds
target_kind, target_key, agent The target: a memory the namespace shares, or the namespace itself.
at When the row was written, to the millisecond.
event assign or review.
steward, review_every_days An assign row: who answers, and the review interval in days.
result, sha256, target_version A review row: the verdict, and the content hash and version it read.
actor Who wrote the row, as the server labels every writer.

A memory target is the row (agent, target_key) whose user_id and session_id are -: only a row the whole namespace reads takes a steward. The namespace target has no key and is stored under the agent -, whatever agent a call carries; its steward is the fallback for every item whose own steward cannot act.

The row departs from the identity tuple in two ways, both on purpose:

  • No user_id and no session_id. A target is a shared row, which has neither, and an assignment is made for the namespace, not for one end user or session.
  • No source_class. A row is an administrative act of its actor, not memory content that entered through a write path, so there is no provenance to downgrade.

The newest assign row of a target is its steward and interval, and the newest review row is its last review. Nothing is updated in place outside erasure, so no read uses FINAL. A write of a call that read an earlier row is stamped after it: one millisecond past the target’s newest row when the clock is not past it (next_at in server/memory/domain/stewardship.py), so the later write wins on every replica. Two calls at once can stamp the same millisecond; both statements order such rows by their other columns, so rows of one millisecond read the same on every call. The insert is synchronous, and every statement on the table runs with sequential consistency (own_write_reads), so a list on one replica reads an assignment another replica just wrote.

How a state is derived

Nothing about a state is stored. Each read derives it from the target’s newest assignment and review, the memory’s live head, the steward’s direct grant, the revocation list, the org’s groups and the clock (state_of, steward_problem in server/memory/domain/stewardship.py). An interval change, a revoked grant and an edited memory therefore show on the next call.

The live head comes from live_revisions, the read memory.get serves its hash from, with the whole namespace as its scope (stewardship_heads in server/memory/app/stewardship.py). A head is reviewable when the row is live, shared, served by the namespace, not of high sensitivity and at most 16,384 bytes. Under the Postgres memory authority the read waits until ClickHouse holds what was committed.

The first rule that holds is the state:

State Holds when
missing The memory has no reviewable head.
never_reviewed The target has no review.
out_of_date The newest review read other content than the live head.
correction_requested The newest review asked for a correction.
needs_evidence The newest review asked for evidence.
overdue The newest review confirmed the content, and the interval has passed.
due The interval passes within 14 days.
current None of the above.

No operation records a review, so an item under stewardship reads never_reviewed, or missing when its memory has no reviewable head.

A problem says why the named steward cannot act, apart from the state:

Problem Holds when
unassigned The item has no steward.
steward_revoked The steward’s sign-in is revoked.
steward_no_grant The steward holds no direct grant of writer or above on the namespace.
group_inactive The steward is a group that no longer exists or has no member.

responsible is the account that should act: the steward when it is a person with no problem, else the namespace’s fallback steward when that one has none, else empty. An item whose stewardship ended names nobody: its steward’s standing is not read.

Assigning

stewardship.assign needs the admin role on the namespace, is audited, and appends a row only when the steward or the interval differs from the stored one; a repeat answers changed: false. A field the call leaves out keeps its stored value.

  • The steward is a Loom account or group:<id>. An account must hold a direct grant of writer or above on the namespace and be able to sign in; a role carried only by a token is not a grant (direct_roles in server/identity/app/direct_roles.py). A group must be live and have a member. The fallback steward is a person. Only a steward that differs from the stored one is checked, so an admin can change the interval of an item whose steward has a problem.
  • The interval is 30 to 730 days; 0 ends stewardship of the item and keeps its rows.
  • An item put under stewardship needs a reviewable head, and a namespace holds at most 500 such items. The ceiling is read and then written without a claim, so concurrent calls can pass it by a few; a list reads up to 1,000 rows and fails past that instead of serving a cut list as whole.

Two calls on one target at once each append a row, and the later one is the assignment. When each sends a different single field, the later row carries the stored value of the field it left out, so one of the two changes is lost.

Cost

A list derives every item of the namespace whatever its filters: one read of the namespace’s rows, the heads of its items, and one read of the namespace’s grants for every steward named. A steward with no grant under its own spelling also takes a cached read of the account’s other spellings. Apart from that read, the number of statements does not grow with the number of items. OP_BUDGETS_P99_MS in server/settings/catalog.py holds the budget of each op, and tests/integration/test_stewardship.py runs a list at the ceiling against it.

Erasure

loom.stewardship_events has a census row and two steps (server/erasure/store/census.py, server/erasure/store/steps_ledgers.py):

  • A namespace erasure deletes the namespace’s rows (stewardship.delete).
  • A user erasure blanks the user as steward and replaces the user as actor with <erased> (stewardship.scrub), in every spelling of the subject. An assignment made after the step can name the user again: the census counts that row, and a resumed saga runs the step again. The item stays under stewardship and reads unassigned.

A deleted or renamed memory keeps its stewardship rows: the item reads missing until an admin ends it. Loom deletes only what its writer asked to delete.

What fails closed

Condition Answer
A live replica predates the table, or the fleet is not read stewardship.assign answers 503 with a 30-second retry.
The steward’s grant is revoked or expired steward_no_grant on the next read, never a silent pass.
The steward cannot sign in steward_revoked on the next read.
A memory is revised while its head is read, twice 503 with a one-second retry, never a guessed state.
ClickHouse does not hold a committed write within the wait 503, never a state from a stale head.
The namespace holds more items than one list reads The list fails instead of serving a cut list.

Rolling upgrades

A build without the table has no erasure step for it. So stewardship.assign refuses while any live replica’s schema version is below the table’s migration, or no heartbeat has been read (require_fleet, STEWARDSHIP_MIGRATION); the two reads are served (rolling upgrades, rule 87). After a rollback, an erasure the older build runs leaves the rows; the rollback note says what to run again.

Source entry points

  • server/memory/domain/stewardship.py — the two vocabularies, the constants and the state function.
  • server/memory/app/stewardship.py — the three handlers, stewardship_heads, require_fleet.
  • server/memory/store/stewardship.py — every statement on the table.
  • server/identity/app/direct_roles.py — the direct grant of each subject.
  • server/erasure/store/steps_ledgers.py — delete_stewardship_by_namespace, scrub_stewardship_by_user.

Invariants

  • A state is derived on read and never stored.
  • No read, rank, expiry, pin or authorization path depends on a stewardship row.
  • A revoked or ungranted steward reads as a problem, never as current without one.
  • Every statement on the table binds its scope and runs with sequential consistency.

Last updated on

Was this page helpful?