diff --git a/docs/engineering/M11_3_DELIVERY_PLAN.md b/docs/engineering/M11_3_DELIVERY_PLAN.md index 8ab30f4..6dcf85f 100644 --- a/docs/engineering/M11_3_DELIVERY_PLAN.md +++ b/docs/engineering/M11_3_DELIVERY_PLAN.md @@ -191,6 +191,11 @@ scoped change before starting the next segment. tests verify identical retry bytes and reject zero ticks, malformed flags, reserved bytes and noncanonical absent-target addresses. Durable lookup and publication remain open. +- 11.3d-5d: `ActionLedger` now has input-aware single and batch record queries. + Its compatibility implementation exposes legacy outcomes without cellular + bytes, which is insufficient to admit v7 retries and therefore fails closed. + PostgreSQL overrides, exact-byte admission comparison and publication remain + open. ## Exit boundary diff --git a/docs/engineering/VALIDATION.md b/docs/engineering/VALIDATION.md index 924cd17..668bf90 100644 --- a/docs/engineering/VALIDATION.md +++ b/docs/engineering/VALIDATION.md @@ -6152,3 +6152,17 @@ compile/run of the cellular protocol test and codec, plus `git diff --check`. The CMake/Ninja target remains stalled before compilation. `clang-format` and `clang-tidy` are unavailable on this Windows PATH. Durable ledger lookup, PostgreSQL publication, crash resolution and CI remain pending. + +## 2026-10-10 — M11.3d-5d input-aware action ledger API (CI pending) + +Extended `ActionLedger` with single and batch durable-record queries that carry +an optional canonical cellular input beside the final outcome. Its default +adapter preserves existing implementations but returns no cellular input for +legacy rows; that cannot prove an exact v7 retry, so callers must refuse such +reuse. The network regression now asserts this fail-closed compatibility view. + +Executed locally: warning-as-error MSVC 19.44 compile of the updated admission +implementation and network regression translation units, plus `git diff +--check`. The combined network executable was not rebuilt or run locally; CI +must run the network suite. The PostgreSQL implementation, exact-input matching +and cellular publication remain pending. diff --git a/include/evo/network/intent_admission.hpp b/include/evo/network/intent_admission.hpp index dd4b3e6..1b8125b 100644 --- a/include/evo/network/intent_admission.hpp +++ b/include/evo/network/intent_admission.hpp @@ -68,6 +68,13 @@ struct ActionKey { AccountId account; std::uint64_t action_id{}; }; +struct DurableActionRecord { + ActionOutcome outcome; + // Present only for cellular actions. This is the canonical 24-byte biological + // input, independent of the session and epoch used to deliver a retry. + std::optional> cellular_input; + friend bool operator==(const DurableActionRecord&, const DurableActionRecord&) = default; +}; class ActionLedger { public: ActionLedger() = default; @@ -79,6 +86,14 @@ class ActionLedger { [[nodiscard]] virtual std::expected>, ActionLedgerError> find_all(std::span keys); + // Input-aware queries are used by v7 cellular actions. The compatibility + // default preserves legacy ledgers; absence of cellular_input cannot prove + // an exact cellular retry and must be treated as an identity conflict. + [[nodiscard]] virtual std::expected, ActionLedgerError> + find_record(const AccountId& account, std::uint64_t action_id); + [[nodiscard]] virtual std::expected>, + ActionLedgerError> + find_all_records(std::span keys); protected: ActionLedger(ActionLedger&&) = default; diff --git a/src/network/protocol/intent_admission.cpp b/src/network/protocol/intent_admission.cpp index 4c537ba..d929dbd 100644 --- a/src/network/protocol/intent_admission.cpp +++ b/src/network/protocol/intent_admission.cpp @@ -438,6 +438,29 @@ ActionLedger::find_all(std::span keys) { return out; } +std::expected, ActionLedgerError> +ActionLedger::find_record(const AccountId& account, std::uint64_t action_id) { + auto found = find(account, action_id); + if (!found.has_value()) + return std::unexpected(found.error()); + if (!found.value()) + return std::optional{}; + return std::optional{DurableActionRecord{*found.value(), std::nullopt}}; +} + +std::expected>, ActionLedgerError> +ActionLedger::find_all_records(std::span keys) { + std::vector> out; + out.reserve(keys.size()); + for (const auto& key : keys) { + auto found = find_record(key.account, key.action_id); + if (!found.has_value()) + return std::unexpected(found.error()); + out.push_back(*found); + } + return out; +} + IntentAdmission::Found IntentAdmission::lookup(const AccountId& account, std::uint64_t action_id) const { Found f; diff --git a/tests/network_control.cpp b/tests/network_control.cpp index f317c26..fd47c61 100644 --- a/tests/network_control.cpp +++ b/tests/network_control.cpp @@ -477,6 +477,11 @@ void deferred_actions() { return a.admit(session, SessionAction{session, 5, id, 1, tick}, f); }; ledger.records.emplace_back(alice, ActionOutcome{9, ActionResult::committed_no_effect, 40, 3}); + const auto legacy_record = ledger.find_record(alice, 9); + CHECK(legacy_record && legacy_record->has_value() && + legacy_record->value().outcome == + ActionOutcome{9, ActionResult::committed_no_effect, 40, 3} && + !legacy_record->value().cellular_input); CHECK(!admit(1, 9, 101) && !admit(1, 20, 101) && !admit(2, 30, 102)); // In-memory refusals answer at once; a repeat of a waiting action is a duplicate. CHECK(admit(1, 20, 101) == ActionReceipt{20, AdmitStatus::duplicate, 100, 101});