You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current document_records persistence stack (#98 → #107) correctly hardens evidence identity, immutable metadata, tenant RLS, exact canonical bytes, and duplicate-key ambiguity. The current #1070021_document_record_persistence.sql write boundary, however, still has no explicit idempotency authority for an uncertain-outcome retry.
The table has tenant-scoped unique constraints for document/artifact/audit/outbox references. Those constraints prevent duplicate durable facts, but they do not by themselves give a caller deterministic replay semantics. If PostgreSQL commits an insert and the caller loses the response, retrying the same logical command can surface a uniqueness error rather than return the first committed authoritative result. A uniqueness violation is not proof to the caller that the existing row was produced by the exact same semantic command rather than by a conflicting command that reused one reference.
This is a document_records owner concern. Do not solve it in talent_acquisition, people_core, #307, or a consumer by retry heuristics, cross-service SQL, timeout assumptions, or by copying mutable #98/#107 source.
Required domain contract
Define a tenant-scoped, versioned persistence command/result boundary with an explicit idempotency identity and a deterministic semantic command digest over the already-governed persistence inputs. The authoritative persistence transaction must distinguish:
first execution: write one immutable document_record plus its required audit/outbox evidence and return one authoritative receipt/result;
same idempotency identity + same semantic digest: converge to the original committed document identity and receipt without creating another business/audit/outbox fact;
same idempotency identity + different semantic digest: fail closed as a conflicting replay;
concurrent first attempts for the same idempotency identity: serialize so exactly one semantic command wins and every same-semantic participant converges to that result;
timeout/connection loss after commit: a later retry can recover the authoritative first result without treating absence, elapsed time, or a generic uniqueness error as success evidence.
The idempotency key/receipt must be purpose-bound and PII-minimized. It must not store document bytes, credentials, free-form HR content, or duplicate Person/Employment truth. Preserve #107's exact canonical-evidence byte/digest invariants and document_records ownership.
Executable acceptance
Add RED PostgreSQL/application contracts for uncertain post-commit retry, same-key/same-semantic concurrency, same-key/different-semantic conflict, duplicate delivery/reordering where applicable, and connection cleanup.
Exercise real PostgreSQL concurrency; a single-threaded unit fixture is insufficient transaction evidence.
Prove one durable document fact and exactly-once logical audit/outbox evidence for same-semantic replay.
Bind the returned replay result to the original committed document identity and immutable receipt; do not generate a fresh identity on replay unless the contract explicitly proves why that identity is non-authoritative.
Keep aggregate/transaction scope minimal and tenant-scoped; use UPSERT/locking only where the semantic digest and result-recovery contract make the replay decision unambiguous.
Preserve FORCE RLS/NOBYPASSRLS acceptance and no cross-service application-table SQL.
Record failure/recovery semantics in ADR/OPERABILITY/TEST_STRATEGY/TRACEABILITY through the canonical writer paths.
Verified buyer/operability gap
The current
document_recordspersistence stack (#98 → #107) correctly hardens evidence identity, immutable metadata, tenant RLS, exact canonical bytes, and duplicate-key ambiguity. The current #1070021_document_record_persistence.sqlwrite boundary, however, still has no explicit idempotency authority for an uncertain-outcome retry.The table has tenant-scoped unique constraints for document/artifact/audit/outbox references. Those constraints prevent duplicate durable facts, but they do not by themselves give a caller deterministic replay semantics. If PostgreSQL commits an insert and the caller loses the response, retrying the same logical command can surface a uniqueness error rather than return the first committed authoritative result. A uniqueness violation is not proof to the caller that the existing row was produced by the exact same semantic command rather than by a conflicting command that reused one reference.
This is a
document_recordsowner concern. Do not solve it intalent_acquisition,people_core, #307, or a consumer by retry heuristics, cross-service SQL, timeout assumptions, or by copying mutable #98/#107 source.Required domain contract
Define a tenant-scoped, versioned persistence command/result boundary with an explicit idempotency identity and a deterministic semantic command digest over the already-governed persistence inputs. The authoritative persistence transaction must distinguish:
document_recordplus its required audit/outbox evidence and return one authoritative receipt/result;The idempotency key/receipt must be purpose-bound and PII-minimized. It must not store document bytes, credentials, free-form HR content, or duplicate Person/Employment truth. Preserve #107's exact canonical-evidence byte/digest invariants and
document_recordsownership.Executable acceptance
develop.This issue is not a reason to close or weaken #107. It is the next operability increment after immutable persistence authority is established.