Skip to content

contributing

github-actions[bot] edited this page Nov 4, 2026 · 7 revisions

This page is generated from docs/contributing.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.

Contributing

Practical guidance for changing this repository: what to treat as true, what must stay green, what must never be committed, and how a change is sequenced into main. It assumes you have read the architecture page; the reasons behind the rules are in design decisions. Maintainer procedures (diagnosing a red CI run, reading a mutation report, refreshing a snapshot) are in the operations runbook.

Set up

python -m venv venv                    # then activate it (venv\Scripts\activate on Windows)
pip install -c constraints.txt -r requirements-dev.txt    # install the reviewed, pinned CI dependency set
pytest                                 # the whole suite; no API key and no network needed

requirements*.txt retain the project's minimum supported versions. constraints.txt pins the exact package versions observed in the green Python 3.11 CI/runtime/security/mutation profiles, including transitive dependencies. Use it for normal installs so a fresh checkout starts from the tested set; do not treat updating a minimum in a requirements file as a complete dependency bump.

CI runs Python 3.11 on Ubuntu and on Windows; Windows is the primary development platform, so a change must work with a cp1252 console, backslash paths and CRLF line endings. The basic pytest command above is serial. To match CI's test profile, Ubuntu runs pytest tests/ -n 4 --dist=loadfile --durations=30 with coverage and Windows runs pytest tests/ -n 4 --dist=loadfile --durations=30. pytest-xdist supplies -n, --dist=loadfile keeps each test file on one worker, and --durations=30 records the slowest tests.

What is true when sources disagree

Documentation describes the system; it does not define it. When two sources disagree, the one nearer the top is right and the other is a bug to fix in the same change.

Fact Authoritative source Explained in
What the code does The implementation and its tests (scripts/, tests/) CLI reference, financial model, data model
What a slash command does .claude/commands/*.md Commands
What an agent is told to do agents/*.md Architecture, AI assurance
How CI, coverage and mutation testing are configured .github/workflows/, pyproject.toml Testing and CI
What Claude Code must follow when it changes this repository CLAUDE.md CLAUDE.md
Everything else a reader needs docs/ The index

The full table, including flags, settings and security controls, is in the documentation index. A page that says something the source does not is wrong, not the source.

Making a change

  1. Start from an issue, or open one. A change that settles a question someone would otherwise reopen gets an entry in decisions.
  2. Branch from an up-to-date main and keep the change to one concern. Unrelated clean-ups go in their own pull request.
  3. Change the source first, then the page that explains it, in the same pull request (next section).
  4. Run the checks in Testing and static analysis before you push.
  5. Open a pull request using the shared PR template, whether the PR is drafted in GitHub, via an API, or by an AI coding assistant. Keep the description concise for simple edits and more explicit for complex work: map acceptance criteria to evidence, explain material design choices/trade-offs, state behavior or compatibility changes, and list known limitations. Use the dedicated Documentation changes section to name updated docs/examples/CLI help/configuration/workflow/prompt/skill guidance; if none changed, say so and explain why. Put scope-boundary claims in "Safety, compatibility, and scope," where a reviewer can check them against the diff. Keep the AI assistance disclosure as the final section: identify every AI tool/product and exact model that contributed, describe each contribution (planning, implementation, tests, docs, or review), and say None if no AI contributed. Do not guess a model identifier or describe a review-only contribution as generated code. A tool's own attribution footer may follow the disclosure but does not replace it. Keep validation results tied to the current PR head and refresh them after rebases or new commits. An AI agent working on the repository also records its work as a CLAIM, STATUS and OUTCOME on issue #245, with the detail on the issue or pull request (Agent ledger).
  6. Merge through the ruleset. main takes changes through a pull request with the test, test-windows and runtime-smoke checks passing and the branch up to date; the maintainer merges. Do not push to main.

Mergeability rubric

Use this as a review aid. The classifications below point to existing repository rules; they do not add new requirements.

Review item Classification Existing rule to check
All required checks (test, test-windows, runtime-smoke) pass and the branch is up to date. Blocker CLAUDE.md — Testing and static analysis; Making a change
No coverage floor, security audit, workflow safeguard or other gate was weakened without the review already required for that change. Blocker Security review; tests/test_ci_workflow.py
A prompt or command edit follows the deliberate-change, own-issue/PR and authorization rules; guarded numbered references and evaluation context are handled. Blocker CLAUDE.md — Editing the agent prompts and commands; Changing an agent prompt; tests/test_prompt_consistency.py
A formula change updates its formula-register entry and affected documented/synthetic example outputs in the same PR. Blocker Formula register conventions; tests/test_formula_register.py; tests/test_docs_examples.py
The PR template's Documentation changes section is completed explicitly, including “none” and why where appropriate. Blocker PR template — Documentation changes; CLAUDE.md — Git workflow
The AI-assistance disclosure is accurate, names the model actually used, distinguishes contribution types, and remains the final PR-template section. Blocker PR template — AI assistance disclosure; CLAUDE.md — Git workflow
No real borrower, customer or personal data, or credentials, are added to the public repository. Blocker Synthetic data only; tests/test_confidential_paths.py
Every confirmed finding, Low included, is fixed or explicitly waived by the maintainer before merge. Blocker Agent ledger — Findings
Validation evidence in the PR body matches the current head (head SHA, run and counts). Blocker CLAUDE.md — Git workflow; PR template — Validation and evidence
Style nits that do not change behavior or clarity, and optional refactors without a demonstrated correctness, security or maintainability need. Non-blocker (advisory) Making a change

The optional ## Declared file scope section in the PR body is a reviewer aid, not a merge condition. The separate .github/workflows/scope-check.yml workflow compares its path/glob declarations with the changed-file list and calls out protected paths even when they are declared. Because a pull_request run executes the script from the PR's own merge commit, its report is a reviewer aid and not a gate or a proof.

Keeping the documentation in step

  • Put each kind of text in its layer. A rule Claude Code must obey goes in CLAUDE.md; an explanation, example or reference goes in docs/; the landing page stays short. CLAUDE.md is not a user manual: if you are explaining, you are in the wrong file.
  • Write the page and the source in one pull request. A renamed flag, a new command, a changed setting or a new CI job is incomplete until the page that names it changes too.
  • Let the tests tell you what you missed. Documentation has executable checks, and each fails with the file and line:
    • links and heading anchors resolve; every page under docs/ is linked from the index; the CLAUDE.md headings that code and commands cite still exist (tests/test_docs.py);
    • every --flag a document passes to a script exists in that script's --help (tests/test_command_flags.py);
    • every figure and message a page quotes from the synthetic worked deal is what the real scripts print (tests/test_docs_examples.py);
    • the slash commands, the documented settings, the CI jobs, the cited repository paths and the schema version agree with the source (tests/test_docs_contracts.py);
    • Guideline N / Audit Checklist item N references resolve (tests/test_prompt_consistency.py).
  • Changing a quoted example. The worked examples are real runs of docs/examples/synthetic_co/. If you change a formula, a message or an input, run the deal again, update the page with the new output, and let tests/test_docs_examples.py confirm they match; never edit a figure by hand to make a test pass.
  • Keep evergreen pages evergreen. No "as of" dates, "has not been run yet" or current test counts in the reference pages. The only dated statement is Project status in the index; volatile status otherwise lives in the tracking issue.
  • Add a new page to the index, or the link test fails.
  • The move ledger is a record, not a living page. It describes the first reorganisation and is not updated when pages change afterwards.

Synthetic data only

The repository is public and forkable. Everything in it that looks like a deal is invented.

  • Use obviously fictional names ("Synthetic Co", "Synthetic Fleet Loan") and round, invented figures in examples, fixtures, snapshots and documentation. The evaluation dataset requires every company name to start with Synthetic .
  • Run python scripts/pii_scan.py <file> over any template or text you add if there is any doubt. It is a heuristic (UK-shaped patterns plus a few international ones); it is not an international PII detector, a clean result is not a guarantee, and a by-hand read is still required.
  • Never put a real borrower, person, institution, figure, document or screenshot into the repository, a test, an issue or a pull request. The tests cannot see issue or pull-request text, so that one is a process rule.
  • Do not copy a reference document someone shared with you into the repository, even into an ignored folder: it creates a persistent copy nobody asked for.
  • An example credential is a placeholder such as sk-ant-..., never a real key, and never one that merely looks real.

Confidentiality and credentials

Anything derived from a user's real material lives in a git-ignored location, and a test enforces the list (Security).

  • Adding a feature that stores something derived from real material? Add its location to .gitignore before anything can write there, and add it to PROTECTED_PATHS in tests/test_confidential_paths.py in the same pull request. A new ignore line that is not confidential (build noise) goes in NOT_CONFIDENTIAL with a reason. Never store such material under a tracked path such as templates/cam/.
  • Credentials. The only credential you provide is ANTHROPIC_API_KEY, read from the environment by the headless scripts (the wiki-publish workflow additionally uses the GITHUB_TOKEN GitHub issues to that one job). Do not write it into a file, a deal folder, a prompt, a command, an issue, a workflow or a chat with an AI assistant. A live key pasted anywhere should be treated as leaked and rotated. Do not add any other secret, token or .env reader without a reviewed design.
  • Live model calls. No test, workflow or default code path makes one. Only python scripts/run_evals.py --live, run by hand with your own key under a call cap, does (Evaluation).

Testing and static analysis

A pull request is ready when all of these pass locally, because CI will run them:

ruff check .                      # rules live in pyproject.toml
bandit -r scripts/ -ll
pytest tests/ -n 4 --dist=loadfile --durations=30 --cov --cov-report=term --cov-report=json --cov-report=xml
python scripts/check_coverage.py coverage.json

What the rules ask of you, in short (the full description is in Testing and CI):

  • Test the change. New behaviour comes with tests that fail without it; a bug fix comes with a test that reproduces it. The tests that guard a rule also demonstrate they can fail (see how tests/test_docs_contracts.py runs each check on deliberately wrong input).
  • Respect the floors. 95% overall, 97% for each of eleven governance modules, and, for the lines your pull request changes, 95% (98% in a governance module). Code that only runs on Windows needs # pragma: no cover - <reason>.
  • No warning, network or hang. Warnings fail the run, pytest-socket forbids network access, and a test that runs over 120 seconds fails.
  • Encoding. Every open() of a text file passes encoding= (the UTF-8 policy; ruff enforces it), and every script's __main__ block starts with from textio import configure_stdio then configure_stdio().
  • A new CLI is added to the list in tests/test_cli_subprocess.py; a finding in scripts/ is fixed or carries a # noqa: <code> with the reason beside it.
  • Known-bad behaviour that you find but are not fixing is a strict xfail naming its issue, so fixing it later fails the test until the marker is removed.
  • No model. Tests use fake clients; a change that makes a test need a key or a network is a bug.

State compatibility

state.json outlives the code that wrote it: deals are resumed weeks later by a newer checkout.

  • Adding an optional key is fine and needs no version bump. SCHEMA_VERSION changes when the schema gains a new top-level shape a reader must know how to interpret, not on every field.
  • Keep the fixtures working. A change to the shape must keep the historical and malformed fixtures in tests/fixtures/state/ (and the malformed-shape matrix in tests/test_legacy_state.py) passing, or add a new fixture that records the new shape.
  • Never downgrade. write_state() and append_review_trail() refuse a newer or malformed schema_version and leave the file unchanged (D7); do not add a write path around that.
  • Validate what you read. A consumer checks only the keys it reads (read_state(..., keys=...)) and a bad shape is one error: line and exit status 1, never a traceback.
  • Two raw-figure stores stay separate (multi_period_financials and analyst_supplied_financials); read them through deal_export.py's _financial_data_from_state() logic and do not merge them (data model).
  • If you bump SCHEMA_VERSION, update the version shown in the data model; tests/test_docs_contracts.py fails if the page and the code disagree.

Golden snapshots

tests/snapshots/ holds the reviewed text of the exported .docx and .xlsx for synthetic inputs. They change only on purpose.

  1. Make the intended output change.
  2. Run pytest tests/test_golden_outputs.py --update-snapshots.
  3. Read the snapshot diff like code and confirm every changed line is intended. A new python-docx or openpyxl release that alters serialisation shows up here; regenerate only after confirming the difference is cosmetic.
  4. Commit the snapshots with the change that caused them.

CI never passes --update-snapshots, and a missing snapshot fails rather than being created, so a forgotten refresh is caught.

Security review

Before asking for review, check the change against this list. Each item is a place the repository has had to be careful.

  • New subprocess, network, file or path handling. Does a path come from model-written text? Treat it as untrusted; restrict it or surface it for review (the image-embedding rule in CLAUDE.md is the pattern).
  • New dependency. It is added to the right requirements file, so pip-audit covers it; prefer the standard library for the deterministic core.
  • Workflow change. Every third-party action pinned to a full commit SHA with a # vX.Y.Z comment; permissions: {} at the top and contents: read per job (the two documented exceptions: model-freshness.yml's issues: write and wiki-publish.yml's one-job contents: write); persist-credentials: false; no pull_request_target; no ${{ ... }} interpolated into a shell command. zizmor runs in CI and the structure is pinned by tests/test_ci_workflow.py. Never weaken the security job with continue-on-error, || true or by dropping a requirements file; the advisory-ignore procedure is in Testing and CI.
  • Content that reaches the model. Source documents, fetched pages and analyst notes are untrusted data. Do not make a code path that treats them as instructions; the prompt-level hardening is deliberately sequenced after a baseline (AI assurance).
  • Confidential locations and credentials, as above.
  • Settings and rulesets. Repository settings, branch protection and rulesets are changed by the maintainer in GitHub, never by a pull request, and are not described by files in this repository.

Changing an agent prompt

agents/underwriter_agent.md and agents/risk_reviewer_agent.md are the model's specification, and editing one is a deliberate act of its own.

  • Never as a side effect. Do not change a prompt while doing something else, and do not change one to make documentation or a test easier.
  • Why it is different. A headless deal records a content hash of each prompt in model_provenance, and an evaluation baseline records the hashes it measured. Editing a prompt makes earlier deals and earlier comparisons refer to text that no longer exists, and there is no automated way to tell whether the edit made the model better or worse until a live baseline exists (AI assurance).
  • So a prompt change has its own pull request, its own issue and explicit maintainer authorisation, and its description states the evaluation story: the baseline it is compared with, or why none is needed.
  • Keep the prompts independent. Do not merge them or have one import the other's context (D1).
  • Numbered references are guarded. Inserting a Guideline or Audit Checklist item mid-list re-points every later reference; tests/test_prompt_consistency.py resolves each one, so renumber deliberately and update EXPECTED_SUBJECTS in the same change.
  • Documentation does not depend on the prompts' layout, and the prompts currently reference neither README.md nor CLAUDE.md; keep it that way, so moving documentation never forces a prompt edit.
  • The interactive Checker is a file too. .claude/agents/risk-reviewer.md sets the Reviewer's tools (Read, Glob and Grep only) and how it applies the role; widening them, or letting /review give it the draft text, resume it or fork it, undoes D1's isolation and fails tests/test_interactive_checker.py.
  • Command files are not prompts but behave like them. A .claude/commands/*.md edit changes what a session does; treat it with the same care, and keep the plain-prose way of including a file ("Read agents/underwriter_agent.md"); there is no @path inclusion.
  • A skill is not a prompt change and must not become one. Skills follow Skill design: no agent prompt or command names or loads one, a skill never writes a deal's records, it never shares a command's name, and its allowed-tools is reviewed like a workflow change, because a checked-in skill can grant itself tool access.
  • A known inconsistency is tracked, not patched in passing. For example, the Risk Reviewer prompt's statement about /review (#197) is corrected only through this process.

Pull request sequencing and the test-count badge

badges/test-count.json records how many tests pass. CI compares it with pytest's own summary line and fails on a mismatch; it never corrects it, because a bot committing to a branch or to main would break the rule that every change goes through review.

  • If your change adds or removes passing tests, update the file in the same pull request, from a complete green run of the whole suite:

    pytest tests/ -n 4 --dist=loadfile --durations=30 | tee pytest_output.txt
    python scripts/check_test_count.py pytest_output.txt --write

    --write refuses output that is visibly not a complete green run (failures, errors, deselected tests, an early halt), but it cannot tell that you ran only part of the suite, so run all of it.

  • Because every pull request that adds tests edits this one-line file, such pull requests are merged one at a time. The second one rebases onto the new main, reruns the suite and runs --write again.

  • A change that does not alter the passing count leaves the file alone; a documentation-only change usually does not touch it.

  • Review the file's diff as part of the pull request: the number should equal the old number plus the tests you added.

Before you ask for review

  • The change is one concern, from a current main.
  • Source changed first; every page, example and command text that describes it changed with it.
  • ruff check ., bandit -r scripts/ -ll and the whole of pytest pass; coverage floors met.
  • The badge matches a complete green run (or is untouched because the count did not change).
  • No real data, key or secret anywhere; a new protected location is in .gitignore and PROTECTED_PATHS.
  • No unrelated change, and no edit to agents/, settings or rulesets that was not the point of this pull request.
  • The description says what was verified and what was left alone.

Clone this wiki locally