Skip to content

workflows

github-actions[bot] edited this page Nov 17, 2026 · 3 revisions

This page is generated from docs/workflows.md in the repository -- docs/ is the canonical documentation. Direct wiki edits here are overwritten on the next publish; make changes in docs/ by pull request.

Workflows

End-to-end walkthroughs of the framework, in both execution modes, using one synthetic deal throughout: Synthetic Co asking for the Synthetic Fleet Loan (a five-year term facility; all figures are in invented "synthetic units"). The input files used below are checked in under examples/synthetic_co/, and tests/test_docs_examples.py re-runs them, so the numbers and messages on this page are the ones the scripts really produce. Nothing here is a real borrower, filing or figure.

For what each command asks for and writes, see the command reference; for every script's flags, the CLI reference; for what the figures mean, the financial model.

Choose a route

flowchart TD
    Q{"What do you need?"} -->|"A Go/No-Go screen and company research"| R["/research<br/>standalone .docx brief"]
    Q -->|"A full credit paper"| F["Full CAM route"]
    F --> A["/triage, /spread, /commercial, /collateral,<br/>/project (optional)"]
    A --> B["/assemble: draft, /review loop, export<br/>.docx + .xlsx"]
    R -. "later, if a full CAM turns out to be needed" .-> A
    Q -->|"Unattended or scripted"| H["scripts/orchestrator.py<br/>(headless, needs ANTHROPIC_API_KEY)"]
Loading

The two execution modes

Claude Code slash commands Headless Python scripts
You run /triage, /spread, ... in a Claude Code session opened on this repository python scripts/orchestrator.py ... in a terminal
The model is called by Claude Code, as the session you are already in The anthropic SDK, from the script
Authentication Your Claude Code login. No ANTHROPIC_API_KEY is needed or read ANTHROPIC_API_KEY in the process environment
Billing Your Claude Code plan Per-token Anthropic API billing
Available Everything, including /research and /calibrate-policy calibrate.py and orchestrator.py (the full CAM only), plus the local evaluation harness
Offline The deterministic scripts and the tests need no network calibrate.py --mock, the tests, and run_evals.py --dry-run make no model call

Credentials belong in your own shell's environment and nowhere in this repository; see Configuration. The worked examples below mark each step (local) when it runs only deterministic code on your machine, and (model) when the model drafts or judges.

Calibration (set up once)

Use it when you want drafts to follow your house style and layout. Needs a few of your own past CAMs as PDFs in inputs/calibration_samples/ (git-ignored). Writes config/style_guide.md and templates/local/cam/<deal_type>_cam.md, both git-ignored.

Claude Code: /calibrate --type asset_finance reads the PDFs directly (model) and writes both files. Headless:

python scripts/calibrate.py --type asset_finance

With no ANTHROPIC_API_KEY set, the script does not fail; it falls back to placeholder output so you can check the plumbing without spending anything:

[INFO] ANTHROPIC_API_KEY not found. Running calibrate.py in --mock mode.
[MOCK] Read 295 characters from 1 sample PDF(s).
[MOCK] Wrote placeholder `config/style_guide.md`.
[MOCK] Wrote placeholder template to templates/local/cam/asset_finance_cam.md.

The mock files are labelled (MOCK) and contain no figures. Real calibration sends the samples' text to the model, so use it only with documents you may send to the Anthropic API; the results stay local and git-ignored. /calibrate-policy does the same for your credit policy documents in inputs/credit_policy/, writing config/credit_policy.md; it has no headless equivalent.

Research (Go/No-Go and company research, no financials)

Use it when you need a quick screen of a prospective borrower without building a CAM. Needs a registration number, a bureau summary, a charges register, and sector and management notes. Writes a standalone <Company>_<Proposal>_Research_Brief.docx, plus triage and commercial state, saved sources and a review trail. Claude Code only.

/research --company "Synthetic Co" --proposal "Synthetic Fleet Loan" <registration number, bureau summary, charges register, sector, management notes>
  1. Claude screens legal identity, ownership and charges and drafts the company and sector sections, citing a source for every claim (model). For a borrower inside a group or with related-party links, it reads the full outstanding charge instruments, the borrower's creditors/debtors/key-estimates/going-concern notes, the parent's guarantee and subsidiary-holder notes, and current plus ceased PSC history. It repeats the accounts-note checks for each available year, not just the latest, and makes register/accounts conflicts analyst follow-ups; an inaccessible document is reported as an evidence gap. Each document it fetches or is given, and each it relies on, is saved to the deal's sources/ folder:

    python scripts/source_manifest.py --company "Synthetic Co" --proposal "Synthetic Fleet Loan" --step research \
        --claim "Synthetic legal identity extract" --file registry_extract.txt --url https://example.invalid/registry

    which records the file and prints the manifest entry (local):

    {
      "filename": "example.invalid_registry.txt",
      "url": "https://example.invalid/registry",
      "step": "research",
      "claim": "Synthetic legal identity extract",
      "fetched_date": "2026-10-04"
    }
  2. source_manifest.py --check-sources reports both the declaration shape and the saved-material floor. A fully completed /research state has triage.sources and commercial.sources as lists of citation strings and both steps in steps_completed; with the corresponding saved research manifest entry above the result is {"missing_saved_sources": false, "sources_declared": "declared"}. The executable documentation fixture only completes spreading/projection and saves a source: its reduced, incomplete state instead reports {"missing_saved_sources": false, "sources_declared": "not_declared"}, not evidence of completed research. Explicit [] lists validly declare no citations. Malformed completion metadata or declarations (including nulls or non-string entries), and completed source-bearing steps without declarations, report {"missing_saved_sources": true, "sources_declared": "unknown"} even when material was saved. Check results exit 0; the calling workflow stops on unknown or missing saved sources and requests correction. The saved-material floor remains deal-level, not one file per citation.

  3. Claude saves the brief to deals/Synthetic Co/Synthetic Fleet Loan_brief.md (an example brief) and runs /review ... --research-brief: the Risk Reviewer checks grounding and narrative, not credit policy or mitigants, because nothing has been structured yet (model). A REJECTED verdict means revise, overwrite the file and review again with a new Reviewer. After the third consecutive REJECTED verdict and every later rejection, the session reads the saved review_trail on disk, shows the pass count and latest findings, and asks through AskUserQuestion with exactly three options: Run another review pass; Stop and export for manual review (unapproved, disclosed); or Stop without exporting. Silence, ambiguity and “carry on” are not consent; ask again. Only the explicit manual-review choice permits --analyst-release-unapproved "<reason>", which adds a dated status paragraph after the first document heading and appends a record to the append-only review_stopped_by_analyst list after the DOCX is written. After a release the session carries on with the remaining export steps (steps 4 onward) as for an approved export; after "Stop without exporting" nothing is exported, but the end-of-deal learnings step still runs. This is a decision point, not a hard cap. If the analyst sets a lower per-deal maximum, the session checkpoints at that number and records it under deal_structure_notes.review_cap in state.json.

  4. The export runs (local):

    python scripts/research_export.py --company "Synthetic Co" --proposal "Synthetic Fleet Loan" \
        --brief "deals/Synthetic Co/Synthetic Fleet Loan_brief.md"
    Done! Research brief exported to deals/Synthetic Co/Synthetic Fleet Loan_2026-10-04/Synthetic Co_Synthetic Fleet Loan_Research_Brief.docx
    

Before export, the brief must end with a populated, flat ## Sources section listing every relied-on document (URL where available) and defining short-form citation keys such as WRG note 14. Each citation is a Markdown link whose text is the readable citation (for example [FY25 accounts, p. 12](url)) and each Sources entry is - **Key:** [title](url), so the Word document shows clickable links; a source with no URL needs no link. /assemble asks for the same inline link form in a CAM, whose templates end with the same kind of ## Sources section; a CAM exported without a populated section still exports, with an advisory warning on standard error (issue #583). Nested bullets are not suitable because the DOCX builder does not render them correctly. A missing or empty section blocks export without writing output. Only an explicit analyst instruction in chat to export without sources, together with the analyst's stated reason, permits --analyst-override-no-sources "<reason>"; the .docx then ends with a dated override footnote. The session never offers or infers this override, and the reason is not stored in state.json.

The deal's state.json now holds triage and commercial exactly as /triage and /commercial would have written them, so the deal can continue into /spread later without redoing anything. A research-only deal does not create the workbook and never saves an auto-generated template.

Spreading (the financial figures)

Use it when you have profit-and-loss and balance-sheet figures. Needs raw line items per period, using the framework's field names (the full list is in commands.md). Writes financials, ratios, multi_period_financials and financials_source to state.json.

The raw input is a JSON file keyed by period; any subset of FY-2, FY-1, FY-Current works (financials_input.json has the last two). An excerpt:

{"FY-Current": {"revenue": 5000, "cost_of_sales": 3000, "admin_expenses": 1000, "depreciation": 300,
                "interest_paid": 150, "scheduled_principal": 350, "capex": 400, "tax_paid": 100,
                "cash": 250, "trade_debtors": 600, "stock": 400, "trade_creditors": 450,
                "current_debt": 350, "long_term_debt": 1650, "tangible_assets": 3200,
                "intangible_assets": 100, "share_capital": 500, "retained_profit": 1800}}

/spread writes that file and runs this (local), rather than recalculating anything in prose:

python scripts/spreading_check.py --company "Synthetic Co" --proposal "Synthetic Fleet Loan" \
    --financials "deals/Synthetic Co/Synthetic Fleet Loan_financials_input.json"

It prints the whole updated state as JSON and checkpoints it. For FY-Current the subtotals and ratios are:

"ebitda": 1000, "tangible_net_worth": 2200, "total_debt": 2000,
"dscr": 2.0, "gross_leverage": 2.0, "net_debt_to_ebitda": 1.75, "current_ratio": 1.3888888888888888,
"gearing": 0.8695652173913043, "fcf_conversion_pct": 0.35, "working_capital_cycle_days": 37.71666666666667

and financials_source is "framework-computed". Each figure is derived in the financial model.

The analyst-supplied alternative. If your institution spreads against its own template (for instance with depreciation inside cost of goods sold), /spread records your subtotals and ratios exactly as given, sets financials_source to "analyst-supplied", and asks whether the convention is specific to this borrower or applies enterprise-wide, never assuming which. The CAM must then carry an explicit caveat that the figures were not independently recomputed. Confirmed conventions are stored for reuse:

python scripts/conventions.py --company "Synthetic Co" --write --financials-source analyst-supplied \
    --note "Depreciation embedded in Cost of Goods Sold" --proposal "Synthetic Fleet Loan"
{
  "financials_source_default": "analyst-supplied",
  "financials_source_note": "Depreciation embedded in Cost of Goods Sold",
  "confirmed_date": "2026-01-15",
  "history": [{"financials_source": "analyst-supplied", "note": "Depreciation embedded in Cost of Goods Sold",
               "confirmed_date": "2026-01-15", "proposal": "Synthetic Fleet Loan"}]
}

(confirmed_date defaults to today; it is fixed here only for the example.) On a later deal /spread reads what is on file with conventions.py --company ... --read (or --enterprise --read; an absent store prints {"found": false, "convention": null}), tells you what it found, and still requires an explicit answer before applying it.

Figures read from an image

An analyst's spreading often arrives as a screenshot of their template, a photo or a scanned page. The session reads the image itself, and a misread digit, a dropped decimal or a flipped sign would otherwise become the deal's ground truth: in analyst-supplied mode nothing recomputes the figures, and in the default mode the ratios are recomputed from whatever was transcribed. So /spread does not write anything for image figures until you have confirmed a read-back:

  1. (model) The session transcribes the figures into a staged file, each exactly as it appears, with the unit it reads from the image and how the source writes its signs: whether a cost, a cash outflow or a liability is shown as a positive number or in brackets. The framework enters costs and liabilities as positive amounts (it subtracts a cost), so a statement that shows a cost as (700) has to be read deliberately, never guessed. The synthetic one is docs/examples/synthetic_co/transcription_input.json (its "screenshot" is the tiny placeholder image statement.png beside it); its costs are in brackets, so it declares "cost_sign": "negative".

  2. (local) python scripts/transcription_check.py --transcription "deals/Synthetic Co/Synthetic Fleet Loan_transcription.json" reads it back. It writes nothing. It shows the image's SHA-256 fingerprint and the sign conventions, then every figure as written beside what will be recorded and why: (700.0) is recorded as 700.0 ("sign reversed: costs are written as negatives in this source"), 1,200.0 as 1200.0 ("as written"). Suppose the session also misread a receivables figure as 260 instead of 200. The cross-foot, which compares each subtotal the image states with the sum of the recorded values of the lines that feed it, shows it:

    | Period | Check | Source states | Lines give | Difference | Tolerance | Result |
    | :--- | :--- | ---: | ---: | ---: | ---: | :--- |
    | FY-Current | gross_profit | 500.0 | 500.0 | 0.0 | 0.15 | match |
    | FY-Current | current_assets | 250 | 310 | -60 | 2.5 | MISMATCH |
    | FY-Current | total_assets | 1,150 | 1210 | -60 | 4.0 | MISMATCH |
    | FY-Current | balance_sheet_balances | 0 (balance sheet identity) | 60 | -60 | 8.5 | MISMATCH |
    

    and ends STATUS: BLOCKED. A commit is refused while a MISMATCH is unresolved.

  3. You compare the discrepancy with the image. The receivables figure really is 200; the session corrects the staged file and reads it back again. Every check now matches, the digest has changed (it covers the figures, the unit, the sign conventions, the source description, any acknowledgement and the image's bytes), and the output ends STATUS: ready for the analyst's confirmation. with Digest: 54af01233cd518c3 and the fingerprint 0a5f4a132143926b9c62a85d53d859c2bf7f854c09c632f093d1bcf47cc68e0f.

  4. You confirm, explicitly, that these figures match the image and that the sign conventions are how it writes them. A question, "looks fine, carry on" or silence is not confirmation, and neither is the session's own confidence. A correction (of a figure, of a sign declaration) sends it back to step 3; cancelling leaves the deal exactly as it was.

  5. (local) python scripts/transcription_check.py --transcription "..." --commit --confirm 54af01233cd518c3 --company "Synthetic Co" --proposal "Synthetic Fleet Loan" first checks the deal can take it (one deal never mixes the two /spread modes), then saves the image as the source of record, verified against the fingerprint you confirmed (its manifest entry says the figures were transcribed from an image), records the figures (recomputed exactly as spreading_check.py does, or, in analyst-supplied mode, as given with the disclosure added to financials_source_note) and adds a financials_transcriptions record that holds the fingerprint, never the image. Quoting the earlier digest of the misread version, or any digest after the image file was replaced, would have been refused.

Why the sign declaration matters. If the same screenshot were declared "cost_sign": "positive", (700.0) would be recorded as -700.0, a credit, and gross profit would come to 1900.0 against the 500.0 the image states. The cross-foot sees that and says why, and no acknowledgement can be used to wave it through, because reading the costs the other way makes it match:

| FY-Current | gross_profit | 500.0 | 1900.0 | -1400.0 | 0.15 | MISMATCH (matches if costs were read with the opposite sign: correct the sign declaration; an acknowledgement cannot cover this) |

A genuine credit is not forced positive: under "cost_sign": "positive" an expense written (50) is recorded as -50, and under "negative" an expense written 50 is. Every figure recorded as negative is listed in the read-back under "Look at these before confirming".

A subtotal whose feeding lines were not all transcribed is shown as NOT ASSESSED: that check was not made, and the figures are not described as verified. Ratios are never cross-footed. The rules and their limits are in the financial model; what code enforces and what rests on you is in AI assurance.

Collateral, projections and covenants

/collateral records each asset and each charge over it as flat lists in state.json; /project records forward years, stress assumptions, covenants and guarantees. These are the structured facts the policy engine works on. The example's deal_structure.json holds the two covenants, two assets, two charges and one guarantee; the covenants are:

[{"metric": "dscr", "type": "minimum", "threshold": 1.25},
 {"metric": "gross_leverage", "type": "maximum", "threshold": 3.5}]

Charge fields are compared as exact strings by code: "perfection_status": "Perfected" and "ranking": "First" mean a fully perfected, senior charge, and anything else (for example "Registered" or "Second") is a gap.

Forward years and the stress case come from two more input files (forward_input.json with FY+1 and FY+2, and stress_input.json):

{"revenue_haircut_pct": 5, "interest_rate_bump_bps": 200}
python scripts/spreading_check.py --company "Synthetic Co" --proposal "Synthetic Fleet Loan" \
    --financials "deals/Synthetic Co/Synthetic Fleet Loan_forward_input.json" \
    --stress-assumptions "deals/Synthetic Co/Synthetic Fleet Loan_stress_input.json" \
    --no-update-financials-source

--no-update-financials-source is always passed here so that forward figures never flip the deal's financials_source. The state now also holds the forward ratios and the downside case. The numbers that matter below: FY+1 has DSCR 1.1 and gross leverage 3.0; FY+2 has negative EBITDA, so its gross leverage is N/A and its DSCR is -0.204; and the FY+1 downside (5% less revenue, 200 basis points more interest) has gross leverage 5.15625 and DSCR 0.600.

Forward years supplied by the analyst

When an institution's forecast convention does not fit the framework's raw schema, /project asks which mode applies and, in the analyst-supplied mode, records the analyst's own forward-year figures as given (docs/examples/synthetic_co/forecast_supplied.json: FY+1 with its subtotals, ratios and the raw lines behind them, every line the covenant ratios read, the nil ones as explicit zeros, FY+2 with ratios and EBITDA only). It also takes the stress shocks (forecast_stress.json: a 10% revenue haircut and a 200 basis point rise). On a deal with no framework-computed history:

python scripts/supplied_forecast.py --company "Synthetic Co" --proposal "Synthetic Budget Loan"     --forecast docs/examples/synthetic_co/forecast_supplied.json     --stress-assumptions docs/examples/synthetic_co/forecast_stress.json     --note "Management budget; depreciation is within cost of sales"

The figures are stored exactly as given, forecast_source and financials_source are analyst-supplied, and the note joins financials_source_note for the CAM's caveat. The summary says what became of the downside:

"basis": {"FY+1": "framework-derived from reconciled analyst-supplied lines"},
"unavailable": {"FY+2": "no raw lines were supplied for this year, so the framework's shocks have nothing to act on"}

FY+1 was stressed by the framework because its lines reproduce the subtotals and ratios the analyst gave (EBITDA 300, gross profit 400, DSCR 6.0, gross leverage 0.67), so the shocks mean what they say: stressed EBITDA is 200. FY+2 has no lines, so the shocks have nothing to act on and no downside is invented. With a minimum DSCR covenant of 1.25 the policy check then reports, for FY+2 (whose supplied DSCR of 1.9 passes), a downside breach DOWNSIDE-FY-2-DSCR with status UNRESOLVABLE and the reason downside analysis unavailable for FY+2: no raw lines were supplied for this year, so the framework's shocks have nothing to act on: the draft must address it, and it cannot be read as a pass. Had the analyst supplied their own stressed FY+2 forecast, that would have been recorded as theirs and tested instead. The rules are in the financial model.

Policy checking

Use it when you want the deterministic facts about a deal before drafting, or to audit a draft. Needs only what state.json already holds. Writes nothing by itself (/assemble stores the result as policy_state).

python scripts/policy_check.py --company "Synthetic Co" --proposal "Synthetic Fleet Loan"

prints JSON with policy_state, reasons, compliant and cam_data_present. For the example, policy_state says:

  • Conditions precedent: KYC-AML, FACILITY-EXECUTION and GUARANTEE-SYNTHETIC-PARENT-HOLDINGS. The first two are always required; the guarantee one exists because the deal has a guarantee.
  • Conditions subsequent: MI-REPORTING, CS-COVENANT-COMPLIANCE, CS-SEC-REPERFECT-AST-001, CS-SEC-REPERFECT-AST-002 and CS-GUARANTEE-SYNTHETIC-PARENT-HOLDINGS.
  • Covenant results (FY-Current): DSCR 2.0 against a minimum of 1.25 is PASS with 60% headroom; gross leverage 2.0 against a maximum of 3.5 is PASS with 42.9% headroom.
  • Downside breaches: DOWNSIDE-FY-1-GROSS-LEVERAGE: PASS in the FY+1 base case (3.0) but FAIL under stress (5.15625). The draft must address it.
  • Forward covenant results, disclosure only: FORWARD-FY-1-DSCR is FAIL (1.1), FORWARD-FY-1-GROSS-LEVERAGE is PASS, FORWARD-FY-2-DSCR is FAIL (-0.204), and FORWARD-FY-2-GROSS-LEVERAGE is UNRESOLVABLE ("gross leverage not meaningful: EBITDA is negative"). None of these rejects a draft by itself.
  • reasons is empty and compliant is true: nothing about the recorded structure forces a rejection.

If a charge is registered but not perfected, or ranks second, the picture changes. With AST-002 recorded as "Registered" and "Second", the same command adds the conditions SEC-PERFECT-AST-002 and SEC-PRIORITY-AST-002 and returns these reasons, which keep compliant false until the recorded structure is fixed:

Unperfected Security: Asset AST-002 charge status is 'Registered', not Perfected.
Subordinate Ranking: Asset AST-002 charge ranking is 'Second', not First.

Assembly and export

Use it when the prior steps are done. Needs spread in steps_completed (a hard gate), a template, and your --pd/--lgd inputs. Writes the .docx and .xlsx, policy_state, draft_path and the review trail.

/assemble --company "Synthetic Co" --proposal "Synthetic Fleet Loan" --type asset_finance --pd "0.20%" --lgd "LGD 3 (15%)"
  1. Resolve the template (local): templates/local/cam/asset_finance_cam.md if it exists, else templates/cam/asset_finance_cam.md.

  2. Gate the step order (local):

    python scripts/state_manager.py --check-steps --company "Synthetic Co" --proposal "Synthetic Fleet Loan" --required spread

    prints {"missing_steps": [], "ok": true}. If spread were missing it would print "ok": false and the command would stop and tell you to run /spread first. (/triage and /collateral are deliberately not required: a deal may be unsecured, or its identity details may come straight from you.)

  3. Get policy_state (local) as above.

  4. Draft (model). The Underwriter writes the CAM into the template and ends with a structured JSON block that declares what it did. The example draft ends:

    {
      "cp_ids_included": ["KYC-AML", "FACILITY-EXECUTION", "GUARANTEE-SYNTHETIC-PARENT-HOLDINGS"],
      "cs_ids_included": ["MI-REPORTING", "CS-COVENANT-COMPLIANCE", "CS-SEC-REPERFECT-AST-001",
                          "CS-SEC-REPERFECT-AST-002", "CS-GUARANTEE-SYNTHETIC-PARENT-HOLDINGS"],
      "reported_figures": {"ebitda": 1000, "tangible_net_worth": 2200, "dscr": 2.0, "gross_leverage": 2.0,
                           "gross_leverage_FY+1_downside": 5.15625},
      "downside_breaches_acknowledged": ["DOWNSIDE-FY-1-GROSS-LEVERAGE"],
      "sources": ["Synthetic Co FY-Current accounts (synthetic example)"]
    }

    (shortened; the real block also covers every risk category). The block is removed from the exported document.

  5. Review (model plus local). /review runs the code-enforced check first and then the Risk Reviewer's judgement; see the next section. Repeat until APPROVED.

  6. Export (local):

    python scripts/deal_export.py --company "Synthetic Co" --proposal "Synthetic Fleet Loan" --type asset_finance \
        --draft "deals/Synthetic Co/Synthetic Fleet Loan_draft.md"
    Done! Files generated in deals/Synthetic Co/Synthetic Fleet Loan_2026-10-04
    

    The deal's dated folder now holds state.json, Synthetic Co_Synthetic Fleet Loan_CAM.docx and Synthetic Co_Synthetic Fleet Loan_Spreading.xlsx (see Outputs). The folder is the deal's existing one, however many days the work has taken. The approved Markdown draft is then moved into that folder as draft_approved.md and its path is recorded in state.json as approved_draft_path; it is not deleted.

The headless equivalent is one command, with the same outputs:

python scripts/orchestrator.py --company "Synthetic Co" --proposal "Synthetic Fleet Loan" --type asset_finance \
    --financials financials.json --collateral collateral.json --stress-assumptions stress.json

Review

/review (and the loop inside /assemble) always applies two layers, in this order:

  1. The code-enforced check (local) runs policy_check.py --draft .... Each line it returns is a reason the draft is rejected, and REJECTED is mandatory whatever the Reviewer thinks. Against the example draft, small defects give, for instance:

    Defect in the draft Reason returned
    FACILITY-EXECUTION missing from cp_ids_included Missing Required CP FACILITY-EXECUTION: Execution of Facility Agreement.
    "dscr": 2.5 in reported_figures Narrative/Ground-Truth Mismatch: reported dscr 2.5 vs computed 2.0
    downside_breaches_acknowledged left empty Undisclosed Downside Breach DOWNSIDE-FY-1-GROSS-LEVERAGE: gross_leverage breaches threshold in FY+1 under stress but is not addressed in the draft.
    no structured block at all one Missing Required CP/Condition Subsequent line per item, Missing or malformed Risk Category for each of the seven categories, the undisclosed downside breach, and Missing Narrative Sources
  2. The Risk Reviewer's judgement (model), run by a fresh sub-agent that has not seen your session and reads the saved draft and the deal's files itself, covers what code cannot: unsourced claims, weak mitigants, whether the narrative is substantive, and (when you have calibrated one) credit-policy violations. For a /research brief, it also checks that the closing Sources list is complete for the claims, that each in-text short-form reference has a citation key, and that no cited document is absent from the list. If an analyst-override footnote replaces Sources, the note must include a reason and date; the authorised override itself is not grounds to reject, but every claim still has to trace to a source cited in the text. A listed source that no claim cites is a minor point, not a reason to reject on its own. A code-enforced reason cannot be overridden by it. The analyst-override footnote is added by the exporter after the review, so the Reviewer cannot see it: a brief exported with an override and no Sources section may therefore be flagged by the Reviewer. The analyst's decision at the review checkpoint (after three consecutive rejected passes, or at a lower maximum the analyst set for the deal) handles that case.

Each verdict is appended to the deal's review_trail, which is never replaced:

{"iteration": 1, "verdict": "REJECTED", "notes": "Missing Required CP FACILITY-EXECUTION: ...", "timestamp": "2026-10-04T10:15:00"}

If the Reviewer rejects a draft over a credit-policy point and you correct its reading of the policy, /review offers to persist that as a standing interpretation note; it writes config/credit_policy_notes.md only on an explicit yes. During /research and /assemble, an analyst-defined term is checkpointed immediately to the deal's state.json under analyst_terms, so compaction cannot lose a definition already recorded. At end of deal, the analyst_terms entries join the reusable REJECTED notes from review_trail in the same candidate batch. Persist a candidate only on an explicit yes and ask each time whether it is borrower-specific or applies to every borrower. If the analyst says a term is industry-standard, point to docs/glossary.md and write nothing to a tracked file. These learnings are advisory, and the fresh Reviewer is not given analyst_terms; if a definition matters to the audit, write it plainly in the brief. See the shared glossary for external credit terms.

State rehydration (resuming and compaction)

Every step reads the deal's state.json first and writes back when it finishes, so a long session, a compaction or a resumed session never loses a completed step. Resuming is therefore just running the next command:

sequenceDiagram
    participant You
    participant Claude as Claude session
    participant State as state.json
    You->>Claude: /assemble ... (days later, new session)
    Claude->>State: read steps_completed, financials, ratios, policy inputs
    State-->>Claude: spread, collateral, project already done
    Claude->>Claude: python scripts/state_manager.py --check-steps ... --required spread
    Claude-->>You: proceeds from the recorded figures, never from memory
Loading

state_manager.py --check-steps is the gate. For a deal that has run spread and project:

$ python scripts/state_manager.py --check-steps --company "Synthetic Co" --proposal "Synthetic Fleet Loan" --required spread,triage,collateral
{
  "missing_steps": ["triage", "collateral"],
  "ok": false
}

(it always exits 0; the caller decides what to do). The dated folder is found automatically, so a deal started on one day and finished on another stays in one folder; pass --new-review to the orchestrator to start a fresh dated folder for a new annual review instead of inheriting last year's inputs.

If state.json cannot be used, the scripts stop with one clear line rather than guess. See Troubleshooting.

Clone this wiki locally