Skip to content

[VPEX][5c] local-env: --check cache purity, greenfield name, and databricks-connect insertion#5854

Merged
rugpanov merged 2 commits into
mainfrom
dbconnect/05c-check-nocache
Jul 14, 2026
Merged

[VPEX][5c] local-env: --check cache purity, greenfield name, and databricks-connect insertion#5854
rugpanov merged 2 commits into
mainfrom
dbconnect/05c-check-nocache

Conversation

@rugpanov

@rugpanov rugpanov commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Why

Follow-up fixes to the local-env python sync pipeline (#5851, now merged), from codex and reviewer feedback. Three independent correctness issues in the merge / dry-run paths, none of which the pipeline PR's own tests caught:

  1. --check still wrote to disk. FetchConstraints populated the on-disk constraint cache on every successful live fetch, so a dry run mutated the cache directory even though the pipeline skips every other write-side step under --check.
  2. Greenfield rendered an invalid project name. filepath.Base(ProjectDir) is . when run from the project's own directory (and / at root) — not a valid PEP 621/508 name, so uv sync rejected the generated pyproject.toml.
  3. Default-mode sync failed for an existing project without a databricks-connect pin. The merge only replaced an existing pin; it never inserted one, so an existing pyproject.toml with a dev group but no databricks-connect was written back unchanged, uv installed nothing, and validation failed with E_VALIDATE. Greenfield worked only because RenderFreshPyproject inserts the pin — a path the existing-project merge lacked.

What

  • --check no cache write — thread a writeCache bool through FetchConstraints; the pipeline passes !p.Check. An existing cache is still read for offline fallback (reading is not a mutation); only the write is suppressed under a dry run.
  • Valid greenfield nameprojectName() resolves ./""/root via filepath.Abs before taking the base and sanitizes to a valid PEP 508 identifier (non-alphanumeric runs collapse to -, trimmed), falling back to app when nothing usable remains.
  • Insert databricks-connect when absentmergeDatabricksConnect now inserts the pin into [dependency-groups].dev (single- or multi-line array), creating the dev key and the [dependency-groups] table when absent, mirroring RenderFreshPyproject. Constraints-only (empty value) stays a no-op. Detection is comment-aware and spans the whole array, so a pin on the dev = [ line or one carrying a trailing comment is rewritten in place rather than duplicated (a duplicate-pin bug codex caught in the first cut of this change). The insert path is idempotent.

Testing strategy

  • --check purity: TestFetchConstraintsSkipsCacheWriteWhenDisabled, and TestPipelineCheckMutatesNothing strengthened to assert the cache dir stays empty; TestPipelineCheckReRunPlanMatchesRealRun for accurate re-run plans.
  • Greenfield name: TestProjectName, TestPipelineGreenfieldFromDotDirRendersValidName.
  • databricks-connect insertion: TestMergeInserts{DatabricksConnectMultiLine,SingleLine,EmptyDev,DevKeyWhenAbsent,DependencyGroupsWhenAbsent}, no-duplicate regressions TestMergeReplacesDatabricksConnect{OnDevLine,WithTrailingComment}, and TestMergeConstraintsOnlyDoesNotInsertDatabricksConnect.
  • Gates: go build, go test, golangci-lint (0 issues), deadcode, gofmt — all green.

About this stack

Follow-up to the databricks local-env python sync stack; targets main now that the pipeline PR (#5851) has merged.

This pull request and its description were written by Isaac.

@rugpanov rugpanov temporarily deployed to test-trigger-is July 8, 2026 11:02 — with GitHub Actions Inactive
@rugpanov rugpanov temporarily deployed to test-trigger-is July 8, 2026 11:02 — with GitHub Actions Inactive
@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Integration test report

Commit: 0eb1236

Run: 29321919460

Env 🔄​flaky 💚​RECOVERED 🙈​SKIP ✅​pass 🙈​skip Time
💚​ aws linux 4 4 230 1084 5:18
💚​ aws windows 4 4 232 1082 7:13
💚​ aws-ucws linux 4 4 316 1001 5:39
💚​ aws-ucws windows 4 4 318 999 7:28
🔄​ azure linux 2 2 4 230 1083 6:53
🔄​ azure windows 2 2 4 232 1081 9:25
💚​ azure-ucws linux 4 4 318 998 5:39
💚​ azure-ucws windows 4 4 320 996 7:16
💚​ gcp linux 4 4 229 1085 5:06
💚​ gcp windows 4 4 231 1083 6:59
8 interesting tests: 4 SKIP, 2 RECOVERED, 2 flaky
Test Name aws linux aws windows aws-ucws linux aws-ucws windows azure linux azure windows azure-ucws linux azure-ucws windows gcp linux gcp windows
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
🙈​ TestAccept/bundle/invariant/no_drift 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_endpoints/drift/recreated_same_name 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_indexes/recreate/embedding_dimension 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/ssh/connection 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
💚​ TestFetchRepositoryInfoAPI_FromRepo 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
🔄​ TestFetchRepositoryInfoAPI_FromRepo/root 💚​R 💚​R 💚​R 💚​R 🔄​f 🔄​f 💚​R 💚​R 💚​R 💚​R
🔄​ TestFetchRepositoryInfoAPI_FromRepo/subdir 💚​R 💚​R 💚​R 💚​R 🔄​f 🔄​f 💚​R 💚​R 💚​R 💚​R
Top 10 slowest tests (at least 2 minutes):
duration env testname
6:23 aws-ucws windows TestAccept
6:02 gcp windows TestAccept
5:59 azure-ucws windows TestAccept
5:59 aws windows TestAccept
5:57 azure windows TestAccept
2:54 gcp linux TestAccept
2:51 azure linux TestAccept
2:49 aws linux TestAccept
2:48 aws-ucws linux TestAccept
2:43 azure-ucws linux TestAccept

@rugpanov rugpanov force-pushed the dbconnect/05b-pipeline branch from af9d41b to c2e8b69 Compare July 8, 2026 14:44
@rugpanov rugpanov force-pushed the dbconnect/05c-check-nocache branch from 8b12b87 to 4716210 Compare July 8, 2026 14:44
@rugpanov rugpanov temporarily deployed to test-trigger-is July 8, 2026 14:44 — with GitHub Actions Inactive
@rugpanov rugpanov temporarily deployed to test-trigger-is July 8, 2026 14:44 — with GitHub Actions Inactive

@anton-107 anton-107 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.

Approving. Tight, correct follow-up: writeCache threaded through FetchConstraints with the pipeline passing !p.Check, and an existing cache is still read for offline fallback (reading isn't a mutation) — exactly right. Test pair is the right shape: unit (TestFetchConstraintsSkipsCacheWriteWhenDisabled) plus the strengthened end-to-end TestPipelineCheckMutatesNothing asserting the cache dir stays empty. All call sites updated. No findings.

@rugpanov rugpanov force-pushed the dbconnect/05c-check-nocache branch from 4716210 to d6462fd Compare July 9, 2026 14:06
@rugpanov rugpanov temporarily deployed to test-trigger-is July 9, 2026 14:06 — with GitHub Actions Inactive
@rugpanov rugpanov temporarily deployed to test-trigger-is July 9, 2026 14:06 — with GitHub Actions Inactive
@rugpanov rugpanov force-pushed the dbconnect/05c-check-nocache branch from d6462fd to 3127207 Compare July 10, 2026 13:37
@rugpanov rugpanov temporarily deployed to test-trigger-is July 10, 2026 13:37 — with GitHub Actions Inactive
@rugpanov rugpanov temporarily deployed to test-trigger-is July 10, 2026 13:37 — with GitHub Actions Inactive
@rugpanov rugpanov temporarily deployed to test-trigger-is July 13, 2026 14:23 — with GitHub Actions Inactive
@rugpanov rugpanov temporarily deployed to test-trigger-is July 13, 2026 14:23 — with GitHub Actions Inactive
Base automatically changed from dbconnect/05b-pipeline to main July 13, 2026 14:30
@rugpanov rugpanov force-pushed the dbconnect/05c-check-nocache branch from 4bd0477 to b09b9ce Compare July 13, 2026 14:30
@rugpanov

Copy link
Copy Markdown
Contributor Author

codex review [P2] — duplicate databricks-connect pins — fixed in b09b9ce.

Confirmed the bug (reproduced: 2 pins for both dev = ["databricks-connect~=16", opening-line arrays and elements with a trailing comment). The multi-line detection used an anchored per-line regex (dbconnectLineRe, …"$) that started scanning at devStart+1, so a pin on the dev = [ line or one carrying a trailing comment was missed → the insert path added a second pin.

Fix: the multi-line branch now scans the whole array span (devStart..arrayLast), detects an existing databricks-connect token comment-aware (via dbconnectTokenRe), and rewrites it in place; it inserts only when no element exists anywhere. Removed the now-unused dbconnectLineRe. Regression tests: TestMergeReplacesDatabricksConnectOnDevLine, TestMergeReplacesDatabricksConnectWithTrailingComment. All gates green.

A --check dry run must not mutate disk, but FetchConstraints wrote the
fetched artifact into the cache dir on every successful live fetch — so a
dry run still populated the cache whenever it was writable, even though the
pipeline skips every other write-side step under --check.

Thread a writeCache flag through FetchConstraints; the pipeline passes
!p.Check. An existing cache is still read for offline fallback, since
reading is not a mutation. Assert both directly (FetchConstraints with
writeCache=false leaves the cache dir empty) and end-to-end (the --check
pipeline test now checks the cache dir stays empty too).

Reported by codex review of the pipeline PR.

Co-authored-by: Isaac
@rugpanov rugpanov force-pushed the dbconnect/05c-check-nocache branch from b09b9ce to ad1b317 Compare July 13, 2026 14:42
@rugpanov rugpanov temporarily deployed to test-trigger-is July 13, 2026 14:43 — with GitHub Actions Inactive
@rugpanov rugpanov temporarily deployed to test-trigger-is July 13, 2026 14:43 — with GitHub Actions Inactive
@rugpanov rugpanov temporarily deployed to test-trigger-is July 13, 2026 14:43 — with GitHub Actions Inactive
@rugpanov rugpanov temporarily deployed to test-trigger-is July 13, 2026 14:43 — with GitHub Actions Inactive
@rugpanov rugpanov changed the title [VPEX][5c] Skip constraint cache writes under --check [VPEX][5c] local-env: --check cache purity, greenfield name, and databricks-connect insertion Jul 14, 2026
@rugpanov rugpanov force-pushed the dbconnect/05c-check-nocache branch from ad1b317 to e257732 Compare July 14, 2026 09:00
@rugpanov

Copy link
Copy Markdown
Contributor Author

codex review [P3] — trailing-comment mutation — fixed in e257732.

Confirmed (reproduced: a dev element with a comment mentioning a quoted "databricks-connect…" token had the comment rewritten too). The multi-line replace applied dbconnectTokenRe to the whole line. Now it splits at commentStart and rewrites only the code portion, re-appending the comment byte-for-byte — matching the single-line branch. Regression test TestMergePreservesCommentMentioningDatabricksConnect. All gates green.

@rugpanov rugpanov temporarily deployed to test-trigger-is July 14, 2026 09:00 — with GitHub Actions Inactive
@rugpanov rugpanov temporarily deployed to test-trigger-is July 14, 2026 09:00 — with GitHub Actions Inactive
Address two correctness nits from review of the pipeline PR (#5851). Since
that PR was already queued to merge, the fixes land here in the follow-up.

- mergeDatabricksConnect only ever *replaced* an existing databricks-connect
  element, so a default-mode sync of an existing project that didn't already
  pin databricks-connect wrote the file back with no pin; uv installed nothing
  and validate failed with E_VALIDATE. It now *inserts* the pin — into the dev
  array (single- or multi-line), creating the dev key and the
  [dependency-groups] table when absent — mirroring RenderFreshPyproject.
  Constraints-only (empty value) stays a no-op; the insert path is idempotent.

- Greenfield rendered name = filepath.Base(ProjectDir), which is "." when run
  from the project's own directory (and "/" at root) — not a valid PEP 621
  name, so uv sync rejected the file. projectName() now resolves via
  filepath.Abs and sanitizes to a valid PEP 508 identifier, falling back to a
  default when nothing usable remains.

Co-authored-by: Isaac
@rugpanov rugpanov force-pushed the dbconnect/05c-check-nocache branch from e257732 to 0eb1236 Compare July 14, 2026 09:28
@rugpanov

Copy link
Copy Markdown
Contributor Author

isaac review — 2 MAJOR bugs in the databricks-connect insert path — both fixed in 0eb1236.

Both reproduced and confirmed real:

  1. Non-canonical spelling → duplicate pin. Detection used a raw case/hyphen-sensitive substring, but the artifact side matches under PEP 503 (isDatabricksConnectDep). An existing databricks_connect / Databricks-Connect / databricks.connect pin escaped detection, so the insert path appended a second element → conflicting specifiers → uv sync fails. Fixed: replaceDbconnectElement now matches quoted elements under PEP 503 normalization (reusing isDatabricksConnectDep), applied at all detect/replace sites; removed the old dbconnectTokenRe. Test TestMergeRewritesNonCanonicalDatabricksConnectSpelling.

  2. Insert produced invalid TOML when the last element had no trailing comma. TOML allows omitting the final comma; the insert appended a new element after it with no separator. Fixed: ensureTrailingComma adds the separator to the prior last element (preserving whitespace/comment) before inserting. Test TestMergeInsertsCommaWhenLastElementHasNone (+ idempotency round-trip).

All gates green (build, test, lint 0, deadcode, gofmt).

@rugpanov rugpanov temporarily deployed to test-trigger-is July 14, 2026 09:29 — with GitHub Actions Inactive
@rugpanov rugpanov temporarily deployed to test-trigger-is July 14, 2026 09:29 — with GitHub Actions Inactive
@rugpanov rugpanov added this pull request to the merge queue Jul 14, 2026
Merged via the queue into main with commit 65dacaf Jul 14, 2026
23 checks passed
@rugpanov rugpanov deleted the dbconnect/05c-check-nocache branch July 14, 2026 10:08
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.

3 participants