docs: clarify draft ownership and cancel recovery (PR16 review71)
This commit is contained in:
@@ -135,3 +135,44 @@ def test_legacy_metadata_field_lists_are_required_retained_fields_not_exhaustive
|
||||
assert re.search(r"required top-level metadata fields", legacy, re.I)
|
||||
assert re.search(r"not (?:an )?exhaustive", legacy, re.I)
|
||||
assert "additive settlement-draft finalize response" in legacy
|
||||
|
||||
|
||||
def test_settlement_draft_project_ownership_and_shared_policy_wiring() -> None:
|
||||
doc = text("docs/project-structure.md")
|
||||
required_rows = {
|
||||
"jarca_ledger_mcp/service.py": "public re-export",
|
||||
"jarca_ledger_mcp/adapters/mcp/tool_contracts.py": "inputSchema",
|
||||
"jarca_ledger_mcp/adapters/streamlit/settlement_gateway.py": "auth-before-DB",
|
||||
"dashboard/page_views/settlement_drafts.py": "render_settlement_drafts",
|
||||
"dashboard/page_views/monthly_settlement.py": "page_monthly_settlement",
|
||||
"dashboard/page_views/assets.py": "page_assets",
|
||||
"jarca_ledger_mcp/application/account_valuation_service.py": "register_account_valuation",
|
||||
"jarca_ledger_mcp/infrastructure/sqlite/schema.py": "schema 13",
|
||||
}
|
||||
for path, responsibility in required_rows.items():
|
||||
rows = [row for row in doc.splitlines() if row.startswith("|") and f"`{path}`" in row]
|
||||
assert rows and any(responsibility in row for row in rows), (path, responsibility)
|
||||
assert (ROOT / path).is_file(), path
|
||||
section = doc.split("### Shared settlement-draft policies", 1)[1]
|
||||
for clause in ("one active draft per month", "idx_settlement_drafts_active_month", "WHERE status='active'",
|
||||
"settlement_draft_service.py", "month-end", "unverified", "authority amount NULL",
|
||||
"confirmed child", "explicit reselection", "review", "approval",
|
||||
"tests/test_settlement_draft_adapters.py", "tests/test_monthly_settlement_drafts.py"):
|
||||
assert clause in section, clause
|
||||
|
||||
|
||||
def test_settlement_draft_runtime_cancel_and_recovery_contract() -> None:
|
||||
doc = text("docs/runtime-flow.md")
|
||||
assert "### Cancellation and reopening" in doc, "cancel/reopen lifecycle must be documented"
|
||||
section = doc.split("### Cancellation and reopening", 1)[1]
|
||||
for clause in ("cancel_settlement_draft(draft_id, expected_version, cancelled_by, reason, db_path=None)",
|
||||
"active", "nonempty", "cancelled_by", "cancellation_reason", "cancelled_at",
|
||||
"approval_fingerprint", "approval_version", "version", "updated_at", "BEGIN IMMEDIATE",
|
||||
"retained", "account_valuations", "asset_snapshot_runs", "asset_snapshots",
|
||||
"rollback", "no-write", "completed", "cancelled", "fresh create key",
|
||||
"same create key", "latest prior run", "correction_of_run_id", "correction_reason",
|
||||
"tests/test_settlement_draft_correction_contract.py"):
|
||||
assert clause in section, clause
|
||||
source = ast.parse(text("jarca_ledger_mcp/application/settlement_draft_service.py"))
|
||||
cancel = next(n for n in source.body if isinstance(n, ast.FunctionDef) and n.name == "cancel_settlement_draft")
|
||||
assert [arg.arg for arg in cancel.args.args] == ["draft_id", "expected_version", "cancelled_by", "reason", "db_path"]
|
||||
|
||||
Reference in New Issue
Block a user