Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(home): stop an account deletion forging a confirmation-integrity Sev 1

nirholasb730a85a36c7
diff --git a/api/_lib/home/privacy.js b/api/_lib/home/privacy.js
index f1abf6aa9..0957aa191 100644
--- a/api/_lib/home/privacy.js
+++ b/api/_lib/home/privacy.js
@@ -662,7 +662,20 @@ export async function deleteAllHomeDataForUser(userId, { email = null } = {}) {
// those rows is entitled to its own history, and it does not need to keep a
// pointer to a person who left.
await sql`update home_action_log set user_id = null where user_id = ${userId}`;
- await sql`update home_action_log set confirmed_by = null where confirmed_by = ${userId}`;
+
+ // Removing WHO confirmed must not erase THAT it was confirmed. A guarded
+ // physical action with no confirmation and no grant behind it is the
+ // subsystem's zero-budget Sev 1 (api/_lib/ops/home-health.js), and a bare
+ // `confirmed_by = null` would forge exactly that shape out of a lawful,
+ // properly confirmed unlock every time somebody exercised their right to
+ // erasure. The marker keeps the household's record honest and keeps the
+ // integrity alert reading the truth.
+ await sql`
+ update home_action_log
+ set confirmed_by = null,
+ detail = coalesce(detail, '{}'::jsonb) || '{"confirmation_scrubbed":true}'::jsonb
+ where confirmed_by = ${userId}
+ `;
const after = await countUserRows(userId, email);
return { before, after, homes: homeIds.length };
diff --git a/api/_lib/ops/home-health.js b/api/_lib/ops/home-health.js
index 4a559f932..811aec4b6 100644
--- a/api/_lib/ops/home-health.js
+++ b/api/_lib/ops/home-health.js
@@ -247,13 +247,27 @@ export async function readHomeSignals({ windowMinutes = WINDOW_MINUTES } = {}) {
// allow list and stamps `detail.allowed_by_grant`. Those rows are counted
// and reported, never paged.
//
+ // The second lawful null is an erased account. Deleting a user scrubs the
+ // pointer to who confirmed an action on a household they have left
+ // (api/_lib/home/privacy.js), which removes the name and not the yes. That
+ // path stamps `detail.confirmation_scrubbed`, so the row reports as
+ // confirmed-by-someone-departed rather than forging a violation out of a
+ // person exercising their right to erasure.
+ //
// What remains a violation is the shape with no yes behind it at all:
- // guarded, executed, nobody confirmed it, and no grant claimed.
+ // guarded, executed, nobody confirmed it, no grant claimed and no
+ // confirmation scrubbed.
withTimeout(
sql`
select
- count(*) filter (where coalesce(detail->>'allowed_by_grant', 'false') <> 'true')::int as violations,
- max(created_at) filter (where coalesce(detail->>'allowed_by_grant', 'false') <> 'true') as last_at,
+ count(*) filter (
+ where coalesce(detail->>'allowed_by_grant', 'false') <> 'true'
+ and coalesce(detail->>'confirmation_scrubbed', 'false') <> 'true'
+ )::int as violations,
+ max(created_at) filter (
+ where coalesce(detail->>'allowed_by_grant', 'false') <> 'true'
+ and coalesce(detail->>'confirmation_scrubbed', 'false') <> 'true'
+ ) as last_at,
count(*) filter (where detail->>'allowed_by_grant' = 'true')::int as grant_backed,
count(*) filter (
where detail->>'allowed_by_grant' = 'true'
@@ -262,7 +276,8 @@ export async function readHomeSignals({ windowMinutes = WINDOW_MINUTES } = {}) {
where g.home_id = home_action_log.home_id
and g.entity_id = any(home_action_log.entity_ids)
)
- )::int as grant_backed_without_grant
+ )::int as grant_backed_without_grant,
+ count(*) filter (where detail->>'confirmation_scrubbed' = 'true')::int as confirmation_scrubbed
from home_action_log
where guarded = true and confirmed_by is null and outcome = 'ok'
and created_at > now() - interval '24 hours'
@@ -329,6 +344,10 @@ export async function readHomeSignals({ windowMinutes = WINDOW_MINUTES } = {}) {
// alerts. A number that climbs while nobody is revoking anything is
// worth reading.
grantBackedWithoutGrant: v.grant_backed_without_grant ?? 0,
+ // Guarded actions that WERE confirmed by a person who has since deleted
+ // their account. Reported so the number is visible, never scored: the
+ // yes happened, and only the pointer to who gave it was erased.
+ confirmationScrubbed: v.confirmation_scrubbed ?? 0,
},
pool,
leak,
@@ -448,6 +467,7 @@ export function homeHealthVerdict(s) {
+ (decidedConfirmations >= MIN_CONFIRMATIONS_FOR_A_VERDICT ? '' : ` (under the ${MIN_CONFIRMATIONS_FOR_A_VERDICT}-confirmation floor, reported not scored)`)
: 'no confirmations in window',
s.integrity.grantBacked ? `${s.integrity.grantBacked} guarded action(s) cleared by a standing grant` : null,
+ s.integrity.confirmationScrubbed ? `${s.integrity.confirmationScrubbed} guarded action(s) confirmed by a since-deleted account` : null,
`pool ${s.pool.open} open, ${s.pool.subscribers} subscribers` + (s.pool.streams === null ? '' : ` across ${s.pool.streams} streams`) + `, ${s.pool.breakersOpen} breakers open` + (s.pool.rung && s.pool.rung !== 'normal' ? `, admission ${s.pool.rung}` : ''),
];
diff --git a/docs/ops/home-operations.md b/docs/ops/home-operations.md
index 7d6d7ceae..73360a8fd 100644
--- a/docs/ops/home-operations.md
+++ b/docs/ops/home-operations.md
@@ -58,7 +58,7 @@ expired of 4 (under the 10-confirmation floor, reported not scored); ...
| Breaker-open homes | `runtime.stats()` | under 2% | 2 to 10% | over 10% |
| p95 action latency (our leg) | `home_action_log.detail->>'latencyMs'` | under 1.5 s | 1.5 to 4 s | over 4 s |
| Subscriber leak | `stats().subscribers` over three checks | flat or falling | climbing with flat connections | climbing with flat connections |
-| Confirmation integrity | `home_action_log`, excluding standing grants | zero rows | n/a | any row |
+| Confirmation integrity | `home_action_log`, excluding standing grants and scrubbed confirmations | zero rows | n/a | any row |
A **refused** action counts as a success. The safety gate refusing to open a
front door is the product working, not a failure to deliver, and scoring it as an
@@ -70,9 +70,18 @@ every legitimate unlock. A standing per-entity allowance in `home_entity_grants`
is a yes the user already gave, recorded once rather than re-asked every time, so
the act path clears the gate through the allow list and stamps
`detail.allowed_by_grant`. Those rows are counted and reported
-(`integrity.grantBacked`), never paged. What remains a Sev 1 is the shape with no
-yes behind it at all: guarded, executed, nobody confirmed it, and no grant
-claimed.
+(`integrity.grantBacked`), never paged.
+
+The second lawful null is an **erased account**. Deleting a user scrubs the
+pointer to who confirmed an action on a household they have left
+([`api/_lib/home/privacy.js`](../../api/_lib/home/privacy.js)), which removes the
+name and not the yes, so that path stamps `detail.confirmation_scrubbed` and
+those rows report as `integrity.confirmationScrubbed` rather than paging. Without
+that marker every right-to-erasure request would forge this Sev 1 out of a
+lawful, properly confirmed unlock.
+
+What remains a Sev 1 is the shape with no yes behind it at all: guarded,
+executed, nobody confirmed it, no grant claimed and no confirmation scrubbed.
### Why one broken house scores `ok` and not `degraded`
@@ -717,6 +726,7 @@ select id, home_id, user_id, actor, channel, action, entity_ids, risk, detail, c
from home_action_log
where guarded = true and confirmed_by is null and outcome = 'ok'
and coalesce(detail->>'allowed_by_grant', 'false') <> 'true'
+ and coalesce(detail->>'confirmation_scrubbed', 'false') <> 'true'
and created_at > now() - interval '24 hours'
order by created_at desc;
```
@@ -724,7 +734,8 @@ order by created_at desc;
Drop the `allowed_by_grant` line to see the grant-backed actions alongside them.
Those are legitimate and are the reason that line is there: without it, this
query returns every standing-grant unlock in the fleet and the alert becomes
-noise within a day.
+noise within a day. Drop the `confirmation_scrubbed` line to see the actions
+whose confirmer has since deleted their account, for the same reason.
**Then, in this order:**
@@ -747,6 +758,10 @@ noise within a day.
`integrity.grantBackedWithoutGrant` on the health block counts rows that
claimed a grant that no longer exists; that is usually a grant the user
revoked afterwards, which is why it reports rather than pages.
+5. **Check the scrub claim.** The alert also excludes rows stamped
+ `detail.confirmation_scrubbed`, which is an account deletion removing the
+ pointer to a confirmer. A row that reached you claimed neither a grant nor a
+ scrub, so somebody's yes is genuinely missing rather than merely anonymous.
**Rollback:** yes. Roll back to the last revision known to gate correctly before
diagnosing further.
diff --git a/tests/home-integrity.test.js b/tests/home-integrity.test.js
index baf3220ab..2d36a5f2b 100644
--- a/tests/home-integrity.test.js
+++ b/tests/home-integrity.test.js
@@ -68,6 +68,19 @@ describe('confirmation integrity is a zero-budget invariant', () => {
expect(verdict.status).toBe('ok');
});
+ it('does not fire on an action confirmed by an account that has since been deleted', () => {
+ // Erasure removes WHO said yes, not THAT somebody did: deleting a user
+ // nulls `confirmed_by` on a household they have left. Without the marker
+ // the scrub stamps, every right-to-erasure request would forge this Sev 1
+ // out of a lawful, properly confirmed unlock and send an operator to tell
+ // an innocent household their house was opened without permission.
+ const verdict = homeHealthVerdict(
+ healthy({ integrity: { violations: 0, lastAt: null, grantBacked: 0, grantBackedWithoutGrant: 0, confirmationScrubbed: 2 } }),
+ );
+ expect(verdict.status).toBe('ok');
+ expect(verdict.detail).toContain('2 guarded action(s) confirmed by a since-deleted account');
+ });
+
it('outranks every other signal, so it is never masked by a busy platform', () => {
const verdict = homeHealthVerdict(
healthy({
diff --git a/tests/home-privacy.test.js b/tests/home-privacy.test.js
index 87e52e944..10735b89c 100644
--- a/tests/home-privacy.test.js
+++ b/tests/home-privacy.test.js
@@ -496,10 +496,16 @@ describe.skipIf(!LIVE)('home privacy: deletion and purge against the real databa
// who is gone.
const [{ n }] = await sql`select count(*)::int as n from home_action_log where home_id = ${theirs}`;
expect(n).toBe(1);
- const [row] = await sql`select user_id, confirmed_by from home_action_log where home_id = ${theirs}`;
+ const [row] = await sql`select user_id, confirmed_by, detail from home_action_log where home_id = ${theirs}`;
expect(row.user_id).toBeNull();
expect(row.confirmed_by).toBeNull();
+ // Removing the name must not forge a safety violation. A guarded action
+ // with a null `confirmed_by` and nothing else on it is the subsystem's
+ // zero-budget Sev 1, so the scrub records that the yes happened while
+ // dropping who gave it.
+ expect(row.detail?.confirmation_scrubbed).toBe(true);
+
// And the account row itself can now actually be deleted, which the
// pre-migration granted_by foreign key made impossible.
await expect(sql`delete from users where id = ${owner.id}`).resolves.toBeDefined();
@@ -608,8 +614,8 @@ describe.skipIf(!LIVE)('home privacy: deletion and purge against the real databa
const data = await privacy.exportHomeData(owner.id);
expect(Object.keys(data).sort()).toEqual([
'action_log', 'confirmations', 'generated_at', 'grants', 'homes_you_own',
- 'inventory', 'invites', 'members', 'memberships', 'notice', 'plan_override',
- 'relay_pairings', 'satellite_codes', 'satellites',
+ 'inventory', 'invites', 'layouts', 'members', 'memberships', 'notice',
+ 'plan_override', 'relay_pairings', 'satellite_codes', 'satellites',
]);
expect(data.homes_you_own).toHaveLength(1);
expect(data.grants).toHaveLength(1);