Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: reject blood marker identity collisions before import

[._.]/ Adam Eivy0137bfcab7aa
diff --git a/server/services/meatspaceHealthIntegrity.test.js b/server/services/meatspaceHealthIntegrity.test.js
index 1adb1cbf04..9437622c21 100644
--- a/server/services/meatspaceHealthIntegrity.test.js
+++ b/server/services/meatspaceHealthIntegrity.test.js
@@ -119,6 +119,8 @@ it('retains all concurrently submitted local workouts', async () => {
it.each([
['source collection', { bloodTests: {} }, { tests: [] }],
['destination wrapper', { bloodTests: [{ id: 'incoming', date: '2026-01-02' }] }, { tests: 'invalid' }],
+ ['source marker date', { bloodTests: [{ id: 'incoming', date: '2026-01-02', markers: { date: 123 } }] }, { tests: [] }],
+ ['source marker identity', { bloodTests: [{ id: 'incoming', date: '2026-01-02', markers: { id: 'another-record' } }] }, { tests: [] }],
])('refuses a malformed %s before importing any goals or health records', async (_label, incoming, local) => {
const goals = { goals: [{ id: 'retained-goal' }] };
await source({ ...incoming, goals: [{ id: 'incoming-goal' }] });
diff --git a/server/services/mortalLoomStore.js b/server/services/mortalLoomStore.js
index 7a36b8de43..0ff2c56455 100644
--- a/server/services/mortalLoomStore.js
+++ b/server/services/mortalLoomStore.js
@@ -833,7 +833,9 @@ export async function importToPortOS() {
if (store[key] !== undefined) assertRows(store[key], key);
}
for (const row of store.bloodTests || []) {
- if (row.markers != null && !isPlainObject(row.markers)) {
+ const reserved = ['id', 'date', 'createdAt', 'updatedAt', 'aliasIds', 'markers'];
+ if (row.markers != null && (!isPlainObject(row.markers)
+ || reserved.some(key => Object.hasOwn(row.markers, key)))) {
throw new Error('MortalLoom import blood markers malformed');
}
}
@@ -869,7 +871,7 @@ export async function importToPortOS() {
for (const item of mlArr) {
// MortalLoom nests blood markers; the local reader consumes flat fields.
const { markers, ...rest } = item;
- const row = mlKey === 'bloodTests' ? { ...rest, ...(markers || {}) } : item;
+ const row = mlKey === 'bloodTests' ? { ...(markers || {}), ...rest } : item;
const keys = keysFor(row);
if (keys.some(key => seen.has(key) || isTombstoned(document[ROW_TOMBSTONES_KEY], key, undefined, 'id'))) {
skipped++;