Skip to content

spec(port): port specs/port/trios/crates/trios-server/src/tools/trios_kg.t27 (Closes #9402) - #9867

Merged
gHashTag merged 1 commit into
gHashTag:masterfrom
dmitrii-f-t27:zcode-port-9402-server-kg
Oct 17, 2026
Merged

gHashTag merged 1 commit into
gHashTag:masterfrom
dmitrii-f-t27:zcode-port-9402-server-kg

Conversation

@dmitrii-f-t27

Copy link
Copy Markdown
Contributor

Summary

Port gHashTag/trios:crates/trios-server/src/tools/trios_kg.rs (at 8b229e9489ee, 148 lines) as specs/port/trios/crates/trios-server/src/tools/trios_kg.t27 — Roadmap Stage 6 (goal #4548), target t27c gen-rust. Closes #9402.

The original exposes Knowledge Graph operations over MCP with four tools behind a name dispatcher (R0 mock stub): kg_create_entity, kg_create_edge, kg_query and kg_traverse, with every mock id derived through a djb2-style hash stub.

Per the issue's rule ("Port the decision, not the plumbing"), all six listed functions are ported under their names as pure functions (no transports — the JSON reading and building are the callers' plumbing) with 8 tests (26 runtime asserts, 0 vacuous, 100% function coverage):

  • dispatch — the four-name routing table; anything else answers None (lines 9-17);
  • kg_create_entity — the entity_type + name gate, the empty-object properties default, the id hashing the name alone (lines 20-48);
  • kg_create_edge — the source + target + edge_type gate, the weight defaulting to 1.0, the id covering all three parts (lines 51-81);
  • kg_query — the query gate, the limit defaulting to 10, the mock results capping at three Concept rows (lines 84-110);
  • kg_traverse — the source gate, max_depth defaulting to 1, the mock paths capping at three related_to edges (lines 113-138);
  • md5_compute — the hash stub: 5381, then hash = hash * 33 + byte per input byte, with known-value tests (lines 140-148).

Verification (all run live from the worktree root, zig 0.16.0)

  • t27c parse: OK. t27c spec-status: IMPLEMENTED. t27c typecheck: 0 errors, 0 warnings.
  • t27c coverage: 10/10 tested (100%) — no transports in this port.
  • t27c test-report: 8 tests / 8 pass / 0 FAIL / 0 BLOCKED, 0 vacuous passes — the hash stub's known values (empty input 5381, single byte 5381·33 + 97), the edge hash covering all three parts, the dispatch table with the unknown-name rejection, every gate with its defaults, and the three-row caps at, below and at the boundary.
  • t27c gen | grep -c 'not yet implemented': 0; gen | wc -l: 141 (> 12).
  • grep -cE '^\s*(pub )?fn (dispatch|kg_create_entity|kg_create_edge|kg_query|kg_traverse|md5_compute)\(': 6. grep -cE '^\s*test\s+(["|[A-Za-z_])': 8 (≥ 6).
  • Boundary: git status --short — exactly this one file. The repo's lefthook pre-commit passed.
  • dupe_scan: all 8 introduced names unique across 2040 specs, and — after the corpus-ratchet lesson — all 4 introduced struct names verified absent from the corpus type set by grep before the commit; the bare body scan adds no duplicate group (752 bodies / 221 groups on base, identical with this spec present).

Dmitrii Fedorov (@dmitrii-f-t27)

…_kg.t27 (Closes gHashTag#9402)

Port gHashTag/trios:crates/trios-server/src/tools/trios_kg.rs (at
8b229e9489ee, 148 lines) as specs/port/trios/crates/trios-server/
src/tools/trios_kg.t27 - Roadmap Stage 6, goal gHashTag#4548, target t27c
gen-rust.

The trios-kg MCP tools' decisions are ported as pure functions and
tested (8 tests, 8 pass, 0 vacuous, 26 runtime asserts, 100%
function coverage): the four-name dispatch table, each tool's
required-key gate with its defaults (entity_type and name for
create_entity with the empty-object properties; source, target and
edge_type for create_edge with the weight defaulting to 1.0; the
query for kg_query with the limit defaulting to 10; the source for
kg_traverse with max_depth defaulting to 1), the three-row cap on
both mock enumerations, and the djb2-style hash stub - 5381, then
hash = hash * 33 + byte per input byte - with the entity ids
hashing the name alone and the edge ids covering all three parts.
The JSON reading and building are the callers' plumbing.

Verified: parse OK, spec-status IMPLEMENTED, typecheck 0 errors,
coverage 10/10, test-report 8/8 pass, 0 BLOCKED, gen 141 lines with
0 'not yet implemented', boundary exactly this one file, dupe_scan:
all 8 introduced names unique across 2040 specs AND all 4
introduced struct names absent from the corpus type set (both
checked before the commit), bare body scan adds no duplicate group
(752/221 unchanged).

Dmitrii Fedorov ([@dmitrii-f-t27](https://github.com/dmitrii-f-t27))
@dmitrii-f-t27

Copy link
Copy Markdown
Contributor Author

@gHashTag Please merge this PR into master via the golden chain — rights on gHashTag/t27 are read-only for me (403), so the merge itself needs your action.

What this is: the #9402 port — crates/trios-server/src/tools/trios_kg.rs (gHashTag/trios, at 8b229e9489ee, 148 lines) re-authored as specs/port/trios/crates/trios-server/src/tools/trios_kg.t27. One file, one commit, head e1cae960d, Closes #9402.

What is verified:

  • t27c parse OK, spec-status IMPLEMENTED, typecheck 0 errors / 0 warnings, coverage 10/10 (100%) — no transports in this port, t27c test-report 8 tests / 8 pass / 0 FAIL / 0 BLOCKED, 0 vacuous — the four-name dispatch table with the unknown-name rejection, every tool's required-key gate with its defaults (entity: entity_type + name with empty properties; edge: source + target + edge_type with weight 1.0; query: the query with limit 10; traverse: the source with max_depth 1), the three-row caps on both mock enumerations, and the djb2-style hash stub (5381; hash·33 + byte) with known-value tests and the entity-id hashing the name alone while the edge-id covers all three parts.
  • gen → 141 lines, 0 not yet implemented; the 6 required names count exactly 6; 8 test blocks; boundary exactly the one file.
  • dupe_scan: all 8 introduced names unique across 2040 specs, and all 4 introduced struct names verified absent from the corpus type set by grep before the commit (the corpus-ratchet lesson applied preventively); the bare body scan adds no duplicate group (752/221 unchanged).
  • The t27b-native-run artifact of this head (commit e1cae96, run 39014257890): trios_kg.t27 row — reference pass, t27b pass, tests 8, invariants 0, asserts 30, blockers [], detail empty, reference_disagree: [].

CI (head e1cae96): required trio green — validate, check-linked-issue, parse-ratchet — Check L1 TRACEABILITY green and Corpus ratchet green; 26 checks pass overall, incl. emit-bitexact, t27b-native-linux, t27b-native-macos.

The 3 reds are the base-red trio, not this change: cli-tri (the #3324 include_str!), duplicate-bodies (only the known base names), t27b-native-ratchet (the same verdict red the Queen's port PRs carry; this spec's own row is reference pass + t27b pass — the registration debt is the UNLISTED class).

After the merge I will: verify the spec file live on the merge SHA, confirm #9402 auto-closed, and file the 14-step report.

Dmitrii Fedorov (@dmitrii-f-t27)

This was referenced Oct 17, 2026
@gHashTag
gHashTag enabled auto-merge (squash) October 17, 2026 18:13
@gHashTag
gHashTag merged commit 03d8ca9 into gHashTag:master Oct 17, 2026
26 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Port gHashTag/trios:crates/trios-server/src/tools/trios_kg.rs (Rust, 6 functions) to specs/port/trios/crates/trios-server/src/tools/trios_kg.t27

2 participants