IArchiveLifecycleService
Namespace: Meshmakers.Octo.Runtime.Contracts.StreamData
Orchestrates state-machine transitions for CkArchive entities. DB-neutral: delegates
DDL to IStreamDataRepository and entity reads/writes to the runtime repository
stack. Status changes are audit-trailed via the existing event infrastructure.
public interface IArchiveLifecycleService
Remarks:
Transition rules (see streamdata-archive-concept §3, §11):
Created → Activated: provision Crate table; on DDL failure transition to Failed.
Activated ↔ Disabled: status only, no Crate side-effect.
Failed → Activated: retry DDL; idempotent.
Delete from any state: drop the Crate table and soft-delete the entity (rtState = Archived).
Operation order is always Crate first, Mongo last so retries converge after transient Mongo failures without leaving inconsistent state visible to callers.
Methods
ActivateAsync(OctoObjectId)
Activates the archive: provisions the Crate table and sets status = Activated.
Allowed from Created, Disabled, and Failed. Re-validates all column
paths against the current CK model before any DDL runs.
Task ActivateAsync(OctoObjectId archiveRtId)
Parameters
archiveRtId OctoObjectId
Returns
DisableAsync(OctoObjectId)
Sets status = Disabled. Allowed from Activated. The Crate table is preserved.
Task DisableAsync(OctoObjectId archiveRtId)
Parameters
archiveRtId OctoObjectId
Returns
EnableAsync(OctoObjectId)
Sets status = Activated from Disabled. Re-validates column paths against the
current CK model; performs no DDL because the table already exists.
Task EnableAsync(OctoObjectId archiveRtId)
Parameters
archiveRtId OctoObjectId
Returns
RetryActivationAsync(OctoObjectId)
Retries activation after a previous DDL failure. Allowed only from Failed; identical
effect to IArchiveLifecycleService.ActivateAsync(OctoObjectId).
Task RetryActivationAsync(OctoObjectId archiveRtId)
Parameters
archiveRtId OctoObjectId
Returns
DeleteAsync(OctoObjectId)
Drops the Crate table (idempotent) and soft-deletes the CkArchive entity by setting
rtState = Archived. Allowed from any status.
Task DeleteAsync(OctoObjectId archiveRtId)
Parameters
archiveRtId OctoObjectId
Returns
AddComputedColumnAsync(OctoObjectId, String, String, FormulaResultType, Boolean)
Adds a computed column to an Activated raw or time-range archive and backfills it
(AB#4189 Phase 7, §8). Validates the prospective column set, persists the column
Pending, adds the physical column, backfills the existing rows while the column stays
hidden, then flips it to Active atomically. A backfill failure leaves the column
Failed and the previous archive state intact. Idempotent re-add of the same name reuses
the orphaned physical column.
Task AddComputedColumnAsync(OctoObjectId archiveRtId, string name, string formula, FormulaResultType resultType, bool indexed)
Parameters
archiveRtId OctoObjectId
name String
formula String
resultType FormulaResultType
indexed Boolean
Returns
RemoveComputedColumnAsync(OctoObjectId, String)
Removes a computed column from an archive (AB#4189 Phase 7). Validates that no remaining computed column references it, then drops it from the logical column set; the physical CrateDB column is left as a harmless orphan the read path no longer projects.
Task RemoveComputedColumnAsync(OctoObjectId archiveRtId, string name)
Parameters
archiveRtId OctoObjectId
name String
Returns
UpdateComputedColumnFormulaAsync(OctoObjectId, String, String)
Changes the formula of an existing computed column on an active archive with optimistic / atomic semantics (AB#4189 Phase 7, §8): readers keep seeing the previous formula's values while a backfill populates the new formula into a fresh versioned physical column, then the column-version pointer is swapped atomically. A backfill failure reverts to the previous formula. The result type is unchanged (a formula edit cannot retype the column). No-op when the formula is unchanged.
Task UpdateComputedColumnFormulaAsync(OctoObjectId archiveRtId, string name, string formula)
Parameters
archiveRtId OctoObjectId
name String
formula String