Skip to content

Add chat parser fixture contract - #66

Merged
TraderSamwise merged 2 commits into
masterfrom
test/chat-parser-fixtures-contract
Jun 6, 2026
Merged

Add chat parser fixture contract#66
TraderSamwise merged 2 commits into
masterfrom
test/chat-parser-fixtures-contract

Conversation

@TraderSamwise

@TraderSamwise TraderSamwise commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • document chat parser block semantics and invariants in code
  • add reusable Claude/Codex parser fixtures for known prompt/suggestion misclassification bugs
  • add fixture-driven parser tests and deterministic repeat-parse assertion

Verification

  • /Users/sam/cs/aimux/node_modules/.bin/vitest run src/agent-output-parser-fixtures.test.ts src/agent-output-parser.test.ts
  • /Users/sam/cs/aimux/node_modules/.bin/tsc --noEmit
  • /Users/sam/cs/aimux/node_modules/.bin/eslint src/agent-output-parser-contract.ts src/agent-output-parser-fixtures.ts src/agent-output-parser-fixtures.test.ts --max-warnings=0
  • PATH=/Users/sam/cs/aimux/node_modules/.bin:$PATH yarn build

Summary by CodeRabbit

Release Notes

  • New Features

    • Added agent output parser to classify and process transcript content into distinct block types.
  • Tests

    • Added comprehensive test coverage validating parser correctness, consistency, and invariants across various scenarios.

@vercel

vercel Bot commented Jun 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app Ready Ready Preview, Comment Jun 6, 2026 7:54am

@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown

Wondering what really moved? Review this PR in Change Stack to inspect semantic changes, definitions, and references.

Review Change Stack

Warning

Review limit reached

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

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

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ 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.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 95f535e8-58e9-426c-af34-d0a23a86b0c8

📥 Commits

Reviewing files that changed from the base of the PR and between a063eaa and 382d4a9.

📒 Files selected for processing (2)
  • src/agent-output-parser-fixtures.test.ts
  • src/agent-output-parser-fixtures.ts
📝 Walkthrough

Walkthrough

This PR establishes a contract-driven testing framework for an agent output parser. It introduces a formal AgentOutputParserContract defining block types and invariants, provides concrete fixture test cases, and validates the parser through Vitest tests that verify compliance with the contract and fixture expectations.

Changes

Agent Output Parser Contract and Fixtures

Layer / File(s) Summary
Parser contract definition
src/agent-output-parser-contract.ts
AgentOutputParserContract interface defines supported block types (prompt, response, status, meta, raw) with descriptions and five invariants governing strict content separation and deterministic re-parsing.
Fixture interface and test data
src/agent-output-parser-fixtures.ts
AgentOutputParserFixture interface and AGENT_OUTPUT_PARSER_FIXTURES array provide multiple named test cases with raw transcript input, expected parsed block sequences, per-block text assertions, and optional prompt content invariants.
Parser contract and fixture validation tests
src/agent-output-parser-fixtures.test.ts
Vitest suite verifies contract block types and invariants, then fixture-driven tests assert parsed block ordering, parser metadata, text include/exclude rules, prompt invariants, and parsing determinism through re-parsing comparison.

🎯 2 (Simple) | ⏱️ ~12 minutes

🐰 The parser contracts bloom,
Fixtures map each transcript room,
Tests that validate with care—
Block types flourish everywhere! 🌿✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add chat parser fixture contract' accurately describes the main change: introducing a parser contract with fixtures for testing the agent output parser.
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 test/chat-parser-fixtures-contract

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

@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.

Actionable comments posted: 2

🤖 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.

Inline comments:
In `@src/agent-output-parser-fixtures.test.ts`:
- Around line 15-20: The test only asserts two invariants but should validate
the complete set from AGENT_OUTPUT_PARSER_CONTRACT.invariants; update the test
to compare the full expected invariant list against
AGENT_OUTPUT_PARSER_CONTRACT.invariants (e.g., build an expectedInvariants array
with every documented invariant and assert equality or set-equality rather than
two .toContain checks). Locate the assertions referencing
AGENT_OUTPUT_PARSER_CONTRACT.invariants and replace them with a single full-list
equality check (or length + set membership checks) to ensure no other invariants
regress.

In `@src/agent-output-parser-fixtures.ts`:
- Around line 41-43: Remove personal machine/user path data by replacing
occurrences of "sam@MacBook-Pro-4", "/Users/sam" and similar host/user strings
in the fixture strings with anonymized placeholders (e.g., "user@host" and
"/home/user" or "~/project"). Update every fixture entry that contains local
paths/hostnames (the entries that include "sam@MacBook...", "/Users/sam/...", or
full local paths) so tests keep the same formatting but contain no PII, ensuring
any matching comparisons or joins remain unchanged except for the sanitized
substrings.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7415d5cd-c652-4112-8354-1aeeb2f30fef

📥 Commits

Reviewing files that changed from the base of the PR and between 90e23b9 and a063eaa.

📒 Files selected for processing (3)
  • src/agent-output-parser-contract.ts
  • src/agent-output-parser-fixtures.test.ts
  • src/agent-output-parser-fixtures.ts

Comment thread src/agent-output-parser-fixtures.test.ts Outdated
Comment thread src/agent-output-parser-fixtures.ts Outdated
@TraderSamwise
TraderSamwise merged commit 8866824 into master Jun 6, 2026
3 checks passed
@TraderSamwise
TraderSamwise deleted the test/chat-parser-fixtures-contract branch June 6, 2026 07:56
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