Skip to content

fix(land): check write access only in auto E and F - #696

Closed
kjgbot wants to merge 2 commits into
mainfrom
fix/land-staged-write-preflight
Closed

kjgbot wants to merge 2 commits into
mainfrom
fix/land-staged-write-preflight

Conversation

@kjgbot

@kjgbot kjgbot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Cloud#5944 limits auto repository write grants to E/F. The land example currently requires a push-capable credential at every stage, causing read-only A-adversarial to refuse before review.

Run the gh authentication and push-capability preflight only at E/F. Read-only A/B/C fix/D stages can proceed, while a denied E/F write grant still refuses before the GitHub gate or final push. This builds on merged flows#694's mode agreement guard. No runtime packages, model pins, or gates change; no npm release is needed.

Validation (Node v22.22.2):

PATH=/Users/khaliqgant/.nvm/versions/node/v22.22.2/bin:$PATH npm --prefix examples/land run typecheck
PATH=/Users/khaliqgant/.nvm/versions/node/v22.22.2/bin:$PATH npm --prefix examples/land test

Both exit 0, 91 passed, 0 failed. The new test drives A/B/C/D with denied push capability then refuses at E. Reverting only the E/F condition fails the same test at A; restoring the source byte-for-byte passes all 91. Literal commands/output and restored SHA: examples/land/evidence/staged-write-preflight/verification.md and sibling transcripts.

Hosted grant behavior remains unverified. Human merge and the land operator's source redeployment are required; this PR does not deploy.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.


Agent Relay sessions

  • codex session 01a19dbc · opened via gh pr create · last active 2026-11-03

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f1673ba0-adeb-4810-954c-e7f4b5d9a33f
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@kjgbot

kjgbot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Codex independent read-only review: no findings at exact head 20ae8125e2366f7b51fdf01374748c0f48d681c8.

Reviewed the source change and captured regression/typecheck/91-test evidence. E/F retain the write preflight; early review, fix and rebase stages use read-only grants without attempting a push probe. The source SHA matches the report; the final commit only adds the literal hash command and captured output. The reviewer did not independently rerun tests or hosted execution.

@kjgbot
kjgbot marked this pull request as ready for review November 3, 2026 06:54
@greptile-apps

greptile-apps Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Limits the gh authentication and push-capability checks to auto stages E/F.

  • Auto runs check write access at E/F, after the read-only stages.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["A/B: review and local CI"] --> C["C: local fixes, when needed"]
  C --> A
  A --> D["D: check base and rebase"]
  D --> ECheck["Auto E: check authentication and push access"]
  ECheck --> E["E: GitHub gate"]
  E --> FCheck["Auto F: check authentication and push access"]
  FCheck --> F["F: squash and push"]
Loading

Reviews (1) · Last reviewed commit: "docs(land): capture restored source hash..." · Reviewed by Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2 issues found across 7 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="examples/land/tests/flow.test.ts">

<violation number="1" location="examples/land/tests/flow.test.ts:762">
P2: This test does not verify the F preflight despite claiming coverage for E/F. Add a stage-specific mock that lets E complete but rejects the dry-run at F, then assert that F stops before the squash push.</violation>
</file>

<file name="examples/land/land.flow.ts">

<violation number="1" location="examples/land/land.flow.ts:924">
P2: The E/F preflight runs before `owned = state`, so a denied write grant returns a refused completion without persisting the existing run's `needs_human` terminal state. Assign the existing state to `owned` before this preflight, or otherwise save the terminal refusal, so the denial is recorded consistently.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic



test('hosted auto allows read-only A-D and proves write access only at E/F', async () => {
const w = world({ config: autoConfig, pushDryRunFails: true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: This test does not verify the F preflight despite claiming coverage for E/F. Add a stage-specific mock that lets E complete but rejects the dry-run at F, then assert that F stops before the squash push.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At examples/land/tests/flow.test.ts, line 762:

<comment>This test does not verify the F preflight despite claiming coverage for E/F. Add a stage-specific mock that lets E complete but rejects the dry-run at F, then assert that F stops before the squash push.</comment>

<file context>
@@ -756,3 +756,27 @@ test('hosted mergeMode is optional locally and validates all supplied values', (
+
+
+test('hosted auto allows read-only A-D and proves write access only at E/F', async () => {
+  const w = world({ config: autoConfig, pushDryRunFails: true,
+    adversarial: [[blocker('probe/src/relay/agents.rs', 'fix')], []], roundFiles: [['probe/src/relay/agents.rs']] });
+  let stage = 'A-adversarial';
</file context>

if (config.mergePolicy.mode === 'auto') {
// Preflight, not polling: the GitHub gate and the push need an authed gh
// and a write-capable git credential; prove both at stage one.
if (config.mergePolicy.mode === 'auto' && (input.stage === 'E' || input.stage === 'F')) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: The E/F preflight runs before owned = state, so a denied write grant returns a refused completion without persisting the existing run's needs_human terminal state. Assign the existing state to owned before this preflight, or otherwise save the terminal refusal, so the denial is recorded consistently.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At examples/land/land.flow.ts, line 924:

<comment>The E/F preflight runs before `owned = state`, so a denied write grant returns a refused completion without persisting the existing run's `needs_human` terminal state. Assign the existing state to `owned` before this preflight, or otherwise save the terminal refusal, so the denial is recorded consistently.</comment>

<file context>
@@ -921,9 +921,9 @@ export async function land(f: Ctx, raw: LandInput): Promise<void> {
-    if (config.mergePolicy.mode === 'auto') {
-      // Preflight, not polling: the GitHub gate and the push need an authed gh
-      // and a write-capable git credential; prove both at stage one.
+    if (config.mergePolicy.mode === 'auto' && (input.stage === 'E' || input.stage === 'F')) {
+      // Cloud grants A-D read-only access. Prove write capability only in
+      // E/F, where the GitHub gate and final push need the scoped write grant.
</file context>

@kjgbot

kjgbot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #695, which owns the stage-preflight change and now also the cancellation fence. The duplicate was opened before the relay handoff arrived. Closing this PR; retaining the branch and captured evidence.

The only preflight difference is that #695 keeps gh auth status on all auto stages, while this PR moved it to E/F too. Read-only grants authenticate gh, so that difference is not needed for the compatibility fix. My additional fixture explicitly drives a C fix round with denied push capability; #695 may reuse that coverage if useful.

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.

1 participant