Skip to content

fix(api): an exec session's closing is decided under a lock on the session (closes #489) - #562

Merged
samuelmbabhazi merged 3 commits into
mainfrom
fix/489-closing-lock
Nov 29, 2026
Merged

samuelmbabhazi merged 3 commits into
mainfrom
fix/489-closing-lock

Conversation

@samuelmbabhazi

@samuelmbabhazi samuelmbabhazi commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

What

This PR fixes the follow-up reopened on #489: an exec session's closing is now decided atomically, once per session.

Before, three paths each read the session's closings, then published one, in two separate steps: the check (the startup sweep and the queue's worker), the retry of the session's end, and another API process's check. Two of them could both find no closing and both publish one.

  • ExecSessionClosingLock, a new port in fleet/application/ports.ts. Its PostgreSQL adapter is PrismaExecSessionClosingLock, which takes pg_advisory_xact_lock on a key hashed from the session's id. This follows the placement and registry locks.
    • The lock is held until the tenant transaction commits or rolls back.
    • The isolation level is READ COMMITTED, so the next holder's read sees what the previous holder committed.
    • It refuses to run outside a transaction, where it would be released at once.
  • ExecSessionRegistry.closeOnce(session, closing) takes the lock, reads the closings, and publishes only when none is recorded. The end, each of its retries, and the checks all go through it. The end's first attempt now also reads before it writes, so a closing recorded by another process's check is never contradicted.
  • The check skips a session whose end this process is still writing (ending(id)): it reschedules it as it does a live one, so its own process's end is not raced at all.
  • SPEC 3.1 describes the lock and that case.

Why

The issue asks for exactly one closing per session, as an end or as an interruption, even when checks, retries and processes overlap. The lock is the "equivalent serialization" the issue allows. It needs no schema change and no new constraint on the audit table.

How it was tested

  • Unit tests (exec-relay.spec.ts) check that the lock is taken before the closings are read, that nothing is published when a closing exists, and that the end goes through the lock and reports ending until it is written. The relay tests that waited one microtask now wait on settle, because publishing comes after the lock and the read.
  • Integration tests against PostgreSQL (exec-session-checks.integration.spec.ts):
    • eight checks of one session run at once and record a single exec.session.interrupted;
    • a session's end races another process's check, and exactly one closing is recorded;
    • a check finds a session whose end is still being written, answers live, and only exec.session.ended is recorded.
  • Mutation: with the lock turned into a no-op, the race between an end and a check failed 3 runs out of 3, and the race between checks failed 2 out of 3. With the lock, both passed 3 out of 3.
  • Full local run:
    • 1004 API unit tests pass.
    • The integration suite passes against PostgreSQL 18, except two kinds of known local failures:
      • the 3 ON DELETE RESTRICT tests that PostgreSQL 18 answers with 23001 instead of 23503;
      • the 4 files that need Docker through Testcontainers, which this machine's sandbox does not have.
  • api:lint and api:typecheck pass.

Security considerations

  • Audit: this change strengthens guarantee 6 (every state change is audited) for exec sessions.
  • Connections: they are still released at once when audit storage is down; the lock is taken only in the audit write's own transaction.
  • Logs: no new data is logged.
  • Lock key: it is a SHA-256 of the session's id. A hash collision only makes two sessions' closings wait for each other.

Closes #489.

Summary by CodeRabbit

  • Bug Fixes
    • Prevented duplicate session-closing events when checks or retries overlap, including when an earlier write’s result is uncertain.
    • Sessions remain reported as live while their closing event is being recorded, then reflect the recorded status after the write completes.
  • Documentation
    • Clarified how session checks, retries, and startup handling work for sessions that are still live or being closed.

…ssion

A check, a retry of the end and another process's check each took the closing decision in two steps: read the closings, then publish one. Two of them could both find none and record two closings. The decision now takes a PostgreSQL transaction-level advisory lock on the session first, and a check finds a session whose end this process is still writing and looks at it again later. Closes #489.

Signed-off-by: samuel mbabhazi <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Explain Change →

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 47 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

Commits

Reviewing files that changed from the base of the PR and between b8cddc0 and 2897874.

Files selected for processing: 11

  • apps/api/src/modules/deployments/application/exec-sessions.spec.ts
  • apps/api/src/modules/deployments/interface/exec-socket.spec.ts
  • apps/api/src/modules/fleet/application/exec-relay.spec.ts
  • apps/api/src/modules/fleet/application/exec-relay.ts
  • apps/api/src/modules/fleet/application/ports.ts
  • apps/api/src/modules/fleet/exec-session-checks.integration.spec.ts
  • apps/api/src/modules/fleet/fleet.module.ts
  • apps/api/src/modules/fleet/infrastructure/exec-session-checks.ts
  • apps/api/src/modules/fleet/infrastructure/prisma-exec-session-closing-lock.ts
  • apps/api/src/modules/fleet/interface/exec-stream.spec.ts
  • docs/SPEC.md

No actionable comments were generated in the recent review.

Walkthrough

Exec-session closing decisions now use a session-scoped PostgreSQL advisory lock and check for an existing closing event before publishing. Retry attempts use the same check. Session checks reschedule sessions that are pending or ending, and tests cover concurrent checks and writes.

Changes: Exec-session closing coordination

Layer / File(s) Summary
Session closing lock
apps/api/src/modules/fleet/application/ports.ts, apps/api/src/modules/fleet/infrastructure/prisma-exec-session-closing-lock.ts, apps/api/src/modules/fleet/fleet.module.ts
A closing-lock interface and dependency token are added. The Prisma implementation requires an active transaction and acquires an advisory lock keyed by session ID. FleetModule registers the implementation.
Registry closing and retries
apps/api/src/modules/fleet/application/exec-relay.ts, apps/api/src/modules/fleet/application/exec-relay.spec.ts, apps/api/src/modules/deployments/application/exec-sessions.spec.ts, apps/api/src/modules/deployments/interface/exec-socket.spec.ts, apps/api/src/modules/fleet/interface/exec-stream.spec.ts
The registry tracks ending writes by session ID. closeOnce locks the session, checks for a prior closing event, and publishes only when none exists. Each retry runs this check inside a tenant transaction. Tests cover ordering, existing closings, and ending-state tracking.
Session checks and race coverage
apps/api/src/modules/fleet/infrastructure/exec-session-checks.ts, apps/api/src/modules/fleet/exec-session-checks.integration.spec.ts, docs/SPEC.md
Checks reschedule sessions that are pending or ending. Other valid sessions use closeOnce to record an interruption. Integration tests cover concurrent checks and end writes; the specification describes the locking and retry behavior.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant ExecSessionChecks
  participant FleetTransaction
  participant ExecSessionRegistry
  participant ExecSessionClosingLock
  participant AuditEventReader
  participant DomainEventBus
  ExecSessionChecks->>FleetTransaction: Run tenant transaction
  FleetTransaction->>ExecSessionRegistry: closeOnce(session, interruption)
  ExecSessionRegistry->>ExecSessionClosingLock: lock(sessionId)
  ExecSessionRegistry->>AuditEventReader: Check for existing closing
  ExecSessionRegistry->>DomainEventBus: Publish closing event if none exists
Loading

Possibly related issues

  • #489 — The changes coordinate closing decisions and prevent duplicate or contradictory closings. They do not add persistent retry or restart reconciliation.

Possibly related PRs

Merge Risk: Low · previous review b8cdd

The change serializes exec-session closing decisions under a per-session database lock, so overlapping checks and end attempts record a single closing event. No concrete defect was found in that path. The linked issue also asks for retry after storage failure and restart reconciliation, which this change does not appear to deliver. Confirm whether that issue should stay open before merging, and make sure the integration tests that could not run locally pass in CI.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive Directly linked issue #489 has these coding objectives:
(a) one durable closing per session when checks, retries, and processes overlap;
(b) eventual recording after a transient write failure once sto…
Confirm which #489 outcomes this PR must deliver. Either (1) narrow the PR's linkage so it does not close #489, or (2) provide evidence that the existing startup sweep and in-process retry meet criteria (b) and (c), with tests for transient…
Passed Passed checks: 3 passed

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: exec session closing is now decided under a lock on the session. The changeset adds an ExecSessionClosingLock port, a PostgreSQL advisory-lock adapter, and ExecSession…
Out of Scope Changes check Passed Every changed file serves the closing-atomicity objective or supports it:
- ports.ts: the new ExecSessionClosingLock port and its injection token.
- prisma-exec-session-closing-lock.ts: the Post…
Full details: Title check

Explanation

The title names the main change: exec session closing is now decided under a lock on the session. The changeset adds an ExecSessionClosingLock port, a PostgreSQL advisory-lock adapter, and ExecSessionRegistry.closeOnce, which route closing decisions through that lock. The title also references issue #489, which the PR text says it closes, although the described solution targets atomicity of overlapping operations rather than the issue's full retry and restart reconciliation scope. The title is specific and accurate for the primary change.

Full details: Out of Scope Changes check

Explanation

Every changed file serves the closing-atomicity objective or supports it:

  • ports.ts: the new ExecSessionClosingLock port and its injection token.
  • prisma-exec-session-closing-lock.ts: the PostgreSQL advisory-lock adapter. It requires a transaction and derives the key by hashing the session id.
  • exec-relay.ts: closeOnce, ending, and the session-keyed write map. The end's first attempt now reads before it writes.
  • exec-session-checks.ts: checks use closeOnce, and checks reschedule a session whose end is still being written. The unused DomainEventBus dependency is removed.
  • fleet.module.ts: provider binding for the lock.
  • Spec files that add the lock stub or the new registry constructor argument: wiring only.
  • exec-relay.spec.ts and exec-session-checks.integration.spec.ts: tests for the lock, the closing-once rule, and the ending case.
  • docs/SPEC.md: describes the lock and the ending case.

No change addresses an unrelated feature. The changes that do not add tests are wiring or documentation for this objective.

Full details: Linked Issues check

Explanation

Directly linked issue #489 has these coding objectives:
(a) one durable closing per session when checks, retries, and processes overlap;
(b) eventual recording after a transient write failure once storage recovers;
(c) restart reconciliation that records a truthful interrupted or unknown outcome;
(d) prompt transport cleanup during storage failure;
(e) tests for closure, transient failure, retry, duplicates, and restart reconciliation.

Objective (a) is addressed. ExecSessionRegistry.closeOnce takes ExecSessionClosingLock.lock(session.id), then reads the closings and publishes only if none exists. PrismaExecSessionClosingLock takes pg_advisory_xact_lock inside the tenant transaction. The end's retry loop (record) and ExecSessionChecks.check both use closeOnce. Integration tests cover concurrent checks and an end/check race. The mutation results in the PR description support this.

Objective (d) is largely pre-existing. ended removes the relay before the audit write, and endAll/settle do not hold the connection for storage. The diff does not change this path.

Objectives (b) and (c) are only partly evidenced. At head, record retries up to CLOSE_ATTEMPTS (20) times in process memory. After that, the session check records exec.session.interrupted. The PR does not add persisted lifecycle state or restart reconciliation. The PR description and the PR objectives both say so. The interrupted outcome may satisfy the issue's 'truthful interrupted/unknown' wording. I did not confirm that the existing startup sweep covers orphaned sessions after restart, because that code is outside this diff and I did not inspect it.

Objective (e) is partly met. The new tests cover concurrency, not transient write failure followed by recovery, the retry path, duplicate callbacks, or restart reconciliation. I did not find tests for these in the changed files, but I did not search the full test suite.

The PR states that it closes #489 while its described solution covers only atomicity under overlap. Whether that meets the issue is a scope decision that the available evidence does not settle.

Resolution

Confirm which #489 outcomes this PR must deliver. Either (1) narrow the PR's linkage so it does not close #489, or (2) provide evidence that the existing startup sweep and in-process retry meet criteria (b) and (c), with tests for transient write failure, retry, duplicates, and restart reconciliation, located at the reviewed head. Then re-run this assessment.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • 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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between dd9ea92 and b8cddc0.

Files selected for processing: 11

  • apps/api/src/modules/deployments/application/exec-sessions.spec.ts
  • apps/api/src/modules/deployments/interface/exec-socket.spec.ts
  • apps/api/src/modules/fleet/application/exec-relay.spec.ts
  • apps/api/src/modules/fleet/application/exec-relay.ts
  • apps/api/src/modules/fleet/application/ports.ts
  • apps/api/src/modules/fleet/exec-session-checks.integration.spec.ts
  • apps/api/src/modules/fleet/fleet.module.ts
  • apps/api/src/modules/fleet/infrastructure/exec-session-checks.ts
  • apps/api/src/modules/fleet/infrastructure/prisma-exec-session-closing-lock.ts
  • apps/api/src/modules/fleet/interface/exec-stream.spec.ts
  • docs/SPEC.md

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator Author

@coderabbitai About the inconclusive Linked Issues check: #489 has two parts.

The original issue (criteria a to f) was closed by #511 on 2026-11-26. Its retry and restart tests are still at this PR's head (b8cddc0):

  • Transient write failure, then retry: exec-relay.spec.ts, "records the end once the audit store answers again, and only once". The first write fails. The second one commits, but its answer is lost. Exactly one exec.session.ended is recorded.
  • Transport released during the failure: "ends the session even when its audit write fails".
  • Restart reconciliation: exec-session-checks.integration.spec.ts, against PostgreSQL, "records interrupted, once, the session of a stopped process". A session queued by a process that stopped is found by the next process's startup sweep() and recorded as exec.session.interrupted. Its later job then finds the closing and records nothing more.

The reopening on 2026-11-27 asked for one thing: an atomic closing decision per session, so that overlapping checks, retries and processes cannot each publish a closing. Its acceptance is PostgreSQL races of recovery against recovery, and of an ending against recovery, each with exactly one closing outcome. Lost-response retries stay idempotent, restart recovery still works, and cleanup stays prompt. This PR delivers that:

  • the lock and closeOnce;
  • the integration tests "records one closing when checks of a session race" and "records one closing when a session's end and another process's check race";
  • the tests above, still passing.

So closing #489 here is intended: nothing from either part is left open.

@coderabbitai

coderabbitai Bot commented Nov 29, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

Analysis chain

Script executed:

#!/bin/bash
set +e
printf '%s\n' '--- revision ---'
git rev-parse HEAD
gh pr view 562 --repo shipkeepdev/shipkeep --json headRefOid,updatedAt,mergeStateStatus --jq '{headRefOid,updatedAt,mergeStateStatus}'
printf '%s\n' '--- named file outlines ---'
for f in apps/api/src/modules/fleet/application/exec-relay.spec.ts apps/api/src/modules/fleet/exec-session-checks.integration.spec.ts apps/api/src/modules/fleet/application/exec-relay.ts apps/api/src/modules/fleet/infrastructure/exec-session-checks.ts; do
  echo "--- $f"
  ast-grep outline "$f" --items all --match 'ExecSession|record|settle|sweep|check|end' 2>&1 | head -100
done
printf '%s\n' '--- named test locations ---'
rg -n -C3 'records the end once the audit store answers again, and only once|ends the session even when its audit write fails|records interrupted, once, the session of a stopped process|records one closing when checks of a session race|records one closing when a session.s end and another process.s check race' apps/api/src/modules/fleet/application/exec-relay.spec.ts apps/api/src/modules/fleet/exec-session-checks.integration.spec.ts
printf '%s\n' '--- sweep and recovery references ---'
rg -n -C4 '\bsweep\s*\(|CLOSE_ATTEMPTS|async (record|closeOnce|check)\s*\(' apps/api/src/modules/fleet/application/exec-relay.ts apps/api/src/modules/fleet/infrastructure/exec-session-checks.ts
printf '%s\n' '--- issue ---'
gh api repos/shipkeepdev/shipkeep/issues/489 --jq '{number,state,title,body,closed_at,updated_at}' 2>&1
printf '%s\n' '--- issue comments ---'
gh api --paginate repos/shipkeepdev/shipkeep/issues/489/comments --jq '.[] | {created_at,user:.user.login,body}' 2>&1
printf '%s\n' '--- issue timeline ---'
gh api --paginate -H 'Accept: application/vnd.github+json' repos/shipkeepdev/shipkeep/issues/489/timeline --jq '.[] | select(.event == "closed" or .event == "reopened" or .event == "cross-referenced") | {event,created_at,actor:.actor.login,source:(.source.issue | {number,title,state,pull_request})}' 2>&1
printf '%s\n' '--- earlier pull request ---'
gh pr view 511 --repo shipkeepdev/shipkeep --json number,title,state,mergedAt,body --jq '{number,title,state,mergedAt,body}' 2>&1

Length of output: 26255


Script executed:

#!/bin/bash
set +e
printf '%s\n' '--- unit tests ---'
cat -n apps/api/src/modules/fleet/application/exec-relay.spec.ts | sed -n '245,335p'
printf '%s\n' '--- integration tests ---'
cat -n apps/api/src/modules/fleet/exec-session-checks.integration.spec.ts | sed -n '1,160p'
printf '%s\n' '--- check startup and recovery ---'
cat -n apps/api/src/modules/fleet/infrastructure/exec-session-checks.ts | sed -n '34,155p'
printf '%s\n' '--- closing and retry implementation ---'
cat -n apps/api/src/modules/fleet/application/exec-relay.ts | sed -n '248,305p;360,420p'
printf '%s\n' '--- startup calls ---'
rg -n -C4 'ExecSessionChecks|\.start\(' apps/api/src/main.ts apps/api/src/modules/fleet/fleet.module.ts
printf '%s\n' '--- pull request checks ---'
gh pr checks 562 --repo shipkeepdev/shipkeep 2>&1

Length of output: 29451


@samuelmbabhazi Thanks for the clarification. I missed the existing recovery tests and the narrower scope of the reopening.

At b8cddc00, I confirmed the retry and lost-response test, the failed-write cleanup test, the startup sweep test, and both PostgreSQL race tests. The restart test simulates a stopped process; the end/check race simulates the other process’s closing decision.

I no longer recommend narrowing the #489 closing link or adding a separate retry and restart implementation for this PR. The saved Linked Issues assessment is not refreshed by this reply.

GitHub reported the TypeScript and PostgreSQL/Docker integration checks as passing. It also reported the PR merge state as BEHIND. Please check whether a base update is required and rerun required checks on the final revision.


Learnings added

Learnt from: samuelmbabhazi
URL: https://github.com/shipkeepdev/shipkeep/pull/562

Timestamp: 2026-11-29T08:10:03.882Z
Learning: Within repository "shipkeepdev/shipkeep", only for files matching one of ["apps/api/src/modules/fleet/application/exec-relay.ts","apps/api/src/modules/fleet/infrastructure/exec-session-checks.ts"]: For exec-session closing recovery in apps/api/src/modules/fleet/application/exec-relay.ts and apps/api/src/modules/fleet/infrastructure/exec-session-checks.ts, do not assume that in-process end retries are the only recovery mechanism. A session's already queued check can survive a stopped process and be handled by the next process's startup sweep, which records exec.session.interrupted if no closing is recorded and the session is not pending or ending in that process.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


Learnings used

Learnt from: CR
Repo: shipkeepdev/shipkeep PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-11-08T12:20:33.141Z
Learning: Source excerpt:
# CLAUDE.md

## Code conventions

### Tests

- Integration tests use real PostgreSQL and Docker, never mocks of them.
Learnt from: CR
Repo: shipkeepdev/shipkeep PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-11-08T12:20:33.141Z
Learning: Source excerpt:
# CLAUDE.md

## Architecture rules (never break these)

6. **Every state change is audited.** Commands publish domain events on `DomainEventBus` after the change; the `audit` module appends one `AuditEvent` per event, and a store failure fails the command. No write path skips this.

You are interacting with an AI system.

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Signed-off-by: samuel mbabhazi <[email protected]>

# Conflicts:
#	docs/SPEC.md
@samuelmbabhazi
samuelmbabhazi merged commit 2e450bd into main Nov 29, 2026
29 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the fix/489-closing-lock branch November 29, 2026 08:57
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.

Persist and recover exec-session closing audit events

1 participant