Skip to content

fix: code review fixes + agent-friendly docs#11

Merged
sunilgattupalle merged 2 commits into
mainfrom
fix/review-and-agent-friendly
Jul 5, 2026
Merged

fix: code review fixes + agent-friendly docs#11
sunilgattupalle merged 2 commits into
mainfrom
fix/review-and-agent-friendly

Conversation

@sunilgattupalle

Copy link
Copy Markdown
Contributor

Summary

  • Fork safety: register_at_fork moved inside the try block in Agent.__init__ so the hook only registers on successful init; removed duplicate registrations from AgentInit.__init__ and BuiltinPipelinePlugin.on_init
  • Half-init bug: is_lambda and register_at_fork now only execute after _initialized = True, preventing a broken post-fork state if init throws
  • Thread-safe singletons: Double-checked locking added to ControlRegistry.__new__ and Config.__new__
  • Rename: SamplingSpanProcessorDbControlSpanProcessor (file: db_control_span_processor.py); old module kept as a backwards-compat shim
  • Encapsulation: AgentInit._init_exporter promoted to public init_exporter; BuiltinPipelinePlugin no longer instantiates a private AgentInit
  • Dead code: Removed always-true inner if key in overriding_config guard in merge_config
  • Agent docs: AGENTS.md with env vars, plugin system, key files, pipeline diagram, build/test instructions; CLAUDE.md symlinks to it

Test plan

  • pytest test/db_control_span_processor_test.py test/sampling_span_processor_test.py test/config/ test/init/ test/filter/ — all 38 pass
  • Backwards-compat: from harness_sdk.sampling_span_processor import SamplingSpanProcessor still works via shim
  • Fork-handling: single post_fork call per fork (no duplicate provider/propagation reinit)

🤖 Generated with Claude Code

- agent.py: move register_at_fork inside try block so fork handler is
  only registered on successful init; fix _initialized guard so
  is_lambda isn't reset on every Agent() call
- agent_init.py: remove register_at_fork from AgentInit.__init__ to
  eliminate duplicate fork hook registrations; expose _init_exporter
  as public init_exporter
- plugins/builtin/pipeline.py: call init_exporter (no longer private);
  remove AgentInit instantiation that was registering a third fork hook
- plugins/control.py: add double-checked locking to ControlRegistry.__new__
  for thread-safe singleton construction
- config/config.py: add double-checked locking to Config.__new__;
  use getattr for _instance to handle test teardown that deletes the attr;
  remove dead inner `if key in overriding_config` check in merge_config
- sampling_span_processor.py: replace with backwards-compat shim;
  rename class to DbControlSpanProcessor in new db_control_span_processor.py
- tests: update to use init_exporter and db_control_span_processor module
- CLAUDE.md: add agent orientation doc covering env vars, plugin system,
  key files, pipeline diagram, and build/test instructions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

AI-Session-Id: b304dbed-aac0-46f5-821c-a12c4bb7e10d
AI-Tool: claude-code
AI-Model: unknown
Content lives in AGENTS.md (Codex/OpenAI agents convention);
CLAUDE.md is a symlink so Claude Code picks it up too.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

AI-Session-Id: b304dbed-aac0-46f5-821c-a12c4bb7e10d
AI-Tool: claude-code
AI-Model: unknown
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@sunilgattupalle
sunilgattupalle merged commit 17f6feb into main Jul 5, 2026
7 checks passed
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.

3 participants