ADE CLI / PR workflow fixes and integration lane ownership#185
Merged
Conversation
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.
ADE CLI RPC/bootstrap improvements, shared adeCliGuidance for agents, orchestrator/chat/CTO wiring, and safer integration lane ownership for cleanup (scratch lanes vs merge-into adoption).
Made with Cursor
Summary by CodeRabbit
Release Notes
New Features
Improvements
Greptile Summary
This PR consolidates ADE CLI guidance into a single shared constant (
ADE_CLI_AGENT_GUIDANCE), fixes several PR duplicate-recovery bugs (cascade-delete scoping,findExistingPrForBranch,#123locator parsing), expands the action allowlist with ~15 new domains and role-based access enforcement, and improves worktree-aware project root discovery in the CLI.All previously flagged issues appear resolved:
startupCommandPreviewnow logs the augmented prompt, duplicate guidance inpromptInspector.tsis removed, the|| Boolean(candidate?.draft)closed-draft matching is gone,--textis absent fromVALUE_CARRIER_FLAGS, andgraph_stateis correctly scoped toruntime.projectId.Confidence Score: 5/5
Safe to merge; all P0/P1 concerns from prior reviews are addressed and the two new findings are minor style inconsistencies.
Every previously flagged P0/P1 issue has a clear fix in this diff. The two new findings are P2: a null-vs-empty-object inconsistency in
layout.setand a hardcoded provider string gate. Neither causes data loss or incorrect behavior in the current provider set.apps/desktop/src/main/services/adeActions/registry.ts —
layout.set(null)inconsistency; apps/desktop/src/main/services/chat/agentChatService.ts — hardcoded"claude"provider check.Important Files Changed
hasHelpFlag/VALUE_CARRIER_FLAGSrouting, worktree-aware root discovery, and command aliases.--textno longer inVALUE_CARRIER_FLAGS, fixing the prior help-swallowing bug.graph_state,layout,tiling_tree,keybindings,github,budget, etc.), role-based access control helpers (isCtoOnlyAdeAction/callerHasRoleAtLeast), and inline domain-service builders.layout.set(null)stores{}instead of clearing, inconsistent withtiling_tree.setandgraph_state.set.getRowByLocator,repoPrKey,findExistingPrForBranchfor safer duplicate-PR recovery;upsertRowreturns the upserted ID; cascade deletes gated behindallowRepoPrAdoption;#123PR locator parsing;getIntegrationLaneOriginnull-safe guard;listAllnow accepts laneId filter.ADE_CLI_AGENT_GUIDANCEconstant; removes the duplicate "ADE TOOLING" push that previously resulted in two copies of the guidance in every worker prompt.ADE_CLI_AGENT_GUIDANCEinto startup-command override prompt;startupCommandPreviewnow logs the augmented prompt (not the bare override), fixing prior debug-visibility bug.ADE_CLI_AGENT_GUIDANCEmust NOT be prepended to the worker prompt file becausebuildFullPromptalready injects it via the system prompt for Claude workers.ADE_CLI_AGENT_GUIDANCE(multi-line) andADE_CLI_INLINE_GUIDANCE(single-line) to consolidate ADE CLI guidance strings across agents, inspector, and chat service.providerHasPersistentGuidance) using a hardcoded"claude"provider name comparison that may miss future providers.autoUpdateServicecreation to beforeinitContextForProjectRootso all RPC runtimes capture a live reference; exposes many additional services onrpcRuntimeto match the expandedADE_ACTION_ALLOWLIST.ADE_ACTION_DOMAIN_NAMESconst instead of hardcoded enum arrays; wiresisCtoOnlyAdeActioninto bothlist_ade_actions(filter) andrun_ade_action(enforcement) handlers;create_pr_from_lanetitleno longer required.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[ade CLI invocation] --> B{hasHelpFlag?} B -- yes --> C[Return HELP_BY_COMMAND text] B -- no --> D{Primary command} D --> E[prs create / link] D --> F[actions run] D --> G[git / lanes / files / ...] E --> H[prService.createFromLane] H --> I{GitHub API create PR} I -- success --> J[upsertRow - returns prId] I -- duplicate error --> K[findExistingPrForBranch] K --> L[Adopt existing PR row allowRepoPrAdoption:true] L --> J J --> M[markHotRefresh + refreshOne] F --> N{isCtoOnlyAdeAction?} N -- yes, caller not CTO --> O[Throw permission error] N -- no / caller is CTO --> P[Invoke domain service method] subgraph ADE_CLI_GUIDANCE [Shared guidance injection] Q[ADE_CLI_AGENT_GUIDANCE constant] Q --> R[baseOrchestratorAdapter - startup override prompt] Q --> S[promptInspector - worker base guidance] Q --> T[agentChatService - non-Claude providers only] Q --> U[ctoStateService - CTO doctrine] endComments Outside Diff (5)
apps/desktop/src/main/services/orchestrator/promptInspector.ts, line 178-225 (link)ADE_CLI_AGENT_GUIDANCEblock in every worker promptbuildWorkerBaseGuidanceunconditionally callssections.push(...)withADE_CLI_AGENT_GUIDANCEat two separate points (lines 178 and 213). Both execute for every worker, so the resulting prompt contains the## ADE CLIheading and its two-line body verbatim twice.Before this PR the two slots held distinct strings:
"ADE CLI: In terminal-capable sessions, use the bundled \ade` command…"`"ADE TOOLING: Use ADE's action surface or the \ade` CLI for team collaboration commands when available."`After the consolidation both slots emit the same constant. The worker identity / key-actions block in the second
sections.pushis still unique and correct, but it is now prefixed with a redundant## ADE CLIsection that will appear a second time in the prompt.Prompt To Fix With AI
apps/desktop/src/main/services/prs/prService.ts, line 2541-2559 (link)The condition used to trigger
findExistingPrForBranchis:"validation failed"is a broad phrase that GitHub also returns for unrelated schema violations (e.g. invalid base branch, missing required field). If such an error is misidentified as a duplicate-PR error, the code will silently look up and adopt an existing PR for the branch — potentially mapping the wrong PR to the lane. A narrower pattern such as/pull request already exists/i(or checking the GitHub422status code) would reduce the false-positive surface.Prompt To Fix With AI
apps/desktop/src/main/services/prs/prService.ts, line 1308-1330 (link)findExistingPrForBranchtyped asPromise<any | null>The function and its
fetchAllPages<any>call useany, which drops type safety on the returned GitHub PR object. The rest ofprService.tsaccesses.state,.draft,.number, etc. from the result with runtimeasString/Numberguards — that pattern works — but the signature makes it impossible for callers to know what shape they're consuming without reading the implementation.Prompt To Fix With AI
apps/desktop/src/main/services/orchestrator/promptInspector.ts, line 178-225 (link)ADE_CLI_AGENT_GUIDANCEinbuildWorkerBaseGuidanceADE_CLI_AGENT_GUIDANCEis pushed intosectionsat two separate points in this function (lines 178 and 213). Both calls execute unconditionally for every worker, so the inspector output contains the## ADE CLIheading and body verbatim twice. The inspector therefore shows a longer prompt than whatbuildFullPromptinbaseOrchestratorAdapter.tsactually sends to workers (where the guidance only appears once), making the inspector inaccurate for debugging.The second push (lines 213–225) is what contains the unique "worker identity" / key-actions text;
ADE_CLI_AGENT_GUIDANCEshould not prefix that block as well.Prompt To Fix With AI
apps/desktop/src/main/services/prs/prService.ts, line 1154-1215 (link)upsertRownow falls back togetRowForRepoPrwhengetRowForLanefinds nothing, and when it does match a PR that belongs to a different lane it immediately deletes that PR'spr_group_membersrows and nullifiesintegration_proposalsreferences. This path fires from bothcreateFromLane(duplicate-recovery) andlinkToLane.The
linkToLanecase is the risky one: if PR #X was already in a merge queue under lane A and a caller links it to lane B, the queue membership is silently destroyed with no notification or rollback. The caller has no signal that anything was cleared.Consider guarding the cascade deletes with a check that verifies neither
pr_group_membersnor activeintegration_proposalsexist before proceeding, or at minimum logging a warning when rows are removed.Prompt To Fix With AI
Prompt To Fix All With AI
Reviews (9): Last reviewed commit: "ship: iteration 4 (post-rebate) — post-m..." | Re-trigger Greptile