Files

5.6 KiB

Dispatch authenticated session commands with exact retry outcomes

Task ID: S16-01 Role: sol_implementer Status: READY

1. Context and baseline

Exclusive /home/faumaray/Projects/stoneheart_at_home-worktrees/s16 system/s16-authority, 8d2870a. Main checkout is a different task. F2/F3 and M01-P2 approve this scope; pinned Void 7b0fea6, upstream gap Void/Library#6.

2. Objective and deliverables

Implement S16-W01 game command admission/dispatch in a single-owner component plus integration tests with two trusted client handles. Expose a frozen interface for S01 runtime and modern transport.

3. Scope and non-goals

S16 dispatcher only, no sockets/UI/clock or save format. Preserve legacy World::apply_command behavior and LAN11 decoding for existing callers.

4. Files to inspect

Inspect world.hpp, world.cpp World::next_command_sequence/apply_command and queue_cabin, app/lan_wire.cpp, tests/core_tests.cpp, docs/plan/systems/S16.md. Void/Core/Uuid.hpp at exact pin supplies nonnil identities/try_v4; source stubs/compile headers from known library checkout.

5. Write ownership and coordination

Write scope: engine/include/settlement/core/command_dispatcher.hpp; engine/src/command_dispatcher.cpp; tests/session_tests.cpp; CMakeLists.txt You are not alone. All writes only to specified worktree with explicit absolute paths/workdir. Root integrates branches and CMake; no switching shared Serena, changing others' files, committing/pushing or spawning.

6. Implementation or investigation approach

Use one host dispatcher per world/session and one shared city for M01 (plus disallowed city test). Authenticate caller via trusted local connection slot passed separately, never trust payload player. Envelope includes version, nonnil world+session UUID, city, uint64 request id, game action fields. Per trusted client require contiguous monotonic numbers from 1. Session/identity/version and trusted slot validated before any cached response. For full payload and city equal to an existing key, replay original outcome; reject ID reuse with a changed payload (compare all fields) without mutation. Persist accepted and completed rejected results within session until replaced. Global or per-client configurable capacity: Busy before NEW requests at capacity; honor all previously admitted receipts, no eviction/reexecution. Stale/out-of-order/busy transient errors don't consume request; completed domain rejections do. Store or reserve result before applying effect. Do not silently drop prior receipts on exceptions; runtime will retire faulted owner and session before more commands.

7. Interfaces and data contracts

NEW CommandEnvelope/CommandPayload, session identity (using Void::Uuid::Uuid or fixed byte-compatible game type), target city and explicit outcomes incl status, assigned tick and revision; trusted player is supplied to dispatcher, not a payload identity. Map payload to PlayerCommand using World::next_command_sequence after auth, with no change to legacy sequences on rejection. Provide bounded acceptance path for legacy queue_cabin when needed by viewer (new owner command, preserve checked prerequisite and return outcome) or report exact adaptation to root. New command and session types should be usable without event loop. Share exact API with root early.

8. Dependencies and integration

Consumers S01 runtime, S15 checkpoint and modern transport. Worker owns CMake additions in isolated branch; link Void::Core PUBLIC only if publicly required. Reference #6 in companion task + local source/milestone decision with replacement check. No extra generic ledger.

9. Edge cases security and performance

Check nonnil IDs, invalid/unsupported action, sequence zero, overflow, two clients same request numbers, different payload/city, old world/session, accepted and failed duplicates even after later requests, capacity and exception-safe reservation. Old rejection corrected under a new envelope ID must still use correct World sequence. No hidden trust from bytes.

10. Acceptance criteria

  1. Two clients converge and repeat accepted/rejected commands without reapplication, including after newer requests. 2. Stale after rollback and wrong city/identity rejected with identical world bytes. 3. Changed payload, exhaustion, unsupported version/order bounded and tested. 4. Legacy and new tests build/run using actual World. Header communicates semantics to runtime.

11. Verification commands and evidence

Source /tmp/stoneheart-verify.KoZwE4o8/env.sh. From YOUR worktree configure cmake -S . -B /tmp/stoneheart-milestones.xprJ2SVp/session-build -G Ninja --toolchain "$SETTLEMENT_VERIFY/cross.cmake" -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release -DFETCHCONTENT_SOURCE_DIR_VOID_LIBRARY:PATH="$SETTLEMENT_VERIFY/candidate/_deps/void_library-src". Build with cmake --build --parallel 6, run ctest --test-dir --output-on-failure and your targeted tests. Evidence required. Tag new tests session, including positive effects and exact repeat receipt tick/revision. Report performance bounds by inspection.

12. Constraints and stop conditions

Escalate required cross-branch changes, genuine ambiguity or two failed repairs; use direct source in this worktree instead of querying the main graph as if it were the same checkout. No external actions.

13. Authorization and decisions

User authorized full roadmap and branches/commits/push; root owns remote actions. F3 READY for S16 dispatcher under above semantics.

14. Return format

Return S16-01 status, actual files and public interface early, semantics/complexity, test and build counts, gaps, runtime integration notes. No subagents.