Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
110b4de
wip: record response checkout evidence during legacy placement sync
lukemaj Nov 25, 2026
2841b9b
wip: retain literal native response input evidence for #105
lukemaj Nov 25, 2026
855a957
wip: mirror Chromeria run purposes and native execution evidence
lukemaj Nov 25, 2026
54924c1
Report local outcomes from native run and response evidence
lukemaj Nov 25, 2026
a1fa2ed
wip: reconcile literal Grok tool calls and inverse turn records
lukemaj Nov 25, 2026
d13e469
wip: reject quarantined ownership and filter published cost evidence
lukemaj Nov 25, 2026
581beb0
wip: document the Grok completion witnesses
lukemaj Nov 25, 2026
3e766ad
wip: label delivery scope independently of run membership
lukemaj Nov 25, 2026
2eb191e
wip: retain Claude ancestry only for accepted records
lukemaj Nov 25, 2026
9ff55db
wip: keep forge identity in legacy checkout placement
lukemaj Nov 25, 2026
00c682e
wip: require accepted Grok completion counters for native ownership
lukemaj Nov 25, 2026
77ae9cd
wip: preserve native purpose evidence across T3 sources
lukemaj Nov 25, 2026
250b034
wip: reconcile explicit capture with native report and trace ownership
lukemaj Nov 25, 2026
90098ec
wip: expose conflicting native run snapshots in outcome reports
lukemaj Nov 25, 2026
6ced7aa
wip: withhold explicit credit when retained source identities disagree
lukemaj Nov 25, 2026
673286b
wip: withhold private forge coordinates from published task labels
lukemaj Nov 25, 2026
4b3b745
wip: preserve explicit captures on legacy-linked sessions
lukemaj Nov 25, 2026
f212fa7
wip: observe checkouts when native events first import
lukemaj Nov 25, 2026
78f8700
wip: verify legacy tree context stays outside both task bills
lukemaj Nov 25, 2026
b33e3b0
wip: exclude disputed Grok calls and describe native task ownership
lukemaj Nov 25, 2026
51f2777
wip: expose sync-time checkout observations separately from outcome o…
lukemaj Nov 25, 2026
7b04b0e
wip: require native checkout evidence for legacy placement
lukemaj Nov 25, 2026
af784d6
wip: retain first-import checkout observations for diagnostics only
lukemaj Nov 25, 2026
53729b2
wip: distinguish non-GitHub issue and PR task identities
lukemaj Nov 25, 2026
cd7828a
wip: reconcile task trace and cost with literal response ownership
lukemaj Nov 25, 2026
6b9ee84
wip: preserve task coverage and reconcile source-owned measurements
lukemaj Nov 25, 2026
7b736f2
wip: preserve ownership evidence when a native record is malformed
lukemaj Nov 25, 2026
eaa8cfb
wip: retain unresolved source identities and withhold incomplete totals
lukemaj Nov 25, 2026
7c80817
wip: bound legacy capture and missing usage to their source evidence
lukemaj Nov 25, 2026
758d066
wip: reconcile final measurements and preserve incomplete response ev…
lukemaj Nov 25, 2026
0a06da1
wip: finish fixture usage before testing source removal
lukemaj Nov 25, 2026
57328e0
wip: require a usable native final before clearing a billing gap
lukemaj Nov 25, 2026
bdd8d87
wip: retain final obligations across provisional source replays
lukemaj Nov 25, 2026
55a5b4a
wip: keep incomplete Claude final counters out of complete totals
lukemaj Nov 25, 2026
37611b8
Integrate ledger health changes and prepare native outcome accounting…
lukemaj Nov 25, 2026
b4851cf
wip: preserve disputed Claude finals across torn replay and complete …
lukemaj Nov 25, 2026
603df40
wip: reconcile disputed final fields and validate combined cache counts
lukemaj Nov 25, 2026
ce4217d
wip: rebuild Claude response accounting when a measured source withdraws
lukemaj Nov 25, 2026
1782f2a
wip: retire unsupported ledger fields and require current legacy even…
lukemaj Nov 25, 2026
926e01b
wip: reconcile Codex atomic turn and measurement witnesses per source
lukemaj Nov 25, 2026
d731b98
wip: preserve Codex incremental append and immutable accounting guara…
lukemaj Nov 25, 2026
ac5c5c7
wip: compare native Codex measurements independently of ambient model…
lukemaj Nov 25, 2026
d4ecc25
wip: reconcile observed Codex responses when a partial append finishes
lukemaj Nov 25, 2026
73698b2
wip: reconcile completed Codex archives with their incomplete source …
lukemaj Nov 25, 2026
76e8720
wip: verify legacy Codex file identity before clearing a torn receipt
lukemaj Nov 25, 2026
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 .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "agent-observer",
"version": "1.6.0",
"version": "1.7.0",
"description": "Measure agent work across Codex, Claude Code, OpenCode and Grok Build from native records, and compare behavior by model and AgentsMD version.",
"author": {
"name": "toolboxmd",
Expand Down
2 changes: 1 addition & 1 deletion .codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "agent-observer",
"version": "1.6.0",
"version": "1.7.0",
"description": "Measure agent work across Codex, Claude Code, OpenCode and Grok Build from native records, and compare behavior by model and AgentsMD version.",
"author": {
"name": "toolboxmd",
Expand Down
2 changes: 1 addition & 1 deletion .grok-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "agent-observer",
"version": "1.6.0",
"version": "1.7.0",
"description": "Measure agent work across Codex, Claude Code, OpenCode and Grok Build from native records, and compare behavior by model and AgentsMD version.",
"author": {
"name": "toolboxmd",
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [1.7.0] - 2026-11-25

### Added

- Report native Issue and PR response ownership and show incomplete outcome costs.

## [1.6.0] - 2026-11-25

### Added
Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,30 @@ Intervention text, problem lines and session attributes stay on this machine:

## Ownership and tasks

For a Chromeria run with a declared Issue or PR purpose, use its reference
as the task ID. For example, `agent-observer task show --task owner/repo#12 --json`
lists the native responses joined to that purpose, even before a delivery PR
exists. On hosts other than github.com, use `forge.example/owner/repo/issue#12`
or `forge.example/owner/repo/pr#12`. Historical IDs such as
`forge.example/owner/repo#12` remain available for earlier captures. Observer
keeps those captures under the original ID because they recorded no kind.
The `native_purpose` section identifies each run, the input that joins
a response to it, delivery PRs, provider counter checks, and gaps in coverage.
A planner serving two Issues can have responses for each in the same session.
For Grok, a session update can connect the prompt index to the completion ID.
A tool call can also supply that connection when Chromeria and Grok record
the same call ID for the turn. A tool-free response without either witness
stays unplaced.

A provider turn can reconcile while the full outcome cost remains unknown.
Chromeria v1 records observed background causes for some drivers and has no
background inventory for others. A missing child boundary or unavailable
price leaves any priced work as a subtotal. The same scope appears in
`publish --task`. For legacy PR links, `legacy_checkout_observations`
shows which checkout Observer saw when it imported a tool call. The observation
survives checkout retirement. A path can change hands before import, so a
matching PR head alone leaves the response outside the bill.

Put `observer_task_id` in related Router jobs' prepared task JSON to connect
them to one Observer task. `sync` binds their dedicated worker and dispatcher
sessions using Router records, preserving captured task metadata and outcomes.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.6.0
1.7.0
636 changes: 608 additions & 28 deletions agent_observer/adapters/claude.py

Large diffs are not rendered by default.

86 changes: 68 additions & 18 deletions agent_observer/adapters/codex.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
import os
import sqlite3

from .. import db, privacy
from .. import db, native_response, placement, privacy
from . import codex_atomic
from ..identity import SessionIdentity, skill_from_path
from ..ingest import (JsonlSource, MissingNativeId, fingerprint, insert_event,
iso_ts, stored_path, text_hash)
Expand Down Expand Up @@ -61,6 +62,7 @@ def _occurrences_ready(row) -> bool:


HARNESS = "codex"
_CONTEXT_VERSION = 10 # Recover atoms deferred while a formerly incomplete source was growing.
SEMANTICS = "codex:input_includes_cached,output_includes_reasoning"
# Older rollouts carry usage only in token_count events: last_token_usage per
# response and a cumulative total that repeats when nothing new happened.
Expand Down Expand Up @@ -371,6 +373,8 @@ def __init__(self, con: sqlite3.Connection, src: JsonlSource, stats: dict):
self.con = con
self.src = src
self.stats = stats
self.first_new_ordinal = src.first_new_ordinal()
self.checkout_events = []
self.session_id = src.row["session_id"]
self.thread_id = src.row["thread_id"]
self.thread_source = src.row["thread_source"]
Expand Down Expand Up @@ -482,7 +486,10 @@ def event(self, obj, family, native_id, *, legacy_id=None, **kw):
native_id=native_id, ordinal=self.record_position,
ts=iso_ts(obj.get("timestamp")),
update=self.src.privacy_stale and same_source,
migrate_ordinal=first and same_source, **kw)
migrate_ordinal=first and same_source,
checkout_events=self.checkout_events
if self.first_new_ordinal is not None
and self.record_position >= self.first_new_ordinal else None, **kw)
event_id = prior["id"] if prior is not None else None
if event_id is None:
stored = self.con.execute(
Expand Down Expand Up @@ -761,10 +768,10 @@ def import_codex_file(con: sqlite3.Connection, path: str,
"events_duplicate": 0, "compactions": 0, "malformed": 0,
}
src = JsonlSource(con, HARNESS, path, full=full)
if (src.row["codex_context_version"] != 6
predecessor = codex_atomic.relocated_source(src)
if (predecessor is not None or src.row["codex_context_version"] != _CONTEXT_VERSION
or src.row["codex_context_offset"] != src.row["read_offset"]):
# Replay older indexes once, including search extensions previously
# discarded from otherwise unchanged sources (#94).
# Replay older indexes once to recover literal turn witnesses from copies.
src.start_offset = 0
src.end_offset = 0
src.unchanged = False
Expand Down Expand Up @@ -811,7 +818,12 @@ def import_codex_file(con: sqlite3.Connection, path: str,
"session_key": session_key,
})
return stats
if src.incremental and db._has_table(con, "codex_incomplete_sources") and con.execute(
"SELECT 1 FROM codex_incomplete_sources WHERE source_id=? AND replay", (src.source_id,)).fetchone():
src.start_offset = src.end_offset = 0
reader = _Reader(con, src, stats)
codex_atomic.prepare(reader)
native_response.prepare(con, src.source_id, replace=not src.incremental)
_ensure_cumulative_table(con)
own = _first_meta(path)
boundary = _history_file_boundary(path, own) if own is not None else None
Expand Down Expand Up @@ -882,6 +894,7 @@ def import_codex_file(con: sqlite3.Connection, path: str,
for ordinal, obj, line in src.records():
stats["lines"] += 1
if obj is None or not isinstance(obj, dict):
reader.unreadable_atomic = True
stats["malformed"] += 1
src.error(ordinal,
"malformed_json" if obj is None else "unknown_record",
Expand All @@ -906,17 +919,26 @@ def import_codex_file(con: sqlite3.Connection, path: str,
src.error(ordinal, "missing_id", line)
continue
except _UnsupportedSchema:
if (not isinstance(obj.get("type"), str) or
isinstance(obj.get("payload"), dict) and "response_id" in obj["payload"]):
reader.unreadable_atomic = True
stats["malformed"] += 1
src.error(ordinal, "unsupported_schema", line)
continue
except (KeyError, TypeError, ValueError, AttributeError):
if obj.get("type") == "token_usage_record":
if isinstance(obj.get("payload"), dict):
codex_atomic.observe(reader, obj, None)
else:
reader.unreadable_atomic = True
stats["malformed"] += 1
src.error(ordinal, "schema_error", line)
continue
ts = iso_ts(obj.get("timestamp"))
if ts is not None:
reader.first_ts = ts if reader.first_ts is None else min(reader.first_ts, ts)
reader.last_ts = ts if reader.last_ts is None else max(reader.last_ts, ts)
codex_atomic.finish(reader, predecessor)
_flush_token_counts(reader)
_resolve_legacy_user_messages(reader)
if not src.privacy_stale:
Expand Down Expand Up @@ -961,16 +983,17 @@ def import_codex_file(con: sqlite3.Connection, path: str,
thread_source=reader.thread_source))
backfill = 1 if _backfill_complete(
con, src.source_id, getattr(src, "last_ordinal", None)) else 0
con.execute("UPDATE sources SET codex_context_version=6,codex_context_offset=?,"
con.execute("UPDATE sources SET codex_context_version=?,codex_context_offset=?,"
"codex_model=?,codex_effort=?,occurrence_backfill=? WHERE id=?",
(src.end_offset, reader.model, reader.effort, backfill,
(_CONTEXT_VERSION, src.end_offset, reader.model, reader.effort, backfill,
src.source_id))
for key, (native, lost_rows) in settle.items():
_settle(con, key, native, lost_rows)
if settle:
stats["moved_rows_with"] = sorted(settle)
stats["session_key"] = reader.session_key
con.commit()
placement.observe_new_checkouts(con, reader.checkout_events)
return stats


Expand Down Expand Up @@ -1592,14 +1615,23 @@ def _ingest_usage(r: _Reader, obj: dict) -> None:
u_raw = p.get("usage")
tt_raw = p.get("turn_token_usage")
th_raw = p.get("thread_token_usage")
_validate_bucket(u_raw)
_validate_bucket(tt_raw)
_validate_bucket(th_raw)
try:
for bucket in (u_raw, tt_raw, th_raw):
_validate_bucket(bucket)
if bucket and any(v is not None and not 0 <= v < 2**63
for v in (bucket.get(k) for k in _CODEX_BUCKET_KEYS)):
raise _MalformedUsage("invalid atomic counter")
except _MalformedUsage:
codex_atomic.observe(r, obj, None)
raise
u = u_raw if isinstance(u_raw, dict) else {}
tt = tt_raw if isinstance(tt_raw, dict) else {}
th = th_raw if isinstance(th_raw, dict) else {}
rid = f"{HARNESS}:{p['response_id']}"
turn_id = f"{HARNESS}:{p['turn_id']}" if p.get("turn_id") else None
want = {k: u.get(k) for k in _CODEX_BUCKET_KEYS}
want.update(turn_total_tokens=tt.get("total_tokens"), thread_total_tokens=th.get("total_tokens"))
codex_atomic.observe(r, obj, want)
cur = r.con.execute(
"INSERT OR IGNORE INTO responses(response_id, source_id, harness,"
" session_key, thread_id, turn_id, root_turn_id, session_id,"
Expand All @@ -1624,14 +1656,6 @@ def _ingest_usage(r: _Reader, obj: dict) -> None:
" total_tokens, turn_total_tokens, thread_total_tokens"
" FROM responses WHERE response_id=?", (rid,)).fetchone()
seen = dict(existing) if existing is not None else {}
want = {"input_tokens": u.get("input_tokens"),
"cached_input_tokens": u.get("cached_input_tokens"),
"cache_write_input_tokens": u.get("cache_write_input_tokens"),
"output_tokens": u.get("output_tokens"),
"reasoning_output_tokens": u.get("reasoning_output_tokens"),
"total_tokens": u.get("total_tokens"),
"turn_total_tokens": tt.get("total_tokens"),
"thread_total_tokens": th.get("total_tokens")}
if seen != want:
raise _UsageConflict("usage conflict")
_migrate_response_position(r, rid, r.record_position)
Expand All @@ -1642,6 +1666,11 @@ def _ingest_usage(r: _Reader, obj: dict) -> None:
r.usage_context_seen.add(rid)
r.stats["responses_inserted"] += 1
_note_occurrence(r, "response", rid, obj, model=r.model, effort=r.effort)
native_turn = native_response.identifier(p.get("turn_id"))
if (native_turn and (r.thread_id or r.session_id)
and native_response.identifier(p.get("response_id"))
and p.get("thread_id") in (None, r.thread_id)):
native_response.record(r.con, r.src.source_id, r.session_key, rid, native_turn)
if turn_id:
r.con.execute(
"INSERT OR IGNORE INTO turns(turn_id, source_id, session_key,"
Expand Down Expand Up @@ -2192,3 +2221,24 @@ def _function_read(r, obj, call_id, path, state, turn_id):
r.event(obj, family, call_id, turn_id=turn_id, name=os.path.basename(path),
target=skill if family == "skill_read" else path, status=state,
detail={"skill": skill, "skill_path": path} if family == "skill_read" else None)


def legacy_response_inputs(con, session_key):
"""Atomic records imported before per-occurrence evidence still have
their literal turn_id. Retouch touches Claude exclusively. Fallback
token_count records have a separate semantics and no native response id.
"""
columns = {row[1] for row in con.execute("PRAGMA table_info(sources)")}
old = (" AND COALESCE(s.codex_context_version,0)<7"
if "codex_context_version" in columns else "")
for rid, turn in con.execute(
"SELECT r.response_id,r.turn_id FROM responses r JOIN sources s ON s.id=r.source_id"
" WHERE r.harness='codex' AND r.session_key=? AND r.semantics=? AND r.is_overlap=0"
" AND (r.thread_id IS NULL OR 'codex:'||r.thread_id=r.session_key)" + old,
(session_key, SEMANTICS)
):
if (isinstance(turn, str) and turn.startswith("codex:")
and native_response.identifier(turn[6:])
and isinstance(rid, str) and rid.startswith("codex:")
and native_response.identifier(rid[6:])):
yield rid, turn[6:]
Loading