Skip to content

feat: evidence-grade NIM discovery + all-modality cost-quality benchmark - #90

Draft
seonghobae wants to merge 159 commits into
fix/atheris-interpreter-lockfrom
claude/nim-all-models-support-fecb0b
Draft

feat: evidence-grade NIM discovery + all-modality cost-quality benchmark#90
seonghobae wants to merge 159 commits into
fix/atheris-interpreter-lockfrom
claude/nim-all-models-support-fecb0b

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Purpose

Implement issue #86 as a provider-neutral, evidence-grade NVIDIA NIM discovery and benchmark harness while preserving standalone operation and the modular CWL MSA boundary.

Exact integration identity

The branch descends from the exact current #96 head. Every check, review, or approval associated with a predecessor feature head is historical only and must not be reused.

Current-head verification state

Exact-head repository workflows completed successfully:

  • Tests run 31073765240;
  • Fuzz run 31073765223;
  • Security run 31073765231;
  • CodeRabbit commit status: successful.

Trusted organization-central 100% statement/branch/docstring/package evidence, Security Scan, SAST Semgrep, current-head OpenCode/Noema/Strix review, and qualifying independent non-author approval are not yet complete for this exact head. The central prerequisite remains ContextualWisdomLab/.github#759; after it merges, #96 must regenerate authoritative exact-head coverage and review evidence, merge first, and this PR must then be retargeted to the integrated main and fully revalidated. Queued, pending, cancelled, predecessor-head, stale-base, synthetic-merge, or absent evidence does not count as success.

Implemented scope

  • dynamically discover the OpenAI-compatible GET /v1/models catalog without a hard-coded authoritative inventory;
  • deduplicate and provenance-hash catalog evidence;
  • compute one complete request plan after catalog discovery and before capability egress;
  • fail closed before the first capability probe unless the hard cap covers catalog discovery, every discovered model × every required capability, and the full equal-budget evaluation reserve;
  • probe every discovered model under deterministic bounded concurrency;
  • cover chat, completion, Responses, embeddings, image, valid deterministic one-frame H.264 video, audio understanding, transcription, and speech contracts;
  • classify supported, unsupported, throttled, unavailable, failed, and malformed probes with machine-readable reasons;
  • compare direct, route_once, bounded conduct, and reviewed cheapest-worker policies under one common prompt-plus-completion token allowance and maximum-call envelope;
  • separate reviewed current free-to-caller evidence from reviewed hypothetical paid scenarios, reject stale or incomplete pricing evidence before provider egress, never infer prices, and leave unavailable prices unknown;
  • record provenance, uncertainty, evidence sufficiency, task completeness, configured-versus-observed budgets, request-plan counts, paired comparisons, and Pareto frontiers in secret-redacted JSON/CSV/Markdown artifacts;
  • preserve every policy/task cell's exact step, role, agent, and model assignments in deterministic CSV evidence with JSON/CSV identity parity and malformed or duplicate assignment rejection;
  • transactionally publish the supported CLI's complete JSON/CSV/Markdown evidence set through a hidden sibling staging directory, exact complete-set validation, same-filesystem directory renames, ordinary-failure rollback, residue cleanup, sole-backup crash recovery, ambiguous-backup fail-closed behavior, and final-path-only success output;
  • provide deterministic no-egress dry runs, fuzz coverage, architecture/evaluation doctoring, APA 7 references, and CHANGELOG.md entries.

Security and import boundary

  • provider connections dial only validation-time globally routable addresses;
  • the original hostname remains the HTTP authority and TLS SNI/certificate-verification name;
  • redirects and ambient proxy routing are disabled;
  • provider responses are bounded to 8 MiB;
  • credentials are neither forwarded outside the validated origin nor serialized;
  • dry-run jobs receive no NVIDIA_NIM_API_KEY; only the bounded live job owns the GitHub Secret binding;
  • optional benchmark and CSV-evidence adapters remain lazy; ordinary package import does not mutate benchmark globals;
  • the CSV/publication adapter accepts no credentials, opens no sockets, and suppresses the CLI success payload when enrichment, validation, or publication fails;
  • no GitHub Copilot credential path is introduced.

Evidence contracts

Test-first regressions cover:

  1. complete all-model plan preflight and zero partial egress when one request short;
  2. deterministic bounded concurrency and reserved evaluation capacity;
  3. valid deterministic media fixtures;
  4. exclusion and explicit reporting of zero-success policies from Pareto frontiers;
  5. complete schema validation before artifact publication;
  6. preservation of valid positive sub-second timeouts;
  7. normalization of catalog depth failures to CatalogDiscoveryError;
  8. fixture-safe direct execution of the standalone benchmark test module;
  9. Atheris import instrumentation of the NIM catalog parser;
  10. completion-dependent evidence-status semantics;
  11. deterministic complete CSV model-assignment evidence;
  12. fresh-target publication failure with no visible partial set;
  13. byte-identical preservation and restoration of a prior complete set;
  14. mid-publication rollback, staging/backup cleanup, interrupted-backup recovery, and ambiguous-backup rejection;
  15. final public artifact-path rewriting and malformed success-payload rejection;
  16. exact contributor-head checkout for repository-local pull-request tests, fuzzing, and security jobs.

The dedicated quality gate requires 100% production statement and branch coverage for the benchmark and publication modules, 100% public docstrings, wheel build/install, and clean installed-package imports.

Unresolved exact-head gate

The transactional-publication blocker is implemented and documented, and repository Tests/Fuzz/Security pass on the exact head. Its inline thread intentionally remains unresolved until trusted central 100% statement/branch/docstring/package evidence and every required current-head gate complete, as required by the review instruction.

Stack order and merge acceptance

  1. merge central .github#759 after exact-head independent approval;
  2. regenerate and satisfy every exact-head gate on fix(security): pin provider egress and repair the Atheris lock #96, then merge fix(security): pin provider egress and repair the Atheris lock #96 without bypass;
  3. retarget this PR to integrated main without changing the reviewed feature boundary;
  4. rerun all repository and central exact-head checks and fresh independent review;
  5. resolve only the publication thread and any other findings whose exact-head evidence is complete;
  6. merge only when branch protection and repository policy permit it.

Do not mark Ready, merge, publish, or release until:

  1. Tests, Fuzz, Security, Security Scan, SAST Semgrep, complete production statement/branch/docstring coverage, packaging, provenance, and release-acceptance gates pass on the exact integrated head;
  2. no synthetic-merge, queued, pending, predecessor-head, stale-base, cancelled, or absent result is counted as exact-head success;
  3. no unresolved valid human, CodeRabbit, GHAS, Dependabot, OpenCode, Noema, Strix, or other automated finding remains;
  4. a qualifying non-author independent reviewer approves the exact integrated head; and
  5. branch protection and repository policy permit merge without bypass.

Refs #86.
Depends on #96 and ContextualWisdomLab/.github#759.

…ark (#86)

Optional stdlib-only benchmark harness (contextual_orchestrator/nim_benchmark.py):

- Dynamic catalog discovery from the OpenAI-compatible GET /v1/models —
  no hard-coded inventory; deduplicated, sorted (response-order-drift
  immune), with machine-readable duplicate/invalid hygiene lists.
- Capability probes for every contract NIM can host: chat completions,
  text completions, Responses API, embeddings, image understanding,
  video understanding, omni-style audio understanding, audio
  transcription, and audio speech — omni_capable derived, skipped
  probes always carry a machine-readable reason, bounded concurrency
  under one shared hard request budget.
- Fair policy comparison on a locked task split: per-worker direct
  baselines (source of best-single-worker-in-hindsight), route_once,
  conduct capped at five steps, cheapest-eligible-worker; identical
  scorers, caps, timeouts, and token budgets across systems.
- Honest cost accounting: actual cost 0 while the hosted catalog is
  free; hypothetical paid cost only from an explicit versioned pricing
  scenario, "unknown" otherwise; the two never mix.
- Paired-bootstrap CIs, quality-latency and quality-hypothetical-cost
  Pareto frontiers, full provenance (git SHA, run id, catalog/manifest/
  pricing hashes, parameters), schema-validated JSON/CSV/Markdown
  artifacts with a secret-leak refusal guard.
- Fail closed: missing KV credential (NVIDIA_NIM_API_KEY, bootstrap
  env->KV only, never argv), incomplete discovery, exceeded budget,
  missing provenance, schema violations.
- Deterministic --dry-run drives the whole pipeline against an
  in-process synthetic provider covering every modality class — zero
  network, byte-identical artifacts.
- Tests: 100% statement+branch coverage of the new module, adversarial
  cases (malformed catalogs, duplicate ids, non-finite tokens/costs,
  rate limits, timeouts, order drift, secret redaction); new fuzz seam
  (Hypothesis + Atheris) for the catalog parser.
- CI: manual + conservative monthly scheduled workflow, single-flight
  concurrency, hard budgets, pinned actions, 90-day artifact retention.
- Docs: docs/nim_benchmark.md, architecture/tracks pointers, HELM
  (arXiv:2211.09110) added to docs/papers.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

NVIDIA NIM 비용·품질 벤치마크 하네스를 추가했습니다. 카탈로그 탐색, modality 검증, 정책 평가, 비용·증거 검증, 결정적 dry-run, live CI 실행, artifact 생성 및 품질 테스트를 포함합니다.

Changes

NIM 벤치마크 기능과 검증

Layer / File(s) Summary
벤치마크 엔진과 실행 입력
contextual_orchestrator/nim_benchmark.py, contextual_orchestrator/__main__.py, examples/nim_*.json
NIM 모델 카탈로그 탐색, 전 modality probe, 요청 예산, 가격 검증, 정책 비교, 통계, provenance, artifact 생성 및 nim-benchmark CLI를 추가했습니다.
CI 실행과 카탈로그 퍼징
.github/workflows/*, fuzz/*, tests/fuzz/*, .gitignore
dry-run 및 live benchmark 작업을 추가했습니다. pull request 대상 제한을 제거했습니다. NIM 카탈로그 퍼징과 관련 Hypothesis 테스트를 추가했습니다.
벤치마크 계약 및 릴리스 검증
tests/test_nim_benchmark*.py, tests/test_pr_workflow_oidc_boundary.py, tests/test_repository_security_metadata.py
보안 경계, 요청 계획, 예산, capability 결과, 가격 증거, token usage, MP4 fixture, provenance, secret 격리 및 workflow 계약을 검증합니다.
증거 정책과 운영 문서
README.md, docs/*, CHANGELOG.md, docs/papers/README.md, conductor/tracks.md
실행 방법, 보안 제약, 증거 등급, 비용 처리, 운영 승인 규칙, 평가 방법론 및 변경 기록을 문서화했습니다.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

Sequence Diagram(s)

sequenceDiagram
  participant Operator
  participant GitHubActions
  participant NIMBenchmark
  participant NIMProvider
  participant ArtifactStore

  Operator->>GitHubActions: dry-run 또는 live 실행 요청
  GitHubActions->>NIMBenchmark: 고정된 예산·manifest·provenance 전달
  NIMBenchmark->>NIMProvider: 카탈로그 조회 및 capability probe
  NIMProvider-->>NIMBenchmark: 모델·probe 결과 반환
  NIMBenchmark->>NIMProvider: 평가 task 요청 전송
  NIMProvider-->>NIMBenchmark: 응답·usage 반환
  NIMBenchmark->>ArtifactStore: JSON·CSV·Markdown artifact 업로드
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 55.94% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 NIM 모델 탐색과 전체 모달리티 비용·품질 벤치마크라는 PR의 주요 변경 사항을 정확하고 간결하게 설명합니다.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch claude/nim-all-models-support-fecb0b
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/nim-all-models-support-fecb0b

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

Comment thread contextual_orchestrator/nim_benchmark.py Outdated

Copy link
Copy Markdown
Contributor Author

Exact-head maintainer audit of 064973ea3ac3dfd8975342f8453483fa16a09aa6 found three release-blocking gaps. This is not approval evidence.

  1. Provider egress is not DNS-pinned and redirects/proxies are not closed. build_default_transport() validates DNS once, then calls urllib.request.urlopen() against the hostname. That creates a second DNS resolution, follows redirects by default, and honors environment proxy configuration. A changed DNS answer or redirect can therefore forward the NVIDIA bearer credential outside the validated address set. The live policy-evaluation path also uses this branch's pre-fix(security): pin provider egress to validated public addresses #76 ModelClient transport. Stack this work on fix(security): pin provider egress to validated public addresses #76 and reuse its validation-time-address pinning, original-host TLS verification, direct no-proxy connection, and redirect rejection for both catalog/probe calls and model evaluation. Add adversarial tests for DNS rebinding, redirect credential forwarding, proxy bypass, non-global addresses including RFC 6598, and pinned-IP/original-host SNI behavior.

  2. The compared policies do not have an equal adjusted token budget. Each request receives the same max_output_tokens, while conduct_bounded may issue up to five calls and route_once/direct baselines issue one. Conduct can therefore consume roughly five times the output-token allowance, contrary to issue [Product Gap] Evidence-grade NVIDIA NIM model discovery and cost-quality benchmark #86. Introduce a per-policy/task total token allowance and the same declared maximum-call envelope, decrement it across every step, stop or fail cells when exhausted, and record configured versus observed budgets in every cell and the provenance parameters. Tests must prove identical total allowances across direct, route-once, and conduct arms.

  3. Actual-free cost is asserted without versioned evidence provenance. The report hard-codes actual_cost_usd = 0.0 and a static honesty label. NVIDIA currently documents Developer Program hosted endpoints as free for prototyping/research/testing, but evidence-grade artifacts must record the reviewed source identity, observation/review date, access/program context, and uncertainty or require a versioned run input. Do not silently carry the zero-cost assertion forward if access terms change.

Do not mark this PR ready or resolve these findings from stale checks. Re-run all required workflows and independent review on the exact repaired head.

@seonghobae
seonghobae changed the base branch from main to claude/inkspan-pr-audit-ci-q1u4uj August 4, 2026 08:15

@seonghobae seonghobae left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking security finding

CRITICAL — benchmark HTTPS transport reintroduces DNS-rebinding SSRF

require_public_https_endpoint() validates one DNS answer, but build_default_transport() then calls urllib.request.urlopen(), which resolves the hostname again. The validated_hosts cache widens the gap by skipping validation on later calls. A provider hostname can therefore pass public-address validation and later connect to loopback, private, RFC 6598, link-local, or otherwise non-global infrastructure. Redirects are also delegated to urllib's default handler, so credentials may be forwarded to an unvalidated destination.

This is the same TOCTOU class repaired by PR #76. Keep this PR Draft until #76 is in main, then reuse or generalize its DNS-pinned transport so the socket dials only validation-time public IPs while preserving the original hostname for HTTP authority, TLS SNI, and certificate verification. Reject redirects, bypass environment proxies, require is_global, clear stale pins before each validation, and deterministically close failed sockets/responses.

Required regression evidence:

  • no transport-time DNS re-resolution;
  • public IPv4/IPv6 pinning and hostname/SNI preservation;
  • RFC 6598/private/loopback/link-local/multicast/reserved/unspecified rejection;
  • redirect rejection with no authorization propagation;
  • approved-IP fallback and all-address failure;
  • exact-head statement/branch coverage and full repository checks.

Do not merge based on the current local 100% claim; it does not cover this security invariant.

@seonghobae
seonghobae marked this pull request as draft August 4, 2026 08:16
@seonghobae
seonghobae changed the base branch from claude/inkspan-pr-audit-ci-q1u4uj to main August 4, 2026 08:32

@seonghobae seonghobae left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exact-head review — still blocked

The latest head addresses the three audit themes, but the implementation is not yet mergeable.

1. HIGH — production security behavior is coupled to a test monkeypatch

nim_benchmark_hardening._build_secure_transport() deliberately falls back to urllib.request.urlopen() whenever that global has been replaced. This keeps the old offline tests green by changing production behavior instead of replacing the obsolete tests. It reintroduces the hostname-resolving, proxy-aware, redirect-capable path that this repair is supposed to eliminate, and requires a nosemgrep waiver on the exact sink.

Remove the compatibility branch entirely. Rewrite the transport tests to inject the pinned connection/resolver seam and prove the real direct transport. Do not let test instrumentation select a less-secure production path.

2. HIGH — the new 531-line hardening module has no direct regression suite

The current tests/test_nim_benchmark.py still asserts the old urlopen behavior and contains no evidence for EqualBudgetModelClient, expiry enforcement, actual-cost evidence validation, configured/observed budget fields, or the installed wrappers. A 100% repository claim cannot be accepted while the newly shipped module and its branches are not directly exercised.

Add behavior tests that fail without each contract, then prove exact-head statement and branch coverage at 100% for both nim_benchmark.py and nim_benchmark_hardening.py, plus 100% public docstrings.

3. HIGH — cited cost source does not support the recorded claim

ACTUAL_COST_EVIDENCE names https://docs.nvidia.com/nim/large-language-models/latest/faq.html, but the current NVIDIA FAQ location is different and the available FAQ content does not establish that the API Catalog hosted endpoint used by this run is free to the caller. Current build.nvidia.com model pages do label prototype endpoints as free, while NIM offering/licensing documentation distinguishes free exploratory offerings from NVIDIA AI Enterprise production support. Record the exact reviewed page/version or immutable evidence artifact that supports the hosted endpoint claim; do not cite a generic or moved FAQ as proof.

4. MEDIUM — optional adapter boundary is lost

contextual_orchestrator.__init__ now imports the entire benchmark and monkeypatch installer for every package import. Keep the NIM evaluator optional: integrate the fix directly into its module, or install it only from the benchmark entrypoint. Runtime gateway users should not import benchmark-only code or mutate benchmark globals as a side effect of import contextual_orchestrator.

5. MEDIUM — temporary privileged workflow remains in the PR tree

.github/workflows/temporary-nim-transport-fix.yml has top-level contents: write, persists checkout credentials, and triggers on every branch push. It must be removed from the final tree. Any one-shot repair must use read-only defaults, isolate credentials to the publication step, validate exact changed paths, and disappear before review.

Keep the PR Draft. Replace the compatibility installer with direct, test-first implementation; remove the temporary workflow; update the PR body to the actual head; then rerun all exact-head checks and independent review.

Copy link
Copy Markdown
Contributor Author

Exact-head maintainer follow-up for the new hardening commits:

  1. Keep the existing GHAS thread unresolved until contextual_orchestrator/nim_benchmark.py itself no longer contains the hostname-re-resolving urllib.request.urlopen implementation. Installing a replacement through package import does not remove the vulnerable/static-scanned implementation and forces the optional benchmark adapter into every package import.
  2. Correct the cost-evidence source to the current official NVIDIA NIM General FAQ: https://docs.api.nvidia.com/nim/docs/product. That page explicitly states free Developer Program access to NIM API endpoints for prototyping and distinguishes production use, which requires NVIDIA AI Enterprise. The current docs.nvidia.com/nim/large-language-models/latest/faq.html identity and the docs.nvidia.com-only validator do not match the reviewed current source.
  3. Preserve lazy/optional adapter loading: install benchmark-specific behavior from the benchmark module or integrate it directly, rather than eagerly importing the full benchmark and compatibility installer from package __init__.

Do not resolve the security thread or mark the PR ready until these are implemented and verified on the exact repaired head.

Copy link
Copy Markdown
Contributor Author

Exact-head update after CI-driven repairs:

  • current head: 88b0e962b69d56a2f552e61b6b3762938defd97d
  • current stacked base: 03124cf97b7bf02e30a48a13acfd78b6ef08d1ef
  • verification PR base: 6841b71935e0b7cb98fb52bcb4709cc5100c8d87

The first exact-head verification attempt correctly failed: the existing workflow contract required the original one-line interrogate command, and the README disclaimer assertion was unintentionally case-sensitive. The branch now preserves the original benchmark docstring command, adds a separate 100% adapter docstring gate, and makes the unchanged no-routing disclaimer contract case-insensitive. No queued or in-progress result is treated as success. PR #96 remains the integration prerequisite.

Copy link
Copy Markdown
Contributor Author

Exact-head verification receipt for 88b0e962b69d56a2f552e61b6b3762938defd97d:

  • Tests run 31040728716: completed success; full unit/contract suite passed, and the NIM quality job passed 100% statement/branch coverage, 100% public-docstring gates, wheel build/install, and installed-wheel imports for both nim_benchmark and nim_csv_evidence.
  • Fuzz run 31040728278: completed success; Hypothesis and all Atheris targets, including the NIM catalog parser, passed.
  • Security run 31040728943: completed success; CodeQL and Python supply-chain/SBOM jobs passed.
  • Security Scan run 31040728271: completed success.
  • SAST Semgrep run 31040728426: completed success.
  • CodeRabbit exact-head commit status: success.

These results verify the exact feature head against temporary verification base 6841b71935e0b7cb98fb52bcb4709cc5100c8d87; they do not replace the required post-#96 integrated-main rerun or current-integrated-head independent approval. PR #90 remains Draft and must not merge before #96.

Copy link
Copy Markdown
Contributor Author

Correction to the earlier verification receipt: runs 31040728716, 31040728278, 31040728943, 31040728271, and 31040728426 checked out synthetic merge commit 7e89420, not branch head 88b0e96. They are integration-smoke evidence only and do not satisfy exact-head gates.

Current head 692e49a adds a regression contract and explicitly selects the pull-request head SHA in every repository-local Tests, Fuzz, and Security checkout. Fresh job logs must show that exact SHA before any result is described as exact-head evidence.

Copy link
Copy Markdown
Contributor Author

Exact-head repository-native verification is complete for current feature head 1ef2c97994272439a2dfbb1250b4eb2cb5e26014 via verification PR #101. The following pull-request workflow runs completed successfully on that exact commit:

  • Tests 31041713721
  • Fuzz 31041713751
  • Security 31041714135
  • Security Scan 31041717345
  • SAST Semgrep 31041713693

This records repository-local current-head evidence only. It does not satisfy the post-#96 integrated-base rerun, current-head automated review, independent non-author approval, branch protection, or release gates. Verification PR #101 will be closed unmerged as intended.

Copy link
Copy Markdown
Contributor Author

Exact-current-head review request for f0429534618c283a40ee841d61a13024c9455b9f against exact base 8b479f5667e92b39a6c611cb58cfa6f39a9cfa0f. Do not reuse predecessor-head evidence. Repository-local Tests 31047228010, Fuzz 31047227861, and Security 31047227211 completed successfully on this exact head; CodeRabbit commit status is successful and every inline review thread is resolved. Verify the complete dynamic request-plan preflight, all-model/all-capability probing, equal evaluation reserve, deterministic bounded concurrency, DNS-pinned proxy-free redirect-rejecting credential egress, valid media fixtures, free-to-caller versus hypothetical-cost provenance, evidence sufficiency, paired uncertainty, zero-success Pareto exclusion, atomic artifact publication, lazy import boundary, fuzz instrumentation, 100% benchmark statement/branch/docstring and package evidence, and stacked-base policy. Keep the PR Draft and submit APPROVE only if all required exact-head evidence—including any organization-central coverage/security gates—is complete and no current-head blocker remains; otherwise report the precise missing or failing gate.

@opencode-agent @cwl-noema-review @coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

HEAD_SHA="f0429534618c283a40ee841d61a13024c9455b9f"
BASE_SHA="8b479f5667e92b39a6c611cb58cfa6f39a9cfa0f"

printf '%s\n' '== Checked-out commit =='
git rev-parse HEAD
git show -s --format='HEAD=%H%nparents=%P%nsubject=%s' HEAD

printf '%s\n' '== Requested commits =='
git cat-file -t "$HEAD_SHA"
git cat-file -t "$BASE_SHA"
git merge-base --is-ancestor "$BASE_SHA" "$HEAD_SHA" && echo "base_is_ancestor=true" || echo "base_is_ancestor=false"
git diff --check "$BASE_SHA...$HEAD_SHA"
git diff --name-status "$BASE_SHA...$HEAD_SHA"

printf '%s\n' '== Relevant source and test outlines =='
ast-grep outline contextual_orchestrator/nim_benchmark.py --items all --view expanded
for candidate in \
  tests/test_nim_benchmark.py \
  tests/test_nim_benchmark_review_regressions.py \
  tests/test_nim_benchmark_release_acceptance.py \
  tests/test_nim_benchmark_workflow_contract.py \
  tests/test_nim_benchmark_workflow_secret_boundary.py \
  fuzz/targets.py \
  fuzz/fuzz_nim_catalog.py; do
  if [ -f "$candidate" ]; then
    echo "--- $candidate"
    ast-grep outline "$candidate" --items all --view expanded
  fi
done

printf '%s\n' '== Security, planning, provenance, artifact, and import-boundary references =='
rg -n -C 3 --type py \
  'class Pinned|Pinned|NoRedirect|ProxyHandler|urlopen|create_connection|getaddrinfo|CAPABILITY_PROBE_ORDER|plan_complete_request_budget|probe_discovered_models|BenchmarkBudgetError|remaining_requests|conduct|route_once|actual_cost_usd|hypothetical_cost_source|pricing|evidence|pareto|excluded_zero_success|write_benchmark_artifacts|os\.replace|atomic|RecursionError|_REPORT_REQUIRED_PATHS|timeout_seconds' \
  contextual_orchestrator/nim_benchmark.py tests fuzz

printf '%s\n' '== Import and workflow boundary references =='
rg -n -C 3 --type py 'nim_benchmark|nim_benchmark_hardening' contextual_orchestrator/__init__.py contextual_orchestrator/__main__.py tests 2>/dev/null || true
for workflow in .github/workflows/tests.yml .github/workflows/fuzz.yml .github/workflows/security.yml .github/workflows/nim-benchmark.yml; do
  if [ -f "$workflow" ]; then
    echo "--- $workflow"
    sed -n '1,280p' "$workflow"
  fi
done

printf '%s\n' '== Temporary artifacts and prohibited compatibility paths =='
for candidate in \
  .review-evidence/nim-direct-integration \
  .review-evidence/nim-source-repair.yml \
  contextual_orchestrator/nim_benchmark_hardening.py \
  tests/test_nim_benchmark_hardening.py; do
  if [ -e "$candidate" ]; then
    echo "PRESENT $candidate"
  else
    echo "ABSENT $candidate"
  fi
done

printf '%s\n' '== Exact-head GitHub check runs =='
gh api "repos/ContextualWisdomLab/contextual-orchestrator/commits/$HEAD_SHA/check-runs?per_page=100" \
  --jq '.check_runs[] | [.name, .status, .conclusion, .details_url] | `@tsv`' || true

printf '%s\n' '== Pull request metadata and review state =='
gh pr view 90 --repo ContextualWisdomLab/contextual-orchestrator \
  --json number,state,isDraft,headRefOid,baseRefOid,statusCheckRollup,reviews \
  --jq '{number, state, isDraft, headRefOid, baseRefOid, checks: [.statusCheckRollup[] | {name, status, conclusion}], reviews: [.reviews[] | {author: .author.login, state, commit: .commit.oid}]}' || true

Length of output: 178131


🏁 Script executed:

#!/bin/bash
set -euo pipefail

HEAD_SHA="f0429534618c283a40ee841d61a13024c9455b9f"
BASE_SHA="8b479f5667e92b39a6c611cb58cfa6f39a9cfa0f"

printf '%s\n' '== Exact revision and changed paths =='
printf 'checked_out='; git rev-parse HEAD
git show -s --format='head=%H%nparents=%P%nsubject=%s' "$HEAD_SHA"
git merge-base "$BASE_SHA" "$HEAD_SHA"
git diff --name-status "$BASE_SHA...$HEAD_SHA"
git diff --stat "$BASE_SHA...$HEAD_SHA"

printf '%s\n' '== NIM benchmark function locations =='
rg -n --type py \
  '^(def (build_default_transport|discover_model_catalog|probe_discovered_models|plan_complete_request_budget|planned_complete_run_requests|evaluate_policies|build_pareto_frontiers|render_markdown_summary|validate_report_schema|write_benchmark_artifacts|assemble_benchmark_report|run_benchmark)|class (_BudgetedModelClient|EqualBudgetModelClient|RequestBudget|_PinnedHTTPSConnection))\b|^_REPORT_REQUIRED_PATHS\b|^CAPABILITY_PROBE_ORDER\b|^MAX_WORKFLOW_DEPTH\b' \
  contextual_orchestrator/nim_benchmark.py

printf '%s\n' '== Focused implementation sections =='
python - <<'PY'
from pathlib import Path
import re

path = Path("contextual_orchestrator/nim_benchmark.py")
lines = path.read_text(encoding="utf-8").splitlines()
names = (
    "build_default_transport", "discover_model_catalog", "probe_discovered_models",
    "plan_complete_request_budget", "planned_complete_run_requests", "evaluate_policies",
    "build_pareto_frontiers", "validate_report_schema", "render_markdown_summary",
    "write_benchmark_artifacts", "assemble_benchmark_report", "run_benchmark",
)
starts = []
for index, line in enumerate(lines, 1):
    if re.match(rf"^def ({'|'.join(names)})\(", line):
        starts.append(index)
starts.append(len(lines) + 1)
for start, end in zip(starts, starts[1:]):
    print(f"\n--- {path}:{start}-{end - 1} ---")
    print("\n".join(f"{n:5} {lines[n-1]}" for n in range(start, end)))
PY

printf '%s\n' '== Markdown direct report paths versus schema paths =='
python - <<'PY'
import ast
from pathlib import Path

source = Path("contextual_orchestrator/nim_benchmark.py").read_text(encoding="utf-8")
tree = ast.parse(source)
required = set()
render = None
for node in tree.body:
    if isinstance(node, ast.Assign) and any(
        isinstance(target, ast.Name) and target.id == "_REPORT_REQUIRED_PATHS"
        for target in node.targets
    ):
        required = set(ast.literal_eval(node.value))
    if isinstance(node, ast.FunctionDef) and node.name == "render_markdown_summary":
        render = node

def path_of(node):
    parts = []
    while isinstance(node, ast.Subscript):
        key = node.slice
        if isinstance(key, ast.Constant) and isinstance(key.value, str):
            parts.append(key.value)
        else:
            return None
        node = node.value
    if isinstance(node, ast.Name) and node.id == "report":
        return ".".join(reversed(parts))
    return None

paths = sorted({path for node in ast.walk(render) if (path := path_of(node))})
print("required paths:")
print("\n".join(sorted(required)))
print("\ndirect report subscript paths:")
print("\n".join(paths))
print("\nmissing from required paths:")
print("\n".join(path for path in paths if path not in required) or "<none>")
PY

printf '%s\n' '== Provider transport ownership and benchmark imports =='
fd -a 'provider_transport\.py|nim_benchmark\.py|nim_csv_evidence\.py' contextual_orchestrator -x sh -c 'echo "--- $1"; sed -n "1,320p" "$1"' sh {} 
rg -n -C 2 --type py \
  'urllib\.request\.urlopen|build_opener|ProxyHandler|HTTPRedirectHandler|socket\.getaddrinfo|create_connection|server_hostname|NVIDIA_NIM_API_KEY|nim_benchmark' \
  contextual_orchestrator/nim_benchmark.py contextual_orchestrator/provider_transport.py contextual_orchestrator/__init__.py contextual_orchestrator/__main__.py

printf '%s\n' '== Exact-head statuses and required branch checks =='
gh api "repos/ContextualWisdomLab/contextual-orchestrator/commits/$HEAD_SHA/status" \
  --jq '{state, statuses: [.statuses[] | {context, state, target_url}]}' || true
gh api "repos/ContextualWisdomLab/contextual-orchestrator/branches/main/protection/required_status_checks" \
  --jq '{strict, contexts, checks}' || true
gh api "repos/ContextualWisdomLab/contextual-orchestrator/rules/branches/main" \
  --jq '.' || true

Length of output: 166515


@seonghobae

I reviewed exact head f0429534618c283a40ee841d61a13024c9455b9f against exact base 8b479f5667e92b39a6c611cb58cfa6f39a9cfa0f.

I found one blocking artifact-integrity defect.

  • Atomic artifact publication is not implemented. write_benchmark_artifacts() writes benchmark_report.json at Line 2281, then writes benchmark_cells.csv, then renders and writes Markdown at Line 2300. If CSV or Markdown generation or writing fails, earlier files remain in the final output directory. nim_csv_evidence.enrich_benchmark_cell_csv() atomically replaces only the CSV. It does not make the JSON, CSV, and Markdown artifact set atomic. Stage all artifacts in a temporary sibling directory, validate and enrich there, then publish the complete set with an atomic directory-level replacement strategy. On failure, leave no new final artifacts.

The requested repository-local exact-head checks are successful. These include full tests, NIM 100% coverage and docstring gates, wheel install/import, Hypothesis, Atheris, CodeQL, and Python supply-chain checks.

I could not verify all organization-central required gates. The organization rules require security-scan.yml, sast-semgrep.yml, opencode-review.yml, noema-review.yml, and other listed workflows. The retrieved exact-head check runs and PR rollup do not contain results for these workflows. The branch-protection status-check endpoint also returned HTTP 403.

Do not approve this Draft PR. Resolve the atomic-publication defect and provide successful exact-head results for the organization-central required workflows.

You are interacting with an AI system.

Copy link
Copy Markdown
Contributor Author

@opencode-agent @cwl-noema-review @coderabbitai review

Please independently review exact current head f0429534618c283a40ee841d61a13024c9455b9f against exact base 8b479f5667e92b39a6c611cb58cfa6f39a9cfa0f. The current-head repository Tests (31047228010), Fuzz (31047227861), and Security (31047227211) runs succeeded, the CodeRabbit commit status is successful, and all existing inline threads are resolved. Discard every predecessor-head verdict and re-evaluate the complete integrated NIM benchmark, especially complete-plan preflight, equal token/call budgets, pricing-evidence honesty, zero-success Pareto exclusion, atomic artifact publication, deterministic media fixtures, DNS-pinned/redirect-free/proxy-free credential egress, lazy optional-adapter activation, current-head coverage/docstrings/package evidence, and branch-protection requirements. Submit APPROVE only for this exact SHA if every required current-head gate is successful and no actionable finding remains; otherwise report the precise blocker without treating queued, absent, stale, or synthetic-merge evidence as success.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

head_sha="f0429534618c283a40ee841d61a13024c9455b9f"
base_sha="8b479f5667e92b39a6c611cb58cfa6f39a9cfa0f"
repo="ContextualWisdomLab/contextual-orchestrator"

echo "== Revision =="
printf "checked_out="; git rev-parse HEAD
git show -s --format='head=%H%nparents=%P%nsubject=%s' "$head_sha"
git merge-base --is-ancestor "$base_sha" "$head_sha" && echo "base_is_ancestor=true"
git diff --check "$base_sha...$head_sha"

echo "== Artifact implementation map =="
ast-grep outline contextual_orchestrator/nim_benchmark.py --items all --view expanded
rg -n -C 8 --type py \
  'def write_benchmark_artifacts\(|def validate_report_schema\(|def render_markdown_summary\(|os\.replace|tempfile|mkdtemp|TemporaryDirectory|benchmark_report\.json|benchmark_cells\.csv|benchmark_summary\.md|enrich_benchmark_cell_csv' \
  contextual_orchestrator tests

echo "== Artifact implementation =="
python - <<'PY'
from pathlib import Path
import ast

path = Path("contextual_orchestrator/nim_benchmark.py")
source = path.read_text(encoding="utf-8")
tree = ast.parse(source)
lines = source.splitlines()
for node in tree.body:
    if isinstance(node, ast.FunctionDef) and node.name == "write_benchmark_artifacts":
        for index in range(node.lineno, node.end_lineno + 1):
            print(f"{index:5} {lines[index - 1]}")
PY

echo "== Relevant tests =="
fd -a 'test_nim*.py' tests -x sh -c '
  echo "--- $1"
  rg -n -C 5 "write_benchmark_artifacts|artifact|atomic|os\.replace|TemporaryDirectory|mkdtemp" "$1" || true
' sh {}

echo "== Exact-head check runs =="
gh api "repos/$repo/commits/$head_sha/check-runs?per_page=100" \
  --jq '.check_runs[] | [.name, .status, (.conclusion // "null"), .head_sha, .details_url] | `@tsv`' || true

echo "== PR state and check rollup =="
gh pr view 90 --repo "$repo" \
  --json isDraft,headRefOid,baseRefOid,statusCheckRollup \
  --jq '{isDraft, headRefOid, baseRefOid, checks: [.statusCheckRollup[] | {name, status, conclusion, detailsUrl}]}' || true

echo "== Required checks and rules =="
gh api "repos/$repo/branches/main/protection/required_status_checks" \
  --jq '{strict,contexts,checks}' || true
gh api "repos/$repo/rules/branches/main" --jq '.' || true

Length of output: 73982


@seonghobae I reviewed exact head f0429534618c283a40ee841d61a13024c9455b9f against exact base 8b479f5667e92b39a6c611cb58cfa6f39a9cfa0f.

I found one blocking artifact-integrity defect.

  • Atomic artifact publication is not implemented. write_benchmark_artifacts() creates output_dir at Line 2278. It writes benchmark_report.json at Lines 2281-2283. It then generates and writes benchmark_cells.csv at Lines 2285-2298. It renders and writes benchmark_summary.md at Lines 2300-2304. If a later generation or write operation fails, earlier files remain in the final directory. nim_csv_evidence.enrich_benchmark_cell_csv() atomically replaces only the CSV. It does not publish the JSON, CSV, and Markdown set atomically.

Stage, validate, and enrich the complete artifact set outside the final output directory. Publish the complete set only after all operations succeed. On failure, do not leave newly created final artifacts.

The exact-head repository checks are successful. This includes Tests, Fuzz, Security, CodeQL, the NIM 100% coverage/docstring gate, and package smoke checks.

I cannot verify all organization-required gates. The organization rules require security-scan.yml, sast-semgrep.yml, opencode-review.yml, noema-review.yml, and other workflows. The exact-head check list has no results for these workflows. The branch-protection status-check endpoint also returned HTTP 403.

I do not approve this Draft PR.

You are interacting with an AI system.

Copy link
Copy Markdown
Contributor Author

@opencode-agent

Implement the current-head CodeRabbit blocker on branch claude/nim-all-models-support-fecb0b test-first, without touching unrelated stack work. Anchor all work to exact head f0429534618c283a40ee841d61a13024c9455b9f and re-read the head immediately before each write.

Add RED regression coverage proving that a failure during CSV enrichment/rendering or Markdown generation leaves no newly published final artifact set, does not corrupt a previously complete artifact set, and removes all staging/backup residue. Then implement a bounded cross-platform transaction for write_benchmark_artifacts: fully validate, render, secret-scan, and enrich JSON/CSV/Markdown inside a sibling staging directory; fsync files and the staging directory where supported; publish only the complete set; preserve/restore any pre-existing complete set on publication failure; and clean staging/backup paths deterministically. Do not claim a single os.replace() over a non-empty directory is portable or atomic. Document the exact atomicity/rollback contract and crash-window limitations honestly in authoritative doctoring and CHANGELOG.md. Preserve CSV assignment enrichment, lazy optional imports, deterministic artifacts, Windows compatibility, 100% production statement/branch coverage, 100% public docstrings, and package import behavior.

After GREEN, run the focused artifact tests, full benchmark coverage/docstring/package gates, Tests/Fuzz/Security, and request the organization-central security/review workflows for the resulting exact head. Do not resolve the blocker or mark Ready until the exact resulting SHA has successful required checks and a fresh independent review.

@seonghobae seonghobae left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exact-head blocker recorded as an unresolved inline thread because the author account cannot submit REQUEST_CHANGES on its own PR. Keep Draft until addressed and reverified.

"""Validate cost evidence and schema, then write JSON, CSV, and Markdown."""
_validate_actual_cost_evidence(report)
validate_report_schema(report)
os.makedirs(output_dir, exist_ok=True)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BLOCKER — JSON/CSV/Markdown are published as a partial set. Creating the final directory here and then writing each artifact directly means a later CSV enrichment/rendering, Markdown, or filesystem failure can leave a newly visible partial set or partially replace a prior complete set. Repair test-first: stage, validate, render, secret-scan, and enrich the complete set outside the final path; publish only after all steps succeed; preserve/restore an existing complete set on ordinary publication failure; remove staging/backup residue; and document the exact portable rollback/crash-window contract. Add regressions for fresh-target failure, prior-set preservation, mid-publication failure, cleanup, and returned paths. Do not resolve until the repaired exact head has 100% statement/branch/docstring evidence and all required checks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed test-first on exact head 1cea0c019a0af0f523e5ffef10dfafcba4554baa through the supported CLI composition boundary. The branch now stages the complete JSON/CSV/Markdown set in a hidden sibling directory, enriches and validates the CSV there, validates exact non-empty regular-file membership, publishes by same-filesystem directory renames, restores a prior complete set after ordinary mid-publication failure, removes staging/backup residue, recovers a sole interrupted backup on the next invocation, rejects ambiguous backups, and rewrites success output to final public paths only. The portable two-rename crash window and recovery limits are documented. Focused regressions are in tests/test_nim_artifact_publication.py and tests/test_nim_artifact_publication_edges.py; the current exact head has successful repository Tests run 31073765240, Fuzz run 31073765223, and Security run 31073765231. The thread remains unresolved because trusted central 100% statement/branch/docstring/package evidence and every required current-head gate still depend on .github#759 integration and subsequent exact-head redispatch.

Copy link
Copy Markdown
Contributor Author

Exact-current-head revalidation record

Inventory identity for this review cycle:

  • exact head: 1cea0c019a0af0f523e5ffef10dfafcba4554baa
  • exact base: 8b479f5667e92b39a6c611cb58cfa6f39a9cfa0f
  • predecessor head f0429534618c283a40ee841d61a13024c9455b9f and every result attached to it are historical only.

The artifact-publication blocker has been implemented test-first at the active CLI composition root without making package import eager. nim-benchmark now writes into a hidden sibling staging directory, enriches and validates the complete JSON/CSV/Markdown set, secret-checks through the benchmark writer, publishes the directory as one unit, restores a prior complete set after ordinary publication failure, cleans staging/backup residue, recovers a sole interrupted backup on the next run, fails closed on ambiguous backups, and rewrites the success payload only to final paths. Regressions cover fresh-target failure, prior-set preservation, mid-publication rollback, interrupted-publication recovery, residue cleanup, complete-set validation, and returned paths. The direct writer remains confined to the private staging path in the supported CLI route.

Exact-head repository evidence now observed:

  • Tests: success (31073765240), including the NIM quality job with 100% statement and branch coverage for nim_benchmark.py and nim_csv_evidence.py, 100% public docstrings, and wheel build/install/import smoke;
  • Security: success (31073765231);
  • Fuzz: success (31073765223);
  • CodeRabbit commit status: success.

This does not establish merge acceptance. No exact-head Security Scan or SAST Semgrep run is currently present in the observed workflow inventory, the inline blocker remains unresolved pending the complete gate, and a qualifying independent non-author approval is still required. Keep this PR Draft and do not reuse predecessor-head or synthetic-merge evidence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants