Skip to content

feat(maintain): add promote_check task to ontos maintain#78

Merged
ohjonathan merged 6 commits intomainfrom
feat/maintain-promote-check
Feb 23, 2026
Merged

feat(maintain): add promote_check task to ontos maintain#78
ohjonathan merged 6 commits intomainfrom
feat/maintain-promote-check

Conversation

@ohjonathan
Copy link
Owner

Summary

Adds promote_check (order 45) to the ontos maintain pipeline. Runs ontos promote --check non-interactively to report documents ready for promotion from L0/L1 to L2.

Changes

  • maintain.py: New registered task _task_promote_check at order 45
  • Ontos_Agent_Instructions.md: "Maintain Ontos" section updated (8 → 9 tasks)
  • Ontos_Manual.md: Numbered task list updated (8 → 9 tasks)
  • test_maintain.py: Updated registry order assertion + 2 new tests

Design Notes

  • ontos scaffold was not added separately because migrate_untagged (order 10) already calls find_untagged_files + _run_scaffold_command(apply=True)
  • promote_check uses the existing --check mode which is non-interactive and read-only

Tests

All 22 maintain tests pass.


Antigravity, powered by Claude

Add promote_check (order 45) to the maintain pipeline. Runs
ontos promote --check non-interactively to report documents
ready for promotion from L0/L1 to L2.

- New registered task _task_promote_check in maintain.py
- Updated docs: Manual and Agent Instructions (8 → 9 tasks)
- Annotated migrate_untagged as covering scaffold
- Added 2 new tests for promote_check (normal + dry-run)
- All 22 maintain tests pass
@ohjonathan
Copy link
Owner Author

Review: 3-agent team (Alignment, Code Quality, Adversarial)

Verdict: REQUEST CHANGES (test fixes only — production code is sound)


Alignment Review — APPROVE

PR is well-aligned with project goals. All conventions followed (commit style, branch naming, task registration pattern, test naming). Docs are consistent across Manual, Agent Instructions, and registry test. Design decisions verified in code:

  • migrate_untagged already covers scaffold ✓
  • promote --check is genuinely read-only (returns before any SessionContext or commit()) ✓

Code Quality Review — COMMENT (2 Major in test quality)

Production code is correct and follows established patterns perfectly. Issues are confined to test quality.


Adversarial Review — REQUEST CHANGES (1 High, 2 Medium)

Core safety claim verified: check=True is provably read-only. However both tests are fundamentally flawed.


Consolidated Findings

Sev Finding
HIGH test_promote_check_task_reports_promotable_docs scans the real project (cwd), not the test fixture — provides zero signal
MEDIUM test_promote_check_dry_run_skips_scan monkeypatches __wrapped__ which doesn't exist; raising=False silently swallows the failure, making the safety net inert
MEDIUM No failure-path test for exit_code != 0
LOW Session log missing trailing newline
LOW Pre-existing typo "documents find""documents found" in promote.py:216

Implementation Prompt

Three fixes needed, all in tests/commands/test_maintain.py:

Fix 1: test_promote_check_task_reports_promotable_docs scans real project, not fixture

_run_promote_command calls find_project_root() which resolves from cwd, not from the test's tmp_path. The test creates fixture docs but the task scans whatever project is at the current working directory.

Fix: Add monkeypatch to the test signature and call monkeypatch.chdir(tmp_path) before invoking the task. Then assert on the message content (e.g., "1 documents" or similar) to verify the fixture was actually scanned — not just result.status == "success".

Fix 2: test_promote_check_dry_run_skips_scan monkeypatch is inert

The monkeypatch targets _task_promote_check.__wrapped__, but register_maintain_task doesn't use functools.wraps, so __wrapped__ doesn't exist. The raising=False silently swallows this, making the safety net a no-op.

Fix: Replace the monkeypatch target with ontos.commands.promote._run_promote_command. Remove raising=False. Example:

monkeypatch.setattr(
    "ontos.commands.promote._run_promote_command",
    lambda _opts: (_ for _ in ()).throw(AssertionError("dry-run should not call promote")),
)

Fix 3: Add failure-path test

The _fail() branch (when exit_code != 0) is untested.

def test_promote_check_reports_failure(tmp_path, monkeypatch):
    _init_project(tmp_path)
    monkeypatch.chdir(tmp_path)
    ctx = _build_context(tmp_path, quiet=True)
    monkeypatch.setattr(
        "ontos.commands.promote._run_promote_command",
        lambda _opts: (1, "Document load failed"),
    )
    result = _task_promote_check(ctx)
    assert result.status == "failed"
    assert "Document load failed" in result.message

Verification

python3 -m pytest tests/commands/test_maintain.py -v --tb=short

🤖 3-agent review by Claude Code

- Fix test_promote_check_task_reports_promotable_docs: monkeypatch cwd
  to tmp_path so promote scans the fixture, not the real project
- Fix test_promote_check_dry_run_skips_scan: patch _run_promote_command
  directly instead of nonexistent __wrapped__ attribute
- Add test_promote_check_reports_failure for the exit_code != 0 branch
- Fix pre-existing typo 'documents find' → 'documents found' in promote.py
- Add trailing newline to session log
@ohjonathan
Copy link
Owner Author

Round 2 Review: All 3 Agents APPROVE

Review Round 1 Round 2
Alignment APPROVE APPROVE
Code Quality COMMENT (2 Major) APPROVE (4/4 resolved)
Adversarial REQUEST CHANGES (1 High, 2 Medium) APPROVE (all verified fixed)

All Round 1 findings resolved

Finding Sev Status
Test scans real project, not fixture HIGH Fixed — monkeypatch.chdir(tmp_path) + message assertion
Dry-run monkeypatch targets non-existent __wrapped__ MEDIUM Fixed — targets _run_promote_command directly
No failure-path test MEDIUM Fixed — new test_promote_check_reports_failure added
Typo "documents find" NIT Fixed — "documents found"

Residual (non-blocking, cosmetic)

  • LOW: "1 documents found" — no singular/plural handling (pre-existing in promote.py)
  • LOW: Session log missing trailing newline

Test suite

23/23 maintain tests pass. No new issues introduced by the fix commit.

Consensus: APPROVE for merge.

🤖 3-agent review by Claude Code

… consistency

1. Root correctness:
   - Add optional repo_root to PromoteOptions
   - _run_promote_command uses repo_root when provided, falls back
     to find_project_root() for CLI compatibility
   - _task_promote_check passes ctx.repo_root, decoupling from CWD

2. Ready semantics:
   - --check now reports 'N ready for promotion (M candidates)'
   - Ready count = docs with info.promotable == True
   - Total candidates = all L0/L1 docs
   - Docs updated to reflect 'ready count' semantics

3. Artifact consistency:
   - Regenerated Ontos_Context_Map.md and AGENTS.md from commands

4. Tests (29/29 pass):
   - test_promote_check_uses_repo_root_not_cwd: regression for root
   - test_promote_check_excludes_non_ready_from_ready_count: ready semantics
   - Updated assertions in test_promote_parity.py and
     test_b2_promote_absolute_path.py for new message format
@ohjonathan ohjonathan merged commit f1beb20 into main Feb 23, 2026
5 checks passed
@ohjonathan ohjonathan deleted the feat/maintain-promote-check branch February 23, 2026 03:34
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