Continue work on Cthulhu Remote.
This commit is contained in:
1 parent
63e84e9ac7
commit
0c74038c49
16 files changed
+2896
-30
No files matched your search
@@ -0,0 +1,110 @@
|
||||
# Remote connection coordinator
|
||||
|
||||
Implemented as a source-library increment on 2026-11-03, based on Tentacles
|
||||
`63e84e9` and the public Go SDK in reader `573d15d`. The Tentacles branch matched
|
||||
`origin/master` after fetch. The reader revision was inspected locally; its
|
||||
remote branch was not refreshed for this increment. No reader code changed.
|
||||
|
||||
`src/coordinator.go` joins the existing relay transport and membership machine
|
||||
to the reader's protocol 1.1 lifecycle API. It supplies no connection dialog,
|
||||
desktop effects, executable or package. There is still no production issuer of
|
||||
the reader approvals it requires.
|
||||
|
||||
## Ownership and explicit connection
|
||||
|
||||
The coordinator owns one SDK `Events()` consumer for its entire lifetime. Its
|
||||
parent context must belong to the Tentacle process session. Event-stream EOF
|
||||
also cancels it. Do not run a second event consumer alongside it.
|
||||
|
||||
Core `remote.action` events populate a one-element approval channel for
|
||||
UI orchestration. A newer event replaces an unread approval and stops any old
|
||||
connection. The coordinator stores its own copy of the approved role/grants.
|
||||
Neither receiving an approval nor reading settings starts networking.
|
||||
|
||||
The subsequent [connection workflow](connection-ui.md) claims a pending action
|
||||
once and uses its cancellation context for forms and key-free inspection. That
|
||||
context ends on replacement, matching revocation, consumption, disconnect or SDK
|
||||
loss. `disconnect_epoch` retires only the original epoch, so stale form cleanup
|
||||
cannot revoke a newer action or connection. This does not create local consent
|
||||
or replace the reader's expiry check.
|
||||
|
||||
An explicit `connect` call must provide the matching pending action token and
|
||||
epoch, an endpoint with any already-approved pin, and a channel key. It validates
|
||||
and freezes TLS options, consumes the pending approval once and schedules a
|
||||
background attempt. Repeated/concurrent calls are refused. Failed attempts do
|
||||
not restore the approval or retry; a new core action is required.
|
||||
|
||||
The worker calls public SDK `remote.open` before dialing. The reader checks token
|
||||
expiry, role and grants. Denial makes no relay connection. The returned lease
|
||||
must have the expected epoch and a 32-character identifier. Reader-facing
|
||||
`controller`/`controlled` roles map to relay `master`/`slave` roles internally.
|
||||
|
||||
Snapshots distinguish opening a lease, connecting, waiting for a peer, and ready
|
||||
relay membership. **Ready means one opposite-role relay peer, not active desktop
|
||||
control.** Known desktop payloads are validated, counted and discarded without
|
||||
retention. No output/input queue or effect callback is exposed by this increment.
|
||||
|
||||
## Liveness and teardown
|
||||
|
||||
The worker sends `remote.heartbeat` each second, including while TLS/join is
|
||||
pending. Heartbeats and the final close use strictly increasing per-lease
|
||||
sequence numbers. The following stop the relay lifetime:
|
||||
|
||||
- Explicit Disconnect, coordinator close or parent-context cancellation.
|
||||
- A matching-epoch `remote.revoked`, a replacement action or SDK event EOF.
|
||||
- Heartbeat failure, TLS/join/read failure, malformed relay messages, invalid
|
||||
role/origin or any terminal membership change.
|
||||
|
||||
The socket context is cancelled immediately and peer readiness is cleared before
|
||||
waiting for cleanup RPCs. The worker finishes an in-flight heartbeat, then requests
|
||||
`remote.close`; each call has a two-second deadline. It deliberately does not
|
||||
cancel a healthy SDK call during ordinary Disconnect: SDK call cancellation
|
||||
retires the entire Tentacle process session. Reader-side lease expiry remains
|
||||
independent if communication fails. These bounds are not physical-key recovery
|
||||
evidence, and no keyboard service uses this worker yet.
|
||||
|
||||
`disconnect()` returns a completion barrier. No new connection is admitted until
|
||||
the old close finishes. A failed close or invalid lease reply makes the
|
||||
coordinator unavailable for the rest of its lifetime. A fresh process/SDK session
|
||||
is needed; there is no implicit resume, lease recreation or network retry.
|
||||
`close()` additionally stops the event consumer; its `done` channel and the
|
||||
Disconnect barrier allow callers to await both owners.
|
||||
|
||||
Statuses and errors retain no channel key, action token, certificate, server
|
||||
diagnostic, RPC message or received desktop content. The current attempt needs
|
||||
the supplied key for TLS/join only; it is not saved for reconnection. Clearing a
|
||||
Go variable does not promise secure memory erasure. Storage and future local
|
||||
Remember key/trust actions retain their separate contract.
|
||||
|
||||
## Verification and remaining gates
|
||||
|
||||
Run from this repository (private loopback sockets must be allowed):
|
||||
|
||||
```sh
|
||||
GOCACHE=/tmp/cthulhu-cache GOPROXY=off go test -race ./remote/src -count=1 -timeout=60s
|
||||
make check
|
||||
```
|
||||
|
||||
Both passed for this increment. Coordinator fixtures exercise approval denial,
|
||||
token reuse/stale epochs, copied role/grants, both roles, payload discard, peer
|
||||
departure, explicit fresh reconnection, revoke during open, heartbeat during a
|
||||
stalled TLS handshake, SDK EOF, replacement approval, parent cancellation,
|
||||
socket closure during a stalled heartbeat, cleanup ordering and failed-close
|
||||
admission. A pipe fixture uses the actual public Go SDK for negotiation,
|
||||
action/revocation events, open and close against a synthetic host.
|
||||
|
||||
The original pipe fixture runs in-process; the later connection-workflow fixture
|
||||
also exercises a separate SDK process. Neither replaces the reader's existing
|
||||
real-child-process SDK/authorizer tests or establish production consent. `make
|
||||
check` also verifies existing metadata, command registration and actual-host
|
||||
invocation for Hello World, Wormhole and Battery Status. Review the new source
|
||||
and these contracts before submission; neither command installs or replaces the
|
||||
active reader.
|
||||
|
||||
Next: production local consent and lock/handoff integration, endpoint/role
|
||||
selection and registration of the library forms, persistent-pin UI, typed reader
|
||||
output/presentation services and their effect
|
||||
ownership. Xorg provenance/collision safety and virtual/raw Braille remain open.
|
||||
There is no new live workflow to test yet. Audible speech, physical input and
|
||||
Braille, real NVDA/Orca sessions and installed-package behavior remain separate
|
||||
acceptance gates in the parent plan.
|
||||
Reference in new issue
Block a user