Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/presentation/dashboard/src/data/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ export const runGoalSchema = z.object({
delivery_window: z.object({
schema_version: z.string().optional(),
state: z.enum(["fresh", "stale", "missing", "unknown"]).catch("unknown"),
reason: z.enum(["no_expectation", "no_observation", "unparseable_observation"]).optional().nullable(),
reason: z.enum(["no_expectation", "no_observation", "unparseable_observation", "unverified_activity"]).optional().nullable(),
last_observed_at: z.string().optional().nullable(),
age_seconds: z.number().optional().nullable(),
age_hours: z.number().optional().nullable(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const observationReasons: Readonly<Record<string, WorkspaceMessageKey>> = {
record_unrecognized: "activity.reason.recordUnrecognized",
no_turn_marker: "activity.reason.noTurnMarker",
unparseable_observation: "activity.reason.unparseableObservation",
unverified_activity: "activity.reason.unverifiedActivity",
};

/** A sibling of the Goal navigation button so help never selects a Goal. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ export function goalObservationGaps(goal: Pick<GoalActivityInput, "hostThreadAct
for (const thread of threads) {
if (thread.state === "unknown" || thread.deliveryWindow?.state === "missing"
|| (thread.state === "turn_open" && (!thread.lastEventAt || Number.isNaN(Date.parse(thread.lastEventAt))))
|| thread.deliveryWindow?.reason === "unparseable_observation") missing++;
|| thread.deliveryWindow?.reason === "unparseable_observation"
|| thread.deliveryWindow?.reason === "unverified_activity") missing++;
else if (thread.deliveryWindow?.state === "stale") stale++;
}
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1478,6 +1478,7 @@ const en = {
"activity.reason.recordUnrecognized": "The host record format could not be recognized.",
"activity.reason.noTurnMarker": "The bounded host history contains no turn start or end. Execution remains unknown.",
"activity.reason.unparseableObservation": "The recorded activity time could not be read.",
"activity.reason.unverifiedActivity": "The thread moved recently, but nothing ties that activity to the scheduled prompt.",
"activity.claimedAt": "claimed {time}",
"activity.viaHost": "{host} host",
"activity.quiet": "no new activity for {minutes} min",
Expand Down Expand Up @@ -3119,6 +3120,7 @@ const zhCN: Record<WorkspaceMessageKey, string> = {
"activity.reason.recordUnrecognized": "暂时无法识别宿主记录格式。",
"activity.reason.noTurnMarker": "有限的宿主历史中没有回合开始或结束标记,执行状态仍未知。",
"activity.reason.unparseableObservation": "暂时无法读取记录中的活动时间。",
"activity.reason.unverifiedActivity": "线程最近有活动,但没有与定时提示匹配的送达记录,交付状态未验证。",
"activity.claimedAt": "领取于{time}",
"activity.viaHost": "{host} 宿主",
"activity.quiet": "已 {minutes} 分钟无新动静",
Expand Down
98 changes: 98 additions & 0 deletions docs/integrations/attached-agent-session-broker.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,101 @@ to another host, deliver a message or qualify live execution. Homes are searched
in the order `CODEX_HOME`, `~/.codex`,
then sibling `~/.codex-*` directories; set `LOOPX_CODEX_HOMES` (an
`os.pathsep`-separated list) to search exactly those homes instead.

## Missed Delivery Windows

The status route adds `delivery_window` to each observed lane of
`host_thread_activity`. For a `codex-app` lane the expected cadence comes from
the `rrule` of the installed heartbeat automation whose prompt names that Goal
and agent and whose `target_thread_id` is the lane's canonical binding; another
lane's automation is never read as this one's, and two automations claiming one
lane leave the window `unknown`. Other surfaces report `unknown` there.

Activity alone does not prove a scheduled prompt arrived: an empty Turn, a
resumed Turn and a hand-written message leave the same trace. `loopx doctor`
therefore also asks for *delivery evidence* and only reads a lane `fresh` when
the thread's newest Turn is one the host attributes to an automation — its
`task_started.turn_attribution.turn_trigger` is `automation_heartbeat` (the
routing contract's name) or `automation_heartbeat_scheduled` (the value the
current Codex App rollout writes for the same delivery), with the
`heartbeat_xml` / `user_input` / `user` transport the contract already requires
— and carries a user message matching the installed prompt. Matching text is
only a pointer: a `composer` Turn that repeats the prompt verbatim, with or
without the host's envelope, proves nothing, and a trigger this adapter has not
seen stays unverified rather than being read as a tick. When the envelope names an
`<automation_id>`, it must be the automation installed for this lane, so a
sibling automation's body cannot stand in. The matching message's time is
published as `delivery_evidence_at`. The scan reads a bounded 8 MiB tail of the
thread's own rollout and stops at the newest `task_started`; a Turn that arrives
without its opening record, without attribution, or one larger than that budget
is unattributed rather than guessed.

| `state` | Meaning |
| --- | --- |
| `fresh` | The lane received its installed prompt inside `expected_interval_minutes × tolerance` (tolerance defaults to 2). |
| `stale` | The lane's last recorded tick is older than that window. This names the symptom only; it does not name a cause. |
| `missing` | No observation of this lane was available at all. |
| `unknown` | The window could not be computed; `reason` is `no_expectation`, `no_observation`, `unparseable_observation` or `unverified_activity`. |

`unverified_activity` is the middle case: the lane moved inside its window but
nothing ties that activity to the installed prompt. Its last activity time is
still reported, so an operator can tell "quiet" from "busy, but not scheduled".
The Dashboard status route keeps its existing activity-only semantics; only the
`doctor` readback asks for delivery evidence.

`loopx doctor` reads the same projection once per run and reports it as the
optional `host_prompt_delivery_windows` check and the `host_prompt_delivery`
payload: a `status` of `fresh`, `stale`, `unverified` or `not_applicable`, a
per-state `counts` map, and one row per lane carrying `last_observed_at`,
`age_hours`, `window_minutes` and the cadence `source`. A `stale` lane carries
`diagnosis.code = host_prompt_delivery_missed` with the last tick the host did
record; `missing`/`unknown` lanes carry
`diagnosis.code = host_prompt_delivery_unverified` and their reason. Only a
missed window turns the check red — an absent receipt is not proof that the host
stopped delivering, so it is reported rather than counted as a fault. A run that
could not measure every lane also leaves the optional check red, with the gap
named in its detail, because a green check would claim coverage the run did not
have. The check stays optional either way, so it never fails `loopx doctor` on
its own.

Stopped Goals are skipped: their automation is no longer a live promise.
Observation is bounded to 64 lanes per run (`truncated` says whether the bound
was hit). The shared observer also keeps at most 32 bindings per Goal; a Goal
past that cap is counted in `incomplete_goals` and also sets `truncated`, since a
silent lane can hide among the bindings that were not read.

Lane identity is resolved over the Goal's complete binding list, before that
bound trims what the run reads. An agent bound to two threads on one surface has
no canonical thread, so its window stays `unknown/no_expectation` whether the
second binding sits at position 2 or past the cap; truncation removes
observations, never identities.

A run that did not measure every lane never reports `fresh`: the lanes it did
read may all be inside their window while an unread lane is silent. Such a run
reports `unverified` with `reason = scan_truncated` when the lane bound was hit,
or `not_applicable` with the same reason when nothing was left to read. A
binding on an observable surface that names no thread (`unmeasured_bindings`) or
a Goal whose activation record cannot be read
(`unreadable_activation_goals`) reports `unverified` with
`reason = unmeasured_lane`.

Doctor reads each lane's store read-only and never starts a Turn, writes the host
store or spends quota. The diagnostic registry is the one the run resolved: an
explicit `--registry` replaces the default global path for every diagnostic this
run projects, so a moved registry is measured where it lives instead of reading
as an empty workspace. A registry this build cannot decode is reported as
`not_applicable` with `reason = registry_requires_upgrade`, and a missing or
unreadable one as `registry_unavailable`, so a broken workspace never turns this
optional check into a doctor failure. `loopx doctor --installation-only` does
not read host state at all and therefore omits this projection.

A Goal, agent or host surface identifier is free-form registry text, so a lane
can be named after a directory or a token-shaped string. Such a label is
replaced before publication by `<redacted:<sha256-prefix>>` plus, when the last
path segment is itself safe, `:<segment>`; the row carries
`label_redacted = true`. The digest is stable across runs and differs per
identifier, so two path-shaped Goals stay distinguishable and an operator can
still match the lane to the silent Goal. If any unanticipated field still
violates the public-output boundary, the projection keeps its `status`, counts
and check verdict and sets `labels_withheld = true` instead of failing the
whole doctor run.
Loading
Loading