fix(agent): the raw-fetch GitHub writers respect the global pause / freeze - #1263
Merged
Conversation
…reeze The dry-run client chokepoint (#1258) suppresses installation-Octokit writes under a non-live mode, but two agent-initiated writers use a raw PAT outside it and ignored the operator brake: - fileUpstreamDriftIssues (upstream/ruleset.ts) POSTed/PATCHed GitHub issues every cron tick, gated only by GITTENSORY_AUTO_FILE_DRIFT_ISSUES — neither the env brake nor the DB freeze stopped it. - generateContributorIssueDrafts (services/contributor-issue-draft.ts) filed issues whenever a caller passed {dryRun:false}, with no relation to the agent action mode. Both now consult the global agent state: fileUpstreamDriftIssues returns early with status "paused", and the contributor-draft dryRun flag is OR-ed with the env brake / DB freeze so a paused/frozen agent never writes. The end-user fork drafting (services/draft.ts) is intentionally left alone — it acts under the user's own OAuth token, a different actor class than the autonomous agent. Regression tests cover both the env-brake and DB-freeze arms for each writer, asserting no POST/PATCH reaches the network.
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1263 +/- ##
=======================================
Coverage 95.03% 95.03%
=======================================
Files 177 177
Lines 19884 19886 +2
Branches 7164 7166 +2
=======================================
+ Hits 18896 18898 +2
Misses 395 395
Partials 593 593
🚀 New features to boost your workflow:
|
26 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The dry-run client chokepoint (#1258) suppresses installation-Octokit writes under a non-live mode, but two agent-initiated writers use a raw PAT outside it and ignored the operator brake — the documented boundary from that PR:
fileUpstreamDriftIssues(upstream/ruleset.ts) POSTed/PATCHed GitHub issues every cron tick, gated only byGITTENSORY_AUTO_FILE_DRIFT_ISSUES— neither the env brake nor the DB freeze stopped it (a globally-paused/frozen agent still filed issues).generateContributorIssueDrafts(services/contributor-issue-draft.ts) filed issues whenever a caller passed{dryRun:false}, with no relation to the agent action mode.Fix
Both now consult the global agent state:
fileUpstreamDriftIssuesreturns early withstatus: "paused"under the env brake or DB freeze.dryRunflag is OR-ed withisGlobalAgentPause(env) || isGlobalAgentFrozen(env), so a paused/frozen agent never writes even when a caller asks to create.The end-user fork drafting (
services/draft.ts) is intentionally left alone — it acts under the user's own OAuth token, a different actor class than the autonomous agent, so the agent's operator brake should not silence it.This closes the raw-fetch boundary so the "no autonomous GitHub write under pause/freeze" invariant now holds for all agent-initiated writers, not just the installation-Octokit ones.
Scope
upstream/ruleset.ts,services/contributor-issue-draft.ts); no schema / migration / binding changeValidation
npm run test:ci— full gate greennpm audit --audit-level=moderate— 0 vulnerabilitiesPOST/PATCHreaches the networkmainimmediately before openingSafety
site//CNAME/lovable