mirror of
https://github.com/mvschwarz/openrig.git
synced 2026-11-09 17:32:41 -10:00
fix(test): harden plugin-discovery same-root proof + neutralize comment phrasing
Forward-fix on the initial wiring test, addressing two guard
findings:
(1) Same-root test hardening:
- Replaces 'openrig-core' (which exists on operators' default-rooted
hosts) with a unique synthetic id `synthetic-cross-leak-${Date.now()}`
so pre-fix code cannot satisfy the assertion from a host
~/.openrig/plugins/openrig-core directory.
- Adds a PluginEntry.path startsWith assertion proving discovery
resolved against <tmpHome>/plugins, not the default homedir root.
- The previous id-only check would not have discriminated pre-fix
from post-fix on hosts where openrig-core was already vendored at
the default location.
(2) Comment phrasing adjusted to drop walk-context attribution:
- "caught it on $WALK refresh" → "caught the bug originally"
- "$WALK refresh exposed" → "velocity-qa VM dogfood exposed"
- Slice id token plugin-discovery-respects-openrig-home retained
(stable identifier; same rule applied on slice 17 forward-fix #1)
- Substrate ACK packet at the substrate path is NOT retroactively
modified (substrate context vs product source)
Test discrimination: 3 of 3 tests FAIL on pre-fix tip 91d81d2
(static-grep audit + scans-and-finds + same-root verification); 3 of 3
PASS on post-fix. Confirmed via temporary
`git checkout <pre-fix-sha> -- packages/daemon/src/startup.ts` + re-run.
Full daemon suite: 3353 passed / 1 skipped / 0 failed.
git diff --check clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This commit is contained in:
1 parent
eeb583e654
commit
d5cc5ed390
1 file changed
+29
-23
@@ -6,8 +6,8 @@
|
||||
// scan logic against injected paths; THIS test covers the call-site
|
||||
// resolution in startup.ts that pre-fix hardcoded
|
||||
// `~/.openrig/plugins`. Without this gate, the next regression at the
|
||||
// call site would only surface via end-to-end VM exercise (which is
|
||||
// exactly how velocity-qa caught it on founder-walk VM refresh).
|
||||
// call site would only surface via end-to-end VM dogfood exercise
|
||||
// (which is exactly how velocity-qa caught the bug originally).
|
||||
//
|
||||
// HG-5 (audit-grep) is asserted as a static check in the second
|
||||
// describe: no `homedir().*\.openrig.*plugins` literal remains in
|
||||
@@ -67,29 +67,35 @@ describe("plugin discovery honors OPENRIG_HOME (HG-1, HG-3, HG-4)", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("vendor + discovery resolve to the SAME OPENRIG_HOME-rooted path (no cross-leak between services)", async () => {
|
||||
// Symmetric resolution check: after createDaemon runs, the
|
||||
// bundled openrig-core asset MUST have been vendored under
|
||||
// <OPENRIG_HOME>/plugins/openrig-core/. If discovery resolved a
|
||||
// different root, the auto-vendored asset wouldn't be visible
|
||||
// through listPlugins (which is exactly the founder-walk VM
|
||||
// refresh bug — vendor wrote one place, discovery scanned
|
||||
// another). Same-root verification proves both services share
|
||||
// the resolver.
|
||||
it("vendor + discovery resolve to the SAME OPENRIG_HOME-rooted path (path startsWith verification)", async () => {
|
||||
// Hardened symmetric-resolution check: assert the discovered
|
||||
// PluginEntry.path actually lives under <tmpHome>/plugins, not
|
||||
// just that an id with the same name appeared. A host with
|
||||
// ~/.openrig/plugins/openrig-core would otherwise let pre-fix
|
||||
// code satisfy the id-only assertion from the wrong root.
|
||||
//
|
||||
// Two layers of evidence:
|
||||
// 1. Synthetic plugin id (NOT 'openrig-core' — that name exists
|
||||
// at the host default location on some operators' machines,
|
||||
// so it wouldn't discriminate pre-fix vs post-fix code).
|
||||
// 2. PluginEntry.path startsWith <tmpHome>/plugins/<unique-id>.
|
||||
const uniqueId = `synthetic-cross-leak-${Date.now()}`;
|
||||
const pluginDir = join(tmpHome, "plugins", uniqueId);
|
||||
writeClaudePluginManifest(pluginDir, {
|
||||
name: uniqueId,
|
||||
version: "0.1.0",
|
||||
description: "cross-leak probe",
|
||||
});
|
||||
|
||||
const { deps, db } = await createDaemon({ dbPath: ":memory:" });
|
||||
try {
|
||||
// Vendor should have placed openrig-core at <tmpHome>/plugins/openrig-core/
|
||||
const expectedVendoredPath = join(tmpHome, "plugins", "openrig-core");
|
||||
const stats = (() => {
|
||||
try { return statSync(expectedVendoredPath); } catch { return null; }
|
||||
})();
|
||||
expect(stats, `vendor service should have placed openrig-core under ${expectedVendoredPath}`).not.toBeNull();
|
||||
expect(stats!.isDirectory()).toBe(true);
|
||||
|
||||
// And discovery should surface it via the listPlugins envelope.
|
||||
const plugins = await deps.pluginDiscoveryService!.listPlugins({});
|
||||
const vendoredIds = plugins.filter((p) => p.source === "vendored").map((p) => p.id).sort();
|
||||
expect(vendoredIds).toContain("openrig-core");
|
||||
const entry = plugins.find((p) => p.id === uniqueId);
|
||||
expect(entry, `discovery should surface synthetic plugin ${uniqueId}`).toBeDefined();
|
||||
expect(entry!.source).toBe("vendored");
|
||||
// Path-startsWith proof: discovery resolved against tmpHome,
|
||||
// not the host's default ~/.openrig.
|
||||
expect(entry!.path.startsWith(join(tmpHome, "plugins"))).toBe(true);
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
@@ -100,7 +106,7 @@ describe("plugin-discovery-respects-openrig-home audit (HG-2, HG-5)", () => {
|
||||
// T5: static-grep audit — no hardcoded `homedir() ... .openrig ...
|
||||
// plugins` literal should remain in daemon src. Comments OK; runtime
|
||||
// path construction NOT OK. This test will fail if a future change
|
||||
// reintroduces the hardcoded path that founder-walk VM refresh
|
||||
// reintroduces the hardcoded path that velocity-qa VM dogfood
|
||||
// exposed.
|
||||
it("no daemon src file constructs the plugins path via homedir() literal", () => {
|
||||
const daemonSrcDir = resolve(__dirname, "..", "src");
|
||||
|
||||
Reference in new issue
Block a user