The Lawfare Academy

Lawfare Group → Knowledge Institute → Lawfare Academy

← Back to program

← AI 320 — Applied AI, Retrieval and Reliable Automation

Weeks 15–16

A bounded retrieval assistant and operating plan

Learning objectives

  • Explain and trace the mechanisms in a bounded retrieval assistant and operating plan.
  • Apply the method to the worked example and changed-condition exercise.
  • Identify assumptions, failure cases and the evidence needed to justify a result.

Current study directions: use the original Academy preparation chapters, preserved teaching and complete optional worked reasoning on LawfareGroup.com. Retained attributed readings, source exercises and historical assignment directions are optional further study. This notice supersedes earlier textbook-supported directions preserved below and in historical companions. Independent subject review and observed learner testing remain pending.

The final project connects retrieval, output validation, evaluation and workflow control. Begin with fictional documents and local execution. Keep the first release narrow: answer policy questions with evidence or abstain, produce drafts for review and simulate actions rather than contacting people or changing records. This scope lets you test failure behavior without conflating a demonstration with permission to act.

Document the complete chain from question to final result. Which passages were eligible, which were retrieved, what context was supplied, which output was proposed, which checks passed and what a reviewer approved? Store only the information needed for diagnosis under a clear retention policy. A log containing raw private prompts can itself become a sensitive datastore. Keep secrets outside source code and browser bundles, and enforce limits at the server.

An operating plan specifies source updates, model and prompt versions, evaluation triggers, cost budgets, incident response and retirement. A model provider update can change behavior without an application code change. Repeat representative checks when dependencies change. Provide a useful fallback, such as source search without generation. Judge readiness by demonstrations of supported answers, correct abstention, denied access, safe retries and recovery after interruption, not by a claim that the assistant is autonomous.

Worked reasoning This non-generative baseline returns an attributed passage rather than synthesizing unsupported claims. It is not a complete answer-verification system: lexical matching can still return an irrelevant passage. Its purpose is to make the contribution of generation measurable. The retrieve function is defined in the preceding unit; include it or import it when running this snippet.

Extended teaching and laboratory

A release gate connects evidence to an operating decision. Specify the permitted corpus, claim types, action boundaries and failure response before evaluating. Include a transparent non-generative retrieval baseline so generation’s incremental contribution can be measured. A system that cites a passage is not necessarily faithful: it can cite an irrelevant passage or omit an exception.

Version the entire configuration, including model, prompt, retrieval settings, source snapshot and validator. A provider update can change outputs without an application deployment. Rerun representative evaluations after consequential changes and preserve a fallback that is actually tested.

Worked problem An assistant answers 90 of 100 routine questions correctly but sends one unauthorized external request. The release rule permits no unauthorized actions in the test suite. Evaluate the gate.

Step-by-step reasoning 1. Routine answer accuracy is 90%, but it is not the only release criterion.

  1. The unauthorized action violates the declared gate. Do not average it away as one error among 100 questions.
  1. Disable or constrain external actions, repair the boundary and rerun both the failing case and related adversarial variants.
  1. Document that passing a finite gate supports the bounded release decision; it does not prove that no future unauthorized action is possible. Maintain monitoring and a fallback.

Harbor: evaluate the complete evidence-and-action procedure

Harbor is a fictional policy-help service. It answers from a versioned corpus, permits an insufficient-evidence or conflict state, and prepares requests for separate approval. Its demonstration sends nothing outside a local synthetic fixture. Produce a reproducible dossier joining task decomposition, literal output validation, calculated retrieval, source interpretation, action recovery and operating cost. Use the original project and durable-action laboratory as distinct implementations with different boundaries: the first has an in-memory dry-run store; the second simulates a persistent provider contract. Do not describe either as proof that an arbitrary external provider permits safe automatic retry.

Retain the preceding three-chunk ranking fixture and its changed authorized corpus. Then assess the six cases below. A is a current general policy; C is its applicable custom-order exception; D is an independently conflicting current policy covering the same case. Z is nonexistent. P is a restricted passage the requester cannot read. Gold evidence sets are stipulated for this exercise, not inferred from a similarity score.

Case

Required behavior

Observed context and result

Q1 ordinary order

Answer supported by A

Context A; correct bounded answer citing A

Q2 custom order

Answer accounting for A and C

Context A; positive answer citing A but omitting C's exclusion

Q3 no applicable source

Insufficient evidence

Empty context; explicit insufficient-evidence result

Q4 restricted inquiry

Exclude P before context; deny access

P entered context; final display omitted its citation and refused to answer

Q5 current contradiction

Identify conflict using A and D

Context A,D; correct conflict explanation citing both

Q6 ordinary order

Answer supported by A

Context A; answer attempted with invented citation Z

Report retrieval measures for the positive-answer cases Q1,Q2,Q6 separately from the conflict and denied-access cases. Calculate passage recall across their four required passage occurrences, complete-support retrieval across their three questions, supported-answer precision across attempted positive answers, and correct end-to-end behavior across all six cases. The release rule forbids any unauthorized context entry or invented citation in this fixture. Explain whether the rule passes even if the UI refuses Q4.

A separate operating sample has 150 monthly cases. Drafting saves three minutes per case, review adds two, corrections add one, and maintenance adds four hours monthly. Calculate net labor capacity before subscription charges, and distinguish it from cash savings. Next trace an approved operation R for recipient A through the retained durable fixture's crash after the provider effect. State what the recorded provider hash/result can establish, what a missing result cannot establish, and what a changed recipient requires. Finally describe how database connection lifecycle affects reliable local cleanup.

Complete dossier and changed-record reasoning

Task and evidence.

Exact totals and authorization decisions belong to explicit deterministic contracts; language generation may propose an explanation but cannot grant itself source or tool access. The positive-answer evidence occurrences are A for Q1, A and C for Q2, and A for Q6. Retrieval supplied three of these four occurrences, so micro passage recall is 3/4=.75. Full evidence is present for Q1 and Q6 but not Q2, so complete-support retrieval is 2/3. A's repeated appearance across questions counts once per required evaluation occurrence, not as a new distinct corpus document. The conflict case Q5 has its own two-passage requirement and is reported separately; combining populations without explaining the weighting would change the metric.

Answering and release.

Positive answers were attempted in Q1,Q2,Q6; only Q1 is supported, giving supported-answer precision 1/3. Q6 demonstrates that sufficient retrieved evidence can still produce an invalid answer reference. Q3 and Q5 exhibit correct abstention and conflict behavior. Together with Q1, three of six cases satisfy their complete end-to-end requirement: 3/6=.5. Q4 fails at context admission despite the final refusal. Hiding a citation does not remove the information already exposed to generation. The fixture fails both the unauthorized-context and invented-reference gates. Repair those mechanisms and rerun the original and changed cases before considering release. Six constructed cases and zero failures after repair would remain bounded test evidence, not a population error guarantee.

Cost.

Drafting frees 150×3=450 minutes; review consumes 300 and corrections 150. Before maintenance the net is zero, and four maintenance hours make the net a loss of four labor hours monthly. An estimate of monetary value also needs wage or opportunity-cost assumptions, subscription/infrastructure charges and an account of whether capacity can actually be redeployed. Fixed wages do not automatically fall when work takes fewer minutes. Measure quality improvements separately rather than relabeling them as labor savings.

Recovery.

The fixture can leave local R in executing while the provider has a committed result. Its reconciliation compares the provider's operation identity and payload hash with the approved record, then records the matching result locally. The observed one-effect assertion concerns that synthetic provider's unique-key contract. A missing lookup returns uncertainty; it does not prove that a real provider never executed, particularly if lookup can lag. Do not manufacture a new operation ID or silently switch recipient to B. A changed consequential payload needs fresh authorization and must not be slipped under R's original approval. Atomic local claiming addresses competing ownership; provider reconciliation addresses the different external-effect/local-record window.

Resource lifecycle.

A Python SQLite connection's transaction context manager commits or rolls back; it does not itself guarantee connection closure. An open handle can prevent temporary-file cleanup on Windows even after assertions passed. The following separate teaching example explicitly closes a local connection after its transaction. It is a lifecycle demonstration, not a replacement implementation for the preserved shared laboratory.

from contextlib import closing import sqlite3

def create_local_note(path): with closing(sqlite3.connect(path)) as connection: with connection: connection.execute( "CREATE TABLE IF NOT EXISTS notes(id INTEGER PRIMARY KEY, text TEXT)" ) connection.execute( "INSERT INTO notes(text) VALUES(?)", ("fictional practice",) ) # Transaction ended before closing; no connection is returned to the caller.

Changed record.

Supply C in Q2 and correct its answer to include the exclusion; replace Q6's citation and claim review with a correct answer tied to A. Positive-case passage recall becomes 4/4 and complete-support retrieval 3/3; supported-answer precision becomes 3/3. Correct end-to-end behavior becomes 5/6 because Q4 still admitted P. The release gate still fails. If a subsequent independently observed rerun also excludes P before context, all six stipulated case requirements pass, but retain the finite-fixture limitation. Separately increase monthly drafting savings to five minutes with review/correction unchanged: 750−300−150=300 minutes, or five hours, before maintenance; subtract four maintenance hours to obtain one hour of potential net capacity. These changed assumptions alter the operating estimate, not the authorization requirements.

Optional twenty-point rubric: score each criterion 0–4: (1) task, source version, access and claim-state boundaries; (2) reproducible retrieval calculation and complete-evidence denominators; (3) all answer/state outcomes, severe failures and changed-case release decision; (4) correct cost arithmetic with capacity/value/cash distinctions; (5) durable action trace, unresolved outcomes, connection lifecycle and reproducibility manifest. Four means correct complete reasoning with explicit assumptions; three a limited omission; two a material gap; one an unsupported conclusion; zero absent or contradictory work. Preserve original capstone criteria as well. Written comparison is optional and does not record learner completion or establish observed competence.

Apply the idea

An assistant answers 90 of 100 routine questions correctly but sends one unauthorized external request. The release rule permits no unauthorized actions in the test suite. Evaluate the gate.

A new model version passes average accuracy but fails three previously passing exception-policy cases. What should the release comparison show?

Read the worked reasoning

Show case-level regressions, their severity and the applicable release criteria alongside the aggregate. A stable average can mask changed failure modes. Investigate the exceptions, keep the prior bounded configuration or fallback when required, and rerun the affected source/validation tests before release.

Check understanding

What is the strongest readiness evidence for this prototype?

  1. A claim that all future prompts will behave correctly
    Feedback

    No finite evaluation guarantees every future behavior.

  2. Reproducible task tests including abstention, denied access and recovery
    Feedback

    Observable behavior under failures is stronger than presentation alone.

  3. A single persuasive generated demonstration
    Feedback

    A selected demonstration gives little evidence about error rates.

Further reading

Current study directions: use the original Academy preparation chapters, preserved teaching and complete optional worked reasoning on LawfareGroup.com. Retained attributed readings, source exercises and historical assignment directions are optional further study. This notice supersedes earlier textbook-supported directions preserved below and in historical companions. Independent subject review and observed learner testing remain pending.

Use the preserved original investigation and connected Academy preparation/application below. Compare your reasoning with its optional complete model. Historical source directions remain in immutable edition4.

My learning →