Skip to content

[codex] Record AI gateway message context - #20

Merged
philcunliffe merged 1 commit into
masterfrom
codex/ai-gateway-message-context
May 22, 2026
Merged

[codex] Record AI gateway message context#20
philcunliffe merged 1 commit into
masterfrom
codex/ai-gateway-message-context

Conversation

@philcunliffe

Copy link
Copy Markdown
Contributor

Summary

Records Claude session working-directory context in future AI gateway rows and updates the normalized message schema so previous_message_id is a JSON array of ordered prior message ids.

What Changed

  • Added a local-only /_hypaware/session-context gateway endpoint and a hyp claude-hook session-context --port hook path that posts Claude session_id, cwd, and git branch.
  • Carries recorded cwd and git_branch through finalized gateway exchanges into ai_gateway_messages.
  • Changes previous_message_id from a scalar string to a JSON array and tracks ordered conversation history across projected exchanges.
  • Bumps the AI gateway message schema to v4 and uses the proxy_messages_v4 query-cache partition.
  • Extends unit coverage and the Claude gateway smoke to assert cwd/git branch capture.

Impact

This is a breaking schema change for ai_gateway_messages.previous_message_id. Future rows now expose an array instead of a scalar, and new rows land in the v4 cache partition.

Validation

  • node --test test/plugins/ai-gateway-message-projector.test.js
  • node --test test/plugins/ai-gateway-message-projector.test.js test/plugins/ai-gateway-session-context.test.js
  • npm test
  • npm run lint
  • npm run typecheck
  • npm run smoke -- gateway_claude_capture
  • npm run smoke -- gateway_codex_capture
  • npm run smoke -- ai_gateway_passthrough

@philcunliffe
philcunliffe marked this pull request as ready for review May 22, 2026 18:35
@philcunliffe
philcunliffe merged commit 072b240 into masterMay 22, 2026
6 checks passed
@platypii
platypii deleted the codex/ai-gateway-message-context branch May 28, 2026 06:37
philcunliffe added a commit that referenced this pull request Jun 11, 2026
…91)
* feat(sinks): partition iceberg exports by day with conversation sort
Lay out @hypaware/format-iceberg exports for an archive's job, not the
cache's: partition by day(primaryTimestampColumn) — a writer-owned
default, not the cache's conversation_id-identity cachePartitioning,
which sets an unbounded ~1-file-per-conversation floor compaction can't
beat — and sort each day partition by the dataset's lookup columns
(conversation_id-led) so a conversation lookup prunes row groups by
min/max instead of needing a partition per conversation.
- Promote partitionSpecForDeclaration + validatePartitionSpecStability
(and the declaration type) from src/core/cache/iceberg to a shared
src/core/iceberg home, re-exported from src/core/index.js: they are
core surface consumed by the registry, cache, plugin types, and now
the export (LLP 0003).
- format-iceberg derives the day grain + sort order per dataset at
commit time, creates the table with both, and rejects partition-spec
drift on append (iceberg_partition_spec_drift). Emits hyp_partition_spec
and hyp_sort_order on commit spans.
- Reframe maintenance compaction: available via icebergRewrite but not
run in-daemon and not needed for a day grain (was "blocked by icebird").
Spec: LLP 0022 (rewritten from the abandoned cache-parity decision);
xrefs in LLP 0014 and 0003. Tests: 10 (derivation + drift through the
real icebird write path) plus a passing iceberg_export_partitioned_local_fs
smoke asserting the layout and hyp_partition_spec.
Clustering (icebird #22) and read pruning (#20/#21) require a published
icebird containing commit 3edb15b; the package.json pin must move off
0.8.5 before those benefits land. The code degrades gracefully on 0.8.5
— partitioning and drift work; the sort order is recorded but inert.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* chore(deps): bump icebird 0.8.5 -> 0.8.9 (sort-on-write + scan pruning)
Activates the conversation sort within day partitions and read-side
scan pruning that the partitioned export records in metadata. Clears
the merge blocker: 0.8.9 contains icebird 3edb15b.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(sinks): address PR #91 review — reverse drift guard, on-disk sort assertions, CLI text
- commitBatch now rejects reverse partition-spec drift: appending with no
derived partitioning onto an already-partitioned table throws
iceberg_partition_spec_drift instead of silently skipping the guard
(and mislabeling spans as unpartitioned). LLP 0022#drift-rejection
updated to record the guard as bidirectional; new test alongside the
forward-drift case.
- The conversation sort is now asserted on disk, not just in metadata:
both the commitBatch integration test and the partitioned smoke read a
day-partition parquet file back with hyparquet and assert conversation_id
row order — fails on an icebird that records the sort order but writes
unsorted. Verified against icebird 0.8.9.
- hyp sink maintain CLI text reframed to match maintenance.js / LLP 0022:
compaction is not run by this sink (out-of-band via icebergRewrite), not
'unsupported by icebird'; action label is now compaction_out_of_band.
- Removed stray </content> artifact from the end of LLP 0022.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for freeto 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

@philcunliffe