Skip to content

store: one PostgreSQL connection on this computer; machines attach - #786

Merged
yifanxuaaa merged 5 commits into
layerfs_v2_0_0from
claude/pg-connect-attach
Nov 24, 2026
Merged

yifanxuaaa merged 5 commits into
layerfs_v2_0_0from
claude/pg-connect-attach

Conversation

@yifanxuaaa

Copy link
Copy Markdown
Contributor

PostgreSQL Stores get one connection, saved on this computer, and machines attach to it (owner decisions 2026-11-24).

Calls

  • store connect <store> <url> --user U --password-stdin [--synchronous-commit X]: a new Store needs user and password and is checked from this computer before anything is saved. Run again, it changes the address, user, password or setting; an omitted user or password keeps the saved one, and the new values must reach the same Store (binding).
  • store disconnect <store>: forgets the Store, its saved password and its attachments; data stays.
  • store attach <store> --machine M / store detach <store> --machine M (new): attach checks from M with the saved URL and login; detach is refused InUse while a Sandbox of the Store is on M. Machine native is an ordinary machine here: it attaches like any other, and its platform's loopback decides whether a loopback URL is allowed.
  • sandbox.create for a PostgreSQL Store's project runs only on an attached machine. With no machine named it uses the only attached one, and refuses otherwise (attach fix, or next.machines).
  • store doctor: from this computer, then every attached machine (--machine M: that machine only).
  • store get / store list: url, user, password_saved, password_changed_at, reach (this computer), machines with their reach. store.connect records this computer's reach.
  • machine.get / machine.list: new read-only loopback: shared | apart, from the platform adapter.

Removed, with no compatibility or fallback

store save-auth, store auths, store remove-auth, store update, --auth, --machine on connect/disconnect, per-machine own addresses (OwnConnection) and all old-record handling. An old record fails through the normal path.

Commits

Checks (merged tree, real postgres:17, each test command <= 120 s)

  • Clippy -D warnings: workspace, all targets, with --features layerfs-api/machine: clean.
  • layerfs-store 108/0, layerfs-platform 107/0, layerfs-machine 19/0, layerfs-control 172/1.
  • layerfs-api --features machine: postgres_login 2, postgres_refusals 6, postgres_connect 2, postgres_sandbox_reach 1, sandbox_machines 7, store_routes 6, doctor_targets 7, machine_calls 1, gc_calls 14, all passing; calls_table 25/1, contract 11/1.
  • The three failures are upstream: store.repair_mount_holders and the doctor checks store.mount_holders / store.gc_audit (fix(gc): make the merged lean GC authority (#770) never worse than the base #783/fix(gc): close the lean place-authority gaps left after #783 #784) are in the code but not in core/docs/issues/call-surface-2-0/calls.json, so doctor_frame, calls_table and contract fail on layerfs_v2_0_0 without this branch too. Not fixed here.
  • Earlier on the branch (before the merge): layerfs-sandbox 172/7, the same 7 pre-existing macOS failures (lp176_image_recovery, workspace_isolation); generator checks, Python stubs and Node calls/coverage pass.
  • NOT_RUN: live Sandbox tests on a VM machine, api/mcp tests (@modelcontextprotocol/sdk not installed).

The dsh-layerfs UI for this (Store tab rows, Connect / Edit connection, attach picker) is on dsh-layerfs branch claude/store-rows.

🤖 Generated with Claude Code

yifanxuaaa and others added 5 commits November 24, 2026 15:29
Owner direction 2026-11-24: this computer is the one place a PostgreSQL
Store's URL and login are saved; machines attach to the Store and dial
with both; no machine has an address or a login of its own.

Calls:
- store.connect(store, url, { user, password, synchronous_commit });
  shell `--user U --password-stdin`. A first connect needs both and
  checks them before saving; the record keeps url, user,
  synchronous_commit and binding, the password goes to the home secret
  `secret/login/<store>.json` (never answered, logged or recorded) and
  into the URL only when dialled. On a connected Store it changes the
  address, user, password or setting (omitted ones keep the saved ones)
  after reaching the same binding; outcome `connected` or `updated`.
  A sqlite Store of the name is `Exists`.
- store.disconnect(store): no --machine; also forgets the saved
  password and every attachment.
- New store.attach(store, { machine }) and store.detach(store,
  { machine }): attach checks from the machine (it must exist and run
  PostgreSQL Sandboxes) before recording it in the record's `attached`
  list and its reach (`attached`, or `checked` again); detach is InUse
  while a Sandbox of the Store's projects is on the machine, NotFound
  when not attached. sqlite and `native` are InvalidInput.
- sandbox.create on a machine not attached is refused InvalidInput
  with `layerfs store attach <store> --machine <machine>` as its fix.
- store.doctor checks this computer, then every attached machine (or
  --machine alone, which must be attached); a host failure checks no
  machine.
- store.get/list: url, user, password_saved, password_changed_at,
  binding, reach, machines ({machine, reached, reach}; names in list
  and the home tree); auth and connections removed.
- Removed with no alias: store.save_auth, store.auths,
  store.remove_auth, store.update, --auth, --machine on connect and
  disconnect, OwnConnection.

No migration or backward compatibility (owner override): the old-format
handling is deleted, not replaced. Removed: record.rs outdated fields,
refused URLs, without_old_fields, legacy() and OwnConnection;
login.rs's save-auth fix machinery (no_auth_fix, missing_fix,
login_fix, fix_of, update_fix); state.rs's PostgreSQL `outdated` and
`missing` derivation; store_target.rs own_state; connect.rs readdress,
refuse_settings and legacy checks; postgresql/update.rs. A record
without the new fields fails through the normal dial path.

Docs: api/sdk/store.md, control sqlite-and-postgresql.md, versioned
2.0.0 calls.md, machines-and-stores.md and migration.md, the doctor,
home, platform, worker, sdk and front-end guides, the JS SDK skill,
the call spec (calls.json, families/store.json, families/home.json,
81 calls); regenerated index.d.ts, the Python stubs, coverage.md and
mcp.md's profile table.

Deleted tests (they drove removed calls or the retired saved-login and
own-address model):
- api/crates/layerfs-api/tests/postgres_connections.rs (whole file):
  an_old_record_reads_outdated_until_its_fix_connects_it_again,
  an_update_racing_a_login_removal_never_names_a_removed_login,
  every_side_that_connects_is_listed_with_what_was_seen
- api/crates/layerfs-api/tests/postgres_update.rs (whole file):
  addresses_and_logins_are_proven_before_they_are_saved
- control/crates/layerfs-store/tests/postgresql_no_auth.rs (whole
  file): a_key_value_address_is_refused_before_anything_dials_it,
  a_record_with_no_saved_login_is_refused_with_the_save_auth_fix,
  a_saved_login_goes_into_the_dialled_url,
  its_state_is_broken_outdated_with_the_same_fix,
  the_login_replaces_the_user_part_its_client_reads
- postgres_refusals.rs:
  a_login_is_saved_privately_listed_without_its_password_and_removed_when_unused
  (rewritten: connect_refuses_a_login_in_the_url_and_a_missing_login,
  disconnect_refuses_a_held_store_then_forgets_it_and_its_password,
  attach_and_detach_refuse_what_is_not_theirs, an_old_url_login_is_never_shown)
- observed_reach.rs: a_login_file_that_cannot_be_read_is_a_broken_row,
  a_missing_login_reads_missing_and_wins_over_old_fields,
  old_fields_read_outdated_and_an_update_drops_them_but_never_a_url,
  connections_list_every_side_that_connects (replaced by
  machines_list_the_attached_machines_with_their_reach,
  a_missing_password_is_refused_and_a_saved_one_is_dialled)
- postgresql_url_corpus.rs:
  a_machine_address_is_connected_again_and_an_update_names_its_login,
  an_update_fix_dials_only_with_the_login_it_names,
  an_update_never_rewrites_a_url_to_another_host (replaced by
  a_connect_never_rewrites_an_older_url_to_another_host)
New: api/crates/layerfs-api/tests/postgres_login.rs.

Production LOC: 211762 -> 211291 (delta -471)
  core 42163 -> 42163 (0), engine 97424 -> 97424 (0),
  control 61844 -> 61437 (-407), api 10331 -> 10267 (-64);
  reference absent (retired R9c; last counted 65,417 at tree 498dd19).
  Method: python3 tools/production_loc.py --root <tree> on `git archive`
  of the parent fe9b4d1 and `git checkout-index -a` of the staged
  tree; nonblank, non-comment product source, tests, docs, tools and
  generated stubs excluded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner correction 2026-11-24: "this computer" (the host) is the control
process: the home, records, secrets, the Store's saved connection and
the check made from this computer. It is never a machine and never
named `native`. Machine native is the built-in machine with
Platform::Native; what it allows (shared loopback, local executor)
comes from its platform, not its name.

- store.attach / store.detach accept native like any machine: the
  platform support check, the reach check from that machine (its
  Loopback decides whether a loopback URL is allowed) and the record.
  The "machine native is this computer, which every PostgreSQL Store is
  attached to" refusal is gone.
- sandbox.create needs the machine attached, native included, with the
  same refusal and fix. With no --machine, a PostgreSQL Store's Sandbox
  no longer defaults to native: exactly one attached machine is used;
  none is refused InvalidInput with `layerfs store attach <store>
  --machine <machine>` as its fix; several are refused InvalidInput,
  listed in next.machines, asking for --machine.
- store.doctor checks this computer, then every attached machine,
  native only when attached; --machine native follows the same rule
  (refused with the attach fix when not attached).
- Reaches: this computer's check stays `here`, machine native's is
  `reach.native`; observed.rs no longer folds native into `here`, and
  the doctor no longer drops native from the attached machines.
- store.connect attaches nothing (unchanged, now documented).

Tests updated: observed_reach (native's reach is its own),
postgres_refusals (native attach dials and fails Unavailable against
a dead address; detach NotFound), postgres_login (doctor --machine
native refused until attached; native attached against a real server,
checked again, in the doctor's rows and store.get, detached),
postgres_sandbox_reach (native attached first), sandbox_machines (no
default machine: none and several refused; one attached used; live
test attaches native). No test deleted.

Docs: api/sdk/store.md, sandbox.md, README.md, control
sqlite-and-postgresql.md, versioned calls.md and machines-and-stores.md,
the JS SDK skill's store and sandbox pages, the call spec notes and
sandbox.create's machine help (also in the guide).

Production LOC: 211291 -> 211308 (delta +17)
  core 42163 -> 42163 (0), engine 97424 -> 97424 (0),
  control 61437 -> 61455 (+18), api 10267 -> 10266 (-1);
  reference absent (retired R9c; last counted 65,417 at tree 498dd19).
  Method: python3 tools/production_loc.py --root <tree> on `git archive`
  of the parent 2dd49a2 and `git checkout-index -a` of the staged
  tree; nonblank, non-comment product source, tests, docs, tools and
  generated stubs excluded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- store.connect (a first connect and an update) records its own check
  as this computer's reach (`here` in the Store's observation file, the
  record store.doctor writes): ok, with how long the check took. It is
  written only after the connect is saved; a refused connect records
  nothing. store.get's `reach` is no longer "not checked" right after a
  connect.
- machine.list items and machine.get answer a read-only `loopback`:
  `shared` or `apart`, from the platform adapter's `Loopback`
  (layerfs_platform::shares_loopback); null for a removed platform or a
  record that describes no machine. Long form, after `supports`.
  Clients read it instead of testing platform names.

Tests: postgres_login (reach after a first connect and an update; a
refused connect leaves observed.json unchanged), machine_calls (native
shared; docker apart off Linux), machine_removed_platforms (null).
No test deleted.

Docs: api/sdk/machine.md, api/sdk/store.md, control
sqlite-and-postgresql.md, versioned calls.md; call spec machine.get and
machine.list long keys.

Production LOC: 211308 -> 211342 (delta +34)
  core 42163 -> 42163 (0), engine 97424 -> 97424 (0),
  control 61455 -> 61487 (+32), api 10266 -> 10268 (+2);
  reference absent (retired R9c; last counted 65,417 at tree 498dd19).
  Method: python3 tools/production_loc.py --root <tree> on `git archive`
  of the parent ebf6697 and `git checkout-index -a` of the staged
  tree; nonblank, non-comment product source, tests, docs, tools and
  generated stubs excluded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The doc comment said a sqlite Store's file sits in the home "while it is on
native". The file is in the home while the Store is on the machine whose calls
run in this process; native is only today's such machine. Comment only.

Production LOC: 211342 -> 211342 (delta 0)
Scope and method: tools/production_loc.py --root on the worktree before and
after the edit (core/engine/control/api; reference absent, retired R9c; last
counted 65,417 at tree 498dd19). Comment-only change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nect-attach

Conflicts, resolved keeping both sides:
- api store/mod.rs: upstream's new `repair_mount_holders` call is kept; this
  branch's removal of save_auth, remove_auth and update stands.
- layerfs-platform lib.rs and setup/mod.rs: the re-export lists keep both
  upstream's `provider_state` and this branch's `shares_loopback`.

Adapted to this branch's API: control/crates/layerfs-store/tests/repair_postgresql.rs
(added upstream) saves the password under the Store's name and records the
user in `StoreRecord::connected`, instead of a named saved login.

Production LOC: 211342 -> 213839 (delta +2497)
Scope and method: first-parent comparison (this branch's 2f81c3d vs the
merged tree) with tools/production_loc.py --root on `git archive` of the
parent and `git checkout-index -a` of the staged tree. The delta is
upstream's work merged in (#781 native boundary, #783, #784 and the other
layerfs_v2_0_0 commits since fe9b4d1), not new code on this branch.
Reference absent (retired R9c; last counted 65,417 at tree 498dd19).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant