ci / checks (push) Successful in 51s
ci / test (push) Successful in 1m1s
ci / chart (push) Successful in 5s
ci / web (push) Successful in 18s
ci / docker (push) Successful in 6s
ci / publish-edge-image (push) Successful in 11s
ci / publish-edge-chart (push) Successful in 4s
A message posted without a mention while the agent worked waited for the
next turn, so the model read it only once the work the line was about was
finished. The spec's turn rules already promised the mid-turn half ("the
next step of the running turn"); the runner implemented the turn-boundary
half only.
The turn now hands the framework's steering hook a source over the room's
`absorbed_seq` cursor. The driver drains it between two steps and appends
one User-role message per drain, so the line lands in the history without
the step in flight dying. The drain stops at the first line it cannot
carry, a mention (the drop path owns that one) or a message with images (a
line of text cannot hold them), and leaves the cursor there, so the
boundary pass appends them in the log's order.
The row has one writer. `drain` carries the cursor in memory only, and
`commit` writes it after `save_session` succeeds, which is the order the
boundary pass already uses: append, checkpoint, advance. The boundary pass
hands its own cursor to the turn in the config the turn reads, so the
first drain never reads back what that pass just appended. A line retired
too early would be gone, one that comes back is deduped within the turn.
A mention still drops the turn: that is the only way to stop a running
command, and this change does not touch it.
Co-authored-by: Kosmos <kosmos@vhaudiquet.fr>
112 lines
5.0 KiB
Markdown
112 lines
5.0 KiB
Markdown
# AGENTS.md
|
|
|
|
Conventions for working in this tree.
|
|
|
|
## Before every commit
|
|
|
|
```sh
|
|
cargo fmt --all
|
|
cargo clippy --all-targets -- -D warnings
|
|
cargo test
|
|
(cd web && pnpm typecheck && pnpm build)
|
|
```
|
|
|
|
`cargo fmt` may touch files you did not edit. Include those changes in
|
|
the commit rather than leaving the tree dirty. `web/.output/public` is
|
|
gitignored; the server rebuilds nothing, so build it before testing the
|
|
whole app.
|
|
|
|
## What this is
|
|
|
|
rhema-together is a separate product that depends on the Rhema crates
|
|
from crates.io, at a version pinned in `Cargo.toml` and `Cargo.lock`. It
|
|
is not `rhema-claw` and it is not a mode of it.
|
|
The claw is resident and single-owner; this is a room with accounts,
|
|
many sandboxes, and invite links.
|
|
|
|
Rules:
|
|
|
|
- Do not point the manifest at a local checkout of the framework. If a
|
|
framework change is needed, note it in `specs/rhema-together.md` §11
|
|
and keep the workaround local until a release carries it.
|
|
- Do not copy claw code. `rhema-code` may be read for a pattern (the
|
|
turn-level steering in `src/room/runner.rs` is copied from its turn
|
|
loop), and the spec says where.
|
|
- The sandbox is the security boundary. Approval is always `AllowAll`;
|
|
never add an approval prompt in the room.
|
|
- The control plane never opens an ssh connection and never parses ssh,
|
|
HTTP, or terminal bytes from a sandbox. `src/worker.rs` owns the data
|
|
plane: one disposable process per target, one room's key on stdin, a
|
|
loopback route behind a random token, no database, no master key.
|
|
Keep new sandbox parsing there, not in `src/api` or `src/room`.
|
|
- Every path into the sandbox goes through `rhema_sandbox::Sandbox` or
|
|
`ShellSandbox` (agent tools, files, terminal, preview). Do not spawn a
|
|
command on the host for room work.
|
|
- Secrets never leave the server. Provider keys and ssh private keys are
|
|
sealed with `crypto::Secrets`; no route returns a decrypted key.
|
|
|
|
## Map
|
|
|
|
```
|
|
src/main.rs process start, listener, background jobs
|
|
src/config.rs YAML + TOGETHER_* env
|
|
src/db.rs schema and migrations
|
|
src/crypto.rs ChaCha20Poly1305 secrets, preview HMAC
|
|
src/auth.rs sessions, cookies, CSRF
|
|
src/state.rs AppState: db, hub, secrets, runner, tunnels
|
|
src/api/ routes: auth, settings, rooms, messages, files
|
|
src/room/agent.rs per-turn config, ssh sandbox, HostAgent assembly
|
|
src/room/runner.rs one task per room; mention -> turn; steering
|
|
src/room/message_tool.rs the agent's voice in the room
|
|
src/room/preview_tool.rs the agent's preview target
|
|
src/worker.rs disposable data plane: loopback HTTP, PTY, forward, worker spawn
|
|
src/ssh.rs russh client and PTY pump, used only by the worker
|
|
src/preview.rs signed preview hosts, worker forward, static reads
|
|
web/app/ Nuxt 4 SPA (no SSR)
|
|
```
|
|
|
|
## Invariants
|
|
|
|
- A room is visible only to its members. Every room route calls
|
|
`member_of` (or checks the member row directly).
|
|
- Mutating API calls require the `X-CSRF-Token` header matching the
|
|
`together_csrf` cookie. The cookie is readable by JS; the session
|
|
cookie is `HttpOnly`.
|
|
- Guests may join and chat. Only `kind = "user"` accounts create rooms
|
|
or add providers and sandbox targets.
|
|
- Room log events are append-only. `seq` is the ordering. Durable
|
|
events (`message`, `notice`, `turn_start`, `turn_end`, `tool_result`,
|
|
`preview`) are stored and replay from `?since=`; deltas are broadcast
|
|
only and may leave gaps.
|
|
- The agent speaks through `message` only. It must always send one
|
|
before its last message. `message` is `ReplaySafety::Unsafe`.
|
|
- Turns are serialized per room. A new mention while a turn runs drops
|
|
the turn future (turn-level steering) and starts a new turn over the
|
|
committed session. A message without a mention never drops anything:
|
|
`runner::RoomSteering` hands it to the framework's steering hook, which
|
|
appends it at the next step boundary; the turn advances `absorbed_seq`
|
|
once that session is saved, so the next boundary pass cannot repeat it.
|
|
Do not drop the room task.
|
|
- The preview host label is `r<room>-p<port>-<expiry>-<hmac>.<preview
|
|
host>` for a port, or `r<room>-s<hash>-<expiry>-<hmac>.<preview host>`
|
|
for a static target. The HMAC covers the target and expiry with a key
|
|
derived from the master key. The static hash covers the root and entry
|
|
file. The preview origin must be a wildcard DNS zone for subdomains to
|
|
resolve.
|
|
|
|
## Testing
|
|
|
|
- `cargo test` runs the unit tests in the binary.
|
|
- An end-to-end turn needs an ssh target and a provider. A fake
|
|
OpenAI-compatible server (SSE `chat/completions`) plus `sshd` on
|
|
localhost is enough; see `specs/` and the commit log for the manual
|
|
run. Do not commit a live API key.
|
|
- The first account is created through `/setup` and printed as a
|
|
one-time URL in the server log; there is no default password.
|
|
|
|
## Commits
|
|
|
|
Conventional Commits, a short imperative subject, a body that says why
|
|
when the change is not obvious. Scopes: `server`, `api`, `room`, `ssh`,
|
|
`preview`, `web`, `spec`, `docs`. One logical change per commit.
|