Commit graph

10 commits

Author SHA1 Message Date
Snider
3ba8fbb8fb fix: Phase 2 — error wrapping, context audit, rate limiting review
- Standardise all fmt.Errorf calls to "package.Func: context" pattern
  across jobrunner/journal.go, agentci/config.go, agentci/security.go,
  handlers/dispatch.go, and forge/labels.go (15 bare errors fixed)
- Add SecureSSHCommandContext with context propagation for cancellable
  SSH operations; update dispatch handler to use it
- Add CheckGitHubRateLimitCtx for context-aware rate limit checking
- Document Forgejo/Gitea SDK v2 context limitation in FINDINGS.md
  (SDKs do not accept context.Context — adding ctx to 66 wrappers
  would be ceremony without real propagation)
- Review and document rate limiter: handles all edge cases, adaptive
  throttling at 75% GitHub usage, SDK header parsing not feasible

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 05:42:02 +00:00
Claude
8d1d7fce01
test: push coverage across collect/jobrunner/gitea
collect: 83.0% -> 90.0% via error medium injection (write/list/read/ensureDir
failures), rate limiter blocking tests, HTTP mock servers for papers/market/
bitcointalk write errors, processor context cancellation, state round-trip,
and GitHub collector gh-auth-failure paths.

gitea: 89.2% -> 94.0% via paginated org/user repo servers, PR meta with
comment counting and nil dates, GetCommentBodies with nil poster, ListPullRequests
state mapping, and NewFromConfig flag override tests.

jobrunner: 86.4% -> 94.4% via journal error paths (empty baseDir, readonly dir,
path sanitisation), poller with error-returning source/handler/report, journal
integration (JSONL file verification), multiple sources, immediate cancellation,
and cycle counter tests.

handlers: 83.8% -> 89.2% via dispatch mock servers (invalid repo, EnsureLabel
failure, GetIssue not found, AssignIssue failure, AddIssueLabels error, issue
with no special labels), completion label errors, EnableAutoMerge pending checks,
PublishDraft merged state, SendFixCommand merge conflict, DismissReviews stale
review, TickParent checkbox ticking, and dual-run mode. Remaining 10.8% is in
SSH-dependent dispatch code (secureTransfer/runRemote/ticketExists) that cannot
be tested without modifying production code.

Co-Authored-By: Charon <charon@lethean.io>
2026-02-20 03:06:43 +00:00
Claude
b3e3ef2efb
test(git): push coverage from 79.5% to 96.7%
Add tests for Service lifecycle: NewService factory, OnStartup, and all
handleQuery/handleTask paths (QueryStatus, QueryDirtyRepos,
QueryAheadRepos, TaskPush, TaskPull, TaskPushMultiple, unknown types).

Add integration tests for Push with a real bare remote (push succeeds,
ahead count drops to zero), PushMultiple with multiple paths, empty
paths, and ahead/behind with no upstream tracking branch.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 02:01:12 +00:00
Claude
f50fc405f5
test(forgejo): push coverage from 73.3% to 95.0%
Add unit tests for all signal mapping functions (mapPRState, mapMergeable,
mapCombinedStatus with all branches including nil, zero count, error
state). Add tests for parseEpicChildren (all checked, all unchecked,
no checkboxes), findLinkedPR (found, not found, nil), buildSignal
(with and without head SHA), splitRepo table-driven tests.

Add Poll integration tests: multiple repos, NeedsCoding with assignee,
merged PR, no head SHA (PENDING status), API errors (graceful skip),
empty repos list, non-epic issues filtered. Add Report tests: nil
result, failed result with error message.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 01:59:36 +00:00
Claude
2505aff461
test(handlers): push coverage from 61.6% to 83.8%
Add full test suite for CompletionHandler (success, failure, no-message,
ensure-label-fails). Add Name() tests for all six handlers. Add Match
edge cases (closed PR, conflicting, no threads). Add Execute error paths
for PublishDraft (server error), SendFixCommand (code reviews message,
comment fails), TickParent (already ticked, fetch fails, edit fails,
close child fails), DismissReviews (list fails, nothing to dismiss,
dismiss fails). Add Dispatch dedup tests (already in-progress, already
completed, invalid repo owner).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 01:58:07 +00:00
Claude
b4e3d0555a
test(collect): push coverage from 57.3% to 83.0%
Add HTTP mock tests for BitcoinTalk (fetchPage, Collect with server),
papers (IACR HTML parsing, arXiv XML parsing, PaperSourceAll), market
(historical with FromDate, invalid date, server errors), process
(ordered lists, blockquotes, h4-h6, nested objects, cancelled context),
excavate (resume skips completed, progress events), and state (copy
safety, cursor round-trip, null JSON).

Uses httptest.Server with rewriteTransport to intercept external HTTP
calls without touching the production code.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 01:55:18 +00:00
Claude
4de0356880
docs(todo): mark Phase 1 complete with commit hash 9db37c6
Co-Authored-By: Charon <developers@lethean.io>
2026-02-20 01:00:10 +00:00
Claude
9db37c6fb3
test: add comprehensive unit tests for forge/, gitea/, git/, agentci/
Phase 1 test coverage for the three 0% packages plus agentci/ improvement:

- git/ (0% -> 79.5%): RepoStatus methods, status parsing with real temp
  repos, multi-repo parallel status, Push/Pull error paths, ahead/behind
  with bare remote, context cancellation, GitError, IsNonFastForward,
  service DirtyRepos/AheadRepos filtering

- forge/ (0% -> 91.2%): All SDK wrapper functions tested via httptest mock
  server — client creation, repos, issues, PRs, labels, webhooks, orgs,
  meta, config resolution, SetPRDraft raw HTTP endpoint

- gitea/ (0% -> 89.2%): All SDK wrapper functions tested via httptest mock
  server — client creation, repos, issues, PRs, meta, config resolution

- agentci/ (56% -> 94.5%): Clotho DeterminePlan all code paths, security
  helpers (SanitizePath, EscapeShellArg, SecureSSHCommand, MaskToken)

Key findings documented in FINDINGS.md:
- Forgejo SDK validates token via HTTP on NewClient()
- SDK route patterns differ from public API docs (/org/ vs /orgs/)
- Gitea SDK requires auth token for GitHub mirror creation
- Config resolution priority verified: config file < env vars < flags

Co-Authored-By: Charon <developers@lethean.io>
2026-02-20 00:59:46 +00:00
Snider
bedcb4e652 docs: add CLAUDE.md, TODO.md, FINDINGS.md for fleet delegation
Full domain expert session brief with architecture map, 4-phase
TODO covering test coverage (critical), hardening, AgentCI pipeline,
and Forge↔Gitea sync. Initial findings documenting package inventory,
zero-test gaps, and auth resolution.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 00:28:39 +00:00
Claude
3e883f6976
feat: extract SCM/forge integration packages from core/go
Forgejo and Gitea SDK wrappers, multi-repo git utilities, AgentCI
dispatch, distributed job orchestrator, and data collection pipelines.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 15:25:58 +00:00