mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 19:01:08 +02:00
feat(shared-ai): SYSTEM_BOOTSTRAP system source — fallback inserts now stamp origin='system'
The race-window `getOrCreateLocalDoc()` fallback in userContextStore + kontextStore stays (without it, a write that lands between "endpoint provisioned the singleton in mana_sync" and "first pull landed it in IndexedDB" would hit `update(missing-id, diff)` — a Dexie no-op that silently swallows the user's edit). But it was semantically lying: the insert stamped `origin='user'` even though the row is logically a client-side replica of the server-side bootstrap. This commit adds `SYSTEM_BOOTSTRAP = 'system:bootstrap'` to `@mana/shared-ai` and wraps the two fallback inserts in `runAsAsync(makeSystemActor(SYSTEM_BOOTSTRAP), ...)`. The Dexie hook now stamps `origin: 'system'` on the empty-row insert — structurally identical to the row mana-auth's bootstrap-singletons.ts writes. When the server's pull arrives later both sides carry the same origin and the conflict-gate stays quiet. The user's subsequent writes still stamp `origin: 'user'` on the changed fields. Plan: docs/plans/sync-field-meta-overhaul.md (F4-fu Fallback-Origin row). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
01681b58ff
commit
ae6a14fb76
6 changed files with 61 additions and 20 deletions
|
|
@ -33,13 +33,23 @@ export const SYSTEM_RULE = 'system:rule';
|
|||
export const SYSTEM_MIGRATION = 'system:migration';
|
||||
export const SYSTEM_STREAM = 'system:stream';
|
||||
export const SYSTEM_MISSION_RUNNER = 'system:mission-runner';
|
||||
/**
|
||||
* Client-side singleton bootstrap. Stamped on the rare race-window
|
||||
* `getOrCreateLocalDoc()` insert in `userContextStore` / `kontextStore`
|
||||
* — a structural twin of mana-auth's server-side bootstrap (which uses
|
||||
* the `'system:bootstrap'` principalId on the wire). Maps to
|
||||
* `origin='system'` via `originFromActor`, so the conflict-gate exempts
|
||||
* it from the user-write codepath.
|
||||
*/
|
||||
export const SYSTEM_BOOTSTRAP = 'system:bootstrap';
|
||||
|
||||
export type SystemSource =
|
||||
| typeof SYSTEM_PROJECTION
|
||||
| typeof SYSTEM_RULE
|
||||
| typeof SYSTEM_MIGRATION
|
||||
| typeof SYSTEM_STREAM
|
||||
| typeof SYSTEM_MISSION_RUNNER;
|
||||
| typeof SYSTEM_MISSION_RUNNER
|
||||
| typeof SYSTEM_BOOTSTRAP;
|
||||
|
||||
/** Legacy sentinels for records that pre-date the identity-aware actor
|
||||
* shape. Read-path normalization maps missing fields to these. */
|
||||
|
|
@ -141,6 +151,8 @@ function defaultSystemDisplayName(source: SystemSource): string {
|
|||
return 'Event-Stream';
|
||||
case SYSTEM_MISSION_RUNNER:
|
||||
return 'Mission-Runner';
|
||||
case SYSTEM_BOOTSTRAP:
|
||||
return 'Bootstrap';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ export {
|
|||
SYSTEM_MIGRATION,
|
||||
SYSTEM_STREAM,
|
||||
SYSTEM_MISSION_RUNNER,
|
||||
SYSTEM_BOOTSTRAP,
|
||||
LEGACY_USER_PRINCIPAL,
|
||||
LEGACY_AI_PRINCIPAL,
|
||||
LEGACY_SYSTEM_PRINCIPAL,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue