You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Stacked on #238. Migrates the GitHub and Linear gatekeepers to applyActionsThrough, using the shared @gadgets/backend-utils/gatekeeper-action helpers (validateApplyThroughArgs, displayReason, SerialTaskQueue, and for Linear InvalidationLog). Both keep their existing disposal idioms and legacy per-action semantics (throw on unknown/settled — no silent no-ops).
GitHub
resolveActionVetoes applies direct vetoes plus GitHub's known dependency cascades (resource dependents of a vetoed creation; transitive reply chains, with direct-veto attribution precedence) to the stored records; the batch method retires the changed records and then applies pending actions ascending, stopping at the first failure with the specific apply error as stopped.reason. Attribution persists on retired records (GitHub's existing retire idiom), so repeated requests re-report invalidatedByVeto.
Fixes over the straightforward port:
The batch sweep applies only "pending" records — never "staged" ones whose submitAction() hasn't completed (the contract forbids it; the old sweep would have applied them).
Record mutation now invalidates the in-memory pending-overlay cache structurally: #putActionRecord/#retireActionRecord are the two storage chokepoints and clear #pendingActionsCache themselves, so no veto path can leave stale simulation overlays (previously each call site had to remember; the batch veto path didn't).
Tests move to @cloudflare/vitest-pool-workers so they run inside workerd: unit coverage of the cascade resolution plus DO-level batch tests against a real GitHubGatekeeperImpl facet (real staging flow and facet storage) covering cascade + re-report on retry, the legacy path refusing a cascade-invalidated action, unknown-veto tolerance, RPC-boundary validation, and legacy-reject attribution durability.
Linear
applyActionsThrough per the contract: vetoes first (recursive provisional-issue cascade and label cascade keep deleting, now recording attribution in an invalidation: keyspace via InvalidationLog), then pending actions ascending with a status guard (the legacy applyAction had none and would re-apply settled records if asked).
enqueue now writes records as "staged" and flips to "pending" only after submitAction() resolves (read overlays include both), and rolls the record back if submit fails — previously a failed submit left an orphaned pending record.
All resolution methods serialize through one SerialTaskQueue.
Tested with pnpm build, pnpm lint:check, and the gatekeeper-github suite (17 tests, including the new DO-level batch tests).
Review of #241 turned up a correctness bug in the foundation branch that this PR copies: applyStoredActionsThrough silently skipping an in-range record whose submitAction() has not completed yet (record.state !== "pending" → continue / filter). The driver infers appliedThrough = stopped ? at-1 : actionId, so a silent skip lets it mark the staged action approved without it ever being applied — reachable whenever the batch RPC beats the submitAction() response (the hot path for auto-approved actions).
The foundation branch (#238) has been amended: a "staged" in-range record now returns {...invalidations, stopped: {at: record.id, reason: new Error("This action is still being submitted for approval. Retry in a moment.")}} instead of skipping, with tests pinning it in both gatekeepers.
When rebasing this PR onto the amended foundation, apply the same staged→stopped fix (and matching tests) to the gatekeepers here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #238. Migrates the GitHub and Linear gatekeepers to
applyActionsThrough, using the shared@gadgets/backend-utils/gatekeeper-actionhelpers (validateApplyThroughArgs,displayReason,SerialTaskQueue, and for LinearInvalidationLog). Both keep their existing disposal idioms and legacy per-action semantics (throw on unknown/settled — no silent no-ops).GitHub
resolveActionVetoesapplies direct vetoes plus GitHub's known dependency cascades (resource dependents of a vetoed creation; transitive reply chains, with direct-veto attribution precedence) to the stored records; the batch method retires the changed records and then applies pending actions ascending, stopping at the first failure with the specific apply error asstopped.reason. Attribution persists on retired records (GitHub's existing retire idiom), so repeated requests re-reportinvalidatedByVeto.Fixes over the straightforward port:
"pending"records — never"staged"ones whosesubmitAction()hasn't completed (the contract forbids it; the old sweep would have applied them).#putActionRecord/#retireActionRecordare the two storage chokepoints and clear#pendingActionsCachethemselves, so no veto path can leave stale simulation overlays (previously each call site had to remember; the batch veto path didn't).Tests move to
@cloudflare/vitest-pool-workersso they run inside workerd: unit coverage of the cascade resolution plus DO-level batch tests against a realGitHubGatekeeperImplfacet (real staging flow and facet storage) covering cascade + re-report on retry, the legacy path refusing a cascade-invalidated action, unknown-veto tolerance, RPC-boundary validation, and legacy-reject attribution durability.Linear
applyActionsThroughper the contract: vetoes first (recursive provisional-issue cascade and label cascade keep deleting, now recording attribution in aninvalidation:keyspace viaInvalidationLog), then pending actions ascending with a status guard (the legacyapplyActionhad none and would re-apply settled records if asked).enqueuenow writes records as"staged"and flips to"pending"only aftersubmitAction()resolves (read overlays include both), and rolls the record back if submit fails — previously a failed submit left an orphaned pending record.SerialTaskQueue.Tested with
pnpm build,pnpm lint:check, and the gatekeeper-github suite (17 tests, including the new DO-level batch tests).