Skip to content

feat: carry the project identifier from the client to the IaC service - #572

Open
viodid wants to merge 1 commit into
developfrom
feature/manifest-project-identifier
Open

viodid wants to merge 1 commit into
developfrom
feature/manifest-project-identifier

Conversation

@viodid

@viodid viodid commented Nov 25, 2026

Copy link
Copy Markdown
Member

Summary

A repository can be named by a project identifier (e.g. sistemas-kumoss-rsg-esc1-dev) that the mapping service resolves to its URL. An IaC service implementation may pick the credentials a command runs with by that identifier, so it now travels from the client to every IaC call of the session.

  • Client → core: POST /v1/repository/parse echoes the input as project_identifier. The web wizard sends it back on the session's first call.
  • First call: the new project_identifier field is dropped when it equals repo_uri and rejected if it embeds a password. Before any session is created it must resolve to repo_uri through the mapping service (422 otherwise), so a client cannot pair a project with an arbitrary repository.
  • Session: stored on the session's workspace (migration 0003) and in the cached context (key bumped to ctx:v5), so iteration and apply calls carry it too.
  • Manifest: kumoss.yaml records it, and sync saves when only the identifier changed. The reader's flexible layout is now documented and tested: version and fingerprint are required, and unknown keys are ignored on read and dropped on save.
  • Core → IaC: Terraform sends it as the Kumoss-Project header on every IaC call, through one client builder. IaC contract 2.1.0 documents the optional header. The reference service ignores it.
  • Rename: the Terraform state digest project_id becomes state_id (TerraformUtils, TerraformBackend, TerraformFactory, docs), so it isn't confused with the new project_identifier.

Checklist

Additional context

  • Not included: the authz service does not receive the identifier yet. That would be an additive project_identifier in AuthZEN resource.properties (authz contract 2.1.0) plus a keyword on authorize/authorize_providers.
  • Core tests (Docker, with throwaway Postgres, Redis and object storage): 1090 passed. The 20 failures match unmodified main in count: they need Langfuse or depend on test order. Two order-dependent orchestration failures land on different test names because this PR adds tests to that class; both pass when their package runs alone.
  • Web client: tsc --noEmit is clean, eslint reports no errors, and 592 tests passed.

@viodid
viodid requested a review from a team as a code owner November 25, 2026 17:22
@viodid viodid added documentation Improvements or additions to documentation web client React web client core Core FastAPI app - Nebula's brain iac service IaC OSS microservice labels Nov 25, 2026
Copilot AI balanced review requested due to automatic review settings November 25, 2026 17:22
@viodid viodid added the github_actions Pull requests that update GitHub Actions code label Nov 25, 2026
@viodid
viodid changed the base branch from main to develop November 25, 2026 17:28
A repository can be named by a project identifier (e.g.
sistemas-kumoss-rsg-esc1-dev) that the mapping service resolves to its
URL. The IaC service may pick the credentials a command runs with by
that identifier, so it now travels with every IaC call of the session.

- /v1/repository/parse echoes the input as project_identifier, and the
  web wizard sends it back on the session's first call.
- The first call accepts project_identifier. It is dropped when it is
  repo_uri itself, rejected when it embeds a password, and must resolve
  to repo_uri through the mapping service (422 otherwise) before any
  session is created.
- The session records it on its workspace (migration 0003) and in the
  cached context, so iteration and apply calls carry it too.
- The root module's manifest records it; sync saves when only the
  identifier changed. The kumoss.yaml reader documents its flexible
  layout: version and fingerprint required, unknown keys ignored.
- Terraform sends it as the Kumoss-Project header on every IaC call,
  through one client builder. IaC contract 2.1.0 documents the optional
  header; the reference service ignores it.
- The Terraform state digest formerly called project_id is now
  state_id (TerraformUtils, TerraformBackend, TerraformFactory and the
  docs' state key placeholder), apart from the new project_identifier.
- Docs: the root module manifest, core, IaC and mapping API references,
  database schema, upgrade notes, end-to-end flow, data and state, the
  request guide and a glossary entry cover the project identifier.

Signed-off-by: David Yunta <davidy@inditex.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved critical policy defects allow Kubernetes and command-execution checks to be bypassed and encryption-key removals to be missed or falsely reported.

1 open issue
What changed in this PR

Carries a validated project identifier from the web wizard through session storage and manifests to the IaC service, allowing implementations to select project-specific credentials. The PR also expands compliance policies and separates Terraform state naming from project identifiers.

Changes:

  • Adds project-identifier validation, persistence, client propagation, and the optional Kumoss-Project header.
  • Adds provider-specific compliance policies, broader general checks, revision tracking, tests, and documentation.
  • Renames the Terraform state digest to state_id across implementation, tests, and documentation.
File Description
services/​iac/​src/​main.py Updates service version to 2.1.0.
docs/​src/​modules/​main/​partials/​glossary/​compliance-audit.adoc Describes multiple compliance policies.
docs/​src/​modules/​main/​pages/​roadmap.adoc Updates delivered compliance capabilities.
docs/​src/​modules/​main/​pages/​reference/​configuration.adoc Documents policy checks and state naming.
docs/​src/​modules/​main/​pages/​guides/​upgrade-notes.adoc Explains policy changes and compatibility.
docs/​src/​modules/​main/​pages/​guides/​state-backends/​kumoss-managed.adoc Renames state-key placeholders.
docs/​src/​modules/​main/​pages/​guides/​production/​operations.adoc Updates state verification examples.
docs/​src/​modules/​main/​pages/​guides/​production/​hardening.adoc Documents compliance deployment safeguards.
docs/​src/​modules/​main/​pages/​guides/​generate-infrastructure.adoc Describes expanded compliance checks.
docs/​src/​modules/​main/​pages/​guides/​development.adoc Updates policy testing commands.
docs/​src/​modules/​main/​pages/​guides/​deploy-to-production.adoc Explains command-execution checks and limits.
docs/​src/​modules/​main/​pages/​guides/​customize-prompts.adoc Documents provider policies and prompt changes.
docs/​src/​modules/​main/​pages/​guides/​configure-state-backends.adoc Uses state_id terminology.
docs/​src/​modules/​main/​pages/​faq.adoc Expands compliance-lock explanations.
docs/​src/​modules/​main/​pages/​architecture/​end-to-end-flow.adoc Documents multi-policy evaluation and reports.
core/​tests/​policies/​vsphere_test.rego Tests vSphere compliance rules.
core/​tests/​policies/​oci_test.rego Tests OCI compliance rules.
core/​tests/​policies/​kubernetes_test.rego Tests Kubernetes compliance rules.
core/​tests/​policies/​google_test.rego Tests Google Cloud compliance rules.
core/​tests/​policies/​fixtures/​kubernetes/​data.json Adds Kubernetes plan fixture.
core/​tests/​policies/​fixtures/​google/​data.json Adds Google Cloud plan fixture.
core/​tests/​policies/​fixtures/​general/​data.json Adds general-policy plan fixture.
core/​tests/​policies/​fixtures/​aws/​data.json Adds AWS plan fixture.
core/​tests/​policies/​compliance_test.rego Tests expanded general rules.
core/​tests/​policies/​azurerm_test.rego Tests Azure compliance rules.
core/​tests/​policies/​aws_test.rego Tests AWS compliance rules.
core/​tests/​infrastructure/​terraform/​test_utils.py Updates state-digest tests.
core/​tests/​infrastructure/​terraform/​test_terraform.py Tests project-header propagation.
core/​tests/​infrastructure/​terraform/​test_backend.py Updates backend state naming.
core/​tests/​infrastructure/​templates/​test_seed_loader.py Verifies seeded policy providers.
core/​tests/​infrastructure/​templates/​test_seed_catalog.py Checks policy packages and rule separation.
core/​tests/​infrastructure/​policy/​test_opa_policy_engine.py Tests multi-policy evaluation and failures.
core/​tests/​infrastructure/​filesystem/​test_manifest_file.py Tests identifier serialization and flexible reading.
core/​tests/​infrastructure/​database/​test_migrations.py Updates legacy-schema migration setup.
core/​tests/​domains/​services/​test_compliance_check_service.py Tests revision lists and backward compatibility.
core/​tests/​application/​test_iac_requests.py Tests project-identifier request validation.
core/​tests/​application/​services/​test_session_orchestration_service.py Tests identifier persistence across calls.
core/​tests/​application/​services/​test_manifest_session_service.py Tests identifier recording in manifests.
core/​tests/​api/​v1/​test_repository_parse.py Tests echoed project identifiers.
core/​tests/​api/​v1/​test_project_identifier.py Tests identifier-to-repository matching.
core/​tests/​api/​v1/​test_manifest_probe.py Supplies module context for reconciliation.
core/​src/​shared/​config/​system_config.py Updates state-prefix docstring terminology.
core/​src/​main.py Verifies seeded provider policies at startup.
core/​src/​infrastructure/​terraform/​utils.py Renames the state-digest function.
core/​src/​infrastructure/​terraform/​terraform.py Centralizes clients and adds project headers.
core/​src/​infrastructure/​terraform/​factory.py Passes project identifiers and state IDs.
core/​src/​infrastructure/​terraform/​backend.py Renames internal state identifiers.
core/​src/​infrastructure/​templates/​prompt_seeder.py Exposes seeded policy-provider discovery.
core/​src/​infrastructure/​policy/​opa_policy_engine.py Fetches and merges multiple policies.
core/​src/​infrastructure/​filesystem/​manifest_file.py Reads and writes project identifiers.
core/​src/​infrastructure/​database/​models.py Adds nullable workspace project identifier.
core/​src/​infrastructure/​database/​migrations/​versions/​0003_workspaces_project_identifier.py Migrates workspace identifier storage.
core/​src/​domains/​value_objects/​workspace_facts.py Adds optional cached workspace identifier.
core/​src/​domains/​value_objects/​manifest.py Adds manifest and module identifiers.
core/​src/​domains/​services/​manifest_service.py Reconciles and saves identifier changes.
core/​src/​domains/​services/​database_service.py Persists identifiers and versions context cache.
core/​src/​domains/​services/​compliance_check_service.py Uses revision lists for failed evaluations.
core/​src/​domains/​interfaces/​policy_engine_interface.py Adds providers to startup verification.
core/​src/​domains/​entities/​session.py Exposes the session project identifier.
core/​src/​domains/​dto.py Adds multi-policy revision compatibility.
core/​src/​application/​services/​session_orchestration_service.py Records identifiers during session creation.
core/​src/​application/​services/​manifest_session_service.py Passes session identifiers into manifests.
core/​src/​application/​iac_requests.py Defines and validates project identifiers.
core/​src/​application/​factory.py Connects session identifiers to Terraform.
core/​src/​api/​v1/​terraform.py Checks repository mappings before session creation.
core/​src/​api/​v1/​repository.py Echoes identifiers in parse responses.
core/​prompts/​seed/​vsphere/​policies/​compliance.rego Adds vSphere compliance policy.
core/​prompts/​seed/​vsphere/​guidelines/​resource_creation.yaml Removes provider and provisioner restrictions.
core/​prompts/​seed/​vsphere/​guidelines/​permissions.yaml Removes TLS restriction guidance.
core/​prompts/​seed/​oci/​resources/​vcn.yaml Removes default-security-list setup guidance.
core/​prompts/​seed/​oci/​resources/​security_list.yaml Removes security-list restrictions and defaults.
core/​prompts/​seed/​oci/​resources/​network_security_group.yaml Removes public-ingress prohibition.
core/​prompts/​seed/​oci/​resources/​instance_configuration.yaml Removes guest-configuration and secret guidance.
core/​prompts/​seed/​oci/​resources/​iam_policy.yaml Removes any-user restriction guidance.
core/​prompts/​seed/​oci/​resources/​compute_instance.yaml Removes guest-initialization guidance.
core/​prompts/​seed/​oci/​resources/​bastion.yaml Removes client-CIDR restriction guidance.
core/​prompts/​seed/​oci/​policies/​compliance.rego Adds OCI compliance policy.
core/​prompts/​seed/​oci/​guidelines/​resource_creation.yaml Removes protective-default guidance.
core/​prompts/​seed/​oci/​guidelines/​permissions.yaml Removes any-user prohibition.
core/​prompts/​seed/​oci/​guidelines/​networking.yaml Removes security-list and ingress guidance.
core/​prompts/​seed/​kubernetes/​resources/​cluster_role_binding.yaml Removes service-account admin prohibition.
core/​prompts/​seed/​kubernetes/​policies/​compliance.rego Adds Kubernetes compliance policy.
core/​prompts/​seed/​kubernetes/​guidelines/​permissions.yaml Removes service-account admin prohibition.
core/​prompts/​seed/​google/​resources/​service_account.yaml Removes role and key restrictions.
core/​prompts/​seed/​google/​resources/​gke_autopilot.yaml Removes workload-identity guidance.
core/​prompts/​seed/​google/​resources/​firewall.yaml Removes public-ingress restriction guidance.
core/​prompts/​seed/​google/​resources/​compute_instance.yaml Removes guest-configuration and secret guidance.
core/​prompts/​seed/​google/​policies/​compliance.rego Adds Google Cloud compliance policy.
core/​prompts/​seed/​google/​guidelines/​permissions.yaml Removes basic-role and key prohibitions.
core/​prompts/​seed/​general/​policies/​compliance.rego Adds encryption, command, and output checks.
core/​prompts/​seed/​general/​guidelines/​terraform.yaml Removes command-execution prohibition section.
core/​prompts/​seed/​azurerm/​resources/​vm_scale_set.yaml Removes guest-command restrictions.
core/​prompts/​seed/​azurerm/​resources/​virtual_machine.yaml Removes guest-configuration and secret guidance.
core/​prompts/​seed/​azurerm/​resources/​role_assignment.yaml Removes privileged-role restrictions.
core/​prompts/​seed/​azurerm/​resources/​network_security_group.yaml Removes public-ingress restriction guidance.
core/​prompts/​seed/​azurerm/​policies/​compliance.rego Adds Azure compliance policy.
core/​prompts/​seed/​azurerm/​guidelines/​permissions.yaml Removes break-glass-only Owner restriction.
core/​prompts/​seed/​aws/​resources/​security_group.yaml Removes public-ingress restriction guidance.
core/​prompts/​seed/​aws/​resources/​launch_template.yaml Removes guest-configuration and secret guidance.
core/​prompts/​seed/​aws/​resources/​ec2.yaml Removes guest-configuration and secret guidance.
core/​prompts/​seed/​aws/​policies/​compliance.rego Adds AWS compliance policy.
contracts/​openapi/​iac.v1.yaml Documents optional project header in 2.1.0.
client/​web/​src/​types/​index.ts Uses compliance revision arrays.
client/​web/​src/​types/​api.ts Adds first-call project identifier.
client/​web/​src/​services/​workflows/​terraform_action.ts Sends identifiers on first calls.
client/​web/​src/​services/​workflows/​terraform_action.test.ts Tests identifier request payloads.
client/​web/​src/​services/​core/​iac_code.ts Types the echoed parse identifier.
client/​web/​src/​hooks/​wizardFlow.test.ts Updates wizard-state fixture.
client/​web/​src/​hooks/​useWizardNavigation.ts Stores wizard project identifiers.
client/​web/​src/​hooks/​useWizardNavigation.test.ts Updates initialization and reset expectations.
client/​web/​src/​hooks/​useRepositoryScan.ts Returns identifiers from repository scans.
client/​web/​src/​hooks/​useRepositoryScan.test.ts Tests scan identifier propagation.
client/​web/​src/​components/​Sessions/​SessionData/​ArtifactContent.test.tsx Updates multi-policy report fixture.
client/​web/​src/​components/​Home/​useHomeWizard.ts Carries identifiers through wizard execution.
client/​web/​src/​components/​Home/​useHomeWizard.test.ts Tests wizard identifier propagation and resets.
.github/​workflows/​verify.yml Checks and tests all seeded policies.

Review effort: Balanced

Comment on lines +263 to +264
if self.project_identifier == self.repo_uri:
self.project_identifier = None
@viodid
viodid force-pushed the feature/manifest-project-identifier branch from 05f45a6 to 76bbecd Compare November 25, 2026 17:52
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core FastAPI app - Nebula's brain documentation Improvements or additions to documentation github_actions Pull requests that update GitHub Actions code iac service IaC OSS microservice web client React web client

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants