Skip to content

perf(cli): make GitHub-backed commands fast - #91

Open
FreshlyBrewedCode wants to merge 1 commit into
fix/80-github-backend-resiliencefrom
feat/83-github-commands-fast
Open

FreshlyBrewedCode wants to merge 1 commit into
fix/80-github-backend-resiliencefrom
feat/83-github-commands-fast

Conversation

@FreshlyBrewedCode

Copy link
Copy Markdown
Owner

Closes #83.

Stacked on #87 (the #80 dependency); retargets to main once #80 lands.

Wayful's GitHub-backed commands stop re-fetching what they already have, cache reused reads across processes, back off instead of tripping GitHub's burst limit, and surface the map's sub-issue budget.

What changed

  • One snapshot per map. listSteps/listGoals and saveStep/saveGoal now answer from the same memoized GraphQL snapshot instead of re-reading sub-issues and walking every step's blocked_by edges. step complete and map show no longer grow with the number of steps.
  • A cache that outlives the process. Conditional GETs are ETag-revalidated and persisted under the user cache directory, so a fresh CLI invocation reuses an unchanged body — and can never serve stale data, because every hit revalidates.
  • Backoff on bursts. A secondary (burst) limit now retries with exponential backoff honoring retry-after, rather than failing the command.
  • Visible budget. map status reports used/cap sub-issues and warns as it approaches the cap; creating past the cap still fails with the existing named error.
  • The filesystem backend is unchanged and reports no capacity.

User-facing change

Command Before After
step complete on an N-step map ~N+6 requests one snapshot plus constant writes
map show sub-issues listed twice, one dependency read per step one snapshot
a repeated read in a fresh process full body every time 304, cached body reused
a step create burst hitting the secondary limit fails hard backs off and completes
map status near the cap budget invisible Sub-issues: 95/100 (approaching the 100 sub-issue cap)
Before / after examples

map status on a GitHub-backed map near its cap:

Before:

$ wayful map status --map redesign
Map redesign
Goals: 0/1 satisfied
Steps: 12 pending, 0 blocked, 0 complete, 0 cancelled
Blockers:
- none
Actionable steps:
- 1 chart-the-work: ...

After:

$ wayful map status --map redesign
Map redesign
Goals: 0/1 satisfied
Steps: 12 pending, 0 blocked, 0 complete, 0 cancelled
Sub-issues: 95/100 (approaching the 100 sub-issue cap)
Blockers:
- none
Actionable steps:
- 1 chart-the-work: ...

A burst of step create calls that trips GitHub's secondary limit:

Before:

$ wayful step create third --map redesign --type task --description "..."
wayful: github secondary rate limit exceeded on rapid requests; retry after 60 seconds. Wayful avoids rapid bursts of writes.

After: the command waits out retry-after (with exponential backoff) and succeeds.

Validation

  • bun check (lint + typecheck + test): CLI 335 pass / 1 skip / 0 fail, UI 49 pass / 0 fail.
  • New stubbed-HTTPS tests cover: one query for a 30-step map's listSteps+listGoals, the snapshot-backed save paths, a disk cache revalidated across two layer constructions (and never stale), secondary-limit retry/backoff, and sub-issue usage/cap reporting.

Reads and writes now share one GraphQL map snapshot instead of
re-fetching sub-issues and walking every step's dependencies one
request at a time; conditional GETs are cached across processes with
ETag revalidation; burst-limited writes back off; and `map status`
reports the shared sub-issue budget.

- github `listSteps`/`listGoals` derive from the memoized snapshot, so
  `map show`/`map next`/`step` commands stop paying a read per step.
- `saveStep`/`saveGoal` answer from the same snapshot instead of
  re-reading the issue and its `blocked_by` edges.
- A filesystem-backed, ETag-revalidated response cache lets a fresh CLI
  process reuse an unchanged body and never serves stale data.
- Secondary rate limits retry with exponential backoff honoring
  `retry-after` rather than failing hard.
- `map status` reports `used/cap` sub-issues and warns near the cap,
  while creating past the cap still fails with the named error.
- The filesystem backend is unchanged and reports no capacity.

closes #83
@FreshlyBrewedCode FreshlyBrewedCode linked an issue Sep 13, 2026 that may be closed by this pull request
8 tasks
(error) =>
attemptNumber + 1 >= SECONDARY_RATE_LIMIT_ATTEMPTS
? Effect.fail(secondaryRateLimitError(error.retryAfterSeconds?.toString()))
: Effect.sleep(secondaryRetryDelay(attemptNumber, error.retryAfterSeconds)).pipe(

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

effect has first class support for retry, backoff, etc. See https://effect.website/docs/v4/error-management/retrying. We should not use our own implementation here

This branch has not been deployed

No deployments
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.

perf(cli): make GitHub-backed commands fast

1 participant