test(integrations): add registry self-consistency invariants#2773
Conversation
Greptile code reviewThis repo uses Greptile for automated review. Before merge, aim for Confidence Score: 5/5 with zero unresolved review threads — see CONTRIBUTING.md. Run a review — add a PR comment with: Give it ~5-10 minutes (sometimes longer) for results, then fix feedback and re-trigger until you reach Confidence Score: 5/5. Optional: automate with the greploop skill. |
Greptile SummaryAdds
Confidence Score: 5/5Test-only change; no production code is touched and the new tests cannot break any existing behavior. All five invariants are logically sound and the xfail strategy is appropriate. The only finding is a misleading assertion message with no runtime impact. No files require special attention beyond the minor message fix in test_registry_invariants.py. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
subgraph Registry["app/integrations/registry.py"]
SPECS["INTEGRATION_SPECS"]
SETUP["SUPPORTED_SETUP_SERVICES"]
VERIFY["SUPPORTED_VERIFY_SERVICES"]
SPECS --> SETUP
SPECS --> VERIFY
end
subgraph CLI["app/integrations/cli.py"]
HANDLERS["_HANDLERS dict"]
SETUP_SERVICES["_SETUP_SERVICES (intersection)"]
HANDLERS --> SETUP_SERVICES
SETUP --> SETUP_SERVICES
end
subgraph Invariants["test_registry_invariants.py"]
T1["test_setup_orders_are_unique (xfail)"]
T2["test_verify_orders_are_unique (xfail)"]
T3["test_every_cli_handler_is_registered_in_registry"]
T4["test_every_verifier_has_a_verify_order"]
end
subgraph Existing["test_registry.py"]
T5["test_every_setup_spec_has_handler"]
end
SPECS -->|setup_order uniqueness| T1
SPECS -->|verify_order uniqueness| T2
HANDLERS -->|orphan handler check| T3
SETUP -->|orphan handler check| T3
SPECS -->|verifier completeness| T4
SETUP -->|forward direction| T5
HANDLERS -->|forward direction| T5
Reviews (3): Last reviewed commit: "test(integrations): fold duplicate handl..." | Re-trigger Greptile |
|
@greptile review |
kespineira (Tracer-Cloud#2773) flagged that test_every_setup_service_has_a_cli_handler asserts the same invariant as the existing test_every_setup_spec_has_handler added in Tracer-Cloud#2537. Both check that every SUPPORTED_SETUP_SERVICES entry has a matching _HANDLERS key. Fold the descriptive failure message (offending-service list) into the existing test in tests/integrations/test_registry.py and drop the duplicate from test_registry_invariants.py. Update the module docstring to point at the canonical forward-direction test. The reverse-direction (orphan handler) test in test_registry_invariants.py is retained — it covers an invariant the existing test does not check.
|
@greptile review |
Add tests/integrations/test_registry_invariants.py with five static assertions over INTEGRATION_SPECS and the CLI _HANDLERS dict: - setup_order uniqueness across specs - verify_order uniqueness across specs - every setup-enabled service has a CLI handler (and vice versa) - every verifier has a verify_order (so positional CLI works) The two order tests are marked xfail(strict=False) because main has 9 collisions (jenkins+dagster being the latest, landed after the audit). The renumber PR flips both to strict / removes the markers. Refs Tracer-Cloud#2772
- _duplicates returns set[int]; count was never consumed by callers - Replace misleading "Click" wording in two assertion messages. app/integrations/cli.py uses a hand-rolled sys.argv parser plus questionary.select, not Click. New wording names the real failure modes: silent _SETUP_SERVICES exclusion and the cmd_setup "Usage: setup <service>" error.
kespineira (Tracer-Cloud#2773) flagged that test_every_setup_service_has_a_cli_handler asserts the same invariant as the existing test_every_setup_spec_has_handler added in Tracer-Cloud#2537. Both check that every SUPPORTED_SETUP_SERVICES entry has a matching _HANDLERS key. Fold the descriptive failure message (offending-service list) into the existing test in tests/integrations/test_registry.py and drop the duplicate from test_registry_invariants.py. Update the module docstring to point at the canonical forward-direction test. The reverse-direction (orphan handler) test in test_registry_invariants.py is retained — it covers an invariant the existing test does not check.
def7612 to
10c5f36
Compare
|
🎯 Bullseye. @Davidson3556 opened a PR, kept the vibes clean, and got it merged. Absolute cinema. 🎬 👋 Join us on Discord - OpenSRE : hang out, contribute, or hunt for features and issues. Everyone's welcome. |
…ions (#2791) Pre-existing main carried 9 collisions surfaced by the registry contract tests (#2773): 4 setup_order ties and 5 verify_order ties. Renumber the later-added spec in each collision pair (preserving first-occurrence in source = original number) to a free slot at the high end of the range, with one fill-in at verify_order=6 (the only existing gap): setup_order tracer 12->25, telegram 19->26, whatsapp 19->27, mysql 20->28, dagster 24->29 verify_order victoria_logs 2->6, kafka 22->37, mysql 27->38, openclaw 28->39, dagster 36->40 The two xfail markers on test_setup_orders_are_unique and test_verify_orders_are_unique are now removed since both assertions pass on this state. Any future PR that reintroduces a collision will fail those tests strictly. Closes #2790

Fixes #2772
Describe the changes you have made in this PR -
Adds
tests/integrations/test_registry_invariants.pywith five static assertions over the integration registry and the CLI dispatch:test_setup_orders_are_unique— no two services share asetup_ordertest_verify_orders_are_unique— no two services share averify_ordertest_every_setup_service_has_a_cli_handler— everySUPPORTED_SETUP_SERVICESentry has a_HANDLERSentry inapp/integrations/cli.pytest_every_cli_handler_is_registered_in_registry— reverse direction, no orphan handlerstest_every_verifier_has_a_verify_order— every spec withverifier=...has averify_orderso the positional CLI worksThe two order tests are marked
xfail(strict=False)becausemaincurrently has 9 pre-existing collisions (4 setup + 5 verify), which the renumber PR will clear. After that lands, the markers flip to strict (or are removed entirely) so the gate is permanent. The other three tests pass onmaintoday.No production code changes.
tests/integrations/is already routed bymake test-scope, so this naturally gates any PR that touchesapp/integrations/.Demo/Screenshot for feature changes and bug fixes -
Default CI run (xfail markers in effect, what this PR posts):
Screen.Recording.2026-06-08.at.02.35.35.mov
The collision payload names every offending service, so the renumber author has the full punch list inline.
Code Understanding and AI Usage
Did you use AI assistance (ChatGPT, Claude, Copilot, etc.) to write any part of this code?
If you used AI assistance:
Explain your implementation approach:
The registry in
app/integrations/registry.pyand the CLI handler dict inapp/integrations/cli.pyare two halves of the same contract. They have to stay in sync, but nothing enforces that. So when someone adds a new integration, they can pick asetup_orderthat collides with another service, or skip wiring a_HANDLERSentry, and the drift only surfaces when a user runsopensre integrations setup/verify <svc>and hits a Click rejection or non-deterministic ordering. That is howmainended up with 9 collisions today, including ajenkins/dagstercollision that landed after muddlebee's audit in#opensre-integrations.The tests are pure registry introspection. No integration is probed, no subprocess is spawned, no fixtures are loaded. Five invariants total, runs in under 2 seconds.
I considered putting the check in a standalone CI script (or a pre-commit hook) instead of a pytest file. Two reasons I went with tests:
make test-scopealready routes anything undertests/integrations/to run on PRs that touchapp/integrations/, so this naturally gates the right diffs without any new CI wiring; and the assertion messages name the offending services inline, which is friendlier than a script logging to stderr.The two order-uniqueness tests use
xfail(strict=False)rather thanskipdeliberately.skipwould silently drop them.xfail(strict=False)keeps them collecting and visible in CI output, so when the renumber PR flips the registry clean, the tests becomeXPASSand the author flips the markers to strict (or removes them) in the same PR. That is the planned signal.Helper:
_duplicates(values)returns a{value: count}map of only the duplicated entries. Both order-uniqueness tests use it so the assertion output formats consistently across both axes.Checklist before requesting a review