Commit Graph
8 Commits
Author SHA1 Message Date
CatoandClaude Opus 5.5 6e96590fae fix(check): the loop probe asks for a summary unique to the run; the check passes 5 of 5 on the live site (#1692)
* fix(check): the loop probe asks for a summary unique to the run

2026-11-12 18:28: the orangecat probe went into the live Claude session that
had written "e2e ok — no changes" at 17:00. The handoff already said it, so
Claude left the file as it was, its time stayed 17:00:00, the run's delivery
(now the claim time, 18:27:45) was later, and the run sat at Needs you. A
token per run makes the agent write, and proves the handoff is this run's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi

* docs(handoff): the loop check passes 5 of 5 on the live site

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 20:08:00 +01:00
CatoandClaude Fable 5.2 54a7024cdc fix(queue, runs, chat, ops): an idle run is closed before the next task starts; a blocked pull request is said in the thread; an address to Loki is not the loki project; the builder can be given a memory ceiling (#1678)
* fix(check): the on-demand loop check signs in on the box, and is red when it cannot ask

The first run of loki-loop-check.yml (2026-11-12, run 43188095136) printed
"down: loki e2e could not mint a session on the box" two seconds in, and
the job was green. Three things were wrong:

- The deploy ships the runner a fixed list of scripts and nothing under
  scripts/test, so on the box there was no test to run and no token
  script. The workflow now carries the check's own files with it.
- The check minted an Auth.js session cookie. Sign-in moved to AccountKit
  on 2026-11-01, where that cookie is no session. It now signs in the way
  a runner does: scripts/test/mint-check-token.ts mints an agent token for
  the operator that expires in two hours, the check uses it as a bearer
  and removes it on exit. The cookie mint stays as the fallback.
- A check that could not sign in exited 0. With the verdict asked for, it
  exits 1, and it says why (long strings masked).

scripts/test/loop-check-signs-in.ts pins all of it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi

* docs(handoff): what production showed after the first fix, and why the check could not sign in

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi

* fix(check): the loop check prints Loki's own reason for a task that does not start

Its first full run on the live site (2026-11-12, run 43191224470) ended
"still queued (Queued) after 35 min" and then guessed at the builder's
sign-in. The run route already answers the track's sentence for an open
run (detail), and the chat's reply says where the task went: the check
prints both, right after the dispatch and again when it gives up.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi

* docs(handoff): the first full check on the live site, 4 of 5

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi

* docs(handoff): why the probe did not start, in Loki's own words

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi

* fix(chat): an address to Loki is not the loki project; the loop check reaches the project it was sent to

A project named in a message outranks the selected project, on purpose
(lib/loki-fleet-commands). The assistant is called Loki and so is one of
the projects, so "Loki, add a dark mode toggle" typed with orangecat
selected was sent to the loki project.

Found through the loop check on the live site (2026-11-12, run
43198552471): asked for project orangecat, it came back "Sent loki to the
cloud runner", because its marker was "[loki-e2e]". Three runs in a row
had waited behind the loki project's open run while reporting on a
project the probe never reached.

- project-mention: withoutAddressTo removes an address to the assistant
  before matching: the name at the start followed by punctuation, after a
  greeting, "@loki", or set off by a comma at the end. "Loki's sidebar",
  "in loki" and a bare "Loki fix the header" still name the project.
- loki-loop-e2e: the marker is "[e2e-probe]" and names no project, and the
  check fails at once when Loki dispatched to another project than the
  one it asked for.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi

* docs(handoff): the probe had been going to the loki project; the routing fix

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi

* fix(queue): a run that has gone silent gives its project to the waiting message

A project's shared session takes one message at a time: the claim gate holds
the next one until the run ahead has closed. A run closes when its agent
reports. An agent that ended its turn without reporting still has a process
at its prompt, and the reaper shelters a run with a live process for up to
MAX_RUN_HOURS, so the next message could wait twelve hours behind a session
that was doing nothing. On the live site (2026-11-12) messages sent through
Loki's chat read "This project is still on an earlier task" and were still
queued 25 to 35 minutes later.

- lib/orchestration/quiet-lane: the rule, pure. The runner beats while the
  terminal prints and while the agent waits at a sign-in or an approval. No
  beat for 20 minutes (twice the window after which every surface says
  Stalled), not waiting for a person, no command outstanding, and still so
  90 seconds after it was first seen: release. The second look covers a
  runner that could not beat for a while and whose first request back is
  the claim.
- db/queries/quiet-lane: reads those facts for the run at the head of each
  lane a message waits in, through olderOpenRunSql, and closes it with the
  reaper's own verdict (partial with the handoff note, else timeout with the
  sentence), ended at its last beat. No escalation.
- claimNextPendingCommand calls it before the gate, so the message is
  claimed in the request that closed the run.
- The waiting sentence carries the bound.

A working agent prints, so its beat is seconds old at any age and it keeps
its lane. Nothing is closed when nobody is waiting.

scripts/test/quiet-lane.ts, and five scenarios in
scripts/test/lane-and-reaper.ts against a real Postgres (13 of 13 locally).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi

* fix(runs): a pull request that cannot merge is said in the thread, with the message that repairs it

The fleet's sweep merges a green pull request and leaves a red or conflicted
one waiting. A task sent from the chat that ended at such a pull request read
"done, it merges on its own" until somebody opened GitHub.

- feedback/fix-shipping: PrBlocker, prBlockerFor (a conflict when GitHub says
  mergeable: false, else the names of the checks that failed; cancelled and
  still-running are not failures), prBlockerNews (once per commit and reason).
- feedback/fix-shipping-refresh: readBlockers on the refresh input; only then
  are the head commit's check runs and statuses read.
- run-follow-notify: the fifteen-minute follower asks, and on news writes one
  line into the thread the task came from and sends one push. The line ends
  with the message to send ("<project>: fix the failing checks on <pull
  request> and push to the same branch."): a message naming a project is a
  task for it.
- Loki does not send the repair itself: no agent run nobody asked for
  (lib/auto-dispatch).

scripts/test/run-follow-notify.ts.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi

* docs(handoff): the 11:17 rehearsal failed on a slow box: sign-up 504, 96% memory, a 503 window

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi

* docs(handoff): bots do not answer on the live site (502, 11:39 UTC); OrangeCat #1672; #1678 green

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi

* fix(queue): only a run whose runner has reported output can be read as having stopped

A runner from before the beat existed reports nothing while its agent works.
Silence since delivery would have closed such a run after twenty minutes and
typed the waiting message into a working session. A run that has never
beaten now keeps its lane; one that truly never printed is the reaper's,
which closes it as never started from the runner's own unverified ack.

scripts/test/quiet-lane.ts, and a sixth scenario in
scripts/test/lane-and-reaper.ts (14 of 14 locally).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi

* fix(ops): the box usage report prints the builder's memory budget and finishes on a slow box

On 2026-11-12 the box had 0.6 GiB available and no swap left, and the report
was cancelled at its 20-minute limit inside the first du. Each disk walk now
gets a minute. A new section prints what the runner unit holds, whether it
has a memory ceiling, and which cgroup the sandboxes' processes are in:
sandbox.ts relies on the unit's MemoryMax to bound sealed sessions.

Read-only, names and sizes only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi

* docs(handoff): what holds the box's memory, measured; the builder has no ceiling

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi

* fix(queue): an idle run is closed before the next task starts; the runner's six-hour stop and a turn answered in seconds are read correctly

Three faults in the idle rule (#1680), found by an independent review and
shown failing first in scripts/test/lane-and-reaper.ts against main (13
passed, 4 failed; 17 of 17 after):

- An idle run stopped holding its project but stayed open until the hourly
  reaper. The next task went into the same session, and its ready handoff
  closes every delivered open run of the project, so the idle run was
  recorded as done with the other run's summary. The claim now closes the
  idle run first, with the reaper's own function and sentence, and only when
  a task is waiting in that project (db/queries/idle-run-close).
- The runner stops beating six hours into a run. Half an hour later the run
  read as idle while it printed, and the next prompt went into a working
  session. A last working beat at that horizon is not read as silence
  (RUN_PROGRESS_HORIZON_SECONDS).
- A turn that ended before the runner began reporting on it never had a
  working beat, read as unknown and held its project for up to twelve hours.
  Every beat stamps lastBeatAt; a run the runner reports on that has printed
  no work since delivery is idle after the same half hour. A run with no
  beat of any size keeps its lane, as before.

scripts/test/idle-run-release.ts, scripts/test/lane-and-reaper.ts.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi

* fix(ops): the box usage report can be asked for memory alone

The disk walks took the whole 20 minutes twice on 2026-11-12, on a box that
was swapping, when only the memory was wanted. what=memory stops after the
memory sections.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi

* feat(ops): the builder can be given a memory ceiling, read and set from the Sealed builds workflow

Measured on the box, 2026-11-12 12:19 UTC: loki-box-runner.service held 6.3
GiB with MemoryHigh and MemoryMax at infinity, every sandbox process is in
that unit's cgroup, the box had no swap left, and the kernel had stopped 30
processes for memory since boot: the gateway 15 times, a live site 3 times,
a sandbox 3 times. Every site unit has a 1G ceiling; the builder had none,
though sandbox.ts relies on the unit's MemoryMax to bound sealed sessions.

sealed-builds-ctl.sh gains three modes, run from sealed-builds.yml:
- memory: read. What the builder holds, what bounds it, what the box has left.
- memory-set, runs="<GiB>": MemoryMax and MemoryHigh one below it, and the
  builder's processes are marked to give first when the whole box runs out.
  Refused when the ceiling is below what the builder holds now, because that
  stops sessions at once; "force" after the number sets it anyway. Nothing
  is restarted.
- memory-clear: undo.

Nothing is set by a deploy. It is a decision, applied by a person.

scripts/hetzner/test-sealed-builds-memory.sh, in test:ops.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi

* fix(runs, chat): the blocked pull request notice is said once and its repair reaches the right project; an address to Loki is set off, and is the project when nothing else is

From the independent review of this branch, each finding confirmed by a
second agent told to refute it.

The notice:
- It would have repeated every tick. "Already said" lived in the ledger, the
  ledger is rebuilt on every refresh, and the dispatch card's own refresh
  does not read blockers. It is kept beside the ledger now
  (payload.prBlockerSaid, per reason), written once the line is in the thread.
- Its repair line named the pull request by link. The link carries the
  repository owner's name, and a project of that name won the match: the
  repair for loki went to Bitbaum. The line names the number, opens with
  "In <project>," and uses a verb the chat's own rule takes as a task, for a
  conflict as well. The test sends it through projectMentionedIn and
  looksLikeDispatchTask for four projects and both reasons.
- action_required and stale count as failed: neither turns green by waiting.

The address:
- "ok loki is broken, fix its header", "loki-loop-check is red" and "run the
  tests on @loki" lost the project; "Loki - add a toggle" kept it. An address
  is the name set off from the sentence (a comma, a colon, any dash with
  space around it, "please", "can you"), at the start of any sentence.
- "loki: fix the header" is read as an address, so a selected project gets
  the work; with nothing selected and no other project named, the name is
  the project (projectNamedByAddress, the last resort of both paths).

scripts/test/run-follow-notify.ts, scripts/test/project-mention.ts (114).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi

* fix(ops): the builder's ceiling is a ceiling only; docs(handoff): the box's memory, the review's findings, what is ready and not applied

memory-set no longer sets MemoryHigh one below the ceiling: at the moment it
is set the builder holds close to the ceiling, and a mark under what it holds
would slow every session at once.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi

* docs(handoff): the box's memory now holds up OrangeCat merges: Browser smoke is red on main

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 14:09:49 +01:00
CatoandClaude Opus 5 e3d9024887 fix(orchestration): a closed run tells the thread what the agent actually did (#772)
Both close notifications — the outcome turn in /loki and the push/Telegram
message — read only `payload.resultText`. The hosted runner and openclaw set
it. The local PTY path, which is the one a person watches after typing into
/loki, does not: it closes from the agent's session handoff, and the agent's
own words land in `summary`.

So the main path reported "🟡 **loki** — partly done." and nothing else. The
agent had written `done: e2e ok — no changes`, the judge had written exactly
what it found missing, and none of it reached the thread — which is the trip
out of the product this message exists to prevent.

One shared `runReportText` now answers "what did the agent say", preferring a
runner's own result text and falling back to the handoff: `done`, plus `next`
when it holds something, because on anything short of success `next` carries
the definition-of-done gap and the gap is what the operator must act on.

And the live check stops asserting what its own prompt forbids. The probe says
do NOT change a file, commit, or open a pull request; the judge then correctly
grades the run partial for having no committed change; the check demanded a ✅
and so failed on a perfect run (2026-09-17, run 69cdbdb7: injected 11:56:11,
handoff "e2e ok — no changes" thirty-two seconds later, every leg working).
It now asserts the thing that actually proves the loop — the agent's own
handoff summary coming back into the thread — and still fails on ❌ or on a
turn that carries somebody else's words.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-17 08:32:35 -07:00
CatoandClaude Opus 5 c8ebc5708d test(e2e): widen the dispatch window past a measured cold start (#766)
The window was twenty minutes and guessed. On 2026-09-15 a cold-start agent
on the box — fresh PTY, boot, trust prompt, then the task — wrote its handoff
at 13:44 for a dispatch injected at 13:23: twenty-one minutes to answer
`git status`. The check aborted at 13:43 and reported a broken loop that was
one minute from succeeding, which is the worst thing a health check can do.

Thirty minutes in the script, thirty-five on the box timer (the timer runs
six-hourly, so the extra slack costs nothing and the check must outlast the
slowest healthy path it exercises).

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-17 05:58:04 -07:00
CatoandClaude Opus 5 a4755151d9 test(e2e): a held dispatch is a skip, not a dead builder (#730)
Loki serialises per project: while a run is open, the next dispatch is HELD —
the run row is created, the assistant says "Dispatched", and no
pending_command is written, so no builder can claim it and no outcome can
arrive. Correct behaviour. From outside it is indistinguishable from a builder
that never picked the work up.

The scheduled check waited twenty minutes on exactly that and then reported
"First suspect: the box builder cannot authenticate" — while the builder was
fine and the blocker was the check's OWN previous run, left open when an
earlier invocation was killed. A check that poisons its next run and then
misnames the cause is worse than no check.

It now reads the absence of a commandId, aborts its own held run, and skips
with the real reason. The tell is durable: held = no command; stuck builder =
a command that is unclaimed or never acked.


Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 05:02:25 -07:00
CatoandClaude Opus 5 b2b724289b test(e2e): the check reads the run's real status, and a rationed refusal is a skip (#725)
Two ways this check lied about a working product, both found by running it on
the box rather than by reading it.

It printed `still ?/- after 20 min` when a dispatch produced no outcome turn.
`GET /api/orchestration/runs/[id]` answers the DERIVED dispatch view
(status/label/terminal), not the raw row, so reading it as {state, outcome}
told nobody anything — exactly when the diagnosis mattered most. It now reads
`status` + `terminal`, so a closed run with no turn is named as a lost
notification and an open one as a stuck builder.

And it FAILED "knows the fleet" when Loki correctly answered "You've used your
share of today's free AI budget for now." The free tier is rationed by design;
on a six-hourly timer with Telegram on flip, that pages for a healthy product
until the alerts get muted. A test against a rationed dependency needs three
verdicts, so there is now SKIP-with-reason: it does not fail the run, it says
why, and it never retries a rationed refusal (which would only spend the next
window too).


Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 02:32:06 -07:00
CatoandClaude Opus 5 aa287aa2cf fix(hosted): a one-shot runner drains its work before it exits, so the thread hears (#721)
A hosted dispatch ran, Hermes did the task, the run closed `done/success`
with its summary — and the conversation that asked for it never heard a word.
Nothing errored. Nothing logged.

`updateOrchestrationRun` fires `void notifyRunClosed(...)` — its contract is
never to slow a close — and that call is what writes the outcome turn. The web
server outlives such a promise for free. `hosted-runner.ts --once` is a
45-second cron tick: it drained the command and called `process.exit(0)`
while the write was still in flight.

- settle-background-work.ts: a bounded drain window (5s,
  HOSTED_RUNNER_DRAIN_MS), paid only by a tick that actually drained
  something. A window rather than a promise registry, because the void-call is
  this codebase's convention at dozens of sites and threading bookkeeping
  through all of them to repair one process boundary is the larger change.
- loki-loop-e2e.ts now reads the run's state when no turn arrives, so the two
  halves can never be confused again: a CLOSED run with no turn is a lost
  notification (the work happened); an OPEN one is a stuck builder. That
  distinction cost an hour today.


Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 01:08:42 -07:00
CatoandClaude Fable 5.1 efeabdec64 test(e2e): does Loki work as intended — asked of the live site, on a clock (#712)
Three testable meanings, one script, no browser and no mocks
(scripts/test/loki-loop-e2e.ts, run as the signed-in operator through the
same API the /loki page uses):

1. knows the fleet — a fleet-shaped question is answered from the studio map
   (all three pillars named, fleet_map among the retrieved sources) and the
   reply is an answer, not the model's plan for one;
2. publishes the map — /api/fleet/map is public with the pillars live, and
   bitbaum's map.json is the same map, recently generated;
3. closes the loop (--dispatch) — a request typed into a thread comes back
   into that thread as an outcome turn. A run that never returns is aborted
   with a [loki-e2e] marker so no test leaves the operator's queue hanging.

Proven against production before commit: 3/3 without dispatch; with dispatch
and the builder unauthenticated, the loop failed honestly inside two minutes
with the runner's own diagnosis delivered into the thread.

Scheduled on the box every six hours (install-loki-e2e-watch.sh ->
loki-e2e-check.sh, alert on flip; the dispatch leg only when the builder-auth
probe last said ok). pnpm run test:e2e:loki runs it from a laptop.


Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-14 05:17:40 -07:00