Skip to content

feat(telemetry): implement constraint evaluation — Phase 3#30

Merged
pertrai1 merged 5 commits into
mainfrom
feat/telemetry-phase-3-constraints
Apr 18, 2026
Merged

feat(telemetry): implement constraint evaluation — Phase 3#30
pertrai1 merged 5 commits into
mainfrom
feat/telemetry-phase-3-constraints

Conversation

@pertrai1

Copy link
Copy Markdown
Owner

Summary

Implements Telemetry Phase 3 (Constraint Evaluator) — the critical-path blocker for Wave 1 of the unified ROADMAP. Enables constraint evaluation against pipeline events to prevent runaway token spend, infinite retry loops, and stages that exceed duration limits.

3 new capabilities:

  • ConstraintEvaluator (ConstraintEvaluatorImpl) — core evaluation engine with addConstraint, removeConstraint, evaluate. Supports pipeline-scoped and stage-scoped constraints. Evaluates against all events from StorageBackend.
  • Default constraints — 5 pre-built factory functions: createMaxRetriesConstraint, createTokenBudgetConstraint, createDurationConstraint, createConsecutiveFailuresConstraint, createLintViolationsConstraint + batch createDefaultConstraints factory.
  • Builder utilitiesthreshold(), boolean(), aggregation() for declarative constraint construction with all comparison operators.

Quality gates: Build ✅, 112 tests passing ✅, Lint ✅ (0 errors), Performance ✅ (p99 < 50ms with 10 constraints × 1000 events).

Test plan

  • npx nx build telemetry passes
  • npx nx test telemetry — 112 tests passing (6 evaluator + 17 defaults + 15 builders + 1 performance + 40 telemetry + 30 storage + 3 types)
  • npx nx lint telemetry — 0 errors
  • npx nx affected -t build,test,lint — all 4 affected projects pass
  • Performance test validates NF-002 (< 50ms p99)

Requirements covered

F-020, F-021, F-022, F-023, F-030, F-031, F-032, F-034, NF-002

pertrai1 and others added 5 commits April 18, 2026 11:10
…stage scoping

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
…ails

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
…, aggregation)

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
… evaluation

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@coderabbitai

coderabbitai Bot commented Apr 18, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

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

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 43 minutes and 20 seconds.

⌛ 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f06a55e8-9120-46be-84b7-81032b6690f0

📥 Commits

Reviewing files that changed from the base of the PR and between 528063e and 7b7b183.

📒 Files selected for processing (18)
  • openspec/changes/archive/2026-04-18-telemetry-constraints/.openspec.yaml
  • openspec/changes/archive/2026-04-18-telemetry-constraints/design.md
  • openspec/changes/archive/2026-04-18-telemetry-constraints/proposal.md
  • openspec/changes/archive/2026-04-18-telemetry-constraints/specs/constraint-builder/spec.md
  • openspec/changes/archive/2026-04-18-telemetry-constraints/specs/constraint-evaluator/spec.md
  • openspec/changes/archive/2026-04-18-telemetry-constraints/specs/default-constraints/spec.md
  • openspec/changes/archive/2026-04-18-telemetry-constraints/tasks.md
  • openspec/specs/constraint-builder/spec.md
  • openspec/specs/constraint-evaluator/spec.md
  • openspec/specs/default-constraints/spec.md
  • packages/telemetry/src/ConstraintEvaluatorImpl.ts
  • packages/telemetry/src/constraints/builder.ts
  • packages/telemetry/src/constraints/defaults.ts
  • packages/telemetry/src/index.ts
  • packages/telemetry/tests/builder.test.ts
  • packages/telemetry/tests/constraints-performance.test.ts
  • packages/telemetry/tests/constraints.test.ts
  • packages/telemetry/tests/default-constraints.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/telemetry-phase-3-constraints

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7b7b1834b6

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

constraintName,
stage,
message: result.message ?? `Constraint failed: ${constraintName}`,
severity: 'error',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve configured violation severity during evaluation

createViolation hard-codes every failure as severity: 'error', so callers cannot emit warning or critical violations even though ConstraintViolation supports them. This causes downstream policy logic to treat all default constraints as hard errors, which breaks severity-based gating when a constraint is intended to be advisory or critical.

Useful? React with 👍 / 👎.

Comment on lines +74 to +78
const existing = groups.get(event.stage);

if (existing === undefined) {
groups.set(event.stage, {
stage: event.stage,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Separate stage groups by phase to avoid mixed evaluations

Stage events are grouped only by event.stage, which merges repeated executions of the same stage across different phase values into one bucket. When a stage appears again in a later phase, stage-scoped constraints evaluate against combined historical + in-progress events, so per-stage checks can falsely pass/fail because they are no longer scoped to a single completed stage run.

Useful? React with 👍 / 👎.

@pertrai1
pertrai1 merged commit c2f1d66 into main Apr 18, 2026
2 checks passed
@pertrai1
pertrai1 deleted the feat/telemetry-phase-3-constraints branch April 18, 2026 19:09
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