Skip to content

fix(ci): gate carto/main PRs on CARTO feature tests and harden the sync resolver - #124

Open
mateo-di wants to merge 2 commits into
carto/mainfrom
fix/upstream-sync-hardening
Open

fix(ci): gate carto/main PRs on CARTO feature tests and harden the sync resolver#124
mateo-di wants to merge 2 commits into
carto/mainfrom
fix/upstream-sync-hardening

Conversation

@mateo-di

Copy link
Copy Markdown
Collaborator

Summary

Long-term fix for the failure class behind the PR #121 regression (streaming_iterator.py resolved to upstream's version while auto-merged handler.py kept passing a CARTO-only kwarg — every streaming request 500'd, caught only by cloud-native integration tests days later). Root-cause analysis showed every sync automation "passed" because none of them execute code: presence-greps passed while wiring broke, and upstream's unit-test workflows never trigger for carto/main (their pull_request branch filters only cover upstream branches), so zero Python tests run on any PR here.

Changes

1. New carto-feature-tests.yml — execution gate on every carto/main PR

  • Derives its test scope from .github/carto-features.yml: for each feature file, runs the mirrored directory under tests/test_litellm/ (walking up to the nearest existing dir). Currently resolves to 6 dirs: litellm_core_utils, llms/azure, llms/databricks/chat, llms/oci/chat, llms/snowflake/chat, responses/litellm_completion_transformation.
  • Directory-level mirroring is deliberate: it pulls in tests for auto-merged sibling files (e.g. handler.py) whose wiring can break when a conflicted neighbor is resolved against them — exactly the PR 🔄 Upstream Sync: LiteLLM v1.92.0 #121 blind spot.
  • Plus an import litellm smoke check.
  • Deps via make install-test-deps (upstream-maintained target), actions pinned to the same SHAs upstream's workflows use.
  • Since carto-upstream-sync-ready-checker.yml requires all PR checks green before adding sync-ready, this gate automatically blocks the automated release chain (n8n → cloud-native PR) on failure.

2. Resolver manifest verification is now blocking

Previously warning-only ("Claude may have intentionally changed code") — it could never fail the build. Claude updates the manifest itself when upstream legitimately substitutes a feature (it did so correctly in PR #121 for the OCI tool-call feature), so a pattern still missing after resolution means a feature was dropped unaccounted for → fail before completing the merge.

3. Resolver prompt: cross-file wiring check directive

Instructs Claude to verify call sites and self.<attr> assignments across the whole package — including git-auto-merged files — after resolving each conflicted file, and to re-read all files of a multi-file manifest feature together. Documents the PR #121 incident inline as the motivating example.

Test plan

  • YAML parses; all run: blocks pass bash -n
  • Scope-derivation script dry-run against carto/main's manifest resolves to the 6 expected dirs
  • This PR itself triggers carto-feature-tests.yml (it touches .github/workflows/carto-feature-tests.yml) — verify the job runs green on carto/main's code
  • Next upstream-sync PR: confirm the gate runs and sync-ready waits for it

Follow-ups (separate, after PR #121 merges, to avoid conflicts with the open sync)

  • Enrich carto-features.yml with wiring-level patterns (e.g. the litellm_completion_request param + call-site patterns for Redis Session Storage, handler.py added to its files:)
  • Unit regression test pinning the handler→iterator wiring in tests/test_litellm/responses/litellm_completion_transformation/

…nc resolver

Three measures against the failure class that shipped the PR #121 wiring
regression (streaming_iterator.py resolved against upstream while the
auto-merged handler.py kept passing a CARTO-only kwarg - caught only by
cloud-native integration tests, 3 repos downstream):

1. New carto-feature-tests.yml: runs the unit suites mirroring every file
   listed in .github/carto-features.yml (plus an import smoke) on all PRs
   to carto/main. Upstream's test workflows never trigger for carto/main,
   so until now zero Python tests ran on any PR here. Directory-level
   mirroring deliberately includes auto-merged sibling files' tests. The
   ready-checker requires all checks green, so this also gates sync-ready.

2. Resolver's manifest verification is now blocking (exit 1) instead of
   warning-only. Claude updates the manifest itself when upstream
   legitimately substitutes a feature, so a missing pattern at this point
   means a feature was dropped unaccounted for.

3. Resolver prompt gains a cross-file wiring check directive: verify call
   sites and attribute assignments across the whole package (including
   git-auto-merged files) after resolving each conflicted file, and
   re-read every file of a multi-file manifest feature together.
@mateo-di mateo-di self-assigned this Jul 17, 2026
The runner's bare python3 has no PyYAML; the project venv does (litellm
core dependency).
@mateo-di

Copy link
Copy Markdown
Collaborator Author

Status: blocked on #121 merging first — and the red check here is the gate working as intended.

The CARTO feature unit tests run on this PR fails with 21 test failures — all of them pre-existing drift on carto/main between its code (v1.83.14 base + assorted backports) and its test files (which expect newer internals, e.g. _queue_tool_call_delta_events, OCI digest-synthesis behavior). This drift was invisible until now because no Python test has ever run against carto/main PRs — the exact gap this workflow closes.

Evidence it's drift and not a workflow bug: the identical suites pass 971/971 on the upstream-sync/v1.92.0 branch (PR #121), where code and tests are mutually consistent.

Merge order: #121 first (replaces both code and tests with the consistent v1.92.0 state), then re-run checks here — the pull_request merge-ref will then test the post-sync state and should go green. Residual risk to verify on that re-run: the derived scope includes all of tests/test_litellm/litellm_core_utils/ (beyond what was run locally), pure upstream code that's green in upstream CI.

mateo-di added a commit that referenced this pull request Aug 4, 2026
…sts (#125)

* fix(ci): restore agent reaction to test failures via CARTO Feature Tests

The upstream-sync fixer and ready-checker were wired to react to "LiteLLM
Mock Tests" and "LiteLLM Linting" workflow_run completions. Both are dead
on carto/main: Mock Tests is upstream-deprecated (workflow_dispatch only)
and Linting only triggers for upstream's own branches. So no test ever
ran on a carto/main sync PR, the fixer never fired, and the only failure
signal was cloud-native integration tests three repos downstream (see the
v1.92.0 sync, where three broken CARTO wirings shipped that way).

Wire both workflows to "CARTO Feature Tests" (carto-feature-tests.yml,
CARTO's own unit-test gate) instead:

- ready-checker: replace the two dead names with Docker CI + Feature
  Tests. workflow_run only re-invokes ready-checker when a listed
  workflow completes, so listing Feature Tests is what makes sync-ready
  wait for the tests rather than just the build.
- ci-fixer: same trigger list; swap the log-extraction query from the
  dead Mock Tests workflow to Feature Tests; align the prompt's local
  verification with the gate's real command (uv + make install-test-deps
  + manifest-derived scope) instead of the stale pip/pytest invocation.

Supersedes #123 (which only removed the dead names). Depends on the
CARTO Feature Tests workflow from #124.

* docs(ci): align sync resolver/fixer/analyzer prompts with wiring-aware reasoning (#126)

The v1.92.0 sync shipped three CARTO features that passed every automated
check yet were functionally broken (dropped call site across an auto-merged
file, an orphaned helper with no caller, and a store/lookup key that
mismatched after upstream changed id encoding). None were catchable by the
prompts' existing "does the pattern still grep" verification, and two of the
prompts' heuristics actively caused the loss. This aligns the prompts with
the reasoning that actually found and fixed those bugs.

Resolver prompt:
- Verbatim-first rule: restore CARTO blocks byte-identical from carto/main
  (diff-verified); adapt only where an upstream API change makes verbatim
  impossible, minimally and marked # CARTO PATCH. Replaces "preserve the
  BEHAVIOR, not necessarily the exact file versions", which licensed the
  paraphrase that dropped a session read-path.
- Remove harmful heuristics: delete "bigger file = probably correct" and
  reframe "upstream TAG code WORKS" as "works for upstream's call graph, not
  necessarily CARTO's - re-verify callers, attributes, data formats".
- Add three post-resolution checks the grep cannot do: orphan sweep
  (helper with no caller), cross-file wiring (auto-merged siblings), and
  cross-version data-flow (format drift across the version boundary).
- Reference the regression canaries as the definition of "wired correctly".

Fixer prompt:
- Same verbatim-first rule, orphan sweep, and call-graph reframing.
- Manifest-aware loop guard: the "3+ fixes -> sync entire file from upstream"
  escape hatch now excludes manifest files; for those, take upstream as base
  and re-apply the CARTO block verbatim (blind sync is how wirings get erased).
- Log extraction / verification already retargeted to CARTO Feature Tests in
  the agent-reaction PR this is stacked on.

Analyzer prompt:
- Judge PRESERVED_CARTO by WIRING, not string presence: an orphaned helper,
  a missing call site, or broken data-flow is INCORRECTLY_DROPPED even when
  the def/pattern greps OK. It had reported the dead session read as PASS.

CARTO_UPSTREAM_SYNC.md:
- New troubleshooting section documenting the three v1.92.0 wiring-loss
  classes with detection commands.

Manifest wiring-pattern enrichment (adding call-site patterns to
carto-features.yml) is deliberately deferred to a follow-up to avoid
clobbering the manifest changes on the open v1.92.0 sync PR.
@mateo-di
mateo-di marked this pull request as ready for review August 4, 2026 12:24
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.

1 participant