Compare complete document revisions with their source, run a limited set of deterministic checks and inspect saved alternatives offline.
Decision supported
Help a reviewer inspect drafting changes while keeping the source wording, dependencies and unresolved questions visible. A proposed revision is not an agreement to its terms.
Architecture baseline 2026-10-26Local source snapshotLawyers reviewing proposed document revisions · Legal AI evaluators using public or synthetic text · Researchers comparing bounded revision mechanisms
All 37 tests passed on 31 October 2026, including eight replay-integrity regressions. The retained services-document run replayed 57 of 57 evaluations unchanged without a model call. A fresh authored example passes a deadline-only proposal and blocks removal of a protected confidentiality clause; altered saved sources are refused before replay output is written.
The map below describes its original snapshot. The note above covers later fixes and checks; older results below still belong to the earlier version.
01 / Workflow
How the work moves through the system.
Read from left to right. Open a step to see why it matters, how it works, and where to find the code.
Process or decisionEvidence or data exchange
01Documents & context
implemented
Choose source and review goal
The user supplies a text document and an instruction. The CLI saves the source version so each proposal can be checked against the same record.
Legal ↔ Technical +
Legal purpose
Proposed amendments remain distinguishable from existing wording.
How it works
Validate supported text, retain original content and hash raw bytes.
docloop/core.py:15read_document
docloop/__main__.py:15main
02Application & processing
implemented
Represent clauses and source support
Paragraph anchors and lexical references form a limited representation of the document. They support edits without claiming to model all of its legal meaning.
Legal ↔ Technical +
Legal purpose
Dependencies and extracted wording are review aids.
Generation uses an available Codex sign-in. The orchestrator sends instructions tied to the source and saves candidate edits, usage and any failures.
Legal ↔ Technical +
Legal purpose
New terms are proposals; assumptions cannot silently become source facts.
How it works
Schema-constrained generation with serial, fresh, mutation and recombination arms.
docloop/engine.py:33packet
docloop/engine.py:104run_screen
docloop/provider.py:33generate
implemented
Recheck data and rendered wording
Deterministic checks and a document-body roundtrip test look for configured defects. The draft then goes to engineering review.
Legal ↔ Technical +
Legal purpose
A clean mechanical check is not legal approval.
How it works
Source version and exact quote checks, protected blocks, finite regex rules and HTML text extraction.
docloop/checks.py:19evaluate
docloop/output.py:16candidate_files
docloop/output.py:46extract_body
03Review & decisions
implemented
Compare chosen alternatives
The reviewer selects saved drafts for comparison. Their checks are recomputed against the supplied source and policy, showing complete alternatives without choosing a legal winner.
Legal ↔ Technical +
Legal purpose
The reviewer sees resolved and introduced check findings alongside remaining unknowns.
How it works
Explicit candidate loading, current evaluation, per-candidate artifacts and comparison checksum.
docloop/compare.py:11compare_drafts
deferred
Make the consequential decision outside the tool
Technical checks cannot establish legal adequacy or another party’s assent. A qualified reviewer decides whether to use a revision through a separate authorized professional process.
Legal ↔ Technical +
Legal purpose
Final judgment and acceptance are not delegated to the score.
How it works
No in-app authenticated approval, execution or transmission path is implemented.
docloop/checks.py:19evaluate
docloop/engine.py:212reviewer_packets
04Records & handoff
implemented
Retain reviewable draft records
The tool saves complete drafts, differences, source anchors and records needed to reproduce the run. Another reviewer can inspect what changed after triage or comparison.
Legal ↔ Technical +
Legal purpose
Historical signatures in source wording do not evidence assent to a revision.
none; source is explicitly supplied, not retrieved
Persistence
Source/policy/schema freeze, per-call prompt/events/answer/call files, per-arm candidates and recommendations, results.json
Review & permissions
Public/synthetic generation flag, available signed-in Codex CLI, then qualified review outside this tool.
Output
Draft revisions, failure records, measured transport usage and engineering-only recommendation.
docloop/__main__.py:15main
docloop/engine.py:104run_screen
docloop/engine.py:54propose
docloop/engine.py:33packet
docloop/provider.py:15command
docloop/provider.py:33generate
docloop/core.py:139recombine
implemented
CLI replay
Check retained drafts again without confusing old scores with the current source.
+
Interface / command
docloop/__main__.py:main
Call
python -m docloop replay → evaluate
Service / backend
docloop/checks.py:evaluate
Rules & validation
Read saved source/policy unless a new text source is provided; evaluate candidate files and compare non-timing fields with saved evaluations. Source mismatch produces an integrity finding, not rebased edits.
Model / provider
none
Prompt
none
Retrieval / sources
none
Persistence
New replay output: replay.json
Review & permissions
Reviewer must explicitly rebase stale edits; replay does not regenerate or approve them.
Output
Current evaluation and unchanged-result flags.
docloop/__main__.py:15main
docloop/checks.py:19evaluate
docloop/core.py:63render_blocks
implemented
CLI questions and optional improve information inputs
Identify which unresolved fact can change the supported choice across a supplied finite case.
Enumerate explicitly supplied branches and outcomes; return a recommendation only when the surviving worlds agree; do not invent probabilities or answers.
Model / provider
none for questions; improve remains separately configuration-dependent
Prompt
none for questions; supplied supported facts join engine.packet in improve
Retrieval / sources
none
Persistence
JSON case and optional answers read locally; questions prints state and next question
Review & permissions
The actual owner supplies facts; conflicting answers are rejected.
Output
Possible winners, unresolved state and a decision-relevant question.
docloop/__main__.py:15main
docloop/information.py:5worlds
docloop/information.py:29assess_information
docloop/information.py:39next_question
implemented
CLI compare and comparison review workspace
Compare selected complete drafts under the source and policy being reviewed now.
+
Interface / command
docloop/__main__.py:main; docloop/compare.py:compare_drafts HTML
Bound explicit candidates; reject source-version mismatch before creating output; recalculate every check and show source-relative findings without selecting a legal winner. Saved evaluation.json files are ignored.
Model / provider
none
Prompt
none
Retrieval / sources
none
Persistence
Fresh output: comparison.json, source.json, policy.json, source-reference/ and candidate-NN/ snapshots
Review & permissions
A user selects inputs; source/candidate integrity failures stay visible; professional selection remains external.
Output
Navigable source/current-draft comparison and checksum-bound comparison record.
docloop/__main__.py:15main
docloop/compare.py:11compare_drafts
docloop/checks.py:98comparison
docloop/output.py:16candidate_files
implemented
Candidate and recommendation HTML reports
Inspect the entire proposed document, exact changes, source support and unknowns.
+
Interface / command
docloop/output.py:candidate_files / page
Call
Direct local report files; no HTTP server or frontend API
Escape untrusted content, retain full replacements and append-only proposed clauses, then require body text extracted from HTML to equal the evaluated text.
Banner preserves draft/no-assent status; CSP blocks scripts and form actions; user reviews beyond the narrow rules.
Output
Complete review page and exact text artifacts.
docloop/output.py:16candidate_files
docloop/output.py:12page
docloop/output.py:46extract_body
docloop/core.py:63render_blocks
implemented
Blinded reviewer packet output
Prepare complete drafts for independent professional review without exposing method labels.
+
Interface / command
docloop/engine.py:reviewer_packets generated draft.html and review.json
Call
run_screen → reviewer_packets after recommendations freeze
Service / backend
docloop/engine.py:reviewer_packets
Rules & validation
Deterministic shuffle creates labels and keeps the candidate key outside reviewer folders. Forms remain blank until a genuine reviewer supplies assessments.
Local Python study entry points → docloop.numeric.search
Service / backend
docloop/numeric.py:search
Rules & validation
Freeze finite synthetic instances, budgets and code hash; compare search arms with a finite independent reference. Numerical outcomes do not become legal drafting claims.
Model / provider
none
Prompt
none
Retrieval / sources
none
Persistence
New study output: frozen protocol, per-arm/seed records, oracle records and results
Review & permissions
Separate research interpretation; no promotion into a legal evaluator.
Output
Synthetic mechanism comparisons and resource records.
studies/e1/run.py:16main
studies/e1/linked_followup.py:48main
docloop/numeric.py:133search
implemented
E3 uncertainty and stronger-control studies
Test question selection on authored finite ambiguity cases.
Use frozen possible outcomes and answer packets with question ceilings; distinguish software behavior from an actual owner interaction or measured human time.
Model / provider
none
Prompt
none
Retrieval / sources
none
Persistence
New study output JSON with per-policy outcomes, question counts and summaries
Review & permissions
Authored answers are synthetic; no owner participation or real-time savings claimed.
Output
Controlled question-policy and baseline results.
studies/e3/run.py:45main
studies/e3/strong_control.py:25main
docloop/information.py:60run_policy
config dependent
E2 public-document studies and supplemental research tools
Frozen source/instruction/policy/challenge hashes precede generation. Challenge checks follow frozen recommendations. Separate model review checks exact supplied quotations but is not expert validation.
Model / provider
gpt-6-astra alias via provider.generate when generation/review is invoked
Prompt
engine.packet; semantic_review.RUBRIC and SCHEMA; generator_instructions.md
Retrieval / sources
none; curated supplied public source text only
Persistence
Per-study frozen inputs, proposal/recommendation files, provisional reviewer records and diagnostics
Review & permissions
No new live calls in this task. Same-family model review remains provisional; professional validation unfilled.
Output
Controlled public-document screens and explicit diagnostic/semantic-review limits.
studies/e2/prepare.py:21main
studies/e2/run.py:10main
studies/e2/semantic_review.py:21review_one
studies/e2/semantic_review.py:36main
studies/e2/recombination_diagnostic.py:27main
docloop/engine.py:104run_screen
Which parts of the app are mapped
Ten grouped surfaces: all five docloop CLI commands, complete-draft and blinded-review outputs, and maintained E1/E2/E3 study entry points. Internal provider self-test follows the mapped generation transport; tests are validation, not product surfaces. No HTTP API exists.
10 mapped0 partial0 unmapped
CLI prepareimplemented
Traced to current source; implementation status does not mean professional validation.
CLI improve with four revision methodsconfig dependent
Traced to current source; implementation status does not mean professional validation.
CLI replayimplemented
Traced to current source; implementation status does not mean professional validation.
CLI questions and optional improve information inputsimplemented
Traced to current source; implementation status does not mean professional validation.
CLI compare and comparison review workspaceimplemented
Traced to current source; implementation status does not mean professional validation.
Candidate and recommendation HTML reportsimplemented
Traced to current source; implementation status does not mean professional validation.
Blinded reviewer packet outputimplemented
Traced to current source; implementation status does not mean professional validation.
E1 numerical and linked follow-up studiesimplemented
Traced to current source; implementation status does not mean professional validation.
E3 uncertainty and stronger-control studiesimplemented
Traced to current source; implementation status does not mean professional validation.
E2 public-document studies and supplemental research toolsconfig dependent
Traced to current source; implementation status does not mean professional validation.
03 / Review and permissions
What needs to happen before the next step?
implemented
Source version and claim status
Edits bind to the original source hash; extracted assertions need exact current quotes, while proposals, assumptions and interpretations keep distinct statuses.
Code references
docloop/core.py:86validate_candidate
docloop/core.py:63render_blocks
implemented
Narrow evaluation and visible uncertainty
Protected blocks, introduced references, instruction patterns and declared textual rules are checked; unknowns and missing semantic coverage remain explicit.
Code references
docloop/checks.py:19evaluate
config dependent
Transport authority and resource boundary
Generation uses ephemeral read-only Codex calls with disabled tools, forced ChatGPT sign-in, a structured schema, wall-time limits and usage records; API-key environment overrides are removed. This is not a confidential-data certification.
Code references
docloop/provider.py:15command
docloop/provider.py:33generate
docloop/engine.py:74costs
implemented
Rendered output integrity
The complete HTML document body must extract back to the exact text evaluated; HTML is escaped and report CSP disables active code and form actions.
Code references
docloop/output.py:12page
docloop/output.py:16candidate_files
docloop/output.py:46extract_body
implemented
No legal winner from comparison
Comparison recomputes checks under supplied policy, preserves old output directories, and leaves selection null. Local hashes are change evidence, not external signatures.
Code references
docloop/compare.py:11compare_drafts
deferred
Professional review remains external
Blind review forms contain null reviewer/time/acceptability fields. The system neither authenticates a lawyer nor asserts enforceability, assent or measured commercial improvement.
Code references
docloop/engine.py:212reviewer_packets
docloop/checks.py:98comparison
04 / Completion work
What changed in this snapshot.
Implemented change
Offline compare command and source-bound comparison workspace
Added compare_drafts and the compare CLI. It validates up to twelve explicitly selected candidate inputs, rejects stale source versions before creating output, recomputes checks, preserves full drafts and diffs, and writes a comparison record with no selected legal winner.
Saved drafts existed individually, but reviewers lacked a normal command to recheck selected alternatives together under the source and policy they actually intend to review. This closes that handoff without adding model calls or an invented legal-quality score.
Options considered
Add broad PDF/DOCX extraction and tracked-change support.
Add an authenticated reviewer workflow or another model critic.
Complete an offline comparison handoff using current source/policy checks.
Files changed
docloop/compare.py
docloop/__main__.py
tests/test_compare.py
README.md
Validation
passedpython3 -B -m unittest discover -s tests -v
Actual source directory: 29 tests passed, including six comparison tests; baseline was 23. Executed using the bundled Python runtime.
passedpython3 -B -m docloop --help
The compare command is reachable in the actual CLI.
Fresh authored synthetic input and candidate were used; current-policy refund check resolved and no legal selection was inferred. Paths are recorded in the local smoke log.
Negative CLI smoke returned expected exit 2 for source-version mismatch and created no output directory.
Scope of the tool
Only UTF-8 Markdown/text up to the documented intake limit; containers require verified extraction outside the tool.
Model generation is restricted by the CLI to public or synthetic data, uses a configured Codex subscription route, and requires runtime availability.
Exact quotation and narrow regex checks do not establish enforceability, general legal entailment or commercial acceptance.
No authenticated legal sign-off, counterparty transmission, contract execution or production release path exists.
Unfinished work and gaps in the map
No PDF/DOCX/scan/track-change ingestion or Word editing integration.
No external retrieval, citator, legal-currentness service or jurisdictional authority engine.
No authenticated professional review capture, calibrated legal-quality evaluator, commercial acceptance or sender.
Textual rules are incomplete and may miss legal dependency/exception errors; exact quotes do not prove interpretation.
Fresh generation and provisional model review were not run during this task; transport/model-alias availability remains runtime-dependent.
Independent reviewer judgments, user studies, enforceability and net time savings remain unmeasured.
Existing frozen studies and negative findings are preserved; consumed cases are not fresh holdouts.
Comparison output is a local evidence workspace, not a recorded professional approval.
General legal-quality and independent reviewer-time evidence remain unmeasured.
No fresh live-model campaign or professional study was run.
Implementation snapshot
These maps explain the software, its sources, and who reviews the results. Local and synthetic tests do not establish legal accuracy or readiness for production. The technical traces identify configured integrations and unfinished paths.