Skip to content

test: assert every provider adapter against one conformance suite - #193

Merged
malon64 merged 6 commits into
mainfrom
test/provider-adapter-conformance-suite
Sep 10, 2026
Merged

malon64 merged 6 commits into
mainfrom
test/provider-adapter-conformance-suite

Conversation

@malon64

@malon64 malon64 commented Sep 9, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #188.

One suite at tools/olf/tests/test_provider_conformance.py that every provider
adapter must pass. 40 tests, ~0.8s, no cluster and no cloud credentials: every
provider is built from an empty environment onto a recording runner, and each
root's contract is read from the v3 fixture already captured beside the file.

The parameter list is the Provider enum, not a literal. Adding a provider
enrols it in every assertion at once, and each one fails with a message naming
the contract it broke. Verified by temporarily adding GCP = "gcp" to the enum:
all 14 test functions failed (13 parameterized cases for gcp, plus the
cross-provider identity test), starting with "'gcp' has no
DeploymentContext.gcp() factory. Every provider needs one: it is how shared
code resolves that provider's paths, kube context, and scoped command
environment without knowing which provider it is running against."

Invariants implemented

Invariant How it is asserted
Every adapter satisfies DeploymentProvider structurally Members are read off the Protocol itself (__annotations__ + its functions), so a member added there is required of every adapter from that moment. Method signatures are compared exactly.
Every adapter exposes the env overlay shared callers use Read off the class, not the instance (touching it resolves the Docker endpoint, and on cloud the foundation outputs). This is #187 Group A — see below.
Every root declares a v3 stage-indexed contract surface hcl2 over each root's contracts.tf: schema_version == "3.0.0", stages built over local.enabled_stages, and the canonical stage-scoped references (stage/${name}/runtime_identity, .../catalog, .../orchestration, activations/${name}, shared/ops_storage) pinned to the stage being emitted.
Every root declares the outputs shared tooling reads provider_contracts, shared_namespace, stage_names. stage_names is load-bearing: a root that omits it makes terraform output answer "output variable requested could not be found", which applied_stage_names reads as an unapplied root — silently disarming the stage-removal guard on that provider only.
Every enabled stage resolves from the contract parse_provider_contracts over each provider's captured output; every enabled stage resolves by name, and a stage the profile does not enable raises.
Stage identities derive from logical identity alone (rule 2) Per provider: namespace, catalog_name, activation.prefix equal their canonical derivation; no identity carries a provider or implementation name; each bucket carries its own stage and layer.
…stated as an equality across providers The same stage resolves to the same (namespace, catalog_name, activation prefix, principal, bronze/silver/gold buckets) on local, AWS, and Azure. This is rule 2 as a property rather than a naming convention — it is what makes an adapter swappable.
The destructive-apply guards reject stage removal identically everywhere require_no_stage_removal and require_no_shared_namespace_replacement driven through each provider's own config: applied-stage removal, the drift path (state gone, namespace still labelled), the --allow-stage-removal opt-in, and the pre-v0.3 lakehouse namespace.
Every ADR 0002 phase is selectable and ordered identically Per adapter: --phase <p> runs that phase's step and nothing else, and olf deploy runs foundation → platform → artifacts.

What I dropped, and why

"Every root emits a v3 stage index that provider_contracts parses" — not
checkable in full without Terraform. hcl2 parses HCL syntax, not Terraform
semantics: a root's stages value collapses to one opaque ${...} expression
string, so nothing short of a real init + apply (with provider credentials)
renders the payload. Split into the two halves that are checkable without a
cluster: the root declares a v3 stage-indexed surface with canonical
stage-scoped refs (static, hcl2), and the captured output parses for every
enabled stage (fixture-driven). The remaining half — that a real apply emits
exactly the fixture's payload — stays with olf e2e run. The module docstring
says so explicitly rather than implying the suite covers it.

Nothing else was dropped.

Gaps found, for #187

  • Group A confirmed, not landed here. env is on both providers and read by
    shared code, but not on the Protocol. I asserted it on what the adapters
    actually expose rather than adding the member, so this PR stays the suite and
    not the refactor. The one-line addition is worth its own commit on Complete the DeploymentProvider contract: config is still reached past the Protocol #187.
  • Group B is visible in this suite's own code. _adapter() returns the
    built provider and the guard tests read adapter.config — because there is no
    DeploymentConfig on the Protocol to read instead. The suite reaches past the
    seam for exactly the reason Complete the DeploymentProvider contract: config is still reached past the Protocol #187 exists.
  • The cloud guard path works, and is now covered. require_no_stage_removal
    and require_no_shared_namespace_replacement, declared against
    LocalDeploymentConfig, behave identically given a CloudDeploymentConfig:
    everything they touch (context.enabled_stages, context.owned_namespaces,
    context.topology, context.allow_stage_removal, context.shared_namespace,
    kube_context, paths.kubeconfig_path) exists on both. It is covered now, not
    fixed — the type gap is untouched, and olf.deployment.cloud.platform stays on
    the mypy override list. docs/technical-debt.md's row said the path was
    "neither type-checked nor covered by a cloud-path test"; that sentence is no
    longer true, so the row is updated to "partly fixed" with the type gap intact
    rather than left stale.

Gate results (from the repository root)

Re-run after rebasing onto e5134a0 (#192). #192 removed the "Seven CLI tests depend on the working directory" debt row, adjacent to the guards row this change rewrites; main's deletion is kept and the rewritten row carried forward. The numbers below are the post-rebase measurements, not the pre-rebase ones — they happen to be identical.

Gate Result
olf check all exit 0, no failures
ruff check tools/olf All checks passed
mypy --config-file tools/olf/pyproject.toml tools/olf/olf Success: no issues found in 150 source files
pytest tools/olf/tests --cov --cov-config=tools/olf/pyproject.toml 1413 passed, 81.03% branch coverage

Coverage moves from 81.01% to 81.03% (baseline re-measured on the rebased tree: 1373 tests, 81.01%) — honestly, a rounding error. The suite
exercises mostly already-covered lines; its value is that it fails when a
contract breaks, not that it touches new ones. The floor stays at 81%; nothing
was lowered.

Notes

🤖 Generated with Claude Code

https://claude.ai/code/session_01Ue9Z94NHioRFYyjVB6egE5

@malon64
malon64 force-pushed the test/provider-adapter-conformance-suite branch from 054d4b3 to ab27443 Compare September 9, 2026 15:53

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 054d4b389b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/technical-debt.md Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 05883b0c57

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/technical-debt.md Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 12b012f669

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e3e85be125

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

malon64 and others added 4 commits September 10, 2026 18:57
The tests were organised per module while the architecture is organised by
contract, so nothing asserted that every adapter satisfies the same one. An
adapter could diverge and only fail at runtime, on the provider nobody
exercises locally - which is how the destructive-apply guards ended up called
from the cloud platform apply with a config they were never written for, and
never covered there.

The suite parameterizes over the Provider enum rather than a literal list, so
a provider is enrolled the moment the enum names it and every assertion fails
until its adapter conforms. It needs no cluster and no cloud credentials:
providers are built from an empty environment onto a recording runner, and
each root's contract is read from the fixture already captured beside it.

Three more provider-touching changes (#130, #131, #155) are about to be
written; this exists first so they are written against it.

Refs #188.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ue9Z94NHioRFYyjVB6egE5
Four review findings, all about the suite asserting the wrong thing.

The destructive-apply guards were called directly with `adapter.config`,
so deleting either call from `cloud/platform.py` left every test green --
the coverage claim the debt row made was not one the tests backed. They
now run through each provider's own platform apply; removing the call
fails ten cases across AWS and Azure.

Cross-provider equality compared physical bucket names and runtime
principals. Architectural rule 2 delegates physical naming to the
provider contract, so an adapter deriving account-specific names was
correct and failed anyway. Equality now covers only the logical
identities olf derives.

Comparing stage sets by intersection meant a fixture that dropped PROD
was skipped rather than caught -- the exact omission the suite exists to
detect. The stages are now a declared constant every provider must
serve.

Protocol conformance compared `str(inspect.signature(...))`, which
breaks on an added keyword-only argument or an equivalent annotation
spelling without breaking any caller. It now binds Protocol-shaped
calls.

The debt row records what the tests actually prove: behaviour is
covered, by `test_cloud_platform.py` since #163 and by this suite for
every provider, and the type gap alone remains.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ue9Z94NHioRFYyjVB6egE5
Two claims were wider than their evidence.

The debt row said cloud guard behaviour is covered. Driving the guards
through `platform_up` proves they run, not that they inspect the right
cluster -- and they do not: `platform_up` hands them `config`, whose
`kube_context` is empty on cloud until the foundation outputs resolve, so
they query `kubectl --context ''` and fall through to whatever the
kubeconfig's current context happens to be. The sibling
`import_namespace_if_missing_in_state` call is given `facts.kube_context`
explicitly; these two are not. The row now records that, and the fix
path leads with it.

The stage-reference check reads `stages` as one opaque expression string,
because that is all hcl2 returns, so it can only prove a token appears
somewhere -- not that each field is pinned to its own stage. Pinning the
wrong stage into one field while another still carries the token passes
it. The failure message and the module docstring now say so, rather than
advertising a cross-stage isolation guarantee only a rendered contract
can give.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ue9Z94NHioRFYyjVB6egE5
`env` was asserted with `hasattr` on the class, so an adapter whose `env`
is None, raises, or yields something a subprocess cannot take would have
passed here and failed at activation. It is now resolved and checked as a
non-empty str-to-str mapping carrying KUBE_CONTEXT, with the fake
foundation facts primed first so a cloud adapter does not reach a real
Terraform to do it.

The two phase tests record the steps rather than run them, which is what
keeps them cluster-free and is equally their limit: they prove which step
each phase selects, and in what order, on every adapter -- not that a step
does the right work. An adapter whose `platform_up` became a no-op still
passes. Their docstrings say so now instead of implying a lifecycle
regression would be caught here.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ue9Z94NHioRFYyjVB6egE5
@malon64
malon64 force-pushed the test/provider-adapter-conformance-suite branch from e3e85be to 34f26d3 Compare September 10, 2026 16:58
Priming `adapter.__dict__["_foundation_facts"]` reached past the adapter
into how a cached property stores what it resolved. A `CloudProvider`
that kept its facts anywhere else would have written an unrelated dict
entry, let `env` fall through to real foundation resolution, and failed
this suite while its public behaviour stayed correct -- the coupling a
conformance test is least entitled to.

The resolver it calls is stubbed instead, leaving the adapter free to
store the result however it likes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ue9Z94NHioRFYyjVB6egE5
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 34f26d3dbc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Nothing connected a captured contract back to the provider it stands for.
`_topology_of` derives the expected topology from the fixture's own
`deployment.provider`, so a copied or mislabelled capture would validate
one provider's contract while the suite reported it as another's
coverage. The fixture loader now asserts that field matches the
parameterized provider.

The Protocol-call generator only ever offered a positional call for
POSITIONAL_OR_KEYWORD parameters, so an adapter narrowing one to
positional-only passed while rejecting `plan(phase=...)` -- a call a
holder of `DeploymentProvider` may legally make. Both forms are generated
when every positional slot can also be named.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ue9Z94NHioRFYyjVB6egE5
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@malon64
malon64 merged commit 49c977b into main Sep 10, 2026
8 checks passed
@malon64
malon64 deleted the test/provider-adapter-conformance-suite branch September 10, 2026 17:11
chouaibmouidis-py pushed a commit to chouaibmouidis-py/openlakeforge that referenced this pull request Nov 4, 2026
…enLakeForge#193)

* test: assert every provider adapter against one conformance suite

The tests were organised per module while the architecture is organised by
contract, so nothing asserted that every adapter satisfies the same one. An
adapter could diverge and only fail at runtime, on the provider nobody
exercises locally - which is how the destructive-apply guards ended up called
from the cloud platform apply with a config they were never written for, and
never covered there.

The suite parameterizes over the Provider enum rather than a literal list, so
a provider is enrolled the moment the enum names it and every assertion fails
until its adapter conforms. It needs no cluster and no cloud credentials:
providers are built from an empty environment onto a recording runner, and
each root's contract is read from the fixture already captured beside it.

Three more provider-touching changes (OpenLakeForge#130, OpenLakeForge#131, OpenLakeForge#155) are about to be
written; this exists first so they are written against it.

Refs OpenLakeForge#188.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ue9Z94NHioRFYyjVB6egE5

* test: drive the conformance guards through each provider's apply

Four review findings, all about the suite asserting the wrong thing.

The destructive-apply guards were called directly with `adapter.config`,
so deleting either call from `cloud/platform.py` left every test green --
the coverage claim the debt row made was not one the tests backed. They
now run through each provider's own platform apply; removing the call
fails ten cases across AWS and Azure.

Cross-provider equality compared physical bucket names and runtime
principals. Architectural rule 2 delegates physical naming to the
provider contract, so an adapter deriving account-specific names was
correct and failed anyway. Equality now covers only the logical
identities olf derives.

Comparing stage sets by intersection meant a fixture that dropped PROD
was skipped rather than caught -- the exact omission the suite exists to
detect. The stages are now a declared constant every provider must
serve.

Protocol conformance compared `str(inspect.signature(...))`, which
breaks on an added keyword-only argument or an equivalent annotation
spelling without breaking any caller. It now binds Protocol-shaped
calls.

The debt row records what the tests actually prove: behaviour is
covered, by `test_cloud_platform.py` since OpenLakeForge#163 and by this suite for
every provider, and the type gap alone remains.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ue9Z94NHioRFYyjVB6egE5

* docs: say what the conformance checks actually prove

Two claims were wider than their evidence.

The debt row said cloud guard behaviour is covered. Driving the guards
through `platform_up` proves they run, not that they inspect the right
cluster -- and they do not: `platform_up` hands them `config`, whose
`kube_context` is empty on cloud until the foundation outputs resolve, so
they query `kubectl --context ''` and fall through to whatever the
kubeconfig's current context happens to be. The sibling
`import_namespace_if_missing_in_state` call is given `facts.kube_context`
explicitly; these two are not. The row now records that, and the fix
path leads with it.

The stage-reference check reads `stages` as one opaque expression string,
because that is all hcl2 returns, so it can only prove a token appears
somewhere -- not that each field is pinned to its own stage. Pinning the
wrong stage into one field while another still carries the token passes
it. The failure message and the module docstring now say so, rather than
advertising a cross-stage isolation guarantee only a rendered contract
can give.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ue9Z94NHioRFYyjVB6egE5

* test: resolve the adapter environment instead of checking for it

`env` was asserted with `hasattr` on the class, so an adapter whose `env`
is None, raises, or yields something a subprocess cannot take would have
passed here and failed at activation. It is now resolved and checked as a
non-empty str-to-str mapping carrying KUBE_CONTEXT, with the fake
foundation facts primed first so a cloud adapter does not reach a real
Terraform to do it.

The two phase tests record the steps rather than run them, which is what
keeps them cluster-free and is equally their limit: they prove which step
each phase selects, and in what order, on every adapter -- not that a step
does the right work. An adapter whose `platform_up` became a no-op still
passes. Their docstrings say so now instead of implying a lifecycle
regression would be caught here.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ue9Z94NHioRFYyjVB6egE5

* test: stub the foundation resolver, not the property's cache

Priming `adapter.__dict__["_foundation_facts"]` reached past the adapter
into how a cached property stores what it resolved. A `CloudProvider`
that kept its facts anywhere else would have written an unrelated dict
entry, let `env` fall through to real foundation resolution, and failed
this suite while its public behaviour stayed correct -- the coupling a
conformance test is least entitled to.

The resolver it calls is stubbed instead, leaving the adapter free to
store the result however it likes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ue9Z94NHioRFYyjVB6egE5

* test: tie each fixture to its provider and offer keyword calls

Nothing connected a captured contract back to the provider it stands for.
`_topology_of` derives the expected topology from the fixture's own
`deployment.provider`, so a copied or mislabelled capture would validate
one provider's contract while the suite reported it as another's
coverage. The fixture loader now asserts that field matches the
parameterized provider.

The Protocol-call generator only ever offered a positional call for
POSITIONAL_OR_KEYWORD parameters, so an adapter narrowing one to
positional-only passed while rejecting `plan(phase=...)` -- a call a
holder of `DeploymentProvider` may legally make. Both forms are generated
when every positional slot can also be named.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ue9Z94NHioRFYyjVB6egE5

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add provider adapter conformance tests so a new adapter cannot silently break a contract

1 participant