Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
130e4f3
wip(objectql): sealed-object expiry seam beside the reap guard (ADR-0…
claude Nov 26, 2026
32555e5
feat(plugin-audit): expire sealed rows by whole checkpoints under sig…
claude Nov 26, 2026
3e6fc7a
test(plugin-audit): sealed expiry pins and the S4 verifier arm (WIP)
claude Nov 26, 2026
1854f11
test(plugin-audit): plugin registration pins; docs and changeset for …
claude Nov 26, 2026
51ba1c1
test: adjust gates and cli audit verify pins to the sys_audit_log sea…
claude Nov 26, 2026
9177bc8
docs: production readiness names the sealed audit log and its global …
claude Nov 26, 2026
5860216
fix(plugin-audit): pass --sealer-stopped in the SQLite audit-migrate …
claude Nov 26, 2026
4deab94
test(cli): pay the preview-read-only fixture's dynamic imports at mod…
claude Nov 26, 2026
46e272e
fix(plugin-audit): admit every checkpoint a resumed expiry deletes; a…
claude Nov 26, 2026
48e81f3
fix(plugin-audit): address review 7202871622 on the sealed expiry
claude Nov 26, 2026
c05884d
test(dogfood): pass --sealer-stopped to the SQLite os migrate audit-*…
claude Nov 26, 2026
65a5d7d
fix(plugin-audit): address review 7205485052 on the sealed expiry
claude Nov 26, 2026
71bb12a
feat(plugin-audit): on a sealed object, a retention override cannot s…
claude Nov 27, 2026
05e6a57
fix(lifecycle): signed expiry covers objects declared in packaged met…
claude Nov 27, 2026
ff14eb2
fix(audit): signed expiry only on a positive packaged-metadata answer…
claude Nov 27, 2026
2a45517
test(audit): state the signed-expiry scope rule in two test comments
claude Nov 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .changeset/31908-p4c-sealed-expiry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
'@objectstack/plugin-audit': minor
'@objectstack/objectql': minor
'@objectstack/verify': minor
'@objectstack/spec': minor
---

feat(plugin-audit): the audit log is sealed by default, and sealed rows expire by whole checkpoints under a signed expiry amendment

Clause-②: yes (narrowing) — narrowed: because `sys_audit_log` now declares `lifecycle.seal` on every deployment, `os migrate audit-key-material`, `audit-mail-bodies`, `audit-metadata-bodies` and `audit-side-copies` with `--apply` refuse on SQLite or Turso without `--sealer-stopped`, and on Postgres or MySQL take the audit seal lock and refuse when a sealer pass still holds it after ten minutes, where 18.6.0 ran them unlocked on a deployment that sealed nothing; `os audit verify` exits 1 on a row in a window at or before the newest window a trusted `window` checkpoint names that no checkpoint holds (`late`, unsealed), where it read the window unsealed and exited 0; `os audit verify` refuses with `archive_not_connected` and exits 2 wherever the `archive` datasource is declared and not connected on its own boot, where 18.6.0 printed that nothing is sealed and exited 0; `verifyAuditLedger` throws for `sys_audit_log` when the `archive` datasource it archives to is not connected and no `archive` is passed; and on an object whose packaged metadata declares `lifecycle.seal` and no `archive`, a `lifecycle` settings override of `retention.maxAge` or `ttl.expireAfter` below the declared window, global or for one organization, is rejected and reported at `error`, and the declared window applies, where 18.6.0 applied it. An object created at runtime is outside the override arm and outside signed expiry: it keeps the 18.6.0 row-cutoff retention sweep, and a settings override applies to it; the `os audit verify` arms hold for it as for any sealed object. This breaks the bound changeset `35c9a30` (#33675) set, "No object declares `lifecycle.seal` by default, so a deployment that did not opt in sees no change": this release is the one that opts every deployment in. Widened: `@objectstack/objectql` `LifecycleService.registerExpiryPrefix` and the types `LifecycleExpiryPrefix`, `LifecycleExpiryPrefixRequest` (with its `tenants` windows and `tenantColumn`), `LifecycleExpiryPrefixRun`, the predicate `takesSignedExpiry` with its type `SignedExpiryRegistryLike`, and three optional owner reads on `LifecycleEngineLike.registry`; a sweep entry's `policy` gains `'expiry'` and `skipped[].reason` gains `seal-expiry-pending` and `seal-delete-unsupported`.
Metadata-protocol: semantic — on an object whose packaged metadata declares `lifecycle.seal`, the authored `retention.maxAge`, `ttl.expireAfter` and `archive.keep` no longer delete a row at its row cutoff: rows leave by whole checkpoints under a signed expiry amendment, counted to the start of a UTC day, at most 10,000 a sweep, and not at all while no sealer runs; an object created at runtime keeps its row cutoff
Skills-docs: follow-up owed — this claim's second PR (amendment 7193137455) rewrites `skills/objectstack-data/rules/lifecycle.md`, which still says the sweeper deletes sealed rows

<!-- adr-0087: not-required (no-migration-prescription) No schema key, accepted value or metadata type is added, removed or renamed, and nothing stored is rewritten: the moved answers are whether an os migrate audit-* --apply run may proceed while a sealer could be sealing sys_audit_log, how os audit verify reads a lagging chain, and when a sealed row may be deleted. A declaration keeps its meaning as a lower bound, so no author's declaration needs rewriting. The one-line fix for each is in the body. -->

**BREAKING** for operators and library callers, because the audit log is now sealed on every deployment:

- **`os migrate audit-* --apply` on SQLite or Turso** stops before writing and names the flag. Fix: stop every server that seals the database, then run it again with `--sealer-stopped`.
- **The same run on Postgres or MySQL** waits up to ten minutes for a sealer pass in flight, then refuses having changed nothing. Fix: run it again once that pass has finished.
- **`os audit verify` exits 1** on a row it reads `late` and unsealed in a window another chain of the object already sealed. Fix: none is owed by the command; read the rows the report names (a chain a fault left behind), and run it again after the sealer's next pass.
- **`os audit verify` exits 2** (`archive_not_connected`) where the `archive` datasource is declared and the command's boot does not connect it. Fix: declare the datasource with `autoConnect: true`, or make it reachable from where the command runs.
- **`verifyAuditLedger`** (`@objectstack/plugin-audit`) throws for `sys_audit_log` when its `archive` datasource is not connected. Fix: pass `archive`, for example `archive: () => 'none'` where the deployment has no archive datasource.
- **On a sealed object with no `archive` whose lifecycle is declared in packaged metadata, a retention override cannot shorten the declared window.** An override below it is rejected at every sweep, reported at `error` (`floorViolations` on the sweep report), and the declared window applies. On an object that archives, an override still sets when rows move to the archive. Fix: remove the override or raise it to at least the declared window; to keep rows for less time, shorten the window the object declares.

Every dry run is unchanged. A deployment's own objects that do not declare `lifecycle.seal` keep the row-cutoff retention they had.

ADR-0154 D8 and D10 (#31908, slice P4c, the last one).

- **`sys_audit_log` is sealed.** Its lifecycle declares `seal: { valueFields: ['old_value', 'new_value', 'metadata'] }`, so every deployment whose `AuditPlugin` has a crypto provider (`os serve` hands it one) signs each hour's audit rows into a per-organization checkpoint, and `os audit verify` checks them. The three value columns enter each checkpoint as salted commitments; every other column enters in clear.
- **Sealed rows leave only by whole checkpoints.** Signed expiry covers objects whose lifecycle is declared in packaged metadata; an object created at runtime keeps the 18.6.0 row-cutoff retention sweep, its rows then reading as missing. Extending signed expiry to runtime-created objects is a separate card. The LifecycleService no longer deletes a row of a sealed object whose lifecycle is declared in packaged metadata by a row cutoff (`retention.maxAge`, `ttl.expireAfter`, or the archive's `keep` prune). It hands each policy to the sealed expiry the audit sealer registers (`LifecycleService.registerExpiryPrefix`, `@objectstack/objectql`). Per chain, the sealer takes the consecutive checkpoints from the chain's first remaining one whose windows ended before the cutoff (aligned down to a UTC day, so once its backlog is drained a chain gains at most one expiry amendment a day), each admitted under a trusted signing key, at most 10,000 rows a sweep. It signs and stores the chain's `expiry` amendment first. The sweep then deletes exactly those rows, by id, from the hot store and the archive, and only after them the checkpoints and their seeds. A sweep stopped part way resumes under the stored amendment and signs no second one. A run a reap guard vetoes in part is not completed and is retried. The verifier reads an expired row as `expired` while its checkpoint stands, and after it is gone honours the range as before (D8).
- **`os migrate audit-* --apply` on SQLite or Turso now needs `--sealer-stopped` for the audit log.** The rule 18.6.0 set for a sealed object now holds on every deployment, since `sys_audit_log` is one: stop every server that seals the database, then run with the flag. That includes the `os migrate audit-side-copies --apply` an upgrade from 18.4.0 or earlier runs. Postgres and MySQL take the audit seal lock, and a dry run is unchanged.
- **No sealer, no deletion.** While no sealed expiry is registered (an `AuditPlugin` with no crypto provider, a one-shot boot), a sealed object's rows past their policy are kept, the archive copy still runs, the sweep reports `seal-expiry-pending`, and the lifecycle service says so once at `warn`; such a host keeps `sys_audit_log` past `archive.keep`, and its sealer reports the missing provider hourly at `error`. An archive store with no `bulkDelete` is never planned (`seal-delete-unsupported`), so no amendment is signed over rows it could not delete. A chain whose first remaining checkpoint does not follow its last expiry (a checkpoint removed outside the platform), or whose next checkpoint does not verify under a trusted key, is not expired past that point, and the sealer says so. An expiry acts only on the chain's own checkpoints and amendments, linked in order; a stopped expiry is resumed only over checkpoints that also each verify under a trusted key and run on to the amendment's last sequence and digest; otherwise nothing in its range is deleted, and the sealer says so. The verifier holds an expiry it honours to the same. An expiry deletes rows for good: a deleted row cannot be restored from the ledger.
- **On a sealed object with no `archive`, a retention override cannot shorten the declared window.** `AuditPlugin` registers a retention floor (the mechanism the job queue uses for its idempotency window) for every object whose packaged metadata declares `lifecycle.seal` and no `archive`, at its declared `retention.maxAge` and `ttl.expireAfter`, refreshed before every sealer pass so it follows the declaration. An override, global or for one organization, may lengthen the window; one below it is rejected and the declared window applies. `archive.keep` takes no override. A lifecycle service that takes a sealed expiry but no retention floors is given no expiry, so its sealed rows are kept, and the plugin says so at `error`.
- **A tenant-scoped retention override applies to its organization's chain where it is set on the chain column.** Tenant windows are set on the object's `organization_id` column, so this holds on an object chained by it (`seal.chainField: 'organization_id'`). The lifecycle service hands each tenant's window, through the same floors, to the sealed expiry (`LifecycleExpiryPrefixRequest.tenants`), with the column the windows are set on (`LifecycleExpiryPrefixRequest.tenantColumn`). Where that is the object's chain column, an organization's chain expires under its own window and its amendment signs that value. Every other chain expires under the longest window configured: the chain of rows about no organization, and every chain of an object whose windows are set on another column than its chain column, which may hold rows of several organizations. On such an object a shorter tenant window has no effect on its sealed rows: they are kept to the longest. No row expires under a window shorter than one set for it.
- **A fully expired chain continues.** Its next checkpoint chains onto the expiry: sequence after the expiry's last, linked to its `last_removed_digest`.
- **`os audit verify` stays loud for a chain a fault left behind** (seat ruling 6885452378, ADR-0154 D3 as amended): a window that starts at or before the newest window a trusted `window` checkpoint names is sealed, so a row there that no checkpoint holds reads `late` and unsealed, and the check fails.
- **The verify harness hands its crypto provider to `AuditPlugin`.** `bootStack` gives an `AuditPlugin` it mounts (an `extraPlugins` entry, a stack `plugins` entry, or the provider `requires: ['audit']` constructs) the same `harnessCryptoProvider()` instance that settings and the engine get, never a bare `LocalCryptoProvider`; an instance composed with its own provider keeps it.
- The `lifecycle.seal` description no longer says the retention sweeper deletes sealed rows.
29 changes: 27 additions & 2 deletions content/docs/data-modeling/objects.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ lifecycle: {
}
```

The platform's own audit log, `sys_audit_log`, declares exactly this block, so
it is sealed on every deployment whose `AuditPlugin` has a crypto provider.

- Each hour of `created_at` is sealed ten minutes after it ends, per
organization (and once for rows about no organization): into one
checkpoint, or, when the hour holds more than 10,000 such rows, into
Expand Down Expand Up @@ -274,8 +277,30 @@ lifecycle: {
- Refused at parse time beside `seal`: a `class` other than `audit`,
`retention.onlyWhen`, `ttl.onlyWhen`, a `ttl` on a field other than
`created_at`, and rotation `storage`. Each deletes part of a sealed hour.
Until expiry amendments ship (ADR-0154 P4), the retention sweeper still
deletes sealed rows, which then read as missing.
Signed expiry covers objects whose lifecycle is declared in packaged
metadata. Their sealed rows past their `retention`, `ttl` or `archive.keep`
window leave only by whole checkpoints: the sealer first writes a signed expiry
amendment naming them, so the verifier reads them as `expired` rather than
missing. The window is counted to the start of a UTC day, so a row can stay
up to a day past it, and at most 10,000 such rows leave per object per sweep,
so a backlog drains over several sweeps; once it has, a chain gains at most
one expiry amendment a day. On such a packaged object with no `archive`, a
retention override cannot shorten the declared window: an override of
`retention.maxAge` or `ttl.expireAfter` in the `lifecycle` settings, global
or for one organization, may lengthen it, and one below the declared window
is rejected, reported at `error`, and the declared window applies. On an
object that archives, an override still sets when rows move to the archive,
and `archive.keep` takes no override. A tenant-scoped window is set on the
object's `organization_id` column, so it applies to that organization's
chain only on an object chained by that column
(`seal.chainField: 'organization_id'`). Every other chain keeps its rows to
the longest window configured: the chain of rows about no organization, and
every chain of an object chained by another column (the default
`tenant_id`), which may hold rows of several organizations. No row leaves
before the window set for it. While no sealer is running (no crypto
provider), the sweeper keeps them and says so once. On an object created at
runtime the retention sweeper still deletes sealed rows at their row cutoff,
which then read as missing, and a retention override applies to it.
- Sealing needs a crypto provider, which the host passes to `AuditPlugin` as
`cryptoProvider`. `os serve` passes the one it seals every secret with; an
app that puts its own `AuditPlugin` in `plugins` passes one itself. Without
Expand Down
10 changes: 10 additions & 0 deletions content/docs/deployment/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2378,6 +2378,16 @@ crypto provider `os serve` seals with is available.
ten minutes after it ends, and it can seal a row between the command's decision
and its write; that row then reads `modified`.

**The audit seal lock.** An `--apply` run holds the audit seal lock from before
its first write to after its last, archive runs included, on the database of
each object it covers that declares `lifecycle.seal`. `sys_audit_log` declares
it, so this is every run that covers the audit log. On Postgres and MySQL the
run waits up to ten minutes for a sealer pass in flight, then refuses having
changed nothing: run it again once that pass has finished. On SQLite and Turso,
which offer no session lock, the run stops before writing and names
`--sealer-stopped`: stop every server that seals the database, then run it again
with the flag. A dry run takes no lock and needs no flag.

#### `os migrate organization-ownership`

The v18 ownership ceremony (ADR-0131 D10), and the upgrade path of a database
Expand Down
7 changes: 5 additions & 2 deletions content/docs/deployment/production-readiness.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ and per-class budgets:
the `lifecycle.retention_overrides` setting **before** go-live if your
compliance regime needs longer, and register an `archive` datasource
if audit data must move to cold storage instead of being retained hot.
The sealed audit log expires by whole checkpoints under its global
window: a tenant-scoped override does not change it.

## CDN / reverse-proxy caching of `/meta` object schemas

Expand Down Expand Up @@ -282,5 +284,6 @@ strongly, so a layer that weakens it to `W/` makes those saves fail.
recipe, not the endpoint, because TLS / auth / path conventions vary.
- **A built-in audit log immutability layer.** `@objectstack/plugin-audit`
writes `sys_audit_log` records via ObjectQL afterInsert/afterUpdate/afterDelete
hooks; durable storage and tamper-evidence are the host's choice
(append-only S3, immudb, etc.).
hooks and seals them (ADR-0154), so a change or delete made outside the
platform shows in `os audit verify`. Sealing detects; it does not prevent:
write-once storage is the host's choice (append-only S3, immudb, etc.).
Loading
Loading