Skip to content

Add neutral review-domain contract module - #97

Merged
oshorefueled merged 14 commits into
mainfrom
codex/feat/harness-review-contract
Jul 22, 2026
Merged

oshorefueled merged 14 commits into
mainfrom
codex/feat/harness-review-contract

Conversation

@oshorefueled

@oshorefueled oshorefueled commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds the neutral review-domain contract for the harness refactor. This gives follow-on work a typed, Zod-validated ReviewRequest -> ReviewResult surface with explicit boundaries, budgets, model-call selection, and a conservative bridge from existing prompt files.

Branch Target

  • This PR targets release-docs because it updates docs for the latest released CLI and should be published now.
  • This PR targets main because parent Ticket 01 has merged and this branch has been advanced onto main.
  • This is a stacked PR targeting codex/ci/harness-stop-the-bleeding because it builds on Ticket 01.

What this PR covers

  • Adds src/review/ with the contract types, strict Zod schemas, boundary helpers, budget enforcement, model-call selection, ReviewExecutor, and buildReviewRequest.
  • Adds tests/review/ coverage for module surface, schemas, budget behavior, boundary scope, result shapes, model-call selection, and request building.
  • Documents the review contract module and its on-page boundary rule for follow-on executor and finding-processing work.
  • Removes internal planning/audit artifact references from the review module comments and README.

Scope

In scope:

  • New additive review contract module.
  • New focused review contract tests.
  • Optional module README.
  • Neutral product-facing wording for review-module comments and docs.

Out of scope:

  • CLI wiring.
  • Executor implementations.
  • Changes to src/cli, src/agent, src/providers, src/output, src/scoring, or src/evaluators.

Behavior Impact

  • User-facing changes: none; no runtime CLI behavior changes.
  • Release/deprecation/migration impact: none. This targets unreleased/internal harness implementation paths, so there is no public agent-mode deprecation, user migration, or compatibility obligation.
  • Operational impact: none.

Risk and Mitigations

  • Risk level: low.
  • Primary risks:
    • Follow-on harness work may depend on the exact contract shape.
  • Mitigations:
    • Strict Zod schemas reject legacy rule/evaluator fields.
    • Tests cover every exported contract surface and the runtime edit boundary.
  • Rollback plan:
    • Revert this PR's review-contract commits (99f73c2 and 4c9519d) or revert the merged PR.

API / Contract / Schema Changes

  • Adds the new internal review-domain contract under src/review/.
  • Adds ReviewRequest, ReviewRule, ReviewContext, ReviewBudget, ReviewFinding, ReviewScore, ReviewDiagnostic, ReviewUsage, ReviewResult, and paired schemas.
  • Adds modelCall: 'single' | 'agent' | 'auto'.

Follow-ups

  • Continue the harness refactor delivery with the remaining dependent tickets after this PR reaches the delivery gate.
  • Follow-on CLI wiring can validate buildReviewRequest output at the external integration boundary.

Known Tradeoffs

  • buildReviewRequest maps existing validated PromptFile values conservatively and does not re-parse its own output; callers should validate at the external wiring boundary.

Verification

  • I verified the docs are accurate for the branch I am targeting.

How to test / verify

Checks run

  • npm run verify - passed, 52 files / 346 tests.
  • npm run test:run -- tests/review - passed, 7 files / 46 tests.
  • Forbidden-reference scan over src/review and tests/review - no matches.
  • Runtime diff check against origin/main for src/cli, src/agent, src/providers, src/output, src/scoring, and src/evaluators - empty.

Summary by CodeRabbit

  • New Features

    • Added a structured review framework with request and result contracts.
    • Added validation for review inputs and outputs.
    • Added configurable review budgets with enforcement and clear limit errors.
    • Added scope checks to prevent out-of-scope or traversal-based file access.
    • Added automatic selection between single-call and agent-based review modes.
    • Added request building with defaults, prompt conversion, and optional context.
  • Documentation

    • Added guidance for contributors and documentation describing the review framework.
  • Tests

    • Added comprehensive coverage for validation, budgets, scope handling, model selection, requests, and public APIs.

- Add npm run typecheck (tsc --noEmit) as the source-of-truth type gate
- Narrow exactOptionalPropertyTypes gaps via conditional spreads and
  optional-with-undefined fields across agent executor, orchestrator,
  observability, providers, and scorer
- Make CheckItem.line/description optional to match runtime reality
  (reported items carry optional fields; output formatters use a
  separate Issue type, so display is unaffected)
- Confine @ai-sdk/perplexity LanguageModelV1 -> LanguageModel skew to a
  single cast; ai@6 dropped V1 types and a provider upgrade is a
  separate, out-of-scope dependency change
- No strict compiler options relaxed; src/agent/* left compiling only
- Add docs/research/** to eslint ignores; the directory holds local,
  untracked throwaway research scripts that are not part of the shipped
  package and should not be type-checked by lint
- Project had no vitest config; vitest ran on pure defaults
- Pin test discovery to tests/**/*.test.ts and inline ora,
  @langfuse/otel, and @opentelemetry/sdk-node so suites that
  transitively import agent/observability modules resolve reliably
- No change to the 45 suites / 323 tests baseline
- Runs typecheck, lint, and test:run in sequence
- Single command for CI and downstream refactor phases to prove the
  verification baseline
- New typecheck.yml runs tsc --noEmit on push/PR for main and release-docs
- Bump test.yml from Node 18 to 20 to satisfy package.json engines>=20.6
- Catches type regressions in CI before merge, not just via ESLint
- README Agent Mode section replaced with under-review notice linking the audit
- --mode agent now warns through the injected logger and runs standard
  evaluation; the agent executor code is retained (unreachable from the CLI)
  pending Phase 4 removal
- Add logger to EvaluationOptions so the deprecation warning routes through the
  logging abstraction instead of console
- Rewrite orchestrator-agent-output tests to assert deprecation + fallback

BREAKING: --mode agent no longer runs the autonomous workspace-agent loop
- Record the shifted 2026-07-13 baseline: only tsc --noEmit was failing;
  lint and test:run were already green, so the audit's lint and four-suite
  module-resolution failures are stale
- Note the durable Phase 1 gates (typecheck, verify, vitest.config,
  docs/research lint exclusion, Node 20 typecheck/test workflows)
- Point to the --mode agent deprecation and standard fallback as the
  precondition for Phases 2-5; record that no spec or architecture doc is
  superseded in this appendix
- Commit a repository-native .vectorlint.ini using the bundled
  VectorLint preset (verbatim `vectorlint init` template).
- The required validation commands `npm start -- README.md --output line`
  and `npm start -- README.md --mode agent` previously failed from the
  committed branch with "Missing configuration file"; they had relied on
  an untracked, deleted VECTORLINT.md.
- Both smoke commands now run from a clean checkout with no untracked
  setup files; --mode agent still warns and falls back to standard mode.

Refs: .agent-runs/2026-07-13-223741-harness-refactor/reports/01-stop-the-bleeding.md
- Introduce src/review/ with typed + Zod-validated ReviewRequest/Result
  contracts, boundary helpers, budget defaults/enforcement, model-call
  selection, ReviewExecutor interface, and a PromptFile request builder
- Every external shape has a paired strict Zod schema; legacy scoring-mode,
  rubric, and model-authored rule-override fields are rejected
- modelCall is single | agent | auto; chooseModelCall() resolves auto
- On-page boundary (target + caller context only) via buildScope/isInScope
  with pure lexical URI normalization; no filesystem reads
- BudgetExceededError extends the repository VectorlintError base
- Purely additive: no changes outside src/review/ and tests/review/
- tests/review/ covers surface, schemas, budget, boundary, results,
  model-call selection, and the request builder (46 tests)
@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 33c32912-d0dd-4dcf-97b7-c6bce34e0004

📥 Commits

Reviewing files that changed from the base of the PR and between ae69954 and 82e8669.

📒 Files selected for processing (17)
  • AGENTS.md
  • src/review/README.md
  • src/review/boundary.ts
  • src/review/budget.ts
  • src/review/errors.ts
  • src/review/executor.ts
  • src/review/index.ts
  • src/review/request-builder.ts
  • src/review/schemas.ts
  • src/review/types.ts
  • tests/review/boundary.test.ts
  • tests/review/budget.test.ts
  • tests/review/executor.test.ts
  • tests/review/module-surface.test.ts
  • tests/review/request-builder.test.ts
  • tests/review/result.test.ts
  • tests/review/types.test.ts

📝 Walkthrough

Walkthrough

Changes

Review Domain

Layer / File(s) Summary
Review contracts and schemas
src/review/types.ts, src/review/schemas.ts, tests/review/types.test.ts, tests/review/result.test.ts
Defines review request/result data structures and strict schemas for targets, rules, findings, diagnostics, scores, usage, and policies.
Scope and budget enforcement
src/review/boundary.ts, src/review/budget.ts, src/review/errors.ts, tests/review/boundary.test.ts, tests/review/budget.test.ts
Normalizes file URIs, enforces scope membership, applies budget defaults, and reports exceeded model-call or wall-clock limits.
Review request construction
src/review/request-builder.ts, tests/review/request-builder.test.ts
Converts prompt files into review rules, validates input, and applies request defaults and overrides.
Execution strategy contract
src/review/executor.ts, tests/review/executor.test.ts
Defines executor capabilities and selects single or agent model execution based on explicit mode, target size, and rule count.
Review module surface and documentation
src/review/README.md, src/review/index.ts, tests/review/module-surface.test.ts
Documents the review domain and verifies the barrel exports its public helpers, constants, types, and schemas.

Agent Guidelines

Layer / File(s) Summary
Agent behavior guidance
AGENTS.md
Adds structured coding-behavior guidance and removes one prior error-handling principle.

Estimated code review effort: 3 (Moderate) | ~25 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/feat/harness-review-contract

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


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.

- Describe agent mode as an unreleased internal implementation path\n- Keep the standard-mode fallback notice focused on bounded harness rework\n- Remove the audit artifact and align orchestrator coverage with the notice
- Replace audit and phase references with stable review contract wording\n- Preserve review behavior and integration semantics\n- Validate review tests and repository verification
…view-contract

# Conflicts:
#	README.md
#	src/cli/commands.ts
#	src/cli/orchestrator.ts
#	tests/orchestrator-agent-output.test.ts
@oshorefueled
oshorefueled changed the base branch from codex/ci/harness-stop-the-bleeding to main July 17, 2026 00:17
Comment thread src/review/budget.ts Outdated
Comment thread src/review/budget.ts Outdated
- Move BudgetExceededError into a focused review error module.\n- Remove comments and tests that preserve discarded contract concepts.\n- Add agent rules for surgical changes, error placement, and comments.
@oshorefueled
oshorefueled marked this pull request as ready for review July 22, 2026 22:34
@oshorefueled
oshorefueled merged commit 42e0031 into main Jul 22, 2026
4 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