Commit graph

33 commits

Author SHA1 Message Date
acamilo
6612f9ae9c feed bus in production: fly-feed switch, flysim wants the edge, watchdog checks the edge and falls back, deploy refuses a release without fly-edge 2026-10-01 22:10:44 +00:00
acamilo
ac7be4a204 infra: fly-cpu-confine also confines /.lxc, check ignores its own chain (PERF-02 review R1-R3)
apply/release/status now cover the cgroup pct exec lands in (/.lxc, only when
it already exists, warn-only when unwritable). check no longer counts its own
process or its parents. Runbook: rollback via an older 05-deploy needs
fly-cpu-confine release; the exact post-first-deploy status/check commands.
2026-10-01 15:57:46 +00:00
acamilo
ab537d1045 infra: the sim's cpus are exclusive to the sim (PERF-02 review N1)
A pinned sweep worker cannot leave its cpu, so any sustained cpu-bound process allowed there
collapsed the session runtime to 0.14x real time. flysim and flysim-session now run in
flysim.slice (AllowedCPUs = the sim's set) and bin/fly-cpu-confine, run by their ExecStartPre,
confines system.slice, user.slice and init.scope to the other cpus. It refuses while a sim unit
still sits outside the slice (shrinking system.slice under it would make it float). Without a
partition the deploy writes FLY_SESSION_PIN=0. fly-recap and fly-retention run at SCHED_IDLE.
The drop-in plan is one function (cpuset_dropin_plan) shared by the deploy and lint; lint covers the
plan, the units, the deploy wiring and fly-cpu-confine against a stub systemctl and a fake /proc.
Runbook and README updated.
2026-10-01 15:01:47 +00:00
acamilo
390d118460 infra: fly-shadow-run check reads fly.env as KEY=VALUE lines, never sources it
fly.env is systemd EnvironmentFile syntax; GAME_TITLE=Pokemon Red is valid
there and a shell error when sourced. The v0.7.3 cutover's check died on it
(exit 127) after a passing verdict. Parse it as fly-runtime does; lint
refuses any infra/bin script that sources fly.env.
2026-10-01 09:54:11 +00:00
acamilo
ff67e6cdd6 shadow: a trace stop ends the verdict's window; a pass counts only brain time after the last coverage gap (SHADOW-02 review B2)
A stopped trace (no consumer, byte cap) is no longer an allowed skip: the shadow drops the brain time and saves compared before it, so a restarted box shadow that replays a stopped trace cannot count pre-gap time. The relay closes coverageLost only when the verdict's window.lastStopTrace is the lost trace or later, persists coverageLost (fsync) before forwarding the stop, and check refuses a verdict without a window. Runbook: a mid-run relay restart costs the run.
2026-10-01 03:49:18 +00:00
acamilo
b39ee8e805 shadow: a lost coverage is never forgotten (SHADOW-02 review B1) and the review notes
B1: after an outage of more than ten minutes flysim stops its trace for want of a
consumer and the live fly runs untraced. When the link heals the relay reported healthy
and, counted in trace lines, the box's lag fell under the catch-up bound before its
shadow reached the stop, so `check` could pass for about a minute. The relay now scans
the trace bytes it forwards for that stop and sets a sticky coverageLost in relay.json
(kept across a relay restart of the run; cleared only by a new shadow window, which
takes the stop as history) and reports itself not healthy. `check` refuses on
coverageLost, on a live trace not written for 90 s, and on a run id that is not the
drop-in's (also for a verdict that carries one without a remote drop-in).

Notes: the divergence files the box may send are bounded (after a diverged verdict, at
most three, capped in size); the saves queue holds twelve minutes and the relay unit
gets 1G; fly-shadow-remote-setup keeps authorized_keys in a root-owned home apart from
the mirror, never follows a symlink there as root and requires --from; the runbook
documents the clock-skew refusal, the recovered-stop rule and the first-hour RTF watch.
Also: the ingest lists the mirror's traces under its ledger lock (a file created between
the listing and the lock was marked finished).
2026-10-01 00:45:54 +00:00
acamilo
56a315eda1 shadow: SHADOW-02, the shadow run on a build box
The on-container shadow cost the live fly real time (RTF 0.9998 -> 0.93-0.98,
27 ms/frame on shared CPUs, falling behind every hour). fly-shadow gains:

- relay (release container, as flyshadow.service): streams new saves, the
  trace bytes of this run and the sugar journal over one ssh connection;
  writes the box shadow's verdict back (runId-bound, lagTransitions plus the
  unsynced tail, a relay member) and keeps flysim's consumer heartbeat fresh
  only while connected, the box shadow of this run is alive and the box has
  everything that was on disk a minute ago; exits 3 on a remote divergence.
- ingest (build box, the relay key's forced command): checks the release
  directory and binary hashes against its own, resets the mirror for a new
  run, writes the mirror and reports acks, liveness, verdict, divergence.
- run --run-id-file: the verdict carries runId; a new id exits 4.
- coverage: a no-consumer trace stop while following is a coverage
  divergence (a stop that predates the shadow stays a trace-cap skip); the
  journal is read before the trace directory is listed.

tests/shadow_remote.rs runs a real flysim, the relay, the real ingest binary
and a remote shadow through a restart, a remote shadow death and a sync
stall (coverage divergence relayed back).

infra: fly-shadow-run start runs remote with /etc/fly/shadow-remote.env
(a flyshadow.service drop-in running the relay; --local keeps the old
placement), check also needs relay.json healthy; infra/box/ holds the build
box's flyshadow-remote.service/.path and fly-shadow-remote-setup (release at
the same path, root-owned restrict,command= authorized_keys); 02-base adds
openssh-client. Runbook, lint and a dated legacy-gameboy-v1 section 18
amendment.
2026-10-01 00:45:54 +00:00
acamilo
e4272ba00d infra: a reset's replay is not progress; the ladder measures progress and catches against the reward names it has seen (row 70 review r3)
The watchdog names each lasting reward in window.progress.keys (kind:label).
fly-loop-recover keeps progressSeen (last 2000 names): only a new name starts
the ladder over (and only after a clear probe past SETTLE), and only a new
species opens the 2 h protection. Restarts stay HOLD apart after a start-over;
a failed reset does not mark its archive. Only-rung-11-escapes trap: 2.1 h
(3.3 h after a catch), was 5.6 h / 6.8 h; v0.7.0 2.1 h.
2026-09-30 23:58:13 +00:00
acamilo
d7f5ef5ff7 infra: the recovery ladder starts over after real progress, keeps a recent catch, and never replays one archive twice (row 70)
Check 10 now reports window.progress (a milestone, and pokedex/area/trainer/badge rewards; the
species alone), read by no rule. fly-loop-recover returns to level 0 when lasting progress
follows the last step by more than SETTLE, demotes a milestone reset to a restart within six
hours of a species owned, and never restores the archive the last reset restored (a restore is
deterministic: the live rung-11 replay matched the first one event for event and walked into the
same trap). Ladder tests, lint check 10 case 9, loop-recovery.md, macros-traps row 70b-e.
2026-09-30 20:57:52 +00:00
acamilo
6c0cc2b717 infra: session stops the shadow and guard; shadow start verifies its cpuset
fly-runtime session now stops a running shadow and its guard (fly-shadow-run stop,
no flysim restart) once flysim is healthy on the session runtime, so the guard
cannot judge the session against the legacy baseline during the probation. The
runbook cutover drops the restart in step 5.

fly-shadow-run start refuses, starting nothing, unless flyshadow's cpuset drop-in
exists and its AllowedCPUs is non-empty and disjoint from flysim.service's.

Tests in infra/tests/lint.sh cover both.
2026-09-30 13:36:12 +00:00
acamilo
c1f0dde9e9 infra: CUT-01 speed probation after fly-runtime session
fly-runtime session now starts fly-runtime-probation (timer every 60 s, 30 minutes):
after a 300 s warm-up, a sustained median realtime factor below 0.97 or lag growth
over 30 s in a 10-minute window runs fly-runtime fallback with reason speed. A pass
writes /run/fly/runtime-probation.json and stops the timer; fly-runtime legacy and
every fallback cancel it; state on disk resumes it after a reboot. Lint drives it over
synthetic traces; runbook gets the end-to-end cutover procedure.
2026-09-30 12:58:05 +00:00
acamilo
416c73941a lint: the build and package checks name flysim-session, fly-shadow and fly-session together 2026-09-30 10:19:32 +00:00
acamilo
b3f6d6fbba Merge port/shadow-01 (SHADOW-01) into v0.7.0 release candidate
Conflicts: deploy/build/package scripts (flysim-session, fly-shadow and fly-session all
built, packaged and given cpuset drop-ins; fly-runtime and fly-shadow-run both converged),
fly-legacy-session Cargo.toml and lib.rs (service and shadow both kept, tokio gains signal),
runbook and implementation guide (both sections kept).
2026-09-30 10:09:01 +00:00
acamilo
b996695f0a Merge port/serve-01 (SERVE-01) into v0.7.0 release candidate
Conflicts in fly-legacy-session task.rs (feed record next to PERF-01 profile spans) and
fly-session coordinator.rs (media_bytes doc, read_agent_extension and trim_records kept
alongside PERF-01 spans, publish span and publish metric both kept).
2026-09-30 10:06:03 +00:00
acamilo
f7ca35ba2c infra: the shadow guard survives the shadow's crash-restart delay; check needs a live guard and a baseline; refuse a verdict dated in the future
Review round 3, G1-a: the guard stops only when flyshadow's ActiveState is inactive or failed
(systemctl show), not while it is activating/auto-restart. check also requires the guard timer
active and baseline.json. allows_cutover refuses an updatedAt more than 60 s ahead of the clock.
Lint drives the guard and check with a fake systemctl; a real systemd 257 user manager run is
kept in the review notes.
2026-09-30 04:06:38 +00:00
acamilo
5a7747210f Merge main (v0.6.7: row 68 damage reward, adapter pokered-unique8-v8) into port/shadow-01 2026-09-30 03:16:36 +00:00
acamilo
19d84de387 infra: the guard judges the live fly against its own baseline (SHADOW-01 review round 2, G1)
fly-shadow-run start measures a 10-minute baseline before the shadow
exists (sixty 10-s realtime-factor means: mean, spread; the lag growth
rate). The guard trips only on a sustained degradation against it: 3
checks in a row where the last 5 samples of the same process fall below
the baseline realtime factor or grow lag faster than the baseline rate,
by more than max(0.05, 4 x spread / sqrt 5). It stops itself when
flyshadow.service is not running; check refuses after a guard trip or
with the shadow down. lint drives the rule over RTF traces shaped on the
release CT (a flat 0.66, 0.77-0.99 noisy, real time with hiccups) which
must not trip, and degradations which must. Section 18 and the runbook
follow.
2026-09-30 01:39:52 +00:00
acamilo
2d8b529f42 infra: the shadow's live-impact guard (SHADOW-01 review N2, N1)
fly-shadow-run start records the live fly's baseline (fly_realtime_factor
over 10 s, fly_lag_seconds, uptime), waits for the shadow's heartbeat and
starts flyshadow-guard.timer. fly-shadow-run guard (every 60 s, root)
stops the shadow and the guard, removes the trace drop-in and restarts
flysim without the trace when fly_lag_seconds grew 1 s in the same
process or the mean realtime factor fell below min(0.97, baseline-0.03);
a paused fly is not judged, a restarted one rebaselines. check passes
--current /opt/fly/current --binary flysim-session. lint drives the
guard's rule on six cases. Runbook rewritten: the trace cannot outlive
the shadow (heartbeat, 8 GiB directory cap), not the old claim.
2026-09-30 01:39:52 +00:00
acamilo
095cf7b1da infra: flyshadow.service and fly-shadow-run (SHADOW-01)
Report-only unit, off by default, not bound to flysim, SCHED_IDLE on the
page and encoder CPUs, stays stopped after a divergence (exit 3).
fly-shadow-run start|stop|status|check installs the flysim trace drop-in,
restarts flysim once and reads the verdict. Deploy, build and packaging
ship fly-shadow and fly-session; lint holds the unit to its rules; the
runbook has a Shadow run section.
2026-09-30 01:39:42 +00:00
acamilo
6c7c58b35a infra: RestartMode=direct so OnFailure= fires only at the start limit; one lock for fly-runtime rollback and fallback
Verified on systemd 257: with the default RestartMode=normal the unit passes through failed
before every auto-restart, so OnFailure= ran on the first crash. The session drop-in now sets
RestartMode=direct. session, legacy, fallback and the trap rollback share one flock; a switch
holds it only until its restart is queued (restart --no-block, health checked against the new
invocation), and the rollback skips restoring an older drop-in once a fallback has completed.
lint.sh covers the drop-in key, the interleaving and the shared lock; runbook corrected.
2026-09-30 01:36:23 +00:00
acamilo
1d29ab1ff8 infra: persistent session-to-legacy fallback, signal-safe fly-runtime, MALLOC_ARENA_MAX=2
The fallback used to live only inside one 'fly-runtime session' invocation. The session
drop-in now carries OnFailure=fly-runtime-fallback.service and a 3-starts-in-10-minutes
start limit, so a session binary that will not stay up puts flysim.service back on legacy
after a reboot, a watchdog or loop-recover restart or a deploy. 'fly-runtime fallback'
removes the drop-in, daemon-reloads, restarts on legacy, writes /run/fly/runtime-fellback.json
and a journal line; it is locked, idempotent and keeps the drop-in if legacy cannot start.
fly-runtime traps INT/TERM/HUP and any failure during a switch and rolls back to the
previous state. Session drop-in and flysim-session.service set MALLOC_ARENA_MAX=2.
05-deploy keeps the chosen runtime (operator decision: session stays, trust gates),
refreshes the drop-in in place, and says so; the runbook documents all of it.
lint.sh drives the fallback, the interrupts and the deploy policy against a fake systemctl.
2026-09-30 00:11:25 +00:00
acamilo
0012759ace infra: flysim-session.service, fly-runtime, and shipping the session runtime
fly-runtime session|legacy|status switches which binary flysim.service runs
with one drop-in (flysim.service.d/10-runtime.conf), so fly.target, flyedge's
Requires=, the watchdog, fly-loop-recover and its sudoers line,
fly-loop-reset, fly-reset-to-milestone and the unstick rule keep naming
flysim.service, and the choice survives reboots and deploys. It refuses a
release without flysim-session or with a different compatibility string,
waits for /healthz and an advancing frame, and falls back to legacy by
itself when the session runtime does not come up.

flysim-session.service: the standalone unit (flysim's limits, cpuset and
environment, Conflicts=flysim.service, no [Install]). build-flysim.sh and
package-release.sh ship flysim-session and fly-session; 05-deploy.sh
installs fly-runtime, writes the standalone unit's cpuset drop-in and
refuses a release without flysim-session while the drop-in is present;
tmpfiles creates /run/fly/session. lint.sh checks all of it and drives
fly-runtime against stubs. Runbook: Switch the runtime.
2026-09-29 20:31:20 +00:00
acamilo
5a05b1667a Merge fix/loop-row67 (reviewed: APPROVE-WITH-NOTES)
# Conflicts:
#	docs/design/macros.md
#	infra/docs/macros-traps.md
#	services/flysim/crates/flysim/tests/rom_macros_mode.rs
2026-09-29 18:43:50 +00:00
acamilo
05324293ee tools: pii-scan guard with a private pattern list, tag-release gate and pre-push hook
tools/pii-scan.sh scans the tree, a commit range (added lines and messages) or a push
(pre-push protocol, incl. annotated tag messages). Generic shapes stay in the script; the
proper nouns move to the operator's private list ($FLY_PII_PATTERNS), which can also name
env files whose values are matched as literals and never printed. lint.sh section 5 now
runs it (a missing list is a note, so public CI still passes) and no longer spells the
names with one bracketed character. tag-release.sh fails closed without the list and scans
the tree and every line since the previous tag. tools/install-hooks.sh installs a pre-push
hook that scans pushes to github. Tests in infra/tests/pii-scan-test.sh.
2026-09-29 15:52:35 +00:00
acamilo
b6a4098992 infra: check 10 flags battles lost on repeat (row 67)
A whiteout ring in the Pewter Gym ran for an hour and a half without a
flag: every macro completed, and a stray tile reward on a walk back reset
the unrewarded rule. Reward lines now carry their rewardKind, and
unwon-battles flags 24+ MOVE n decisions with no wildwin/trainer/badge
reward in the window, on two probes, with no new ground. Report only, as
every check-10 rule; lint case 8 fails on main and passes here.
2026-09-29 15:34:00 +00:00
acamilo
63ecc32b2f loop recovery: an escalation ladder that unsticks a trap on its own
Restart flysim, then reset to the current rung's milestone, then to the
archive below the best rung (never lower), one step per confirmed trap
that outlives the previous one. Two resets a day, three-hour restarts
once they are spent; the ladder starts over at a new best rung or after
six quiet hours. State and history live in the unit's StateDirectory so
a reboot does not forget where the ladder stood.

A router model list confirms each step; a 'not stuck' answer delays it
at most three probes and no answer leaves the watchdog to decide alone.
Each step is announced 60 s ahead in /run/fly/wd/recovery-notice.json
for the stage's recovery splash.

fly-loop-reset is the one new root surface (a sudoers line); 05-deploy
now converges config/fly-sudoers so a release can add it.
2026-09-28 21:23:33 +00:00
acamilo
dccc52ae1c Document recovery and run its regressions in infra gate 2026-09-26 01:15:44 +00:00
acamilo
6fd6d840dc Merge fix/loop-row58: the gym's people are there when the screen does not draw them, and the game's own moves write no ledger 2026-09-23 13:43:18 +00:00
acamilo
2da7f688a8 infra: FLY_FEED_VIA is validated at deploy and read case-blind by the watchdog; flyedge gets the page's CPUs
Review round 1. flysim reads FLY_FEED_VIA case-insensitively, so check 2 must
too: with Bus in fly.env it read flysim's zeroed counters and would have
escalated to restarting flystage and flycast every pass. It now lowercases.
05-deploy.sh runs the value through feed_via_normalize (lib/common.sh) and
dies on anything but direct|bus, writing the lowercased word, so a typo is a
deploy refusal instead of a flysim boot loop.

lint's fly.target check read only the first physical Wants=/Requires= line;
target_pulls joins backslash continuations and drops comments, with a
fixture that names a unit only on a continuation line. The cpuset loop writes
a flyedge drop-in on the page CPUs, and lint holds it.
2026-09-23 11:50:11 +00:00
acamilo
2b1a6c0dea watchdog: check 10 reads the reward events, and flags a window busy going nowhere
Row 58's pad was GO OBJECTIVE into the Pewter Gym and GO OUT straight
back out for 25 minutes, diluted by eight other names, every macro done:
ten distinct names, so the four-name sequence rule could not fire, no
macro near 95%, nothing refused or blocked, and the exploration count
flat. What the window did not have was a reward event.

The stream carries the reward events beside the macros, and one more
rule reads them behind the same no-new-ground gate: WD_LOOP_BUSY_MIN
(100) decisions and no reward in the window, on two probes running, is
'unrewarded'. fly_loop_rewards is exported and loop.json carries
window.rewards. Run against the live row-58 log it flags (211 decisions,
0 rewards, 10 names) where the rules before it did not. Still never
acts: the fixture's two new cases restart nothing.
2026-09-23 11:48:57 +00:00
acamilo
3d9a08d0be infra: flyedge.service, off by default, and the feed bus through build, deploy and watchdog
flyedge.service runs /opt/fly/current/fly-edge After= and Requires=
flysim.service, with its metrics on loopback :9102 and a
ConditionPathExists so a release without the binary leaves it inactive. It is
in no target and 07-enable.sh does not enable it; the header has the switch
and the way back.

build-flysim.sh also builds fly-edge beside the flysim binary and
package-release.sh ships it when present. 05-deploy.sh writes
FLY_FEED_VIA (default direct) into fly.env, flysim.service names
FLY_BUS_DIR=/run/fly/bus and tmpfiles creates it. Watchdog check 2 reads the
feed counters from whoever serves the feed: flyedge when fly.env says bus.
lint.sh holds all of that, and drives check 2's choice against a fixture.
2026-09-23 11:41:28 +00:00
flybrain
b8a5c8fc52 watchdog: check 10 counts outcomes, not only starts
Row 57's pad was one button refused every hold for two hours: one start
and one name in ten brain minutes, so neither the sequence rule nor the
dominance rule could fire, and the coordinator's own watcher saw it
first. Check 10 now reads every macro outcome in the window. The fly's
decisions are its starts and its refusals; `stalled` flags 90% of 20+
decisions ending refused, blocked or timed out, and `zero-progress`
flags decisions with no `done` among them on two probes in a row. Both
sit behind the same no-new-ground gate as the old rules.

fly_loop_refused, fly_loop_blocked and fly_loop_done are exported, and
loop.json carries window.decisions and window.outcomes. It still never
acts: the lint fixture asserts no unit is restarted across six cases,
two of them new (the row-57 log, and a zero-progress log).
2026-09-23 05:48:01 +00:00
acamilo
660c3cf00d flybrain v0.4.0: public tree (history retained privately)
Some checks failed
ci / node 22 (test + typecheck) (push) Has been cancelled
ci / rust stable (cargo test --workspace --release) (push) Has been cancelled
ci / infra/tests/lint.sh (push) Has been cancelled
ci / playwright apps/stage (allowed to fail) (push) Has been cancelled
2026-09-21 15:09:46 +00:00