Repository navigation
rules register
This page is generated from
docs/rules-register.mdin the repository --docs/is the canonical documentation. Direct wiki edits here are overwritten on the next publish; make changes indocs/by pull request.
The code is authoritative; this page describes the behavioural rules the deterministic policy engine and its checks must preserve. That is the same boundary as D18: the register does not define behaviour and must not be used to justify a change that the code and its source do not support. The scheme was approved on issue #495 (the design note and the maintainer's sign-off with amendments A1 to A4); decision D33 (issue #496) records it.
- One claim per rule. Each Claim is one independently reviewable obligation, in one short sentence. Source points to the sentence or decision that states it; the Claim describes that obligation without copying the source paragraph. The implementation remains authoritative.
-
Stable IDs. IDs use
R-<AREA>-NNN, with three digits and a separate sequence per area, numbered consecutively from 001. The agreed areas arePOL(policy engine and draft checks),STATE(state persistence and validation),SPREAD(financial calculations and spreading), andEXPORT(raw-value selection and rendered output). An ID belongs to the obligation, not its Python location. IDs are never reused or renumbered. - Splitting and withdrawal. If a compound obligation is split, retain its old ID as Withdrawn, state the reason and list the successor IDs in Tracking, then allocate new IDs. A withdrawn entry is never deleted or reused. Merging obligations keeps one surviving ID and withdraws the others with the successor recorded.
- IDs ever issued. The list below is an append-only human-reviewed history. Every entry ID appears there once, and every listed ID has exactly one entry. The gate can detect inconsistencies within the current page; it cannot prove that a coordinated edit did not remove both an old entry and its history item. Reviewers must therefore treat this list as append-only.
-
No test inventory here. There is no Citing tests field. The gate derives citations from literal
Rule: R-...lines in pytest test-function docstrings. Issue #500 performed the initial claim-to-test audit; citations live in the individual test docstrings rather than a duplicate inventory on this page.
Every rule has exactly one of these statuses:
-
Covered — at least one test docstring cites the ID, and the test-to-claim check has verified that the cited
assertion covers the whole Claim. Tracking is
—. - Not covered — the whole Claim has not yet been verified by a citing test. Tracking links the issue responsible for the gap or the temporary verification work. A Not covered row does not mean the implementation is absent.
- Withdrawn — the obligation has been retired or split. Tracking records why and, for a split, the successor IDs. Withdrawn IDs remain in this page and cannot be reused.
The active rules in this register began as Not covered with issue #500 as the temporary citation and verification tracker. During #500, candidate test bodies were checked against each Claim; only tests whose assertions verify the whole Claim received a citation and a Covered status. The remaining Not covered entries from that audit each link their own gap issue, which asks for the missing test. The second batch links issue #530 for its outstanding test-citation verification; existing behavioural tests do not make a new rule Covered until they cite its ID.
Inventory at this revision: 43 IDs ever issued; 33 active Covered; 7 active Not covered; 3 Withdrawn.
The field has one of three forms, using repository-relative paths:
-
<file>names a file only. Use this when responsibility sits in that module but no single function is the right reference. -
<file>::<function>names a module-level function. A method is written<file>::<Class>.<method>. -
nonestates that no implementation exists.
The #499 gate will check that a file path exists and, when a function or method suffix is present, that the named
definition exists in that file (by source inspection, without importing the module). A file-only reference is checked
for the file, not an invented function. none makes no file/function existence claim and is used only for a
Not covered rule with a Tracking issue. Where several functions implement a rule within one module and no single
function is the owner, use the file-only form.
A citation declares which rule a test is responsible for; it is not proof that the test is strong or that its assertions cover the Claim. The static gate cannot establish that a cited test executes: a test marked skipped is still present in source, a test can be deselected at run time, and tests generated dynamically in a loop are not reliably visible as ordinary test definitions to an AST scan. It also does not judge assertion quality, fixtures, or whether the chosen test genuinely proves the behaviour. Those remain matters for source inspection and review. A green gate therefore means the register and citations are structurally linked, not that every claim has been independently proven by the gate.
R-POL-001R-POL-002R-POL-003R-POL-004R-POL-005R-POL-006R-POL-007R-POL-008R-POL-009R-POL-010R-POL-011R-POL-012R-POL-013R-POL-014R-POL-015R-POL-016R-POL-017R-POL-018R-POL-019R-POL-020R-POL-021R-STATE-001R-STATE-002R-STATE-003R-STATE-004R-SPREAD-001R-SPREAD-002R-SPREAD-003R-SPREAD-004R-SPREAD-005R-EXPORT-001R-EXPORT-002R-EXPORT-003R-EXPORT-004R-EXPORT-005R-EXPORT-006R-SPREAD-006R-SPREAD-007R-EXPORT-007R-EXPORT-008R-STATE-005R-STATE-006R-SPREAD-008
- Claim: A covenant on an N/A ratio is UNRESOLVABLE for both minimum and maximum covenants.
- Source: N/A and UNRESOLVABLE.
-
Implemented in:
scripts/policy_engine.py::_evaluate_covenant - Status: Covered
- Tracking: —
- Claim: A current-year covenant FAIL or UNRESOLVABLE is a code-enforced draft rejection.
- Source: Covenants.
-
Implemented in:
scripts/policy_checks.py::check_draft_compliance - Status: Withdrawn
-
Tracking: Split because the named test verified only the UNRESOLVABLE case: successor rules
R-POL-013(FAIL) andR-POL-014(UNRESOLVABLE).
- Claim: A forward-year base-case covenant FAIL or UNRESOLVABLE does not itself produce a code-enforced draft rejection.
- Source: D6.
-
Implemented in:
scripts/policy_checks.py::check_draft_compliance - Status: Covered
- Tracking: —
- Claim: A downside breach is recorded only when its base-case covenant passes and its stressed result is FAIL or UNRESOLVABLE.
- Source: Covenants.
-
Implemented in:
scripts/policy_engine.py::_evaluate_downside_covenants - Status: Covered
- Tracking: —
-
Claim: Each downside breach must be acknowledged by its own
breach_id, otherwise the draft is non-compliant. - Source: The downside case.
-
Implemented in:
scripts/policy_checks.py::check_draft_compliance - Status: Withdrawn
-
Tracking: Split into
R-POL-015(an unacknowledged breach produces a rejection reason) andR-POL-016(acknowledgement is specific to each breach ID).
- Claim: A covenant whose basis differs from the recorded financial view is UNRESOLVABLE.
- Source: D19 .
-
Implemented in:
scripts/policy_engine.py::_evaluate_covenant - Status: Covered
- Tracking: —
- Claim: An unknown metric/type or missing/non-numeric threshold yields UNRESOLVABLE with a reason, not a crash or silent skip.
- Source: N/A and UNRESOLVABLE.
-
Implemented in:
scripts/policy_engine.py::_evaluate_covenant - Status: Withdrawn
-
Tracking: Split into
R-POL-017(unknown metric),R-POL-018(unknown type) andR-POL-019(missing or non-numeric threshold) so each invalidity has its own rule.
- Claim: An actual equal to its threshold passes for both minimum and maximum covenants.
- Source: Covenants.
-
Implemented in:
scripts/policy_engine.py::_evaluate_covenant - Status: Covered
- Tracking: —
- Claim: A zero covenant threshold has no percentage headroom, but PASS or FAIL is still decided by direct comparison.
- Source: Covenants.
-
Implemented in:
scripts/policy_engine.py::_evaluate_covenant - Status: Covered
- Tracking: —
- Claim: A percent-type covenant is UNRESOLVABLE when its recorded actual or threshold has an absolute value greater than 10.
- Source: Percent-type ratios are stored as fractions .
-
Implemented in:
scripts/policy_engine.py::_evaluate_covenant - Status: Covered
- Tracking: —
- Claim: Aggregate collateral cover is N/A when total exposure is zero or negative.
- Source: N/A and UNRESOLVABLE (the “Collateral cover percentage” paragraph).
-
Implemented in:
scripts/policy_checks.py::compute_collateral_cover_pct - Status: Covered
- Tracking: —
- Claim: The deterministic policy check never changes an existing REJECTED verdict to APPROVED.
- Source: Execution scripts.
-
Implemented in:
scripts/orchestrator.py::_apply_deterministic_policy_checks - Status: Covered
- Tracking: —
- Claim: A current-year covenant FAIL produces a code-enforced rejection reason.
- Source: Covenants.
-
Implemented in:
scripts/policy_checks.py::check_draft_compliance - Status: Covered
- Tracking: —
- Claim: A current-year covenant UNRESOLVABLE produces a code-enforced rejection reason.
- Source: Covenants.
-
Implemented in:
scripts/policy_checks.py::check_draft_compliance - Status: Covered
- Tracking: —
- Claim: A downside breach without a matching acknowledgement produces an undisclosed-breach rejection reason.
- Source: Covenants.
-
Implemented in:
scripts/policy_checks.py::check_draft_compliance - Status: Covered
- Tracking: —
-
Claim: Acknowledging one downside
breach_iddoes not acknowledge a second breach with a different ID. - Source: The downside case.
-
Implemented in:
scripts/policy_checks.py::check_draft_compliance - Status: Covered
- Tracking: —
- Claim: An unrecognised covenant metric remains in the results as UNRESOLVABLE.
- Source: N/A and UNRESOLVABLE.
-
Implemented in:
scripts/policy_engine.py::_evaluate_covenant - Status: Covered
- Tracking: —
- Claim: A covenant type other than minimum or maximum is UNRESOLVABLE with a reason.
- Source: N/A and UNRESOLVABLE.
-
Implemented in:
scripts/policy_engine.py::_evaluate_covenant - Status: Covered
- Tracking: —
- Claim: A missing or non-numeric covenant threshold is UNRESOLVABLE with a reason.
- Source: N/A and UNRESOLVABLE.
-
Implemented in:
scripts/policy_engine.py::_evaluate_covenant - Status: Covered
- Tracking: —
- Claim: Aggregate collateral cover is N/A when any asset has a negative or non-finite exposure or collateral value.
- Source: N/A and UNRESOLVABLE (the “Collateral cover percentage” paragraph).
-
Implemented in:
scripts/policy_checks.py::compute_collateral_cover_pct - Status: Covered
- Tracking: —
-
Claim: A
guarantor_groupcovenant uses only the exact named, explicitly guarantee-linked entity's current framework-computed spread; a missing or invalid ID, role, guarantee link or period makes the result UNRESOLVABLE, with no borrower or other-entity fallback. - Source: Guarantor-group covenant routing (case C step C4).
-
Implemented in:
scripts/covenant_basis.py::resolve_covenant_view - Status: Not covered
- Tracking: Issue #473
-
Claim:
write_state()refuses to overwrite a state whoseschema_versionis newer than the framework's supported version. - Source: State manager and state.json.
-
Implemented in:
scripts/state_manager.py::write_state - Status: Covered
- Tracking: —
-
Claim:
append_review_trail()refuses to overwrite a state whoseschema_versionis newer than the framework's supported version. - Source: State manager and state.json.
-
Implemented in:
scripts/state_manager.py::append_review_trail - Status: Covered
- Tracking: —
-
Claim:
write_state()refuses to overwrite a state whoseschema_versionis not a validMAJOR.MINOR.PATCHstring. - Source: State manager and state.json.
-
Implemented in:
scripts/state_manager.py::write_state - Status: Covered
- Tracking: —
-
Claim:
append_review_trail()refuses to overwrite a state whoseschema_versionis not a validMAJOR.MINOR.PATCHstring. - Source: State manager and state.json.
-
Implemented in:
scripts/state_manager.py::append_review_trail - Status: Covered
- Tracking: —
-
Claim: An otherwise permitted
write_state()preserves each pre-existing unknown top-level field unless the caller supplies that field in the update. - Source: State manager and state.json.
-
Implemented in:
scripts/state_manager.py::_merge_and_write - Status: Not covered
- Tracking: Issue #530
-
Claim: On a permitted
write_state()call that omitsschema_versionfrom its supplied fields, the resulting state records the currentSCHEMA_VERSION. - Source: State manager and state.json.
-
Implemented in:
scripts/state_manager.py::_merge_and_write - Status: Not covered
- Tracking: Issue #530
- Claim: Framework-computed ratios are independently recomputed from the period's raw line items.
- Source: Context Window & State Management Protocol.
-
Implemented in:
scripts/spreading_builder.py::evaluate_financial_model - Status: Covered
- Tracking: —
- Claim: A spreading update for a new period preserves the other periods already recorded in the deal.
- Source: Execution scripts.
-
Implemented in:
scripts/spreading_check.py::plan_fields - Status: Covered
- Tracking: —
- Claim: A partial correction to a recorded period merges the supplied raw fields with that period's existing raw fields.
- Source: Execution scripts.
-
Implemented in:
scripts/spreading_check.py::plan_fields - Status: Covered
- Tracking: —
-
Claim: A forward-only
/projectupdate does not change an analyst-supplied deal'sfinancials_sourcetoframework-computed. - Source: Execution scripts.
-
Implemented in:
scripts/spreading_check.py::plan_fields - Status: Covered
- Tracking: —
- Claim: A forward forecast marked analyst-supplied is recorded without recomputing its supplied figures through the framework formulas.
- Source: state.json at a glance.
-
Implemented in:
scripts/supplied_forecast.py::record - Status: Covered
- Tracking: —
- Claim: A framework-computed ratio with a zero or negative denominator is N/A.
- Source: N/A and UNRESOLVABLE.
-
Implemented in:
scripts/spreading_builder.py::evaluate_financial_model - Status: Not covered
- Tracking: Issue #530 (test citation and verification).
-
Claim:
spreading_checkrefuses historical raw-period input on an analyst-supplied deal even whenupdate_financials_sourceis false. - Source: Analyst-supplied figures.
-
Implemented in:
scripts/spreading_check.py::plan_fields - Status: Not covered
- Tracking: Issue #530 (test citation and verification).
-
Claim: An incoming raw line item whose name is not one of the framework's field names is refused
before anything is written, with one error naming the period, the key and the nearest valid name; an
unknown name already on file is warned about and still computed. A new guarantor entity record is refused
the same way at registration (
state_manager.record_entity_record), and a stored one is warned about when it is spread (spreading_check.compute_entity). - Source: Raw line-item names.
-
Implemented in:
scripts/numeric_validation.py::refuse_unknown_raw_line_items - Status: Covered
- Tracking: —
-
Claim: For historical periods, the workbook exporter selects raw figures from
analyst_supplied_financialswhenfinancials_sourceisanalyst-supplied, and fromfinancials[period]["raw"]otherwise. - Source: Two raw-figure stores, never blended within a period.
-
Implemented in:
scripts/deal_export.py::_financial_data_from_state - Status: Covered
- Tracking: —
-
Claim: For forward periods, the workbook exporter selects raw figures from
analyst_supplied_financialswhenforecast_sourceisanalyst-supplied, and fromfinancials[period]["raw"]otherwise. - Source: Two raw-figure stores, never blended within a period.
-
Implemented in:
scripts/deal_export.py::_financial_data_from_state - Status: Covered
- Tracking: —
- Claim: The workbook exporter does not fall back to the other raw-figure store when the selected store has no record for a period.
- Source: Two raw-figure stores, never blended within a period.
-
Implemented in:
scripts/deal_export.py::_financial_data_from_state - Status: Covered
- Tracking: —
- Claim: The workbook exporter never combines raw fields from both raw-figure stores within one period.
- Source: Two raw-figure stores, never blended within a period.
-
Implemented in:
scripts/deal_export.py::_financial_data_from_state - Status: Covered
- Tracking: —
-
Claim:
export_deal()reads and validates deal state before creating the output folder or auto-saving a template. - Source: Execution scripts.
-
Implemented in:
scripts/deal_export.py::export_deal - Status: Covered
- Tracking: —
-
Claim:
docx_builderomits fenced code blocks taggedjsonfrom the exported DOCX. - Source: Context Window & State Management Protocol.
-
Implemented in:
scripts/docx_builder.py::export_to_docx - Status: Covered
- Tracking: —
-
Claim:
export_deal()writes an auto-saved CAM template undertemplates/local/cam/, never under the shippedtemplates/cam/. - Source: Confidentiality rule for new features.
-
Implemented in:
scripts/deal_export.py::export_deal - Status: Not covered
- Tracking: Issue #530 (test citation and verification).
-
Claim: An unterminated HTML comment outside a closed fenced code block causes
docx_builderto refuse DOCX export. - Source: Calibrated overrides.
-
Implemented in:
scripts/docx_builder.py::_strip_html_comments - Status: Not covered
- Tracking: Issue #530 (test citation and verification).
This page is generated from
docs/README.mdin the repository --docs/is the canonical documentation. Direct wiki edits here are overwritten on the next publish; make changes indocs/by pull request.
- Home
- Architecture
- Workflows
- Slash command reference
- Collateral analysis
- Skills
- Skill design
- Financial model and policy engine
- Formula register
- Rules register
- Shared glossary
- Data model
- CLI reference
- Outputs and templates
- Configuration
- Testing and CI
- Security and confidentiality
- AI assurance
- Evaluation harness
- Contributing
- Agent ledger
- Operations runbook
- Troubleshooting
- Design decisions
- OpenCAM MVP v1 — product requirements document (reconstructed)
- Move ledger
Examples