Skip to content

feat: add adversarial editing pass with typed cut classifications#18

Closed
rjwalters wants to merge 1 commit intomainfrom
feature/issue-5
Closed

feat: add adversarial editing pass with typed cut classifications#18
rjwalters wants to merge 1 commit intomainfrom
feature/issue-5

Conversation

@rjwalters
Copy link
Copy Markdown
Owner

@rjwalters rjwalters commented Apr 14, 2026

Summary

Implements the adversarial editing technique for the revision pipeline: instead of asking "how to improve," ask "what to cut." Each proposed cut is classified by type and presented as a reviewable suggestion.

Changes

  • src/pipeline/types.ts — Core types: ProposedCut, CutType, AdversarialEditConfig, AdversarialEditResult, CutDistribution
  • src/pipeline/adversarial-edit.ts — Main module: prompt builder, response parser, Claude API caller, cut applicator, report formatter
  • src/pipeline/index.ts — Public API exports
  • src/pipeline/__tests__/adversarial-edit.test.ts — 21 unit tests covering parser, distribution, cut application, and report formatting
  • tsconfig.json — TypeScript configuration for the project
  • package.json — Updated scripts to use vitest and tsc

Acceptance Criteria Verification

Criterion Status Verification
Adversarial edit pass identifies 10-20 passages per document adversarialEdit() sends prompt requesting configurable targetCuts (default 15) passages
Classify each cut by type (6 categories) CutType union type enforces exactly: OVER-EXPLAIN, REDUNDANT, FAT, TELL, STRUCTURAL, GENERIC
Include exact quoted passage for each cut Parser extracts PASSAGE: """...""" blocks; tested with 6 sample cuts
Present cuts as reviewable suggestions (accept/reject) Each ProposedCut has `status: "pending"
Track cut type distribution as quality signal computeDistribution() returns Record<CutType, number>; formatReport() shows percentages
Integrate as optional step in revision pipeline PipelineStage type includes "adversarial-edit" between review and revision; module is independently importable

Test Plan

  • npx vitest run — 21 tests passing (parser, distribution, cut application, report formatting)
  • npx tsc --noEmit — Clean type check, no errors

Closes #5 (removed: wrong issue)

Closes #15 (removed: wrong issue)

@rjwalters rjwalters added loom:review-requested PR ready for Judge to review loom:reviewing Judge is actively reviewing this PR labels Apr 14, 2026
@rjwalters
Copy link
Copy Markdown
Owner Author

Changes Requested - Merge Conflict

Merge Conflict

This PR has merge conflicts with main that could not be automatically resolved. The main branch now includes a full webapp template (React, Vite, Tailwind, Biome, Cloudflare Workers) from PR #20, which fundamentally changes both conflicting files:

Conflicting files:

  • package.json — PR has minimal devDependencies (typescript, vitest), but main now has ~20 dependencies including React, Vite, Tailwind, Biome, Wrangler. Scripts also conflict.
  • tsconfig.json — PR adds a simple Node-oriented config, but main has a React/Vite-oriented config with JSX, path aliases, and project references.

These are complex conflicts requiring understanding of the webapp template structure. The Doctor role should handle the rebase to integrate the pipeline code with the existing webapp setup.

Code Review (for after conflicts are resolved)

The implementation quality is strong — well-structured, well-tested, clean TypeScript. Specific observations:

Strengths

  • Clean type system (types.ts): CutType union, ProposedCut with status tracking, CutDistribution as a quality signal — all well-designed
  • Robust parser (adversarial-edit.ts:83-116): Handles malformed blocks, invalid types, and missing WORDS fields gracefully
  • Thorough tests (21 tests): Good edge case coverage including empty responses, malformed blocks, invalid types, and word count fallback
  • applyCuts sorting (adversarial-edit.ts:193-195): Smart approach sorting by passage length descending to avoid offset issues

Minor Notes

  • Branch name feature/issue-5 doesn't match the linked issue Implement AI review pipeline (critical review and revision) #15 — cosmetic but potentially confusing in logs
  • The callClaude function uses raw fetch — consider whether the Anthropic SDK would be more appropriate once the project's dependency strategy is established

PR Description

Verdict

The code is ready to approve once merge conflicts are resolved. No code changes needed — just the rebase integration.

@rjwalters rjwalters added loom:changes-requested PR requires changes before re-review (Judge requested modifications) loom:merge-conflict PR has merge conflicts loom:treating Doctor is fixing this bug or addressing PR feedback and removed loom:reviewing Judge is actively reviewing this PR loom:review-requested PR ready for Judge to review labels Apr 14, 2026
Implement the adversarial edit module for the revision pipeline that asks
the LLM to identify passages to remove rather than improve. Each proposed
cut is classified (OVER-EXPLAIN, REDUNDANT, FAT, TELL, STRUCTURAL, GENERIC)
and presented as a reviewable suggestion with accept/reject status.

Includes response parser, cut distribution tracker, cut application logic,
markdown report formatter, and 21 unit tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@rjwalters rjwalters added the loom:review-requested PR ready for Judge to review label Apr 14, 2026
@rjwalters rjwalters added loom:reviewing Judge is actively reviewing this PR and removed loom:treating Doctor is fixing this bug or addressing PR feedback loom:review-requested PR ready for Judge to review loom:changes-requested PR requires changes before re-review (Judge requested modifications) labels Apr 14, 2026
@rjwalters
Copy link
Copy Markdown
Owner Author

🔀 Automatically rebased branch to resolve merge conflicts. Proceeding with code evaluation.

@rjwalters
Copy link
Copy Markdown
Owner Author

Changes Requested

Evaluating this PR per user request.

Critical Issues

1. Destructive package.json replacement (blocker)

The PR completely replaces the project's package.json, removing:

  • All React dependencies (react, react-dom, react-router-dom, Radix UI)
  • Build tooling (vite, @vitejs/plugin-react, postcss, tailwindcss, autoprefixer)
  • Linting (@biomejs/biome)
  • Testing libraries (@testing-library/*, jsdom)
  • Deployment tooling (wrangler, @cloudflare/workers-types)
  • Project metadata (name: "draftwell"name: "loom-workspace", type: "module" removed)

This would break the entire existing web application. The PR should add its dependencies to the existing package.json, not replace it.

2. Destructive tsconfig.json replacement (blocker)

Similarly, the PR replaces tsconfig.json entirely, removing:

  • DOM/JSX types ("lib": ["DOM", "DOM.Iterable"], "jsx": "react-jsx")
  • Path aliases ("@/*")
  • Project references (tsconfig.node.json)
  • Strict checks (noUnusedLocals, noUnusedParameters, noFallthroughCasesInSwitch)
  • isolatedModules, resolveJsonModule, allowImportingTsExtensions
  • Adds outDir/rootDir/declaration which conflict with the existing noEmit setup

3. No issue auto-close syntax

The PR body has ~~Closes #5~~ (struck through), meaning no issue will be auto-closed on merge. Issue #5 is the correct target.

Code Quality (new files only)

The actual pipeline implementation is solid:

  • types.ts: Clean, well-typed interfaces. CutType union and ProposedCut with status tracking are well designed.
  • adversarial-edit.ts: Good prompt design, robust parser with graceful fallbacks for missing fields, clean API. applyCuts sorting by passage length to avoid offset issues is a nice touch.
  • index.ts: Proper barrel exports.
  • Tests: 21 tests with good coverage of parser edge cases (empty response, malformed blocks, invalid types, missing WORDS field). Well-structured with the makeCut helper.

What Needs to Change

  1. Do not modify package.json — or if new deps are needed, add them to the existing file
  2. Do not modify tsconfig.json — the existing config should work for the new code (it already has "include": ["src"])
  3. Fix PR description to include Closes #5
  4. Verify tests pass with the existing vitest.config.ts and project dependencies

Test Execution

Tests could not be executed because the package.json changes removed @vitejs/plugin-react (required by the existing vitest.config.ts).

No CI checks have been reported on this branch.

@rjwalters rjwalters added loom:changes-requested PR requires changes before re-review (Judge requested modifications) and removed loom:reviewing Judge is actively reviewing this PR loom:merge-conflict PR has merge conflicts labels Apr 14, 2026
@rjwalters
Copy link
Copy Markdown
Owner Author

Closing stale PR from previous attempt. Shepherd re-running issue #5 in merge mode.

@rjwalters rjwalters closed this Apr 14, 2026
@rjwalters rjwalters deleted the feature/issue-5 branch April 14, 2026 05:06
@rjwalters rjwalters restored the feature/issue-5 branch April 14, 2026 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

loom:changes-requested PR requires changes before re-review (Judge requested modifications)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement AI review pipeline (critical review and revision) Add adversarial editing pass to revision pipeline

1 participant