Skip to content

feat(zcode): enrich parser with new DB tables (quotes, session_input, tool_usage, turn_usage) - #53

Merged
pro-target merged 5 commits into
mainfrom
feat/zcode-db-enrichment
Nov 12, 2026
Merged

pro-target merged 5 commits into
mainfrom
feat/zcode-db-enrichment

Conversation

@pro-target

Copy link
Copy Markdown
Owner

Extracts data the zcode parser was silently dropping: structural conversationQuotes annotations (quotes preset now prefers structured source over the verbatim heuristic), unpromoted/cancelled user inputs, backgroundNotifications (task_id/tool_use_id), tool_usage join (approval_status, destructive, cancelled_by_user, exit_code, duration_ms), turn_usage rollup (retries, context_exceeded, durations), message.data.error. Fail-soft on legacy schemas (all readers covered by a legacy fixture test); includes assimilated legacy-compat CLI fix (ac57129). Reviewed: APPROVE with 3 minors, all closed in 9754fe0.

Dmitrii Makarov added 5 commits November 12, 2026 14:04
…ol_usage and turn_usage data

- Message gains a parser-specific extra bag (not in equality contract)
- message.data.metadata.inputIntent: conversationQuotes + inputOrigin →
  Message.extra; turn-level error object → Message.extra.error
- quotes preset: structured conversationQuotes take priority over the
  verbatim heuristic (source_kind=structured, no invented source event)
- session_input: unpromoted (cancelled/discarded) inputs and
  backgroundNotifications (task-id/tool-use-id/status/summary parsed)
  → read_session extras
- tool_usage join by tool_call_id: approval_status, destructive,
  cancelled_by_user, exit_code, duration_ms on tool_use entries
- turn_usage rollup in read_token_usage: turns, model_retry_count,
  context_exceeded, turn_duration_ms, turn_error_types
- fail-soft on legacy schemas (new tables absent → fields just absent)
- docstring fix: file parts ARE observed (tool-result artifacts, 2026-11)

Agent: zcode
…oc, quotes fall-through

- session_input: include admitted-but-never-promoted rows in
  unpromoted_inputs (4 such rows exist in the live DB; docstring now
  matches the code)
- read_token_usage: document the contract — turns>0 with zero message
  tokens returns the zeroed token block with turn stats, not None
- quotes: when conversationQuotes is non-empty but EVERY record is
  invalid, fall through to the verbatim heuristic instead of dropping
  the turn (edge test added)

Agent: zcode
… zcode fixture

SQLite only parses underscored numeric literals from 3.46.0; the CI
wheels bundle older sqlite and failed with 'unrecognized token'. The
two session INSERT statements now use plain digits (parameter values
outside SQL strings are unaffected).

Agent: zcode
The mixed-literal stats dict inferred as dict[str, object], making the
in-loop += and error_types indexing 'object' operands. Accumulate in
typed locals (int counters + Dict[str, int]) and assemble the returned
Dict[str, Any] once at the end.

Agent: zcode
@pro-target
pro-target merged commit d5cfe1c into main Nov 12, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant