← back to invincible-jha__aumai-sovereignstack

Function bodies 16 total

All specs Real LLM only Function bodies
deploy_command function · python · L36-L70 (35 LOC)
src/aumai_sovereignstack/cli.py
def deploy_command(config_path: str) -> None:
    """Generate a compliance report for a deployment config.

    Example: aumai-sovereignstack deploy --config deploy.json
    """
    raw_text = Path(config_path).read_text(encoding="utf-8")
    try:
        data: object = json.loads(raw_text)
    except json.JSONDecodeError as exc:
        click.echo(f"Invalid JSON: {exc}", err=True)
        sys.exit(1)

    if not isinstance(data, dict):
        click.echo("Config must be a JSON object.", err=True)
        sys.exit(1)

    try:
        config = DeploymentConfig.model_validate(data)
    except Exception as exc:
        click.echo(f"Validation error: {exc}", err=True)
        sys.exit(1)

    report = _deployer.generate_report(config)
    status_label = "PASS" if report.all_compliant else "FAIL"
    click.echo(f"Deployment: {config.name}  [{status_label}]")
    click.echo(f"Region: {config.region.name} ({config.region.country_code})")
    click.echo(f"Total checks: {len(report.compliance_
compliance_command function · python · L81-L108 (28 LOC)
src/aumai_sovereignstack/cli.py
def compliance_command(config_path: str) -> None:
    """Run compliance checks and print results as JSON.

    Example: aumai-sovereignstack compliance --config deploy.json
    """
    raw_text = Path(config_path).read_text(encoding="utf-8")
    try:
        data: object = json.loads(raw_text)
    except json.JSONDecodeError as exc:
        click.echo(f"Invalid JSON: {exc}", err=True)
        sys.exit(1)

    if not isinstance(data, dict):
        click.echo("Config must be a JSON object.", err=True)
        sys.exit(1)

    try:
        config = DeploymentConfig.model_validate(data)
    except Exception as exc:
        click.echo(f"Validation error: {exc}", err=True)
        sys.exit(1)

    checks = _deployer.validate_compliance(config)
    output = [check.model_dump(mode="json") for check in checks]
    click.echo(json.dumps(output, indent=2))

    if not all(check.passed for check in checks):
        sys.exit(1)
regions_command function · python · L114-L139 (26 LOC)
src/aumai_sovereignstack/cli.py
def regions_command(list_all: bool, country: str | None) -> None:
    """List available sovereign regions or look up a specific one.

    Example: aumai-sovereignstack regions --list
    """
    if country:
        try:
            region = _registry.get_region(country)
        except RegionNotFoundError as exc:
            click.echo(str(exc), err=True)
            sys.exit(1)
        click.echo(json.dumps(region.model_dump(mode="json"), indent=2))
        return

    if list_all:
        for region in _registry.list_regions():
            residency_label = "data-residency-required" if region.data_residency_required else "no-residency-req"
            click.echo(
                f"[{region.country_code}] {region.name}"
                f"  ({residency_label})"
            )
            if region.compliance_frameworks:
                click.echo(f"  Frameworks: {', '.join(region.compliance_frameworks)}")
        return

    click.echo("Specify --list to list all regions or --country COD
RegionRegistry.register_region method · python · L72-L78 (7 LOC)
src/aumai_sovereignstack/core.py
    def register_region(self, region: SovereignRegion) -> None:
        """Add or overwrite a region entry.

        Args:
            region: The region to register.
        """
        self._regions[region.country_code.upper()] = region
RegionRegistry.get_region method · python · L80-L97 (18 LOC)
src/aumai_sovereignstack/core.py
    def get_region(self, country_code: str) -> SovereignRegion:
        """Look up a region by its ISO country code.

        Args:
            country_code: ISO 3166-1 alpha-2 code (e.g. ``"IN"``, ``"DE"``).

        Returns:
            The matching ``SovereignRegion``.

        Raises:
            RegionNotFoundError: If the code is not registered.
        """
        try:
            return self._regions[country_code.upper()]
        except KeyError:
            raise RegionNotFoundError(
                f"No region registered for country code '{country_code}'."
            ) from None
RegionRegistry.list_regions method · python · L99-L105 (7 LOC)
src/aumai_sovereignstack/core.py
    def list_regions(self) -> list[SovereignRegion]:
        """Return all registered regions sorted by region_id.

        Returns:
            List of all ``SovereignRegion`` objects.
        """
        return sorted(self._regions.values(), key=lambda r: r.region_id)
SovereignDeployer.create_config method · python · L111-L137 (27 LOC)
src/aumai_sovereignstack/core.py
    def create_config(
        self,
        name: str,
        region: SovereignRegion,
        infrastructure: dict[str, object] | None = None,
        model_configs: list[dict[str, object]] | None = None,
        data_policies: dict[str, object] | None = None,
    ) -> DeploymentConfig:
        """Build a new deployment configuration for the specified region.

        Args:
            name: Deployment name.
            region: Target sovereign region.
            infrastructure: Optional infrastructure descriptor.
            model_configs: Optional per-model configurations.
            data_policies: Optional data handling policies.

        Returns:
            A populated ``DeploymentConfig``.
        """
        return DeploymentConfig(
            name=name,
            region=region,
            infrastructure=infrastructure or {},
            model_configs=model_configs or [],
            data_policies=data_policies or {},
        )
Open data scored by Repobility · https://repobility.com
SovereignDeployer.validate_compliance method · python · L139-L152 (14 LOC)
src/aumai_sovereignstack/core.py
    def validate_compliance(self, config: DeploymentConfig) -> list[ComplianceCheck]:
        """Run all applicable compliance checks for a deployment config.

        Args:
            config: The deployment configuration to evaluate.

        Returns:
            List of ``ComplianceCheck`` results.
        """
        checks: list[ComplianceCheck] = []
        checks.append(self.check_data_residency(config))
        for framework in config.region.compliance_frameworks:
            checks.extend(self._checks_for_framework(config, framework))
        return checks
SovereignDeployer.check_data_residency method · python · L154-L189 (36 LOC)
src/aumai_sovereignstack/core.py
    def check_data_residency(self, config: DeploymentConfig) -> ComplianceCheck:
        """Verify that the deployment satisfies data residency requirements.

        If the region requires data residency, ``data_policies`` must contain
        ``"data_residency": true``.

        Args:
            config: The deployment config to inspect.

        Returns:
            A ``ComplianceCheck`` indicating pass or fail.
        """
        framework = "Data Residency"
        if not config.region.data_residency_required:
            return ComplianceCheck(
                check_name="data_residency_not_required",
                passed=True,
                details=f"Region '{config.region.name}' does not mandate data residency.",
                framework=framework,
            )

        policy_value = config.data_policies.get("data_residency")
        passed = policy_value is True
        return ComplianceCheck(
            check_name="data_residency_enforced",
            passed=passed,
SovereignDeployer.generate_report method · python · L191-L206 (16 LOC)
src/aumai_sovereignstack/core.py
    def generate_report(self, config: DeploymentConfig) -> DeploymentReport:
        """Generate a full compliance report for the given deployment config.

        Args:
            config: The deployment configuration to evaluate.

        Returns:
            A ``DeploymentReport`` summarising all checks.
        """
        compliance_results = self.validate_compliance(config)
        all_compliant = all(check.passed for check in compliance_results)
        return DeploymentReport(
            config=config,
            compliance_results=compliance_results,
            all_compliant=all_compliant,
        )
SovereignDeployer._checks_for_framework method · python · L212-L235 (24 LOC)
src/aumai_sovereignstack/core.py
    def _checks_for_framework(
        self, config: DeploymentConfig, framework: str
    ) -> list[ComplianceCheck]:
        upper_framework = framework.upper()

        if "GDPR" in upper_framework:
            return self._gdpr_checks(config, framework)
        if "DPDP" in upper_framework:
            return self._dpdp_checks(config, framework)
        if "HIPAA" in upper_framework:
            return self._hipaa_checks(config, framework)
        if "PDPA" in upper_framework:
            return self._pdpa_checks(config, framework)
        if "UAE PDPL" in upper_framework or "TDRA" in upper_framework:
            return self._uae_checks(config, framework)

        return [
            ComplianceCheck(
                check_name=f"{framework.lower().replace(' ', '_')}_acknowledged",
                passed=True,
                details=f"Framework '{framework}' noted; no automated checks configured.",
                framework=framework,
            )
        ]
SovereignDeployer._gdpr_checks method · python · L237-L263 (27 LOC)
src/aumai_sovereignstack/core.py
    def _gdpr_checks(
        self, config: DeploymentConfig, framework: str
    ) -> list[ComplianceCheck]:
        has_dpa = bool(config.data_policies.get("data_protection_officer"))
        has_lawful_basis = bool(config.data_policies.get("lawful_basis"))
        return [
            ComplianceCheck(
                check_name="gdpr_dpo_designated",
                passed=has_dpa,
                details=(
                    "Data Protection Officer is designated."
                    if has_dpa
                    else "data_policies['data_protection_officer'] must be set for GDPR."
                ),
                framework=framework,
            ),
            ComplianceCheck(
                check_name="gdpr_lawful_basis_defined",
                passed=has_lawful_basis,
                details=(
                    "Lawful basis for processing is defined."
                    if has_lawful_basis
                    else "data_policies['lawful_basis'] must be set for GDPR."
 
SovereignDeployer._dpdp_checks method · python · L265-L291 (27 LOC)
src/aumai_sovereignstack/core.py
    def _dpdp_checks(
        self, config: DeploymentConfig, framework: str
    ) -> list[ComplianceCheck]:
        has_consent = bool(config.data_policies.get("consent_mechanism"))
        is_india_region = config.region.country_code.upper() == "IN"
        return [
            ComplianceCheck(
                check_name="dpdp_consent_mechanism",
                passed=has_consent,
                details=(
                    "Consent mechanism is configured."
                    if has_consent
                    else "data_policies['consent_mechanism'] required by DPDP Act."
                ),
                framework=framework,
            ),
            ComplianceCheck(
                check_name="dpdp_data_fiduciary_in_india",
                passed=is_india_region,
                details=(
                    "Deployment is in India — data fiduciary obligations apply."
                    if is_india_region
                    else "DPDP Act applies only to India-region depl
SovereignDeployer._hipaa_checks method · python · L293-L308 (16 LOC)
src/aumai_sovereignstack/core.py
    def _hipaa_checks(
        self, config: DeploymentConfig, framework: str
    ) -> list[ComplianceCheck]:
        has_phi_controls = bool(config.data_policies.get("phi_access_controls"))
        return [
            ComplianceCheck(
                check_name="hipaa_phi_access_controls",
                passed=has_phi_controls,
                details=(
                    "PHI access controls are configured."
                    if has_phi_controls
                    else "data_policies['phi_access_controls'] required for HIPAA."
                ),
                framework=framework,
            )
        ]
SovereignDeployer._pdpa_checks method · python · L310-L325 (16 LOC)
src/aumai_sovereignstack/core.py
    def _pdpa_checks(
        self, config: DeploymentConfig, framework: str
    ) -> list[ComplianceCheck]:
        has_purpose_limitation = bool(config.data_policies.get("purpose_limitation"))
        return [
            ComplianceCheck(
                check_name="pdpa_purpose_limitation",
                passed=has_purpose_limitation,
                details=(
                    "Purpose limitation policy is defined."
                    if has_purpose_limitation
                    else "data_policies['purpose_limitation'] required for PDPA."
                ),
                framework=framework,
            )
        ]
Powered by Repobility — scan your code at https://repobility.com
SovereignDeployer._uae_checks method · python · L327-L347 (21 LOC)
src/aumai_sovereignstack/core.py
    def _uae_checks(
        self, config: DeploymentConfig, framework: str
    ) -> list[ComplianceCheck]:
        has_cross_border = bool(
            config.data_policies.get("cross_border_transfer_controls")
        )
        return [
            ComplianceCheck(
                check_name="uae_cross_border_transfer_controls",
                passed=has_cross_border,
                details=(
                    "Cross-border transfer controls are in place."
                    if has_cross_border
                    else (
                        "data_policies['cross_border_transfer_controls'] required"
                        " for UAE PDPL / TDRA."
                    )
                ),
                framework=framework,
            )
        ]