Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
40fe7f2
Port hermes-provider-map.ts to .t27 (isHermesSupportedProviderType, g…
Oct 5, 2026
29bdc21
docs: the coordination entry this branch needs to land
claude Oct 5, 2026
d82e22a
Port gHashTag/trinity:src/brain/fusiform_gyrus.zig to specs/port/trin…
Oct 5, 2026
d5bdc33
docs: the coordination entry this branch needs to land
claude Oct 6, 2026
86eb3ac
docs: the coordination entry this branch needs to land
claude Oct 12, 2026
1cd82ef
docs: the coordination entry this branch needs to land
claude Oct 12, 2026
367ddeb
spec(port): port specs/port/trinity/src/bsd/verify_lmfdb.t27 (Closes …
dmitrii-f-t27 Oct 17, 2026
d34a1c4
merge master: the fill/matmul twin groups are in the duplicate-bodies…
dmitrii-f-t27 Oct 17, 2026
e632042
spec(port): port specs/port/trinity/src/cli/tri_record.t27 (Closes #9…
dmitrii-f-t27 Oct 17, 2026
3e1d26a
spec(port): port specs/port/trinity/src/vibeec/create_test_mistral.t2…
dmitrii-f-t27 Oct 17, 2026
285b6bd
spec(port): port specs/port/trinity/src/vibeec/soul_collector.t27 (Cl…
dmitrii-f-t27 Oct 17, 2026
e35a82c
spec(port): port specs/port/trinity/src/registry/export_cli.t27 (Clos…
dmitrii-f-t27 Oct 17, 2026
882e5f8
spec(port): port specs/port/trinity/src/phi-engine/quantum/qutritizer…
dmitrii-f-t27 Oct 17, 2026
ca0d712
spec(port): port specs/port/trios-railway/bin/seed-agent/src/main.t27…
dmitrii-f-t27 Oct 17, 2026
ce83b82
spec(port): port specs/port/trinity/src/tri/compat/managed_list.t27 (…
dmitrii-f-t27 Oct 17, 2026
7b388bb
spec(port): port specs/port/trinity/src/tri/faculty_types.t27 (Closes…
dmitrii-f-t27 Oct 17, 2026
e11faf5
fix(ci): master green -- rust_convert CSE hoist, mesh crypto mismatch…
gHashTag Oct 18, 2026
108f6b8
Merge PR #6399
gHashTag Oct 18, 2026
f10ae42
Merge PR #6885
gHashTag Oct 18, 2026
0c11e5d
Merge PR #10119
gHashTag Oct 18, 2026
a62d1d7
Merge PR #10120
gHashTag Oct 18, 2026
65e9f43
Merge PR #10121
gHashTag Oct 18, 2026
d9dd4c7
Merge PR #10129
gHashTag Oct 18, 2026
378fe49
Merge PR #10131
gHashTag Oct 18, 2026
ac4bd49
Merge PR #10132
gHashTag Oct 18, 2026
feef18a
Merge PR #10133
gHashTag Oct 18, 2026
f986666
Merge PR #10141
gHashTag Oct 18, 2026
fb77496
Merge PR #10142
gHashTag Oct 18, 2026
1de17df
spec(port): name the hermes provider-map struct apart from OC-01's He…
gHashTag Oct 18, 2026
5943cf1
Merge remote-tracking branch 'origin/master' into sweep/land-11-ports
gHashTag Oct 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# NOW -- Port gHashTag/BrowserOS:trios/agent-server/apps/server/src/lib/agents/hermes/hermes-provider-map.ts (TypeScript, 2 functions) to specs/port/browseros/trios/agent-server/apps/server/src/lib/agents/hermes/hermes-provider-map.t27 (published 2026-10-05)

## A bee's work on #6381, published from `queen-6381` (Closes #6381)

- The branch changes 1 file(s): `specs/port/browseros/trios/agent-server/apps/server/src/lib/agents/hermes/hermes-provider-map.t27`.
- `git diff --stat origin/master...queen-6381` reads: 1 file changed, 205 insertions(+)
- This entry is written by the publisher, not by the bee. A pull request must
add exactly one `docs/now/` entry and a bee has no way to know that: its brief
names a boundary file and acceptance criteria, and `docs/now/` is neither.
- What this entry does NOT establish: that the work is correct. The gates on the
pull request judge that, and they are the same gates every other change meets.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# NOW -- Port gHashTag/trinity:src/brain/fusiform_gyrus.zig (Zig, 4 functions) to specs/port/trinity/src/brain/fusiform_gyrus.t27 (published 2026-10-06)

## A bee's work on #6383, published from `queen-6383` (Closes #6383)

- The branch changes 1 file(s): `specs/port/trinity/src/brain/fusiform_gyrus.t27`.
- `git diff --stat origin/master...queen-6383` reads: 1 file changed, 115 insertions(+)
- This entry is written by the publisher, not by the bee. A pull request must
add exactly one `docs/now/` entry and a bee has no way to know that: its brief
names a boundary file and acceptance criteria, and `docs/now/` is neither.
- What this entry does NOT establish: that the work is correct. The gates on the
pull request judge that, and they are the same gates every other change meets.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# NOW -- Port gHashTag/BrowserOS:trios/agent-server/apps/server/src/lib/agents/hermes/hermes-provider-map.ts (TypeScript, 2 functions) to specs/port/browseros/trios/agent-server/apps/server/src/lib/agents/hermes/hermes-provider-map.t27 (published 2026-10-12)

## A bee's work on #6381, published from `queen-6381` (Closes #6381)

- The branch changes 2 file(s): `docs/now/2026-10-05-published-port-ghashtag-browseros-trios-agent-server-apps-server-src-l.md`, `specs/port/browseros/trios/agent-server/apps/server/src/lib/agents/hermes/hermes-provider-map.t27`.
- `git diff --stat origin/master...queen-6381` reads: 2 files changed, 216 insertions(+)
- This entry is written by the publisher, not by the bee. A pull request must
add exactly one `docs/now/` entry and a bee has no way to know that: its brief
names a boundary file and acceptance criteria, and `docs/now/` is neither.
- What this entry does NOT establish: that the work is correct. The gates on the
pull request judge that, and they are the same gates every other change meets.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# NOW -- Port gHashTag/trinity:src/brain/fusiform_gyrus.zig (Zig, 4 functions) to specs/port/trinity/src/brain/fusiform_gyrus.t27 (published 2026-10-12)

## A bee's work on #6383, published from `queen-6383` (Closes #6383)

- The branch changes 2 file(s): `docs/now/2026-10-06-published-port-ghashtag-trinity-src-brain-fusiform-gyrus-zig-zig-4-fun.md`, `specs/port/trinity/src/brain/fusiform_gyrus.t27`.
- `git diff --stat origin/master...queen-6383` reads: 2 files changed, 126 insertions(+)
- This entry is written by the publisher, not by the bee. A pull request must
add exactly one `docs/now/` entry and a bee has no way to know that: its brief
names a boundary file and acceptance criteria, and `docs/now/` is neither.
- What this entry does NOT establish: that the work is correct. The gates on the
pull request judge that, and they are the same gates every other change meets.
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
// Port of trios/agent-server/apps/server/src/lib/agents/hermes/hermes-provider-map.ts
// (gHashTag/BrowserOS at 879799a8bfb2, 86 lines of hand-written TypeScript).
//
// The original is the decision table from BrowserOS LLM provider types (the
// values that live in LlmProviderConfig.type on the extension side) to Hermes
// runtime configuration: which provider key to write into `model.provider` in
// config.yaml, which env var carries the API key, and whether an explicit
// baseUrl is required. The whole file is a decision - one fixed table, two
// lookups - so both exported functions are ported with real bodies; there is
// no plumbing and no function body is left undefined.
//
// Three shape changes the language forces, documented rather than faked:
// - The original imports HERMES_SUPPORTED_BROWSEROS_PROVIDER_TYPES from
// @browseros/shared/constants/hermes. That set is exactly the keys of the
// original's HERMES_PROVIDER_MAP (the original type-checks that every
// supported type has a mapping), so the four values are inlined here as
// the decision they carry.
// - The original's optional `defaultBaseUrl?` field becomes hasDefaultBaseUrl
// plus defaultBaseUrl ("" when absent). In the original the field is only
// read when hermesProvider is "custom" and the caller passed no baseUrl.
// - The original's `HermesProviderMapping | undefined` return becomes a
// verdict struct: ok == false is the original's `undefined`, i.e. agent
// creation rejects the type and no mapping exists for it.

// Named apart from trios-openclaw OC-01 HermesProviderMapping: the same table ported from
// another tree with a different field set; one definition per type name (#2774).
pub struct HermesProviderMapEntry {
// Hermes' own provider key, written into `model.provider` in config.yaml.
hermesProvider: []const u8,
// Env var Hermes reads the API key from.
envVarName: []const u8,
// True when the harness must require an explicit baseUrl from input.
requiresBaseUrl: bool,
// True when the original mapping carries a defaultBaseUrl.
hasDefaultBaseUrl: bool,
defaultBaseUrl: []const u8,
}

pub struct HermesMappingResult {
// False is the original's `undefined`: unsupported provider type.
ok: bool,
mapping: HermesProviderMapEntry,
}

// The original's HERMES_SUPPORTED_BROWSEROS_PROVIDER_TYPES.includes(providerType):
// a case-sensitive membership test over the shared constant, whose values are
// exactly the keys of the original's HERMES_PROVIDER_MAP. Inlined here as
// literal comparisons.
pub fn isHermesSupportedProviderType(providerType: []const u8) -> bool {
if (providerType == "anthropic") {
return true;
}
if (providerType == "openai") {
return true;
}
if (providerType == "openrouter") {
return true;
}
if (providerType == "openai-compatible") {
return true;
}
return false;
}

// The zero mapping, standing in for an absent table entry.
fn hermes_mapping_empty() -> HermesProviderMapEntry {
return HermesProviderMapEntry { hermesProvider: "", envVarName: "", requiresBaseUrl: false, hasDefaultBaseUrl: false, defaultBaseUrl: "" };
}

// HERMES_PROVIDER_MAP.anthropic: pass-through, no base URL involved.
fn hermes_mapping_anthropic() -> HermesProviderMapEntry {
return HermesProviderMapEntry { hermesProvider: "anthropic", envVarName: "ANTHROPIC_API_KEY", requiresBaseUrl: false, hasDefaultBaseUrl: false, defaultBaseUrl: "" };
}

// HERMES_PROVIDER_MAP.openai: the original rewrites this to Hermes' custom
// provider shape and carries the OpenAI base URL as the default.
fn hermes_mapping_openai() -> HermesProviderMapEntry {
return HermesProviderMapEntry { hermesProvider: "custom", envVarName: "OPENAI_API_KEY", requiresBaseUrl: false, hasDefaultBaseUrl: true, defaultBaseUrl: "https://api.openai.com/v1" };
}

// HERMES_PROVIDER_MAP.openrouter: pass-through, no base URL involved.
fn hermes_mapping_openrouter() -> HermesProviderMapEntry {
return HermesProviderMapEntry { hermesProvider: "openrouter", envVarName: "OPENROUTER_API_KEY", requiresBaseUrl: false, hasDefaultBaseUrl: false, defaultBaseUrl: "" };
}

// HERMES_PROVIDER_MAP["openai-compatible"]: custom provider shape, and the
// caller must supply the base URL explicitly.
fn hermes_mapping_openai_compatible() -> HermesProviderMapEntry {
return HermesProviderMapEntry { hermesProvider: "custom", envVarName: "OPENAI_API_KEY", requiresBaseUrl: true, hasDefaultBaseUrl: false, defaultBaseUrl: "" };
}

// The original's getHermesProviderMapping: the table entry for a supported
// provider type, `undefined` when it is not supported. ok == false carries
// the `undefined`; the zero mapping it arrives with must not be read as a
// real entry.
pub fn getHermesProviderMapping(providerType: []const u8) -> HermesMappingResult {
if (!isHermesSupportedProviderType(providerType)) {
return HermesMappingResult { ok: false, mapping: hermes_mapping_empty() };
}
if (providerType == "anthropic") {
return HermesMappingResult { ok: true, mapping: hermes_mapping_anthropic() };
}
if (providerType == "openai") {
return HermesMappingResult { ok: true, mapping: hermes_mapping_openai() };
}
if (providerType == "openrouter") {
return HermesMappingResult { ok: true, mapping: hermes_mapping_openrouter() };
}
// Only "openai-compatible" is left: the guard above rejects everything
// else, so this fall-through mirrors the original's table index.
return HermesMappingResult { ok: true, mapping: hermes_mapping_openai_compatible() };
}

// The four supported BrowserOS provider types: exactly the shared constant
// the original imports, i.e. the keys of the original's table.
test is_supported_provider_types {
assert(isHermesSupportedProviderType("anthropic"));
assert(isHermesSupportedProviderType("openai"));
assert(isHermesSupportedProviderType("openrouter"));
assert(isHermesSupportedProviderType("openai-compatible"));
}

// The original's check is case-sensitive (a plain string includes over the
// constant) and whitespace-significant; anything else yields no mapping.
test rejects_unsupported_provider_types {
assert(!isHermesSupportedProviderType("gemini"));
assert(!isHermesSupportedProviderType("Anthropic"));
assert(!isHermesSupportedProviderType("openai_compatible"));
assert(!isHermesSupportedProviderType(" openai"));
assert(!isHermesSupportedProviderType(""));
}

// Each entry of the original's HERMES_PROVIDER_MAP, field by field.
test mapping_entries {
const anthropic = hermes_mapping_anthropic();
assert(anthropic.hermesProvider == "anthropic");
assert(anthropic.envVarName == "ANTHROPIC_API_KEY");
assert(!anthropic.requiresBaseUrl);
assert(!anthropic.hasDefaultBaseUrl);

const openai = hermes_mapping_openai();
assert(openai.hermesProvider == "custom");
assert(openai.envVarName == "OPENAI_API_KEY");
assert(!openai.requiresBaseUrl);
assert(openai.hasDefaultBaseUrl);
assert(openai.defaultBaseUrl == "https://api.openai.com/v1");

const openrouter = hermes_mapping_openrouter();
assert(openrouter.hermesProvider == "openrouter");
assert(openrouter.envVarName == "OPENROUTER_API_KEY");
assert(!openrouter.requiresBaseUrl);
assert(!openrouter.hasDefaultBaseUrl);

const compatible = hermes_mapping_openai_compatible();
assert(compatible.hermesProvider == "custom");
assert(compatible.envVarName == "OPENAI_API_KEY");
assert(compatible.requiresBaseUrl);
assert(!compatible.hasDefaultBaseUrl);
}

// The zero mapping that stands in for an absent entry: empty strings, no
// default base URL.
test mapping_empty {
const m = hermes_mapping_empty();
assert(m.hermesProvider == "");
assert(m.envVarName == "");
assert(!m.requiresBaseUrl);
assert(!m.hasDefaultBaseUrl);
assert(m.defaultBaseUrl == "");
}

// The public lookup for supported types: ok with the table's entry.
test get_mapping_supported {
const a = getHermesProviderMapping("anthropic");
assert(a.ok);
assert(a.mapping.hermesProvider == "anthropic");
assert(a.mapping.envVarName == "ANTHROPIC_API_KEY");
assert(!a.mapping.requiresBaseUrl);

const o = getHermesProviderMapping("openai");
assert(o.ok);
assert(o.mapping.hermesProvider == "custom");
assert(o.mapping.envVarName == "OPENAI_API_KEY");
assert(o.mapping.hasDefaultBaseUrl);
assert(o.mapping.defaultBaseUrl == "https://api.openai.com/v1");

const r = getHermesProviderMapping("openrouter");
assert(r.ok);
assert(r.mapping.hermesProvider == "openrouter");
assert(r.mapping.envVarName == "OPENROUTER_API_KEY");

const c = getHermesProviderMapping("openai-compatible");
assert(c.ok);
assert(c.mapping.hermesProvider == "custom");
assert(c.mapping.requiresBaseUrl);
assert(!c.mapping.hasDefaultBaseUrl);
}

// Unsupported types get the original's `undefined`: ok == false.
test get_mapping_unsupported {
const g = getHermesProviderMapping("gemini");
assert(!g.ok);
const blank = getHermesProviderMapping("");
assert(!blank.ok);
const cased = getHermesProviderMapping("Anthropic");
assert(!cased.ok);
}
115 changes: 115 additions & 0 deletions specs/port/trinity/src/brain/fusiform_gyrus.t27
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
module port::trinity::src::brain::fusiform_gyrus;

pub fn encodeF32ToGF16(v: f32) -> u16 {
if (v == 0.0) {
return 0;
}

// Check for infinity
if (v > 1.0e38) {
return if (v < 0) 0xFFFF else 0x7FFF;
}
if (v < -1.0e38) {
return 0xFFFF;
}

const sign: u16 = if (v < 0) 1 << 15 else 0;
const abs_v = if (v < 0) -v else v;

var exp: i16 = 0;
var mant_f: f64 = abs_v;
while (mant_f >= 1.0 and exp < 31) : (exp += 1) {
mant_f /= 2.0;
}
while (mant_f < 0.5 and exp > -32) : (exp -= 1) {
mant_f *= 2.0;
}

const temp_exp: i32 = exp + 31;
const clamped_temp: i32 = if (temp_exp > 63) 63 else if (temp_exp < 0) 0 else temp_exp;
const exp_u6: u16 = clamped_temp as u16;
const clamped_exp: u16 = if (exp_u6 > 63) 63 else exp_u6;
const mant_u9: u16 = @intFromFloat((mant_f - 0.5) * 512.0);
const clamped_mant: u16 = if (mant_u9 > 511) 511 else mant_u9;

return sign | (clamped_exp << 9) | (clamped_mant & 0x1FF);
}

pub fn decodeGF16ToF32(raw: u16) -> f32 {
if (raw == 0) {
return 0.0;
}
if (raw == 0x8000) {
return -0.0;
}

const sign: f32 = if ((raw >> 15) & 1 == 1) -1.0 else 1.0;
const exp: u16 = (raw >> 9) & 0x3F;
const mant: u16 = raw & 0x1FF;

if (exp == 0x3F) {
return if (sign < 0) -999999.0 else 999999.0;
}

const exp_f: f32 = @as(f32, exp) - 31.0;
const mant_f: f32 = 0.5 + @as(f32, mant) * 0.001953125;

// Simplified power calculation for 2^exp_f
var power: f32 = 1.0;
var abs_exp: usize = if (exp_f > 10.0) 10 else if (exp_f > 5.0) 5 else if (exp_f > 0.0) 2 else if (exp_f > -5.0) 5 else 8;
for (0..abs_exp) |_| {
if (exp_f > 0.0) {
power *= 2.0;
} else {
power *= 0.5;
}
}

return sign * mant_f * power;
}

pub fn encodeBF16(v: f32) -> u16 {
const bits: u32 = @bitCast(v);
return @intCast(bits >> 16);
}

pub fn decodeBF16(raw: u16) -> f32 {
const bits: u32 = @as(u32, raw) << 16;
return @bitCast(bits);
}

test encodeF32ToGF16_zero {
assert(encodeF32ToGF16(0.0) == 0);
}

test encodeF32ToGF16_positive {
assert(encodeF32ToGF16(1.0) == 0x4000);
}

test encodeF32ToGF16_negative {
assert(encodeF32ToGF16(-1.0) == 0xC000);
}

test decodeGF16ToF32_zero {
assert(decodeGF16ToF32(0) == 0.0);
}

test decodeGF16ToF32_negative_zero {
assert(decodeGF16ToF32(0x8000) == -0.0);
}

test encodeBF16_simple {
assert(encodeBF16(1.0) == 0x3F80);
}

test decodeBF16_simple {
assert(decodeBF16(0x3F80) == 1.0);
}

test encode_decode_GF16_roundtrip {
const original: f32 = 3.14;
const encoded = encodeF32ToGF16(original);
const decoded = decodeGF16ToF32(encoded);
const err = @abs(original - decoded) / original;
assert(err < 0.01);
}
Loading
Loading