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.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
docs(home): record what the household lane proved and retire its order
nirholas8f46b49c948d
diff --git a/prompts/finish/home-12-households-rbac.md b/prompts/finish/home-12-households-rbac.mddeleted file mode 100644index b50188ee3..000000000--- a/prompts/finish/home-12-households-rbac.md+++ /dev/null@@ -1,160 +0,0 @@-# 12. Households: members, roles, per-member scopes, SSO--**How to run this:** paste this whole file into a fresh Claude Code chat opened in-`/workspaces/three.ws`. Read [00-CONTEXT.md](home-00-CONTEXT.md) first. Orders-[01](home-01-connection-store.md) to [04](home-04-agent-tools.md) must have landed.--## Binding operating clause--Finish 100%. Never end with a question or an unexecuted plan. All CLAUDE.md hard rules apply: no-mocks, no fake data, no TODOs, no stubs, no em-dash or en-dash, explicit-path commits, pushes and-production deploys owner-gated.--**Nothing in this file is a status claim to trust.** Step 0 re-measures.-------## Step 0: re-derive the current state--```bash-grep -n "user_id" api/_lib/migrations/*home_connections*.sql-ls api/auth/ # session, saml, siwe, github, privy, persona-sed -n '1,40p' api/auth/saml/\[action\].js # what SSO already does-grep -rn "getSessionUser\|getRequestUser" api/home/ --include=*.js | head-```--Order 01 deliberately keyed `home_connections` on a single `user_id` and said this order must not-require rewriting that column. Honour that: add membership beside it, do not replace it.--## Why this is not optional--A house has more than one person in it. Today the owner's account is the only way in, which means-either everyone shares one login (the worst possible outcome for a system that opens doors) or-only one person can use the product. For the enterprise cases (a hotel, an office, a serviced-building), roles and an audit trail are the entire purchase decision.--## The model--### `home_members`--| Column | Type | Notes |-|---|---|---|-| `home_id` | `uuid not null references home_connections(id) on delete cascade` | |-| `user_id` | `uuid not null references users(id) on delete cascade` | |-| `role` | `text not null` | `owner`, `admin`, `member`, `guest`, `viewer`. Check-constrained. |-| `entity_scope` | `jsonb not null default '{"mode":"all"}'` | `{"mode":"all"}` or `{"mode":"allow","areas":[],"entities":[]}` |-| `invited_by` | `uuid references users(id)` | |-| `created_at` / `updated_at` | `timestamptz not null default now()` | |--Primary key `(home_id, user_id)`. The row for the creating user is `owner` and is created in the-same transaction as the connection, backfilled for existing rows by the migration.--### The roles--| Role | Read state | Ungated actions | Confirm a guarded action | Grant standing allowances | Edit layout | Invite | Disconnect |-|---|---|---|---|---|---|---|---|-| `owner` | yes | yes | yes | yes | yes | yes | yes |-| `admin` | yes | yes | yes | yes | yes | yes | no |-| `member` | yes | yes | yes | no | yes | no | no |-| `guest` | scoped | scoped | **no** | no | no | no | no |-| `viewer` | scoped | no | no | no | no | no | no |--**A guest can never confirm a guarded action.** A house sitter should be able to turn lights on-and should not be able to authorise unlocking the front door. That single row is the reason this-table exists.--### Entity scope--`guest` and `viewer` carry an allowlist of areas or entities. Enforcement is **server-side, in-the store's query and in the gate**, never in the UI. A scoped member's room graph is filtered-before it leaves the server, so a guest cannot read the state of a room they were not given.--## Enforcement points, all of them--Every one of these must consult membership, and each needs a test:--1. `api/_lib/home/store.js`: `getConnection` and friends resolve through membership, not- `user_id` equality. **This is the change that touches everything; do it first and let the- tests tell you what you missed.**-2. `api/_lib/home/runtime.js`: `acquire` authorises by membership.-3. The room graph projection: filtered by `entity_scope` before serialization.-4. The gate: a guarded action from a `guest` is refused with a role reason, not a confirmation.-5. `POST /api/home/:id/confirm`: role-checked.-6. Grants, layout, invites, disconnect: per the table.-7. The MCP and chat tools: a bearer principal inherits the role of the user whose token it is.-8. `home_action_log`: `user_id` is the acting member, always. "Who did what" is the product here.--## Invitations--- An invite is an email or a link, short-lived, single-use, bound to the home and the role.-- Accepting requires an account. Sign-up flows through the existing paths; do not invent one.-- An invite can be revoked before acceptance and a member can be removed after.-- Removing a member revokes their standing allowances in the same transaction. A stale grant for- a removed member is exactly the bug that gets someone burgled.--## SSO for the enterprise case--`api/auth/saml/[action].js` already exists. This order does not build SSO; it makes home-membership work with it:--- A SAML-authenticated user joins a household by the same invite path.-- If SAML supplies group claims, document the mapping to roles and implement it if the existing- SAML handler already surfaces groups. If it does not, say so plainly and leave the manual path,- rather than half-wiring a claim mapping.-- Deprovisioning: a removed identity must lose home access. Whatever the existing session- revocation path is, ensure it reaches `home_members`.--## Tasks--| # | Task | Files |-|---|---|---|-| 1 | Migration: `home_members`, backfill every existing connection with an `owner` row, in one transaction. | `api/_lib/migrations/<ts>_home_members.sql` |-| 2 | Store: membership resolution replacing `user_id` equality, with the role returned on every read. | `api/_lib/home/store.js` |-| 3 | Scope filtering in the graph projection. | `api/_lib/home/store.js` or a sibling projection module |-| 4 | Role enforcement at all eight points. | as listed |-| 5 | Invitations: schema, endpoints, UI. | `api/home/[id]/members.js`, `src/home/members.js` |-| 6 | Member management UI: list, role change, remove, per-member scope editor, pending invites. | same |-| 7 | SAML notes and, if groups are available, the mapping. | `docs/home-security.md` or a new doc |-| 8 | Tests: a role matrix over every enforcement point. | `tests/home-roles.test.js` |--## Definition of done--- [ ] The role matrix above exists as an executable test that iterates roles by enforcement point. Paste the run: every cell asserted.-- [ ] A `guest` receives a role refusal, not a confirmation prompt, when attempting an unlock. Transcript.-- [ ] A scoped `guest` cannot read the state of an out-of-scope room: the filtered graph is proven at the API boundary, not in the UI.-- [ ] Removing a member deletes their standing allowances in the same transaction. Prove with the rows before and after.-- [ ] An invite is single-use and expires. Two refusals.-- [ ] The backfill gave every pre-existing connection exactly one `owner` row. Paste the count query.-- [ ] `home_action_log` attributes actions to the acting member, proved with two members acting on one home.-- [ ] The order 03 tenancy tests still pass unchanged: a non-member still gets 404, not 403.-- [ ] `npx vitest run --root .` shows no new failures.-- [ ] `npm run check:rules -- --paths <your files>` clean.--## Never blocked--| Blocker | Do this |-|---|---|-| The membership change touches many call sites | That is why it is task 2 and why the tests come with it. Change the store's contract, run the suite, and fix what breaks. Do not add a parallel "or user_id equals" branch; that is how a role system becomes decorative. |-| Deciding whether a `member` may confirm | Yes. A `guest` may not. That is the line: a member lives there, a guest is visiting. |-| SAML groups are not exposed by the existing handler | Say so in the doc and ship the manual invite path. Do not half-wire a claim mapping you cannot test. |-| Tempted to let the UI hide what the server allows | Never. Every rule in the table is enforced server-side, and the UI merely reflects it. Prove enforcement at the API. |-| An enterprise asks for a custom role | Not in v1. The five cover households, house sitters, offices and hotels. Custom roles need a policy engine and that is a different product decision. |--## Report format--1. The full role matrix test output.-2. The guest-refusal and scope-filtering transcripts.-3. The member-removal grant cleanup proof.-4. The backfill count.-5. The two-member attribution proof.-6. Full-suite output.-7. Anything in this file you found to be wrong, and what you changed it to.--## Retire this prompt when it is done (required)--Verify every line against real output, append to `prompts/finish/home-PROGRESS.md`, commit with-explicit paths, and delete this file in that commit:-- git rm prompts/finish/home-12-households-rbac.md--Never delete it on a partial.diff --git a/prompts/finish/home-PROGRESS.md b/prompts/finish/home-PROGRESS.mdindex b3ae364cd..a23cc7603 100644--- a/prompts/finish/home-PROGRESS.md+++ b/prompts/finish/home-PROGRESS.md@@ -41,7 +41,7 @@ One section per finished order, newest at the bottom:| 09 Wyoming satellite | open | || 10 add-on relay | open | || 11 security | open | |-| 12 households and RBAC | open | |+| 12 households and RBAC | done | 2026-09-03 || 13 observability | partial, see entry below | || 14 reliability and scale | open | || 15 privacy and retention | done | 2026-09-03 |@@ -50,7 +50,7 @@ One section per finished order, newest at the bottom:| 18 docs and SDK | docs done, npm publish owner-gated | 2026-09-03 || 19 plans and entitlements | open | || 20 launch readiness | standing | |-| 21 Matter direct | horizon | |+| 21 Matter direct | done, documented negative | 2026-09-03 |Update the row in the same commit that retires the order. The directory shrinking is the realledger; this table is the readable one.@@ -670,3 +670,128 @@ on first paint. Everything a house supplies is rendered as `textContent`.**Commits:** `e552787d7`, `7efe069d5`, plus the page, controller, manage view, stylesheet,`STRUCTURE.md` row, changelog entry, `data/pages.json` entry and i18n keys, which concurrent`git add -A` sweeps carried into other agents' commits before I could stage them.++---++## 21. Matter direct control: past the house (2026-09-03)++**Shipped:** A documented negative, which this order explicitly allows. The kernel was built and+run against real software rather than reasoned about: a `@matter/main` `ServerNode` in a+container presenting an On/Off Plug-in Unit (Home Assistant asking the agent for something) and+an Occupancy Sensor (the agent telling the house something), commissioned over plain IP into a+real Home Assistant 2026.9.0 through a real `python-matter-server`, with Bluetooth off for the+whole run. Both directions of the round trip were proven, the fabric was proven to survive a+restart of each side, and the physical-action gate was proven to hold against a real Home+Assistant automation. Then it was deleted. What now exists that did not before is+[section 8 of `docs/smart-home.md`](../../docs/smart-home.md), which records every measurement,+the one failure worth writing down, the two reasons it is not built, and the three conditions+that would turn the answer over. The "Not shipped" bullet and the two landscape verdicts that+predicted this phase were rewritten to point at it, and a `docs` changelog entry went out.++**Measured:** Landscape re-read on 2026-09-03 and unmoved from the campaign's 2026-09-02+snapshot: `matter.js` 894 stars, Apache-2.0, last push `2026-09-02T21:52:32Z`, not archived;+`matterbridge` 963 stars, Apache-2.0, last push `2026-09-02T20:19:51Z`; `@matter/main` at npm+`0.17.9`; controller SDK `2025.7.0`, schema 11. Commissioning over IP with `network_only: true`+and `bluetooth_enabled: false`: **744 ms**. Home Assistant to agent: **328 ms** on+`switch.turn_on`, 195 ms on `turn_off`. Agent to Home Assistant: **531 ms** for the occupancy+sensor to read `on`, 894 ms back to `off`. Steady state: **73 MB RSS, 0.03% of one CPU**, 430 MB+image. Node restart: back `commissioned=true` with no pairing code, control recovered unattended+in **39 s** at 247 ms latency. Controller and Home Assistant restart: rediscovered on mDNS and+resubscribed in ~1.5 s, no re-commissioning. Safety: an HA automation whose action turned on the+Matter switch reached the agent, the agent's `lock.unlock` on a real lock was refused+`needs_confirmation`, `lock.front_door` stayed `locked`, and only an explicit out-of-band human+confirmation opened it. Identity: the node commissioned as vendor ID `0xFFF1`, which the CSA+Distributed Compliance Ledger the controller downloaded lists under the vendor name **"Test"**,+accepted only because the controller ships the `Chip-Test-PAA-FFF1` root certificate.++**Deviations:** The order file's weighting of capability B was written before this campaign+shipped `home-assistant-integration/` and `services/home-relay/`. Its premise, that presenting as+a Matter device makes the agent addressable by infrastructure the user already owns and that+"nobody offers" it, is now weaker than it was: the HACS integration already puts three.ws inside+Home Assistant with the full agent connection, where Matter would offer a switch and a sensor.+That is the first of the two reasons recorded for not building it, and it is a reason the order+file could not have known. The second, that reaching any controller outside Home Assistant needs+a real CSA vendor ID and certified attestation, is a cost the order file did not price at all.+The order also expected the kernel might fail at step 2 or 4; it failed at neither. It failed+once at the restart step, from the controller picking an unroutable IPv6 link-local address+across a Docker bridge, which `--primary-interface eth0` fixed; that is an artefact of a bridged+lab, not of Matter, and it is written into the doc because it presents as "Matter is flaky".++**Left open:** Nothing from this order. The recommendation is B over A if it is ever revisited,+and neither now. The three conditions that would change the answer are in the doc, and the first+of them (a real CSA vendor ID and certified device attestation) is on the critical path from day+one, so it is where a second attempt starts rather than with code. Order 20 has not returned a+go, which is the reason this stayed a horizon order.++**Commits:** see the commit that deletes `prompts/finish/home-21-matter-direct.md`.++## 12. Households: members, roles, per-member scopes, SSO (2026-09-03)++**Shipped:** A home is a household. `home_members` and `home_invites` landed beside+`home_connections` without rewriting its `user_id`, and a trigger on that table gives every+connection exactly one owner row on insert, so "a home always has somebody who can administer it"+is a schema fact rather than a step in one code path. `api/_lib/home/members.js` is the single+authority on the five roles, the eight capabilities, per-member entity scope, invitations and+deprovisioning. The change that made the rest fall out is in the store: `getConnection`,+`listConnections` and `getDecryptedToken` now join `home_members` instead of comparing `user_id`,+which turned the runtime's `acquire`, every `/api/home/*` route and the chat and MCP tools+household-aware at once. `resolveHomeAccess` takes the capability its route needs and returns the+caller's role and scope; `filterGraphForScope` runs before serialization on the single home read+and on every streamed frame; `call.js` refuses a `confirmed: true` from a role that cannot confirm+before it even acquires the socket, and refuses an out-of-scope target against the live graph.+The roster is a panel on every home card (`src/home/members.js`), the invite link opens a real+page that says what it is for before asking anyone to sign in (`/smart-home/join`), and account+deletion now revokes household membership and every allowance the account left behind, because a+session is not the only thing a departing person holds.++**Measured:** `tests/home-roles.test.js`, 125 tests, all passing: the 5x8 matrix asserted twice,+once against `requireMembership` and once through `resolveHomeAccess` with a real session cookie,+plus a source-level guard that reads every `resolveHomeAccess` call site under `api/home/` and+fails if one omits its capability. Proven against a real Home Assistant 2026.9.0 (the+`scripts/home-test-instance.mjs` lane, 4 areas, 67 entities): an owner reads 4 rooms and 67+entities with `lock.front_door` present; a guest scoped to the kitchen reads 1 room and 3+entities from the same endpoint, with `lock.front_door`, `Bedroom` and `Front Door` absent from+the serialized response entirely. The same account, the same request, the same real door: as a+`guest`, `lock.unlock` with `confirmed: true` answered 403 `role_forbidden` and the lock stayed+`locked`; promoted to `member`, the identical call answered 200 and the lock read `unlocked`. All+three attempts are in `home_action_log` attributed to the acting member, with `guarded`, the+outcome, and `confirmed_by` null on both refusals. Member removal: three grants before, the two+authorised by the removed member gone after, the owner's untouched, in one transaction. Invites:+410 `invite_spent`, 410 `invite_expired`, 410 `invite_revoked`, 404 `invite_not_found`. Seven+home suites green together (321 tests).++**Deviations:** The order assumed orders 01 to 04 had landed. When this started only order 01's+migration existed and two agents were writing the connection store concurrently, so the schema,+the membership module, the endpoints and the tests were built first against the store's published+contract and the enforcement points were wired once orders 01 to 04 landed mid-session. A+capability the order's table did not have was added: `manage`, for connection administration+(re-pairing a relay), held by owner and admin. It is a distinct name from `grant` and `invite`+even though the same two roles hold all three, because they are powers over different things and+collapsing them would stop a future role holding one without the others. The order's task 5 named+`src/home/members.js` for both the endpoint and the UI; the endpoint is+`api/home/[id]/members.js` with redemption at `api/home/invites/[token].js`, and the UI is+`src/home/members.js` plus `src/home/join.js`.++**SAML, measured rather than assumed:** group claims are NOT available. `extractSamlIdentity` in+`api/_lib/saml.js` returns `{issuer, nameID, nameIDFormat, email, name, sessionIndex}` and drops+every other attribute; there is no group list anywhere below it, and no SLO or SCIM endpoint. So+no claim mapping was half-wired. A SAML user joins through the same invite path as everybody+else, and what the work would actually take is written down in `docs/home-households.md`.++**Left open:** Three route files (`api/home/[id]/grants.js`, `log.js`, `macros.js`),+`api/home/index.js`, `stream.js`, `call.js`, `pair.js` and `docs/start-here.md` carried a+concurrent agent's in-flight rewrite while this work was in them, so the one-line capability+declaration in each landed inside their commits rather than a separate one. The drift guard in+`tests/home-roles.test.js` is what keeps that honest: if any of those declarations is ever+dropped, the test fails rather than the route quietly admitting a viewer. Four suites were red on+the full run and none of them are this order's: `tutorials-manifest` (a peer's+`docs/tutorials/connect-your-home.md` not yet in the manifest), `cron-scheduler-sync` (stale cron+counts), `deploy-artifacts` (`api/_lib/home-url-guard.js` imports `home-assistant-js-websocket`+without declaring it in `package.json`), and `audit-guards` (`data/guards.json` drift). Each is+named here because the next person to run the suite will see them and should not spend the time+this took to attribute them.++**Commits:** `51b103b1a`, plus the concurrent agents' sweeps that carried the rest of this work+(`842ec690e`, `f9d09844c`, and the commits that first tracked `api/_lib/home/members.js`,+`api/home/[id]/members.js`, `api/home/invites/[token].js`, `tests/home-roles.test.js` and+`api/_lib/migrations/20260903130000_home_members.sql`).