Repository navigation
ci: verify the stack on the current base (do not merge) - #45
Closed
PermutationResearch wants to merge 162 commits into
Closed
PermutationResearch wants to merge 162 commits into
PermutationResearch wants to merge 162 commits into
Conversation
A separate per-host process: an explicit HTTP(S) proxy per machine that allows only listed host names, refuses private and special addresses after resolving, connects to the address it checked, enforces per-machine limits and writes one JSONL line per request. Nothing is wired into hearth-host yet; that is PR 2. Spec: docs/plans/guest-egress.md. The draft is the Hearth Codex session's (codex/guest-egress-proxy). Changes on top of it: - Enforce the per-machine tunnel limit (E-10). The semaphore existed but only tests acquired it; a request now takes a tunnel before the lookup and holds it to the end, and a refusal is logged as `tunnels`. - Charge plain-request header bytes, both directions, to the per-minute byte budget, through a new exchange_heads seam. CONNECT bytes that arrive with the head are charged too. - A proxy-level test that CONNECT to a port other than 443 is refused and logged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tests/mutations/egress-* each remove one guard the proxy depends on; scripts/gate-egress.sh runs format, clippy, every test (loopback ones included) and those proofs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- docs/plans/guest-egress.md: the approved spec, with PR 1 as built (what it refuses, the seven proofs, which checks ran and which did not). - docs/decisions/guest-egress.md: append-only log of decisions made while building PR 1. - docs/decisions/vibemon.md: slice 0, decided by the owner on 2026-11-03: keep Hearth's Firecracker host, borrow specific pieces. - AGENTS.md: a Lessons section; tests/mutations/README.md: the egress proofs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each machine gets a resolver on its host-side address, port 53, over UDP and TCP, forwarding unchanged to the host's upstream (the config's `resolver`, else the first nameserver in /etc/resolv.conf). Every query writes one `kind: "dns"` line to the same log as the proxy. The proxy and the resolver share one budget per machine; `dns_per_minute` (default 1000) counts UDP and TCP together, and a flood logs its first refusal of the minute only. The forwarder reads only the header and the first question, by hand, instead of adding hickory-proto as the spec proposed: a root process that forwards bytes unchanged needs an id, two flag bits and a name, not a DNS library. Unit and property tests cover the parser. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Three proofs (egress-dns-logged, egress-dns-limit, egress-dns-tcp-answer), the PR 1b as-built section of the spec, and four decision-log entries: the hand-written parser, the shared budget and quiet floods, the resolver default, and DNS as a visible, rate-limited channel out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hearth-host, when /etc/hearth/egress.toml exists (E-9):
- Each TAP's nftables table accepts exactly three new flows, all from its
guest address to its own host address on its own TAP: TCP 3128, UDP 53
and TCP 53. Forwarding stays dropped both ways. The rule shape is the
Hearth Codex session's draft from the shared checkout.
- After a TAP is up it writes {"up":N} to /run/hearth/egress.sock, and
before one goes down {"down":N}. Best effort: no socket or no process
behind it never fails a start or a stop.
hearth-egress:
- Listeners follow those events instead of a static list. `listeners` is
replaced by `proxy_port` (default 3128) and `events`; at start it reads
`ip -j -4 addr show` so a restart finds running machines.
- One failed listener costs that machine that one service; it no longer
ends the process.
deploy/nixos: services.hearth.host.egress.{enable,allow,resolver} writes
the config (0600) and a hardened hearth-egress unit; three new eval checks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Four proofs: the TAP accept names guest and host, no port opens without the config, hearth-egress hears about a slot coming up, and bad slot events are ignored. The gate adds hearth-host's format, clippy and network tests, and evaluates deploy/nixos's checks when nix is present. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- hearth-host appends `hearth.egress=1` to a guest's kernel command line when its egress config exists (direct and jailed launch); otherwise the boot arguments are unchanged. - The login dispatcher reads /run/hearth/egress.env before `env -i` and hands agent commands http(s)_proxy, their upper-case forms and no_proxy=localhost,127.0.0.1, only when the file is a regular file whose first line is exactly a machine's proxy address. - images/nixos/guest.nix: on the flag, hearth-net adds the default route via the host end of the /30, registers it with resolvconf, writes the proxy file and sets the variables for later services; login shells read the same file in environment.extraInit. Without the flag nothing changes. - Four guest eval checks, and a test that the image writes the file the dispatcher reads on the flag the host sets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Three proofs (boot flag only with the config, the dispatcher's address check and link refusal); the gate runs the dispatcher tests and evaluates images/nixos too; PR 2b as built and two decisions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- hearth-host: {"op":"egress_log"} returns complete lines with their exact
byte offsets from a day file, at most 64 KiB, plus each slot's machine.
The file named in a request is matched against the directory's listing
only. File identity is the SHA-256 of the first complete line, not the
first 4 KiB as the spec said: that hash changes while a file is young,
which would have re-ingested every line.
- hearth-control: migration 0089 adds egress_requests (append-only) and
egress_log_cursors. Ingest runs beside the usage sample; each read's rows,
cursor and events commit together, and the unique key on file identity
and offset drops what a re-read repeats.
- Denials: policy refusals become audit rows (`egress.denied`), one per
machine, name and reason per read, capped at 32 so a guest cannot choose
how many it writes. A name not on the allowlist also becomes a papercut
naming /etc/hearth/egress.toml. Events come only from rows the read
actually inserted.
- GET .../machines/{machine}/egress and the console's "Recent outbound":
refusals by default, everything when asked.
0089 is above every number claimed on any branch or checkout (0079-0088);
the live database's schema is at 78.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Eight proofs (log reads, ingest atomicity and dedupe, the denial cap, the list's default), the gate adds the control-plane and console tests, the PR 2c as-built section and five decisions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test failed the read during its inserts, before the cursor was written, so it passed with the cursor outside the transaction; the gate's proof caught that. It now fails while the read's events are recorded, after the cursor. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- hearth-egress: the allowlist can change while it runs. Names approved
through the control plane live in approved-names.json in the state
directory and only add to the operator's config; exact names only. A
`{"reload":true}` event or a 30-second timer reads them again, and a file
that cannot be used keeps the last good list. When a name leaves the list
new requests are refused and its open tunnels close, logged as `revoked`
with their byte counts.
- hearth-host: {"op":"egress_allow"} replaces that file, refusing anything but
exact host names. Each log read reports a digest of the file.
- hearth-control: migration 0090. Someone who may view a machine can ask for
a name it was refused; only an instance admin decides or removes
(Action::ManageEgress). Postgres is the truth: a decision stands whether or
not the host was reachable, and each tick sends the list again when the
host's digest differs. Every step is audited.
- Console: "Ask to allow" in Recent outbound; decisions and removals on the
Hosts page, saying so when the host does not have the new list yet.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Eight proofs, the approval tests in the gate, the PR 2d as-built section with the change-and-revocation table, and four decisions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…names Findings from reviewing #6-#11: - A day file with a partial last line, or a line longer than a chunk, no longer holds the log reader; both are passed over once nothing more can end them. - Sending the approved names is apart from ingesting the log: once per tick, and a failure no longer stops traffic being recorded. - A line older than the machine now on its slot is stored with no owner, so a reused slot cannot credit one team's requests to another. Slots are reused as soon as a machine is deleted, and logs can be read hours later. - A name is stored as the allowlist compares it (lower case, no trailing dot), so what the list shows can always be asked for. - A machine's list shows where only its own refused names stand. It showed every name asked for or approved on the host, across teams. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
More findings from reviewing #6-#11: - NixOS hosts: the firewall's input chain runs after Hearth's table with a default of drop, so guests could not reach their proxy or DNS. The module now opens exactly those ports on the machines' TAPs, for both firewall backends. - Provider sessions start from an empty environment and never saw the proxy; only commands over SSH did. They now read the same checked file. - proxy_port, state_dir and events looked configurable, but hearth-host, the firewall rule and the guest all name the same values, so changing one silently broke egress. They are fixed now, and setting one is an error. - egress_requests expires: requests after 30 days and DNS lookups after 7, a bounded batch per tick. Rows still cannot be rewritten. An index on `at` is added on evidence: 360 ms to 0.02 ms per tick on 3 million rows. The lists took 150-180 ms there, so they get none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
scripts/smoke-egress.sh runs the spec's acceptance list on a real Linux host: a real control plane, sign-in, machines through the API, firewall rules, a proxy and the internet. It adds the review's concerns: the guest's route and resolver, agent and login shells getting the proxy, isolation between machines, asking, deciding and removing a name, and closing an open tunnel. It reports SKIP, never a pass, for what it cannot show. It has not been run: it needs root and KVM. Checked here: bash -n, shellcheck, its argument and preflight paths, and its guest probe against a fake proxy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The allowlist permitted names like `evil.example#.github.com`, `x..github.com` and `github.com..`, and the guard then resolved what the client wrote, not what was checked. None of them reached another domain, since the whole string is one name under the allowed suffix, but that held only by luck and the docs promised one trailing dot. A name now matches only as host labels, `Allowlist::admit` returns its canonical spelling, and the guard resolves that. A wildcard over a numeric name is refused at start, because it would match IP literals. A plain request's `Host` is replaced with the name from the request line, as RFC 9112 asks of a proxy, so a client cannot name a site the allowlist never saw. A folded line goes with the header it continues. This does not change E-2 or E-8: a CONNECT can still ask for another site on the same address inside TLS, and DNS still forwards every name. The decision log says so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Logging and a rate limit made the DNS channel visible but did not bound what left: 1000 names a minute to any domain. The forwarder now reads the proxy's live allowlist for the question's name. A name not on it is answered REFUSED, logged as `allowlist`, counted against the minute, and never sent upstream, so an approved or removed name applies to DNS and the proxy at once. This replaces E-8. A query must carry exactly one question and no answer or authority records. Checking only the first question was not enough, because the packet is forwarded unchanged and a second question would have gone with it. The allowlist now has to cover lookups as well as connections. The guest image runs timesyncd against pool.ntp.org, and the TAP rules drop UDP 123, so listing those names would not make it sync; their lookups are now refused and show up as a papercut. The decision log records this and what stays open. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A guest's TAP accepts the proxy and DNS and nothing else, so UDP 123 has no route out and timesyncd could only fail. Since the forwarder started refusing unlisted names, its lookups also wrote allowlist rows that spent dns_per_minute. The clock comes from the VMM at boot, and every run is a cold boot, because hearth-host has no VM resume. An evaluation check holds the setting. scripts/smoke-slice1.sh now asserts that a guest's clock matches the host's at boot and after stop and start, that timesyncd is inactive on NixOS, and on aarch64 that the PL031 line is in the serial log. That smoke needs root on Linux with KVM and has not run. The Ubuntu image is supplied by the operator and is not changed here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The script asserted that a refused name resolves, which the forwarder no longer does. It now checks that a name not on the list fails to resolve and is logged as `allowlist`, that an approved name resolves with no restart, and that a removed name stops resolving. Its wait for the proxy's refusal of example.com names kind = 'request', because the DNS refusal is now also a row and the wait wanted exactly one. It also checks that timesyncd is inactive and the boot clock is right. Not run: this needs root on Linux with KVM. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Saved before a likely restart of the Mac, which would wipe the scratch worktree. Not compiled yet: rustfmt and the commit hooks passed, and no Rust test has run. The Go request fixture is recorded from the real Go client against a local stand-in. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ream-plan docs(plans): catch the agent chain up with upstream nanocode
…entions docs(agents): prefer enforced checks over written rules
The only conflict was the migration list in db.rs: keep the trunk's 0095_decision_links, then this branch's 0096_worktree_landings.
Landing merges a subagent's branch into its parent's and runs a check command as the person, but land_worktree took any Via, so anything holding the person's CLI token could do it. It now calls require_browser first, like approving a fleet landing (docs/decisions/decisions-need-a-browser.md). Test: a_cli_token_cannot_land_work. Red proof: land-needs-a-browser.
Landing now refuses a CLI token, and this test sent its long-running landing as a raw bearer, so the check never started. It now sends Alice's browser headers, which the harness builds in one place (browser_headers) for call, send and this test.
Let a person land a subagent's worktree
AGENTS.md keeps both: the Cloud Agent section from this branch, then Enforcement and Lessons from the trunk.
The trunk took migrations 95 (decision_links) and 96 (worktree_landings), so agent_journal_author becomes 97; its red proof and the plan follow. requested_cancel keeps this branch's actor_kind check and takes the trunk's Via on the person it returns.
An agent's journal event now names the person it runs under (actor_kind 'agent', actor_user the person). drive_command read actor_user alone, so a user.command row an agent wrote would have run as that person. It now takes the person only from a row whose actor_kind is 'user', and refuses any other before the runner check, so the refusal says why. Test a_command_an_agent_wrote_does_not_run_as_the_person, red proof person-command-an-agent-wrote; person-command-not-started-late's patch follows the reorder.
Cargo.toml keeps both new members, hearth-nix-cache and hearth-approval. The decision log records the owner's 2026-11-23 calls: every path is signed at copy time, and CA stays dropped. nix-grpc-builds.md section 7 says a publication is signed again when copied.
Brings slice-2's 14 commits the candidate lacks (research tools over MCP, approved and accounted model comparisons, ChatGPT plan routes, owned SNP comparisons, the run-isolation WIP) so #13 can land without conflicts. - Migrations: slice-2's 86 and 87 become 98 (comparison_accounting) and 99 (unpriced_usage_baseline). The candidate holds 86, 87-88 are reserved for the self-improvement branch, and #14 takes 97. - Approving a tool call goes through the candidate's calls::record, and the tool.approved event carries both its session and slice-2's comparison_bindings, which comparison.rs reads back. - Config, main, lib, threads and the test world keep both sides' options.
Port 12b0b34 onto the integration candidate. Nothing wrote the improvement.keep_rate signals that the weekly report already reads. Add an on-demand observer for one published Fleet integration at least seven days old: the coordinator's home machine runs a fixed Git helper against the configured repository, and the result is journaled with its source and idempotency key in one transaction. Repository attribution now needs published Fleet evidence. New migration 0087 anchors a registered repository to a Fleet run and makes improvement_signal_observations take repo_id from the verified association only (0085 is applied and unchanged).
The merge renumbered slice-2's 86 and 87; the upgrade test still applied everything before 86 and expected [86, 87].
…the second machine's thread unbound journal_tool_result started at the counter's value, which is the last machine_seq used, so it collided once bind_fleet had journaled an event on the same machine. It now takes each number as insert_event does. The weekly report's aborted thread on a second machine is not bound, as in 12b0b34: one label anchors one machine, path and ref.
…v-721d Document the Cloud Agent toolchain and Postgres test URL
…o-ic Merge slice-2/control-plane into the integration candidate
The trunk now has slice-2's migrations 98 and 99; this branch's 97 goes before them.
The counter must start at 1, so seeding it at 0 tripped its trigger.
…ibution Journal child agents' messages as the agent, not the person
Observe keep rate for published Fleet workers (port of #5)
Cargo.lock is the trunk's, plus hearth-nix-cache's entry.
feat(build-cache): check Nix binary caches before publishing them
…idate Integration candidate: Hearth slices 1-5 with codex/hearth-combined
`cargo clippy --workspace --all-targets -- -D warnings` failed before the test step ran, on code that predates the workflow. - chatgpt_plan_store.rs: import db::GenericClient, so the four advisory-lock `query_one` calls dispatch to the trait method that prepares once and keeps the statement. clippy.toml disallows tokio-postgres' inherent method. - threads/comparison.rs: fold the nested `if` into a let-chain. - chatgpt_plan.rs: move `mod tests` below the items it tests. - hearth-cli/tests/common/mod.rs: one `#![allow(dead_code)]` for fixtures the binaries share but do not all use, and drop the two now-duplicate outer allows. That is how hearth-control/tests/common already does it.
Every TestDb created an empty database and replayed all 99 migrations, so one test binary of 16 tests spent 113 s of its 8 s of actual work on migrations. The suite is 1,554 tests; this is most of why a full run takes over 40 minutes. Each migration cut is now migrated once into `hearth_tpl_<version>_<digest>` and every test copies it with CREATE DATABASE ... TEMPLATE. The name comes from the cut, so an unchanged schema reuses an earlier run's template, and a changed one builds beside it. Creation is serialised by an advisory lock, the template connection is closed before use (Postgres refuses a template with live connections), and a copy that races another gets 20 bounded retries on "being accessed by other users". Same 16-test binary, same machine, with the four macOS-only `setpriv` tests skipped: 113.31 s -> 15.83 s.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Verification only: current base + workflow + lint fixes + template databases. Do not merge; the same commits arrive through #40, #42 and #43.