Skip to content

feat(id-core): freshness token + frontier check as pure logic (#13094) - #13151

Open
dezren39 wants to merge 1 commit into
mainfrom
xaltha/13094-freshness-token
Open

dezren39 wants to merge 1 commit into
mainfrom
xaltha/13094-freshness-token

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Closes #13094

Implements §6 of the #9128 design record (doc/2026-11-23_design_id9128_social_app_reference_model.md) as pure logic in id-core — new module crates/id-core/src/freshness.rs, no I/O, no store access, no clock:

  • FreshnessToken (§6.1): view_id (BLAKE3 hash of the canonical view definition), frontier, issued_at (informational only — tokens do not expire by time, §8.5), server identity, and an ed25519 signature. Signing follows the Part A conventions: fixed domain-prefixed preimage (id/freshness-token/v1\0) over the canonical-CBOR encoding of the signed fields. Full canonical encode/decode; every field is critical on decode, so an unknown or malformed field is a rejection, never a silent drop.
  • Frontier (§6.2): per-input high-water marks. List inputs carry the accepted head sequence (design(id): append-list user-attribute protocol — signed submission, server order, pending queue #9127 §4) plus the tombstone-set revision (design(id): true-delete + moderation pipeline #9130) that filters the list; relation inputs carry the projection checkpoint (research(id): triple encoding bake-off — compressed binary vs JSONB vs normalized byte-key maps #9125). Comparison is the component-wise product partial order — a frontier is unchanged iff every component equals; components that diverged or changed kind are incomparable.
  • check_freshness (§6.3): the verdict as a pure function of the presented token, the expected view/server, the current frontier, and the server's retention floor (oldest_reachable):
    • NoToken — absent, or signature/view/server verification failed. Per §6.5 a forged or foreign token is treated as no token (full view fetch), never as an error.
    • NothingNew — frontier unchanged; the server re-issues with a fresh issued_at.
    • Delta — names exactly the advanced inputs, each with the token's per-input after position (the append-read after-seq for list inputs, design(id): append-list user-attribute protocol — signed submission, server order, pending queue #9127 §3). A since-date token is just an old token on this path (§6.4).
    • Resync — the token's frontier is unreachable: below the retention floor, beyond the current frontier, diverged from it, or covering a changed input set.

The before-date form (§6.4) renders against a pinned frontier — that is the view builder's job (#13096); the Frontier/FreshnessToken types here are the seam #13095 and #13096 build on.

Tests

18 unit tests walking the §6.3 check table row by row (nothing-new at the current frontier; delta naming exactly the advanced inputs, including a tombstone-revision-only advance; resync below the floor / beyond current / diverged / changed input set; forged signature, wrong view, and foreign server all yielding NoToken; canonical encode/decode round-trip with critical-field rejection) plus 4 proptest properties: frontier comparison reflexivity, transitive consistency, the §6.3 verdict oracle over generated frontier pairs, and the retention-floor resync.

Verification

  • Remote dispatch (per the 2026-11-23 remote-only build/test directive): cargo test --manifest-path pkgs/id/Cargo.toml -p id-core --lib on this branch, dispatch handle fp_b28e233d8fae833289d8bed22f8981f1. At the time of this PR the job is still queued — every placement tier reported exhausted at submission (GitHub-hosted surfaces full/standby, Blacksmith budget spent) and the job is recorded, never dropped; track it with fleet queue session status fp_b28e233d8fae833289d8bed22f8981f1 (run URL appears there once a run correlates).
  • Sandbox evidence gathered before that directive landed mid-task (local rustup 1.99.0, labelled as sandbox evidence): freshness tests 22 passed / 0 failed (18 unit + 4 proptest); full id-core lib suite 562 passed / 0 failed / 1 ignored; cargo clippy -p id-core --all-targets reports no warnings in freshness.rs; check-rust-module-reach.sh shows no new unreached files (the 12 pre-existing ones in id-config/id-core/id-store are untouched by this change).

See it in action
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Implements #9128 design §6 in id-core (new freshness module):

- FreshnessToken: view_id (hash of the canonical view definition),
  frontier, issued_at, server identity, ed25519 signature over the
  canonical-CBOR encoding of the signed fields, with a fixed
  domain-prefixed signature preimage per the Part A conventions.
  Full canonical encode/decode; every field critical on decode.
- Frontier: per-input high-water marks — list inputs carry the
  accepted head sequence (#9127 §4) plus the tombstone-set revision
  (#9130); relation inputs carry the projection checkpoint (#9125).
  Component-wise product partial order: unchanged iff every
  component equals; diverged or kind-changed components are
  incomparable.
- check_freshness: the §6.3 verdict as a pure function — NoToken
  (absent, or signature/view/server verification failed; §6.5:
  treated as no token, never an error), NothingNew, Delta naming
  exactly the advanced inputs with the token's per-input after
  positions, Resync when the token's frontier is unreachable
  (below the server's retention floor, beyond current, diverged,
  or a changed input set).

Tests: 18 unit tests walking the §6.3 check table row by row plus
4 proptest properties (order reflexivity, transitive consistency,
the §6.3 verdict oracle over generated frontier pairs, and the
retention-floor resync). The Frontier/FreshnessToken types are the
seam #13095/#13096 build on.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T09:24:10.560494Z 71ec29f 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.

@coderabbitai

coderabbitai Bot commented Nov 23, 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 49 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: e0a61ad6-73fd-4464-ad56-8b2fc4709a0b
Commits

Reviewing files that changed from the base of the PR and between d220c7b and 71ec29f.

Files selected for processing: 2

  • pkgs/id/crates/id-core/src/freshness.rs
  • pkgs/id/crates/id-core/src/lib.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

This branch has not been deployed

No deployments
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.

impl(id): freshness token + frontier check in id-core (per #9128 design)

1 participant