Repository navigation
Add OBS-009..012 for agent-reliability-otel-labels label correctness - #261
Conversation
… correctness OBS-006..008 prove the agent-reliability-otel-labels labels are written; OBS-009..012 prove they are right. Four repo-scope rules: - OBS-009 (medium, 0.6): a Run shared between runs (module scope, class body, Python default argument, or a literal run id). - OBS-010 (low, 0.55): tool spans labelled only on success (no mark_tool_span in finally / except / catch, an error callback, or a .finally / .catch handler). - OBS-011 (low, 0.7): every tool-span label passes a constant attempt. - OBS-012 (low, 0.55): no run-end label can record a failure. Discovery: OtelLabelsSignal gains the run_construct kind and per-call facts (ModuleScope, RunIDConst, FailureSafe, HookUnknown, ErrorPath, AttemptConst, SideEffect, ExitReason). A Python construct under `if __name__ == "__main__":` is a one-run script and a non-static TS/JS class field runs per instance, so neither is module scope. Labels inside an OpenAI Agents RunHooks / AgentHooks on_tool_end are left out as unknown. Test-file signals never count and one correct call credits the repo. Rules: four predicates (repo_otel_labels_run_shared, repo_otel_labels_tool_span_failure_unsafe, repo_otel_labels_attempt_constant, repo_otel_labels_run_end_success_only). Findings carry the offending call's file and line, so SARIF renders them as located results. The scan report gains otel_labels (not folded into ScanID). schema_version 22 -> 23 (main took 22 for LC-116). The fixture holds 338 rules and is in sync with agent-reliability-rules. Do not merge before agent-reliability-otel-labels 0.1.1 is published: the 0.1.0 README example trips OBS-009..012.
sairenchristianbuerano
left a comment
There was a problem hiding this comment.
Resolve merge conflict
|
@ericksondelacruz heads-up on the rule schema number before this merges. main is now at schema 25 in both the analyzer and the rules pack: AGCFG-008 (Codex hooks) took 24 and AGCFG-009 (AGENTS.md hidden text) took 25. This PR still sets 23 (it was 22), and the companion rules PR #184 sets 23 too. Merged as is, the engine constant would go backwards while the pack says 25, and an older engine would skip the OTel label rules without telling anyone. Before merging:
|
Resolve conflicts with the agent_config work on main: - schema_version: main took 23-26 for the agent_config pack, so OBS-009..012's four predicates move to 27 (SupportedSchemaVersion and the fixture manifest). - rule_detector.go: repo findings try otel-labels evidence first, then fall back to main's configHitLocation for agent_config rules. - COVERAGE.md / CLAUDE.md: keep main's review entries, restate this batch as 26 -> 27 with re-derived counts (347 = 343 + 4).
This is now handled. Thank you! |
Main took schema 27 for OBS-009..012 (#261). The 26 -> 27 bump here merged cleanly on top of it, so renumber by hand: SupportedSchemaVersion and the fixture manifest go to 28. COVERAGE.md keeps both review entries; CHANGELOG, CLAUDE.md, ARCHITECTURE and COVERAGE restate the batch as 27 -> 28 with re-derived counts (356 = 347 + 9).
Summary
OBS-006..008 check that the agent-reliability-otel-labels labels are written at all. This PR adds OBS-009..012, four repo-scope rules that check the labels are correct:
Runis shared between runs: built at module scope, in a class body, or as a Python default argument, or given a literal run idmark_tool_spanin afinally/except/catchblock, an error callback, or a.finally/.catchhandlerattemptas a constantChanges
internal/analysis/otel_labels_facts.go).OtelLabelsSignalgains therun_constructkind and the facts the rules read:ModuleScope,RunIDConst,FailureSafe,HookUnknown,ErrorPath,AttemptConst,SideEffectandExitReason. Three cases are deliberately not flagged:if __name__ == "__main__":construct is a one-run script.RunHooks/AgentHookson_tool_endare treated as unknown, not unsafe.otel_labels. It is not folded intoScanID.schema_versiongoes from 26 to 27, becausemainalready took 22 for LC-116 and 23–26 for the agent_config pack.schema.yamlare updated. The fixture holds 347 rules.Testing
go vet ./...andgo test -race ./...pass.scripts/check-rules-sync.shagainst theagent-reliability-rulesbranchfeat/otel-labels-correctness: in sync, 133 files (re-run 2026-10-26 after mergingmain).main).Merge order
feat/otel-labels-correctnessPRs in agent-reliability-rules and trustabl-rulebook. The rulebook PR is "Rationale for OBS-009..012 (otel-labels label correctness) and LC-116".rules-syncjob uses the rules branch with the same name when it exists.Known limits
Recorded in the design spec and not addressed in this PR:
Run()inexamples/orscripts/.__exit__, and TS.then(ok, onRejected).self.run = Run()in a long-lived object is not caught.