Skip to content

docs: trajectory→convergence integration contract#34

Merged
kjgbot merged 2 commits into
mainfrom
docs/convergence-integration
Jun 22, 2026
Merged

docs: trajectory→convergence integration contract#34
kjgbot merged 2 commits into
mainfrom
docs/convergence-integration

Conversation

@kjgbot

@kjgbot kjgbot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Adds `docs/convergence-integration.md` — the agent-facing reference for how the trajectory (reasoning) lens maps into the Agent Relay Loop convergence store. Source-side companion to the WS-1 ADR in `relayhistory-cloud` (which remains authoritative).

What it documents

  • The convergence envelope a tool emits (POST /v1/ingest records), tenancy server-derived.
  • Field mapping table: trajectories/src/core/schema.ts → convergence fields.
  • The deterministic, kind-namespaced event-id scheme (decision:<traj>:<i>, finding:<traj>:learning:<i>, reflection:<traj>:suggestion:<i>, etc.) and the rules that keep it collision-free.
  • Server-owned transforms clients must NOT do: confidence float→basis-points, Task: content enrichment, scrub/raw-drop.
  • v1 scope (distilled decisions + retrospective) vs deferred full chapter stream (WS-6).
  • The shared traj_abc acceptance fixture (6 rows), pinned by both the Rust client test and the relayhistory-cloud PGlite server test.

Context

Output of the WS-1 convergence work this session. Documents the ratified contract from the trajectory source side so trajectory-tool authors find it in this repo. Docs-only; no code changes.

🤖 Generated with Claude Code

Document how the trajectory (reasoning) lens maps into the Agent Relay Loop
convergence store: the envelope, field mapping, deterministic kind-namespaced
event-id scheme, server-owned transforms (confidence→basis points, Task
enrichment, scrub), v1 distilled scope vs deferred chapter stream, and the
shared traj_abc acceptance fixture. Source-side companion to the WS-1 ADR.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 21, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@kjgbot, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 17 minutes and 43 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f636f840-8531-4415-9266-c37f5f41ef7b

📥 Commits

Reviewing files that changed from the base of the PR and between 8236a2e and d28933f.

📒 Files selected for processing (1)
  • docs/convergence-integration.md
📝 Walkthrough

Walkthrough

Adds docs/convergence-integration.md, a new specification document for the trajectory-to-convergence event ingest contract. It covers the ingest envelope shape, field-by-field trajectory mapping, deterministic eventId generation, server-owned normalizations, v1 vs. deferred scope, and an acceptance fixture with 6 expected persisted rows.

Changes

Convergence Integration Contract Documentation

Layer / File(s) Summary
Overview and ingest envelope contract
docs/convergence-integration.md
Introduces the integration context, references the WS-1 normalized schema, and defines the POST /v1/ingest envelope shape including server-side tenancy derivation and the natural-key idempotency basis for upserts.
Field mapping and deterministic eventId scheme
docs/convergence-integration.md
Specifies the field-by-field mapping from trajectory schema to convergence envelope (epoch-ms → ISO timestamps, content handling, confidence wire semantics, actor attribution, dropped fields) and the kind-namespaced collision-free eventId generation rules with retrospective array indexing.
Server transforms, v1 scope, and acceptance fixture
docs/convergence-integration.md
Lists server-owned normalizations (confidence → basis points, task-title enrichment, compliance scrubbing), defines v1 shipping scope vs. deferred chapter stream events, and pins the contract with the traj_abc fixture asserting 6 persisted rows, specific confidence_basis_points values, and idempotent re-push behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 A doc appeared where none had been,
With envelopes and fields pristine.
Six rows upserted, IDs exact,
Convergence captured, fully tracked.
The rabbit stamps it: contract fact! ✅

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: documenting the trajectory-to-convergence integration contract.
Description check ✅ Passed The description is directly related to the changeset, providing comprehensive context about the new documentation file, its purpose, and the concepts it covers.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/convergence-integration

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new documentation file, docs/convergence-integration.md, which defines the integration contract and field mappings for the trajectory reasoning lens within the Agent Relay Loop convergence store. The review feedback highlights two necessary corrections in the documentation tables: updating the schema path for status to reflect its correct location under Trajectory rather than Trajectory.task, and prefixing decisions[i] with retrospective in the event-id scheme table to maintain consistency with other retrospective-related rows.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

| `TrajectoryEvent.raw` | — | **dropped** by default-tier scrub; never emitted |
| `agents[].name` / `chapter.agentName` (`persona_id`) | `actorName` | "which engineer/agent" attribution |
| `Trajectory.projectId` | `projectId` | |
| `Trajectory.task.title/description/status` | `taskTitle` / `taskDescription` / `taskStatus` | structured fields; `taskTitle` feeds embedding via server `Task:` enrichment |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In src/core/schema.ts, status is a direct property of Trajectory (Trajectory.status), not nested under Trajectory.task (Trajectory.task.status). The table should be updated to reflect this correct path.

Suggested change
| `Trajectory.task.title/description/status` | `taskTitle` / `taskDescription` / `taskStatus` | structured fields; `taskTitle` feeds embedding via server `Task:` enrichment |
| Trajectory.task.title/description and Trajectory.status | taskTitle / taskDescription / taskStatus | structured fields; taskTitle feeds embedding via server Task: enrichment |

| Source | `kind` | `eventId` |
| --- | --- | --- |
| chapter stream event | (event type) | `trajevent:<chapterId>:<arrayIndex>` *(deferred — see scope)* |
| decision[i] | `decision` | `decision:<trajectoryId>:<i>` |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To align with the other retrospective fields in this table (such as retrospective learnings[i], retrospective challenges[i], etc.), this row should be prefixed with retrospective and refer to decisions[i] since decisions is nested under the retrospective object in the schema.

Suggested change
| decision[i] | `decision` | `decision:<trajectoryId>:<i>` |
| retrospective decisions[i] | decision | decision:<trajectoryId>:<i> |

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (4)
docs/convergence-integration.md (4)

64-66: ⚡ Quick win

Clarify whether taskRef is always emitted or omitted when null.

Line 66 describes Trajectory.task.source {system,id}taskRef as "future cross-lens correlation seed (often null; not persisted by ai-hist yet)". It is unclear whether:

  • taskRef is always present in the envelope (even when null), or
  • taskRef is omitted from the envelope when null (i.e., optional field).

Clarify the presence/absence rule (e.g., "Always emit taskRef if present, omit if null" or "Always emit with null if not available").

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/convergence-integration.md` around lines 64 - 66, The `taskRef` field
description in the Trajectory mapping table lacks clarity about whether it is
always emitted in the envelope or omitted when null. Update the description for
the `Trajectory.task.source {system,id}` → `taskRef` mapping row to explicitly
state the presence/absence rule, such as "Always emit taskRef if present, omit
if null" or "Always emit with null if not available", so readers understand
whether taskRef is an optional field in the envelope or always included
regardless of value.

51-70: ⚡ Quick win

Clarify Retrospective fan-out field mapping.

Line 68 references "fan-out events — see below" for Retrospective.{summary,approach,learnings[],suggestions[],challenges[]}, but the actual event-id mapping is in the event-id scheme table (lines 78–86), not immediately below. To avoid reader confusion, make the Retrospective-to-eventId mapping explicit in the field mapping table or add a direct cross-reference to the event-id scheme section.

For implementer clarity, state which Retrospective fields produce which event kinds (e.g., summary and approachreflection, learningsfinding:…:learning, suggestionsreflection:…:suggestion, challengesfinding:…:challenge).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/convergence-integration.md` around lines 51 - 70, The Retrospective row
in the field mapping table references fan-out events with "see below" but the
actual event-id mapping is located in a separate table section (event-id
scheme), causing confusion about which specific Retrospective fields map to
which event types. Update the Retrospective row in the field mapping table to
explicitly state the mapping between each Retrospective field and its
corresponding event kind (for example: summary and approach fields map to
reflection events, learnings array maps to finding:learning events, suggestions
array maps to reflection:suggestion events, and challenges array maps to
finding:challenge events), or add a direct cross-reference that clearly directs
readers to the event-id scheme section where the complete mapping is defined.

127-150: ⚡ Quick win

Explicitly document confidence inheritance for nested retrospective arrays.

The acceptance fixture shows that learning:0, suggestion:0, and challenge:0 have confidence_basis_points = null, implying they inherit confidence from their parent retrospective event. This is correct, but it is not stated explicitly in the prose. Add a note to the fixture description (or to the field mapping table at line 60) to clarify that nested retrospective array elements (learnings, suggestions, challenges) do not carry their own confidence and instead inherit from the parent Retrospective.confidence (if present).

This avoids implementer confusion: "Should my Learning event have its own confidence or null?"

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/convergence-integration.md` around lines 127 - 150, The acceptance
fixture table for traj_abc shows that nested retrospective array elements
(learning:0, suggestion:0, challenge:0) have null confidence_basis_points
values, but this inheritance behavior from the parent Retrospective.confidence
is not explicitly documented in the prose description. Add a clarifying note in
the fixture description section that explicitly states nested retrospective
array elements do not carry their own confidence values and instead inherit
confidence from their parent Retrospective event. This note should be added
either immediately after the fixture table or referenced in relation to the
field mapping table to prevent implementer confusion about whether Learning,
Suggestion, and Challenge events should have their own confidence values.

22-48: 💤 Low value

Add note that envelope example is abbreviated.

The convergence envelope JSON example (lines 28–44) is representative but omits fields listed in the field mapping table, such as significance, tags, projectId, taskDescription, taskStatus, taskRef, filesTouched, and codeChurn.

Add a brief note (e.g., "Example shows commonly-emitted fields; see the field mapping table for the full set.") to signal that the example is not exhaustive. This prevents implementers from assuming omitted fields should never be sent.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/convergence-integration.md` around lines 22 - 48, The convergence
envelope JSON example in the documentation is incomplete and lacks any
indication that it is abbreviated. Add a clarifying note immediately after the
code example closing backtick that states the example shows commonly-emitted
fields and directs implementers to refer to the field mapping table for the
complete set of supported fields, explicitly mentioning that omitted fields like
significance, tags, projectId, taskDescription, taskStatus, taskRef,
filesTouched, and codeChurn can and should be sent as needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@docs/convergence-integration.md`:
- Around line 64-66: The `taskRef` field description in the Trajectory mapping
table lacks clarity about whether it is always emitted in the envelope or
omitted when null. Update the description for the `Trajectory.task.source
{system,id}` → `taskRef` mapping row to explicitly state the presence/absence
rule, such as "Always emit taskRef if present, omit if null" or "Always emit
with null if not available", so readers understand whether taskRef is an
optional field in the envelope or always included regardless of value.
- Around line 51-70: The Retrospective row in the field mapping table references
fan-out events with "see below" but the actual event-id mapping is located in a
separate table section (event-id scheme), causing confusion about which specific
Retrospective fields map to which event types. Update the Retrospective row in
the field mapping table to explicitly state the mapping between each
Retrospective field and its corresponding event kind (for example: summary and
approach fields map to reflection events, learnings array maps to
finding:learning events, suggestions array maps to reflection:suggestion events,
and challenges array maps to finding:challenge events), or add a direct
cross-reference that clearly directs readers to the event-id scheme section
where the complete mapping is defined.
- Around line 127-150: The acceptance fixture table for traj_abc shows that
nested retrospective array elements (learning:0, suggestion:0, challenge:0) have
null confidence_basis_points values, but this inheritance behavior from the
parent Retrospective.confidence is not explicitly documented in the prose
description. Add a clarifying note in the fixture description section that
explicitly states nested retrospective array elements do not carry their own
confidence values and instead inherit confidence from their parent Retrospective
event. This note should be added either immediately after the fixture table or
referenced in relation to the field mapping table to prevent implementer
confusion about whether Learning, Suggestion, and Challenge events should have
their own confidence values.
- Around line 22-48: The convergence envelope JSON example in the documentation
is incomplete and lacks any indication that it is abbreviated. Add a clarifying
note immediately after the code example closing backtick that states the example
shows commonly-emitted fields and directs implementers to refer to the field
mapping table for the complete set of supported fields, explicitly mentioning
that omitted fields like significance, tags, projectId, taskDescription,
taskStatus, taskRef, filesTouched, and codeChurn can and should be sent as
needed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 41e9079f-dd04-45df-bbee-cb1bd1fd54c3

📥 Commits

Reviewing files that changed from the base of the PR and between b4a1b41 and 8236a2e.

📒 Files selected for processing (1)
  • docs/convergence-integration.md

…enda

v1.1 = the compacted roll-up → convergence-event contract PR #26 implemented against.
v1.2 = the Learn lens spec (distill session history into Pair signal for users without
trajectories): input adapter, learn_<hash> idempotent eventIds, client-side LLM-locality
privacy gate, summary-downweight ranking note, learn_fixture acceptance + scrub-bait.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@agent-relay-code

Copy link
Copy Markdown
Contributor

All CI-equivalent steps pass for the actual tracked tree:

  • typecheck: pass
  • build: pass
  • test: 257/257 pass
  • lint (biome on src+docs): pass (the npm run lint failure was only on untracked sandbox runtime dirs that won't exist in CI)

I made no edits. The PR is a pure, additive documentation file whose factual claims I verified against the repo's actual code.

Review Summary

PR #34 adds one new file: docs/convergence-integration.md (313 lines). It documents the cross-repo contract for mapping trajectory data into the Agent Relay Loop convergence event store, plus two addenda (v1.1 compacted roll-up mapping, v1.2 Learn lens). No source, types, tests, or config are touched.

Verification of doc claims against this repo's code:

  • Field-mapping table matches src/core/schema.ts exactly: traj_ id regex (schema.ts:236), ts epoch-ms number (schema.ts:84), significance enum low|medium|high|critical (schema.ts:73), confidence float 0..1 (schema.ts:90-94), alternatives is string[] | {option,reason}[] (schema.ts:112), task.{title,description,source} and projectId all present.
  • v1.1 references parse_trajectory_file/map_compacted — correctly attributed to the Rust ai-hist-core client repo, not this TS repo.
  • v1.2 claims COMPACTION_SYSTEM_PROMPT + COMPACTED_OUTPUT_SCHEMA exports — confirmed in src/compact/prompts.ts:11,22.
  • v1.2 claims provider supports baseUrl override via OPENAI_BASE_URL/ANTHROPIC_BASE_URL — confirmed in src/compact/provider.ts:76-77.

CI impact: None. biome.json ignores *.md; typecheck/test/build don't process docs. Verified full canonical CI (lint/typecheck/build/test:run) passes on the tracked tree.

Fixes applied: None needed. Biome ignores markdown, and there's no markdownlint/spell tooling, so no mechanical changes apply.

Addressed comments

  • No bot or human review comments were present (.workforce/ contains only pr.diff, changed-files.txt, context.json; no comments file). Nothing to address.

Advisory Notes

  • The npm run lint script (biome check .) failed in this sandbox solely on agent-relay runtime artifacts under memory/ and slack/ — directories that are untracked, not part of the repo, and absent from a clean CI actions/checkout. No action; these are harness-generated, not PR content.
  • Doc-only observation (no change requested): the v1.1/v1.2 addenda describe behavior implemented in other repos (ai-hist-core, relayhistory-cloud). The acceptance fixtures (traj_abc, compact_fixture, learn_fixture) are pinned in those repos, not here — outside this PR's scope to verify.

This PR is a clean documentation addition with no code risk and accurate technical claims. It does not require my judgment to gate a human — but since there were no outstanding comments, no CI failures attributable to the change, and no merge-conflict signal available in the provided context, I leave the merge decision to the maintainer.

@kjgbot kjgbot merged commit c3a2b69 into main Jun 22, 2026
8 checks passed
@kjgbot kjgbot deleted the docs/convergence-integration branch June 22, 2026 12:12
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