Skip to content

feat(wiki): Phase 8 — compile_topic_tracked + loop integration#8372

Merged
HydraOps-T-rav merged 1 commit intomainfrom
hydraflow/wiki-compile-topic-tracked
Apr 20, 2026
Merged

feat(wiki): Phase 8 — compile_topic_tracked + loop integration#8372
HydraOps-T-rav merged 1 commit intomainfrom
hydraflow/wiki-compile-topic-tracked

Conversation

@HydraOps-T-rav
Copy link
Copy Markdown
Collaborator

Summary

Closes the last piece of loop-side behaviour that hadn't been ported to the tracked layout. Once a topic has ≥ 5 status: active entries, RepoWikiLoop now calls WikiCompiler.compile_topic_tracked: LLM synthesis runs against per-entry files, and the resulting synthesis entries + superseded flag rewrites land in the next chore(wiki): maintenance PR. Stacked on #8371.

What's in

src/repo_wiki.py helpers

  • _load_tracked_active_entries(topic_dir) — dicts with id / title / body / source fields / path.
  • _write_tracked_synthesis_entry(topic_dir, *, entry, topic, supersedes) — emits per-entry file with source_issue: synthesis, source_phase: synthesis, supersedes: id1,id2,…, filename {id:04d}-issue-synthesis-{slug}.md.
  • _mark_tracked_entry_superseded(entry_path, *, superseded_by) — flips status + adds pointer; no-op on files without frontmatter.

WikiCompiler.compile_topic_tracked

Tracked counterpart of compile_topic. Reuses _COMPILE_TOPIC_PROMPT + _parse_entries. Returns 0 when < 2 active entries, LLM call fails, or parse returns empty.

RepoWikiLoop._do_work

Legacy compile pass unchanged. New tracked compile pass runs when tracked_root is set and topic has ≥ 5 active entries. Errors log at warning and don't crash the tick. Module-level _iter_tracked_active_files streams active files for the count check without the pydantic round-trip.

Tests (11 new, 45 total)

  • tests/test_compile_topic_tracked.py:
    • _load_tracked_active_entries returns only active (filters stale / superseded), missing dir, no-frontmatter tolerance
    • _write_tracked_synthesis_entry frontmatter shape + monotonic id
    • _mark_tracked_entry_superseded status flip + pointer + no-op on files without frontmatter
    • compile_topic_tracked writes synthesis + supersedes originals, skips < 2 active, LLM None keeps originals, LLM [] keeps originals

Stubs WikiCompiler._call_model via AsyncMock so the suite never touches a real LLM backend.

Test plan

  • uv run pytest tests/test_compile_topic_tracked.py tests/test_active_lint_tracked.py tests/test_repo_wiki_loop_pr.py — 45 pass.
  • make lint-check clean.
  • CI make quality.
  • After merge, the next wiki tick with a qualifying topic produces a PR with both the new synthesis entry and the superseded-flag rewrites bundled together.

🤖 Generated with Claude Code

Base automatically changed from hydraflow/wiki-active-lint-tracked to main April 20, 2026 16:00
Turns LLM synthesis on against the tracked per-entry layout.  Once a
topic has ≥ 5 ``status: active`` entries, RepoWikiLoop now calls
``WikiCompiler.compile_topic_tracked``: it reads the active entries,
asks the model to consolidate them, writes each synthesis output as a
new per-entry file under
``repo_wiki/{owner}/{repo}/{topic}/{id:04d}-issue-synthesis-{slug}.md``
with ``source_phase: synthesis`` and a ``supersedes:`` list, and
flips every input to ``status: superseded`` with a ``superseded_by``
pointer.  Those rewrites land as uncommitted diffs that the same
tick's ``_maybe_open_maintenance_pr`` bundles into the next
``chore(wiki): maintenance`` PR.

Helpers in src/repo_wiki.py

- ``_load_tracked_active_entries(topic_dir)`` — returns rich dicts
  (id / title / body / source fields / path) for every ``status:
  active`` entry.  Lets the compiler build the synthesis prompt
  without round-tripping through WikiEntry.
- ``_write_tracked_synthesis_entry(topic_dir, *, entry, topic,
  supersedes)`` — writes a synthesis entry with
  ``source_issue: synthesis`` and a ``supersedes: id1,id2,…`` field.
  Filename uses ``issue-synthesis`` so synthesis outputs are
  distinguishable at a glance from ingest entries.
- ``_mark_tracked_entry_superseded(entry_path, *, superseded_by)`` —
  flips ``status`` → ``superseded`` and adds ``superseded_by``.
  Silent no-op on files without frontmatter.

WikiCompiler

- ``compile_topic_tracked(tracked_root, repo, topic)`` — tracked
  counterpart of ``compile_topic``.  Reuses ``_COMPILE_TOPIC_PROMPT``
  and ``_parse_entries``.  Returns 0 when the topic has < 2 active
  entries, when the LLM call fails, or when the parse returns
  nothing.

RepoWikiLoop._do_work

- Existing legacy compile pass unchanged.
- New tracked compile pass runs when ``tracked_root`` is set and the
  topic has ≥ 5 active entries.  Failures log at ``warning`` and
  don't crash the tick.
- Module-level ``_iter_tracked_active_files(topic_dir)`` streams
  active files without building WikiEntry objects — avoids paying
  the pydantic round-trip just to count.

Tests (11 new, 45 total in the suite pass)

- ``tests/test_compile_topic_tracked.py``: ``_load_tracked_active_entries``
  returns only active (stale / superseded filtered), missing dir, no
  frontmatter; ``_write_tracked_synthesis_entry`` frontmatter shape +
  monotonic id; ``_mark_tracked_entry_superseded`` status flip + pointer
  + no-op on files without frontmatter; ``compile_topic_tracked``
  writes synthesis + supersedes originals, skips when < 2 active
  entries, LLM call returning None keeps originals, LLM returning
  ``[]`` keeps originals.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@HydraOps-T-rav HydraOps-T-rav force-pushed the hydraflow/wiki-compile-topic-tracked branch from 6df1cc3 to 8431682 Compare April 20, 2026 16:00
@HydraOps-T-rav HydraOps-T-rav merged commit 548036a into main Apr 20, 2026
20 checks passed
@HydraOps-T-rav HydraOps-T-rav deleted the hydraflow/wiki-compile-topic-tracked branch April 20, 2026 16:11
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