MARK GARASLEGAL AI & SOFTWARE

Legal ↔ Technical / Architecture map

Document Loop

Compare complete document revisions with their source, run a limited set of deterministic checks and inspect saved alternatives offline.

Workflow SVG ↓Project case study ↗

Current workflow review / 31 October 2026

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.

Read the updated case study ↗Current verification record ↓
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.

How it works

Blank-line anchors, section/modality heuristics, explicit claim-status schemas.

  • docloop/core.py:37representation
  • docloop/core.py:86validate_candidate
config dependent

Generate complete cumulative edits

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.

How it works

Versioned source/candidate/evaluation files, frozen recommendations, blank blinded-review forms.

  • docloop/output.py:16candidate_files
  • docloop/engine.py:212reviewer_packets
Read the connections as a list
  • Choose source and review goal → Represent clauses and source supportPreserved source
  • Represent clauses and source support → Generate complete cumulative editsOptional generation
  • Generate complete cumulative edits → Recheck data and rendered wordingProposed edit schema
  • Choose source and review goal ⇢ Recheck data and rendered wordingCurrent source and policy
  • Recheck data and rendered wording → Compare chosen alternativesRecheck selected drafts
  • Compare chosen alternatives → Retain reviewable draft recordsFull comparison artifacts
  • Retain reviewable draft records → Make the consequential decision outside the toolRequired external review
  • Retain reviewable draft records ⇢ Compare chosen alternativesSaved drafts; prior scores ignored

02 / Implementation traces

Follow an action into the code.

10 grouped traces. The model and retrieval entries show which integrations run, which use local rules, and which are only configured.

implemented

CLI prepare

Preserve a source and inspect its current wording without model access.

Interface / command
docloop/__main__.py:main
Call
python -m docloop prepare → read_document / representation / candidate_files
Service / backend
docloop/core.py:read_document; docloop/output.py:candidate_files
Rules & validation
Reject unsupported/empty/binary/oversized text; create unchanged baseline and perform render roundtrip.
Model / provider
none
Prompt
none
Retrieval / sources
none
Persistence
New output folder: source-original.txt, source.json, representation.json, schema.json, instruction.txt, source-reference/
Review & permissions
User chooses the input and a fresh output; no professional approval is inferred.
Output
Preserved source and local source-reference review page.
  • docloop/__main__.py:15main
  • docloop/core.py:15read_document
  • docloop/output.py:16candidate_files
config dependent

CLI improve with four revision methods

Produce complete proposed revisions under an unchanged instruction and explicit source status.

Interface / command
docloop/__main__.py:main
Call
python -m docloop improve → run_screen → propose → generate
Service / backend
docloop/engine.py:run_screen / propose; docloop/provider.py:generate
Rules & validation
Current source reference participates in stable engineering triage. Calls, duplicate slots, usage uncertainty and failure states remain recorded; recombination preserves connected edit components.
Model / provider
gpt-6-astra alias; reasoning_effort low; snapshot not returned by transport
Prompt
docloop/engine.py:packet; docloop/generator_instructions.md; SCHEMA
Retrieval / sources
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.

Interface / command
docloop/__main__.py:main
Call
python -m docloop questions → assess_information / next_question; improve optionally appends supported answers
Service / backend
docloop/information.py:worlds / assess_information / next_question
Rules & validation
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
Call
python -m docloop compare → compare_drafts → evaluate / comparison / candidate_files
Service / backend
docloop/compare.py:compare_drafts
Rules & validation
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
Service / backend
docloop/core.py:render_blocks / render_text; docloop/output.py:extract_body
Rules & validation
Escape untrusted content, retain full replacements and append-only proposed clauses, then require body text extracted from HTML to equal the evaluated text.
Model / provider
none
Prompt
none
Retrieval / sources
none
Persistence
draft.txt, draft.md, candidate.json, evaluation.json, changes.diff, index.html, render-check.json
Review & permissions
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.
Model / provider
none
Prompt
none
Retrieval / sources
none
Persistence
reviewer-packets/Review-NN/{draft.html,source.txt,review.json}; reviewer-key-private.json
Review & permissions
No reviewer identity, qualification, time or acceptability is fabricated. No authenticated form ingestion is implemented.
Output
Anonymized complete-draft packets and unfilled review forms.
  • docloop/engine.py:104run_screen
  • docloop/engine.py:212reviewer_packets
implemented

E1 numerical and linked follow-up studies

Test bounded search mechanisms separately from document quality.

Interface / command
studies/e1/run.py:main; studies/e1/linked_followup.py:main
Call
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.

Interface / command
studies/e3/run.py:main; studies/e3/strong_control.py:main
Call
Local study entry points → information.run_policy
Service / backend
docloop/information.py:run_policy
Rules & validation
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

Freeze document-specific conditions, compare generation methods and inspect provisional semantic failures.

Interface / command
studies/e2/prepare.py:main; run.py:main; semantic_review.py:main; recombination_diagnostic.py:main
Call
Prepare freeze → run_screen; optional semantic_review.review_one → provider.generate; local diagnostic replays
Service / backend
docloop/engine.py:run_screen; studies/e2/semantic_review.py:review_one
Rules & validation
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.

passedpython3 -B -m docloop compare SOURCE --candidates CANDIDATE --instruction "Clarify refund timing" --policy POLICY --out NEW_OUTPUT

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.

passedPYTHONPYCACHEPREFIX=WORK_CACHE python3 -m compileall -q docloop tests

Syntax compilation passed in the actual source directory; bytecode cache was written only under this task workspace.

passedpython3 -B -m docloop compare STALE_SOURCE --candidates CANDIDATE --instruction Review --out NEW_OUTPUT

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.