#38

Observation provenance: trace entries back to source message ranges

Openparzival1lopened 7mo ago

Follow-up notes from discussion around kanban task 22 (threadhop observations, landed in PR #35). No code changes proposed yet — capturing the gap so it can be turned into a future task without losing the reasoning from that implementation thread.

1. What we track today vs what we do not track

Already tracked:

  • Per-session observer progress in SQLite via observation_state.source_byte_offset
  • Per-session observation file path / entry count / running status
  • Per-observation payload fields like type, text, context, ts

Not tracked today:

  • The exact source message range that produced a given observation
  • A stable pointer like start_uuid / end_uuid / final_uuid
  • Any per-entry source offset (prompts/observer.md explicitly forbids source_offset in JSONL)

So the system can answer "where did the observer stop reading the transcript?" but not "which exact messages caused this decision/todo/observation line to be written?"

2. Why this is a real product gap

The observer works on small chunks (roughly 3-5 turns at a time), and the prompt intentionally asks it to extract the final form of a decision or todo across multiple turns.

That keeps the saved note clean, but it means a user who later asks:

  • "Why did this observation get created?"
  • "Show me the exact part of the thread this came from"
  • "Was this really decided here, or did the model over-compress it?"

...has no precise way to jump back to receipts.

Right now the best we have is a timestamp on the observation line plus the session file. That's helpful, but it's not enough for reliable provenance.

3. Why simple line numbers / raw offsets are probably the wrong main design

The observer does not operate on raw transcript lines one-to-one:

  • assistant streaming chunks are merged
  • tool noise is filtered out
  • system-reminder blocks are stripped
  • one observation may summarize several turns

So a naive "source lines 41-45" pointer is fragile and not especially meaningful.

If we add provenance, the more useful unit is probably stable message identity from the cleaned transcript view, for example:

  • session_id
  • start_uuid
  • end_uuid
  • maybe final_uuid
  • maybe start_ts / end_ts

That would let the UI / CLI reconstruct "show me the span that produced this note" without coupling the feature too tightly to raw file layout.

4. Two plausible implementation directions

Option A — enrich each observation entry

Append optional provenance fields directly into each JSONL observation entry.

Pros:

  • Self-contained
  • Easy to carry through CLI output / exports
  • No join needed to trace an observation back to source

Cons:

  • Makes the JSONL heavier and less minimal
  • Harder to keep the observer prompt simple
  • Risks cluttering the grep/jq-friendly output we intentionally preserved in task 22 / PR #35

Option B — keep JSONL minimal, add provenance in SQLite (or sidecar metadata)

Store provenance separately from the observation text itself. For example: one row keyed by session + observation ordinal or a generated observation id.

Pros:

  • Keeps observation files clean and lightweight
  • Lets the CLI keep printing minimal JSONL by default
  • Easier to evolve provenance schema later

Cons:

  • Requires a join / lookup step when the user wants receipts
  • Needs a stable observation identity beyond "line N in file"

My bias: Option B is probably the cleaner long-term fit.

The actual user-facing need

This isn't just "more metadata would be nice." It's really about trust and auditability:

  • Users should be able to inspect where an observation came from
  • Handoffs / summaries should be explainable with receipts
  • Future UI features could support "jump to source span" from an observation entry
  • It becomes easier to tell the difference between a solid extracted decision and an over-eager summary

Action items (future task / follow-up task)

  • Decide whether provenance lives inside observation JSONL or in SQLite-side metadata
  • Pick the provenance unit: raw offsets vs stable message UUID span
  • Define how multi-turn "final form" observations map back to source (start_*, end_*, final_*?)
  • Ensure any provenance design still keeps threadhop observations usable in grep/jq workflows
  • Add a lookup path for "show me the source span for this observation"
  • Decide whether provenance is required for all observation types or only high-value ones (decision, todo, maybe conflict)

References

  • PR #35 — kanban task 22, threadhop observations CLI query
  • Kanban tasks 18 / 19 / 22 (observer core, watch loop, observations query)
  • ADR-018, ADR-019 (observer core + per-session observation files)
  • prompts/observer.md — explicitly excludes source_offset from JSONL entries

Activity

0

No activity yet.