Skip to content

Plugin System Phase 3: Tracker Slot (#9) - #28

Merged
tu11aa merged 21 commits into
developfrom
feature/tracker-plugin-slot
Apr 21, 2026
Merged

Plugin System Phase 3: Tracker Slot (#9)#28
tu11aa merged 21 commits into
developfrom
feature/tracker-plugin-slot

Conversation

@tu11aa

@tu11aa tu11aa commented Apr 21, 2026

Copy link
Copy Markdown
Owner

Summary

Phase 3 of issue #9 (Plugin/Extension System). Abstracts GitHub issue/PR operations behind a `TrackerDriver` interface mirroring phase 1 runtime (PR #20) and phase 2 workspace (PR #26). GitHub is the sole provider; Linear/Jira/GitLab are explicit follow-ups. Per design, polling stays provider-specific (`poll-github.sh` unchanged); only one-shot ops go through the driver.

Spec: `docs/specs/2026-04-21-plugin-system-tracker-design.md`
Plan: `docs/specs/2026-04-21-plugin-system-tracker-plan.md`

What changed

New:

  • `src/trackers/types.ts` — `TrackerDriver`, `Issue`, `PullRequest`, `CheckRun`, `ReviewDecision`, `TrackerScope`, `TrackerProbeResult`, `IssueFilter`, `TrackerFactory`
  • `src/trackers/github.ts` — `createGitHubDriver(scope)` — 8 methods via gh CLI
  • `src/trackers/registry.ts` — `TrackerRegistry` with `forProject`, `get`, `probeAll`
  • `src/trackers/index.ts` + tests: 15 github, 7 registry, 3 memory-tracker = 25 new tests
  • `src/trackers/tests/helpers/memory-tracker.ts` — in-memory fixture
  • `src/commands/tracker.ts` — `cockpit tracker create-issue|merge-pr|get-checks|get-run-log|list-issues` CLI

Migrated:

  • `scripts/execute-reaction.sh` — `auto-merge` case now calls `cockpit tracker merge-pr`; `auto-fix-ci` uses `cockpit tracker get-checks --json` + `cockpit tracker get-run-log`. Zero `gh` refs remain in the script.
  • `src/commands/doctor.ts` — probes tracker providers via `probeAll()`; adds `Tracker 'github' installed` + `authenticated` checks.

Config (backward compatible):

  • `tracker?: string` at top level and per-project. Absent = `"github"`.

Docs:

  • README — commands table + config JSON + Tracker Abstraction architecture subsection.

Contract highlights

  • Primitive ops only. No N+1 enrichment in the driver (reviewer-validated decision). Callers that need enrichment compose `listPullRequests` + `getPullRequestChecks` themselves.
  • Async throughout. Matches runtime (phase 1) and workspace (phase 2) patterns.
  • Provider-specific polling stays. `poll-github.sh` unchanged — future Linear adds `poll-linear.sh` alongside. Hybrid decision documented in spec.

Intentionally NOT migrated (per spec §Non-Goals)

  • `scripts/poll-github.sh` — canonical GitHub polling
  • `scripts/match-reactions.sh` — provider-agnostic already
  • `src/commands/feedback.ts` — opens a browser URL (no `gh issue create` today). Spec incorrectly listed it; plan corrected.
  • GitHub Project-board GraphQL — already a TODO; stays for now.
  • Cross-tracker vocabulary normalization in `reactions.json` — follow-up #27.

Test plan

  • `npm run test -- --run`: 107 pass, 2 pre-existing `config.test.ts` failures (emoji-prefix baseline, predates this PR)
  • `npm run lint` exits 0
  • `npm run build` exits 0
  • `grep -cE "gh (pr|run|api|issue)" scripts/execute-reaction.sh` = 0
  • `cockpit doctor` shows new `Tracker 'github'` lines
  • `cockpit tracker --help` shows 5 subcommands
  • Manual smoke: reactor auto-merge on a test PR (tested by reviewer)
  • Manual smoke: reactor auto-fix-ci dispatch

Pre-PR code review

Internal review (superpowers:code-reviewer) approved with 2 Important items, both addressed in commit `7f3c069`:

  • merge-pr `--method` validation — was silently normalizing invalid values to squash; now errors with `Invalid merge method 'foo'. Allowed: merge, squash, rebase`.
  • Missing-repo error message — opaque `scope.owner required` replaced with actionable `No tracker repo configured for project 'X' (set reactions.json github.repos.X.owner/repo)`.

Other findings (shell-injection surface on `escape()`, runId regex fragility, probeAll bogus scope) tracked for phase-4+ polish; noted in PR comments.

Follow-ups already filed

  • #27 — Normalize cross-tracker vocabulary in `reactions.json` once a 2nd tracker ships

tu11aa added 21 commits April 21, 2026 19:47
Abstract GitHub gh-CLI behind a TrackerDriver interface mirroring
runtime (phase 1) and workspace (phase 2). Thin primitive ops only
(no cross-provider enrichment). Hybrid CLI: one-shot actions go
through cockpit tracker; poll-github.sh stays raw as the canonical
GitHub polling script.

Normalized cross-tracker vocabulary in reactions.json deferred —
tracked as #27 until a 2nd tracker provider ships.
11-task plan for plugin system phase 3 — tracker abstraction. TDD flow
for GitHubDriver + TrackerRegistry + in-memory test driver. Migrates
execute-reaction.sh (auto-merge + auto-fix-ci paths) to cockpit tracker.
poll-github.sh stays raw per spec §Non-Goals.

Plan corrects design-spec error: feedback.ts does NOT use gh issue
create (it opens a browser URL); stays untouched in phase 3.
- CLI merge-pr --method now errors on invalid value (was silently
  normalizing to 'squash'). Matches ReactionRule.merge_method typing.
- Registry.forProject throws actionable error pointing to reactions.json
  when owner/repo missing, instead of opaque 'scope.owner required'
  from GitHubDriver constructor.
- Added test for the new missing-repo error path.

Reviewer-flagged Important items #1 and #3.
@tu11aa
tu11aa merged commit 7f8215f into develop Apr 21, 2026
@tu11aa
tu11aa deleted the feature/tracker-plugin-slot branch April 21, 2026 14:17
@tu11aa tu11aa mentioned this pull request May 5, 2026
2 tasks
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