Skip to content

Add plugin script lifecycle analytics contract - #31851

Closed
kmbroai wants to merge 2 commits into
dev/kyleb/plugin-script-identity-v3from
dev/kyleb/plugin-script-analytics-contract-v3
Closed

kmbroai wants to merge 2 commits into
dev/kyleb/plugin-script-identity-v3from
dev/kyleb/plugin-script-analytics-contract-v3

Conversation

@kmbroai

@kmbroai kmbroai commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

What

  • Add typed lifecycle analytics facts and requests for started, completed, failed, and interrupted.
  • Carry the execution ID, normalized plugin-relative script path, duration, exit code, and optional skill ID.
  • Fail closed on non-normalized or sensitive script paths before serialization.
  • Preserve lifecycle emission for direct core sessions that do not have app-server reducer context.

Why

Phase 1 of Codex Plugin Metrics needs best-effort script lifecycle telemetry without sending sensitive absolute user paths, and the design is UI-agnostic across app-server and direct sessions.

Stacked on #31850.

Backend ingestion: openai/openai#1111392.

How

  • Add lifecycle fact/status types and the analytics client entrypoint.
  • Reduce lifecycle facts into codex_plugin_lifecycle_event.
  • Reject absolute, parent-relative, drive, UNC, backslash, empty, or non-normalized script paths at the telemetry boundary.
  • Prefer registered app-server context and fall back to fact-supplied session/client identity for direct sessions.
  • Add reducer coverage for metadata enrichment, direct-session emission, and sensitive-path suppression.

I tested this

  • just fmt — passed
  • just fix -p codex-core-plugins -p codex-plugin -p codex-analytics -p codex-core -p codex-features -p codex-app-server -p codex-windows-sandbox — passed (stack-wide scoped lint gate)
  • just argument-comment-lint — passed
  • just test -p codex-analytics — passed (86/86)
  • just test — attempted; the local workspace build stopped before tests because the runner lacks system libcap for unrelated codex-bwrap. Exact-head CI provides the full Linux/macOS/Windows matrix.

@kmbroai
kmbroai force-pushed the dev/kyleb/plugin-script-identity-v3 branch from 592501a to 5bb246b Compare July 9, 2026 19:23
@kmbroai
kmbroai force-pushed the dev/kyleb/plugin-script-analytics-contract-v3 branch from 8aa0023 to 1be315c Compare July 9, 2026 19:24
@kmbroai
kmbroai force-pushed the dev/kyleb/plugin-script-identity-v3 branch from 5bb246b to fd57476 Compare July 9, 2026 22:27
@kmbroai
kmbroai force-pushed the dev/kyleb/plugin-script-analytics-contract-v3 branch from 1be315c to 0e6aeaa Compare July 9, 2026 22:28
@kmbroai
kmbroai force-pushed the dev/kyleb/plugin-script-identity-v3 branch from fd57476 to 912c70f Compare July 9, 2026 22:54
@kmbroai
kmbroai force-pushed the dev/kyleb/plugin-script-analytics-contract-v3 branch from 0e6aeaa to cf93b45 Compare July 9, 2026 22:54
@kmbroai
kmbroai marked this pull request as ready for review July 9, 2026 23:13

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cf93b45ac4

ℹ️ 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".

parent_thread_id: thread_metadata.parent_thread_id.clone(),
plugin_id: input.plugin_id,
execution_id: input.execution_id,
script_path: input.script_path,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Normalize plugin script paths before telemetry

If a caller builds this new fact from existing hook metadata such as HookRunSummary.source_path, the value is an absolute path, and the reducer forwards input.script_path unchanged into the analytics payload. That means plugin script lifecycle telemetry can leak /Users/... or other local path details whenever the caller passes an absolute or unnormalized script path, which contradicts the intended sensitive-path suppression; normalize/validate it against the plugin root or use a typed plugin-relative path before serializing.

Useful? React with 👍 / 👎.

Comment thread codex-rs/analytics/src/reducer.rs Outdated
Comment on lines +1457 to +1458
let Some((connection_state, thread_state, thread_metadata)) =
self.thread_context_or_warn(AnalyticsDropSite::plugin_script_lifecycle(&input))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Do not drop lifecycle events in direct core sessions

When plugin script lifecycle facts are emitted from the core session path, there may be no app-server Initialize/ThreadStart response facts in this reducer to populate connections and threads, so this context lookup returns None and the new lifecycle event is silently dropped. Existing hook analytics from core only needs the tracking payload, but this new path requires app-server thread metadata before it can emit anything; either seed the thread context for direct sessions or allow this event to be reduced from the fact's own thread/turn data.

Useful? React with 👍 / 👎.

@kmbroai
kmbroai force-pushed the dev/kyleb/plugin-script-analytics-contract-v3 branch from cf93b45 to ef993e5 Compare July 10, 2026 01:10

kmbroai commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by openai/codex-internal#1386 after the Codex source-of-truth migration. The internal replacement preserves this stack position and carries the validated review fixes.

@kmbroai kmbroai closed this Jul 10, 2026
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