code wiki / (root) / nx_fixshot_lib.nx

nx_fixshot_lib.nx

buildroot/runtime/nx_fixshot_lib.nx

5966 B140 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind orphan library
docsdependenciesstructsconstsfunctions

about

nx_fixshot_lib.nx -- RETRIEVAL FEW-SHOTS for the autonomous fix loop (bugforge-swe-scale rung 2, 2026-07-24). The episode prompt's few-shots are HARDCODED (min2/abs1) -- the harness never learns from its own verified history. This lib retrieves the K most-similar (buggy TAB fixed) pairs from the fixcorpus and composes them as prompt shots, so every mined/verified fix improves future episodes (the cross-instance learning SOTA rung). CONTAMINATION GUARD (bench honesty): rows whose function NAME equals the instance under repair are EXCLUDED -- retrieval may teach patterns from SIMILAR fixes, never leak the target's own answer. Similarity: 4-byte shingle overlap (stride 4) between the buggy fn and each row's buggy half -- cheap, deterministic, no model. Rows scored 0 are never emitted (no random shots). API: fsl_shots(corpus, buggy, bn, selfname, dst, dstcap) -> bytes written into dst (0 = no shots; caller falls back to the hardcoded shots => rule-19 additive, default behavior unchanged) license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_fixshot_lib.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

structs

none

consts

17const FSL_FCAP: i64 = 131072 // corpus read cap
18const FSL_MAXROWS: i64 = 256
19const FSL_K: i64 = 2 // shots emitted
20const FSL_SH_K: i64 = 4 // shingle length
21const FSL_SH_STRIDE: i64 = 4
22const FSL_SH_MAX: i64 = 128 // shingles fingerprinted per fn

functions

24func fsl_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: fsl_isself
27func fsl_overlap(a: *u8, an: i64, b: *u8, bn: i64) -> i64
called by 1: fsl_shots
52func fsl_isself(rb: *u8, rn: i64, selfname: *u8) -> i64
called by 1: fsl_shots calls 1: fsl_slen
64func fsl_shots(corpus: *u8, buggy: *u8, bn: i64, selfname: *u8, dst: *u8, dstcap: i64) -> i64