Skip to content

Test a PostgreSQL Store's reach from each machine before attaching - #790

Merged
yifanxuaaa merged 2 commits into
layerfs_v2_0_0from
claude/pg-reach-test
Nov 24, 2026
Merged

yifanxuaaa merged 2 commits into
layerfs_v2_0_0from
claude/pg-reach-test

Conversation

@yifanxuaaa

Copy link
Copy Markdown
Contributor

A PostgreSQL Store's server may be on this computer or anywhere else, so reach is tested from each machine, never predicted from the address.

What changes

  • One connection-step classifier (layerfs-persistence diagnostic/step.rs), shared by the doctor's connection check and every reach/status check.
  • Every reach refusal names its step, flat beside error/message: configuration, transport, tls, authentication, database, schema or identity. A refusal checked from a machine also names machine. The loopback refusal stays Unsupported, with step configuration. An unreached worker gets no step.
  • store attach <s> --machine M --dry-run runs attach's own check from that machine, takes no lock and records nothing. It answers { ok, outcome: "tested", store, machine, latency_ms, server_version }.
  • store connect on a connected Store with a changed address, user or password checks from this computer, then from every attached machine, before saving. If a machine fails it refuses Conflict with machines: [{ machine, ok: false, step, message }] and fix layerfs store detach <s> --machine <m>, and saves nothing. A synchronous_commit-only change checks no machine.
  • store connect --dry-run answers { outcome: "tested", here, machines } and saves nothing.
    • If this computer's check fails, the machine rows are ok: null ("not checked").
    • A first connect stops before creating the schema and reports empty: true.
  • Docs, calls.json, families/store.json, CLI guide words and the Node typings are updated.

Commits

  • 7344dbbc49 feat(persistence): one connection-step classifier. Production LOC: 213,951 -> 214,016 (delta +65)
  • 5b9226f223 feat(store): reach refusals name their step; attach and connect dry runs; address changes check attached machines. Production LOC: 214,016 -> 214,323 (delta +307) (control +258, api +49; reference absent, retired R9c)

Checks

Each test binary ran separately under a 120 s limit. The PostgreSQL tests used a private trust-auth postgres:17 server.

  • New tests pass: connection_step, plus two in postgres_login (step names, dry runs record nothing, Conflict on an address change).
  • Also pass: postgres_connect, postgres_refusals, postgres_sandbox_reach, calls_table, doctor_targets, sandbox_machines, usage_lines, rendering, all layerfs-store binaries, and layerfs-control apart from doctor_frame. Clippy -D warnings is clean on the touched crates.
  • Still failing, not from this change:
  • postgres_connect's missing-database test is NOT_RUN without LAYERFS_TEST_PG_URL and LAYERFS_TEST_PG_PASSWORD.
  • Live: installed on the dsh 3080 server. The attach picker's per-row Test and Edit connection's Test show the steps (docker and lima at configuration, a wrong port at transport, native reachable).

🤖 Generated with Claude Code

yifanxuaaa and others added 2 commits November 24, 2026 20:25
…reach checks

A PostgreSQL connection that was not made is classed once, by
`ConnectionStep::of_refused_connection` (SQLSTATE class 28 is
`authentication`, 3D000 `database`, anything else, no answer included,
`transport`): the Store doctor's connection check emits its
`store.connection.<step>` id from it, and every status or reach check's
connect (`connect_status`) carries the same step in
`PostgresStatusError` (`step()`; a URL the connector cannot read is
`configuration`, a query after the connection the `schema`'s). No text
classifier. An error the server sent is now said in the server's words
(`database "x" does not exist`) instead of the driver's bare `db error`.

Tests: tests/connection_step.rs (new); observed_reach's "a server that
answered" check reads the server's words instead of `db error`. No test
deleted.

Production LOC: 213,951 -> 214,016 (delta +65)
  core     42,486 -> 42,486 (0)
  engine   98,276 -> 98,341 (+65)  layerfs-persistence +65
  control  62,877 -> 62,877 (0)
  api      10,312 -> 10,312 (0)
  reference absent (retired R9c; last counted 65,417 at tree 498dd19)
  Method: tools/production_loc.py --detail on parent a84bc2a and the staged tree

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…uns; address changes check attached machines

Owner decisions 2026-11-24: the Store may be anywhere, so the UI tests
reach per machine instead of predicting it, shows the step a failure
stopped at, and a connected Store's address never changes so as to cut
off an attached machine unseen.

- Every reach refusal names its connection `step` (flat, as a `next`
  field): this computer's check (`check::check`, `same_store`, the new
  `first`) and a machine's (`check_from`, the worker's `store.reach`),
  classified by the persistence `ConnectionStep` the doctor uses: no
  schema `schema`, another Store's id `identity`, a missing privilege
  `schema`, a login, database or transport refusal as the connect said
  it. A refusal checked from a machine also names `machine`; the
  loopback refusal (an address the machine does not share), a missing
  saved login and an unreadable address are `configuration`, before any
  dial. A machine whose worker was not reached names no step.
- `store.attach --dry-run`: the same checks, no lock, nothing recorded
  (neither `attached` nor the reach); answers `outcome: tested`.
- `store.connect` of a connected Store is split into `prepare` (input
  checks and this computer's dial) and `Update::save`. A new address,
  user or password is then checked from every attached machine before
  anything is saved; one that fails refuses `Conflict` with `machines`
  `[{machine, ok: false, step, message}]` and the detach of the first as
  its fix. A change of `synchronous_commit` alone checks no machine.
- `store.connect --dry-run` makes the same checks and saves and records
  nothing: `{ok, outcome: tested, store, url, here, machines}`; a first
  connect's dry run checks from this computer only and makes no schema
  (`here.empty` for an empty database). A first connect now dials once
  through the access check before it makes the schema, so its answer's
  reach carries the server version.
- calls.json and families/store.json rows, the CLI guide words, the Node
  typings and the SDK/control/2.0 docs follow.

Tests: postgres_login gains connect_refusals_and_dry_runs_name_the_step
and dry_runs_record_nothing_and_an_address_change_checks_attached_machines,
and its long-form expectation gains `here: null`; postgres_connect's
missing-database test reads step `database` and the server's words;
postgresql_url_corpus drives `prepare` + `save`. No test deleted.

Production LOC: 214,016 -> 214,323 (delta +307)
  core     42,486 -> 42,486 (0)
  engine   98,341 -> 98,341 (0)
  control  62,877 -> 63,135 (+258)  layerfs-control +134, layerfs-sandbox +1, layerfs-store +123
  api      10,312 -> 10,361 (+49)   layerfs-api +49
  reference absent (retired R9c; last counted 65,417 at tree 498dd19)
  Method: tools/production_loc.py --detail on parent 7344dbb and the staged tree

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yifanxuaaa
yifanxuaaa merged commit d3fe2c4 into layerfs_v2_0_0 Nov 24, 2026
@yifanxuaaa
yifanxuaaa deleted the claude/pg-reach-test branch November 24, 2026 12:51
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