Skip to content

test(id): PoC — game-post with async turn passing on tic-tac-toe (#2266) - #2755

Merged
dezren39 merged 2 commits into
mainfrom
queue/3421-2266-game-post-async-turns-poc
Nov 2, 2026
Merged

dezren39 merged 2 commits into
mainfrom
queue/3421-2266-game-post-async-turns-poc

Conversation

@dezren39

@dezren39 dezren39 commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

What this is

A proof of concept for issue #2266 (follow-on from the #2053 game-post investigation): the async-turns half 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

Point What the test does
1. game-post object game.post names the package by hash + version (sha256 of examples/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.
2. challenge flow challenge.accept by the second player names the post hash; then alternating game.turn objects, each naming the prev_frontier its 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.
3. concession result At game end both players sign a match.result claim over the same frontier. agreed is Some(outcome) only when both signatures verify, both name the same instance and frontier, and both say the same outcome; disagreement or a frontier mismatch yields None (the dispute is visible, not resolved by fiat).
4. save point + fork A save.point over a mid-game frontier; a third ID publishes save.fork naming 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 --nocapture to 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

cargo test --test game_post_async_turns_poc
# 3 passed

Also rustfmt --edition 2024 --check on the new file is clean. cargo clippy could not run in this environment (host clippy-driver 0.1.99 vs the prebuilt dep artifacts on 1.98 — E0514), so clippy is left to CI.

What this does not do

Closes nothing; relates to #2266, #2053, #2037, #2056.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

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
@dezren39
dezren39 requested a review from a team as a code owner October 30, 2026 13:48
@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d42201f6-766c-43c8-94a1-7efb07a59e8a
Commits

Reviewing files that changed from the base of the PR and between 58635f8 and 9681bfc.

Files selected for processing: 1
  • pkgs/id/tests/game_post_async_turns_poc.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T13:51:19.298509Z e69d592 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +343 to +345
for claim in claims {
claim.verify()?;
if claim.field("instance")? != post.field("instance")? {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +524 to +525
let next = turn(&forked_players[0], &post, 0, 4, "8", &mid);
accept_turn(&mut forked_line, next, &forked_players).unwrap();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant