Repository navigation
Conversation
01a v2.5 §6.18b: registerDayCloseGuard((db, state) → { code, details } | null)
with resetDayCloseGuard / checkDayCloseGuard, the 02a merge-guard pattern.
Asked after not_open / opened_recently and before the append; a non-null
result throws DomainError(code, details) (409 DAY_CLOSE_BLOCKED for 04).
Unregistered → 0 statements, the day closes. Tests 196, 197.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DTZfXNz91zTbB1oaHWoFxj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lane U3, task u8: 04 §4.5 row A-1, built against 01a v2.5 §6.18b (Script row and the "Day-close guard" note) and 01a tests #196 and #197. Marker: Cross (01a). Only the hub half: the client half (G-21) is task UA.
Spec sections
DAY_CLOSE_BLOCKED(:1208), §10 tests 196 and 197 (:1498–1499).Change (
apps/hub/src/commands/close-business-day.ts)DayCloseGuard = (db, state: Readonly<EngineState>) → { code: ErrorCode; details } | null, plusregisterDayCloseGuard(fn),resetDayCloseGuard()andcheckDayCloseGuard(db, state). This copiestables/merge-guard.ts: one guard, and a later registration replaces the earlier one.handle, the guard is asked after thenot_openandopened_recentlyreturns and beforewithStockEffects/ append. A non-null result throwsnew DomainError(code, details). The throw rolls the tx back, so there is no event and noprocessed_commandsrow.DAY_CLOSE_BLOCKED(409) already exists in@pos/domain(P0.3).Tests added (
apps/hub/test/commands/business-day.int.test.ts, describe "day-close guard";afterEachnow callsresetDayCloseGuard())[01a #196] no guard registered → CloseBusinessDay closes as before, 0 extra statementsTypeError: registerDayCloseGuard is not a function[01a #197] a stub guard → 409 DAY_CLOSE_BLOCKED with its details, no event, no processed_commands row, day still open; asked with (db, state) after not_open / opened_recentlyTypeError: registerDayCloseGuard is not a function[01a #197] a stub guard returning null → the day closesTypeError: registerDayCloseGuard is not a function(Before the implementation, the file's existing 11 tests also failed, on the
resetDayCloseGuardimport inafterEach.)Run:
business-day.int.test.ts→ 14 passed. All 7 hub test files that sendCloseBusinessDay→ 106 passed.pnpm --filter @pos/hub typecheckandtypecheck:testsare clean; eslint is clean.Statement counts asserted (
statementCounter, engine-host snapshot writes left out, as in the existing A-14 count test)Readings
close-business-day.ts(or a siblingday-close-guard.ts)". It is inclose-business-day.ts, the row's file.ctx.tx.db(the writer's connection, insideBEGIN IMMEDIATE) andctx.state.STOPs
None.
Needs: #94 (P0.3,
DAY_CLOSE_BLOCKED), merged.Generated by Claude Code