| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- import assert from 'node:assert/strict';
- import { readFileSync } from 'node:fs';
- import path from 'node:path';
- const baseline = JSON.parse(
- readFileSync('cloud/skills/container-provision-job/container-baseline-v1.json', 'utf8'),
- );
- const skill = readFileSync('cloud/skills/container-provision-job/SKILL.md', 'utf8');
- const provisioning = readFileSync('cloud/functions/fmode-provisioning.js', 'utf8');
- const onboarding = readFileSync('cloud/functions/fmode-provisioning.js', 'utf8');
- const planService = readFileSync('src/app/core/plan.service.ts', 'utf8');
- assert.equal(baseline.version, '1.1.0');
- assert.equal(baseline.runtime.image, 'fmode/agent-node:0.21.3');
- assert.equal(baseline.runtime.memoryLimit, '1536m');
- assert.equal(baseline.runtime.nanoCpus, 1_500_000_000);
- assert.equal(baseline.runtime.pidsLimit, 512);
- assert.equal(baseline.runtime.hermesHome, '/opt/data');
- assert.equal(baseline.reporting.heartbeatSeconds, 3600);
- assert.equal(baseline.reporting.jitterMaxSeconds, 900);
- assert.equal(baseline.reporting.appOfflineSeconds, 80 * 60);
- assert.equal(baseline.cleanup.inactiveSeconds, 3600);
- assert.equal(baseline.cleanup.uploadedFileGraceSeconds, 3600);
- assert.equal(baseline.cleanup.diskPressurePercent, 80);
- assert.equal(baseline.cleanup.requiresAppRegistration, true);
- assert.equal(baseline.cleanup.contentDigest, 'sha256');
- for (const skillPath of [baseline.directories.platformSkills, baseline.directories.customSkills]) {
- assert.ok(
- path.posix.relative(baseline.runtime.hermesHome, skillPath).startsWith('skills/'),
- `Hermes skill directory must be below HERMES_HOME/skills: ${skillPath}`,
- );
- }
- const script = readFileSync('cloud/skills/container-provision-job/provision.sh', 'utf8');
- assert.ok(skill.includes('provision.sh'), 'container skill must delegate to provision.sh');
- assert.ok(script.includes('--memory 1536m --cpus 1.5 --pids-limit 512'), 'provision.sh resources must match baseline');
- assert.ok(script.includes('"$IMAGE" gateway run'), 'containers must start the gateway explicitly');
- assert.ok(script.includes('--env-file "$ENV_FILE"'), 'docker env and .env must come from one container.env');
- assert.ok(script.includes('HERMES_HOME=/opt/data'), 'new containers must point Hermes at persistent skills');
- assert.ok(script.includes('/opt/hermes/.venv/bin/hermes skills list'), 'provisioning must inspect Hermes skills');
- assert.ok(script.includes('install -d -o 10000 -g 10000'), 'persistent task and skill directories must be writable by Hermes');
- assert.ok(script.includes('/opt/fmode-bundle/install.py'), 'platform containers must install the onboarding bundle');
- for (const key of baseline.channels.wecomEnv) assert.ok(script.includes(key), `wecom env must be supported: ${key}`);
- const runtimeInstall = script.match(/install -d -o 10000 -g 10000 -m 0755 ([\s\S]*?)\n "\$DOCKER"/)?.[1] || '';
- for (const parent of baseline.directories.writableRuntimeParents) {
- const relative = path.posix.relative(baseline.runtime.hermesHome, parent);
- assert.ok(relative && !relative.startsWith('..'), 'runtime parent must stay below HERMES_HOME');
- assert.ok(runtimeInstall.includes(`"$DST/${relative}"`), `runtime parent must be assigned to Hermes: ${parent}`);
- }
- const createBody = script.slice(script.indexOf('create() {'), script.indexOf('install_safe_gc() {'));
- assert.ok(createBody.indexOf('install_safe_gc') < createBody.indexOf('docker_create ||'),
- 'install cleanup before starting the gateway scheduler');
- assert.doesNotMatch(planService, /\b(?:\d+(?:\.\d+)?\s*(?:核|GiB|GB|g)\b|CPU\s*\d)/i,
- 'customer-facing plan copy must not expose infrastructure sizing');
- console.log('Container baseline v1.1.0 is internally consistent.');
|