Skip to content

feat(wiki): Phase 3.5 — wire plan/review phases to git-backed writes#8358

Merged
HydraOps-T-rav merged 2 commits intomainfrom
hydraflow/wiki-phase-wiring
Apr 19, 2026
Merged

feat(wiki): Phase 3.5 — wire plan/review phases to git-backed writes#8358
HydraOps-T-rav merged 2 commits intomainfrom
hydraflow/wiki-phase-wiring

Conversation

@HydraOps-T-rav
Copy link
Copy Markdown
Collaborator

Summary

Phase 3.5 of the git-backed repo wiki. Turns on the Phase 3 per-entry write path from inside the running phase runners. Stacked on #8357.

What happens at runtime

When config.repo_wiki_git_backed is True and the issue worktree exists, PlanPhase._wiki_ingest_plan and ReviewPhase._wiki_ingest_review:

  1. Construct a worktree-scoped RepoWikiStore pointed at {worktree}/{repo_wiki_path}/.
  2. Write each entry as a per-entry markdown file via write_entry (compiler path uses classify_topic per entry; fallback path uses ingest_from_plan/review(..., git_backed=True)).
  3. Append a per-issue log record via append_log.
  4. Commit the new files via commit_pending_entries — targeted git add, message wiki: ingest {phase} for #{issue}.

When the flag is False or the worktree is missing, the legacy topic-level ingest path runs unchanged.

Dedup state (is_ingested / mark_ingested) keeps living on the main host's legacy wiki path regardless — the tracked writes are an additional artifact. Errors leave the legacy dedup mark unset so the next cycle retries.

What changed

  • src/plan_phase.py_wiki_ingest_plan gains _wiki_tracked_store + _wiki_commit_compiler_entries helpers; both compiler and fallback paths route through the tracked store when applicable.
  • src/review_phase.py — mirror changes for _wiki_ingest_review.
  • src/repo_wiki.py — promotes _classify_topic to a module-level classify_topic (the store's method stays as a backward-compat shim).

Rollback discipline

Compiler-synthesized entries are written in a batch; if any write raises mid-loop, every prior file in that batch is unlinked before the exception re-raises (log append never runs; no commit lands). Matches ingest_from_plan's _write_pairs_or_rollback.

Tests

tests/test_phase_wiki_wiring.py — 10 new parametrized tests covering both phases:

  • _wiki_tracked_store returns None when git_backed=False
  • _wiki_tracked_store returns None when the worktree is missing
  • _wiki_tracked_store returns a worktree-rooted store when both conditions hold
  • _wiki_commit_compiler_entries writes files, commits, respects path_prefix
  • Rollback removes all prior writes when one raises mid-batch

255 tests pass locally (includes the full plan/review/wiki suites). make lint-check clean.

Test plan

  • uv run pytest tests/test_plan_phase.py tests/test_review_phase_core.py tests/test_phase_wiki_wiring.py tests/test_repo_wiki*.py tests/test_wiki_migration.py — 255 passed.
  • make lint-check — clean.
  • CI make quality.
  • After merge, next plan/review cycle on any managed repo should produce a wiki: ingest {phase} for #{N} commit in the issue's PR.

🤖 Generated with Claude Code

Base automatically changed from hydraflow/wiki-per-entry-writes to main April 19, 2026 23:01
T-rav-Hydra-Ops and others added 2 commits April 19, 2026 17:02
Turns on the Phase 3 per-entry layout from inside the running phase
runners.  When `config.repo_wiki_git_backed` is True AND the issue
worktree exists, plan/review phase-ingests write their entries as
per-entry markdown files under `{worktree}/{repo_wiki_path}/` and commit
them via `RepoWikiStore.commit_pending_entries` so the wiki updates ride
the issue's PR.  When the flag is False or the worktree is missing, the
legacy topic-level ingest path runs unchanged.

Dedup state (`is_ingested` / `mark_ingested`) continues to live on the
main host's legacy wiki path regardless — the tracked writes are an
additional artifact, not a replacement for dedup bookkeeping.  Errors in
the tracked-write path still leave the legacy dedup mark unset so the
next cycle can retry.

Changes:

- PlanPhase._wiki_ingest_plan and ReviewPhase._wiki_ingest_review each
  gain `_wiki_tracked_store(issue_number)` and
  `_wiki_commit_compiler_entries(...)` helpers.  Both cover compiler and
  fallback paths: compiler-synthesized entries route through
  `write_entry` with `classify_topic`, fallback sections through
  `ingest_from_plan(..., git_backed=True)` /
  `ingest_from_review(..., git_backed=True)`.
- Promotes `_classify_topic` to a module-level `classify_topic` in
  repo_wiki so phase runners can call it without reaching into private
  store methods.  The store's `_classify_topic` method stays as a
  backward-compat shim.
- tests/test_phase_wiki_wiring.py — 10 new parametrized tests covering
  both PlanPhase and ReviewPhase: `_wiki_tracked_store` decision under
  config flag + worktree-missing branches; `_wiki_commit_compiler_entries`
  producing a commit with the expected files; rollback removes prior
  writes when one raises mid-batch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The Phase 3.5 wiring called `RepoWikiStore.commit_pending_entries`
directly from `PlanPhase._wiki_ingest_plan` / `ReviewPhase._wiki_ingest_review`,
both of which are `async def`. `commit_pending_entries` runs three
synchronous `subprocess.run` git calls (status, add, commit); a slow
`git commit` would block the event loop and stall all five concurrent
phase loops (ADR-0001).

Fix:
- Wrap the compiler-path tracked write in `asyncio.to_thread`:
  `_wiki_commit_compiler_entries` now runs in a worker thread.
- Extract the fallback path into module-level `_run_fallback_ingest_plan`
  / `_run_fallback_ingest_review` helpers so they can be dispatched via
  `asyncio.to_thread` without binding a method reference.
- Legacy (non-git-backed) path unchanged — it was already file-I/O-only
  and fast enough not to block.

Also:
- Replaces a private-attribute assertion in
  test_phase_wiki_wiring.py::TestWikiTrackedStore::test_returns_tracked_store_when_worktree_exists
  (`tracked._wiki_root == ...`) with a behaviour check: write an entry
  and assert it lands under `worktree/repo_wiki/<topic>/`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@HydraOps-T-rav HydraOps-T-rav force-pushed the hydraflow/wiki-phase-wiring branch from 186001a to 35fc358 Compare April 19, 2026 23:02
@HydraOps-T-rav HydraOps-T-rav merged commit 0e0d79f into main Apr 19, 2026
19 checks passed
@HydraOps-T-rav HydraOps-T-rav deleted the hydraflow/wiki-phase-wiring branch April 19, 2026 23:02
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