Expose decision filing and search sources
This commit is contained in:
@@ -3,12 +3,31 @@ from __future__ import annotations
|
||||
from pathlib import Path
|
||||
|
||||
from govoplan_core.core.institutional import CAPABILITY_DECISION_REGISTRY
|
||||
from govoplan_core.core.module_guards import drop_table_retirement_provider, persistent_table_uninstall_guard
|
||||
from govoplan_core.core.modules import CapabilityDocumentation, DocumentationLink, DocumentationTopic, MigrationSpec, ModuleContext, ModuleInterfaceProvider, ModuleManifest, PermissionDefinition, RoleTemplate
|
||||
from govoplan_core.core.module_guards import (
|
||||
drop_table_retirement_provider,
|
||||
persistent_table_uninstall_guard,
|
||||
)
|
||||
from govoplan_core.core.modules import (
|
||||
CapabilityDocumentation,
|
||||
DocumentationLink,
|
||||
DocumentationTopic,
|
||||
MigrationSpec,
|
||||
ModuleContext,
|
||||
ModuleInterfaceProvider,
|
||||
ModuleManifest,
|
||||
PermissionDefinition,
|
||||
RoleTemplate,
|
||||
)
|
||||
from govoplan_core.core.provider_governance import declared_module_architecture
|
||||
from govoplan_core.core.search import SearchSourceProviderRegistration
|
||||
from govoplan_core.db.base import Base
|
||||
from govoplan_decisions.backend.db import models as decision_models
|
||||
from govoplan_decisions.backend.record_source import (
|
||||
CAPABILITY_RECORD_SOURCE_DECISIONS,
|
||||
create_decisions_record_source,
|
||||
)
|
||||
from govoplan_decisions.backend.service import SqlDecisionRegistry
|
||||
from govoplan_decisions.backend.search_source import create_decisions_search_source
|
||||
|
||||
|
||||
MODULE_ID = "decisions"
|
||||
@@ -22,7 +41,16 @@ ADMIN_SCOPE = "decisions:decision:admin"
|
||||
|
||||
def _permission(scope: str, label: str, description: str) -> PermissionDefinition:
|
||||
module_id, resource, action = scope.split(":", 2)
|
||||
return PermissionDefinition(scope=scope, label=label, description=description, category="Decisions", level="tenant", module_id=module_id, resource=resource, action=action)
|
||||
return PermissionDefinition(
|
||||
scope=scope,
|
||||
label=label,
|
||||
description=description,
|
||||
category="Decisions",
|
||||
level="tenant",
|
||||
module_id=module_id,
|
||||
resource=resource,
|
||||
action=action,
|
||||
)
|
||||
|
||||
|
||||
def _router(_context: ModuleContext):
|
||||
@@ -39,40 +67,121 @@ manifest = ModuleManifest(
|
||||
id=MODULE_ID,
|
||||
name=MODULE_NAME,
|
||||
version=MODULE_VERSION,
|
||||
optional_dependencies=("mandates", "approvals", "committee", "cases", "audit", "policy", "records", "files", "postbox", "mail"),
|
||||
provides_interfaces=(ModuleInterfaceProvider(name="decisions.formal_outcome", version="0.1.0"), ModuleInterfaceProvider(name="decisions.reconstruction", version="0.1.0")),
|
||||
optional_dependencies=(
|
||||
"mandates",
|
||||
"approvals",
|
||||
"committee",
|
||||
"cases",
|
||||
"audit",
|
||||
"policy",
|
||||
"records",
|
||||
"files",
|
||||
"postbox",
|
||||
"mail",
|
||||
),
|
||||
provides_interfaces=(
|
||||
ModuleInterfaceProvider(name="decisions.formal_outcome", version="0.1.0"),
|
||||
ModuleInterfaceProvider(name="decisions.reconstruction", version="0.1.0"),
|
||||
ModuleInterfaceProvider(
|
||||
name=CAPABILITY_RECORD_SOURCE_DECISIONS, version="1.0.0"
|
||||
),
|
||||
),
|
||||
permissions=(
|
||||
_permission(READ_SCOPE, "View Decision metadata", "View formal Decision metadata and evidence references."),
|
||||
_permission(SENSITIVE_READ_SCOPE, "View protected Decisions", "View protected reasoning, operative results, and conditions."),
|
||||
_permission(WRITE_SCOPE, "Record Decisions", "Record governed formal outcomes and lifecycle revisions."),
|
||||
_permission(ADMIN_SCOPE, "Administer Decisions", "Administer Decision access, lifecycle, and recovery."),
|
||||
_permission(
|
||||
READ_SCOPE,
|
||||
"View Decision metadata",
|
||||
"View formal Decision metadata and evidence references.",
|
||||
),
|
||||
_permission(
|
||||
SENSITIVE_READ_SCOPE,
|
||||
"View protected Decisions",
|
||||
"View protected reasoning, operative results, and conditions.",
|
||||
),
|
||||
_permission(
|
||||
WRITE_SCOPE,
|
||||
"Record Decisions",
|
||||
"Record governed formal outcomes and lifecycle revisions.",
|
||||
),
|
||||
_permission(
|
||||
ADMIN_SCOPE,
|
||||
"Administer Decisions",
|
||||
"Administer Decision access, lifecycle, and recovery.",
|
||||
),
|
||||
),
|
||||
role_templates=(
|
||||
RoleTemplate(slug="decision_officer", name="Decision officer", description="Record and inspect formal Decisions.", permissions=(READ_SCOPE, SENSITIVE_READ_SCOPE, WRITE_SCOPE)),
|
||||
RoleTemplate(slug="decision_auditor", name="Decision auditor", description="Reconstruct protected formal outcomes.", permissions=(READ_SCOPE, SENSITIVE_READ_SCOPE)),
|
||||
RoleTemplate(
|
||||
slug="decision_officer",
|
||||
name="Decision officer",
|
||||
description="Record and inspect formal Decisions.",
|
||||
permissions=(READ_SCOPE, SENSITIVE_READ_SCOPE, WRITE_SCOPE),
|
||||
),
|
||||
RoleTemplate(
|
||||
slug="decision_auditor",
|
||||
name="Decision auditor",
|
||||
description="Reconstruct protected formal outcomes.",
|
||||
permissions=(READ_SCOPE, SENSITIVE_READ_SCOPE),
|
||||
),
|
||||
),
|
||||
route_factory=_router,
|
||||
capability_factories={CAPABILITY_DECISION_REGISTRY: _registry},
|
||||
capability_documentation={CAPABILITY_DECISION_REGISTRY: CapabilityDocumentation(label="Formal Decision registry", summary="Records and resolves immutable, reconstructable formal outcomes.", contract_version="0.1.0")},
|
||||
capability_factories={
|
||||
CAPABILITY_DECISION_REGISTRY: _registry,
|
||||
CAPABILITY_RECORD_SOURCE_DECISIONS: create_decisions_record_source,
|
||||
},
|
||||
capability_documentation={
|
||||
CAPABILITY_DECISION_REGISTRY: CapabilityDocumentation(
|
||||
label="Formal Decision registry",
|
||||
summary="Records and resolves immutable, reconstructable formal outcomes.",
|
||||
contract_version="0.1.0",
|
||||
),
|
||||
CAPABILITY_RECORD_SOURCE_DECISIONS: CapabilityDocumentation(
|
||||
label="Formal Decision record source",
|
||||
summary="Resolves complete, currently authorized immutable Decision revisions for Records filing.",
|
||||
contract_version="1.0.0",
|
||||
),
|
||||
},
|
||||
migration_spec=MigrationSpec(
|
||||
module_id=MODULE_ID,
|
||||
metadata=Base.metadata,
|
||||
script_location=str(Path(__file__).with_name("migrations") / "versions"),
|
||||
retirement_supported=True,
|
||||
retirement_provider=drop_table_retirement_provider(decision_models.FormalDecisionRevision, label="Decisions"),
|
||||
retirement_provider=drop_table_retirement_provider(
|
||||
decision_models.FormalDecisionRevision, label="Decisions"
|
||||
),
|
||||
retirement_notes="Destructive retirement requires a database snapshot and removes formal Decision history.",
|
||||
),
|
||||
uninstall_guard_providers=(persistent_table_uninstall_guard(decision_models.FormalDecisionRevision, label="Decisions"),),
|
||||
uninstall_guard_providers=(
|
||||
persistent_table_uninstall_guard(
|
||||
decision_models.FormalDecisionRevision, label="Decisions"
|
||||
),
|
||||
),
|
||||
search_sources=(
|
||||
SearchSourceProviderRegistration(
|
||||
id="decisions.decisions",
|
||||
factory=create_decisions_search_source,
|
||||
),
|
||||
),
|
||||
documentation=(
|
||||
DocumentationTopic(
|
||||
id="decisions.formal-outcome",
|
||||
title="Formal institutional Decisions",
|
||||
summary="Reconstruct authority, evidence, reasoning, outcome, effects, and review history.",
|
||||
body="Decisions preserves immutable formal outcomes. Corrections and revocations create linked revisions; requested and observed effects remain distinct for reconciliation. List and unversioned detail reads follow the titlebar valid-time and recorded-time selection; exact revision references remain exact and current authorization is unchanged.",
|
||||
body="Decisions preserves immutable formal outcomes. Corrections and revocations create linked revisions; requested and observed effects remain distinct for reconciliation. List and unversioned detail reads follow the titlebar valid-time and recorded-time selection; exact revision references remain exact and current authorization is unchanged. When Records is enabled, filing resolves one exact complete Decision revision only after current metadata and protected-read permissions are rechecked; Records retains the digest-bound source reference while Decisions remains authoritative. When Search is enabled, Decisions contributes only rebuildable lifecycle, subject, legal-basis, effect, and linked-Case metadata. Operative results, reasoning, and conditions are excluded, and every result receives a current permission check before disclosure.",
|
||||
layer="configured",
|
||||
documentation_types=("admin", "user"),
|
||||
audience=("user", "operator", "module_admin", "auditor"),
|
||||
links=(DocumentationLink(label="Decisions domain and recovery", href="govoplan-decisions/docs/DECISIONS_DOMAIN.md", kind="repository"),),
|
||||
links=(
|
||||
DocumentationLink(
|
||||
label="Decisions domain and recovery",
|
||||
href="govoplan-decisions/docs/DECISIONS_DOMAIN.md",
|
||||
kind="repository",
|
||||
),
|
||||
),
|
||||
metadata={
|
||||
"help_contexts": [
|
||||
"decisions.search.result",
|
||||
"decisions.record.filing",
|
||||
],
|
||||
},
|
||||
),
|
||||
),
|
||||
architecture=declared_module_architecture(
|
||||
@@ -81,10 +190,21 @@ manifest = ModuleManifest(
|
||||
maturity="vertical_slice",
|
||||
documentation_ref="docs/DECISIONS_DOMAIN.md",
|
||||
test_ref="tests/test_decisions.py",
|
||||
known_limits=("No dedicated Decision WebUI is included; consuming procedure modules present outcomes in context.",),
|
||||
known_limits=(
|
||||
"No dedicated Decision WebUI is included; consuming procedure modules present outcomes in context.",
|
||||
),
|
||||
supported_authority_modes=("native_authoritative",),
|
||||
owned_concepts=("formal decision", "decision correction", "decision effect observation"),
|
||||
non_owned_concepts=("approval gate", "committee deliberation", "effect execution", "record binary"),
|
||||
owned_concepts=(
|
||||
"formal decision",
|
||||
"decision correction",
|
||||
"decision effect observation",
|
||||
),
|
||||
non_owned_concepts=(
|
||||
"approval gate",
|
||||
"committee deliberation",
|
||||
"effect execution",
|
||||
"record binary",
|
||||
),
|
||||
reference_packages=("product.service-to-decision",),
|
||||
migration_docs=("docs/DECISIONS_DOMAIN.md",),
|
||||
recovery_docs=("docs/DECISIONS_DOMAIN.md",),
|
||||
|
||||
Reference in New Issue
Block a user