Skip to content

feat(wiki): Phase 5 — /api/wiki/* read + admin-enqueue endpoints#8362

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

feat(wiki): Phase 5 — /api/wiki/* read + admin-enqueue endpoints#8362
HydraOps-T-rav merged 1 commit intomainfrom
hydraflow/wiki-api

Conversation

@HydraOps-T-rav
Copy link
Copy Markdown
Collaborator

Summary

Phase 5 of the git-backed repo wiki. Adds the dashboard API surface. Read endpoints traverse the tracked repo_wiki/ layout (Phase 2); admin endpoints enqueue MaintenanceTask entries into RepoWikiLoop._queue so every edit rides the single-track commit path that Phase 4 ships via chore(wiki): maintenance PRs. Nothing here mutates the wiki directly.

Routes

Method Path Purpose
GET /api/wiki/repos list repos with a wiki
GET /api/wiki/repos/{owner}/{repo}/entries filter by topic/status/q, paginated
GET /api/wiki/repos/{owner}/{repo}/entries/{entry_id} full entry + frontmatter
GET /api/wiki/repos/{owner}/{repo}/log merged per-issue audit log
GET /api/wiki/maintenance/status queue depth + open PR
POST /api/wiki/admin/force-compile enqueue synthesis task
POST /api/wiki/admin/mark-stale enqueue stale flag write
POST /api/wiki/admin/rebuild-index enqueue index rebuild
POST /api/wiki/admin/run-now trigger loop (soft-fallback when no hook)

Security

  • owner / repo path params reject .. or / before any filesystem lookup (path-traversal guard).
  • entry_id validated as 1–6 digits.
  • No authentication added — follows the existing dashboard-route pattern (matches memory routes).

Wiring

  • Registered in src/dashboard_routes/_routes.py alongside the other sub-routers.
  • Admin/status endpoints look up RepoWikiLoop and its MaintenanceQueue lazily via ctx.get_orchestrator()._svc — the orchestrator is constructed after the dashboard, so lazy lookup is the only option. All admin handlers return 503 when the loop isn't up yet.

Tests

17 tests across 3 classes (tests/test_wiki_routes.py) use make_dashboard_router + find_endpoint to call handlers directly:

  • Read — list, filter by topic, filter by status, path-traversal rejection, 404 on unknown id, 400 on non-numeric id, log filter by issue.
  • Maintenance status — reports queue depth + open PR URL/branch.
  • Admin — force-compile / mark-stale / rebuild-index enqueue correct kinds + params; 503 when orchestrator is None; run-now calls trigger_now when available and falls back to acknowledged otherwise.

Test plan

  • uv run pytest tests/test_wiki_routes.py — 17 passed.
  • make lint-check clean.
  • make quality-lite clean.
  • CI make quality.
  • Phase 6 — the UI console that consumes these endpoints.

🤖 Generated with Claude Code

HydraOps-T-rav pushed a commit that referenced this pull request Apr 20, 2026
Phase 4 (RepoWikiLoop maintenance PR) added ``queue_drained`` to the
zero-repos early-return so admin tasks targeting freshly-migrated
repos don't pile up in the queue.  This scenario test still asserted
the pre-Phase-4 shape and broke CI on #8362 even though its source
change was from PR #8359 that already merged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
HydraOps-T-rav pushed a commit that referenced this pull request Apr 20, 2026
Phase 4 (RepoWikiLoop maintenance PR) added ``queue_drained`` to the
zero-repos early-return so admin tasks targeting freshly-migrated
repos don't pile up in the queue.  This scenario test still asserted
the pre-Phase-4 shape and broke CI on #8362 even though its source
change was from PR #8359 that already merged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds the dashboard API surface for the git-backed repo wiki.  Read
endpoints traverse the tracked ``repo_wiki/`` directory under
``config.repo_root / config.repo_wiki_path`` (Phase 2 layout); admin
endpoints enqueue MaintenanceTask entries into RepoWikiLoop's queue so
all edits go through the single-track commit path that Phase 4 ships
via ``chore(wiki): maintenance`` PRs.  Nothing here mutates the wiki
directly.

Routes (src/dashboard_routes/_wiki_routes.py)

- GET  /api/wiki/repos                                    — list repos with a wiki
- GET  /api/wiki/repos/{owner}/{repo}/entries             — filter by topic/status/q, paginated
- GET  /api/wiki/repos/{owner}/{repo}/entries/{entry_id}  — full entry + frontmatter
- GET  /api/wiki/repos/{owner}/{repo}/log                 — merged per-issue audit log
- GET  /api/wiki/maintenance/status                       — queue depth + open PR
- POST /api/wiki/admin/force-compile                      — enqueue synthesis task
- POST /api/wiki/admin/mark-stale                         — enqueue stale flag write
- POST /api/wiki/admin/rebuild-index                      — enqueue index rebuild
- POST /api/wiki/admin/run-now                            — trigger loop immediately
                                                           (soft-fallback when loop
                                                            has no trigger hook)

Path-traversal guards reject owner/repo values containing ``..`` or
``/``; entry_id is validated as 1–6 digits before any filesystem lookup.

Wiring

Registered in ``src/dashboard_routes/_routes.py`` alongside the other
sub-routers.  Admin/status endpoints look up ``RepoWikiLoop`` and its
``MaintenanceQueue`` lazily via ``ctx.get_orchestrator()._svc`` — the
orchestrator is constructed after the dashboard, so lazy lookup is the
only option; all handlers return 503 when the loop isn't up yet.

Tests (tests/test_wiki_routes.py)

17 tests across 3 classes use ``make_dashboard_router`` + ``find_endpoint``
to call handlers directly:

- Read — list/filter by topic, filter by status, path-traversal rejection,
  404 on unknown id, 400 on non-numeric id, log filter by issue.
- Maintenance status — reports queue depth + open PR URL/branch.
- Admin — force-compile/mark-stale/rebuild-index enqueue correct kinds
  and params; 503 when orchestrator is None; run-now calls trigger_now
  when available and falls back to acknowledged otherwise.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@HydraOps-T-rav HydraOps-T-rav merged commit 690b0dd into main Apr 20, 2026
20 checks passed
@HydraOps-T-rav HydraOps-T-rav deleted the hydraflow/wiki-api branch April 20, 2026 09: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