From bc2cafe06ab95eaeb08622db9341bfc9af68d7fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kao=20F=C3=A9lix?= Date: Thu, 8 Oct 2026 16:36:41 +0000 Subject: [PATCH] fix(docs): report post-merge draft conflicts and align tunnel guidance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The post-merge docs author failed with only the git command line when the managed draft conflicted with main. Report the conflicting files and git's conflict messages, and document how to recover. Align the Cloudflare tunnel sections in run-sandboxes.mdx with current behavior: tunnel start targets the selected sandbox's registered dashboard port, and tunnel state is scoped to the OpenShell gateway port. This lets the open managed draft merge cleanly with main. Signed-off-by: Kao Félix --- docs/AUTOMATION.md | 20 ++++++++++++++++++ docs/manage-sandboxes/run-sandboxes.mdx | 18 +++++++++-------- test/generation/post-merge-docs.test.ts | 7 ++++++- tools/post-merge-docs/README.md | 5 +++-- tools/post-merge-docs/run.mts | 27 ++++++++++++++++++++++--- 5 files changed, 63 insertions(+), 14 deletions(-) diff --git a/docs/AUTOMATION.md b/docs/AUTOMATION.md index 02f153176c7..e969d9edfb3 100644 --- a/docs/AUTOMATION.md +++ b/docs/AUTOMATION.md @@ -56,6 +56,26 @@ The publisher also leaves a draft with previous workflow metadata unchanged. It and stops without writing. Close that legacy draft so a later qualifying push can create a current workflow-owned draft, or mark it ready for review to transfer ownership to maintainers. +### Resolve a Draft Merge Conflict + +Each run merges the open managed draft with the triggering `main` commit before authoring. +When both changed the same lines, the author step fails before it creates a sandbox. +The error names the draft commit, the `main` commit, and each conflicting file. +Rerunning without a change hits the same conflict. + +1. Reproduce the conflict locally with + `git merge-tree --write-tree `. +2. Check the conflicting text against current source and tests, then choose the accurate wording. +3. Choose one recovery path: + - To keep automation ownership, open a PR that updates the conflicting `main` text so it + merges cleanly with the draft. Confirm with `git merge-tree` against the draft head. The next + qualifying push to `main` refreshes the draft. + - To take ownership, mark the draft PR ready for review and resolve the conflict on its branch. + Later workflow runs leave the PR unchanged. + +Do not push a resolution commit to the draft branch while automation owns it. The publisher +accepts only commits that the workflow created. + ### Recover an Orphaned Managed Branch If draft PR creation fails after branch creation, the publisher reports the exact branch and commit. diff --git a/docs/manage-sandboxes/run-sandboxes.mdx b/docs/manage-sandboxes/run-sandboxes.mdx index 1eaa45158b1..1a56825cbcd 100644 --- a/docs/manage-sandboxes/run-sandboxes.mdx +++ b/docs/manage-sandboxes/run-sandboxes.mdx @@ -160,10 +160,9 @@ Use [`$$nemoclaw destroy`](../../reference/commands#$$nemoclaw-name-destr ## Manage the Cloudflare Tunnel -When the host has `cloudflared`, `$$nemoclaw tunnel start` starts a Cloudflare tunnel. -The tunnel can expose the dashboard with a public URL. -NemoClaw manages one tunnel for the selected OpenShell gateway port, independent of individual sandbox lifecycles. -Stopping, destroying, or recreating a sandbox does not stop that tunnel. +When the host has `cloudflared`, `$$nemoclaw tunnel start` starts a Cloudflare tunnel for the selected sandbox's registered dashboard port. +Set `NEMOCLAW_SANDBOX_NAME`, `NEMOCLAW_SANDBOX`, or `SANDBOX_NAME` to select a sandbox; otherwise, the command uses the registry default. +The tunnel can expose that dashboard with a public URL. Set `CLOUDFLARE_TUNNEL_TOKEN` before running the command when you want to use a Cloudflare named tunnel instead of a generated quick-tunnel URL. If command-line inspection is unavailable, Windows can still verify and stop a recorded `cloudflared.exe` through an identity-bound process handle. Other platforms require process inspection before signaling. If NemoClaw cannot verify the process identity or stop it safely, it refuses to create a second tunnel; restore inspection access or independently verify and stop the process before retrying. [`$$nemoclaw tunnel status`](../../reference/commands#$$nemoclaw-tunnel-status) reports this recovery state. @@ -172,6 +171,8 @@ $$nemoclaw tunnel start ``` `$$nemoclaw tunnel stop` stops the tunnel and asks NemoClaw to stop the in-sandbox gateway for the selected or default sandbox. +NemoClaw manages one tunnel for the selected OpenShell gateway port, independent of individual sandbox lifecycles. +Stopping, destroying, or recreating a sandbox does not stop that tunnel. An explicitly set `NEMOCLAW_GATEWAY_PORT` selects the host tunnel state. Otherwise, tunnel commands use the selected or default sandbox's owning gateway, falling back to the process-default gateway when no sandbox resolves. If the sandbox name belongs to more than one gateway registry, tunnel-state selection fails closed. @@ -190,10 +191,9 @@ a sandbox or tunnel. Use `$$nemoclaw start` or `$$nemoclaw tunnel start` ## Manage the Cloudflare Tunnel -When the host has `cloudflared`, `$$nemoclaw tunnel start` starts a Cloudflare tunnel. -The tunnel can expose the forwarded Hermes endpoint with a public URL. -NemoClaw manages one tunnel for the selected OpenShell gateway port, independent of individual sandbox lifecycles. -Stopping, destroying, or recreating a sandbox does not stop that tunnel. +When the host has `cloudflared`, `$$nemoclaw tunnel start` starts a Cloudflare tunnel for the selected sandbox's registered dashboard port. +Set `NEMOCLAW_SANDBOX_NAME`, `NEMOCLAW_SANDBOX`, or `SANDBOX_NAME` to select a sandbox; otherwise, the command uses the registry default. +The tunnel can expose that dashboard with a public URL. Set `CLOUDFLARE_TUNNEL_TOKEN` before running the command when you want to use a Cloudflare named tunnel instead of a generated quick-tunnel URL. If command-line inspection is unavailable, Windows can still verify and stop a recorded `cloudflared.exe` through an identity-bound process handle. Other platforms require process inspection before signaling. If NemoClaw cannot verify the process identity or stop it safely, it refuses to create a second tunnel; restore inspection access or independently verify and stop the process before retrying. [`$$nemoclaw tunnel status`](../../reference/commands#$$nemoclaw-tunnel-status) reports this recovery state. @@ -202,6 +202,8 @@ $$nemoclaw tunnel start ``` `$$nemoclaw tunnel stop` stops the tunnel but leaves the supervisor-owned in-sandbox gateway and agent-owned host forwards running for the selected or default sandbox. +NemoClaw manages one tunnel for the selected OpenShell gateway port, independent of individual sandbox lifecycles. +Stopping, destroying, or recreating a sandbox does not stop that tunnel. An explicitly set `NEMOCLAW_GATEWAY_PORT` selects the host tunnel state. Otherwise, tunnel commands use the selected or default sandbox's owning gateway, falling back to the process-default gateway when no sandbox resolves. If the sandbox name belongs to more than one gateway registry, tunnel-state selection fails closed. diff --git a/test/generation/post-merge-docs.test.ts b/test/generation/post-merge-docs.test.ts index abd79fba50b..e0c23d3ae9e 100644 --- a/test/generation/post-merge-docs.test.ts +++ b/test/generation/post-merge-docs.test.ts @@ -965,7 +965,12 @@ describe("post-merge documentation runner", () => { git(source, ["checkout", "main"]); input.env.GITHUB_SHA = git(source, ["rev-parse", "HEAD"]); const { tools } = runnerTools(input); - expect(() => executePostMergeDocs(input.env, tools)).toThrow(); + const run = () => executePostMergeDocs(input.env, tools); + expect(run).toThrow( + `The managed documentation draft ${input.env.POST_MERGE_DOCS_PREVIOUS_SHA} conflicts with main ${input.env.GITHUB_SHA} in: docs/guide.mdx`, + ); + expect(run).toThrow("CONFLICT (content): Merge conflict in docs/guide.mdx"); + expect(run).toThrow("docs/AUTOMATION.md#resolve-a-draft-merge-conflict"); expect(tools.run).not.toHaveBeenCalled(); expect(fs.existsSync(path.join(input.root, "artifact/docs.patch"))).toBe(false); }); diff --git a/tools/post-merge-docs/README.md b/tools/post-merge-docs/README.md index 00509ea61f9..c1acd760227 100644 --- a/tools/post-merge-docs/README.md +++ b/tools/post-merge-docs/README.md @@ -7,8 +7,9 @@ This directory owns the trusted authoring and publishing boundary for `Docs / Au Each refresh merges the selected draft commit with the triggering `main` commit before authoring. The author extends those staged documentation changes. The reviewer checks the combined patch and -compares revisions or removals with the previous draft. A merge conflict stops the run for maintainer -resolution. Publication stops if the managed draft changed after selection. +compares revisions or removals with the previous draft. A merge conflict stops the run before authoring +and reports the conflicting files. Follow +[Resolve a Draft Merge Conflict](../../docs/AUTOMATION.md#resolve-a-draft-merge-conflict). Publication stops if the managed draft changed after selection. Successful draft creation, refresh, recovery, and no-change runs exit successfully. When a managed draft remains open, the publisher emits a notice linking to it for maintainer review and merge. diff --git a/tools/post-merge-docs/run.mts b/tools/post-merge-docs/run.mts index 7f7c4ed3106..7ae0d78fbb4 100755 --- a/tools/post-merge-docs/run.mts +++ b/tools/post-merge-docs/run.mts @@ -2,7 +2,7 @@ // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 -import { execFileSync } from "node:child_process"; +import { execFileSync, spawnSync } from "node:child_process"; import { createHash } from "node:crypto"; import fs from "node:fs"; import path from "node:path"; @@ -73,6 +73,28 @@ function git(repository: string, args: readonly string[]): string { }).trim(); } +function mergeDraftTree(repository: string, main: string, previous: string): string { + const result = spawnSync( + "git", + ["-C", repository, "merge-tree", "--write-tree", "--name-only", main, previous], + { encoding: "utf8", env: GIT_ENV, stdio: ["ignore", "pipe", "pipe"] }, + ); + if (result.error) throw result.error; + const [tree = "", ...rest] = result.stdout.trim().split("\n"); + if (result.status === 0) return exactSha(tree, "merged draft tree"); + if (result.status !== 1) fail(`git merge-tree failed: ${result.stderr.trim()}`); + const separator = rest.indexOf(""); + const files = separator < 0 ? rest : rest.slice(0, separator); + const messages = separator < 0 ? [] : rest.slice(separator + 1); + return fail( + [ + `The managed documentation draft ${previous} conflicts with main ${main} in: ${files.join(", ")}`, + ...messages, + "Follow the recovery procedure: https://github.com/NVIDIA/NemoClaw/blob/main/docs/AUTOMATION.md#resolve-a-draft-merge-conflict", + ].join("\n"), + ); +} + function reset(directory: string): void { fs.rmSync(directory, { force: true, recursive: true }); fs.mkdirSync(directory, { mode: 0o700, recursive: true }); @@ -176,8 +198,7 @@ function prepare(env: NodeJS.ProcessEnv): void { const main = exactSha(env.GITHUB_SHA, "GITHUB_SHA"); const previous = previousSha(env); if (previous) { - const merged = git(repository, ["merge-tree", "--write-tree", main, previous]); - git(repository, ["read-tree", "--reset", "-u", exactSha(merged, "merged draft tree")]); + git(repository, ["read-tree", "--reset", "-u", mergeDraftTree(repository, main, previous)]); validateCandidate(repository); } if (current === "review") {