feat(02-12.1): decide record-session context in one place

- add an import-free contract module both bundles can name, holding the
  header names, the parse and the verdict
- add the server fence: header read, wide-event stamp, and the refusal
- add RecordSessionChangedError as a third sibling on the existing
  sharing-error arm, so the 409 needs no new serialisation branch
This commit is contained in:
Marc-André Bombeck committed 2026-08-06 17:59:07 +02:00
1 parent 5c9befc0ae
commit 59359738c8
7 files changed
+895

No files matched your search

+19
View File
@@ -118,6 +118,25 @@ export class WideEventBuilder {
return this;
}
/**
* v1.37.0 — record the record context this request resolved.
*
* Merges for the same reason `setActingAs` does. Written by exactly one
* caller, the record-session fence, and read back by `apiHandler` to attach
* the response echo. `apiHandler` deliberately does NOT derive the context
* itself: doing so would put a session read on every public route and make
* the echo a second derivation rather than a report of the one that was used.
*/
setRecordContext(context: { epoch: number; scope: string | null }): this {
this.event.auth = { ...(this.event.auth ?? {}), record_context: context };
return this;
}
/** The record context the fence stamped, or undefined if it never ran. */
getRecordContext(): { epoch: number; scope: string | null } | undefined {
return this.event.auth?.record_context;
}
setProviderWorkAuthority(authority: ProviderWorkAuthority): this {
this.event.auth = {
...(this.event.auth ?? {}),
+12
View File
@@ -80,6 +80,18 @@ export interface WideEvent {
delegated_generation?: "suppressed";
/** Durable authority copied into provider queue payloads. */
provider_work_authority?: ProviderWorkAuthority;
/**
* v1.37.0 — the record context this request was actually served under, as
* the record-session fence read it off the session row.
*
* Stamped by the fence on every call it makes, pass or refuse, and by
* nothing else. `apiHandler` copies it onto two response headers so the
* browser can discard a response that resolved a different record than the
* one it is now showing. Present exactly on the responses that resolved a
* record scope; absent everywhere else, which is what makes "no echo" mean
* "nothing about a record was decided here" rather than "unknown".
*/
record_context?: { epoch: number; scope: string | null };
};
// Business-Daten (was wurde getan)