Skip to content

feat: add persistence v0.1 durable state boundary - #21

Open
tim8es wants to merge 2 commits into
mainfrom
feature/persistence-v0-1
Open

feat: add persistence v0.1 durable state boundary#21
tim8es wants to merge 2 commits into
mainfrom
feature/persistence-v0-1

Conversation

@tim8es

@tim8es tim8es commented Aug 29, 2026

Copy link
Copy Markdown
Owner

Summary

Implements issue #16 on feature/persistence-v0-1 from common base 87fbfcf2ed738071f648a3b94bfff1df1f235dba.

This PR is being developed test-first. The initial head contains only persistence contract tests so the permanent Quality workflow can demonstrate the RED phase before production persistence code is added.

Intended persistence model

  • vendor-neutral semantic persistence ports under src/persistence/;
  • D1 as canonical durable operational state;
  • Workspace-scoped Durable Object coordination for mutation ordering;
  • exact (workspaceId, commandId) immutable command receipts;
  • optimistic revisions, durable per-Task fencing, one effective Lease, append-only evidence/history;
  • current-state + audit, not event sourcing;
  • no Cloudflare types in canonical domain/protocol/runtime contracts.

Verification status

  • RED phase: pending permanent Quality run on this tests-only head.
  • Real Cloudflare runtime verification: not yet executed and will not be claimed unless it actually runs.

Closes #16

@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: fe00da920e

ℹ️ 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 +166 to +170
const claims = await Promise.allSettled([
persistence.claimTask({
workspaceId: 'ws-a',
taskId: 'task-a',
sessionId: 'session-a',

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 Exercise claim races through independent coordinators

Both competing calls use the same persistence instance and therefore the same WorkspaceDurableObjectCoordinator; Promise.allSettled only exercises that coordinator's in-memory serialization. An implementation with no database-level compare-and-set or uniqueness guard could pass this test yet grant two active leases when independent coordinator instances or deployments race against the same durable store. Run the claims through independently constructed persistence/coordinator instances sharing the database so this test verifies the durable final guard.

Useful? React with 👍 / 👎.

Comment on lines +317 to +320
await persistence.appendPermissionDecision({
decision: finalDecision,
expectedPreviousDecisionId: initialDecision.id,
});

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 stale permission heads in the contract test

This exercises only the successful case where expectedPreviousDecisionId matches the current head. An implementation that ignores this argument and unconditionally inserts the decision and replaces the head would pass, allowing two human decisions based on the same policy decision to both commit and fork the supposedly single ordered chain. Add a second append with a stale previous-decision ID and assert that it is rejected without changing either history or the head.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

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.

Persistence v0.1: durable state ports, receipts, D1/DO reference

1 participant