Skip to content

Preserve state when audit appends fail - #15

Merged
EauDoon merged 3 commits into
mainfrom
fix/append-before-state-transition
Aug 30, 2026
Merged

Preserve state when audit appends fail#15
EauDoon merged 3 commits into
mainfrom
fix/append-before-state-transition

Conversation

@EauDoon

@EauDoon EauDoon commented Aug 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • Require injected event stores to declare failure-atomic appends.
  • Commit built-in event appends at one non-fallible point, then change transition state.
  • Keep the bound event-store facade nonreplaceable and stage authorization until recovery preflight succeeds.
  • Cover pre-write failures and rejected ambiguous adapters so state, authorization, event count, chain head, and revision remain unchanged.

Verification

  • npm run check (135 tests).

Devin Review

@devin-ai-integration devin-ai-integration 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.

Devin Review found 1 potential issue.

3 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

Comment thread src/rail.js
details_digest: digest(details ?? {}),
});
};
this.eventStore.append(record.action_id, "STATE_TRANSITION", "rail", eventPayload);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 Failed audits retain partial mutations

When append fails, transition preserves the lifecycle state but retains earlier caller mutations. Execution consumes an unused permit, while remediation consumes an unstarted attempt.

Prompt for agents
Make each lifecycle operation failure-atomic for both its transition event and all in-memory record fields changed before that event. Audit callers of transition in src/rail.js, especially execute and remediate: permit_uses and remedy_attempts are incremented before the transition append, and several flows assign reservation, permit, execution, remedy-result, or evidence data before appending. Stage those values until the relevant append succeeds, or restore the complete prior record when append throws. Preserve the required ordering that permit consumption is durably recorded before invoking the connector, and add failure-injection tests at every transition boundary, including transitions after connector side effects.
Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@EauDoon
EauDoon merged commit 6f2faa2 into main Aug 30, 2026
7 checks passed
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