69 lines
1.9 KiB
Python
Raw Normal View History

Converge every account onto every policy agreement it has not declined An instance kept production-identical for extended manual testing is otherwise taxed forever by its own safety controls: five consents, a versioned terms gate on every mutating request, and every account predating the trust and safety commit reading terms_version NULL because init_db deliberately never backfills it. AcceptanceService grants each agreement to each account that has not declined it, so the instance stays production byte for byte while nobody clicks the same dialog again. It is opt-in, dry run by default, and one switch per agreement type. The application is not allowed to know it exists. One registration line in main.py is the only import anywhere, there is no route, schema, template, Devii tool or environment flag, and a unit test greps the tree and fails the suite if a second importer appears. The decline register needs no storage: the ledger is append-only in effect, the service only ever grants, so any withdrawn row was written by a human and that pair is never touched again. No provenance column, nothing to observe. Satisfaction is the gate's own expression, never a proxy, which is why the ordering is created_at then id exactly as consent_state selects, and why the live-account clauses are built with has_column: init_db ensures terms_version and deletion_requested_at but not is_active, so a hardcoded reference raises no such column on an instance where nobody was ever suspended. Every write is one conditional statement decided on the real rowcount, proven with sixteen processes racing one account to exactly one ledger row and one audit row. The two existing audit keys carry it, with actor kind service, because a service that silently mutated consent state would be the worst possible exception to the append-only rule. lensfl.md is the source brief accept.md records the design against. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-10 00:17:47 +02:00
# retoor <retoor@molodetz.nl>
from pathlib import Path
PACKAGE_ROOT = Path(__file__).resolve().parents[4] / "devplacepy"
PACKAGE_DIR = PACKAGE_ROOT / "services" / "acceptance"
NEEDLES = (
"services.acceptance",
"devplacepy/services/acceptance",
"AcceptanceService",
)
def source_files(suffixes):
return [
path
for path in PACKAGE_ROOT.rglob("*")
if path.suffix in suffixes
and path.is_file()
and PACKAGE_DIR not in path.parents
and "__pycache__" not in path.parts
]
def references(path):
body = path.read_text()
return any(needle in body for needle in NEEDLES)
def test_only_main_imports_the_acceptance_package():
importers = [
path.relative_to(PACKAGE_ROOT).as_posix()
for path in source_files({".py"})
if references(path)
]
assert importers == ["main.py"]
def test_no_template_or_static_asset_mentions_the_package():
mentions = [
path.relative_to(PACKAGE_ROOT).as_posix()
for path in source_files({".html", ".js", ".css"})
if references(path)
]
assert mentions == []
def test_the_feature_has_no_route_schema_or_agent_tool():
watched = ("routers", "schemas", "docs_api")
surfaced = [
path.relative_to(PACKAGE_ROOT).as_posix()
for path in source_files({".py"})
if path.parts[len(PACKAGE_ROOT.parts)] in watched and references(path)
]
assert surfaced == []
def test_the_devii_catalog_does_not_expose_the_service():
catalog = PACKAGE_ROOT / "services" / "devii" / "actions"
mentions = [path.name for path in catalog.rglob("*.py") if references(path)]
assert mentions == []
def test_the_package_imports_no_router_and_no_template_global():
for path in PACKAGE_DIR.glob("*.py"):
body = path.read_text()
assert "devplacepy.routers" not in body
assert "devplacepy.templating" not in body