code wiki / (root) / nx_tone.nx

nx_tone.nx

buildroot/runtime/nx_tone.nx

6294 B155 linesdepth 2pulls 2 transitivereach 3 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_tone.nx -- WRITING arc, rung W-TONE-1: the VOICE / TONE FINGERPRINT. Operator intent: "help me write to people in my tone." This organ turns a reference text (the operator's own writing) into a deterministic, length- invariant STYLE VECTOR, and scores how close any candidate draft sits to it -- so a generated draft can be checked/steered toward "my voice". Pure integer, NO floats, NO syscalls, NO own buffers (the nx_note shape, so any lane -- tutor, local-LLM, daemon -- can call it). Reuses nx_writecraft (counts) + nx_writestyle (prose signals) -- DRY, never reimplemented. A FINGERPRINT is TN_DIMS dims, each normalized to PER-1000 so a 40-word note and a 40k-word corpus compare directly (the key to honest matching): tf[0] avg sentence length (words *1000 / sentences) -- cadence tf[1] avg word length letters (letters *1000 / words) -- diction weight tf[2] syllables per word (syll *1000 / words) -- lexical density tf[3] complex-word ratio (complex *1000 / words) -- formality tf[4] adverb ratio (adverbs *1000 / words) tf[5] passive ratio (passive *1000 / words) tf[6] weak/filler ratio (weak *1000 / words) tf[7] dialogue fraction (chars-in-quotes *1000 / chars) -- voice tf[8] hard-sentence ratio (hard *1000 / sentences) -- rhythm tf[9] comma density (commas *1000 / words) -- subordination tf[10] exclamation density (bangs *1000 / sentences) -- emotional pitch tf[11] question density (qmarks *1000 / sentences) -- rhetorical style tn_dist = L1 (sum of abs diffs). tn_closer is a THRESHOLD-FREE comparator (which of two voices a candidate matches) so there is NO magic-number cutoff in the organ; a match THRESHOLD, when one is needed, arrives as operator DATA (rule 11), exactly like the register classifier's threshold. HONEST LIMIT (v1): L1 over raw per-1000 dims is dominated by the high-dynamic- range dims (cadence tf[0] can reach ~30000 while ratio dims sit ~0..400). The gate proves correct voice-matching on contrasting samples; PER-DIMENSION WEIGHTING (operator DATA weights, like register weights) is the next rung. license_tier: ORIGINAL module: nishi-core.write.tone depends: nishi-core.write.craft, nishi-core.write.style capability: WRITE_TONE_FINGERPRINT

dependencies 2 imports · 3 importers

nx_writecraft.nx nx_writestyle.nx nx_tone.nx nx_tone_gate.nx nx_tone_w_gate.nx nx_writer_run.nx

imports: nx_writecraft.nxnx_writestyle.nx

imported by: nx_tone_gate.nxnx_tone_w_gate.nxnx_writer_run.nx

structs

none

consts

43const TN_DIMS: i64 = 12

functions

46func tn_punct(t: *u8, n: i64, out3: *i64) -> i64
called by 1: tn_fingerprint
66func tn_fingerprint(t: *u8, n: i64, tf: *i64, sc: *i64) -> i64
93func tn_dist(a: *i64, b: *i64, k: i64) -> i64
called by 3: tn_closermainmain
106func tn_closer(cand: *i64, a: *i64, b: *i64, k: i64) -> i64
called by 2: mainmain calls 1: tn_dist
119func tn_dist_w(a: *i64, b: *i64, w: *i64, k: i64) -> i64
called by 2: tn_closer_wmain
132func tn_closer_w(cand: *i64, a: *i64, b: *i64, w: *i64, k: i64) -> i64
called by 1: main calls 1: tn_dist_w
143func tn_drift(cand: *i64, ref: *i64, w: *i64, k: i64, out: *i64) -> i64
called by 2: mainwr_do_tone