Skip to content

[AAASM-5756] ✨ (scripts): Add --root override and a negative control to check_contact_metadata.py - #327

Merged
Chisanan232 merged 2 commits into
mainfrom
v0.0.1/AAASM-5756/feat/contact_metadata_root_override
Sep 3, 2026
Merged

[AAASM-5756] ✨ (scripts): Add --root override and a negative control to check_contact_metadata.py#327
Chisanan232 merged 2 commits into
mainfrom
v0.0.1/AAASM-5756/feat/contact_metadata_root_override

Conversation

@Chisanan232

Copy link
Copy Markdown
Contributor

Description

Adds a --root CLI override to scripts/check_contact_metadata.py (the script that syncs SECURITY.md and pyproject.toml's author email against the pinned canonical org contact-metadata registry), and adds a negative-control test proving the gate fails closed when the generated region is dropped.

This is 1 of 4 independent repo-scoped PRs for AAASM-5756 (parent cross-repo ticket). The other three land the equivalent slice in agent-assembly, node-sdk, and .github. No cross-repo dependency — this PR is self-contained and mergeable on its own.

  • --root matches the exact precedent already established by scripts/check_claim_vocabulary.py (parser.add_argument("--root", default=".", help="repository root")root = Path(args.root).resolve()), adapted to this script's existing --check-only argparse shape (default None, falling back to the existing _repo_root() when omitted so the default in-place-sync/check behavior is unchanged).
  • No change to the script's content-generation logic, the pinned registry values, or the registry commit pin (REGISTRY_SOURCE/CANONICAL).

Type of Change

  • ✨ New feature
  • ♻️ Refactoring (test-only addition below)

Breaking Changes

  • No

Related Issues

  • Related JIRA ticket: AAASM-5756

Testing

  • Unit tests added/updated — test/unit/test_contact_metadata_negative_control.py, 6 cases, all using tmp_path fixture copies of the real SECURITY.md/pyproject.toml driven through the script's own main() via --root.

The negative control proves the AC#4 gate-failure property: the parent ticket requires that dropping the generated region unambiguously turns the gate red. Cases and their exit codes (read from the script's own sys.exit/return sites, not assumed):

Case Exit code Why
Clean copy (byte-identical to real SECURITY.md/pyproject.toml) 0 in sync
BEGIN GENERATED: security_contact sentinel removed 2 fail-closed ContactDriftError — region not found
Whole generated block deleted (both sentinels + body) 2 same fail-closed path
Legacy .dev domain swapped into the block's email 1 in-region value drift under --check
SLA day-count edited 1 same drift path
pyproject.toml author email duplicated to 2 entries 2 fail-closed exactly-one-match count guard

The generated-region-removed → non-zero exit case is the one AC#4 requires to unambiguously exist; it's labeled in the test docstrings.

Verification (all run locally)

$ .venv/bin/python scripts/check_contact_metadata.py --check
Contact metadata is in sync with the pinned registry.
$ echo $?
0

$ .venv/bin/python -m pytest test/unit/test_contact_metadata_negative_control.py -v --no-cov
6 passed in 0.03s

$ .venv/bin/ruff check .
All checks passed!

$ .venv/bin/ruff format --check scripts/check_contact_metadata.py test/unit/test_contact_metadata_negative_control.py
2 files already formatted

$ .venv/bin/mypy agent_assembly
# 5 pre-existing errors, all `agent_assembly._core` (native shim not built in
# this checkout) / grpc stubs — unrelated to this PR's changed files
# (scripts/, test/), unchanged by this diff.

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Comments added for complex logic
  • Documentation updated if needed (module docstring in the new test file explains the AC#4 mapping)
  • All tests passing

Chisanan232 and others added 2 commits September 3, 2026 08:56
AAASM-5756: threads a --root override through the pyproject.toml/
SECURITY.md sync check so a negative-control test can point it at a
tmp_path fixture tree instead of the real repo checkout. Matches the
--root precedent already established in check_claim_vocabulary.py.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MrqouPFk9KoAw4DJLrDUDv
…ils on a dropped region

AAASM-5756 AC#4: proves scripts/check_contact_metadata.py --check goes
red (exit 2) when the SECURITY.md generated region's sentinels are
dropped, exit 2 for a duplicated pyproject.toml author email (the
fail-closed exactly-one-match guard), and exit 1 for in-region value
drift (legacy-domain swap, SLA day-count edit). Uses --root to point
the script at a tmp_path fixture copy of the real consumer files.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MrqouPFk9KoAw4DJLrDUDv
@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sonarqubecloud

sonarqubecloud Bot commented Sep 3, 2026

Copy link
Copy Markdown

@Chisanan232

Copy link
Copy Markdown
Contributor Author

LGTM — merging.

Independent review (fresh agent, read-only) verified: `--root` fully redirects every path the script touches (pyproject.toml + SECURITY.md, no fallback to `file` when set); all 6 negative-control test cases construct genuine tmp_path fixtures and assert against the script's real exit-code control flow (traced line-by-line, not trusted); the AC#4 "region entirely removed → gate fails" case is unambiguous; the pyproject duplicate-author "fail-closed count guard" claim is real (verified the regex/count logic); no live-tree mutation; ruff/mypy clean; CI already green. Verdict: ship as-is.

Merging via the AAASM-5858 owner-only admin-merge exception: verified fresh as org admin (`Chisanan232`); CI green, no conflicts, no unresolved defect, no REQUEST_CHANGES; the only blocker is same-identity REVIEW_REQUIRED. Merge method: Create a merge commit.

@Chisanan232
Chisanan232 merged commit 3a321a1 into main Sep 3, 2026
22 checks passed
@Chisanan232
Chisanan232 deleted the v0.0.1/AAASM-5756/feat/contact_metadata_root_override branch September 3, 2026 01:04
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