Add M10.4b durable action records (schema v11)
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m47s
Foundation / checks (network) (push) Successful in 9m30s
Foundation / checks (client) (push) Successful in 12m19s
Foundation / checks (tsan) (push) Successful in 7m43s
Foundation / checks (checks) (push) Successful in 31m29s
Foundation / checks (postgres) (push) Successful in 36m39s
Foundation / postgres-tools (push) Successful in 19s
Foundation / image (push) Successful in 2m15s
Foundation / server-image (push) Successful in 20m37s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m47s
Foundation / checks (network) (push) Successful in 9m30s
Foundation / checks (client) (push) Successful in 12m19s
Foundation / checks (tsan) (push) Successful in 7m43s
Foundation / checks (checks) (push) Successful in 31m29s
Foundation / checks (postgres) (push) Successful in 36m39s
Foundation / postgres-tools (push) Successful in 19s
Foundation / image (push) Successful in 2m15s
Foundation / server-image (push) Successful in 20m37s
Each batch's actions are recorded in the same statement as its checkpoint: one region_actions row per (world, account, action id) and the block in an append-only table, compared on exact retries and resolution. The region host attaches actions to the ticks they ride and reports acknowledgements and drops, keeping unknown-outcome batches unresolved. Outcomes come from the durable record via ActionLedger, so crashes before or after a commit, unknown publications and cross-region moves all resolve to one answer; a repeated id keeps its first record instead of stalling a region. ADR-0092. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -34,6 +34,7 @@ struct PreparedCommit {
|
||||
Uuid commit{};
|
||||
std::vector<std::uint8_t> manifest;
|
||||
std::vector<std::uint8_t> decisions;
|
||||
std::vector<std::uint8_t> actions; // Schema v11 block; empty: published without actions.
|
||||
};
|
||||
struct PublicationFailure {
|
||||
PublicationError kind{};
|
||||
@@ -92,7 +93,8 @@ publish_environmental_batch(Postgres& db, const FilesystemObjectStore& objects,
|
||||
const LeaseGrant& lease, const CommittedCheckpoint& predecessor,
|
||||
const RegionBatch<processes::EnvironmentalCommunity>& batch,
|
||||
Uuid commit, const Sha256Digest& build, std::size_t restore_budget,
|
||||
std::chrono::milliseconds timeout, const PublishHooks& hooks = {});
|
||||
std::chrono::milliseconds timeout, const PublishHooks& hooks = {},
|
||||
std::span<const ActionRecord> actions = {});
|
||||
// Loads and fully verifies the committed head before any readiness (ADR-0065):
|
||||
// manifest digest and chain fields, retained build, payload length/SHA-256 and full
|
||||
// restore; then the head's tail: its trace object binds to the committed
|
||||
@@ -119,7 +121,8 @@ publish_lineage_batch(Postgres& db, const FilesystemObjectStore& objects, const
|
||||
const CommittedCheckpoint& predecessor,
|
||||
const RegionBatch<processes::LineageRegion>& batch, Uuid commit,
|
||||
const Sha256Digest& build, std::size_t restore_budget,
|
||||
std::chrono::milliseconds timeout, const PublishHooks& hooks = {});
|
||||
std::chrono::milliseconds timeout, const PublishHooks& hooks = {},
|
||||
std::span<const ActionRecord> actions = {});
|
||||
[[nodiscard]] std::expected<RecoveredLineageCheckpoint, RecoveryFailure>
|
||||
recover_lineage_checkpoint(Postgres& db, const FilesystemObjectStore& objects, RegionKey key,
|
||||
std::span<const Sha256Digest> retained_builds,
|
||||
|
||||
@@ -57,6 +57,22 @@ inline constexpr std::size_t max_batch_decisions = 8;
|
||||
return trace_header_bytes + (static_cast<std::size_t>(ticks) * trace_step_bytes);
|
||||
}
|
||||
|
||||
// M10.4b durable action records (schema v11, ADR-0092): the actions that rode a batch,
|
||||
// committed in the same statement as its checkpoint. Not part of the trace or manifest.
|
||||
inline constexpr std::size_t action_record_bytes = 34;
|
||||
inline constexpr std::size_t max_batch_actions = 1024;
|
||||
struct ActionRecord {
|
||||
Uuid account{};
|
||||
std::uint64_t action_id{}, tick{};
|
||||
std::uint16_t kind{1}; // 1 = probe (no effect).
|
||||
friend bool operator==(const ActionRecord&, const ActionRecord&) = default;
|
||||
};
|
||||
// Canonical block: sorted by (tick, account, id); refuses zero accounts or ids, other kinds,
|
||||
// ticks outside (begin, end], duplicates and more than max_batch_actions records.
|
||||
[[nodiscard]] std::expected<std::vector<std::uint8_t>, BatchError>
|
||||
encode_actions(std::span<const ActionRecord> actions, std::uint64_t begin_tick,
|
||||
std::uint64_t end_tick);
|
||||
|
||||
// One step per tick, begin_tick+1..end_tick, at most 64.
|
||||
[[nodiscard]] std::expected<std::vector<std::uint8_t>, BatchError>
|
||||
encode_trace(const TraceHeader& header, std::span<const TraceStep> steps);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <expected>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <vector>
|
||||
|
||||
@@ -67,6 +68,14 @@ publish_region_checkpoint(Postgres& db, std::span<const std::uint8_t> manifest,
|
||||
std::span<const std::uint8_t> decisions,
|
||||
std::chrono::milliseconds timeout);
|
||||
|
||||
// Schema v11: the same publication with the batch's action block (encode_actions), recorded
|
||||
// in the same statement. The block is part of the commit identity. An action id already on
|
||||
// record in the world keeps its first record (find_region_action is the authority).
|
||||
[[nodiscard]] std::expected<RegionHead, LeaseStoreFailure>
|
||||
publish_region_checkpoint(Postgres& db, std::span<const std::uint8_t> manifest,
|
||||
std::span<const std::uint8_t> decisions,
|
||||
std::span<const std::uint8_t> actions, std::chrono::milliseconds timeout);
|
||||
|
||||
enum class Resolution : std::uint8_t {
|
||||
committed, // Exact bytes are durable; receipt holds the head. Grants no authority.
|
||||
absent, // Not committed now; proves nothing about a request still in flight.
|
||||
@@ -81,6 +90,22 @@ resolve_region_commit(Postgres& db, RegionKey key, const Uuid& commit,
|
||||
std::span<const std::uint8_t> manifest,
|
||||
std::span<const std::uint8_t> decisions, std::chrono::milliseconds timeout);
|
||||
|
||||
// Schema v11 resolution, comparing the action block too.
|
||||
[[nodiscard]] std::expected<ResolvedCommit, LeaseStoreFailure>
|
||||
resolve_region_commit(Postgres& db, RegionKey key, const Uuid& commit,
|
||||
std::span<const std::uint8_t> manifest,
|
||||
std::span<const std::uint8_t> decisions,
|
||||
std::span<const std::uint8_t> actions, std::chrono::milliseconds timeout);
|
||||
// The committed record of an account's action in the lease's world (schema v11), under the
|
||||
// caller's exact lease. Nothing when the action was never committed.
|
||||
struct CommittedAction {
|
||||
std::uint64_t region{}, tick{}, commit_sequence{};
|
||||
friend bool operator==(const CommittedAction&, const CommittedAction&) = default;
|
||||
};
|
||||
[[nodiscard]] std::expected<std::optional<CommittedAction>, LeaseStoreFailure>
|
||||
find_region_action(Postgres& db, RegionKey key, const LeaseGrant& lease, const Uuid& account,
|
||||
std::uint64_t action_id, std::chrono::milliseconds timeout);
|
||||
|
||||
struct CommittedDecision {
|
||||
std::uint64_t commit_sequence{};
|
||||
BatchDecision decision{};
|
||||
|
||||
Reference in New Issue
Block a user