#7345 · Scoped Git plugin checks use repository commits
Verdict: REPRODUCED · Root-cause confidence: high · reproduction label: confirmed-repro
1. TL;DR
A plugin installed from one directory of a Git collection is offered an update when a sibling directory changes. The update resolver compares repository commit IDs, not the installed plugin's directory tree. The server then temporarily clones and validates that unrelated candidate and persists its commit as an available update. Two clean checkouts of trusted main reproduced both the false result and the extra materialization. No permanent candidate artifact is created by this check: the temporary staging directory is removed.
2. Claims vs findings
| Claim | Finding | Evidence |
|---|---|---|
| Sibling-only commits produce a false update. | Verified | Real local Git repository, real plugin install, real migrated SQLite database: expected current, received update-available in both runs. |
| The unrelated candidate is staged. | Verified, with clarification | Materializations increase from 1 to 2. This is temporary cloning/manifest validation, not a new persisted plugin artifact. |
| No plugin-subdirectory comparison is performed. | Verified | The resolver receives URL/ref/current commit; the service immediately stages a non-range candidate. |
| The reporter's own test validates the report. | Unverified | No reporter code was executed. The regression here was authored from trusted repository fixtures. |
3. Environment
- Public repository: get-bb/bb; trusted origin/main commit
7c1353d80729983b86ea1555d18b42407f320406. - Linux x86_64; Node v22.19.0; pnpm 9.15.0; Git 2.39.5; Vitest 4.1.12.
- No agent provider, live BB instance, browser, or HTTP port is needed. The fixture uses an isolated temporary directory and a real migrated SQLite database; neither user runtime data nor production services are accessed.
- The normal frozen install was attempted in both checkouts. The first returned nonzero after prepare/bin-link warnings for not-yet-built workspace executables; the second succeeded. A full Turbo build then passed all 73 tasks. Native-module verification ran through Turbo.
4. Minimal reproduction
- Clone the public trusted repository and check out the recorded main commit.
git clone https://github.com/get-bb/bb.git bb-issue-7345 cd bb-issue-7345 git checkout --detach 7c1353d80729983b86ea1555d18b42407f320406 pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build
- Add the regression below inside
describe("plugin update service and routes", ...)inapps/server/test/services/plugins/plugin-update.test.ts, immediately after its existinginstallUpdaterhelper. It reuses that file's real service, database, Git fixture, and cleanup. No production code changes are needed. - Run
pnpm exec turbo run test --filter=@bb/server -- test/services/plugins/plugin-update.test.ts -t 'ignores unrelated commits'
- The test relocates a real fixture plugin into
plugins/updater, installs it while tracking main, commits only a sibling directory, then checks for updates. Expected: current, no extra materialization, and no available candidate in the installed row. Actual: update-available, a second materialization, and a candidate commit persisted as available.
Regression test (complete added block)
it("ignores unrelated commits for a branch-tracking subdirectory plugin", async () => {
const pluginDir = join(repo, "plugins", "updater");
await mkdir(pluginDir, { recursive: true });
await rename(join(repo, "package.json"), join(pluginDir, "package.json"));
await rename(join(repo, "server.ts"), join(pluginDir, "server.ts"));
await git(repo, ["add", "-A"]);
await git(repo, ["commit", "-qm", "Move fixture into collection"]);
const installedCommit = await git(repo, ["rev-parse", "HEAD"]);
await service.install(`git:${repo}@main`, {
kind: "subdirectory",
path: "plugins/updater",
});
const installedMaterializations = materializationCount;
const installedArtifacts = listPluginArtifacts(db, "updater").length;
await mkdir(join(repo, "plugins", "sibling"));
await writeFile(join(repo, "plugins", "sibling", "notes.txt"), "changed");
await git(repo, ["add", "-A"]);
await git(repo, ["commit", "-qm", "Change sibling fixture"]);
expect.soft(await service.checkForUpdates("updater")).toMatchObject([
{
id: "updater",
outcome: "current",
installed: { version: installedCommit },
},
]);
expect.soft(materializationCount).toBe(installedMaterializations);
expect(listPluginArtifacts(db, "updater")).toHaveLength(installedArtifacts);
expect(getInstalledPlugin(db, "updater")).toMatchObject({
gitResolvedCommit: installedCommit,
availableCompatibleVersion: null,
});
await writeFile(
join(pluginDir, "server.ts"),
'export default function plugin() { return "changed"; }',
);
await git(repo, ["add", "-A"]);
await git(repo, ["commit", "-qm", "Change plugin fixture"]);
const nextCommit = await git(repo, ["rev-parse", "HEAD"]);
expect(await service.checkForUpdates("updater")).toMatchObject([
{
id: "updater",
outcome: "update-available",
candidate: { version: nextCommit },
},
]);
expect(materializationCount).toBeGreaterThan(installedMaterializations);
});
First trusted-base run: verbatim assertion excerpt
AssertionError: expected [ { id: 'updater', …(3) } ] to match object [ { id: 'updater', …(2) } ]
@bb/server:test: (4 matching properties omitted from actual)
@bb/server:test:
@bb/server:test: - Expected
@bb/server:test: + Received
@bb/server:test:
@bb/server:test: @@ -2,8 +2,8 @@
@bb/server:test: {
@bb/server:test: "id": "updater",
@bb/server:test: "installed": {
@bb/server:test: "version": "f42456c59df7d6c3c801c8ed06af92994cc4ce3d",
@bb/server:test: },
@bb/server:test: - "outcome": "current",
@bb/server:test: + "outcome": "update-available",
@bb/server:test: },
@bb/server:test: ]
@bb/server:test:
@bb/server:test:
The same run additionally reported AssertionError: expected 2 to be 1 for materializations and a non-null available-compatible commit. It exited 1: one test failed, 37 skipped. The installed commit remained unchanged; the artifact count stayed unchanged.
5. Root cause
resolveGitUpdate, lines 885–934 constructs a candidate from the branch head and uses repository commit equality as its sole currentness check:
if (resolved.commit === args.currentCommit) {
return { outcome: "current", current };
}
return { outcome: "update-available", current, candidate };
resolveUpdateForRow, lines 509–522 does not provide the subdirectory to that resolver and stages every non-range candidate:
if (remote.outcome !== "update-available") return remote;
if (intent.selector.kind === "range") return remote;
const staged = await stageGitCandidate({
row: args.row,
commit: remote.candidate.version,
promote: false,
});
The candidate materializer, lines 1206–1230 invokes the materialization hook and clones the candidate repository before resolving its plugin root. It validates the manifest, not tree equality. A successful clone therefore makes an unrelated branch commit look like a legitimate update. The stage is removed in finally; this is unnecessary work and false update state, not a durable staged installation.
6. Proposed fix and validation
For non-range branch updates with a plugin subdirectory, fetch the installed and candidate commit trees into an ephemeral bare repository and compare that subdirectory's tree IDs before candidate materialization. Equal IDs mean current. Different IDs continue normal validation. If commits or trees cannot be inspected, retain the existing validation path rather than suppressing updates. Keep pinned references, range selection, and repository-root installs unchanged.
The contained patch uses a shallow blob-filtered fetch and deletes its temporary repository in a finally block; it introduces no persistent mirror, dependency, migration, or protocol. The added owner-boundary regression fails before the production change and passes afterward. It also verifies that actual changes within the plugin directory are still reported. A separate test removes the installed commit from a replacement remote history and verifies that comparison failure still permits an update.
7. Verification
The same agent repeated the test in a second clean temporary Git worktree, here called CHECKOUT_B, at exactly 7c1353d80729983b86ea1555d18b42407f320406. Only the new test block was applied; production source remained unchanged. Its local plugin repository and SQLite database were newly created by the fixture. No live process ports were used. This is a repeated clean run, not independent-agent verification.
CHECKOUT_B command: pnpm exec turbo run test --filter=@bb/server -- test/services/plugins/plugin-update.test.ts -t 'ignores unrelated commits' Exit: 1 Tests: 1 failed | 37 skipped (38) Materialization assertion: expected 2 to be 1
Second run: verbatim assertion excerpt
AssertionError: expected [ { id: 'updater', …(3) } ] to match object [ { id: 'updater', …(2) } ]
@bb/server:test: (4 matching properties omitted from actual)
@bb/server:test:
@bb/server:test: - Expected
@bb/server:test: + Received
@bb/server:test:
@bb/server:test: @@ -2,8 +2,8 @@
@bb/server:test: {
@bb/server:test: "id": "updater",
@bb/server:test: "installed": {
@bb/server:test: "version": "9ea05e6e13a745e31c0e5189a718eb86111e832d",
@bb/server:test: },
@bb/server:test: - "outcome": "current",
@bb/server:test: + "outcome": "update-available",
@bb/server:test: },
@bb/server:test: ]
@bb/server:test:
@bb/server:test:
Both clean runs support the same root cause. Report clarification: staging here is temporary clone/validation; no new persistent artifact is created. No other correction was necessary.
Post-fix verification: the focused regression passes; the plugin-update, update-resolver, and plugin-install suites pass (114 tests across 3 files). Server Turbo typecheck passes. git diff --check and configured formatting checks pass. The proposed change is 136 added/deleted text lines in 2 files, with no binary or generated changes.
8. Related issues and pull requests
No open pull request linked to #7345 was found through issue timeline metadata or open-PR search before the fix. Similar plugin-update requests exist, but the search found no duplicate report of this scoped tree comparison defect. No linked PR code was checked out or executed.
9. Appendix and trust boundary
The issue's suggested implementation was treated as untrusted input, not executed or copied. All executable code came from the recorded trusted main commit or locally authored changes based on its existing fixtures. No external issue links, scripts, branches, patches, or tests were fetched.
Normal commands used: frozen pnpm install; full Turbo build; the focused Turbo test command above in two clean worktrees; the same command after the repair; pnpm exec turbo run test --filter=@bb/server -- test/services/plugins/plugin-update.test.ts test/services/plugins/update-resolver.test.ts test/services/plugins/plugin-install.test.ts; pnpm exec turbo run typecheck --filter=@bb/server; configured oxfmt checks; git diff --check; and git diff --numstat origin/main. Raw logs remain local. The complete regression is embedded here because the reports repository disallows published log/test artifact directories.
AGENT GENERATED