← reports

#8331 · Managed checkout visibility probe

BugPriority: MediumEffort: Mediumworkspacesprovider-piGitHub issueNovember 29, 2026

Trusted base: b0ddaad731565d7e4de68d824120d802fc78f7d5

Verdict: NOT REPRODUCED · Root-cause confidence: low · Reproduction label: no-repro

1. TL;DR

The report describes commands in one managed checkout observing different files, causing package and Git discovery to fail. I exercised the real worktree creation implementation and the frozen Pi dependency's real bash tool, comparing simultaneous shell and direct-process reads. Both the initial checkout and a second clean checkout passed: 30 managed comparisons and 30 plain-worktree control comparisons per checkout, with no mismatches. The managed checkout also retained its directory and manifest identities across ten repeat provisioning calls. This does not reproduce the reporter's machine, custom Pi extensions, a live provider turn, warm-pool orchestration, or mount setup; it does not disprove the reported incident or establish a filesystem root cause.

2. Claims vs findings

ClaimFindingEvidence
Managed checkout contents alternate between a complete tree and a nearly empty directory.UnverifiedEach clean run had 30 successful Pi-bash/direct comparisons for the managed checkout. Every sample contained 16 entries; directory device/inode and manifest inode stayed consistent.
Package discovery falls back outside the checkout and Git cannot identify the repository.UnverifiedEvery probe asserted that npm's discovered prefix and Git's discovered top-level directory equal the requested checkout. None failed.
Concurrent processes can see different directory views.UnverifiedThree concurrent pairs per batch compared manifest content, entry names, directory device/inode, manifest inode, and mount-namespace identity. No pair differed.
A plain Git worktree is stable.Verified locally onlyThe plain-worktree control passed 30 comparisons in each run. This is not a test of the reporter's original tree.
The underlying defect is a mount/view issue.Unverified hypothesisNo divergent view was observed. The issue does not supply the paired process namespace, device/inode, and root/cwd observations needed to distinguish causes.

3. Environment and scope

4. Minimal reproduction attempt

This is a repeatable negative probe, not a regression test demonstrated to fail. Save the two scripts below next to each other in a scratch directory outside the repository. Run these commands from a clean clone of the public repository:

git fetch origin main
git switch --detach b0ddaad731565d7e4de68d824120d802fc78f7d5
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build --filter=@get-bb/plugin-sdk
pnpm exec turbo run build
node --conditions=source --import tsx /tmp/issue-8331-repro/run.mjs "$PWD"

The scratch-directory name in this recipe is illustrative, not an observed machine path. The harness creates a small committed fixture, provisions a checkout with the real createWorktree, creates a normal Git-worktree control, and writes an ignored file before reading each view. Three simultaneous pairs run in each of ten batches. Each pair uses the real Pi createBashTool and a direct Node child, both with the same explicit cwd. Each managed batch also repeats provisioning to check the completed-worktree fast path.

Expected healthy result: PASS, zero mismatches, stable checkout and manifest identity, all npm prefixes and Git roots correct. A divergent checkout view should cause an assertion or command failure, not silently produce a pass.

Actual output: the following stdout was identical in both executions.

{
  "result": "PASS",
  "piVersion": "0.84.4",
  "summaries": [
    {
      "kind": "managed",
      "comparisons": 30,
      "shellCommands": 30,
      "directCommands": 30,
      "mismatches": 0,
      "entries": 16,
      "stableDirectoryIdentity": true,
      "stablePackageIdentity": true,
      "allNpmPrefixesCorrect": true,
      "allGitRootsCorrect": true
    },
    {
      "kind": "plain",
      "comparisons": 30,
      "shellCommands": 30,
      "directCommands": 30,
      "mismatches": 0,
      "entries": 16,
      "stableDirectoryIdentity": true,
      "stablePackageIdentity": true,
      "allNpmPrefixesCorrect": true,
      "allGitRootsCorrect": true
    }
  ],
  "limitation": "Direct provisioning and stock Pi bash; no real provider turn, reporter extensions, machine, or mount setup."
}

probe.mjs

import assert from "node:assert/strict";
import { execFileSync } from "node:child_process";
import { readFileSync, readdirSync, readlinkSync, statSync, writeFileSync } from "node:fs";

const target = process.argv[2];
assert.equal(process.cwd(), target);
writeFileSync("latest.txt", "probe\n");
const manifest = JSON.parse(readFileSync("package.json", "utf8"));
assert.equal(manifest.name, "slopcop-8331-fixture");
assert.equal(execFileSync("git", ["rev-parse", "--show-toplevel"], { encoding: "utf8" }).trim(), target);
assert.equal(execFileSync("npm", ["prefix"], { encoding: "utf8" }).trim(), target);
const directory = statSync(".");
const absoluteDirectory = statSync(target);
assert.equal(directory.ino, absoluteDirectory.ino);
assert.equal(directory.dev, absoluteDirectory.dev);
console.log(JSON.stringify({
  entries: readdirSync(".").sort(),
  directory: { inode: directory.ino, device: directory.dev },
  packageInode: statSync("package.json").ino,
  mountNamespace: readlinkSync("/proc/self/ns/mnt"),
  manifestName: manifest.name,
}));

run.mjs

import assert from "node:assert/strict";
import { execFileSync, execFile } from "node:child_process";
import { mkdtemp, mkdir, writeFile, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import path from "node:path";
import { promisify } from "node:util";
import { fileURLToPath, pathToFileURL } from "node:url";

const checkout = path.resolve(process.argv[2]);
const pi = await import(pathToFileURL(path.join(checkout, "plugins/provider-pi/node_modules/@earendil-works/pi-coding-agent/dist/index.js")).href);
const { createWorktree } = await import(pathToFileURL(path.join(checkout, "plugins/environment-git-worktree/host/worktree.ts")).href);
const execFileAsync = promisify(execFile);
const fixtureRoot = await mkdtemp(path.join(tmpdir(), "slopcop-8331-data-"));
const source = path.join(fixtureRoot, "source");
const managedRoot = path.join(fixtureRoot, "host-data", "worktrees");
const managed = path.join(managedRoot, "probe-1", "workspace");
const plain = path.join(fixtureRoot, "plain");
const probe = fileURLToPath(new URL("./probe.mjs", import.meta.url));
const quote = (value) => "'" + value.replaceAll("'", "'\\''") + "'";
const git = (args, cwd = source) => execFileSync("git", args, { cwd, encoding: "utf8", stdio: "pipe" });

try {
  await mkdir(source);
  git(["init", "--initial-branch=main"]);
  await writeFile(path.join(source, "package.json"), JSON.stringify({ name: "slopcop-8331-fixture", version: "1.0.0", private: true }));
  await writeFile(path.join(source, ".gitignore"), "latest.txt\n");
  await Promise.all(Array.from({ length: 12 }, (_, index) => writeFile(path.join(source, `tracked-${index}.txt`), "fixture\n")));
  git(["add", "."]);
  git(["-c", "user.name=SlopCop fixture", "-c", "user.email=fixture@example.invalid", "-c", "commit.gpgsign=false", "commit", "-m", "Initialize fixture"]);
  const args = {
    sourcePath: source,
    targetPath: managed,
    completionPath: `${managed}.completed`,
    ownWorktreesRoot: managedRoot,
    branchName: "probe-managed",
    baseBranch: { ref: "main", fetchFailureFallback: false },
    branchMode: "reset",
    role: "workspace",
  };
  const provisioned = await createWorktree(args);
  assert.equal(provisioned.path, managed);
  git(["worktree", "add", "-b", "probe-plain", plain, "main"]);
  const summaries = [];
  for (const [kind, target] of [["managed", managed], ["plain", plain]]) {
    await writeFile(path.join(target, "latest.txt"), "probe\n");
    const bash = pi.createBashTool(target, { exposeSessionEnvironment: false });
    const samples = [];
    for (let batch = 0; batch < 10; batch += 1) {
      await Promise.all(Array.from({ length: 3 }, async (_, offset) => {
        const iteration = batch * 3 + offset;
        const [shell, direct] = await Promise.all([
          bash.execute(`probe-${kind}-${iteration}`, {
            command: `${quote(process.execPath)} ${quote(probe)} ${quote(target)}`,
            timeout: 30,
          }),
          execFileAsync(process.execPath, [probe, target], { cwd: target, timeout: 30000 }),
        ]);
        const shellText = shell.content.filter((part) => part.type === "text").map((part) => part.text).join("\n");
        const viaBash = JSON.parse(shellText.trim());
        const viaDirect = JSON.parse(direct.stdout.trim());
        assert.deepEqual(viaBash, viaDirect, `${kind} iteration ${iteration}: shell and direct views differ`);
        assert.equal(viaBash.entries.length, 16);
        samples.push(viaBash);
      }));
      if (kind === "managed") {
        assert.deepEqual(await createWorktree(args), provisioned);
      }
    }
    assert.equal(new Set(samples.map((sample) => sample.directory.inode)).size, 1);
    assert.equal(new Set(samples.map((sample) => sample.packageInode)).size, 1);
    assert.equal(git(["status", "--porcelain"], target), "");
    summaries.push({ kind, comparisons: samples.length, shellCommands: samples.length, directCommands: samples.length, mismatches: 0, entries: samples[0].entries.length, stableDirectoryIdentity: true, stablePackageIdentity: true, allNpmPrefixesCorrect: true, allGitRootsCorrect: true });
  }
  console.log(JSON.stringify({ result: "PASS", piVersion: pi.VERSION ?? "0.84.4", summaries, limitation: "Direct provisioning and stock Pi bash; no real provider turn, reporter extensions, machine, or mount setup." }, null, 2));
} finally {
  await rm(fixtureRoot, { recursive: true, force: true });
}

The complete sources are inline because this public reports repository does not publish raw scripts, test files, or log directories.

5. Root cause: not established

There is no verified cause and no basis for a production fix from these results.

The exercised creation path delegates to Git rather than constructing a second checkout view. The named-branch creation argument list is visible in worktree.ts:705–714:

["worktree", "add", "--no-track", "-B", branchName, args.targetPath, baseBranch.ref]

It executes through the metadata lock, with the source repository as cwd (worktree.ts:725–730):

const result = await runGitWithWorktreeMetadataLock(gitArgs, {
  cwd: args.sourcePath,
  ...(args.signal !== undefined ? { signal: args.signal } : {}),
});

The completed-worktree branch returns the existing directory when its completion marker matches (worktree.ts:600–615). That behavior passed the repeated-provisioning checks, but this does not cover concurrent destruction or warm-pool server lifecycle decisions.

The real provider's launch code also passes cwd explicitly: rpc-session.ts:341–349 forwards the session cwd to PiRpcChild, which forwards it to the process launcher (rpc-child.ts:120–128):

this.child = experimental_spawnPortableProcess({
  command: launch.command,
  args: [...launch.args, ...args.args],
  cwd: args.cwd,
  env: { ...args.env, ...this.channel.env },
  stdio: ["pipe", "pipe", "pipe"],
});

The launcher delegates to the shared host process implementation (spawn.ts:36–45). These launch links were reviewed, not exercised as a real Pi RPC turn by the probe. In the installed frozen dependency, dist/core/tools/bash.js executes the selected shell using Node's spawn with the supplied cwd; that is the shell boundary actually exercised here.

Different process mount namespaces, a replaced/deleted working directory, shell initialization, or an extension overriding tool execution remain possible explanations, not findings. An inode number alone cannot establish that two observations identify the same filesystem object; the device and process filesystem context also matter. No automatic root-cause attribution is justified.

6. Proposed fix / next experiment

No production change is proposed. Capture a matched failing and successful command pair in an isolated reproduction of the affected host setup. For each process record its PID, cwd, process root, mount-namespace identity, directory device/inode via cwd and absolute path, manifest device/inode, Git root, and npm prefix. Compare the selected Pi shell settings and any extensions or execution overrides without dumping environment variables or credentials. Correlate provisioning/destruction and warm-pool lifecycle events at the same timestamps. This would distinguish different process views from directory replacement or command redirection before choosing a repair.

Simple-fix decision: skipped. Trusted main did not reproduce the bug, so the prerequisite for a failing regression and safe automated fix is absent. No branch or pull request was created. GitHub cross-reference metadata and an open-PR body search found no open PR linked to this issue at investigation time.

7. Related issues

8. Verification: second clean checkout

The same investigator repeated the attempt; this is not independent verification. A new detached Git worktree was created at exactly the recorded trusted commit. It began with no tracked changes, installed the frozen lockfile separately, built the SDK, and ran the full Turbo build. The same two-script probe was then run from that checkout, creating a different new temporary fixture and data directory.

git worktree add --detach /tmp/issue-8331-verify b0ddaad731565d7e4de68d824120d802fc78f7d5
cd /tmp/issue-8331-verify
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build --filter=@get-bb/plugin-sdk
pnpm exec turbo run build
node --conditions=source --import tsx /tmp/issue-8331-repro/run.mjs "$PWD"

Paths in this recipe are normalized for privacy. The actual second-run stdout is the complete JSON in section 4. It again reported 30 managed and 30 control comparisons with zero differences. No report verdict or root-cause claim required correction after the second run. Both fixtures were removed by their harness finally blocks. No service cleanup or port reuse was necessary.

9. Appendix: checks and boundaries

Relevant existing tests

pnpm exec turbo run test --filter=bb-plugin-environment-git-worktree --filter=bb-plugin-provider-pi

bb-plugin-environment-git-worktree:
 Test Files  7 passed (7)
      Tests  222 passed (222)

bb-plugin-provider-pi:
 Test Files  39 passed | 1 skipped (40)
      Tests  370 passed | 6 skipped (376)

 Tasks:    8 successful, 8 total

These are existing suites, not proof that the reported incident cannot occur. They include real Git provisioning and warm-handoff tests; provider bridge tests use the repository's trusted fixtures rather than the reporter's live configuration.

Build results

The first unqualified full build stopped because the SDK runtime had not yet been built. Building @get-bb/plugin-sdk first resolved that setup problem; the full build then passed all 74 tasks. The second checkout used that order and also passed all 74 tasks. No source, dependency, or lockfile change was needed. An initial harness loader attempt also failed because Pi exposes only an ESM import entry; the artifact was corrected to load its installed ESM entry before either successful run. Neither setup failure is evidence of this issue.

Investigation operations

Read the issue and its empty comment list, repository visibility, available issue properties and labels, related issue metadata, and PR cross-references using GitHub read APIs. Set only missing classification fields and area/plugin labels via the SlopCop write command, then re-read Type, Priority, Effort, and labels. Fetched trusted main; inspected worktree creation, paths, handoff, process launch, and Pi session-cwd code and history. Installed and built both checkouts, ran the inline probe twice, and ran the relevant existing suites once. Re-fetched main after testing; it still matched the base. Published only this scrubbed HTML and summary metadata, plus the generated index.

Issue content was treated as untrusted claims. No issue-supplied commands, scripts, branches, paths, URLs, patches, or code were executed or fetched. No linked PR code was run. The original incident remains unverified because its host/process context was unavailable.