mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-28 05:12:33 +00:00
+16




![github-actions[bot] <github-actions[bot]@users.noreply.github.com>](/assets/img/avatar_default.png)




Mega Mind
GitHub
YellowSnnowmann
Steven Enamakel
github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Cyrus Gray
Horst1993
Cursor
James Gentes
Sam
Sami Rusani
oxoxDev
Muhammad Ismail
Claude Fable 5
nb213
binyangzhu000-sudo
Steven Enamakel
CodeGhost21
sanil-23
M3gA-Mind
oxoxDev
mysma-9403
mwakidenis
NgoQuocViet2001
viet.ngo
Maciej Myszkiewicz
2e5b5e7b23
Co-authored-by: YellowSnnowmann <167776381+YellowSnnowmann@users.noreply.github.com> Co-authored-by: Steven Enamakel <31011319+senamakel@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Cyrus Gray <144336577+graycyrus@users.noreply.github.com> Co-authored-by: Horst1993 <horst.w@gmicloud.ai> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: James Gentes <jgentes@users.noreply.github.com> Co-authored-by: Sam <samrusani@users.noreply.github.com> Co-authored-by: Sami Rusani <14844597+samrusani@users.noreply.github.com> Co-authored-by: oxoxDev <164490987+oxoxDev@users.noreply.github.com> Co-authored-by: Muhammad Ismail <78064250+myi1@users.noreply.github.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Co-authored-by: nb213 <binyangzhu000@gmail.com> Co-authored-by: binyangzhu000-sudo <224954946+binyangzhu000-sudo@users.noreply.github.com> Co-authored-by: Steven Enamakel <enamakel@tinyhumans.ai> Co-authored-by: CodeGhost21 <164498022+CodeGhost21@users.noreply.github.com> Co-authored-by: sanil-23 <sanil@tinyhumans.ai> Co-authored-by: M3gA-Mind <elvin@mahadao.com> Co-authored-by: oxoxDev <oxoxdev@users.noreply.github.com> Co-authored-by: mysma-9403 <64923976+mysma-9403@users.noreply.github.com> Co-authored-by: mwakidenis <mwakidenice@gmail.com> Co-authored-by: NgoQuocViet2001 <123613986+NgoQuocViet2001@users.noreply.github.com> Co-authored-by: viet.ngo <viet.ngo@sotatek.com> Co-authored-by: Maciej Myszkiewicz <mmyszkiewicz@bwcoders.com>
192 lines
6.8 KiB
JavaScript
192 lines
6.8 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import { execFileSync } from 'node:child_process';
|
|
import { readFileSync } from 'node:fs';
|
|
import { dirname, resolve } from 'node:path';
|
|
import { test } from 'node:test';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
import {
|
|
diffForwarding,
|
|
INTENTIONALLY_NOT_FORWARDED,
|
|
parseCoreDefaultFeatures,
|
|
parseShellForwardedFeatures,
|
|
stripComments,
|
|
} from '../lib/feature-forwarding.mjs';
|
|
|
|
const REPO_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '../..');
|
|
const CHECKER = resolve(REPO_ROOT, 'scripts/ci/check-feature-forwarding.mjs');
|
|
|
|
// ── parsing ────────────────────────────────────────────────────────────────
|
|
|
|
test('parses the core default gate list', () => {
|
|
const toml = `
|
|
[features]
|
|
default = ["tokenjuice-treesitter", "voice", "media"]
|
|
voice = ["dep:hound"]
|
|
`;
|
|
assert.deepEqual(parseCoreDefaultFeatures(toml), ['tokenjuice-treesitter', 'voice', 'media']);
|
|
});
|
|
|
|
test('parses a multi-line default gate list', () => {
|
|
const toml = `
|
|
[features]
|
|
default = [
|
|
"voice",
|
|
"media",
|
|
]
|
|
`;
|
|
assert.deepEqual(parseCoreDefaultFeatures(toml), ['voice', 'media']);
|
|
});
|
|
|
|
test('ignores a default key belonging to another table', () => {
|
|
const toml = `
|
|
[some-other-table]
|
|
default = ["not-a-gate"]
|
|
|
|
[features]
|
|
default = ["voice"]
|
|
`;
|
|
assert.deepEqual(parseCoreDefaultFeatures(toml), ['voice']);
|
|
});
|
|
|
|
test('parses the shell forwarded list across multiple lines', () => {
|
|
const toml = `
|
|
openhuman_core = { path = "../..", package = "openhuman", default-features = false, features = [
|
|
"media",
|
|
"voice",
|
|
] }
|
|
`;
|
|
assert.deepEqual(parseShellForwardedFeatures(toml), {
|
|
defaultFeatures: false,
|
|
features: ['media', 'voice'],
|
|
});
|
|
});
|
|
|
|
test('detects when the shell inherits defaults instead of forwarding', () => {
|
|
const toml = 'openhuman_core = { path = "../..", package = "openhuman" }\n';
|
|
assert.deepEqual(parseShellForwardedFeatures(toml), { defaultFeatures: true, features: [] });
|
|
});
|
|
|
|
test('comment stripping does not truncate on a # inside a quoted value', () => {
|
|
const stripped = stripComments('a = "issue #4901" # trailing comment\n');
|
|
assert.match(stripped, /issue #4901/);
|
|
assert.doesNotMatch(stripped, /trailing comment/);
|
|
});
|
|
|
|
test('a commented-out gate does not count as forwarded', () => {
|
|
const toml = `
|
|
openhuman_core = { path = "../..", package = "openhuman", default-features = false, features = [
|
|
# "voice",
|
|
"media",
|
|
] }
|
|
`;
|
|
assert.deepEqual(parseShellForwardedFeatures(toml).features, ['media']);
|
|
});
|
|
|
|
// ── drift detection ────────────────────────────────────────────────────────
|
|
|
|
test('passes when every default gate is forwarded', () => {
|
|
const result = diffForwarding({
|
|
coreDefaults: ['voice', 'media'],
|
|
shell: { defaultFeatures: false, features: ['media', 'voice'] },
|
|
});
|
|
assert.equal(result.ok, true);
|
|
assert.deepEqual(result.missing, []);
|
|
});
|
|
|
|
test('reproduces #4901: a dropped voice gate is reported missing', () => {
|
|
const result = diffForwarding({
|
|
coreDefaults: ['tokenjuice-treesitter', 'voice', 'media'],
|
|
shell: { defaultFeatures: false, features: ['media', 'tokenjuice-treesitter'] },
|
|
});
|
|
assert.equal(result.ok, false);
|
|
assert.deepEqual(result.missing, ['voice']);
|
|
});
|
|
|
|
test('reproduces #4918: a dropped tokenjuice-treesitter gate is reported missing', () => {
|
|
const result = diffForwarding({
|
|
coreDefaults: ['tokenjuice-treesitter', 'voice', 'media'],
|
|
shell: { defaultFeatures: false, features: ['media', 'voice'] },
|
|
});
|
|
assert.equal(result.ok, false);
|
|
assert.deepEqual(result.missing, ['tokenjuice-treesitter']);
|
|
});
|
|
|
|
test('a brand new default gate is covered automatically, with no per-gate wiring', () => {
|
|
const result = diffForwarding({
|
|
coreDefaults: ['voice', 'media', 'some-future-gate'],
|
|
shell: { defaultFeatures: false, features: ['voice', 'media'] },
|
|
});
|
|
assert.equal(result.ok, false);
|
|
assert.deepEqual(result.missing, ['some-future-gate']);
|
|
});
|
|
|
|
test('an allow-listed gate passes and is reported as intentional', () => {
|
|
const result = diffForwarding({
|
|
coreDefaults: ['voice', 'heavy-gate'],
|
|
shell: { defaultFeatures: false, features: ['voice'] },
|
|
allowlist: { 'heavy-gate': 'Adds 400MB of models to the bundle.' },
|
|
});
|
|
assert.equal(result.ok, true);
|
|
assert.deepEqual(result.allowed, ['heavy-gate']);
|
|
assert.deepEqual(result.missing, []);
|
|
});
|
|
|
|
test('an allow-list entry for a gate that IS forwarded is flagged as stale', () => {
|
|
const result = diffForwarding({
|
|
coreDefaults: ['voice'],
|
|
shell: { defaultFeatures: false, features: ['voice'] },
|
|
allowlist: { voice: 'stale entry' },
|
|
});
|
|
assert.equal(result.ok, false);
|
|
assert.deepEqual(result.stale, ['voice']);
|
|
});
|
|
|
|
test('inheriting defaults needs no forwarding', () => {
|
|
const result = diffForwarding({
|
|
coreDefaults: ['voice'],
|
|
shell: { defaultFeatures: true, features: [] },
|
|
});
|
|
assert.equal(result.ok, true);
|
|
});
|
|
|
|
test('a missing dependency fails rather than passing vacuously', () => {
|
|
const result = diffForwarding({ coreDefaults: ['voice'], shell: null });
|
|
assert.equal(result.ok, false);
|
|
assert.equal(result.reason, 'dependency-not-found');
|
|
});
|
|
|
|
// ── the real manifests + CLI ───────────────────────────────────────────────
|
|
|
|
test('the checked-in manifests pass the guard', () => {
|
|
const out = execFileSync('node', [CHECKER], { encoding: 'utf8' });
|
|
assert.match(out, /every default-ON core gate is forwarded/);
|
|
});
|
|
|
|
test('--help exits 0', () => {
|
|
const out = execFileSync('node', [CHECKER, '--help'], { encoding: 'utf8' });
|
|
assert.match(out, /Usage:/);
|
|
});
|
|
|
|
test('the real shell manifest forwards every real core default', () => {
|
|
const coreDefaults = parseCoreDefaultFeatures(
|
|
readFileSync(resolve(REPO_ROOT, 'Cargo.toml'), 'utf8')
|
|
);
|
|
const shell = parseShellForwardedFeatures(
|
|
readFileSync(resolve(REPO_ROOT, 'app/src-tauri/Cargo.toml'), 'utf8')
|
|
);
|
|
// Guards the guard: if the parser silently returned nothing, the assertions
|
|
// below would pass against empty input and prove nothing.
|
|
assert.ok(coreDefaults.length > 0, 'expected to parse at least one core default gate');
|
|
assert.equal(shell.defaultFeatures, false, 'shell is expected to set default-features = false');
|
|
for (const gate of coreDefaults) {
|
|
// Gates the shell intentionally does not forward (e.g. `tui` — a terminal
|
|
// subcommand the desktop app never runs) are exempt, matching the checker.
|
|
if (INTENTIONALLY_NOT_FORWARDED[gate]) continue;
|
|
assert.ok(
|
|
shell.features.includes(gate),
|
|
`core default gate not forwarded to the shell: ${gate}`
|
|
);
|
|
}
|
|
});
|