Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

`detectHarness` reports a first-match guess as `confidence: "detected"` on multi-harness machines

Open mj-deving opened this issue 3 months ago • 1 comments

What LifeOS does here

skills/LifeOS/Tools/InstallEngine.ts exports detectHarness(home), which decides which agent harness is hosting a LifeOS install and therefore which config root and skills directory the setup writes into. skills/LifeOS/Tools/DetectEnv.ts is the thin CLI over it, and skills/LifeOS/Workflows/Setup.md step 1 branches on its output.

Current behavior

detectHarness walks a fixed candidate list — claude-code, opencode, hermes, cursor, openclaw — in three passes: config dir plus binary on PATH, config dir alone, binary alone. Each pass returns the first candidate that qualifies. Candidate order is therefore the tiebreaker whenever more than one harness qualifies in the same pass, and claude-code is first in the list.

The result of the first pass is labelled confidence: "detected". In the source, "detected" means "the harness binary was found on PATH" and is documented as fact, in contrast to "assumed". On a machine with two installed harnesses the label is accurate about the binary and wrong about the conclusion: the binary was found, but so was another one, and nothing established which harness is actually running the install.

detectEnv() calls detectHarness(home) with no override parameter, so a caller who knows the answer has no way to supply it.

Reproduction

Against v7.40.4, with a home containing both ~/.claude and ~/.config/opencode, and both claude and opencode on PATH:

mkdir -p h/.claude h/.config/opencode bin
for b in claude opencode; do printf '#!/bin/sh\necho %s\n' "$b" > bin/$b; chmod +x bin/$b; done
echo 'import { detectHarness } from "<checkout>/skills/LifeOS/Tools/InstallEngine.ts";
console.log(JSON.stringify(detectHarness("'$PWD'/h")));' > r.ts
PATH="$PWD/bin:$PATH" bun r.ts

Output:

{"name":"claude-code","configRoot":".../h/.claude","skillsDir":".../h/.claude/skills","confidence":"detected"}

The same output appears whether the install is driven from Claude Code or from OpenCode. An OpenCode user running the LifeOS setup gets a payload deployed into ~/.claude, reported as a detected fact rather than as an ambiguity to confirm.

Why the existing safeguard does not cover this

The function's own comment cites issue #1448 and the rule it implements: "Anything short of a binary match is reported as confidence assumed, never as fact." That rule addresses a different failure — a leftover config directory outranking a live install. It says nothing about two live installs, which is the case where order alone decides. Setup.md instructs the operator to confirm an assumed harness with the user; because this path reports detected, that confirmation step never triggers.

Suggested direction

Two changes. They are not interchangeable: (2) closes the failing path on its own, while (1) only helps if the caller is updated to pass the value.

  1. Accept an explicit harness from the caller: a --harness <name> flag on DetectEnv.ts, an override parameter on detectEnv(), and — the part that actually matters — Setup.md step 1 invoking it with the active harness. The harness running the setup knows its own identity, so this is the reliable signal; but adding the flag without changing the invocation leaves the failing path exactly as it is today.
  2. When more than one candidate qualifies in the same pass, do not return the first one as detected. Either downgrade to assumed and list the tied candidates so Setup.md's confirmation step fires, or add a distinct ambiguous confidence value.

Suggested acceptance tests: two qualifying candidates in the strongest pass must not produce confidence: "detected" for whichever happens to be first in the array; an explicitly supplied harness must win over detection; and the documented setup path must reach detection with that value supplied rather than relying on inference.

Affected versions

Present in v7.40.4, the current release at the time of writing. Not verified before that tag.

mj-deving avatar Aug 21 '26 20:08 mj-deving

Landed: when more than one harness qualifies, detection returns the first as "assumed" so the Setup confirm step fires, and LIFEOS_HARNESS overrides outright. Next release. Thanks.

danielmiessler avatar Sep 03 '26 23:09 danielmiessler