Repository navigation
test(id): PoC — game-post with async turn passing on tic-tac-toe (#2266) - #2755
Conversation
Demonstrates the #2053 game-post model's async-turns mode against the real tic-tac-toe guest (examples/tic-tac-toe/tic-tac-toe.wasm), as a self-contained integration test. PoC only: objects are modelled locally, nothing is wired into the event store, CLI, or board UI. - game-post object naming package hash+version, mode async-turns, two players, attestation concession - challenge acceptance + alternating signed turns, each naming the frontier it builds on, folded through the real Wasm guest; wrong author and stale frontier are refused - paired signed result claims; agreeing claims compute agreed, disagreement and frontier mismatch do not - mid-game save point forked by a third ID; both lines replay independently and the fork object preserves attribution
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 36 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e69d592b44
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for claim in claims { | ||
| claim.verify()?; | ||
| if claim.field("instance")? != post.field("instance")? { |
There was a problem hiding this comment.
Require result claims from both distinct posted players
If the same player's claim is supplied twice, agreed returns Some(outcome) because it verifies signatures without checking their authors against post.body.players or requiring distinct signers. Two outsiders' matching claims also pass. This makes the PoC's concession calculation report agreement without either opponent consenting. Require exactly one verified claim from each posted player and add negative assertions for duplicate and unrelated signers.
Useful? React with 👍 / 👎.
| candidate.field("prev_frontier")? | ||
| )); | ||
| } | ||
| line.push(candidate); |
There was a problem hiding this comment.
Reject no-op moves before advancing the signer rotation
When a correctly signed turn targets an occupied cell, this append advances the expected signer even though the tic-tac-toe guest silently leaves its board and play count unchanged (examples/tic-tac-toe/main.roc:27–28). For example, X plays 0, O plays occupied 0, then X plays 1: all three turns are accepted, but X's last turn places an O because the guest selects marks by successful play count while this validator selects signers by journal length. Validate the candidate transition before appending and reject illegal/no-op moves so they cannot switch control of the marks.
Useful? React with 👍 / 👎.
| let next = turn(&forked_players[0], &post, 0, 4, "8", &mid); | ||
| accept_turn(&mut forked_line, next, &forked_players).unwrap(); |
There was a problem hiding this comment.
Bind fork continuation turns to the new instance
The continuation passes the original post to turn, so its signed instance is the original game's instance rather than the new instance named by branch. Neither construction nor validation of this continuation uses the fork record; the assertions therefore pass while demonstrating only a copied journal with another turn attributed to the original game. Construct the continuation using the fork's instance and assert that its signed instance matches branch.instance, so the PoC actually exercises the claimed independent lineage.
Useful? React with 👍 / 👎.
What this is
A proof of concept for issue #2266 (follow-on from the #2053 game-post investigation): the
async-turnshalf of the game-post model, demonstrated on the existing tic-tac-toe world package.It is one new integration test —
pkgs/id/tests/game_post_async_turns_poc.rs— and nothing else. No production type, no CLI surface, no board UI, no event-store wiring. Per the issue's guardrail, no production game-post feature is claimed under #2266.The four scope points
game.postnames the package by hash + version (sha256ofexamples/tic-tac-toe/tic-tac-toe.wasm,0.1.0),mode: async-turns, both player IDs,attestation: concession, and a genesis frontier. Signed by the poster.challenge.acceptby the second player names the post hash; then alternatinggame.turnobjects, each naming theprev_frontierits author saw. Turns are folded by the real Wasm guest (Sandbox→restore(frontier)→update(participant, move)→snapshot()), so the state is recomputable by anyone holding the journal. No session, no server, nothing live.match.resultclaim over the same frontier.agreedisSome(outcome)only when both signatures verify, both name the same instance and frontier, and both say the same outcome; disagreement or a frontier mismatch yieldsNone(the dispute is visible, not resolved by fiat).save.pointover a mid-game frontier; a third ID publishessave.forknaming that save point, the origin instance, the origin author and the origin frontier, and plays on from the same frontier. Both lines replay independently; the original is untouched.Structural turn enforcement is exercised too: a turn signed by the wrong player, and a turn naming a frontier the line is not at, are both refused.
Object shapes
The last test (
object_shapes_are_documented) emits the full signed objects as one JSON document and re-verifies every one of them after a round-trip; run it with--nocaptureto print them. Envelope used throughout, local to the PoC:{ "kind": "game.post | challenge.accept | game.turn | match.result | save.point | save.fork", "author": "<hex ed25519 public key>", "hash": "<hex sha256 over canonical (kind, body)>", "signature": "<hex ed25519 signature over the same bytes>", "body": { "...kind-specific fields..." } }Deliberate difference from
artifact::SignedArtifact: the chain fields (seq/prev/after) are replaced by explicit lineage references inside the body (instance,prev_frontier), because a turn is ordered by the game's frontier, not by the author's per-key sequence. That is a finding, not an oversight — see the note on #2266.Tests
Also
rustfmt --edition 2024 --checkon the new file is clean.cargo clippycould not run in this environment (hostclippy-driver0.1.99 vs the prebuilt dep artifacts on 1.98 —E0514), so clippy is left to CI.What this does not do
witnessedattestation, no handoff/acceptance chain (that is the succession mode, id: design: ID boards v1 #2054's).Closes nothing; relates to #2266, #2053, #2037, #2056.
Need help on this PR? Tag
@codesmith-botwith what you need.