"""Register the send_result_to_send_20260616 track in conductor/tracks.md."""
from __future__ import annotations

from pathlib import Path

TRACKS = Path("conductor/tracks.md")

NEW_ENTRY = """#### Track: Rename send_result to send (sandbox test track) `[track-created: 2026-06-16]` [shipped: 2026-06-17]
*Link: [./tracks/send_result_to_send_20260616/](./tracks/send_result_to_send_20260616/), Spec: [./tracks/send_result_to_send_20260616/spec.md](./tracks/send_result_to_send_20260616/spec.md), Plan: [./tracks/send_result_to_send_20260616/plan.md](./tracks/send_result_to_send_20260616/plan.md), Metadata: [./tracks/send_result_to_send_20260616/metadata.json](./tracks/send_result_to_send_20260616/metadata.json)*

*Status: 2026-06-17 - SHIPPED. 6 phases, 10 atomic rename commits + 12 plan/script commits (22 total). The FIRST end-to-end test of the `tier2_autonomous_sandbox_20260616` sandbox. Refactor track (mechanical rename; no behavior change). Scope: 37 files modified (6 src/ + 27 tests/ + 3 docs + 1 metadata/state); 0 files added, 0 files deleted. Spec estimated 38 files; actual 37 (test_deprecation_warnings.py no longer exists in the repo).*

*Goal: Revert the 2026-06-15 public_api_migration rename (`ai_client.send` -> `ai_client.send_result`) back to `ai_client.send`. The migration was driven by the data-oriented error handling convention; the user wants the shorter name now that the Tier 2 autonomous sandbox can do the rename safely. Pure mechanical rename across 37 files + a surgical rewrite of one stale deprecation section in error_handling.md.*

*Deliverables: 0 new files, 0 deleted files. The 22 commits include 10 atomic rename commits (1 in src/ai_client.py + 1 batch in 5 other src/ + 5 per-file in top 5 tests + 1 batch in 22 remaining tests + 1 in 3 docs) and 12 plan/script commits (audit trail + helper scripts). The audit_tier2 subdirectory in scripts/tier2/ accumulates the rename + plan-update helper scripts as a record of the mechanical change pattern.*

*Test inventory: 100/101 tests pass in the 26 files directly affected by the rename. 1 pre-existing failure (test_headless_service.py::test_generate_endpoint) unrelated to the rename - confirmed by running the same test against origin/master baseline where it also fails (missing credentials.toml). 7 broader suite failures are all pre-existing credentials.toml issues, also confirmed against origin/master.*

`blocks:` None (independent refactor + sandbox test).
"""


def main() -> int:
 with TRACKS.open("r", encoding="utf-8", newline="") as f:
  content = f.read()
 # Insert after the Tier 2 Autonomous Sandbox block ends. The anchor is
 # the start of the next track (Exception Handling Audit).
 anchor = "#### Track: Exception Handling Audit"
 if anchor not in content:
  print(f"Anchor not found: {anchor!r}", file=__import__("sys").stderr)
  return 1
 new_content = content.replace(anchor, NEW_ENTRY + "\n" + anchor, 1)
 with TRACKS.open("w", encoding="utf-8", newline="") as f:
  f.write(new_content)
 print(f"Inserted {len(NEW_ENTRY)} chars before '{anchor}'")
 return 0


if __name__ == "__main__":
 raise SystemExit(main())
