Skip to content

feat(OMN-10917): delegation env read scanner in report mode - #1577

Merged
jonahgabriel merged 1 commit into
mainfrom
jonah/omn-10917-delegation-env-scanner
May 13, 2026
Merged

jonahgabriel merged 1 commit into
mainfrom
jonah/omn-10917-delegation-env-scanner

Conversation

@jonahgabriel

@jonahgabriel jonahgabriel commented May 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • AST-based scanner for os.environ/os.getenv in delegation-owned modules
  • Report mode (warn only) — enforce mode available for Wave 2 (OMN-10915)
  • Covers delegation orchestrator, routing reducer, delegate-skill orchestrator, LLM inference/completion/embedding effects, projection delegation, and adapters/llm/ paths
  • Deduplicates per-line violations with specificity preference (os.environ.get > os.environ)
  • Honors ONEX_FLAG_EXEMPT and ONEX_EXCLUDE inline skip tokens

Test plan

  • Scanner finds known violations in delegation modules (routing reducer, bifrost config loader, LLM adapters)
  • Scanner ignores test fixtures and non-delegation modules
  • Report mode does not exit non-zero
  • 25/25 unit tests passing

OMN-10917

Evidence-Source: OCC#982
Evidence-Ticket: OMN-10917

AST-based scanner detects os.environ/os.getenv reads in delegation-owned
modules. Report mode warns without blocking CI; enforce mode reserved for
Wave 2 after contract-driven config lands (OMN-10915).

Covers: node_delegation_orchestrator, node_delegation_routing_reducer,
node_delegate_skill_orchestrator, node_llm_inference_effect,
node_llm_completion_effect, node_projection_delegation, adapters/llm/.

Deduplicates per-line with specificity preference (os.environ.get > os.environ).
Honors ONEX_FLAG_EXEMPT and ONEX_EXCLUDE inline skip tokens.
@coderabbitai

coderabbitai Bot commented May 13, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@jonahgabriel has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 6 minutes and 13 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 69d203a0-2c02-4695-a410-b1411101cefd

📥 Commits

Reviewing files that changed from the base of the PR and between b6b233b and 2504911.

📒 Files selected for processing (2)
  • scripts/ci/check_delegation_env_reads.py
  • tests/ci/test_delegation_env_scanner.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jonah/omn-10917-delegation-env-scanner

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud

Copy link
Copy Markdown

@jonahgabriel
jonahgabriel merged commit 2bb3fa6 into main May 13, 2026
73 of 78 checks passed
@jonahgabriel
jonahgabriel deleted the jonah/omn-10917-delegation-env-scanner branch May 13, 2026 17:22
jonahgabriel added a commit that referenced this pull request May 13, 2026
…tract config (#1582)

* feat(OMN-10924): delegation runtime loads Kafka bootstrap from contract, not env

* feat(OMN-10925): replace LLM, bifrost, and security env vars with contract config

* feat(OMN-10926): delegation env scanner — enforce mode (#1583)

* feat(OMN-10926): delegation env scanner — enforce mode for omnibase_infra

- Add check_delegation_env_reads.py to scripts/ci/ (ast.Call-based scanner,
  correctly handles ONEX_FLAG_EXEMPT on closing ) of formatter-wrapped calls)
- Wire scanner in CI lint job as --mode enforce
- Annotate 12 remaining LLM-adapter env reads with ONEX_FLAG_EXEMPT marking
  them as Wave 3 migration targets (OMN-10915); scanner now exits 0 clean
- Add 17 scanner tests covering enforce mode, exempt annotations, and multi-line
  closing-paren skip token detection

OMN-10926

* feat(OMN-10927): proof of life — delegation boots from contract with zero env vars (#1585)

Integration test proving DelegationProfileConfigLoader bootstraps entirely from
contract YAML with all 10 delegation-path env vars explicitly unset. Verifies
contract load, event bus accessor, LLM backend accessor, security config accessor,
caching behavior, and — critically — that zero delegation env vars are read during
load. Final task in Part 1 (OMN-10915).

Co-authored-by: jonahgabriel <jonahgabriel@users.noreply.github.com>

---------

Co-authored-by: jonahgabriel <jonahgabriel@users.noreply.github.com>

* feat(OMN-10917): delegation env read scanner in report mode (#1577)

AST-based scanner detects os.environ/os.getenv reads in delegation-owned
modules. Report mode warns without blocking CI; enforce mode reserved for
Wave 2 after contract-driven config lands (OMN-10915).

Covers: node_delegation_orchestrator, node_delegation_routing_reducer,
node_delegate_skill_orchestrator, node_llm_inference_effect,
node_llm_completion_effect, node_projection_delegation, adapters/llm/.

Deduplicates per-line with specificity preference (os.environ.get > os.environ).
Honors ONEX_FLAG_EXEMPT and ONEX_EXCLUDE inline skip tokens.

Co-authored-by: jonahgabriel <jonahgabriel@users.noreply.github.com>

* fix(OMN-10925): clear llm security sonar hotspot

* test(OMN-10925): align delegation profile integration assertion

---------

Co-authored-by: jonahgabriel <jonahgabriel@users.noreply.github.com>
jonahgabriel added a commit that referenced this pull request May 14, 2026
…tract config (#1582)

* feat(OMN-10924): delegation runtime loads Kafka bootstrap from contract, not env

* feat(OMN-10925): replace LLM, bifrost, and security env vars with contract config

* feat(OMN-10926): delegation env scanner — enforce mode (#1583)

* feat(OMN-10926): delegation env scanner — enforce mode for omnibase_infra

- Add check_delegation_env_reads.py to scripts/ci/ (ast.Call-based scanner,
  correctly handles ONEX_FLAG_EXEMPT on closing ) of formatter-wrapped calls)
- Wire scanner in CI lint job as --mode enforce
- Annotate 12 remaining LLM-adapter env reads with ONEX_FLAG_EXEMPT marking
  them as Wave 3 migration targets (OMN-10915); scanner now exits 0 clean
- Add 17 scanner tests covering enforce mode, exempt annotations, and multi-line
  closing-paren skip token detection

OMN-10926

* feat(OMN-10927): proof of life — delegation boots from contract with zero env vars (#1585)

Integration test proving DelegationProfileConfigLoader bootstraps entirely from
contract YAML with all 10 delegation-path env vars explicitly unset. Verifies
contract load, event bus accessor, LLM backend accessor, security config accessor,
caching behavior, and — critically — that zero delegation env vars are read during
load. Final task in Part 1 (OMN-10915).

Co-authored-by: jonahgabriel <jonahgabriel@users.noreply.github.com>

---------

Co-authored-by: jonahgabriel <jonahgabriel@users.noreply.github.com>

* feat(OMN-10917): delegation env read scanner in report mode (#1577)

AST-based scanner detects os.environ/os.getenv reads in delegation-owned
modules. Report mode warns without blocking CI; enforce mode reserved for
Wave 2 after contract-driven config lands (OMN-10915).

Covers: node_delegation_orchestrator, node_delegation_routing_reducer,
node_delegate_skill_orchestrator, node_llm_inference_effect,
node_llm_completion_effect, node_projection_delegation, adapters/llm/.

Deduplicates per-line with specificity preference (os.environ.get > os.environ).
Honors ONEX_FLAG_EXEMPT and ONEX_EXCLUDE inline skip tokens.

Co-authored-by: jonahgabriel <jonahgabriel@users.noreply.github.com>

* fix(OMN-10925): clear llm security sonar hotspot

* test(OMN-10925): align delegation profile integration assertion

---------

Co-authored-by: jonahgabriel <jonahgabriel@users.noreply.github.com>
jonahgabriel added a commit that referenced this pull request May 14, 2026
… env vars (#1578)

* feat(OMN-10923): delegation profile config loader — contract-only, no env vars

Reads delegation runtime profile YAML and returns typed Pydantic models.
Zero env var reads during load; all config sourced from the contract file.
Caches result after first successful load. Blocked on omnibase_core PR #1072.

* fix(OMN-10923): add Any return type annotations with ONEX_EXCLUDE suppression

* refactor(OMN-10923): import delegation models from omnibase_compat

Switch DelegationProfileConfigLoader to import ModelDelegationRuntimeProfile
from omnibase_compat.contracts.delegation (omnibase_compat PR#87 / OMN-10919)
instead of omnibase_core.models.contracts. Add omnibase-compat>=0.3.1 as an
explicit direct dependency in pyproject.toml.

* test(OMN-10923): add delegation profile integration coverage

* contract(OMN-10923): add deploy gate evidence

* feat(OMN-10924): delegation runtime loads Kafka bootstrap from contract, not env (#1579)

Co-authored-by: jonahgabriel <jonahgabriel@users.noreply.github.com>

* chore(OMN-10923): retrigger blocked CI contexts

* feat(OMN-10925): replace LLM, bifrost, and security env vars with contract config (#1582)

* feat(OMN-10924): delegation runtime loads Kafka bootstrap from contract, not env

* feat(OMN-10925): replace LLM, bifrost, and security env vars with contract config

* feat(OMN-10926): delegation env scanner — enforce mode (#1583)

* feat(OMN-10926): delegation env scanner — enforce mode for omnibase_infra

- Add check_delegation_env_reads.py to scripts/ci/ (ast.Call-based scanner,
  correctly handles ONEX_FLAG_EXEMPT on closing ) of formatter-wrapped calls)
- Wire scanner in CI lint job as --mode enforce
- Annotate 12 remaining LLM-adapter env reads with ONEX_FLAG_EXEMPT marking
  them as Wave 3 migration targets (OMN-10915); scanner now exits 0 clean
- Add 17 scanner tests covering enforce mode, exempt annotations, and multi-line
  closing-paren skip token detection

OMN-10926

* feat(OMN-10927): proof of life — delegation boots from contract with zero env vars (#1585)

Integration test proving DelegationProfileConfigLoader bootstraps entirely from
contract YAML with all 10 delegation-path env vars explicitly unset. Verifies
contract load, event bus accessor, LLM backend accessor, security config accessor,
caching behavior, and — critically — that zero delegation env vars are read during
load. Final task in Part 1 (OMN-10915).

Co-authored-by: jonahgabriel <jonahgabriel@users.noreply.github.com>

---------

Co-authored-by: jonahgabriel <jonahgabriel@users.noreply.github.com>

* feat(OMN-10917): delegation env read scanner in report mode (#1577)

AST-based scanner detects os.environ/os.getenv reads in delegation-owned
modules. Report mode warns without blocking CI; enforce mode reserved for
Wave 2 after contract-driven config lands (OMN-10915).

Covers: node_delegation_orchestrator, node_delegation_routing_reducer,
node_delegate_skill_orchestrator, node_llm_inference_effect,
node_llm_completion_effect, node_projection_delegation, adapters/llm/.

Deduplicates per-line with specificity preference (os.environ.get > os.environ).
Honors ONEX_FLAG_EXEMPT and ONEX_EXCLUDE inline skip tokens.

Co-authored-by: jonahgabriel <jonahgabriel@users.noreply.github.com>

* fix(OMN-10925): clear llm security sonar hotspot

* test(OMN-10925): align delegation profile integration assertion

---------

Co-authored-by: jonahgabriel <jonahgabriel@users.noreply.github.com>

* fix(OMN-10923): address delegation profile review gates

* fix(OMN-10923): pin omnibase-compat to main for delegation contracts

The delegation profile config loader imports from
omnibase_compat.contracts.delegation, which was added in omnibase_compat
PR #87 (commit d86ee00). The previous lock pinned omnibase-compat to
v0.3.1 (commit ea4239d), predating the delegation module — causing
ModuleNotFoundError on the 13 new delegation loader tests in CI Splits
2/15 and 10/15.

Add an explicit [tool.uv.sources] pin plus an override-dependencies
entry (so omnimarket's older zip-archive pin doesn't conflict), locking
omnibase-compat at commit 51c39d8 (omnibase_compat main HEAD, contains
both delegation contract models and the versioned pricing contract).

Per ticket evidence: ticket OMN-10923 dod_evidence.

Resolves Tests Split 2/15 + Split 10/15 + CI Summary + Tests Gate.

* fix(OMN-10923): resolve sibling-compat URL conflict for omnibase-compat

CI was rejecting the install with "Requirements contain conflicting URLs
for package omnibase-compat":
- pyproject.toml [tool.uv] override-dependencies pinned to git+SHA
- check-sibling-compat.yml + ci.yml --overrides files added file://

uv treats CLI --overrides and pyproject override-dependencies as the same
constraint layer, so two URL specs for the same package fail resolution.

Drop the redundant file:// override lines in the three CI workflows; the
pyproject git+SHA pin already forces omnimarket's archive zip URL to be
replaced. The OMN-4315 sibling-compat semantics are preserved (we still
validate dry-run install of omniintelligence against pinned omnibase_infra).

Also invert tests/ci/test_delegation_env_scanner.py::test_scanner_finds_violations_in_repo
to assert ZERO violations (OMN-10925 removed all env reads from delegation
modules; the scanner's job is now to keep that state clean, not to find
known violations).

Rebased onto origin/main; conflict in scripts/ci/check_delegation_env_reads.py
resolved by accepting main's superseding implementation (multi-line skip
token detection from OMN-10925).

---------

Co-authored-by: jonahgabriel <jonahgabriel@users.noreply.github.com>
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