# Existing canonical app adoption

Status: Home capability design approved by independent GPT-6 Astra,
2026-11-02, after rollback, observation and scope revisions. Production
activation remains gated on the reviewed observation runner and confirmations.
Base: d82341c. Amended 2026-11-16 for 522 Plan 1 digests and the Plan 2
waiver (see the observation recipe). Amended 2026-11-17 (Paul, discussion
103): the waiver's delivery evidence is the runner's automated check, and
the negative live checks are dropped for this adoption. Implements
agent-access task 5 and Home discussion 103. Amended 2026-11-20 by Paul’s
approved Equipo native Oficina ID spec, part 3 / E4: Equipo joins canonical
adoption as the seventh app; its app-side contract must be deployed first.
Amended 2026-11-23 (Paul: Base production is https://base.oficina.works):
Base joins as the eighth. Its instance must already serve that host, and
its `base` consumer must be in the credential env manifest with that origin,
before an adoption plan names it.

The eight existing canonical instances need directory membership and routing
without creating replacement instances, changing their keys, or converting
their existing item permissions to TeamMode. Agent adapters already support
this combination: Home controls delegated team admission; each app resolves
the Home subject and enforces its current local resource permissions. A new
directory membership never grants access to existing content by itself.

## Scope and authority

Extend the signed operator plan with optional `existing_team` (the actual
team SQID, not the dashboard label). It is valid only for create-team or
add-apps plans and only for the eight compiled canonical apps. Both roles show
an explicit existing-app adoption description. The directory requires label
`oficina`, shows the exact canonical hosts, and binds seeding and every
subsequent operation to the plan's SQID. The credential plan binds owner-seed
and the signed provisioning record to that same SQID. Existing-only owner
lookup, typed owner confirmation, two-role fresh authentication, signed
stream ordering, expiration and exact retries remain required.

Add an `existing_team` column to each role's operator_plans using new
additive migrations. Store only the bounded opaque SQID; no signed plan or
address. The field defaults empty for old plans. Ordinary plan behavior is
unchanged except that `oficina` is reserved: ordinary create-team plans and
native seeding refuse that label. Ordinary add-apps also refuses that label;
only canonical adoption can add apps there. An ordinary retire-apps window
may disable a directory binding, but cannot retire an env-manifest consumer.
Adoption's SQID must decode to exactly one
positive signed-64-bit team ID and re-encode identically.

Rollback is forward-compatible only after adoption: a pre-adoption binary
rejects canonical live rows and can make the whole chooser fail. Keep an
adoption-capable build as the rollback target. Before any adoption writes,
an older build is permitted only after every adoption window/pending plan
expires. After canonical bindings exist, do not downgrade, restore an old
snapshot, or delete rows to force a downgrade. Disabling delegated access
is the immediate incident response; a separate reviewed recovery is needed
if no adoption-capable binary is usable. App local access and data remain
available independently of the new connection service.

The canonical binding table is compiled and closed: docs, sheets, slides,
memoria, calendar and calls each use consumer ID equal to app slug and
origin `https://<app>.oficina.works`. Their only label is `oficina`.
Directory read policy admits these exact stored tuples, alongside ordinary
label.app destinations. Merely broadening hostname validation is not the
write path: directory.provision-consumer refuses canonical origins unless
ExecuteHTTP supplies an open adoption window matching the exact tuple and
SQID. Native provision never supplies that authorization. Ordinary HTTP
plans cannot write canonical tuples; adoption plans cannot write new-team
tuples. Existing unique origin/consumer constraints prevent another team
claiming an adopted instance. Provenance fence and owner membership remain.

Credential register-consumer under an adoption window verifies the
directory signature, exact issuer/directory/app/consumer/origin and pinned
team, then requires that exact ID/origin pair in the immutable env manifest.
It returns the existing union manifest digest without inserting, replacing
or retiring a registration. Partial matches, table consumers, missing env
entries and ordinary windows all refuse. Sign-in registrations and keys
remain unchanged. Ordinary registration continues rejecting env collisions.

## Activation and existing access

Provisioning still creates pending directory/roster bindings and a signed
record, with the existing operation ledger and bounded verification attempt.
Canonical activation uses explicit policy
`oficina/existing-app-activation/v1` under an adoption window; ordinary
activation keeps `oficina/team-activation/v1`. Policy/route mismatch refuses,
including native activation. Both paths retain all attempt, owner, epoch,
record, generation, build, artifact, manifest and configuration digest checks.

The adoption observation attests the canonical host's exact build, unchanged
existing consumer registration, unchanged storage and identity keys, and
agent configuration bound to the actual team. It does not attest a fresh
isolated database or TeamMode conversion. No TEAM_* settings are enabled,
no content is copied, no existing memberships are inferred, and no existing
local user access is removed. The UI explicitly says that connecting an app
preserves its existing content permissions. This narrows the activation
claim and is a deliberate amendment to team-provisioning-amendment.md §2.6,
§5 and its new-instance-only threat model, not a fake TeamMode probe.

This implementation adds Home's capability and reviewable operator tooling;
Alta's ordinary instance-creation recipe must not be used for adoption.
Production activation still needs actual signed plans, Home's fresh browser
confirmation, and the historical never-provisioned attestation before the
initial generation. Existing deployment authorization does not stand in for
these product-level confirmations. No production mutation is done by tests.

Typed owner confirmation applies to create-team only. An add-apps adoption
plan has no owner field; both fresh confirmations instead identify the
existing SQID, exact app hosts and preservation of local permissions.

### Observation recipe and activation gate

The activation evidence is the operator's signed observation; neither Home
nor the platform attests that arbitrary digest fields describe real checks.
The adoption runner must obtain two supported CARLOS snapshots, before any
configuration write and after the process adopts the intended configuration.
Each snapshot records account/app/instance ID, canonical alias and its
target, named/default environment identity, persistent storage identity,
Home issuer/consumer ID, and the complete effective configuration.

The runner reads configuration only through carlos/platform 522 Plan 1
(spec `2026-11-02-config-receipts-design.md`, approved rev 6), under an
account-owner `Operate` or `Admin` credential. The doors, all under
`/api/cli/apps/{account}/{app}`:

- `GET /config?environment=<name>` (omit `environment` for the default
  bundle). Returns the layer `version` (`cv1:` plus SHA-256 of the stored
  bytes; `none` for an absent layer) and, for every var, `key`, `kind` and
  `digest`. Plain vars also carry `value`; secrets never carry their
  envelope.
- `GET /config/effective?host=<canonical host>`. Returns the applicable layer
  versions (`default`, `environment`, `overlay`; `default` is absent for an
  owned environment) and the merged vars, each
  with `digest`, `from` and `shadows`. This is the snapshot of the complete
  effective configuration and shows if a higher layer covers a key. It shows
  stored layers only, not an exec route's `<host>.env` file.
- `PUT /config` with `if_version` set to the baseline layer version,
  setting only `AGENT_ISSUER` and `AGENT_TEAM`. Answers with a `receipt`:
  `version_before`, `version_after`, `changed`, exact `set`, `unset`,
  `unset_absent`, and `digests` for the keys just set. The console must
  support atomic conditional puts (S3); otherwise it refuses `if_version`
  with 400 and the runner stops. A 412 is a refusal with nothing written.
  `if_version` is one non-empty JSON string in the body; there is no
  `If-Match`, and it cannot be combined with `exec_delivery`.

Preservation is proved with 522's `vd1:` per-key digests, not with
HMACs of secret plaintext. A `vd1:` digest is SHA-256 over a var's stored
kind, value, sealed envelope and sealed-to fingerprint. For a secret the
input is the sealed envelope, so the digest says nothing about the plaintext,
and the runner never holds or hashes any secret plaintext. This is sufficient
because the question the gate asks is "has this key changed since the
runner observed it", not "does it equal a value the runner holds". Any write
to an identity or data key stores a new envelope and so a new digest; an
unchanged digest means those stored bytes were not written. Sealing is
randomised, so even re-setting the same plaintext reads as a change, and the
check fails closed. The cost is that the runner cannot confirm that the
stored key is the right key, only that it is the one it first saw. The
before snapshot establishes which key that is, and adoption does not claim
more. Digests of plain vars are as sensitive as their values, since they
let someone test a guess; they stay in the operator journal and are not
pasted into reports or tickets.

The baseline is the before snapshot's per-key digests and layer versions.
It is captured once, sealed before durable storage, and never rebaselined on
retry. The write and every retry follow 522 spec §4.7. After a 200, require
the receipt's `set` to be exactly `AGENT_ISSUER` and `AGENT_TEAM`, `unset`
empty, and each receipt digest equal to the digest of what was sent. After a
lost answer or a 412, read again and take the first matching branch: all
preserved digests equal the baseline and the new keys equal what was sent
(landed, done); preserved equal and new keys absent (retry with the version
just read); any preserved key changed or gone (stop); new keys partly
present or with another digest or kind (stop and report, do not overwrite).
The after snapshot must preserve every old setting's digest except the
explicitly enumerated AGENT_ISSUER and AGENT_TEAM additions. No TEAM_*
setting may be active before or after; no instance creation or storage swap.
The 522 receipt and digests describe the stored layer. They do not show that
the process has them; see the delivery evidence below.

Compute environment_binding as base64url SHA256 of a canonical JSON array:
context `oficina/existing-app-observation/v1`, exact account/app/instance,
environment and storage identities, canonical alias target, sorted before
configuration entries with their `vd1:` digests, sorted after entries with
their `vd1:` digests, the layer versions of each snapshot, actual team SQID, connection issuer, reviewed artifact SHA256, and
observed version. Require the canonical HTTPS /api/version body and
X-Carlos-Version to equal that reviewed version, without redirects, and
/healthz success. Fetch the existing credential manifest digest through the
verified adoption registration result. The signed activation retains these
digests and the current bounded verification attempt.

#### Delivery evidence: 522 Plan 2 waived for this adoption

522 Plan 2 (evidence from the running instance that it has the stored
configuration) is not built. Paul ruled on 2026-11-16 (oficina/home
discussion 103 and carlos/platform 522) that it is waived for this Oficina
existing-team adoption only. It is not a precedent for any other adoption,
which still needs Plan 2 or its own ruling. Nothing else in the gate is
waived: Plan 1 snapshots, digests and receipts still apply.

In its place, delivery evidence is a check per app, made by the runner
after the app restarts with the new configuration. Paul ruled on
2026-11-17 (discussion 103) that this automated check replaces his
witnessed sign-in; there is no typed confirmation. The check passes only
if:

- the canonical HTTPS `/api/version` body and `X-Carlos-Version` are
  unchanged from the before snapshot and are the reviewed version, with
  no redirect;
- `/healthz` succeeds;
- `GET /api/v1/operations` now answers with agent-access's response,
  which shows that the app runs the delegated-access code with the new
  configuration. That is a move from 404 to 401 or 200. Slides and Calls
  already answer 401 from their own middleware, so for them the 401 must
  become agent-access's own challenge (a `Bearer` `WWW-Authenticate`,
  `Cache-Control: no-store` and a body whose `error.code` is
  `unauthenticated`).

For Base only (Paul, 2026-11-23, oficina/alta discussion 5), the third
bullet is held rather than moved: `GET /api/v1/operations` must answer the
same agent-shaped 401 before and after configure's restart, because it is
Base's own door for Equipo's Assistant and Base reads no agent settings;
every other delivery check is kept (Alta's `docs/base-adoption.md`).

The runner records the check bound to the identity, delivered version and
configuration it observed; it is void if any of them changes. The check is
part of the signed observation: environment_binding carries it in the
place the witness had. Production activation of an app is blocked until
its check is recorded and still current.

#### Approved redeploy after configure (amendment, 2026-11-19)

Status: proposed, for Paul's approval. It changes the first bullet
above for one case only.

During the production run, docs, slides, calls and memoria were
redeployed to new releases after `configure` had landed their agent keys,
restarted them and recorded their checks. Paul approved those releases,
and the runner's config now names their artifacts. Each stored check is
void, because the served version changed. A new check cannot be made,
because the bullet above requires the version to be unchanged from the
before snapshot. A rollback does not help: `configure` refuses once a
rollback is recorded, and the baseline is never retaken.

So `configure`, run again for an app whose write has landed and whose
after snapshot exists, may record a new check on a release other than
the before snapshot's. It reads only: it sends no write and no restart.
It records the check only if all of these hold on one fresh observation:

- the served release changed: the `/api/version` body and
  `X-Carlos-Version` both differ from the before snapshot's. If they do
  not, the check is the ordinary one above, unchanged;
- `X-Carlos-Version` hashes to the app's reviewed artifact in the
  runner's config (the release Paul approved), the body and header name
  the same release, there is no redirect, and `/healthz` is 200;
- `GET /api/v1/operations` gives agent-access's own answer, as in the
  bullet above, which shows the new process runs with the agent keys;
- the journal's write is landed, and both agent keys are plain vars in
  the write layer holding the values it sent;
- every other key and every untouched layer is preserved from the
  before snapshot, and the config equals the after snapshot exactly. A
  config change that came with the redeploy, including a new key, is
  refused;
- the identity equals the before and after snapshots': the same
  instance record and record sequence, environment, storage and
  canonical domain route. A redeploy keeps the instance record.

The check records the redeploy with it: the before snapshot's release,
the new one, the approved artifact and the reason. environment_binding
commits to that record as part of the check; a check with no redeploy
binds exactly as before. The activation gate accepts such a check only
if its record is still true: it starts from the before snapshot's
release, ends at the release the check observed, names the artifact the
config approves now, and the fresh probe passes the rules above. The
ordinary freshness rule still applies, so any later change to the
release, identity or config voids the check, and an unapproved release
is refused as before. Anything else gets the ordinary refusal.

What this does not change: a release that did not change is checked
exactly as before; no new write or restart is allowed; the baseline is
never retaken. One known effect: `rollback-config` waits for the before
snapshot's version, so after a redeploy a rollback's restart cannot
complete. A rollback after a redeploy needs its own reviewed procedure.

#### Negative live checks: dropped for this adoption

This document required the runner to check, against oficina-connect, that
a real Home member lacking local app permission stays refused, and that
revoking directory membership or a connection refuses an existing
delegated connection without removing normal local access. Paul ruled on
2026-11-17 (discussion 103) that these live checks, with their test member
and owner revocation, are dropped for this Oficina adoption. His reason:
revocation is covered by Home's and oficina-connect's own tests. As with
the Plan 2 waiver, this is not a precedent for any other adoption.

What stays: Plan A's two fresh confirmations, and the Calendar canary.
Plan B activates calendar alone. Plan C, the other six apps, is gated
only on Plan B having activated calendar successfully, and stays refused
if calendar has since been rolled back or disabled. Base, added on
2026-11-23, is not covered by this waiver: a plan naming `base` runs the
negative live checks above normally. Synthetic proof of
refusal and revocation stays in integration tests. Until the reviewed
snapshot/observation runner exists, production activation is blocked even
if Home capability is deployed. This document does not authorize
hand-constructing observation digests or bypassing a missing snapshot
facility.

Adoption and Alta share exactly one operator signer, installation, registry
and device on both roles. No native command enrolls a competing stream.
Directory initialize must be sequence 1, before any adoption. Its actual
four-table guard checks roster_generation, roster_consumers, roster_tokens
and roster_operator_receipts; the preflight also checks teams, memberships,
team_instances and both operator streams. Use the shared team-keygen output
only after its own review and CI pass. Existing consumer aliases are checked
against their exact env manifest; no second signer or regenerated keyset is
introduced for the adoption tool.

This supersedes team-provisioning-amendment.md §4's label.app-only rendering
for adoption plans, §2.6/§5's new-instance activation policy, and §8's claim
that a confirmed provisioner cannot affect existing canonical hosts. An
adoption window explicitly allows binding those eight pre-existing hosts to
one confirmed team, changing directory discovery and delegated admission.
It grants no local content permission and cannot change credential env
registrations, existing storage or keys. The operator signer can falsely
attest observations; that trust is explicit and bounded by confirmation.

## Required evidence

- Signed plan roundtrip/persistence, invalid kind/label/app/SQID, changed
  signature and scope, expiry; actual confirmation rendering on both roles.
- Full initialize, owner seed, team seed, canonical provision, existing
  registration verification, verify and activate flow with fresh fixtures.
- Ordinary/native provision refusal, other label/team/app/consumer/origin,
  new-team origin in adoption mode, registration table/env partial matches,
  wrong signature, activation policy substitution and window mismatch.
- Exact replay retains one team/record; no registry duplication; existing
  registration and existing local-content authority preserved.
- Directory/agent discovery exposes only live routes for current members;
  membership removal revokes discovery. Privacy gates cover plan fields and
  no new address/content storage. Existing migrations/gates remain intact.
- Upgrade old pending/open plans, restart and expire new adoption plans;
  demonstrate old-reader incompatibility after activation and verify the
  forward-compatible rollback build. Observer rejects changed storage,
  identity keys, agent team, TeamMode and version body/header mismatch.
- Per app, the runner's automated post-restart delivery check (version
  body/header, healthz, /api/v1/operations 404 or app 401 to agent-access's
  answer) recorded in place of 522 Plan 2, and Plan C gated on Plan B.
- Independent source/evidence review, meaningful adverse mutations, full
  required CI, deployed isolated canary and exact canonical version checks.

No claim of four-client live acceptance follows from these gates. That is a
subsequent authenticated test after actual team setup and connection rollout.
