feat(ghcache): ship a default gh-api read-cache classifier (from coily gh_readcache) #90

Closed
opened 2026-06-07 04:07:37 +00:00 by coilysiren · 1 comment
Owner

Extraction candidate from the coily cmd/coily/ generic-code audit (2026-06-06). Source pinned at coily commit c7c17cb (canonical: forgejo.coilysiren.me/coilyco-bridge/coily). cli-guard is mid-refactor, so the "suggested home" below is the pre-refactor package layout - land this in whatever the post-refactor equivalent is, not necessarily the named package. The durable principle: the classifiers / argv-transforms are generic and move; the policy decisions and message copy stay in coily.

Source: cmd/coily/gh_readcache.go - ghReadCacheClassifier, helpers isBodyFlag, readMethodFlag. Comment in-file cites cli-guard#76.

What it does: recognizes a cacheable gh api <path> GET (declines on body flags or non-GET method) and returns the path + maxAge, in the exact shape cli-guard's passthrough.ReadCacheClassifier expects. It is already written to a cli-guard interface - this is shipping the canonical default implementation upstream.

Generic core (lift this): the whole classifier. No coily/Kai/Forgejo identifiers.

Consumer seam to parameterize: the only coupling is loadGHMaxAge() (coily's COILY_GH_MAX_AGE/--max-age resolver). Inject maxAge as a func() time.Duration instead of a package global.

Bundle (de-dup): the gh api argv grammar (isBodyFlag/readMethodFlag) is triplicated across coily - also in gh_actions_gate.go (isActionsAPIPath) and gh_issue_create_gate.go (parseGHAPIArgs/ghAPIMethodFlag/ghAPIFieldFlag/isIssuesCollectionPath). Land one canonical gh-argv parser (candidate ghargv) that this classifier and both gates consume. Note: those two gates themselves stay in coily (their block messages encode Kai's Forgejo-over-GitHub + Playwright-only-CI policy) - only the parser moves.

Suggested home (pre-refactor): ghcache (or a new ghargv).

Done when:

  • generic logic lives in cli-guard with zero coily/Kai/Forgejo identifiers or defaults
  • behavior-covered tests (table tests where the source has them)
  • godoc-current.txt regenerated (scripts/check-godoc-current.sh --update)
  • coily migrated onto the extracted API, its local copy deleted, make test green both sides
  • closes this issue

Related: the gate policy bodies stay in coily; see also cli-guard#76 (scrub coily* references).

> Extraction candidate from the coily `cmd/coily/` generic-code audit (2026-06-06). Source pinned at coily commit `c7c17cb` (canonical: `forgejo.coilysiren.me/coilyco-bridge/coily`). **cli-guard is mid-refactor**, so the "suggested home" below is the pre-refactor package layout - land this in whatever the post-refactor equivalent is, not necessarily the named package. The durable principle: **the classifiers / argv-transforms are generic and move; the policy decisions and message copy stay in coily.** **Source:** `cmd/coily/gh_readcache.go` - `ghReadCacheClassifier`, helpers `isBodyFlag`, `readMethodFlag`. Comment in-file cites cli-guard#76. **What it does:** recognizes a cacheable `gh api <path>` GET (declines on body flags or non-GET method) and returns the path + maxAge, in the exact shape cli-guard's `passthrough.ReadCacheClassifier` expects. It is already written *to* a cli-guard interface - this is shipping the canonical default implementation upstream. **Generic core (lift this):** the whole classifier. No coily/Kai/Forgejo identifiers. **Consumer seam to parameterize:** the only coupling is `loadGHMaxAge()` (coily's `COILY_GH_MAX_AGE`/`--max-age` resolver). Inject maxAge as a `func() time.Duration` instead of a package global. **Bundle (de-dup):** the `gh api` argv grammar (`isBodyFlag`/`readMethodFlag`) is **triplicated** across coily - also in `gh_actions_gate.go` (`isActionsAPIPath`) and `gh_issue_create_gate.go` (`parseGHAPIArgs`/`ghAPIMethodFlag`/`ghAPIFieldFlag`/`isIssuesCollectionPath`). Land one canonical gh-argv parser (candidate `ghargv`) that this classifier and both gates consume. Note: those two *gates* themselves stay in coily (their block messages encode Kai's Forgejo-over-GitHub + Playwright-only-CI policy) - only the parser moves. **Suggested home (pre-refactor):** `ghcache` (or a new `ghargv`). **Done when:** - [ ] generic logic lives in cli-guard with zero coily/Kai/Forgejo identifiers or defaults - [ ] behavior-covered tests (table tests where the source has them) - [ ] `godoc-current.txt` regenerated (`scripts/check-godoc-current.sh --update`) - [ ] coily migrated onto the extracted API, its local copy deleted, `make test` green both sides - [ ] `closes` this issue **Related:** the gate policy bodies stay in coily; see also cli-guard#76 (scrub coily* references).
Author
Owner

Backlog burndown 2026-06-17: closing low-priority (P3/P4) to bring the open count to a manageable level. Nothing lost — reopen if this resurfaces. Batch tag: burndown-2026-06.

Backlog burndown 2026-06-17: closing low-priority (P3/P4) to bring the open count to a manageable level. Nothing lost — reopen if this resurfaces. Batch tag: `burndown-2026-06`.
coilysiren 2026-06-17 08:23:24 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
coilyco-flight-deck/cli-guard#90
No description provided.