Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

substituteTree(<configRoot>) rewrites the engine's own IDENTITY_PLACEHOLDERS table, and the Doctor fixCmd for #1813 is the command that does it

Open DRAZY opened this issue 3 months ago • 1 comments

Follow-up to #1828 (payload guard) and #1813 (the new identity-placeholders probe). Both fixes are correct as far as they go. This is the gap between them.

Summary

The #1828 guard stops substituteTree from walking into skills/LifeOS/install/. It does not stop it from walking into skills/LifeOS/Tools/, where InstallEngine.ts holds the literal placeholder strings as source data:

const IDENTITY_PLACEHOLDERS = [
  "{{DA_NAME}}", "{{DA_FULL_NAME}}", "{{PRINCIPAL_NAME}}", "{{PRINCIPAL_FULL_NAME}}",
  "{{PRIMARY_VOICE_ID}}", "{{SECONDARY_VOICE_ID}}", "{{LIFEOS_VERSION}}",
] as const;

.ts is in TEMPLATE_EXTENSIONS, so running the documented substituteTree(<configRoot>, vars) rewrites that array in place. With a DA named Aria and a principal named Sam, it becomes:

const IDENTITY_PLACEHOLDERS = [
  "Aria", "Aria", "Sam", "Sam",
  "<primary-voice-id>", "<secondary-voice-id>", "7.40.4",
] as const;

The engine now searches for the principal's rendered name as though it were an unrendered placeholder. Workflows/Setup.md is corrupted the same way, since it is prose about the tokens.

Why this matters more in 7.40.4 than before

Two documented callers now tell a user to run exactly this command.

  1. Setup.md step 9(d): "run the substitution pass the step-4 pass could not reach, substituteTree(<configRoot>, vars) over the deployed tree, then checkSurvivingPlaceholders(<configRoot>) and require passed: true."
  2. The new Doctor probe's own fixCmd, shipped in 7.40.4 for #1813:
fixCmd: 'bun -e \'import {substituteTree} from "<configRoot>/skills/LifeOS/Tools/InstallEngine.ts"; ...\' — re-run Setup.md step 9d substitution',

So the remediation offered for a failing identity-placeholders probe is the command that corrupts the table the probe depends on.

The resulting failure loop

After corruption, checkSurvivingPlaceholders searches model-facing surfaces for the literal strings Sam and Aria. Those appear everywhere by design, because substitution just put them there. The probe therefore reports a large false failure:

Aria x2  <configRoot>/settings.json
Sam x1   <configRoot>/agents/GrokResearcher.md
Aria x6  <configRoot>/agents/Forge.md
...

A user reading that failure follows fixCmd, re-runs substituteTree, and the state does not improve. The probe stays red, and the suggested fix cannot clear it.

Secondary: the guard is asymmetric

entry.name === "install" appears exactly once in InstallEngine.ts, in substituteTree's walker at line 458. checkSurvivingPlaceholders has no equivalent, so a literal reading of Setup 9(d), checkSurvivingPlaceholders(<configRoot>) requiring passed: true, can never pass on a correctly substituted install. It reports the payload's own generic templates as survivors.

gh api "repos/danielmiessler/LifeOS/contents/LifeOS/Tools/InstallEngine.ts?ref=v7.40.4" \
  --jq '.content' | base64 -d | grep -c 'entry.name === "install"'
# => 1

The Doctor probe sidesteps this correctly by passing seven narrow model-facing roots instead of configRoot, and its comment explains why. Setup.md still documents the whole-tree call.

Suggested fix

  1. Exclude the engine's own source from substitution. Skipping skills/LifeOS/ entirely (not just skills/LifeOS/install/) is the smallest change and matches intent: the installer must stay generic in every part, not only its redistribution copy.
  2. Give checkSurvivingPlaceholders the same skip as substituteTree, so the two walkers agree. The docstring already asserts they share a traversal, which stopped being true when the #1828 guard landed on one side.
  3. Update Setup 9(d) to document the narrow-root form the Doctor probe uses, rather than a whole-configRoot call that cannot pass.

Reproduction

# from a working install, run the documented step 9(d) call, then:
grep -A3 "const IDENTITY_PLACEHOLDERS" <configRoot>/skills/LifeOS/Tools/InstallEngine.ts
# expected: the array now holds rendered values instead of {{TOKEN}} strings

Recovery is a file copy from the pristine payload, which the #1828 guard keeps clean:

cp <configRoot>/skills/LifeOS/install/skills/LifeOS/Tools/InstallEngine.ts \
   <configRoot>/skills/LifeOS/Tools/InstallEngine.ts
cp <configRoot>/skills/LifeOS/install/skills/LifeOS/Workflows/Setup.md \
   <configRoot>/skills/LifeOS/Workflows/Setup.md

Environment

macOS 26.6.1, Claude Code harness, configRoot ~/.claude, upgraded 7.28.3 to 7.40.4. Both files verified byte-identical to the pristine payload copies after recovery.

DRAZY avatar Aug 15 '26 05:08 DRAZY

Fixed in source: both walkers now share one skip covering the installer's own Tools and Workflows (the engine can no longer rewrite its own placeholder table), checkSurvivingPlaceholders got the same guard so the pair agree again, and Doctor's fixCmd points at the narrow-roots invocation its own probe uses instead of the command that corrupted the table (skills/LifeOS/Tools/InstallEngine.ts, LIFEOS/TOOLS/Doctor.ts). The remediation-that-breaks-the-probe loop you traced was the sharpest finding in this cluster. Thanks.

danielmiessler avatar Aug 17 '26 23:08 danielmiessler