Repository navigation
feat(OMN-14816): regenerate node_broker_disk_watermark_compute to canonical def-B #2354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jonahgabriel
merged 3 commits into
dev
from
jonah/omn-14816-node_broker_disk_watermark_compute-defb
Jul 20, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...i/adequacy_receipts/omnibase_infra.nodes.node_broker_disk_watermark_compute.handflip.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| { | ||
| "base_ref": "71ab1bf6deb4252edd9593f547dd5a4b4e60939b", | ||
| "canonical_handler_module": "omnibase_infra.nodes.node_broker_disk_watermark_compute.handlers.handler_broker_disk_watermark", | ||
| "legacy_handler_module": "omnibase_infra.nodes.node_broker_disk_watermark_compute.handlers.handler_broker_disk_watermark", | ||
| "node_id": "omnibase_infra.nodes.node_broker_disk_watermark_compute", | ||
| "parity": { | ||
| "selected_input_hashes": [ | ||
| "sha256:a717499da9403e40025b12891003a8849b9106e79d6cec5e8c20757852d2a2d2", | ||
| "sha256:5e6f7ee2fa56cbec23c8dc73be4019b28cb43c129f47828518da9ca6503cffb8", | ||
| "sha256:170122f07cbb1949c0a230f71ec3facd9847f5d2b4e33e9cb5c8e550209dc836", | ||
| "sha256:a60cefb436747aca50e48a192df8f4d5002c6a2bbefdd5279324f8c0c9cb1b55", | ||
| "sha256:3f29ef12329a6a7d1e6d25ef5e5d669465f12ce2fc7ae11f87aa4390b903350a" | ||
| ], | ||
| "status": "pass", | ||
| "test_ids": [ | ||
| "tests/unit/nodes/test_broker_disk_watermark_dispatch_entrypoint_omn14816.py::test_handler_exposes_handle_entrypoint", | ||
| "tests/unit/nodes/test_broker_disk_watermark_dispatch_entrypoint_omn14816.py::test_real_dispatch_callback_returns_p0_output", | ||
| "tests/unit/nodes/test_broker_disk_watermark_dispatch_entrypoint_omn14816.py::test_real_dispatch_callback_returns_clean_output" | ||
| ] | ||
| }, | ||
| "preserved_symbols": [ | ||
| "_classify", | ||
| "_real_docker_info", | ||
| "_real_disk_usage", | ||
| "_resolve_volume_mountpoint", | ||
| "HandlerBrokerDiskWatermark._probe_path" | ||
| ], | ||
| "receipt_schema": "handflip_proof.v1" | ||
| } |
25 changes: 25 additions & 0 deletions
25
scripts/ci/adequacy_receipts/omnibase_infra.nodes.node_broker_disk_watermark_compute.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| { | ||
| "branch_coverage_pct": 42.86, | ||
| "candidate_count": 6, | ||
| "coverage_target": 80.0, | ||
| "handler_module": "omnibase_infra.nodes.node_broker_disk_watermark_compute.handlers.handler_broker_disk_watermark", | ||
| "handler_module_sha256": "sha256:a1d3f32eaac23f505ea084a87218f8480f2ba6430bcfc674d83d4c413353a48e", | ||
| "meets_target": false, | ||
| "node_id": "omnibase_infra.nodes.node_broker_disk_watermark_compute", | ||
| "receipt_schema": "adequacy_receipt.v1", | ||
| "recorded_at": "2026-07-20T02:51:57.262774+00:00", | ||
| "recorder_schema": "adequacy_receipt.v1", | ||
| "selected_count": 5, | ||
| "selected_input_hashes": [ | ||
| "sha256:a717499da9403e40025b12891003a8849b9106e79d6cec5e8c20757852d2a2d2", | ||
| "sha256:5e6f7ee2fa56cbec23c8dc73be4019b28cb43c129f47828518da9ca6503cffb8", | ||
| "sha256:170122f07cbb1949c0a230f71ec3facd9847f5d2b4e33e9cb5c8e550209dc836", | ||
| "sha256:a60cefb436747aca50e48a192df8f4d5002c6a2bbefdd5279324f8c0c9cb1b55", | ||
| "sha256:3f29ef12329a6a7d1e6d25ef5e5d669465f12ce2fc7ae11f87aa4390b903350a" | ||
| ], | ||
| "uncovered_waiver": { | ||
| "reason": "OMN-14816 hand-flips node_broker_disk_watermark_compute to canonical def-B via a PURE RENAME probe_disk_watermark->handle (OMN-14781 path): the probe body is preserved byte-identically and the business-logic helpers (_classify / _probe_path / _real_docker_info / _real_disk_usage / _resolve_volume_mountpoint) are re-derived byte-identical base_ref<->HEAD by the ratchet from git. Equivalence is proven by that git-verbatim preservation plus the green runtime-dispatch parity tests over the selected input corpus, not by a broad branch-coverage claim over the legacy handler body; the real docker/shutil subprocess helpers (_real_docker_info / _real_disk_usage / _resolve_volume_mountpoint) are network/daemon-dependent and are exercised by the existing patched unit suite, so they are stubbed in the deterministic dispatch corpus.", | ||
| "uncovered_branch_count": 9 | ||
| }, | ||
| "volatile_mask": [] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
179 changes: 179 additions & 0 deletions
179
tests/unit/nodes/test_broker_disk_watermark_dispatch_entrypoint_omn14816.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,179 @@ | ||
| # SPDX-FileCopyrightText: 2025 OmniNode.ai Inc. | ||
| # SPDX-License-Identifier: MIT | ||
| # Copyright (c) 2026 OmniNode Team | ||
| """OMN-14816 — HandlerBrokerDiskWatermark is REACHABLE through the real dispatch path. | ||
|
|
||
| This is the RED-against-EXISTS-but-WRONG proof for the canonical def-B flip. | ||
|
|
||
| Before OMN-14816 the handler was contract-declared, wired, ingress-valid and CI-green | ||
| while exposing only the op-method ``probe_disk_watermark()`` and NO ``handle``. | ||
| Auto-wiring's ``_make_dispatch_callback`` looks for ``handle_async`` then ``handle``; | ||
| finding neither it binds ``_missing_handle``, which raises:: | ||
|
|
||
| ModelOnexError: Auto-wired handler HandlerBrokerDiskWatermark does not expose a | ||
| callable handle() or handle_async() dispatch entrypoint. | ||
|
|
||
| ...on the FIRST dispatch. These tests drive the REAL production dispatch callback over | ||
| the REAL handler class (no fake handler, no patched entrypoint), so they FAIL against | ||
| the entrypoint-less pre-flip handler and PASS only once the canonical def-B ``handle`` | ||
| exists. The node uses ``operation_match`` (no contract ``event_model``), so the callback | ||
| signature-introspects ``handle(inp: ModelBrokerDiskWatermarkInput)`` and coerces the | ||
| payload into that model at the adapter boundary (OMN-14716 parity with runtime_local). | ||
|
|
||
| Ticket: OMN-14816 | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import asyncio | ||
| from uuid import uuid4 | ||
|
|
||
| import pytest | ||
|
|
||
| from omnibase_core.models.events.model_event_envelope import ModelEventEnvelope | ||
| from omnibase_infra.enums import EnumDispatchStatus | ||
| from omnibase_infra.models.dispatch.model_dispatch_result import ModelDispatchResult | ||
| from omnibase_infra.nodes.node_broker_disk_watermark_compute.handlers.handler_broker_disk_watermark import ( | ||
| HandlerBrokerDiskWatermark, | ||
| ) | ||
| from omnibase_infra.nodes.node_broker_disk_watermark_compute.models.enum_disk_severity import ( | ||
| EnumDiskSeverity, | ||
| ) | ||
| from omnibase_infra.nodes.node_broker_disk_watermark_compute.models.model_broker_disk_watermark_input import ( | ||
| ModelBrokerDiskWatermarkInput, | ||
| ) | ||
| from omnibase_infra.nodes.node_broker_disk_watermark_compute.models.model_broker_disk_watermark_output import ( | ||
| ModelBrokerDiskWatermarkOutput, | ||
| ) | ||
| from omnibase_infra.runtime.auto_wiring.handler_wiring import _make_dispatch_callback | ||
|
|
||
| _GiB = 1024**3 | ||
| _DOCKER_INFO = {"DockerRootDir": "/data"} | ||
|
|
||
|
|
||
| def _p0_disk_usage(path: str) -> tuple[int, int, int]: | ||
| """96% used — above the p0 watermark (deterministic; no real docker/shutil).""" | ||
| total = 100 * _GiB | ||
| used = int(0.96 * total) | ||
| return total, used, total - used | ||
|
|
||
|
|
||
| def _healthy_disk_usage(path: str) -> tuple[int, int, int]: | ||
| """70% used — well below warn (deterministic).""" | ||
| total = 100 * _GiB | ||
| used = 70 * _GiB | ||
| return total, used, total - used | ||
|
|
||
|
|
||
| def _input(cid: object, disk_usage: object) -> ModelBrokerDiskWatermarkInput: | ||
| return ModelBrokerDiskWatermarkInput( | ||
| correlation_id=cid, # type: ignore[arg-type] | ||
| docker_info_runner=lambda: _DOCKER_INFO, | ||
| disk_usage_runner=disk_usage, # type: ignore[arg-type] | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.unit | ||
| def test_handler_exposes_handle_entrypoint() -> None: | ||
| """The bare invariant: auto-wiring can only bind handle/handle_async. | ||
|
|
||
| RED against the pre-OMN-14816 handler, which exposed only | ||
| ``probe_disk_watermark``. | ||
| """ | ||
| assert callable(getattr(HandlerBrokerDiskWatermark, "handle", None)), ( | ||
| "HandlerBrokerDiskWatermark exposes no handle(); auto-wiring binds " | ||
| "_missing_handle and every dispatch raises ModelOnexError." | ||
| ) | ||
| assert callable(getattr(HandlerBrokerDiskWatermark, "handle_async", None)), ( | ||
| "HandlerBrokerDiskWatermark must expose handle_async(); auto-wiring runs " | ||
| "the synchronous docker/disk probes through the event-loop dispatch path." | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.unit | ||
| @pytest.mark.asyncio | ||
| async def test_real_dispatch_callback_returns_p0_output() -> None: | ||
| """A real payload dispatched through the REAL callback reaches handle() and | ||
| returns a P0 classification. | ||
|
|
||
| Against the entrypoint-less handler this raises ModelOnexError (_missing_handle) | ||
| rather than returning a result — that raise IS the bug, caught here. | ||
| """ | ||
| cid = uuid4() | ||
| callback = _make_dispatch_callback(HandlerBrokerDiskWatermark()) | ||
| envelope: ModelEventEnvelope[object] = ModelEventEnvelope( | ||
| payload=_input(cid, _p0_disk_usage), | ||
| correlation_id=cid, | ||
| event_type="ModelBrokerDiskWatermarkInput", | ||
| ) | ||
|
|
||
| result = await callback(envelope) | ||
|
|
||
| assert result is not None, "Dispatch produced no result — handle() never ran." | ||
| assert isinstance(result, ModelDispatchResult) | ||
| assert result.status is EnumDispatchStatus.SUCCESS | ||
| assert len(result.output_events) == 1, ( | ||
| f"Expected exactly one ModelBrokerDiskWatermarkOutput; got " | ||
| f"{result.output_events!r}" | ||
| ) | ||
| out = result.output_events[0] | ||
| assert isinstance(out, ModelBrokerDiskWatermarkOutput) | ||
| assert out.correlation_id == cid | ||
| assert out.max_severity is EnumDiskSeverity.P0 | ||
| assert "docker-data-root" in out.p0_labels | ||
| assert out.docker_root_dir == "/data" | ||
|
|
||
|
|
||
| @pytest.mark.unit | ||
| @pytest.mark.asyncio | ||
| async def test_real_dispatch_callback_returns_clean_output() -> None: | ||
| """A healthy filesystem dispatched through the REAL callback returns CLEAN.""" | ||
| cid = uuid4() | ||
| callback = _make_dispatch_callback(HandlerBrokerDiskWatermark()) | ||
| envelope: ModelEventEnvelope[object] = ModelEventEnvelope( | ||
| payload=_input(cid, _healthy_disk_usage), | ||
| correlation_id=cid, | ||
| event_type="ModelBrokerDiskWatermarkInput", | ||
| ) | ||
|
|
||
| result = await callback(envelope) | ||
|
|
||
| assert result is not None | ||
| assert isinstance(result, ModelDispatchResult) | ||
| out = result.output_events[0] | ||
| assert isinstance(out, ModelBrokerDiskWatermarkOutput) | ||
| assert out.correlation_id == cid | ||
| assert out.max_severity is EnumDiskSeverity.CLEAN | ||
| assert out.p0_labels == () | ||
| assert out.warn_labels == () | ||
|
|
||
|
|
||
| @pytest.mark.unit | ||
| @pytest.mark.asyncio | ||
| async def test_real_dispatch_callback_runs_blocking_probe_in_worker_thread( | ||
| monkeypatch: pytest.MonkeyPatch, | ||
| ) -> None: | ||
| """The runtime callback binds handle_async, which delegates handle via to_thread.""" | ||
| cid = uuid4() | ||
| delegated: list[object] = [] | ||
|
|
||
| async def _record_to_thread( | ||
| func: object, /, *args: object, **kwargs: object | ||
| ) -> object: | ||
| delegated.append(func) | ||
| return func(*args, **kwargs) # type: ignore[misc] | ||
|
|
||
| monkeypatch.setattr(asyncio, "to_thread", _record_to_thread) | ||
|
|
||
| handler = HandlerBrokerDiskWatermark() | ||
| callback = _make_dispatch_callback(handler) | ||
| envelope: ModelEventEnvelope[object] = ModelEventEnvelope( | ||
| payload=_input(cid, _healthy_disk_usage), | ||
| correlation_id=cid, | ||
| event_type="ModelBrokerDiskWatermarkInput", | ||
| ) | ||
|
|
||
| result = await callback(envelope) | ||
|
|
||
| assert result is not None | ||
| assert delegated == [handler.handle] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.