Skip to content

Commit 85f2b46

Browse files
onthebigtreeclaude
andcommitted
fix: hash hostname in fingerprint, use relative validation paths, remove dead code
Three independent improvements: 1. Hash hostname before storing in envFingerprint (envFingerprint.js) os.hostname() was stored verbatim in every Capsule and EvolutionEvent, which are published to the public Hub. sanitize.js does not redact hostnames (no matching pattern), so strings like 'john-macbook-pro.local' leaked into the public feed. Replace with a 12-char SHA-256 prefix so the value still uniquely identifies the environment class without revealing the machine name. 2. Remove absolute paths from buildValidationCmd (assetStore.js) The previous implementation resolved modules via path.resolve(__dirname) at call time, embedding the current machine's absolute path (e.g. /Users/xxx/codespace/evolver/src/evolve) into Gene validation commands stored in genes.json. Two consequences: - sanitize.js redacts /Users/... in published capsules, corrupting the stored validation command for any consumer. - Moving the project directory breaks all previously stored Gene validation commands. runValidations() already executes with cwd=repoRoot, so switching to require('./src/evolve') style relative paths is correct and portable. 3. Remove appendCapsule dead code (assetStore.js, solidify.js) appendCapsule was exported and imported by solidify.js but never called (solidify uses upsertCapsule exclusively). It also lacked deduplication, so any accidental call would grow capsules.json unboundedly. Removed the function, its export, and the unused import in solidify.js. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
1 parent 203e5b8 commit 85f2b46

File tree

3 files changed

+7
-18
lines changed

3 files changed

+7
-18
lines changed

src/gep/assetStore.js

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,11 @@ function writeJsonAtomic(filePath, obj) {
2626
fs.renameSync(tmp, filePath);
2727
}
2828

29-
// Build a robust validation command that works regardless of CWD.
30-
// Resolves module paths relative to the skill root (skills/evolver/).
29+
// Build a validation command using repo-root-relative paths.
30+
// runValidations() executes with cwd=repoRoot, so require('./src/...')
31+
// resolves correctly without embedding machine-specific absolute paths.
3132
function buildValidationCmd(relModules) {
32-
const skillRoot = path.resolve(__dirname, '..', '..');
33-
const checks = relModules.map(m => {
34-
const abs = path.join(skillRoot, m).replace(/\\/g, '/');
35-
return `require('${abs}')`;
36-
});
33+
const checks = relModules.map(m => `require('./${m}')`);
3734
return `node -e "${checks.join('; ')}; console.log('ok')"`;
3835
}
3936

@@ -216,14 +213,6 @@ function upsertGene(geneObj) {
216213
writeJsonAtomic(genesPath(), { version: current.version || 1, genes });
217214
}
218215

219-
function appendCapsule(capsuleObj) {
220-
ensureSchemaFields(capsuleObj);
221-
const current = readJsonIfExists(capsulesPath(), getDefaultCapsules());
222-
const capsules = Array.isArray(current.capsules) ? current.capsules : [];
223-
capsules.push(capsuleObj);
224-
writeJsonAtomic(capsulesPath(), { version: current.version || 1, capsules });
225-
}
226-
227216
function upsertCapsule(capsuleObj) {
228217
if (!capsuleObj || capsuleObj.type !== 'Capsule' || !capsuleObj.id) return;
229218
ensureSchemaFields(capsuleObj);
@@ -263,7 +252,7 @@ module.exports = {
263252
loadGenes, loadCapsules, readAllEvents, getLastEventId,
264253
appendEventJsonl, appendCandidateJsonl, appendExternalCandidateJsonl,
265254
readRecentCandidates, readRecentExternalCandidates,
266-
upsertGene, appendCapsule, upsertCapsule,
255+
upsertGene, upsertCapsule,
267256
genesPath, capsulesPath, eventsPath, candidatesPath, externalCandidatesPath,
268257
ensureAssetFiles, buildValidationCmd,
269258
};

src/gep/envFingerprint.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function captureEnvFingerprint() {
2626
platform: process.platform,
2727
arch: process.arch,
2828
os_release: os.release(),
29-
hostname: os.hostname(),
29+
hostname: crypto.createHash('sha256').update(os.hostname()).digest('hex').slice(0, 12),
3030
evolver_version: pkgVersion,
3131
cwd: process.cwd(),
3232
container: isContainer(),

src/gep/solidify.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const fs = require('fs');
22
const path = require('path');
33
const { execSync } = require('child_process');
4-
const { loadGenes, upsertGene, appendEventJsonl, appendCapsule, upsertCapsule, getLastEventId } = require('./assetStore');
4+
const { loadGenes, upsertGene, appendEventJsonl, upsertCapsule, getLastEventId } = require('./assetStore');
55
const { computeSignalKey, memoryGraphPath } = require('./memoryGraph');
66
const { computeCapsuleSuccessStreak, isBlastRadiusSafe } = require('./a2a');
77
const { getRepoRoot, getMemoryDir, getEvolutionDir, getWorkspaceRoot } = require('./paths');

0 commit comments

Comments
 (0)