diff --git a/.changeset/31908-p4b2-bounded-checkpoints.md b/.changeset/31908-p4b2-bounded-checkpoints.md new file mode 100644 index 00000000000..a59be52889b --- /dev/null +++ b/.changeset/31908-p4b2-bounded-checkpoints.md @@ -0,0 +1,21 @@ +--- +'@objectstack/plugin-audit': patch +--- + +fix(plugin-audit)!: the audit sealer seals a window into checkpoints of at most 10,000 rows each, `os audit verify` fails on a row two checkpoints list, and a pass bounds what it re-reads while a chain stays skipped + +Clause-②: yes (narrowing) — narrowed: `os audit verify` reports a row id that two checkpoints list as the new chain fault `listed_twice` and fails the run, where the 18.4.0 verifier accepted it, and the 18.4.0 sealer could write such a chain when two of its late sealings overlapped. Widened: the checkpoint's signed body gains two optional fields, `part_index` and `final_part`; `sys_audit_checkpoint` gains two nullable columns for them; and the exported `AuditChainFaultKind` union gains `listed_twice`. +Metadata-protocol: none +Skills-docs: follow-up #33773 — skills/objectstack-data/evals/objects-fields-relationships.json, skills/objectstack-data/rules/lifecycle.md — both still teach that the sealer signs each `created_at` hour into one checkpoint per organization, where this change cuts a window into checkpoints of at most 10,000 rows each (the eval's graded `expected_output`, and `lifecycle.md` § Sealing); the card also carries their older stale claim that no verifier exists, which `os audit verify` already contradicts. `skills/**` is changed only on a `domain:skills` PR, so this one does not edit them; `content/docs/data-modeling/objects.mdx` and `content/docs/deployment/cli.mdx` gain the parts, the new fault and what a removed checkpoint shows in this change. + + + +**BREAKING** for `os audit verify` on a chain that an 18.4.0 sealer wrote while two of its late sealings overlapped (two replicas with no cluster service, whose lock is in-process only, or a lease that lapsed). Such a chain lists one late row in two checkpoints. Verify now reports it as a `listed_twice` fault and fails, where it passed. No tolerance and no repair ships for it. A chain one sealer wrote at a time is not affected. + +**Bounded checkpoints (ADR-0154 D4, as amended 2026-11-14).** A chain's rows of one window now seal into consecutive checkpoints of at most 10,000 rows each, cut in `(created_at, id)` order, instead of one checkpoint however many rows the window holds. Each checkpoint has its own seed. Its signed body carries two new fields, `part_index` (from 0) and `final_part`, and `sys_audit_checkpoint` stores them in two new nullable columns. A pass that stops in the middle of a window resumes it on the next pass as further `window` checkpoints, never as `late` ones. Late rows split into checkpoints of at most 10,000 rows the same way. The work and memory of one checkpoint no longer grow with the window. A checkpoint written before this release has neither field. It still verifies, reads as one final part, and its chain goes on. `part_index` can skip a number, and a window can end with no final part: a part whose rows were all deleted or moved between the sealer's two reads of the window is not written. + +**`os audit verify`.** A row id that two checkpoints list is now a fault of the new kind `listed_twice`, and the run fails. The second listing holds nothing for that row. Verify does not check that a window's parts are continuous or that it ends in a final part. The chain links show a removed interior part, as a `gap` or a `link` fault. They do not show a removed newest part; that part's rows read as late and unsealed instead. + +**Skipped chains.** While a chain stays skipped by a chain-local fault, it holds back the sealed-through watermark, so each pass walked every window from there and re-read all of them. Now, while a chain is skipped, a pass walks at most 168 windows that seal nothing (one late horizon) and then stops. When it stops, the sealer says so at `error`, naming the skipped chains. Once no chain is skipped, the walk is not cut, so sealing catches up whether the chain's fault was fixed or the chain has nothing left to seal. + +**Upgrading is one way once this release writes a checkpoint.** An 18.4.0 reader does not know `part_index` and `final_part`. The 18.4.0 verifier drops them and then fails the signature of every checkpoint that carries them. An 18.4.0 sealer computes the chain head's digest without them, so the checkpoint it writes next is a `link` fault. Roll back to 18.4.0 only before this release seals its first checkpoint. A host's checkpoint sink receives the two fields in each body. diff --git a/content/docs/data-modeling/objects.mdx b/content/docs/data-modeling/objects.mdx index 2e950a76f66..9ac2f014c3e 100644 --- a/content/docs/data-modeling/objects.mdx +++ b/content/docs/data-modeling/objects.mdx @@ -222,9 +222,11 @@ lifecycle: { } ``` -- Each hour of `created_at` is sealed ten minutes after it ends: one - checkpoint per organization (and one for rows about no organization), - holding a Merkle root over the rows, signed with the deployment's Ed25519 +- 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 + consecutive checkpoints of at most 10,000 rows each. Each checkpoint holds a + Merkle root over its rows and is signed with the deployment's Ed25519 key. A row that arrives later in a sealed hour is sealed as a `late` checkpoint; rows that already exist when sealing starts are sealed oldest first, archived rows included. diff --git a/content/docs/deployment/cli.mdx b/content/docs/deployment/cli.mdx index 90709771860..ceafced3351 100644 --- a/content/docs/deployment/cli.mdx +++ b/content/docs/deployment/cli.mdx @@ -800,6 +800,12 @@ Each row a checkpoint lists reads as one of: A row in a sealed window that no checkpoint lists is reported `late` and **unsealed**: on the host alone it cannot be told from a forged insert. +A checkpoint removed from a chain shows as a gap in the chain's links, unless it was the +chain's newest: the links cannot see that one. Its rows then read `late` and unsealed +while their window still counts as sealed (another checkpoint of the object names that +window, or one's sealed-through passes it); otherwise the removal does not show. A row +that two checkpoints list is a fault of its own. + Trust comes only from the deployment's own signing key. A key is trusted only when its wrapped private half opens with the crypto provider `os serve` seals with (the declaring plugin's, or the existing data key from `OS_SECRET_KEY` or the persisted key file; this @@ -811,8 +817,9 @@ Exit codes: - **0**: every chain, link and signature verifies under a trusted key, and every row is `unmodified`, `late` (sealed), `redacted` or `expired`. Also 0 when nothing is sealed. -- **1**: a row is `modified`, `missing` or `late` and unsealed, or a link or signature - fails. The report names every row that is not `unmodified` and every fault. +- **1**: a row is `modified`, `missing` or `late` and unsealed, a link or signature + fails, or two checkpoints list the same row. The report names every row that is not + `unmodified` and every fault. - **2**: no verdict is given. The cause is one of these: a usage error, a stack that would not boot, a crypto provider that cannot open what is sealed, an archive datasource a sealed object declares that this run did not connect (every archived row would read diff --git a/packages/plugins/plugin-audit/src/audit-seal/audit-seal-core.test.ts b/packages/plugins/plugin-audit/src/audit-seal/audit-seal-core.test.ts index a30efe3d6f4..8ab1890e6c9 100644 --- a/packages/plugins/plugin-audit/src/audit-seal/audit-seal-core.test.ts +++ b/packages/plugins/plugin-audit/src/audit-seal/audit-seal-core.test.ts @@ -253,6 +253,8 @@ describe('signed bodies (D4, D7, D8)', () => { tenant_id: 'org_1', sequence: 3, kind: 'window', + part_index: 0, + final_part: true, window_start: '2026-11-10T04:00:00.000Z', window_end: '2026-11-10T05:00:00.000Z', sealed_through: '2026-11-10T05:00:00.000Z', @@ -279,6 +281,8 @@ describe('signed bodies (D4, D7, D8)', () => { window_end: '2026-11-10 05:00:00', sealed_at: Date.parse(body.sealed_at), fencing_token: 17, + part_index: '0', + final_part: 1, // a driver with no boolean column hands back 1 / 0 }; const back = checkpointBodyFromRow(driverRow); expect(back).toEqual(body); @@ -304,6 +308,8 @@ describe('signed bodies (D4, D7, D8)', () => { { ...body, tenant_id: 'org_2' }, { ...body, sealed_through: '2026-11-10T06:00:00.000Z' }, { ...body, seed_handle: 'sec_other' }, + { ...body, part_index: 1 }, + { ...body, final_part: false }, ]) { expect(checkpointDigest(checkpointBodyFromRow(changed))).not.toBe(digest); } @@ -323,6 +329,10 @@ describe('signed bodies (D4, D7, D8)', () => { { ...body, columns: { clear: ['id', 'created_at'], committed: [] } }, { ...body, columns: { clear: ['id'], committed: ['id'] } }, { ...body, fencing_token: '-1' }, + { ...body, part_index: -1 }, + { ...body, part_index: undefined }, + { ...body, final_part: undefined }, + { ...body, final_part: 'yes' }, ]) { expect(() => checkpointBodyFromRow(bad as unknown as Record), JSON.stringify(bad).slice(0, 80)).toThrow(SignedBodyError); } @@ -400,6 +410,8 @@ describe('the deployment chain signs a NULL organization (D5)', () => { tenant_id: null, sequence: 0, kind: 'window', + part_index: 0, + final_part: true, window_start: '2026-11-10T04:00:00.000Z', window_end: '2026-11-10T05:00:00.000Z', sealed_through: '2026-11-10T05:00:00.000Z', @@ -467,7 +479,7 @@ describe('a redaction names its checkpoint by the signed sequence (D7)', () => { it('declares one checkpoint column per stored field, the sequence a redaction refers to among them', () => { const body: CheckpointSignedBody = { - sealed_object: 'sys_audit_log', tenant_id: null, sequence: 0, kind: 'window', + sealed_object: 'sys_audit_log', tenant_id: null, sequence: 0, kind: 'window', part_index: 0, final_part: true, window_start: '2026-11-10T04:00:00.000Z', window_end: '2026-11-10T05:00:00.000Z', sealed_through: '2026-11-10T05:00:00.000Z', leaf_count: 1, row_ids: ['r1'], root: 'a'.repeat(64), previous_digest: null, columns: { clear: ['created_at', 'id'], committed: [] }, @@ -482,7 +494,7 @@ describe('a redaction names its checkpoint by the signed sequence (D7)', () => { describe('NULL names the deployment chain only when it is stated (D5)', () => { const checkpoint: CheckpointSignedBody = { - sealed_object: 'sys_audit_log', tenant_id: null, sequence: 0, kind: 'window', + sealed_object: 'sys_audit_log', tenant_id: null, sequence: 0, kind: 'window', part_index: 0, final_part: true, window_start: '2026-11-10T04:00:00.000Z', window_end: '2026-11-10T05:00:00.000Z', sealed_through: '2026-11-10T05:00:00.000Z', leaf_count: 1, row_ids: ['r1'], root: 'a'.repeat(64), previous_digest: null, columns: { clear: ['created_at', 'id'], committed: [] }, @@ -530,6 +542,8 @@ describe('the leaf hashes beside a checkpoint are trusted only through its signe tenant_id: 'org_1', sequence: 0, kind: 'window', + part_index: 0, + final_part: true, window_start: '2026-11-10T04:00:00.000Z', window_end: '2026-11-10T05:00:00.000Z', sealed_through: '2026-11-10T05:00:00.000Z', diff --git a/packages/plugins/plugin-audit/src/audit-seal/audit-seal-sealer.test.ts b/packages/plugins/plugin-audit/src/audit-seal/audit-seal-sealer.test.ts index 8c54358618a..7d42252aa73 100644 --- a/packages/plugins/plugin-audit/src/audit-seal/audit-seal-sealer.test.ts +++ b/packages/plugins/plugin-audit/src/audit-seal/audit-seal-sealer.test.ts @@ -2,9 +2,9 @@ import type { IAuditCheckpointSigner, IClusterService, LockHandle } from '@objectstack/spec/contracts'; import { describe, expect, it } from 'vitest'; -import { checkpointBodyFromRow, checkpointDigest, signedBodyBytes, verifyAuditLedger } from './index.js'; +import { checkpointBodyFromRow, checkpointDigest, signedBodyBytes, verifyAuditLedger, type CheckpointSignedBody } from './index.js'; import { bindingCrypto, memoryEngine, recordingLogger } from './seal-store.testkit.js'; -import { AUDIT_SEALER_LOCK, AuditSealer } from './sealer.js'; +import { AUDIT_SEAL_MAX_IDLE_WINDOWS_PER_PASS, AUDIT_SEAL_MAX_LEAVES, AUDIT_SEALER_LOCK, AuditSealer } from './sealer.js'; import { LocalCheckpointSigner } from './signer.js'; /** @@ -25,7 +25,7 @@ const LEDGER = { const row = (id: string, created: string, tenant: string | null = 'org_a') => ({ id, created_at: created, action: 'update', tenant_id: tenant, payload: `{"v":"${id}"}` }); -function setup(options: { objects?: unknown[]; crypto?: boolean; signer?: IAuditCheckpointSigner; cluster?: IClusterService } = {}) { +function setup(options: { objects?: unknown[]; crypto?: boolean; signer?: IAuditCheckpointSigner; cluster?: IClusterService; maxLeaves?: number } = {}) { const store = memoryEngine((options.objects ?? [LEDGER]) as never); const crypto = bindingCrypto(); const logger = recordingLogger(); @@ -38,6 +38,7 @@ function setup(options: { objects?: unknown[]; crypto?: boolean; signer?: IAudit cluster: () => options.cluster, logger, now: () => clock.now, + ...(options.maxLeaves === undefined ? {} : { maxLeaves: options.maxLeaves }), }); const checkpoints = () => store.hot.table('sys_audit_checkpoint').map((r) => checkpointBodyFromRow(r)); return { ...store, crypto, logger, signer, clock, sealer, checkpoints }; @@ -49,6 +50,26 @@ function grantingCluster() { return cluster as unknown as IClusterService & { renews: number }; } +/** Runs `change` once, right after the first page read of a window's rows: between the sealer's two reads of it (S7). */ +function betweenReads(s: ReturnType, change: () => void) { + const find = s.hot.find.bind(s.hot); + let changed = false; + s.hot.find = async (object, query) => { + const page = await find(object, query); + if (!changed && object === 'ledger_probe' && query.limit === 500) { + changed = true; + change(); + } + return page; + }; +} + +/** Deletes a row of the sealed object from the hot store. */ +function drop(s: ReturnType, id: string) { + const table = s.hot.table('ledger_probe'); + table.splice(table.findIndex((r) => r.id === id), 1); +} + describe('windows: the backlog oldest first, one checkpoint per chain per window (D3, D5)', () => { it('seals every due window that holds a row, skips the empty one and the one not yet settled', async () => { const s = setup(); @@ -305,6 +326,296 @@ describe('per-chain isolation: only a chain-local fault skips a chain, and only }); }); +describe('bounded checkpoints: a window seals into consecutive parts of at most N leaves (S7, ADR-0154 D4 amended)', () => { + const parts = (s: ReturnType) => + s.checkpoints().map((c) => [c.tenant_id, c.kind, c.window_start, c.sequence, c.part_index, c.final_part, c.row_ids]); + + it('fixes N at 10,000 leaves', () => { + expect(AUDIT_SEAL_MAX_LEAVES).toBe(10_000); + }); + + it('cuts a window into consecutive parts in D1 order (created_at, id), the last one final, each chained after the one before', async () => { + const s = setup({ maxLeaves: 2 }); + // Pushed out of order, with a created_at tie broken by id. + s.hot.table('ledger_probe').push(row('r5', at(8, 50)), row('r2', at(8, 20)), row('r3b', at(8, 30)), row('r1', at(8, 10)), row('r3a', at(8, 30))); + expect(await s.sealer.runPass()).toBe(3); + expect(parts(s)).toEqual([ + ['org_a', 'window', at(8, 0), 0, 0, false, ['r1', 'r2']], + ['org_a', 'window', at(8, 0), 1, 1, false, ['r3a', 'r3b']], + ['org_a', 'window', at(8, 0), 2, 2, true, ['r5']], + ]); + const [p0, p1, p2] = s.checkpoints(); + expect([p1.previous_digest, p2.previous_digest]).toEqual([checkpointDigest(p0), checkpointDigest(p1)]); + expect(new Set(s.checkpoints().map((c) => c.seed_handle)).size).toBe(3); // one seed per checkpoint (D2) + const report = await verifyAuditLedger({ engine: s.engine, crypto: s.crypto, now: () => s.clock.now }); + expect(report.ok).toBe(true); + expect(report.totals).toMatchObject({ unmodified: 5, unsealed: 0 }); + expect(await s.sealer.runPass()).toBe(0); + }); + + it('seals a window of at most N rows as one part, index 0 and final: the single-part checkpoint, which still verifies', async () => { + const s = setup({ maxLeaves: 2 }); + s.hot.table('ledger_probe').push(row('r1', at(8, 10)), row('r2', at(8, 20)), row('r3', at(9, 10))); + expect(await s.sealer.runPass()).toBe(2); + expect(parts(s)).toEqual([ + ['org_a', 'window', at(8, 0), 0, 0, true, ['r1', 'r2']], + ['org_a', 'window', at(9, 0), 1, 0, true, ['r3']], + ]); + expect((await verifyAuditLedger({ engine: s.engine, crypto: s.crypto, now: () => s.clock.now })).ok).toBe(true); + }); + + it('reads a checkpoint written before the amendment (no part index, no final flag) as one final part: it verifies, and its chain goes on', async () => { + const s = setup(); + s.hot.table('ledger_probe').push(row('r1', at(8, 10))); + await s.sealer.runPass(); + const stored = s.hot.table('sys_audit_checkpoint')[0]; + const { part_index: _part, final_part: _final, ...legacy } = checkpointBodyFromRow(stored); + const { signature } = await s.signer.sign(signedBodyBytes(legacy as CheckpointSignedBody)); + Object.assign(stored, { part_index: null, final_part: null, signature }); + expect(Object.keys(checkpointBodyFromRow(stored))).not.toContain('part_index'); + s.hot.table('ledger_probe').push(row('r2', at(9, 10))); + expect(await s.sealer.runPass()).toBe(1); + expect(parts(s)).toEqual([ + ['org_a', 'window', at(8, 0), 0, undefined, undefined, ['r1']], + ['org_a', 'window', at(9, 0), 1, 0, true, ['r2']], + ]); + const report = await verifyAuditLedger({ engine: s.engine, crypto: s.crypto, now: () => s.clock.now }); + expect(report.ok).toBe(true); + expect(report.totals).toMatchObject({ unmodified: 2 }); + }); + + it('resumes a window a stopped pass left mid-way as further window parts, never late ones', async () => { + const s = setup({ maxLeaves: 2 }); + s.hot.table('ledger_probe').push(row('r1', at(8, 10)), row('r2', at(8, 20)), row('r3', at(8, 30)), row('r4', at(8, 40)), row('r5', at(8, 50)), row('n1', at(9, 10))); + const insert = s.engine.insert.bind(s.engine); + let inserts = 0; + s.engine.insert = async (object, r, o) => { + if (object === 'sys_audit_checkpoint' && ++inserts === 2) throw new Error('connection reset'); + return insert(object, r, o); + }; + expect(await s.sealer.runPass()).toBe(1); // part 0 stored; the pass stops at part 1 + expect(await s.sealer.runPass()).toBe(3); + expect(parts(s)).toEqual([ + ['org_a', 'window', at(8, 0), 0, 0, false, ['r1', 'r2']], + ['org_a', 'window', at(8, 0), 1, 1, false, ['r3', 'r4']], + ['org_a', 'window', at(8, 0), 2, 2, true, ['r5']], + ['org_a', 'window', at(9, 0), 3, 0, true, ['n1']], + ]); + expect((await verifyAuditLedger({ engine: s.engine, crypto: s.crypto, now: () => s.clock.now })).ok).toBe(true); + expect(await s.sealer.runPass()).toBe(0); + }); + + it('caps late checkpoints the same way: late rows of a window seal into late parts of at most N', async () => { + const s = setup({ maxLeaves: 2 }); + s.hot.table('ledger_probe').push(row('r1', at(10, 5))); + expect(await s.sealer.runPass()).toBe(1); + s.hot.table('ledger_probe').push(row('l3', at(10, 40)), row('l1', at(10, 20)), row('l2', at(10, 30))); + expect(await s.sealer.runPass()).toBe(2); + expect(parts(s).slice(1)).toEqual([ + ['org_a', 'late', at(10, 0), 1, 0, false, ['l1', 'l2']], + ['org_a', 'late', at(10, 0), 2, 1, true, ['l3']], + ]); + const report = await verifyAuditLedger({ engine: s.engine, crypto: s.crypto, now: () => s.clock.now }); + expect(report.totals).toMatchObject({ unmodified: 1, late: 3, unsealed: 0 }); + }); + + it('refuses a window part the chain, re-read under the lease, already holds at that index or past it (S1, relaxed for parts)', async () => { + const cluster = grantingCluster(); + const s = setup({ cluster, maxLeaves: 2 }); + const other = new AuditSealer({ engine: s.engine, crypto: s.crypto, signer: () => s.signer, cluster: () => cluster, logger: s.logger, now: () => s.clock.now, maxLeaves: 2 }); + s.hot.table('ledger_probe').push(row('r1', at(8, 10)), row('r2', at(8, 20)), row('r3', at(8, 30))); + const sign = s.signer.sign.bind(s.signer); + let raced = false; + s.signer.sign = async (bytes) => { + const signed = await sign(bytes); + if (!raced) { + raced = true; + await other.runPass(); // seals both parts of the window while this pass signs its part 0 + } + return signed; + }; + await s.sealer.runPass(); + expect(parts(s)).toEqual([ + ['org_a', 'window', at(8, 0), 0, 0, false, ['r1', 'r2']], + ['org_a', 'window', at(8, 0), 1, 1, true, ['r3']], + ]); + expect(s.logger.lines.filter((l) => l.level === 'error').map((l) => l.message)).toEqual([expect.stringMatching(/not sealed twice/)]); + }); + + it('refuses a window part when the chain, re-read under the lease, holds a checkpoint of that window written before the amendment: on SQL a NULL part index is not at or past part 0 (S1, N2)', async () => { + const cluster = grantingCluster(); + const s = setup({ cluster }); + // A sealer of the release before the amendment, running beside this one in a rolling upgrade. + const older = new AuditSealer({ engine: s.engine, crypto: s.crypto, signer: () => s.signer, cluster: () => cluster, logger: s.logger, now: () => s.clock.now }); + s.hot.table('ledger_probe').push(row('r1', at(8, 10))); + const find = s.hot.find.bind(s.hot); + let raced = false; + s.hot.find = async (object, query) => { + const page = await find(object, query); + if (object === 'ledger_probe' && query.limit === 500 && !raced) { + raced = true; + await older.runPass(); // seals the window this pass has just read, before this pass reads the chain head + const stored = s.hot.table('sys_audit_checkpoint')[0]; + const { part_index: _part, final_part: _final, ...legacy } = checkpointBodyFromRow(stored); + const { signature } = await s.signer.sign(signedBodyBytes(legacy as CheckpointSignedBody)); + Object.assign(stored, { part_index: null, final_part: null, signature }); // what that release stores + } + return page; + }; + expect(await s.sealer.runPass()).toBe(0); + expect(parts(s)).toEqual([['org_a', 'window', at(8, 0), 0, undefined, undefined, ['r1']]]); + expect(s.logger.lines.filter((l) => l.level === 'error').map((l) => l.message)).toEqual([expect.stringMatching(/at or after part 0 .*not sealed twice/)]); + expect((await verifyAuditLedger({ engine: s.engine, crypto: s.crypto, now: () => s.clock.now })).ok).toBe(true); + }); + + it('cuts the same way whatever order the rows were written in, when a created_at tie straddles a part boundary: the id decides the side', async () => { + const tie = [row('r1', at(8, 10)), row('t-b', at(8, 20)), row('t-a', at(8, 20)), row('r4', at(8, 30))]; + for (const written of [tie, [...tie].reverse()]) { + const s = setup({ maxLeaves: 2 }); + s.hot.table('ledger_probe').push(...written.map((r) => ({ ...r }))); + expect(await s.sealer.runPass()).toBe(2); + expect(parts(s)).toEqual([ + ['org_a', 'window', at(8, 0), 0, 0, false, ['r1', 't-a']], + ['org_a', 'window', at(8, 0), 1, 1, true, ['t-b', 'r4']], + ]); + expect((await verifyAuditLedger({ engine: s.engine, crypto: s.crypto, now: () => s.clock.now })).ok).toBe(true); + } + }); + + it('leaves out of its part a row deleted, or moved to another window, between the two reads; the moved row seals in its new window', async () => { + const s = setup({ maxLeaves: 2 }); + s.hot.table('ledger_probe').push(row('r1', at(8, 10)), row('r2', at(8, 20)), row('r3', at(8, 30)), row('r4', at(8, 40))); + betweenReads(s, () => { + drop(s, 'r2'); + s.hot.table('ledger_probe').find((r) => r.id === 'r3')!.created_at = at(9, 15); + }); + expect(await s.sealer.runPass()).toBe(3); + expect(parts(s)).toEqual([ + ['org_a', 'window', at(8, 0), 0, 0, false, ['r1']], + ['org_a', 'window', at(8, 0), 1, 1, true, ['r4']], + ['org_a', 'window', at(9, 0), 2, 0, true, ['r3']], + ]); + const report = await verifyAuditLedger({ engine: s.engine, crypto: s.crypto, now: () => s.clock.now }); + expect(report.ok).toBe(true); + expect(report.totals).toMatchObject({ unmodified: 3, unsealed: 0 }); + expect(await s.sealer.runPass()).toBe(0); + }); + + it('skips a middle part whose rows all went between the two reads without taking its index: part_index may jump, and the window verifies', async () => { + const s = setup({ maxLeaves: 2 }); + s.hot.table('ledger_probe').push(row('r1', at(8, 10)), row('r2', at(8, 20)), row('r3', at(8, 30)), row('r4', at(8, 40)), row('r5', at(8, 50))); + betweenReads(s, () => (drop(s, 'r3'), drop(s, 'r4'))); + expect(await s.sealer.runPass()).toBe(2); + expect(parts(s)).toEqual([ + ['org_a', 'window', at(8, 0), 0, 0, false, ['r1', 'r2']], + ['org_a', 'window', at(8, 0), 1, 2, true, ['r5']], + ]); + expect((await verifyAuditLedger({ engine: s.engine, crypto: s.crypto, now: () => s.clock.now })).ok).toBe(true); + }); + + it('leaves the window with no final part when its last part empties between the two reads; the next pass resumes it, so a row that arrives then is a window part, never a late one', async () => { + const s = setup({ maxLeaves: 2 }); + s.hot.table('ledger_probe').push(row('r1', at(8, 10)), row('r2', at(8, 20)), row('r3', at(8, 30))); + betweenReads(s, () => drop(s, 'r3')); + expect(await s.sealer.runPass()).toBe(1); + expect(parts(s)).toEqual([['org_a', 'window', at(8, 0), 0, 0, false, ['r1', 'r2']]]); + expect((await verifyAuditLedger({ engine: s.engine, crypto: s.crypto, now: () => s.clock.now })).ok).toBe(true); + expect(await s.sealer.runPass()).toBe(0); // the resume finds every row listed + s.hot.table('ledger_probe').push(row('r6', at(8, 55))); + expect(await s.sealer.runPass()).toBe(1); + expect(parts(s).slice(1)).toEqual([['org_a', 'window', at(8, 0), 1, 1, true, ['r6']]]); + const report = await verifyAuditLedger({ engine: s.engine, crypto: s.crypto, now: () => s.clock.now }); + expect(report.ok).toBe(true); + expect(report.totals).toMatchObject({ unmodified: 3, late: 0, unsealed: 0 }); + }); + + it('shows a removed interior part through the links (a gap); a removed newest part is not seen by the links, and its rows read unsealed (M2)', async () => { + const without = async (sequence: number) => { + const s = setup({ maxLeaves: 2 }); + s.hot.table('ledger_probe').push(row('r1', at(8, 10)), row('r2', at(8, 20)), row('r3', at(8, 30)), row('r4', at(8, 40)), row('r5', at(8, 50))); + expect(await s.sealer.runPass()).toBe(3); + const table = s.hot.table('sys_audit_checkpoint'); + table.splice(table.findIndex((r) => Number(r.sequence) === sequence), 1); + return verifyAuditLedger({ engine: s.engine, crypto: s.crypto, now: () => s.clock.now }); + }; + const interior = await without(1); + expect(interior.ok).toBe(false); + expect(interior.faults.map((f) => [f.kind, f.sequence])).toEqual([['gap', 1]]); + expect(interior.rows.map((r) => [r.row, r.verdict, r.sealed])).toEqual([['r3', 'late', false], ['r4', 'late', false]]); + const newest = await without(2); + expect(newest.ok).toBe(false); + expect(newest.faults).toEqual([]); + expect(newest.rows.map((r) => [r.row, r.verdict, r.sealed])).toEqual([['r5', 'late', false]]); + }); +}); + +describe('the uncounted re-walk is bounded while a chain stays skipped (review#3 S1)', () => { + const HOURS = 200; + /** + * Each of these tests first drives `stalled()`: some 200 windows sealed and + * signed over a dozen passes. That costs 2-5 s on a quiet CI shard and more + * on a loaded one, against vitest's 5 s default, so the budget is stated. + */ + const STALLED_TIMEOUT_MS = 30_000; + /** + * org_s skipped at 00:00 by a row its canonical rule refuses, while org_a + * writes every hour: org_a catches up 24 windows a pass while org_s holds + * the floor at 00:00, until the cap stops the walk. + */ + async function stalled() { + const s = setup(); + s.clock.now = DAY0 + (HOURS + 1) * H; // windows up to HOURS:00 are due + s.hot.table('ledger_probe').push({ ...row('stuck', at(0, 20), 'org_s'), payload: 42 }); + for (let h = 0; h <= HOURS - 1; h++) s.hot.table('ledger_probe').push(row(`a${h}`, at(h, 10))); + for (let pass = 0; pass < 12 && (await s.sealer.runPass()) > 0; pass++); + return s; + } + const catchUp = async (s: ReturnType) => { + for (let pass = 0; pass < 6 && (await s.sealer.runPass()) > 0; pass++); + }; + const sealedOnce = (s: ReturnType) => { + const listed = s.checkpoints().flatMap((c) => c.row_ids).sort(); + return { listed, rows: s.hot.table('ledger_probe').map((r) => String(r.id)).sort(), late: s.checkpoints().filter((c) => c.kind === 'late') }; + }; + + it('walks at most MAX_IDLE_WINDOWS_PER_PASS windows that seal nothing, and says so at error', async () => { + const s = await stalled(); + const windowsRead = new Set(); + const find = s.hot.find.bind(s.hot); + s.hot.find = async (object, query) => { + if (object === 'ledger_probe' && query.limit === 500) windowsRead.add(JSON.stringify((query.where as Record).created_at ?? (query.where as { $and: Array> }).$and[0].created_at)); + return find(object, query); + }; + expect(await s.sealer.runPass()).toBe(0); + expect(windowsRead.size).toBe(1 + AUDIT_SEAL_MAX_IDLE_WINDOWS_PER_PASS); // the floor window, then the cap + expect(s.logger.lines.filter((l) => l.level === 'error').map((l) => l.message)) + .toContainEqual(expect.stringMatching(/'ledger_probe'.*walked .* windows that seal nothing.*chain\(s\) 'org:org_s'/)); + }, STALLED_TIMEOUT_MS); + + it('seals the whole object again once the skipped chain is fixed: its window and the windows past the cap seal as window checkpoints, none late', async () => { + const s = await stalled(); + expect(sealedOnce(s).listed.length).toBeLessThan(HOURS); // org_a up to the cap; org_s and the rest wait + s.hot.table('ledger_probe').find((r) => r.id === 'stuck')!.payload = '{"v":"stuck"}'; + await catchUp(s); + const { listed, rows, late } = sealedOnce(s); + expect(listed).toEqual(rows); + expect(late).toEqual([]); + expect(s.checkpoints().filter((c) => c.tenant_id === 'org_s').map((c) => [c.kind, c.window_start, c.row_ids])).toEqual([['window', at(0, 0), ['stuck']]]); + }, STALLED_TIMEOUT_MS); + + it('seals the whole object again once the skipped chain has nothing left to seal (its refused row gone): no chain is skipped, so the walk past the cap is not cut', async () => { + const s = await stalled(); + drop(s, 'stuck'); + await catchUp(s); + const { listed, rows, late } = sealedOnce(s); + expect(listed).toEqual(rows); + expect(late).toEqual([]); + const report = await verifyAuditLedger({ engine: s.engine, crypto: s.crypto, now: () => s.clock.now }); + expect(report.ok).toBe(true); + expect(report.totals).toMatchObject({ unmodified: HOURS, unsealed: 0 }); + }, STALLED_TIMEOUT_MS); +}); + describe('the lock: audit.sealer, its fencing token on each checkpoint (D3, Q2 (a))', () => { const lockedCluster = (token: bigint | null, onAcquire: (key: string) => void = () => {}) => { let held = token !== null; diff --git a/packages/plugins/plugin-audit/src/audit-seal/audit-seal-verifier.test.ts b/packages/plugins/plugin-audit/src/audit-seal/audit-seal-verifier.test.ts index 77b9d2a7e8e..59b202fa4a3 100644 --- a/packages/plugins/plugin-audit/src/audit-seal/audit-seal-verifier.test.ts +++ b/packages/plugins/plugin-audit/src/audit-seal/audit-seal-verifier.test.ts @@ -11,6 +11,7 @@ import { canonicalValue, checkpointBodyFromRow, checkpointDigest, + checkpointRow, checkpointSeedContext, columnSaltsOf, commitValue, @@ -27,7 +28,7 @@ import { } from './index.js'; import { bindingCrypto, memoryEngine, recordingLogger } from './seal-store.testkit.js'; import { AuditSealer } from './sealer.js'; -import { LocalCheckpointSigner, readAuditSealSecret } from './signer.js'; +import { LocalCheckpointSigner, readAuditSealSecret, writeAuditSealSecret } from './signer.js'; /** * ADR-0154 D9 — the live check over an in-memory engine double: per-row @@ -252,6 +253,24 @@ describe('trust: only keys the anchor vouches for (D6)', () => { expect(verdicts(report)).toEqual({ r5: 'late!' }); }); + it('faults a row id two checkpoints list, though each is signed and linked: the second listing holds nothing (S7)', async () => { + const s = await sealedLedger(); + // A second, validly signed and linked checkpoint of org_b re-listing r5, under its own sealed seed. + const first = checkpointBodyFromRow(s.checkpoint('org:org_b', 0)); + const handle = await readAuditSealSecret(s.engine, first.seed_handle); + const seed = await s.crypto.decrypt(handle!, checkpointSeedContext('ledger_probe', 'org_b', 0)); + const context = checkpointSeedContext('ledger_probe', 'org_b', 1); + const resealed = await s.crypto.encrypt(seed, context); + await writeAuditSealSecret(s.engine, resealed, context); + const body: CheckpointSignedBody = { ...first, sequence: 1, previous_digest: checkpointDigest(first), seed_handle: resealed.id }; + const { signature } = await s.signer.sign(signedBodyBytes(body)); + s.checkpoints().push(checkpointRow(body, { id: 'again', signature, leafHashes: JSON.parse(String(s.checkpoint('org:org_b', 0).leaf_hashes)) })); + const report = await s.verifyNow(); + expect(faultKinds(report)).toEqual(['org:org_b#1:listed_twice']); + expect(report.ok).toBe(false); + expect(report.totals).toMatchObject({ unmodified: 5 }); + }); + it('reports a checkpoint row that is not a signed body as malformed: the run fails', async () => { const s = await sealedLedger(); s.checkpoint('org:org_b', 0).row_ids = '["r5","r5"]'; diff --git a/packages/plugins/plugin-audit/src/audit-seal/seal-store.testkit.ts b/packages/plugins/plugin-audit/src/audit-seal/seal-store.testkit.ts index 4065dc8dc56..72435a2ad28 100644 --- a/packages/plugins/plugin-audit/src/audit-seal/seal-store.testkit.ts +++ b/packages/plugins/plugin-audit/src/audit-seal/seal-store.testkit.ts @@ -14,6 +14,11 @@ function comparable(value: unknown): unknown { return value; } +/** + * A `where` judged the way a SQL driver judges it: a comparison with a NULL + * column is never true (`NULL >= 0` is unknown, where JavaScript's + * `null >= 0` is `true`), and `{ $null: true }` is `IS NULL`. + */ function matches(row: Row, where: Record = {}): boolean { return Object.entries(where).every(([field, cond]) => { if (field === '$and') return (cond as Row[]).every((w) => matches(row, w)); @@ -21,9 +26,13 @@ function matches(row: Row, where: Record = {}): boolean { const value = comparable(row[field]); if (cond !== null && typeof cond === 'object' && !Array.isArray(cond)) { const ops = cond as Record; + const isNull = value === null || value === undefined; + if ('$null' in ops && ops.$null !== isNull) return false; + if (isNull && ['$gte', '$gt', '$lt', '$in'].some((op) => op in ops)) return false; if ('$gte' in ops && !((value as number) >= (comparable(ops.$gte) as number))) return false; if ('$gt' in ops && !((value as number) > (comparable(ops.$gt) as number))) return false; if ('$lt' in ops && !((value as number) < (comparable(ops.$lt) as number))) return false; + if ('$in' in ops && !(ops.$in as unknown[]).some((v) => comparable(v) === value)) return false; return true; } return value === comparable(cond); diff --git a/packages/plugins/plugin-audit/src/audit-seal/sealer.ts b/packages/plugins/plugin-audit/src/audit-seal/sealer.ts index 5e40b5178ea..e6877d87bee 100644 --- a/packages/plugins/plugin-audit/src/audit-seal/sealer.ts +++ b/packages/plugins/plugin-audit/src/audit-seal/sealer.ts @@ -34,6 +34,7 @@ import { chainKeyOf, checkpointBodyFromRow, checkpointDigest, + checkpointPartOf, checkpointRow, signedBodyBytes, SignedBodyError, @@ -44,8 +45,10 @@ import { dropAuditSealSecret, writeAuditSealSecret, type SealStorageDriver, type /** * ADR-0154 D3 — the sealer: after a settle lag, one window at a time, under - * the cluster lock `audit.sealer`, it seals each sealed object's rows into one - * signed checkpoint per chain (organization, or the deployment) per window. + * the cluster lock `audit.sealer`, it seals each sealed object's rows into + * signed checkpoints per chain (organization, or the deployment) per window: + * consecutive parts of at most {@link AUDIT_SEAL_MAX_LEAVES} leaves each + * (S7, D4 as amended 2026-11-14), cut in D1 order, the last one final. * * A pass, per sealed object: * @@ -63,6 +66,13 @@ import { dropAuditSealSecret, writeAuditSealSecret, type SealStorageDriver, type * Each checkpoint carries the sealed-through watermark: the end of the last * window the sealer had completed for every chain when it wrote it. * + * S7: a pass that stops mid-window leaves the chain's last `window` part + * non-final; the next pass resumes that window as further `window` parts, + * counting on from that part's index, so the rest is never sealed as `late`. + * A window is read twice: once for the ids and instants of its rows, then + * each part's rows by id, hashed under that part's own seed (D2) — so one + * checkpoint's work is bounded by N, whatever its window holds. + * * S4 (seat ruling 6884540128 item 2): a fault is isolated to the smallest * thing it belongs to. A chain-local fault — a row a canonical rule refuses, * or a malformed checkpoint of the chain (its head among them) — skips that @@ -91,6 +101,24 @@ const REPORT_REPEAT_MS = 60 * 60 * 1000; const PAGE_SIZE = 500; /** Windows sealed per object per pass; a backlog continues on the next pass, which follows at once. */ const MAX_WINDOWS_PER_PASS = 24; +/** + * S7 (ADR-0154 D4 amended): the most leaves one checkpoint holds. A window + * holding more seals into consecutive parts. A fixed constant, not a knob. + */ +export const AUDIT_SEAL_MAX_LEAVES = 10_000; +/** + * review#3 S1: windows a pass may walk that seal nothing — every row of them + * belongs to a chain sealed past them, or to a chain skipped in this pass — + * while a chain is skipped, before it stops walking. Only a skipped chain + * holds the floor back so that such windows recur; this bounds what each pass + * re-reads while it stays skipped. One late horizon's worth of windows. + * + * With no chain skipped the walk is not cut: such windows are then only what + * a chain skipped before (fixed since, or with nothing left to seal) left + * behind, and walking on to the next window that seals something is what + * moves the floor past them. Cut there, the floor would never move again. + */ +export const AUDIT_SEAL_MAX_IDLE_WINDOWS_PER_PASS = AUDIT_SEAL_LATE_HORIZON_MS / AUDIT_SEAL_WINDOW_MS; /** Sign attempts of one checkpoint before the pass gives up (the S1 loop). */ const MAX_SIGN_ATTEMPTS = 3; /** The key id a body is built with before the signer has named one. */ @@ -121,6 +149,12 @@ export interface AuditSealerOptions { cluster?: () => IClusterService | undefined; logger: AuditSealerLogger; now?: () => number; + /** + * Test seam, like `now`: a smaller {@link AUDIT_SEAL_MAX_LEAVES}, so a test + * can cut a window into parts with a handful of rows. `AuditPlugin` never + * passes it, and nothing an operator or a tenant sets reaches it. + */ + maxLeaves?: number; } /** A sealed object, as a pass reads it. */ @@ -136,13 +170,23 @@ interface ChainHead { readonly digest: string; } -/** One chain's rows of one window, as leaves. */ -interface ChainLeaves { +/** One chain's rows of one window, as read: each row's id and canonical `created_at`, not yet hashed. */ +interface ChainRows { readonly tenantId: string | null; - readonly seed: Buffer; - readonly leaves: Array<{ id: string; at: string; hash: Buffer }>; + readonly rows: Array<{ id: string; at: string }>; } +/** A row as a leaf of one checkpoint, under that checkpoint's seed. */ +interface Leaf { + readonly id: string; + readonly at: string; + readonly hash: Buffer; +} + +/** D1 leaf order: `(created_at, id)`. */ +const leafOrder = (a: { id: string; at: string }, b: { id: string; at: string }): number => + a.at < b.at ? -1 : a.at > b.at ? 1 : a.id < b.id ? -1 : a.id > b.id ? 1 : 0; + const iso = (ms: number): string => new Date(ms).toISOString(); /** @@ -257,6 +301,19 @@ export class AuditSealer { } } + /** + * review#3 S1: the walk stopped on its bound of windows that seal nothing. + * While a skipped chain holds the floor back, windows past that bound wait + * for it; this says so at `error`, once per {@link REPORT_REPEAT_MS}. + */ + private reportIdleStop(object: string, stop: { at: number; windows: number }, skipped: ReadonlyMap): void { + const chains = [...skipped.keys()].map((key) => `'${key}'`).join(', '); // never empty: the bound counts only while one is skipped + this.report(`idle:${object}`, () => + `AuditSealer: '${object}' walked ${stop.windows} windows that seal nothing in one pass and stopped there — ` + + `its rows from the window of ${iso(stop.at)} on are NOT being sealed while the skipped chain(s) ${chains} ` + + 'hold its sealed-through watermark back. Fix the chain fault reported for it; sealing then catches up.'); + } + /** The sealed objects the registry holds that can be sealed; each that cannot is reported. */ private plans(): SealPlan[] { const plans: SealPlan[] = []; @@ -343,6 +400,7 @@ export class AuditSealer { } finally { written += pass?.written ?? 0; if (pass) this.reportSkipped(plan.name, pass.skipped); + if (pass?.idleStop) this.reportIdleStop(plan.name, pass.idleStop, pass.skipped); } } return written; @@ -365,6 +423,10 @@ class ObjectPass { private readonly cursors = new Map(); /** S4: the chains a chain-local fault put out for the rest of this pass, and the window each stays unsealed from. */ readonly skipped = new Map(); + /** S7: the chains whose newest `window` part is not final — the window they resume, and its next part. */ + private readonly resume = new Map(); + /** review#3 S1: where the walk stopped on its bound of windows that seal nothing, if it did. */ + idleStop: { at: number; windows: number } | null = null; /** Checkpoints this pass wrote, counted as each lands. */ written = 0; /** The key id the last checkpoint of this pass was signed under: the next body's expectation. */ @@ -407,18 +469,31 @@ class ObjectPass { const recent = await this.checkpoints.find(AUDIT_CHECKPOINT_OBJECT, { where: { sealed_object: this.plan.name, kind: 'window', window_start: { $gte: iso(this.floor) } }, }); + // S7: a chain whose newest `window` part is not final resumes that window, from the next part. + const newest = new Map(); for (const row of recent) { const key = String(row.chain_key); let start: number; + let part: { part_index: number; final_part: boolean }; try { start = Date.parse(canonicalDatetime(row.window_start, 'window_start')); + // A checkpoint written before the amendment is one part, final. + part = checkpointPartOf(row) ?? { part_index: 0, final_part: true }; } catch (err) { this.skip(key, err, this.floor); continue; } - this.cursors.set(key, Math.max(this.cursors.get(key) ?? start + AUDIT_SEAL_WINDOW_MS, start + AUDIT_SEAL_WINDOW_MS)); + const seen = newest.get(key); + if (!seen || start > seen.start || (start === seen.start && part.part_index > seen.part)) { + newest.set(key, { start, part: part.part_index, final: part.final_part }); + } lastWindow = Math.max(lastWindow ?? start, start); } + for (const [key, { start, part, final }] of newest) { + if (this.skipped.has(key)) continue; + this.cursors.set(key, final ? start + AUDIT_SEAL_WINDOW_MS : start); + if (!final) this.resume.set(key, { window: start, next: part + 1 }); + } } const due = windowOf(this.now - AUDIT_SEAL_SETTLE_MS); @@ -431,13 +506,21 @@ class ObjectPass { cursor = windowOf(oldest); } // Windows oldest first from the floor; each chain is sealed from its own cursor. A window that only re-reads - // chains already sealed (or skipped) past it does not count toward the pass's windows. - for (let n = 0; n < MAX_WINDOWS_PER_PASS;) { + // chains already sealed (or skipped) past it does not count toward the pass's windows; while a chain is + // skipped it counts toward its own bound (review#3 S1): a chain that stays skipped holds the floor, and every + // pass walks on from there. With none skipped it counts toward nothing, so the walk reaches the next window + // that seals something and the floor moves on. + for (let n = 0, idle = 0; n < MAX_WINDOWS_PER_PASS;) { const next = await this.firstRowAt(cursor, due); if (next === null) break; + if (idle >= AUDIT_SEAL_MAX_IDLE_WINDOWS_PER_PASS) { + this.idleStop = { at: windowOf(next), windows: idle }; + break; + } const start = windowOf(next); const chains = await this.readWindow(start, (row) => start >= this.cursorOf(chainKeyOf(tenantOf(row)))); if (chains.size > 0) n += 1; + else if (this.skipped.size > 0) idle += 1; await this.writeChains(chains, start, 'window', Math.max(this.watermark ?? Number.NEGATIVE_INFINITY, Math.min(start, this.stuckFrom()))); cursor = start + AUDIT_SEAL_WINDOW_MS; } @@ -564,8 +647,8 @@ class ObjectPass { * is read once though both stores hold it (between the archive's copy and * its hot delete), and only in the window its canonical `created_at` names. */ - private async readWindow(start: number, accept: (row: Row) => boolean): Promise> { - const chains = new Map(); + private async readWindow(start: number, accept: (row: Row) => boolean): Promise> { + const chains = new Map(); const seen = new Set(); const range = { created_at: { $gte: iso(start), $lt: iso(start + AUDIT_SEAL_WINDOW_MS) } }; for (const store of this.stores()) { @@ -592,11 +675,11 @@ class ObjectPass { seen.add(id); let chain = chains.get(key); if (!chain) { - chain = { tenantId, seed: generateCheckpointSeed(), leaves: [] }; + chain = { tenantId, rows: [] }; chains.set(key, chain); } - const leaf = leafInput(row, this.plan.columns, this.plan.fields, columnSaltsOf(chain.seed, this.plan.name)); - chain.leaves.push({ id, at, hash: leafHash(leaf) }); + // S7: ids and instants only; each part's rows are read again by id and hashed under its own seed. + chain.rows.push({ id, at }); } catch (err) { // S4: a row a canonical rule refuses skips its chain, and only its chain. if (!(err instanceof CanonicalFormError)) throw err; @@ -633,23 +716,93 @@ class ObjectPass { return head; } - private async writeChains(chains: Map, start: number, kind: AuditCheckpointKind, watermark: number): Promise { - // `readWindow` makes a chain only with its first leaf, so no checkpoint is empty (D3). + private async writeChains(chains: Map, start: number, kind: AuditCheckpointKind, watermark: number): Promise { + // `readWindow` makes a chain only with its first row, so no checkpoint is empty (D3). for (const key of [...chains.keys()].sort()) { if (this.skipped.has(key)) continue; try { - await this.writeCheckpoint(key, chains.get(key)!, start, kind, watermark); + await this.writeChain(key, chains.get(key)!, start, kind, watermark); } catch (err) { - // S4: only a chain-local fault of this chain skips it; every other fault stops the object's pass. - if (!(err instanceof ChainFault) || err.chainKey !== key) throw err; + // S4: only a chain-local fault of this chain skips it — a malformed checkpoint of it, or a row of it a + // canonical rule refuses as its part is hashed; every other fault stops the object's pass. + if (!(err instanceof CanonicalFormError) && !(err instanceof ChainFault && err.chainKey === key)) throw err; this.skip(key, err, start); continue; } - if (kind === 'window') this.cursors.set(key, start + AUDIT_SEAL_WINDOW_MS); + if (kind === 'window') { + this.cursors.set(key, start + AUDIT_SEAL_WINDOW_MS); + this.resume.delete(key); + } } if (kind === 'window') this.watermark = Math.max(this.watermark ?? watermark, watermark); } + /** + * S7: one chain's rows of window `start` as consecutive checkpoints of at + * most N leaves, cut in D1 order, the last one final. A `window` sealing + * that resumes a window a stopped pass left continues its part count and + * seals only the rows no checkpoint lists yet. + */ + private async writeChain(key: string, chain: ChainRows, start: number, kind: AuditCheckpointKind, watermark: number): Promise { + await this.headOf(key); + const resumed = kind === 'window' ? this.resume.get(key) : undefined; + let rows = chain.rows; + if (kind === 'late' || resumed?.window === start) { + // N1: the window's checkpoints, re-read once this chain's head is known: a row another sealer listed + // since this pass read the window's lists is not sealed twice. One stored after the head was known + // takes a sequence at or past this one, so the unique index refuses whichever insert comes second. + // A resumed window drops the rows its earlier parts list the same way. + const listed = await this.listedIn(start, key); + rows = rows.filter((r) => !listed.has(r.id)); + } + const ordered = [...rows].sort(leafOrder); + const size = Math.max(1, Math.floor(this.options.maxLeaves ?? AUDIT_SEAL_MAX_LEAVES)); + const first = resumed?.window === start ? resumed.next : 0; + for (let at = 0; at < ordered.length; at += size) { + const seed = generateCheckpointSeed(); + const leaves = await this.leavesOf(key, seed, ordered.slice(at, at + size), start); + // Every row of the part went since the window was read: nothing is written, and its index is not reused, so + // part_index may skip one, and a window whose last part emptied has no final part. Nothing reads either. + if (leaves.length === 0) continue; + await this.writeCheckpoint(key, chain.tenantId, seed, leaves, start, kind, watermark, { + part_index: first + at / size, + final_part: at + size >= ordered.length, + }); + } + } + + /** + * The leaves of one part: its rows read again by id, from the hot store and + * then the archive, hashed under the part's seed, in D1 order. A row gone + * since the window was read, or whose `created_at` or chain moved since, is + * left out: it is no longer a row of this chain's window. + */ + private async leavesOf(key: string, seed: Buffer, part: ReadonlyArray<{ id: string }>, start: number): Promise { + const ids = part.map((r) => r.id); + const byId = new Map(); + for (const store of this.stores()) { + for (let i = 0; i < ids.length; i += PAGE_SIZE) { + const batch = ids.slice(i, i + PAGE_SIZE).filter((id) => !byId.has(id)); + if (batch.length === 0) continue; + await this.lock.renew(LOCK_TTL_MS); + for (const row of await this.find(store, { where: { id: { $in: batch } } })) { + const id = rowIdOf(row); + if (!byId.has(id)) byId.set(id, row); + } + } + } + const saltOf = columnSaltsOf(seed, this.plan.name); + const leaves: Leaf[] = []; + for (const id of ids) { + const row = byId.get(id); + if (!row) continue; + const at = canonicalDatetime(row.created_at, `${id}.created_at`); + if (windowOf(Date.parse(at)) !== start || chainKeyOf(tenantOf(row)) !== key) continue; + leaves.push({ id, at, hash: leafHash(leafInput(row, this.plan.columns, this.plan.fields, saltOf)) }); + } + return leaves.sort(leafOrder); + } + /** * Sign `build`'s body under the S1 loop: built with the key id the signer is * expected to use, signed, and when the signer answers with another key id, @@ -670,33 +823,34 @@ class ObjectPass { throw new Error(`the checkpoint signer answered a different key id on each of ${MAX_SIGN_ATTEMPTS} attempts`); } - private async writeCheckpoint(chainKey: string, chain: ChainLeaves, start: number, kind: AuditCheckpointKind, watermark: number): Promise { + private async writeCheckpoint( + chainKey: string, + tenantId: string | null, + seed: Buffer, + ordered: readonly Leaf[], + start: number, + kind: AuditCheckpointKind, + watermark: number, + part: { readonly part_index: number; readonly final_part: boolean }, + ): Promise { const { engine, crypto } = this.options; const head = await this.headOf(chainKey); - let leaves = chain.leaves; - if (kind === 'late') { - // N1: the window's checkpoints, re-read once this chain's head is known: a row another sealer listed - // since this pass read the window's lists is not sealed twice. One stored after the head was known - // takes a sequence at or past this one, so the unique index refuses whichever insert comes second. - const listed = await this.listedIn(start, chainKey); - leaves = leaves.filter((leaf) => !listed.has(leaf.id)); - if (leaves.length === 0) return; - } - const ordered = [...leaves].sort((a, b) => (a.at < b.at ? -1 : a.at > b.at ? 1 : a.id < b.id ? -1 : a.id > b.id ? 1 : 0)); const sequence = head ? head.sequence + 1 : 0; // Q6: an over-long coordinate is refused here, before anything is encrypted or written. - const context = checkpointSeedContext(this.plan.name, chain.tenantId, sequence); + const context = checkpointSeedContext(this.plan.name, tenantId, sequence); await this.lock.renew(LOCK_TTL_MS); - const handle = await crypto!.encrypt(encodeCheckpointSeed(chain.seed), context); + const handle = await crypto!.encrypt(encodeCheckpointSeed(seed), context); await writeAuditSealSecret(engine, handle, context); let signed: { body: CheckpointSignedBody; keyId: string; signature: string }; try { const sealedAt = iso((this.options.now ?? Date.now)()); signed = await this.signBody((signingKeyId) => ({ sealed_object: this.plan.name, - tenant_id: chain.tenantId, + tenant_id: tenantId, sequence, kind, + part_index: part.part_index, + final_part: part.final_part, window_start: iso(start), window_end: iso(start + AUDIT_SEAL_WINDOW_MS), sealed_through: iso(watermark), @@ -713,9 +867,17 @@ class ObjectPass { })); if (!this.lock.isHeld()) throw new Error('the audit.sealer lock lapsed before the checkpoint was written'); // S1: the chain's window head, re-read under the lease: a window another sealer sealed (or passed) - // since this pass began is not sealed again. Windows of a chain are sealed oldest first. - if (kind === 'window' && (await this.storedCheckpoint(chainKey, { kind: 'window', window_start: { $gte: iso(start) } }))) { - throw new Error(`chain '${chainKey}' already holds a window checkpoint at or after ${iso(start)}; it is not sealed twice`); + // since this pass began is not sealed again. Windows of a chain are sealed oldest first, and the parts of + // one window in order (S7), so only a later window or a part of this one at this index or past it refuses. + // A checkpoint of this window written before the amendment is the whole window; its part index is NULL, + // which no comparison matches on SQL (`NULL >= 0` is not true), so it is matched as NULL. + const thisWindow = { $gte: iso(start), $lt: iso(start + AUDIT_SEAL_WINDOW_MS) }; + if (kind === 'window' && (await this.storedCheckpoint(chainKey, { kind: 'window', $or: [ + { window_start: { $gte: iso(start + AUDIT_SEAL_WINDOW_MS) } }, + { window_start: thisWindow, part_index: { $gte: part.part_index } }, + { window_start: thisWindow, part_index: { $null: true } }, + ] }))) { + throw new Error(`chain '${chainKey}' already holds a window checkpoint at or after part ${part.part_index} of ${iso(start)}; it is not sealed twice`); } } catch (err) { // No insert was attempted, so nothing names the seed. diff --git a/packages/plugins/plugin-audit/src/audit-seal/signed-body.ts b/packages/plugins/plugin-audit/src/audit-seal/signed-body.ts index 66cff064f8b..6cc14de7493 100644 --- a/packages/plugins/plugin-audit/src/audit-seal/signed-body.ts +++ b/packages/plugins/plugin-audit/src/audit-seal/signed-body.ts @@ -65,6 +65,32 @@ export interface CheckpointSignedBody { readonly tenant_id: string | null; readonly sequence: number; readonly kind: AuditCheckpointKind; + /** + * ADR-0154 D4 amended (S7): a chain's window seals into consecutive + * checkpoints of at most N leaves. This one's place among them, from 0 — for + * a `window` part, its place in the window's `window` parts (a pass that + * resumes a window it left mid-way continues the count); for a `late` part, + * its place in the one late sealing of the window that wrote it. + * + * The count may skip a number: a part whose rows were all deleted or moved + * between the sealer's two reads of the window is not written and takes no + * index (parts 0 and 2, say). Nothing reads continuity, and nothing requires + * a final part, since a window whose last part emptied has none. A removed + * interior part still shows in the chain links (`gap`, `link`); a removed + * newest part does not, and its rows read unsealed. + * + * Absent, with `final_part`, from a checkpoint written before the amendment: + * such a body signed neither key, so it is read back without them and reads + * as one part, final. A body holding one of the two and not the other is + * refused. + */ + readonly part_index?: number; + /** + * Whether this is the last part of its sealing: a window, or one late + * sealing of it. Absent with `part_index`. A window whose last part emptied + * between the two reads has no final part (see `part_index`). + */ + readonly final_part?: boolean; readonly window_start: string; readonly window_end: string; /** The sealed-through watermark (D3). */ @@ -191,6 +217,30 @@ function fencingToken(raw: unknown): string { return value; } +/** + * A flag in its one meaning: `true` or `false`, or the `1` / `0` (number or + * text) a driver with no boolean column hands back. Absent is refused, never + * read as either. + */ +function flag(row: Readonly>, field: string): boolean { + const value = row[field]; + if (value === true || value === 1 || value === '1' || value === 'true') return true; + if (value === false || value === 0 || value === '0' || value === 'false') return false; + throw new SignedBodyError(`${field}: true or false is required`); +} + +/** + * A stored checkpoint's place among its window's parts (S7), read alone — the + * sealer's resume reads it without judging the whole body. `null` for a + * checkpoint written before the amendment, which carries neither key (NULL + * columns, or a body without them): one part, final. + */ +export function checkpointPartOf(row: Readonly>): { readonly part_index: number; readonly final_part: boolean } | null { + const absent = (field: string) => row[field] === undefined || row[field] === null; + if (absent('part_index') && absent('final_part')) return null; + return { part_index: count(row, 'part_index'), final_part: flag(row, 'final_part') }; +} + /** A JSON column: stored as JCS text, or handed back already parsed by a driver with JSON columns. */ function json(row: Readonly>, field: string): unknown { const value = row[field]; @@ -240,6 +290,7 @@ export function checkpointBodyFromRow(row: Readonly>): C tenant_id: nullableText(row, 'tenant_id'), sequence: count(row, 'sequence'), kind: oneOf(row, 'kind', AUDIT_CHECKPOINT_KINDS), + ...checkpointPartOf(row), // absent from a body written before the amendment, so its signed bytes stand window_start: instant(row, 'window_start'), window_end: instant(row, 'window_end'), sealed_through: instant(row, 'sealed_through'), diff --git a/packages/plugins/plugin-audit/src/audit-seal/verifier.ts b/packages/plugins/plugin-audit/src/audit-seal/verifier.ts index 10931a980fe..1bb8c22d765 100644 --- a/packages/plugins/plugin-audit/src/audit-seal/verifier.ts +++ b/packages/plugins/plugin-audit/src/audit-seal/verifier.ts @@ -79,6 +79,8 @@ export type AuditChainFaultKind = | 'chain_key' /** Two checkpoints at one sequence of one chain. */ | 'duplicate' + /** A row id another checkpoint already lists (S7: the parts of a window never overlap). */ + | 'listed_twice' /** Sequences no checkpoint holds and no honoured expiry covers. */ | 'gap' /** A `previous_digest` that is not the digest of what precedes it. */ @@ -763,6 +765,13 @@ export abstract class ChainCheck { this.holdsNothing(head, body); return; } + // S7 (ADR-0154 D4 amended): no row is sealed twice, whatever cut a window into parts. A row another + // checkpoint already holds is a fault here, and this listing holds nothing more for it. + const again = new Set(body.row_ids.filter((id) => this.held.has(id))); + if (again.size > 0) { + const named = [...again].slice(0, 5).join(', ') + (again.size > 5 ? ` and ${again.size - 5} more` : ''); + this.check.fault({ ...at, kind: 'listed_twice', sequence: body.sequence, message: `checkpoint ${body.sequence}: lists row(s) ${named} that another checkpoint already lists` }); + } let hashes: string[]; try { hashes = checkpointLeafHashesFromRow(row, body); @@ -779,6 +788,7 @@ export abstract class ChainCheck { } const redactions = this.redactions.get(this.key(head.chain, body.sequence)) ?? []; for (const [i, id] of body.row_ids.entries()) { + if (again.has(id)) continue; this.held.add(id); const leaf = leaves[i]; if (leaf === null) { @@ -816,7 +826,8 @@ export abstract class ChainCheck { /** The columns of a stored checkpoint and amendment a proof bundle copies of a row that is not a signed body. */ const CHECKPOINT_COLUMNS = [ - 'id', 'chain_key', 'signature', 'leaf_hashes', 'sealed_object', 'tenant_id', 'sequence', 'kind', 'window_start', 'window_end', + 'id', 'chain_key', 'signature', 'leaf_hashes', 'sealed_object', 'tenant_id', 'sequence', 'kind', 'part_index', 'final_part', + 'window_start', 'window_end', 'sealed_through', 'leaf_count', 'row_ids', 'root', 'previous_digest', 'columns', 'canon_version', 'seed_handle', 'fencing_token', 'sealed_at', 'signing_key_id', ]; diff --git a/packages/plugins/plugin-audit/src/objects/sys-audit-checkpoint.object.ts b/packages/plugins/plugin-audit/src/objects/sys-audit-checkpoint.object.ts index c9c5733a36e..66f3de03f7c 100644 --- a/packages/plugins/plugin-audit/src/objects/sys-audit-checkpoint.object.ts +++ b/packages/plugins/plugin-audit/src/objects/sys-audit-checkpoint.object.ts @@ -3,8 +3,10 @@ import { ObjectSchema, Field } from '@objectstack/spec/data'; /** - * sys_audit_checkpoint — one Merkle root per chain per window, chained and - * signed (ADR-0154 D4). + * sys_audit_checkpoint — one Merkle root per checkpoint, chained and signed + * (ADR-0154 D4, amended 2026-11-14: a chain's window seals into consecutive + * checkpoints of at most 10,000 rows, each carrying its `part_index` and + * `final_part` under the signature). * * A checkpoint seals one chain's rows of one window of a sealed object: the * chain is that object × one organization, or × the deployment for rows about @@ -91,6 +93,18 @@ export const SysAuditCheckpoint = ObjectSchema.create({ description: 'A window sealed on time, or rows that arrived after their window was sealed', }, ), + // Not required: a checkpoint written before ADR-0154's 2026-11-14 amendment holds NULL in both and reads as + // one part, final — its signed body never carried them. + part_index: Field.number({ + label: 'Part', + readonly: true, + description: 'Place among the consecutive checkpoints of at most 10,000 rows its window (or late sealing) is cut into, from 0', + }), + final_part: Field.boolean({ + label: 'Final Part', + readonly: true, + description: 'Whether this is the last part of its window (or late sealing)', + }), window_start: Field.datetime({ label: 'Window Start', required: true, readonly: true }), window_end: Field.datetime({ label: 'Window End', required: true, readonly: true }), sealed_through: Field.datetime({ diff --git a/packages/plugins/plugin-audit/src/translations/ar.objects.generated.ts b/packages/plugins/plugin-audit/src/translations/ar.objects.generated.ts index d981e5c06b9..6a8992821b1 100644 --- a/packages/plugins/plugin-audit/src/translations/ar.objects.generated.ts +++ b/packages/plugins/plugin-audit/src/translations/ar.objects.generated.ts @@ -330,6 +330,14 @@ export const arObjects: NonNullable = { late: "Late" } }, + part_index: { + label: "Part", + help: "Place among the consecutive checkpoints of at most 10,000 rows its window (or late sealing) is cut into, from 0" + }, + final_part: { + label: "Final Part", + help: "Whether this is the last part of its window (or late sealing)" + }, window_start: { label: "Window Start" }, diff --git a/packages/plugins/plugin-audit/src/translations/ar.source-hashes.generated.ts b/packages/plugins/plugin-audit/src/translations/ar.source-hashes.generated.ts index e1602631a00..6333b59e693 100644 --- a/packages/plugins/plugin-audit/src/translations/ar.source-hashes.generated.ts +++ b/packages/plugins/plugin-audit/src/translations/ar.source-hashes.generated.ts @@ -59,6 +59,8 @@ export const arGeneratedSourceHashes: Readonly> = { "objects.sys_audit_checkpoint.fields.columns.help": "789c1b1b474161a1", "objects.sys_audit_checkpoint.fields.columns.label": "c849ea0a39dedbb6", "objects.sys_audit_checkpoint.fields.fencing_token.label": "7e206dcd4b8d3ffc", + "objects.sys_audit_checkpoint.fields.final_part.help": "dd2ea0abf9d27fa3", + "objects.sys_audit_checkpoint.fields.final_part.label": "accc721e7bff52c3", "objects.sys_audit_checkpoint.fields.id.label": "6ace5d591b082096", "objects.sys_audit_checkpoint.fields.kind.help": "893a956c8c781ed6", "objects.sys_audit_checkpoint.fields.kind.label": "3acd2ee4b0e7f2cf", @@ -67,6 +69,8 @@ export const arGeneratedSourceHashes: Readonly> = { "objects.sys_audit_checkpoint.fields.leaf_count.label": "3879d38d4e5176e5", "objects.sys_audit_checkpoint.fields.leaf_hashes.help": "8c59d342be41804c", "objects.sys_audit_checkpoint.fields.leaf_hashes.label": "74230d1d6453537c", + "objects.sys_audit_checkpoint.fields.part_index.help": "37552741e590bfa1", + "objects.sys_audit_checkpoint.fields.part_index.label": "049d919558de58bd", "objects.sys_audit_checkpoint.fields.previous_digest.help": "f1e76ab5745fa68b", "objects.sys_audit_checkpoint.fields.previous_digest.label": "c0df1553d55fcdd6", "objects.sys_audit_checkpoint.fields.root.label": "2a87592c30d680bc", diff --git a/packages/plugins/plugin-audit/src/translations/de.objects.generated.ts b/packages/plugins/plugin-audit/src/translations/de.objects.generated.ts index 591f061b53e..51084d7b4d2 100644 --- a/packages/plugins/plugin-audit/src/translations/de.objects.generated.ts +++ b/packages/plugins/plugin-audit/src/translations/de.objects.generated.ts @@ -330,6 +330,14 @@ export const deObjects: NonNullable = { late: "Late" } }, + part_index: { + label: "Part", + help: "Place among the consecutive checkpoints of at most 10,000 rows its window (or late sealing) is cut into, from 0" + }, + final_part: { + label: "Final Part", + help: "Whether this is the last part of its window (or late sealing)" + }, window_start: { label: "Window Start" }, diff --git a/packages/plugins/plugin-audit/src/translations/de.source-hashes.generated.ts b/packages/plugins/plugin-audit/src/translations/de.source-hashes.generated.ts index 2f248d310f5..2d381650fa1 100644 --- a/packages/plugins/plugin-audit/src/translations/de.source-hashes.generated.ts +++ b/packages/plugins/plugin-audit/src/translations/de.source-hashes.generated.ts @@ -59,6 +59,8 @@ export const deGeneratedSourceHashes: Readonly> = { "objects.sys_audit_checkpoint.fields.columns.help": "789c1b1b474161a1", "objects.sys_audit_checkpoint.fields.columns.label": "c849ea0a39dedbb6", "objects.sys_audit_checkpoint.fields.fencing_token.label": "7e206dcd4b8d3ffc", + "objects.sys_audit_checkpoint.fields.final_part.help": "dd2ea0abf9d27fa3", + "objects.sys_audit_checkpoint.fields.final_part.label": "accc721e7bff52c3", "objects.sys_audit_checkpoint.fields.id.label": "6ace5d591b082096", "objects.sys_audit_checkpoint.fields.kind.help": "893a956c8c781ed6", "objects.sys_audit_checkpoint.fields.kind.label": "3acd2ee4b0e7f2cf", @@ -67,6 +69,8 @@ export const deGeneratedSourceHashes: Readonly> = { "objects.sys_audit_checkpoint.fields.leaf_count.label": "3879d38d4e5176e5", "objects.sys_audit_checkpoint.fields.leaf_hashes.help": "8c59d342be41804c", "objects.sys_audit_checkpoint.fields.leaf_hashes.label": "74230d1d6453537c", + "objects.sys_audit_checkpoint.fields.part_index.help": "37552741e590bfa1", + "objects.sys_audit_checkpoint.fields.part_index.label": "049d919558de58bd", "objects.sys_audit_checkpoint.fields.previous_digest.help": "f1e76ab5745fa68b", "objects.sys_audit_checkpoint.fields.previous_digest.label": "c0df1553d55fcdd6", "objects.sys_audit_checkpoint.fields.root.label": "2a87592c30d680bc", diff --git a/packages/plugins/plugin-audit/src/translations/en.objects.generated.ts b/packages/plugins/plugin-audit/src/translations/en.objects.generated.ts index c9e26ab966b..bbf8b7dc2e7 100644 --- a/packages/plugins/plugin-audit/src/translations/en.objects.generated.ts +++ b/packages/plugins/plugin-audit/src/translations/en.objects.generated.ts @@ -330,6 +330,14 @@ export const enObjects: NonNullable = { late: "Late" } }, + part_index: { + label: "Part", + help: "Place among the consecutive checkpoints of at most 10,000 rows its window (or late sealing) is cut into, from 0" + }, + final_part: { + label: "Final Part", + help: "Whether this is the last part of its window (or late sealing)" + }, window_start: { label: "Window Start" }, diff --git a/packages/plugins/plugin-audit/src/translations/es-ES.objects.generated.ts b/packages/plugins/plugin-audit/src/translations/es-ES.objects.generated.ts index b98dc99e4c7..c18f28f361c 100644 --- a/packages/plugins/plugin-audit/src/translations/es-ES.objects.generated.ts +++ b/packages/plugins/plugin-audit/src/translations/es-ES.objects.generated.ts @@ -330,6 +330,14 @@ export const esESObjects: NonNullable = { late: "Late" } }, + part_index: { + label: "Part", + help: "Place among the consecutive checkpoints of at most 10,000 rows its window (or late sealing) is cut into, from 0" + }, + final_part: { + label: "Final Part", + help: "Whether this is the last part of its window (or late sealing)" + }, window_start: { label: "Window Start" }, diff --git a/packages/plugins/plugin-audit/src/translations/es-ES.source-hashes.generated.ts b/packages/plugins/plugin-audit/src/translations/es-ES.source-hashes.generated.ts index 681d64e4f7e..3ece94a0b20 100644 --- a/packages/plugins/plugin-audit/src/translations/es-ES.source-hashes.generated.ts +++ b/packages/plugins/plugin-audit/src/translations/es-ES.source-hashes.generated.ts @@ -61,6 +61,8 @@ export const esESGeneratedSourceHashes: Readonly> = { "objects.sys_audit_checkpoint.fields.columns.help": "789c1b1b474161a1", "objects.sys_audit_checkpoint.fields.columns.label": "c849ea0a39dedbb6", "objects.sys_audit_checkpoint.fields.fencing_token.label": "7e206dcd4b8d3ffc", + "objects.sys_audit_checkpoint.fields.final_part.help": "dd2ea0abf9d27fa3", + "objects.sys_audit_checkpoint.fields.final_part.label": "accc721e7bff52c3", "objects.sys_audit_checkpoint.fields.id.label": "6ace5d591b082096", "objects.sys_audit_checkpoint.fields.kind.help": "893a956c8c781ed6", "objects.sys_audit_checkpoint.fields.kind.label": "3acd2ee4b0e7f2cf", @@ -69,6 +71,8 @@ export const esESGeneratedSourceHashes: Readonly> = { "objects.sys_audit_checkpoint.fields.leaf_count.label": "3879d38d4e5176e5", "objects.sys_audit_checkpoint.fields.leaf_hashes.help": "8c59d342be41804c", "objects.sys_audit_checkpoint.fields.leaf_hashes.label": "74230d1d6453537c", + "objects.sys_audit_checkpoint.fields.part_index.help": "37552741e590bfa1", + "objects.sys_audit_checkpoint.fields.part_index.label": "049d919558de58bd", "objects.sys_audit_checkpoint.fields.previous_digest.help": "f1e76ab5745fa68b", "objects.sys_audit_checkpoint.fields.previous_digest.label": "c0df1553d55fcdd6", "objects.sys_audit_checkpoint.fields.root.label": "2a87592c30d680bc", diff --git a/packages/plugins/plugin-audit/src/translations/fr.objects.generated.ts b/packages/plugins/plugin-audit/src/translations/fr.objects.generated.ts index f8537f3bbf9..e39562faa0d 100644 --- a/packages/plugins/plugin-audit/src/translations/fr.objects.generated.ts +++ b/packages/plugins/plugin-audit/src/translations/fr.objects.generated.ts @@ -330,6 +330,14 @@ export const frObjects: NonNullable = { late: "Late" } }, + part_index: { + label: "Part", + help: "Place among the consecutive checkpoints of at most 10,000 rows its window (or late sealing) is cut into, from 0" + }, + final_part: { + label: "Final Part", + help: "Whether this is the last part of its window (or late sealing)" + }, window_start: { label: "Window Start" }, diff --git a/packages/plugins/plugin-audit/src/translations/fr.source-hashes.generated.ts b/packages/plugins/plugin-audit/src/translations/fr.source-hashes.generated.ts index fc3fc48aae5..39318b7aa6d 100644 --- a/packages/plugins/plugin-audit/src/translations/fr.source-hashes.generated.ts +++ b/packages/plugins/plugin-audit/src/translations/fr.source-hashes.generated.ts @@ -60,6 +60,8 @@ export const frGeneratedSourceHashes: Readonly> = { "objects.sys_audit_checkpoint.fields.columns.help": "789c1b1b474161a1", "objects.sys_audit_checkpoint.fields.columns.label": "c849ea0a39dedbb6", "objects.sys_audit_checkpoint.fields.fencing_token.label": "7e206dcd4b8d3ffc", + "objects.sys_audit_checkpoint.fields.final_part.help": "dd2ea0abf9d27fa3", + "objects.sys_audit_checkpoint.fields.final_part.label": "accc721e7bff52c3", "objects.sys_audit_checkpoint.fields.id.label": "6ace5d591b082096", "objects.sys_audit_checkpoint.fields.kind.help": "893a956c8c781ed6", "objects.sys_audit_checkpoint.fields.kind.label": "3acd2ee4b0e7f2cf", @@ -68,6 +70,8 @@ export const frGeneratedSourceHashes: Readonly> = { "objects.sys_audit_checkpoint.fields.leaf_count.label": "3879d38d4e5176e5", "objects.sys_audit_checkpoint.fields.leaf_hashes.help": "8c59d342be41804c", "objects.sys_audit_checkpoint.fields.leaf_hashes.label": "74230d1d6453537c", + "objects.sys_audit_checkpoint.fields.part_index.help": "37552741e590bfa1", + "objects.sys_audit_checkpoint.fields.part_index.label": "049d919558de58bd", "objects.sys_audit_checkpoint.fields.previous_digest.help": "f1e76ab5745fa68b", "objects.sys_audit_checkpoint.fields.previous_digest.label": "c0df1553d55fcdd6", "objects.sys_audit_checkpoint.fields.root.label": "2a87592c30d680bc", diff --git a/packages/plugins/plugin-audit/src/translations/ja-JP.objects.generated.ts b/packages/plugins/plugin-audit/src/translations/ja-JP.objects.generated.ts index 45a46342ba7..8a27c35a615 100644 --- a/packages/plugins/plugin-audit/src/translations/ja-JP.objects.generated.ts +++ b/packages/plugins/plugin-audit/src/translations/ja-JP.objects.generated.ts @@ -330,6 +330,14 @@ export const jaJPObjects: NonNullable = { late: "Late" } }, + part_index: { + label: "Part", + help: "Place among the consecutive checkpoints of at most 10,000 rows its window (or late sealing) is cut into, from 0" + }, + final_part: { + label: "Final Part", + help: "Whether this is the last part of its window (or late sealing)" + }, window_start: { label: "Window Start" }, diff --git a/packages/plugins/plugin-audit/src/translations/ja-JP.source-hashes.generated.ts b/packages/plugins/plugin-audit/src/translations/ja-JP.source-hashes.generated.ts index 46ba9ae38fc..ed6a603112c 100644 --- a/packages/plugins/plugin-audit/src/translations/ja-JP.source-hashes.generated.ts +++ b/packages/plugins/plugin-audit/src/translations/ja-JP.source-hashes.generated.ts @@ -60,6 +60,8 @@ export const jaJPGeneratedSourceHashes: Readonly> = { "objects.sys_audit_checkpoint.fields.columns.help": "789c1b1b474161a1", "objects.sys_audit_checkpoint.fields.columns.label": "c849ea0a39dedbb6", "objects.sys_audit_checkpoint.fields.fencing_token.label": "7e206dcd4b8d3ffc", + "objects.sys_audit_checkpoint.fields.final_part.help": "dd2ea0abf9d27fa3", + "objects.sys_audit_checkpoint.fields.final_part.label": "accc721e7bff52c3", "objects.sys_audit_checkpoint.fields.id.label": "6ace5d591b082096", "objects.sys_audit_checkpoint.fields.kind.help": "893a956c8c781ed6", "objects.sys_audit_checkpoint.fields.kind.label": "3acd2ee4b0e7f2cf", @@ -68,6 +70,8 @@ export const jaJPGeneratedSourceHashes: Readonly> = { "objects.sys_audit_checkpoint.fields.leaf_count.label": "3879d38d4e5176e5", "objects.sys_audit_checkpoint.fields.leaf_hashes.help": "8c59d342be41804c", "objects.sys_audit_checkpoint.fields.leaf_hashes.label": "74230d1d6453537c", + "objects.sys_audit_checkpoint.fields.part_index.help": "37552741e590bfa1", + "objects.sys_audit_checkpoint.fields.part_index.label": "049d919558de58bd", "objects.sys_audit_checkpoint.fields.previous_digest.help": "f1e76ab5745fa68b", "objects.sys_audit_checkpoint.fields.previous_digest.label": "c0df1553d55fcdd6", "objects.sys_audit_checkpoint.fields.root.label": "2a87592c30d680bc", diff --git a/packages/plugins/plugin-audit/src/translations/ko.objects.generated.ts b/packages/plugins/plugin-audit/src/translations/ko.objects.generated.ts index 177f2808757..1cbc908f127 100644 --- a/packages/plugins/plugin-audit/src/translations/ko.objects.generated.ts +++ b/packages/plugins/plugin-audit/src/translations/ko.objects.generated.ts @@ -330,6 +330,14 @@ export const koObjects: NonNullable = { late: "Late" } }, + part_index: { + label: "Part", + help: "Place among the consecutive checkpoints of at most 10,000 rows its window (or late sealing) is cut into, from 0" + }, + final_part: { + label: "Final Part", + help: "Whether this is the last part of its window (or late sealing)" + }, window_start: { label: "Window Start" }, diff --git a/packages/plugins/plugin-audit/src/translations/ko.source-hashes.generated.ts b/packages/plugins/plugin-audit/src/translations/ko.source-hashes.generated.ts index d537eeeb984..da7381dd139 100644 --- a/packages/plugins/plugin-audit/src/translations/ko.source-hashes.generated.ts +++ b/packages/plugins/plugin-audit/src/translations/ko.source-hashes.generated.ts @@ -59,6 +59,8 @@ export const koGeneratedSourceHashes: Readonly> = { "objects.sys_audit_checkpoint.fields.columns.help": "789c1b1b474161a1", "objects.sys_audit_checkpoint.fields.columns.label": "c849ea0a39dedbb6", "objects.sys_audit_checkpoint.fields.fencing_token.label": "7e206dcd4b8d3ffc", + "objects.sys_audit_checkpoint.fields.final_part.help": "dd2ea0abf9d27fa3", + "objects.sys_audit_checkpoint.fields.final_part.label": "accc721e7bff52c3", "objects.sys_audit_checkpoint.fields.id.label": "6ace5d591b082096", "objects.sys_audit_checkpoint.fields.kind.help": "893a956c8c781ed6", "objects.sys_audit_checkpoint.fields.kind.label": "3acd2ee4b0e7f2cf", @@ -67,6 +69,8 @@ export const koGeneratedSourceHashes: Readonly> = { "objects.sys_audit_checkpoint.fields.leaf_count.label": "3879d38d4e5176e5", "objects.sys_audit_checkpoint.fields.leaf_hashes.help": "8c59d342be41804c", "objects.sys_audit_checkpoint.fields.leaf_hashes.label": "74230d1d6453537c", + "objects.sys_audit_checkpoint.fields.part_index.help": "37552741e590bfa1", + "objects.sys_audit_checkpoint.fields.part_index.label": "049d919558de58bd", "objects.sys_audit_checkpoint.fields.previous_digest.help": "f1e76ab5745fa68b", "objects.sys_audit_checkpoint.fields.previous_digest.label": "c0df1553d55fcdd6", "objects.sys_audit_checkpoint.fields.root.label": "2a87592c30d680bc", diff --git a/packages/plugins/plugin-audit/src/translations/pt-BR.objects.generated.ts b/packages/plugins/plugin-audit/src/translations/pt-BR.objects.generated.ts index 42ea8a1ffb7..fe1773019bc 100644 --- a/packages/plugins/plugin-audit/src/translations/pt-BR.objects.generated.ts +++ b/packages/plugins/plugin-audit/src/translations/pt-BR.objects.generated.ts @@ -330,6 +330,14 @@ export const ptBRObjects: NonNullable = { late: "Late" } }, + part_index: { + label: "Part", + help: "Place among the consecutive checkpoints of at most 10,000 rows its window (or late sealing) is cut into, from 0" + }, + final_part: { + label: "Final Part", + help: "Whether this is the last part of its window (or late sealing)" + }, window_start: { label: "Window Start" }, diff --git a/packages/plugins/plugin-audit/src/translations/pt-BR.source-hashes.generated.ts b/packages/plugins/plugin-audit/src/translations/pt-BR.source-hashes.generated.ts index e4892929219..427b6abdc23 100644 --- a/packages/plugins/plugin-audit/src/translations/pt-BR.source-hashes.generated.ts +++ b/packages/plugins/plugin-audit/src/translations/pt-BR.source-hashes.generated.ts @@ -59,6 +59,8 @@ export const ptBRGeneratedSourceHashes: Readonly> = { "objects.sys_audit_checkpoint.fields.columns.help": "789c1b1b474161a1", "objects.sys_audit_checkpoint.fields.columns.label": "c849ea0a39dedbb6", "objects.sys_audit_checkpoint.fields.fencing_token.label": "7e206dcd4b8d3ffc", + "objects.sys_audit_checkpoint.fields.final_part.help": "dd2ea0abf9d27fa3", + "objects.sys_audit_checkpoint.fields.final_part.label": "accc721e7bff52c3", "objects.sys_audit_checkpoint.fields.id.label": "6ace5d591b082096", "objects.sys_audit_checkpoint.fields.kind.help": "893a956c8c781ed6", "objects.sys_audit_checkpoint.fields.kind.label": "3acd2ee4b0e7f2cf", @@ -67,6 +69,8 @@ export const ptBRGeneratedSourceHashes: Readonly> = { "objects.sys_audit_checkpoint.fields.leaf_count.label": "3879d38d4e5176e5", "objects.sys_audit_checkpoint.fields.leaf_hashes.help": "8c59d342be41804c", "objects.sys_audit_checkpoint.fields.leaf_hashes.label": "74230d1d6453537c", + "objects.sys_audit_checkpoint.fields.part_index.help": "37552741e590bfa1", + "objects.sys_audit_checkpoint.fields.part_index.label": "049d919558de58bd", "objects.sys_audit_checkpoint.fields.previous_digest.help": "f1e76ab5745fa68b", "objects.sys_audit_checkpoint.fields.previous_digest.label": "c0df1553d55fcdd6", "objects.sys_audit_checkpoint.fields.root.label": "2a87592c30d680bc", diff --git a/packages/plugins/plugin-audit/src/translations/ru.objects.generated.ts b/packages/plugins/plugin-audit/src/translations/ru.objects.generated.ts index e63717ea193..9e357034a38 100644 --- a/packages/plugins/plugin-audit/src/translations/ru.objects.generated.ts +++ b/packages/plugins/plugin-audit/src/translations/ru.objects.generated.ts @@ -330,6 +330,14 @@ export const ruObjects: NonNullable = { late: "Late" } }, + part_index: { + label: "Part", + help: "Place among the consecutive checkpoints of at most 10,000 rows its window (or late sealing) is cut into, from 0" + }, + final_part: { + label: "Final Part", + help: "Whether this is the last part of its window (or late sealing)" + }, window_start: { label: "Window Start" }, diff --git a/packages/plugins/plugin-audit/src/translations/ru.source-hashes.generated.ts b/packages/plugins/plugin-audit/src/translations/ru.source-hashes.generated.ts index 65a725eaa8c..4b11ae59750 100644 --- a/packages/plugins/plugin-audit/src/translations/ru.source-hashes.generated.ts +++ b/packages/plugins/plugin-audit/src/translations/ru.source-hashes.generated.ts @@ -59,6 +59,8 @@ export const ruGeneratedSourceHashes: Readonly> = { "objects.sys_audit_checkpoint.fields.columns.help": "789c1b1b474161a1", "objects.sys_audit_checkpoint.fields.columns.label": "c849ea0a39dedbb6", "objects.sys_audit_checkpoint.fields.fencing_token.label": "7e206dcd4b8d3ffc", + "objects.sys_audit_checkpoint.fields.final_part.help": "dd2ea0abf9d27fa3", + "objects.sys_audit_checkpoint.fields.final_part.label": "accc721e7bff52c3", "objects.sys_audit_checkpoint.fields.id.label": "6ace5d591b082096", "objects.sys_audit_checkpoint.fields.kind.help": "893a956c8c781ed6", "objects.sys_audit_checkpoint.fields.kind.label": "3acd2ee4b0e7f2cf", @@ -67,6 +69,8 @@ export const ruGeneratedSourceHashes: Readonly> = { "objects.sys_audit_checkpoint.fields.leaf_count.label": "3879d38d4e5176e5", "objects.sys_audit_checkpoint.fields.leaf_hashes.help": "8c59d342be41804c", "objects.sys_audit_checkpoint.fields.leaf_hashes.label": "74230d1d6453537c", + "objects.sys_audit_checkpoint.fields.part_index.help": "37552741e590bfa1", + "objects.sys_audit_checkpoint.fields.part_index.label": "049d919558de58bd", "objects.sys_audit_checkpoint.fields.previous_digest.help": "f1e76ab5745fa68b", "objects.sys_audit_checkpoint.fields.previous_digest.label": "c0df1553d55fcdd6", "objects.sys_audit_checkpoint.fields.root.label": "2a87592c30d680bc", diff --git a/packages/plugins/plugin-audit/src/translations/zh-CN.objects.generated.ts b/packages/plugins/plugin-audit/src/translations/zh-CN.objects.generated.ts index 50e55bd8f39..3aa71ad32c9 100644 --- a/packages/plugins/plugin-audit/src/translations/zh-CN.objects.generated.ts +++ b/packages/plugins/plugin-audit/src/translations/zh-CN.objects.generated.ts @@ -330,6 +330,14 @@ export const zhCNObjects: NonNullable = { late: "Late" } }, + part_index: { + label: "Part", + help: "Place among the consecutive checkpoints of at most 10,000 rows its window (or late sealing) is cut into, from 0" + }, + final_part: { + label: "Final Part", + help: "Whether this is the last part of its window (or late sealing)" + }, window_start: { label: "Window Start" }, diff --git a/packages/plugins/plugin-audit/src/translations/zh-CN.source-hashes.generated.ts b/packages/plugins/plugin-audit/src/translations/zh-CN.source-hashes.generated.ts index 1eef8db5fc6..670fbd6c8fa 100644 --- a/packages/plugins/plugin-audit/src/translations/zh-CN.source-hashes.generated.ts +++ b/packages/plugins/plugin-audit/src/translations/zh-CN.source-hashes.generated.ts @@ -60,6 +60,8 @@ export const zhCNGeneratedSourceHashes: Readonly> = { "objects.sys_audit_checkpoint.fields.columns.help": "789c1b1b474161a1", "objects.sys_audit_checkpoint.fields.columns.label": "c849ea0a39dedbb6", "objects.sys_audit_checkpoint.fields.fencing_token.label": "7e206dcd4b8d3ffc", + "objects.sys_audit_checkpoint.fields.final_part.help": "dd2ea0abf9d27fa3", + "objects.sys_audit_checkpoint.fields.final_part.label": "accc721e7bff52c3", "objects.sys_audit_checkpoint.fields.id.label": "6ace5d591b082096", "objects.sys_audit_checkpoint.fields.kind.help": "893a956c8c781ed6", "objects.sys_audit_checkpoint.fields.kind.label": "3acd2ee4b0e7f2cf", @@ -68,6 +70,8 @@ export const zhCNGeneratedSourceHashes: Readonly> = { "objects.sys_audit_checkpoint.fields.leaf_count.label": "3879d38d4e5176e5", "objects.sys_audit_checkpoint.fields.leaf_hashes.help": "8c59d342be41804c", "objects.sys_audit_checkpoint.fields.leaf_hashes.label": "74230d1d6453537c", + "objects.sys_audit_checkpoint.fields.part_index.help": "37552741e590bfa1", + "objects.sys_audit_checkpoint.fields.part_index.label": "049d919558de58bd", "objects.sys_audit_checkpoint.fields.previous_digest.help": "f1e76ab5745fa68b", "objects.sys_audit_checkpoint.fields.previous_digest.label": "c0df1553d55fcdd6", "objects.sys_audit_checkpoint.fields.root.label": "2a87592c30d680bc", diff --git a/packages/plugins/plugin-audit/src/translations/zh-Hant.objects.generated.ts b/packages/plugins/plugin-audit/src/translations/zh-Hant.objects.generated.ts index 06a6b24da85..cd5f51e0df9 100644 --- a/packages/plugins/plugin-audit/src/translations/zh-Hant.objects.generated.ts +++ b/packages/plugins/plugin-audit/src/translations/zh-Hant.objects.generated.ts @@ -330,6 +330,14 @@ export const zhHantObjects: NonNullable = { late: "Late" } }, + part_index: { + label: "Part", + help: "Place among the consecutive checkpoints of at most 10,000 rows its window (or late sealing) is cut into, from 0" + }, + final_part: { + label: "Final Part", + help: "Whether this is the last part of its window (or late sealing)" + }, window_start: { label: "Window Start" }, diff --git a/packages/plugins/plugin-audit/src/translations/zh-Hant.source-hashes.generated.ts b/packages/plugins/plugin-audit/src/translations/zh-Hant.source-hashes.generated.ts index 271fe17738b..f6fa560eadd 100644 --- a/packages/plugins/plugin-audit/src/translations/zh-Hant.source-hashes.generated.ts +++ b/packages/plugins/plugin-audit/src/translations/zh-Hant.source-hashes.generated.ts @@ -59,6 +59,8 @@ export const zhHantGeneratedSourceHashes: Readonly> = { "objects.sys_audit_checkpoint.fields.columns.help": "789c1b1b474161a1", "objects.sys_audit_checkpoint.fields.columns.label": "c849ea0a39dedbb6", "objects.sys_audit_checkpoint.fields.fencing_token.label": "7e206dcd4b8d3ffc", + "objects.sys_audit_checkpoint.fields.final_part.help": "dd2ea0abf9d27fa3", + "objects.sys_audit_checkpoint.fields.final_part.label": "accc721e7bff52c3", "objects.sys_audit_checkpoint.fields.id.label": "6ace5d591b082096", "objects.sys_audit_checkpoint.fields.kind.help": "893a956c8c781ed6", "objects.sys_audit_checkpoint.fields.kind.label": "3acd2ee4b0e7f2cf", @@ -67,6 +69,8 @@ export const zhHantGeneratedSourceHashes: Readonly> = { "objects.sys_audit_checkpoint.fields.leaf_count.label": "3879d38d4e5176e5", "objects.sys_audit_checkpoint.fields.leaf_hashes.help": "8c59d342be41804c", "objects.sys_audit_checkpoint.fields.leaf_hashes.label": "74230d1d6453537c", + "objects.sys_audit_checkpoint.fields.part_index.help": "37552741e590bfa1", + "objects.sys_audit_checkpoint.fields.part_index.label": "049d919558de58bd", "objects.sys_audit_checkpoint.fields.previous_digest.help": "f1e76ab5745fa68b", "objects.sys_audit_checkpoint.fields.previous_digest.label": "c0df1553d55fcdd6", "objects.sys_audit_checkpoint.fields.root.label": "2a87592c30d680bc",