On Linux psutil's create_time() is the cached /proc/<pid>/stat start ticks
plus boot_time(), and psutil 7.2.2 re-reads /proc/stat btime on every call.
WSL2 re-anchors btime after host sleep, so the owner's read of a live
worker's birth drifted from the one the worker reported in its hello, and
the exact-equality fences (reservation, worker.adopt/persist, delegation
dispatch, the launcher signal and the Kanban owner receipt) refused it:
every Kanban card, cron run and subagent ended permission_denied.
worker_birth() reads the kernel start ticks since boot
(create_time(monotonic=True)) on Linux and keeps process_birth() elsewhere;
every managed-worker identity fence now uses it. The spawn ledger keeps
process_birth() so its persisted epoch births still match after an update.
An owner_admitted receipt written before this change reads as another
process: its reclaim pauses, the fail-safe direction.
Refs #143547
Co-authored-by: Sebastian Hänisch <5960303+TKCen@users.noreply.github.com>
Since #106742 every Kanban card runs in a gateway managed worker, and
ef52a09a55 removed the delegation toolset there: a delegated child needs
its own owner-registered execution (review r4224751560 / r4230769955), and
_open_child_session_db refused with worker_child_registration_required.
The rule stays; the missing owner side is built:
- child.reserve (gateway/session_worker_child.py): a worker asks on its own
fenced receipt stream. The owner verifies the parent's claim, mints the
child's session row (source subagent, parent lineage, parent profile,
_delegate_from marker) and a kind='child' execution bound to the parent's
verified pid/birth, the worker's fresh secret and the connection
principal, under the parent's id prefix. Caps come from the root
session's frozen policy (delegation.max_concurrent_children,
max_spawn_depth); a refusal or draining owner is a receipt, so the
parent's journal never sticks.
- ChildSessionStore (agent/runtime_session_child.py): the child persists
through ordinary worker.persist under its own claim, writes only its own
row, never binds the process delegation ledger, finishes on close.
- Retirement: every terminal transition of an execution (finish, loss,
settlement) retires its live children and ends their rows; an owner
restart retires old-epoch children (never adoptable) while the root alone
becomes unknown.
WORKER_DISABLED_TOOLSETS is gone because the only child path in a worker
now goes through the reservation.
Fixes#141793
On macOS psutil shifts create_time() by abs(INIT_BOOT_TIME - boot_time()),
using a boot-time reference frozen when psutil was imported in the
calling process. After a clock step (NTP, sleep/wake) a long-lived
gateway owner reads a different birth for a fresh worker than the worker
reports itself, so verify_worker_identity's exact match refused every
managed worker with permission_denied until a gateway restart.
hermes_cli.process_identity.process_birth reads the unadjusted kernel
start (create_time(monotonic=True)) on macOS and plain create_time()
elsewhere (Linux and Windows apply no per-process reference). Every site
that writes or checks a worker birth now uses it: the worker's hello,
the reservation, the worker.adopt claim, the delegation dispatch check,
the verified-interpreter signal, and the Kanban owner binding with its
reclaim check. The match stays exact, so a forged birth is still refused.
#140612 undoes the shift arithmetically (birth - diff). psutil applies
abs(diff), so for a backward step that doubles the error instead of
removing it, and the other birth sites stay exact on the drifting value.
The new test emulates both step directions on every platform.
Refs #134889 (KB-6)
Refs #140580
Refs #140719
Mechanism: worker.register needed only session:control, which every default
interactive ticket carries, so any local client could insert a 'registered'
compute execution for a session. Its pid/birth live only inside the hashed
adoption_digest, nothing in the live owner reaps the row, and while it stays
registered claim_session_input returns None: the drain pauses session_busy and
API/webhook/Bot observers wait on queued work until a restart turns the row
unknown (then the session refuses claims until a reset). The repo has no
interactive caller; managed workers reserve through the private
reserve_admission_worker path.
Fix (maintainer ruling: restrict to the managed worker's own launch, fail
closed): register now requires the worker-adoption capability (worker:adopt),
the same grant adopt/persist use, and the registrant pid must be this owner's
child (at most MAX_LAUNCHER_HOPS launchers below it). The worker RPC client
mints a worker-adoption ticket for register too. No new grant type.
Red on r13-base2: tests/gateway/test_worker_register_restriction.py (real
SessionAuthority + SQLite, real child process): an interactive ticket
registered a row; after the fix it and a foreign same-user pid are refused and
the owner's own child still registers.
Review: ahrazzle B1-14
b9a7337821f fenced cron and the Bot relay verbs on a retired authority
(require_serving). The authority's own mutators reached through a stale
connection (submit, cancel_queued, resolve_unknown, mutate, attach) all pass
SessionAuthority.authorize first, and a managed worker's adopt/persist goes
through worker_request: until a successor runs begin_runtime_epoch the retired
epoch still passes the store fence, so each of those could still commit into
the home the profile released. authorize() and worker_request() now call
require_serving first (runtime_retired). `retired` is initialised in __init__.
Also: test doubles of the authority used by the retire/shutdown tests gain the
`adopted` map stop_authority_turns now reads (beea566de7); production
authorities always carry it.
Test: test_retired_authority_refuses_writes_before_successor_epoch gains
authority.cancel_queued, authority.submit and worker.adopt rows; all three
fail on the previous head.
Review: andrexibiza 5479692359 P1.6, andrexibiza 5480238075 #4 (retired-authority-mutator-fence)
`claim_session_input` returns None both for an empty FIFO and for one whose
head is blocked by a live `registered`/`running` worker execution. The drain
treated both as "done" and exited without `_pause`, so a messaging adapter's
delivery waiter (`admit_message`, no timeout) stayed parked on a turn that
could not run, breaking `_pause`'s invariant. When the worker later sent its
durable `execution.finish`, nothing called `_schedule`, so the queued input sat
until an unrelated submit or cancel happened.
The drain now tells the two apart: it read a queued head, so a None claim
means blocked, not empty. It pauses with `session_busy`: the waiter is
released with a transient "saved, will be answered when the running work
finishes" notice (one per pause episode), and the row stays queued. The
worker transport's `execution.finish` calls the new
`SessionAuthority.wake_after_worker`, which restarts the drain for the
logical owner (and for the physical id the worker reports, when that is
served); the row then runs and is delivered through the adapter like any
paused-then-resumed input.
`claim_session_input` keeps its store contract (None, not an error, while a
worker is live), so the blessed blocked-claim row in
tests/hermes_state/test_ledger_delete_consistency.py is unchanged.
Review: https://github.com/NousResearch/hermes-agent/pull/106742 (@itsflownium MAJOR-3)