Skip to content

fix(bundle,plan): one compile for bundle --env, lighter plan attribution, profiling --env bundles - #1191

Merged
fas89 merged 4 commits into
mainfrom
fix/bundle-env-plan-attribution
Dec 5, 2026
Merged

fas89 merged 4 commits into
mainfrom
fix/bundle-env-plan-attribution

Conversation

@fas89

@fas89 fas89 commented Dec 5, 2026 •

Copy link
Copy Markdown
Collaborator

What this changes

Four commits.

1. fluid bundle --env reports one compile again

The privacy-overlay check composed the base contract through the same function as the bundle itself, so fluid bundle --env logged compile_start and compile_done twice. The base is now composed with loader.compose_contract directly, with no compile events. tests/fragments/test_compat_gate.py (output byte-identical to v0.24.0) passes again: its two test_m01_...[overlay-075|overlay-076] cases failed on main.

The compat gate extracts v0.24.0 with git archive and skipped on every CI leg, because the checkout is shallow. The Test (Python 3.12) leg now fetches that tag alone (depth 1: its tree, no history) and sets FLUID_COMPAT_GATE_REQUIRED=1, which makes a missing tag fail the gate instead of skipping it. A second test that needs no tag, test_a_bundle_built_with_an_env_reports_one_compile, pins the event count everywhere.

2. fluid plan no longer runs every cloud's emitter for the attribution block

build_attribution_block imported and ran the IaC emitter of every cloud (AWS, GCP, Snowflake, Databricks) on every plan, whatever the contract targets. It now runs the emitters of the clouds the contract declares (iac.provider_match.detect_clouds, the same detection fluid generate iac uses) plus the plan's provider. A contract that declares no platform and names no provider still gets every emitter, and so does one whose bindings cannot be read.

  • plan.json (planDigest and the attribution block) is byte-identical on 42 of the 45 template and example contracts, base 1775a73 vs head.
  • The other three are the AWS Iceberg examples (examples/aws-glue-data-lake/contract-etl-job, contract-iceberg, examples/aws-iceberg-lakehouse). The GCP emitter used to list a google_storage_bucket and its IAM entries for their AWS Iceberg exposes. Apply on AWS never creates those, so the block no longer bills them.
  • Module set of fluid plan on the customer-360 template: v0.44.0's set plus fluid_build.attribution.* and fluid_build.iac.naming (the key registry's identifier helper). The GCP provider package, databricks_genie and databricks_folders are gone from the plan path.
  • fluid generate artifacts builds its MANIFEST attribution block through the same function (with no plan provider), so its block changes the same way: only the declared clouds' emitters run.
  • fluid generate iac is unchanged.

3. A bundle built with --env can be profiled when its overlay left the privacy block alone

fluid profile and fluid privacy-audit refused every bundle built with --env whose contract carries a privacy block, because a bundle holds its overlay merged in and could not say what the overlay changed. fluid bundle --env now compares the overlaid contract with the contract alone. When the block, every tie to a column it lists and the exposes and columns it was written for are unchanged, and the block is enforceable on both, it records "privacyBlock": "unchanged" in the MANIFEST source block. Profile and audit take a bundle with that record. A bundle without it (one from an earlier version) is refused as before, with a hint to rebuild it. The record sits beside env in the source block, outside the merkle root, as env does. Bundles of contracts without a privacy block are unchanged.

4. An overlay may not take a tie away or add an expose, in any bundle format

fluid bundle --env refused an overlay that changes the privacy block, but an overlay that rewrote a relationship's fromColumns (and so took away the tie that withholds a column) was written into a yaml or json bundle, and a profile of that file published the column. An overlay that adds an expose or a column the contract does not declare could also carry withheld data under a name the block does not list. fluid bundle --env (every format), fluid profile --env and fluid privacy-audit --env now refuse all three, through one shared check (_privacy_overlay.overlay_privacy_refusal). The refusal applies to any fluid bundle --env of a contract with a top-level privacy block, whatever the output format. For a contract without the block, only the existing refusal of an overlay that adds one applies.

Performance

case before (main) after
fluid plan customer-360, wall, min of 21 alternating runs 305 ms (v0.44.0: 297 ms) 298 ms
same, median 310 ms (v0.44.0: 304 ms) 306 ms
build_attribution_block inside fluid plan, customer-360 (local engine) 20.8 ms 0.1 ms
same, aws-s3-glue-athena example (AWS) 22.0 ms 2.0 ms
modules loaded by fluid plan customer-360 551 539

Whole-command timings: macOS, M-series, all three trees byte-compiled first, each run in its own tree, alternating order, run alone. Block timings: time.perf_counter around the call in a real fluid plan process, best of 7 to 9 runs. fluid plan is back within 0.3% of v0.44.0 (main was 2.7% over).

Borrow before build

Checked locally:

  • iac.provider_match.detect_clouds already detects the clouds a contract declares for fluid generate iac; reused as is.
  • _privacy_overlay.block_changed and withholding_dropped are the checks fluid profile --env ran; the bundle and the new shared refusal reuse them. forge_datamodel.semantics_builder.declared_columns and policy._common.iter_exposes give the declared exposes and columns. forge.core.bundle.make_bundle_source / read_bundle_source carry the new field.
  • loader.compose_contract is the composition every command reads; the base check now calls it directly.

Searched:

Reuse strategy:

  • Attribution: adapt the pattern (load and run only the declared providers), with forge's own detection. No dependency.
  • Bundle record: adapt the VSA idea (the producer that ran the check records its verdict beside the artifact) as one MANIFEST field. Diverge from a signed attestation on purpose: forge bundles carry no signature, and the record has the same standing as the env field it sits beside.

Tests (failing first)

  • tests/fragments/test_compat_gate.py::test_m01_...[overlay-075|overlay-076] failed on main, pass now.
  • tests/profiler/test_cli_profile_policy.py, failing before: test_a_bundle_built_with_an_env_reports_one_compile, test_a_bundle_whose_overlay_leaves_the_block_and_its_ties_alone_is_profiled, test_a_bundle_built_with_an_env_that_records_no_check_is_refused_by_the_profile, test_a_bundle_whose_overlay_takes_a_tie_away_is_not_written[yaml|json], test_an_overlay_that_adds_an_expose_is_refused_by_the_profile, test_a_bundle_whose_overlay_adds_an_expose_is_not_written. Also new: test_a_bundle_of_a_contract_without_a_block_records_no_privacy_check.
  • tests/attribution/test_block.py: new tests that only the declared clouds' emitters run, that a local-engine contract runs none and loads no cloud emitter module, that a platform-less contract runs the plan's provider, and that unreadable bindings run every emitter; each fails before. One pins that a contract declaring nothing still runs every emitter (passes before and after). Two existing tests updated to the new rule.

Checks

  • Full suite, -n 3, macOS: 56624 passed, 8 failed. All 8 come from this machine's environment, in files this change does not touch: 5 in tests/iac/test_iac_databricks_alerts_fake_e2e.py (no databricks-sdk locally), 2 in tests/providers/test_duckdb_sandbox_workspace_root.py (macOS temp dir), 1 in tests/test_dotenv_unfiltered_readers.py (no dbt locally).
  • After rebasing on 1775a73: the compat gate (required mode), tests/attribution, the profile, privacy-audit, plan and bundle dbt-project tests, tests/perf/test_startup_budget.py and tests/test_import_cycles.py: 409 passed, 1 skipped.
  • ruff and black clean.
  • The compat gate's session fixture takes about 60 s on one worker; it runs only on the 3.12 leg.

fas89 added 4 commits December 5, 2026 09:35
…ibility gate in CI

The privacy-overlay check composed the base contract through the same path
as the bundle itself, so `fluid bundle --env` logged compile_start and
compile_done twice. The base is now composed without those events, and the
output reads as v0.24.0's again.

The compatibility gate extracts v0.24.0 with git archive and skipped on every
CI leg because the checkout is shallow. The Python 3.12 leg now fetches that
tag alone and sets FLUID_COMPAT_GATE_REQUIRED=1, which turns a missing tag
into a failure instead of a skip.

Signed-off-by: Speculator55005 <50082482+fas89@users.noreply.github.com>
…tters only

fluid plan built its attribution block by importing and running every
cloud's IaC emitter, whatever the contract targets, which cost about 20 ms
and a dozen imports on every plan. The block now runs the emitters of the
clouds the contract declares, plus the plan's provider. Every emitter still
runs for a contract that declares no platform and names no provider, and
for one whose bindings cannot be read.

plan.json is byte-identical on 42 of the 45 template and example
contracts. The three AWS Iceberg examples lose the GCS bucket and bucket
IAM entries the GCP emitter used to list for their AWS exposes: apply on
AWS never creates them, so the block no longer bills them.

Signed-off-by: Speculator55005 <50082482+fas89@users.noreply.github.com>
…udit take an --env bundle

A bundle holds its overlay merged in, so fluid profile and fluid
privacy-audit refused every bundle built with --env whose contract carries
a privacy block, even when the overlay left the block alone. fluid bundle
--env now compares the overlaid contract with the contract alone and, when
the block and every tie to a column it lists are unchanged, records
privacyBlock: unchanged in the MANIFEST source block. Profile and audit
take a bundle with that record; one without it (an earlier bundle, or an
overlay that takes a tie away) is still refused, now with a hint to
rebuild it.

Signed-off-by: Speculator55005 <50082482+fas89@users.noreply.github.com>
…xpose, in every bundle format

fluid bundle --env refused an overlay that changes the privacy block, but
an overlay that rewrote a relationship's fromColumns, and so took away the
tie that withholds a column, was written into a yaml or json bundle, and a
profile of that file published the column. fluid bundle --env now refuses
such an overlay in every format, as fluid profile --env does.

An overlay that adds an expose or a column the contract does not declare
could carry what the block withholds under a name it does not list. fluid
profile, fluid privacy-audit and fluid bundle now refuse it when the
contract carries a privacy block. The three checks live in one helper the
commands share.

Signed-off-by: Speculator55005 <50082482+fas89@users.noreply.github.com>
@github-actions github-actions Bot added ci Continuous integration and automation changes cli Changes to the CLI surface or implementation tests Test coverage or test infrastructure changes needs-docs Pull request needs a linked docs update or justification labels Dec 5, 2026
@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown

📄 Documentation Reminder

This PR appears to be missing a documentation reference. Our docs live in a separate repo.

Please update the PR description with one of:

  • Link a docs PR — check the "Docs PR linked" box and paste the URL
  • Mark as no docs needed — check "No docs needed" with a justification
  • Acknowledge docs TODO — check "Docs TODO" and create the docs PR before merge

See the Contributing Guide for details.

@fas89
fas89 marked this pull request as ready for review December 5, 2026 09:08
@fas89
fas89 merged commit df1d00e into main Dec 5, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continuous integration and automation changes cli Changes to the CLI surface or implementation needs-docs Pull request needs a linked docs update or justification tests Test coverage or test infrastructure changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant