Skip to content

feat(compass-agent): activate loop OpenTelemetry in cli.ts main() (RIG-2508 T1) - #648

Merged
mattwilkinsonn merged 2 commits into
mainfrom
compass-agent/rig-2508-loop-otel-activate
Aug 26, 2026
Merged

feat(compass-agent): activate loop OpenTelemetry in cli.ts main() (RIG-2508 T1)#648
mattwilkinsonn merged 2 commits into
mainfrom
compass-agent/rig-2508-loop-otel-activate

Conversation

@rigel-mintaka

@rigel-mintaka rigel-mintaka commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

This PR is part of a stack containing 2 PRs:

  1. main
  2. "feat(compass-agent): activate loop OpenTelemetry in cli.ts main() (RIG-2508 T1)" (this PR)
  3. docs(compass-agent): loop-OTel deployer contract + env reachability pin (RIG-2508 T2) #654

Implements task T1 of the frozen record
docs/designs/platform/compass-agent-loop-otel/design.md: activate the OMP
agent loop's native GenAI-semconv OpenTelemetry (invoke_agent / chat /
execute_tool spans) by passing telemetry: {} to createAgentSession,
gated hard on an OTLP endpoint being configured.

  • isTelemetryEndpointConfigured(env): the pre-registration gate mirroring
    initTelemetryExport (endpoint present via OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
    or the base OTEL_EXPORTER_OTLP_ENDPOINT, kill-switches clear).
  • Enabled path only: default OTEL_SERVICE_NAME (never clobber a deployer
    value), append compass.session.id=<manager session id> to
    OTEL_RESOURCE_ATTRIBUTES as the cross-signal join key (Decision 3a), then
    initTelemetryExport(). Order is load-bearing: env before registration.
  • telemetry: {} on the session options keyed off the authoritative
    post-registration isTelemetryExportEnabled() check; the key is omitted
    entirely when off.
  • Off by default: with no OTLP endpoint the whole block is skipped, so
    process.env is unmutated and the session build is bit-identical to a
    no-telemetry container (Global Constraints; F2).
  • Telemetry hooks injected at the MainDeps seam so tests assert the gating /
    env / option logic without running the real global-provider registration
    (F3 test isolation).

Zero transport change (OQ1 ruled (b)); no new deps, no bun.lock change.

Co-authored-by: Matt Wilkinson matt@rigel.build

…G-2508 T1)

Implements task T1 of the frozen record
docs/designs/platform/compass-agent-loop-otel/design.md: activate the OMP
agent loop's native GenAI-semconv OpenTelemetry (invoke_agent / chat /
execute_tool spans) by passing `telemetry: {}` to createAgentSession,
gated hard on an OTLP endpoint being configured.

- `isTelemetryEndpointConfigured(env)`: the pre-registration gate mirroring
  `initTelemetryExport` (endpoint present via OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
  or the base OTEL_EXPORTER_OTLP_ENDPOINT, kill-switches clear).
- Enabled path only: default OTEL_SERVICE_NAME (never clobber a deployer
  value), append `compass.session.id=<manager session id>` to
  OTEL_RESOURCE_ATTRIBUTES as the cross-signal join key (Decision 3a), then
  `initTelemetryExport()`. Order is load-bearing: env before registration.
- `telemetry: {}` on the session options keyed off the authoritative
  post-registration `isTelemetryExportEnabled()` check; the key is omitted
  entirely when off.
- Off by default: with no OTLP endpoint the whole block is skipped, so
  process.env is unmutated and the session build is bit-identical to a
  no-telemetry container (Global Constraints; F2).
- Telemetry hooks injected at the MainDeps seam so tests assert the gating /
  env / option logic without running the real global-provider registration
  (F3 test isolation).

Zero transport change (OQ1 ruled (b)); no new deps, no bun.lock change.

Co-authored-by: Matt Wilkinson <matt@rigel.build>
@linear-code

linear-code Bot commented Aug 26, 2026

Copy link
Copy Markdown

RIG-2508

@github-actions

github-actions Bot commented Aug 26, 2026

Copy link
Copy Markdown

Compass engineering docs preview: https://compass-agent-rig-2508-loop-sx7m.compass-eng-docs.pages.dev

Deployed from compass-agent/rig-2508-loop-otel-activate at 4310216.

…sEnabled (RIG-2508 T1)

Review of #648 flagged that the load-bearing "option gate authority"
invariant -- the telemetry session key gates on the post-registration
isEnabled(), not on the endpoint being configured -- had no behavioral
test. A regression swapping the gate to isTelemetryEndpointConfigured
would ship green because every existing test conflates endpoint-set with
enabled-after-init.

Add the distinguishing branch: telemetryDeps now takes registerOnInit
(default true); false models the protocol-decline case where init() runs
(endpoint gate fired, env defaults written) but no provider registers, so
isEnabled() stays false. The new test asserts that with an endpoint set
and a declining provider, init ran and env was written yet NO telemetry
key is added. Verified non-vacuous: swapping the gate to the endpoint
predicate reds this test alone.

Co-authored-by: Matt Wilkinson <matt@rigel.build>
@mattwilkinsonn
mattwilkinsonn merged commit 837687c into main Aug 26, 2026
22 checks passed
@mattwilkinsonn
mattwilkinsonn deleted the compass-agent/rig-2508-loop-otel-activate branch August 26, 2026 14:44
rigel-mintaka added a commit that referenced this pull request Aug 26, 2026
…in (RIG-2508 T2)

T2 of the frozen loop-OTel record. Two additive deliverables, no
production code-path change beyond T1.

- Env reachability test (cli.test.ts): pins that all four loop-OTel keys
  the Runner materializes into $HOME/.compass/env -- OTEL_SERVICE_NAME,
  OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, OTEL_RESOURCE_ATTRIBUTES,
  OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT -- survive
  isReservedEnvKey filtering (none are HOME/COMPASS_*) and reach
  process.env before the registration point (cli.ts:838), via the
  env-merge loop (cli.ts:614-618) that runs earlier. Non-vacuous: a
  COMPASS_-prefixed or HOME key would be dropped, as the neighboring test
  pins for COMPASS_FUTURE_VAR.
- deployer-contract.md: maintainer-facing reference for configuring a
  collector -- endpoint key, service-name override, content-capture
  opt-in + sensitivity warning, off-by-default guarantee, and the two
  asymmetries a deployer must know: F5 endpoint-gate (the loop honors
  OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, the transport gates only on
  OTEL_EXPORTER_OTLP_ENDPOINT) and F1 service-name split (an
  OTEL_SERVICE_NAME override renames the loop signal only; the durable
  cross-signal join is compass.session.id, not service.name). All cites
  source-verified against @oh-my-pi/pi-coding-agent@16.5.2 and the frozen
  transport otel-layer.ts.

Doc lives under docs/designs/platform/ (ungoverned ledger root -> no
DECISIONS row). Stacked on #648 (T1).

Co-authored-by: Matt Wilkinson <matt@rigel.build>
mattwilkinsonn added a commit that referenced this pull request Aug 27, 2026
…in (RIG-2508 T2) (#654)

* docs(compass-agent): loop-OTel deployer contract + env reachability pin (RIG-2508 T2)

T2 of the frozen loop-OTel record. Two additive deliverables, no
production code-path change beyond T1.

- Env reachability test (cli.test.ts): pins that all four loop-OTel keys
  the Runner materializes into $HOME/.compass/env -- OTEL_SERVICE_NAME,
  OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, OTEL_RESOURCE_ATTRIBUTES,
  OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT -- survive
  isReservedEnvKey filtering (none are HOME/COMPASS_*) and reach
  process.env before the registration point (cli.ts:838), via the
  env-merge loop (cli.ts:614-618) that runs earlier. Non-vacuous: a
  COMPASS_-prefixed or HOME key would be dropped, as the neighboring test
  pins for COMPASS_FUTURE_VAR.
- deployer-contract.md: maintainer-facing reference for configuring a
  collector -- endpoint key, service-name override, content-capture
  opt-in + sensitivity warning, off-by-default guarantee, and the two
  asymmetries a deployer must know: F5 endpoint-gate (the loop honors
  OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, the transport gates only on
  OTEL_EXPORTER_OTLP_ENDPOINT) and F1 service-name split (an
  OTEL_SERVICE_NAME override renames the loop signal only; the durable
  cross-signal join is compass.session.id, not service.name). All cites
  source-verified against @oh-my-pi/pi-coding-agent@16.5.2 and the frozen
  transport otel-layer.ts.

Doc lives under docs/designs/platform/ (ungoverned ledger root -> no
DECISIONS row). Stacked on #648 (T1).

Co-authored-by: Matt Wilkinson <matt@rigel.build>

* test(compass-agent): pin OTEL_SERVICE_NAME reachability with a distinct sentinel (RIG-2508 T2)

The four-key loop-OTel reachability test wrote OTEL_SERVICE_NAME=compass-agent,
which is byte-identical to the activation's `??=` default (cli.ts:839). A
filter-drop regression (key wrongly reserved by isReservedEnvKey) would
re-default to the same value, leaving the assertion green. Swap to a distinct
sentinel (deployer-custom-name) so the key must genuinely survive the filter
and reach process.env for the assertion to pass; proven to red under a
simulated reserve of OTEL_SERVICE_NAME. The other three keys were already
non-vacuous.

Co-authored-by: Matt Wilkinson <matt@rigel.build>

---------

Co-authored-by: Matt Wilkinson <matt@rigel.build>
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.

2 participants