Skip to content

fix(land): refuse mismatched hosted merge modes - #694

Merged
khaliqgant merged 1 commit into
mainfrom
fix/land-hosted-mode-contract
Nov 3, 2026
Merged

khaliqgant merged 1 commit into
mainfrom
fix/land-hosted-mode-contract

Conversation

@kjgbot

@kjgbot kjgbot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Cloud now sends mergeMode, but the released land example discards it and chooses the repository config independently. An auto run with a shadow config can complete without a push and be interpreted by Cloud as landed.

Retain and validate the optional mode, and refuse mismatches against the pinned or persisted config before review, agent or push work and before terminal/already-advanced replays. Matching modes keep their existing behavior; local runs may omit the field. No runtime package or model gate changes, no npm release, and no deployment in this PR.

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; 90 passed, 0 failed. With the four regression cases added before implementation, 3 failed and 1 passed. Commands and literal captured outputs: examples/land/evidence/hosted-mode/verification.md and its sibling transcripts. Hosted execution is not yet verified.

Human merge required; the land deployment owner handles redeployment after merge.


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
  • claude session fdd0fe32 · contributor · ran gh pr commands · 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: 089b8c18-97e6-4d9a-b710-1f63659d178c
  • 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 review at exact head 34c4e94a6cca1f6851da4bbef49d573a04c6c2d9: no findings.

Independent read-only reviewer checked the full diff against 0075bf2c and the captured baseline/typecheck/90-test output. The request mode is validated and retained, initial config comes from the pinned SHA, resumes use persisted config, and the equality check precedes terminal/no-op returns and owned-state assignment. Local omission remains compatible. Tests and hosted execution were not independently rerun by the reviewer.

@kjgbot
kjgbot marked this pull request as ready for review November 3, 2026 06:40

@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.

No issues found across 7 files

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

@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

The flow now keeps and checks the optional mergeMode sent by Cloud.

  • Hosted land requests must match the mode in their config.

kjgbot explicitly states that hosted execution is not yet verified and redeployment belongs to the land operator after merge. The supplied transcripts record 90 passing local tests and a successful type check; these checks were not rerun during this review.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Read input and saved state] --> B[Choose initial or saved config]
  B --> C{mergeMode omitted or matching?}
  C -->|No| D[Return needs_human without saving state]
  C -->|Yes| E{Terminal or already advanced?}
  E -->|Yes| F[Repeat saved result]
  E -->|No| G[Continue existing stage work]
Loading

Reviews (1) · Last reviewed commit: "fix(land): refuse mismatched hosted merg..." · Reviewed by Greptile

@khaliqgant
khaliqgant merged commit d3668b3 into main Nov 3, 2026
5 checks passed
@khaliqgant
khaliqgant deleted the fix/land-hosted-mode-contract branch November 3, 2026 06:50
@kjgbot

kjgbot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

maintainability lens — PASS

Maintainability review — PR #694

Concerns

  1. Enum duplicated as a regex literal. examples/land/land.flow.ts:216 validates mergeMode with a hand-written /^(?:shadow|approval|auto)$/ even though MERGE_MODES already exists at land.flow.ts:49 and the oneOf() helper is used for the same enum at land.flow.ts:143. The three branches drift silently if someone adds a mode: the type ((typeof MERGE_MODES)[number]) and the config-side validator update automatically, but the input-side regex doesn't. A future reader has to notice the inconsistency. Prefer check(..., MERGE_MODES) with a small array variant of check, or inline a MERGE_MODES.includes(...) guard, so the enum has one source of truth.

  2. JSDoc overstates the contract. land.flow.ts:165 says "must agree with the pinned config and every persisted stage." The code at land.flow.ts:912-914 only compares against config.mergePolicy.mode, which is state?.config ?? parsed-at-A. That's correct — the mode is pinned at stage A — but a reader six months out will search for the "every persisted stage" check and not find it. The README row at README.md:46 already states it precisely ("the pinned mergePolicy.mode on the first stage and the persisted config on every resume"); mirror that wording into the JSDoc.

Notes

  1. approval acceptance is a trap worth a test. mergeMode: 'approval' passes the regex and, if mergePolicy.mode === 'approval', the check succeeds — but the next line (land.flow.ts:918) still returns declined. That's defensible per the current spec, but no test pins it, so a future refactor could silently flip the outcome. One assertion in the input-validation test (flow.test.ts:749) would freeze the behavior.

  2. Hosted-vs-local invariant is honor-system. The field is optional precisely to keep local runs ergonomic (land.flow.ts:165), but a hosted caller that drops mergeMode reintroduces the exact bug this PR fixes. The verification note calls this out; it's not actionable here, but worth a [[hosted-mode-contract]] memory or a check on the Cloud side so the invariant isn't invisible.

  3. Comment at land.flow.ts:910-911 is good. It names why the check must run before terminal/already-advanced replays, which is the non-obvious part. Keep that style.

Tests

The four new tests cover crossed modes, matching modes (including real-push on auto), replay-of-advanced-stage without state mutation (deepEqual(w.state(), before) at flow.test.ts:733), and terminal-replay refusal. Input validation covers absent, each enum value, and five bad inputs. A behavior change (e.g., allowing crossed modes) would fail at least two of these. Coverage is adequate.

No blockers.

REVIEW_PASSED

@kjgbot

kjgbot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

history lens — PASS

Blockers: None. PR #694 passes the HISTORY lens. I found no repeated DRIVE-LOG mistake, new contradiction with a settled RFC-0001 decision, or false commit-message claim.

Notes: The change strengthens the existing mode boundary. examples/land/land.flow.ts:908–916 checks the requested mode against persisted configuration before returning terminal or already-advanced results. It refuses disagreement rather than changing configuration or permitting work under another mode. This preserves the previous shadow/auto separation and adds no replay mechanism, kernel vocabulary, provider abstraction, or merge-authority exception prohibited by settled decisions.

The regression cases in examples/land/tests/flow.test.ts:702–746 address crossed modes, matching modes, advanced-stage retries, and terminal replay. Existing behavior remains behind the new agreement check; the diff does not restore previously removed shadow dispatch behavior or unsupported harnesses.

The sole commit message, fix(land): refuse mismatched hosted merge modes, accurately describes the implementation and makes no additional test or deployment claims. Unlike the overstated behavioral claims documented in DRIVE-LOG’s PR #252 retrospective, the evidence report explicitly limits its scope: verification.md:13–30 provides commands and transcript references and identifies the runs as local fixture tests.

Concerns: Hosted execution and redeployment remain unverified follow-up work, explicitly disclosed in the PR body and evidence report. That limits rollout confidence but does not establish a HISTORY blocker. I did not independently rerun the submitted tests.

REVIEW_PASSED
hook: Stop
hook: Stop Completed

@kjgbot

kjgbot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

structure lens — MISSING

@kjgbot

kjgbot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

🎯 review-swarm: FAILED (M:pass H:pass S:missing)

Lens transcripts posted as sibling comments above.

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.

2 participants