Skip to content

fix(telemetry): preserve controls and share request attribution - #1691

Merged
mldangelo-oai merged 12 commits into
mainfrom
mdangelo/codex/shared-telemetry-context
Oct 20, 2026
Merged

mldangelo-oai merged 12 commits into
mainfrom
mdangelo/codex/shared-telemetry-context

Conversation

@mldangelo-oai

@mldangelo-oai mldangelo-oai commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Centralize request attribution across the CLI, SDK, and helpers. GitHub Action runs carry integration and configured-provider attribution, while token totals remain unknown when measurements are missing. Preserve account allowance snapshots independently of token measurements.

Changes

  • Share request context while preserving caller metadata, literal dotted keys, selected-profile analytics settings, and OpenTelemetry configuration.
  • Forward context through scan patches and fresh/resumed Deep workers; attribute publication and embedding requests through their existing request paths.
  • Distinguish missing usage from measured zero, retain retry-thread associations, preserve unpriced token totals, and enforce budgets against measured subtotals.
  • Save allowance snapshots from owned sessions even when token receipts are absent or incomplete. Keep finalization pending until token receipts arrive, without inventing zero usage.
  • Reuse existing native configuration and test helpers, including coverage of the cheaperinference built-in provider and concurrent request contexts.

Testing

After integrating main at 06201edfa54a83fdfc3a9d0e28bfb019ce30b4c0:

  • Python scan usage suite: all 127 tests passed.
  • The eight focused SDK suites produced 363 passes and 3 platform skips. Three comparison assertions failed because of local macOS temporary-path aliases; all four variants passed when rerun with a canonical temporary path.
  • The MCP Deep Scan executor module passed, including fresh/resumed worker settings and telemetry inheritance.
  • All five required portable source checks passed in order, including all nine compatibility-checker tests.
  • Plugin build, SDK/MCP type checks, changed TypeScript formatting, Action build/type/distribution checks, and diff checks passed.
  • Fresh hosted CI and Codex/Copilot reviews are required on the integrated head before merge.

Risk and rollout

No new CLI flags, Action inputs, collectors, or export destinations. The Action retains analytics.enabled=false; request attribution remains separate from native analytics and explicitly configured OTel exporters. Provider tags describe wrapper configuration; native managed-provider overrides can select a different backend. Attribution does not establish OpenAI-side reporting for other providers.

Migration 51 adds a local worker-thread registry, backfills known associations, and retains them until the scan is deleted. Allowance-only records retain unavailable token coverage and preserve existing legacy cost values.

Public disclosure review

  • No customer, partner, prospect, or user identities, data, or identifying details are included.
  • No credentials, personal data, private source, scan findings, or nonpublic links or tickets are included.
  • I reviewed the branch name, title, description, commits, changes, comments, logs, screenshots, attachments, and links for public disclosure.

@github-actions github-actions Bot added the bug Something isn't working label Oct 17, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T01:45:50.648397Z 41983f1 Manual request
🔒 Security Review ✅ Completed 2026-10-20T01:46:34.456848Z 41983f1 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@kmbroai kmbroai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed 454fc60. The implementation is reasonable, and I found no concrete correctness issue.

Nonblocking scope recommendation: separate request attribution and analytics/OTel propagation from usage/cost accounting, budget behavior, and retry-thread history (including migration 50). These are independently shippable changes; separating them would make the accounting and persistence changes easier to review and revert independently. The existing helpers are proportionate; this is a recommendation about PR focus.

Targeted attribution, cost/budget, worker, and usage checks passed, and CI is green. Local validation had one unrelated raw-byte directory fixture blocked by the sandbox; the broader Python run was stopped before completion. Approving with the scope recommendation above.

@alandelong-oai alandelong-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Owner-level merge-safety review. Thanks for preserving caller controls while consolidating attribution and usage handling. I found no material unresolved issues. Metadata/configuration propagation, missing-versus-zero usage, measured-budget enforcement and retry-thread retention are consistent across the reviewed paths.

Validation included 153 Action tests, 120 fresh/resumed worker launches, eight real SQLite/rollout cases with base comparisons, native request probes, schema migrations, builds, types, formatting and portable checks. The collector probe reproduced five incorrect complete-usage classifications on the base while preserving measured controls.

Local full SDK/Python runs encountered ownership, virtual Git and fixture-environment constraints; I do not count those suites as passing. Downloaded PR validation reports passed all 879 affected SDK tests (seven skips), 168 usage/migration tests (three skips), and the MCP executor/store/migration checks. No live model or publication request was made.

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the updated head dc54791af974a12ec51d7379a4b90a2a76e15f46 after integrating main and the shared test-fixture repairs. The conflict resolution preserves main's native configuration pass-through and usage roles, time windows, rate-limit snapshots, and turn-coverage warnings. Missing worker measurements remain unknown; the direct coordinator's control-only session remains a known zero. The worker-thread registry is now migration 51, leaving every existing main migration unchanged.

Python usage/migration coverage passed after targeted assertion updates, including retention of rate-limit snapshots from unmeasured workers. The Action bundle was rebuilt and checked; current local validation and environment limitations are recorded in the PR description. Hosted CI must pass before merge.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Cross-process telemetry controls, budget accounting, and the persistent schema migration need successful hosted CI and final human review given the reported verification gaps.

No open issues 🎉

What changed in this PR

Centralizes request attribution across the CLI, SDK, GitHub Action, and Deep Scan workers while preserving telemetry controls and improving usage accounting.

Changes:

  • Shares attribution while retaining caller metadata, profile settings, and OpenTelemetry configuration.
  • Distinguishes missing usage from measured zero and enforces budgets against measured subtotals.
  • Preserves worker retry history through migration 51 and expands regression coverage.
File Description
sdk/​typescript/​tests-ts/​support/​request-metadata.ts Adds metadata assertion helper.
sdk/​typescript/​tests-ts/​scan-comparison.test.ts Checks provider attribution.
sdk/​typescript/​tests-ts/​request-metadata.test.ts Tests shared context and configuration preservation.
sdk/​typescript/​tests-ts/​publish.test.ts Checks publication attribution.
sdk/​typescript/​tests-ts/​multiscan.test.ts Uses completed-scan fixtures.
sdk/​typescript/​tests-ts/​finding-embeddings.test.ts Checks embedding request identification.
sdk/​typescript/​tests-ts/​direct-deep-scan.test.ts Tests isolated coordinator usage and worker completeness.
sdk/​typescript/​tests-ts/​cost.test.ts Tests incomplete usage and measured subtotals.
sdk/​typescript/​tests-ts/​cli-verify-fix.test.ts Updates metadata assertions.
sdk/​typescript/​tests-ts/​cli-skills.test.ts Checks shared skill attribution.
sdk/​typescript/​tests-ts/​cli-project-config.test.ts Filters incomplete cost notifications.
sdk/​typescript/​tests-ts/​cli-patch.test.ts Tests profile telemetry forwarding.
sdk/​typescript/​tests-ts/​api.test.ts Expands attribution and configuration coverage.
sdk/​typescript/​tests-ts/​api-usage.test.ts Tests finalization and incomplete-usage budgets.
sdk/​typescript/​tests-ts/​api-policy.test.ts Tests policy budget enforcement.
sdk/​typescript/​tests-ts/​api-patch.test.ts Updates patch metadata assertions.
sdk/​typescript/​tests-ts/​api-direct-deep-scan.test.ts Verifies worker usage survives completion.
sdk/​typescript/​tests-ts/​api-credentials.test.ts Checks metadata override preservation.
sdk/​typescript/​tests-ts/​api-attribution-concurrency.test.ts Tests concurrent request-context isolation.
sdk/​typescript/​src/​server/​embeddings.ts Adds package-version User-Agent.
sdk/​typescript/​src/​scan-comparison.ts Uses shared request context.
sdk/​typescript/​src/​request-metadata.ts Centralizes attribution and literal-key serialization.
sdk/​typescript/​src/​publish.ts Attributes connected-app publication requests.
sdk/​typescript/​src/​deep-scan.ts Shares zero-usage coordinator definition.
sdk/​typescript/​src/​deduplication/​codex-review.ts Uses shared deduplication attribution.
sdk/​typescript/​src/​cost.ts Separates incomplete subtotals from complete totals.
sdk/​typescript/​src/​cli.ts Forwards attribution and patch telemetry settings.
sdk/​typescript/​src/​api.ts Integrates context and usage completeness handling.
sdk/​typescript/​docs/​cli.md Documents attribution and telemetry inheritance.
plugins/​codex-security/​tests/​test_workbench_setup_and_migrations.py Registers migration 51 expectations.
plugins/​codex-security/​tests/​test_workbench_scan_usage.py Covers missing measurements and retry accounting.
plugins/​codex-security/​tests/​test_workbench_db.py Expects worker-thread history table.
plugins/​codex-security/​shared/​workbench-migrations.json Adds persistent worker-thread history.
plugins/​codex-security/​scripts/​workbench_scan_usage.py Tracks measured usage and historical workers.
plugins/​codex-security/​mcp-app/​tests/​test_workbench_database.ts Tests history migration and retention.
plugins/​codex-security/​mcp-app/​tests/​test_deep_scan_store_integration.ts Verifies retry-thread associations persist.
plugins/​codex-security/​mcp-app/​tests/​test_deep_scan_executor.ts Expands worker telemetry launch assertions.
plugins/​codex-security/​mcp-app/​tests/​support/​fake-codex-fixture.ts Extracts reusable executable fixture.
plugins/​codex-security/​mcp-app/​tests/​deep_scan_worker_telemetry_fixture.ts Adds telemetry inheritance fixtures.
plugins/​codex-security/​mcp-app/​src/​deep-scan/​executor.ts Preserves worker context and merges telemetry tables.
github-action/​tests/​main.test.ts Checks integration and provider attribution.
github-action/​src/​inputs.ts Adds attribution through existing CLI settings.
github-action/​README.md Explains attribution and analytics separation.
github-action/​dist/​index.cjs Updates bundled Action attribution.

Review effort: Balanced

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: dc54791af9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@alandelong-oai alandelong-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for preserving caller telemetry controls while consolidating request attribution and usage accounting. Owner-level merge-safety review: no material unresolved findings. Missing worker measurements remain unknown, measured subtotals still enforce budgets, and migration 51 retains retry-thread history without changing existing migrations.

Validation included 161 Action tests, 120 fresh/resumed discovery/reducer launches, 17 real SQLite/rollout cases, cost and metadata tests, native configuration checks, builds, types, formatting, and portable checks. Current CI reports for a merge with an identical source tree passed the relevant Python and MCP coverage plus two Linux SDK shards. Local runtime suites encountered ownership/Git fixture constraints and are not counted as passing; full cross-platform CI was still running at review time.

Copy link
Copy Markdown
Collaborator Author

Integrated main in 0471da6 after Windows shard 2 reached the old 25-minute timeout. This brings in the merged 40-minute CI budget and Windows credential handling; the telemetry changes are unchanged. Formatting and diff checks pass. Fresh hosted CI is pending.

@codex review

Please review the updated head and main integration.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 0471da6fdc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Cross-process telemetry, budget accounting, and the persistent migration need fresh CI and human validation, alongside the retained attribution correction.

1 open issue

Review effort: Balanced

Comment thread sdk/typescript/src/request-metadata.ts

Copy link
Copy Markdown
Collaborator Author

@codex review

Updated head efc4ec3 addresses the provider-attribution review finding with a two-line implementation/test change. Configured and inherited-context smoke checks, formatting, and diff checks pass. Please review the updated head; fresh CI is pending.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: efc4ec34b2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Cross-process configuration and persistent usage changes need final human review and pending cross-platform validation, with a usage-history issue still unresolved.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Preserve account rate limits when token coverage is unavailable

plugins/​codex-security/​scripts/​workbench_scan_usage.py:186

When an owned rollout has an account-rate-limit update (token_count with info: null) but no token receipt, this return discards the rate_limits collected above. The saved usage then loses observed allowance history, although token coverage and account-rate-limit observations are independent. Keep coverage unavailable, but include any collected accountRateLimits; add a regression case where no thread has measured tokens.

1 resolved since last review

Review effort: Balanced

@alandelong-oai alandelong-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for fixing the provider attribution. Owner-level merge-safety review: one usage-history issue remains. I independently confirmed the reported allowance-snapshot loss; the inline comment adds the base/head reproduction and the persistence-contract change needed to fix it.

Current-head metadata tests, native configuration checks, builds, types, and formatting pass. The additional real SQLite/rollout probe confirms the regression while its measured-token control passes. Earlier Action, accounting, migration, worker-launch, and portable-check evidence remains applicable to unchanged inputs. Full local suites retain the documented ownership/Git fixture limitations, and current cross-platform CI is still pending.

Comment thread plugins/codex-security/scripts/workbench_scan_usage.py Outdated
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

Updated head: 9e9db95.

Allowance snapshots from owned sessions now survive missing token measurements and remain available during pending finalization. This preserves unavailable token coverage and existing costs without fabricating zero totals.

All 127 usage tests, 12 request-metadata tests, and the required portable source checks pass. Please review this follow-up and its parent/worker, delayed-receipt, and persisted-contract coverage.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 9e9db95a04

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Cross-process configuration inheritance, budget accounting, and persistent-schema changes warrant final human review alongside hosted CI.

No open issues 🎉

Review effort: Balanced

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

Current head: 41983f1.

Integrated main while preserving telemetry forwarding, Daybreak settings, and Windows policy credential protections. The allowance-snapshot fix remains intact and all 127 usage tests pass. MCP worker-launch checks, focused SDK validation, required portable checks, type checks, and Action build/distribution checks completed; the PR body records the local temporary-path limitation and successful focused rerun. Please review this integration before merge.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 41983f1ace

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The persistent migration and cross-process telemetry and usage-accounting changes warrant final human review and fresh hosted CI validation.

No open issues 🎉

Review effort: Balanced

@alandelong-oai alandelong-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for fixing the allowance-history regression. Owner-level merge-safety review at 41983f1: no material unresolved findings. Allowance readings survive unavailable token measurements and pending finalization without inventing token totals; existing costs and sealed artifacts remain intact. The main integration preserves telemetry forwarding, Daybreak settings, and credential protections.

Current-head validation passed 524 focused SDK/CLI tests (three platform skips), MCP worker/database/store checks, 171 Action tests, Action metadata/docs/distribution checks, 12 SQLite lifecycle/validator probes, builds, types, formatting, and portable source checks. The 380 Python usage/database/migration passes (three platform skips) are reused from 9e9db95 after verifying unchanged Linux inputs. Full SDK suites and Windows runtime checks were not rerun.

@mldangelo-oai
mldangelo-oai merged commit 2c6028b into main Oct 20, 2026
143 of 146 checks passed
@mldangelo-oai
mldangelo-oai deleted the mdangelo/codex/shared-telemetry-context branch October 20, 2026 02:28
@github-actions github-actions Bot mentioned this pull request Oct 20, 2026
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants