From 722f019f3826a08627cbf8dc026d73a5030753e2 Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 11:46:17 +0800 Subject: [PATCH 01/46] research: add code locator fixture --- .../fixtures/repository/web/src/ws/client.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 examples/system-one-code-locator/fixtures/repository/web/src/ws/client.ts diff --git a/examples/system-one-code-locator/fixtures/repository/web/src/ws/client.ts b/examples/system-one-code-locator/fixtures/repository/web/src/ws/client.ts new file mode 100644 index 00000000..ee60f8fa --- /dev/null +++ b/examples/system-one-code-locator/fixtures/repository/web/src/ws/client.ts @@ -0,0 +1,19 @@ +export class WebSocketClient { + private socket?: WebSocket; + private reconnectTimer?: ReturnType; + + connect(url: string) { + this.socket = new WebSocket(url); + this.socket.onopen = () => this.clearReconnect(); + this.socket.onclose = () => this.scheduleReconnect(url); + this.socket.onerror = () => this.socket?.close(); + } + + private scheduleReconnect(url: string) { + this.reconnectTimer = setTimeout(() => this.connect(url), 1000); + } + + private clearReconnect() { + if (this.reconnectTimer) clearTimeout(this.reconnectTimer); + } +} From 1fe0b929329128b475b6fa23ae09f8062824916a Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 11:46:19 +0800 Subject: [PATCH 02/46] research: add code locator fixture --- .../fixtures/repository/web/src/api/user.ts | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 examples/system-one-code-locator/fixtures/repository/web/src/api/user.ts diff --git a/examples/system-one-code-locator/fixtures/repository/web/src/api/user.ts b/examples/system-one-code-locator/fixtures/repository/web/src/api/user.ts new file mode 100644 index 00000000..97dff825 --- /dev/null +++ b/examples/system-one-code-locator/fixtures/repository/web/src/api/user.ts @@ -0,0 +1,4 @@ +export async function loadUser(id: string) { + const response = await fetch(`/api/users/${id}`); + return response.json(); +} From 44db245da1fd9ffc724c133469dbcf4eefc92d46 Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 11:46:21 +0800 Subject: [PATCH 03/46] research: add code locator fixture --- .../fixtures/repository/server/src/http.ts | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 examples/system-one-code-locator/fixtures/repository/server/src/http.ts diff --git a/examples/system-one-code-locator/fixtures/repository/server/src/http.ts b/examples/system-one-code-locator/fixtures/repository/server/src/http.ts new file mode 100644 index 00000000..33d14544 --- /dev/null +++ b/examples/system-one-code-locator/fixtures/repository/server/src/http.ts @@ -0,0 +1,3 @@ +export function startHttpServer() { + console.log('http server started'); +} From fea07dfc73636e7214a0bcd0306605ff227ce7fd Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 11:51:43 +0800 Subject: [PATCH 04/46] research: add System One code locator demo --- .../system_one_code_locator.py | 161 ++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 examples/system-one-code-locator/system_one_code_locator.py diff --git a/examples/system-one-code-locator/system_one_code_locator.py b/examples/system-one-code-locator/system_one_code_locator.py new file mode 100644 index 00000000..2bc6f82b --- /dev/null +++ b/examples/system-one-code-locator/system_one_code_locator.py @@ -0,0 +1,161 @@ +#!/usr/bin/env python3 +"""System One progressive code-localization research demo.""" +from __future__ import annotations +import argparse, json, os, re, sys, time, urllib.error, urllib.request +from datetime import datetime, timezone +from pathlib import Path + +API_URL = "https://api.typesafe.ai/v1/systemone" +MODEL = "jev-latest" +IGNORE = {".git", ".idea", ".vscode", ".venv", "node_modules", "target", "dist", "build", "__pycache__"} +SUFFIXES = {".py", ".rs", ".go", ".java", ".ts", ".tsx", ".js", ".jsx", ".vue", ".proto", ".sql", ".sh", ".yaml", ".yml", ".toml", ".md"} + +class Trace: + def __init__(self, path): + self.path = Path(path) if path else None + if self.path: + self.path.parent.mkdir(parents=True, exist_ok=True) + self.path.write_text("") + def emit(self, event, **data): + if self.path: + record = {"timestamp": datetime.now(timezone.utc).isoformat(), "event": event, **data} + with self.path.open("a", encoding="utf-8") as f: + f.write(json.dumps(record, ensure_ascii=False, sort_keys=True) + "\n") + +class SystemOneScorer: + def __init__(self, key, trace, endpoint=API_URL, model=MODEL, batch_size=48): + self.key, self.trace, self.endpoint, self.model, self.batch_size = key, trace, endpoint, model, batch_size + def _request(self, payload): + body = json.dumps(payload).encode() + for attempt in range(4): + req = urllib.request.Request(self.endpoint, data=body, method="POST", headers={"Authorization": f"Bearer {self.key}", "Content-Type": "application/json"}) + try: + with urllib.request.urlopen(req, timeout=60) as resp: + return json.loads(resp.read().decode()) + except urllib.error.HTTPError as exc: + detail = exc.read().decode(errors="replace") + if exc.code not in {429, 529}: raise RuntimeError(f"TypeSafe HTTP {exc.code}: {detail}") from exc + if attempt == 3: raise RuntimeError(f"TypeSafe HTTP {exc.code}: {detail}") from exc + time.sleep(2 ** attempt) + def score(self, query, stage, candidates): + out, usage = [], {"model_calls": 0, "input_tokens": 0, "output_tokens": 0} + for offset in range(0, len(candidates), self.batch_size): + batch = candidates[offset:offset+self.batch_size] + questions = {} + for i, candidate in enumerate(batch): + questions[f"candidate_{i}"] = { + "type": "noul", + "instructions": {"task": query, "stage": stage, "candidate": candidate["payload"], "question": "Would retaining this candidate materially help locate or understand source code relevant to the task?"}, + "criteria": {"true": "Plausibly relevant; keep it, including indirect supporting code.", "false": "Unlikely to help locate or understand the requested implementation."}, + } + payload = {"state": {"goal": query, "stage": stage, "candidate_count": len(batch)}, "model": self.model, "questions": questions} + self.trace.emit("system_one_request", stage=stage, batch=offset//self.batch_size, candidate_ids=[x["id"] for x in batch], request=payload) + started = time.perf_counter(); response = self._request(payload); latency = round((time.perf_counter()-started)*1000, 3) + u = response.get("usage", {}); usage["model_calls"] += 1 + usage["input_tokens"] += int(u.get("input_tokens", 0) or 0); usage["output_tokens"] += int(u.get("output_tokens", 0) or 0) + scores = [] + for i, candidate in enumerate(batch): + answer = response.get("answers", {}).get(f"candidate_{i}", {}) + if answer.get("type") != "noul": raise RuntimeError(f"unexpected answer: {answer!r}") + item = {**candidate, "score": float(answer["noul"])}; out.append(item); scores.append({"id": item["id"], "score": item["score"]}) + self.trace.emit("system_one_response", stage=stage, batch=offset//self.batch_size, latency_ms=latency, model=response.get("model"), usage=u, scores=scores) + return sorted(out, key=lambda x: (-x["score"], x["id"])), usage + +class OfflineScorer: + model = "offline-lexical-fixture" + def __init__(self, trace): self.trace = trace + def score(self, query, stage, candidates): + tokens = set(re.findall(r"[a-zA-Z][a-zA-Z0-9_]+", query.lower())) + if "websocket" in tokens: tokens |= {"ws", "socket", "connect", "connection", "reconnect"} + out = [] + for c in candidates: + text = json.dumps(c["payload"]).lower(); hits = sum(t in text for t in tokens if len(t) >= 2) + score = 0.05 if hits == 0 else 0.62 if hits == 1 else 0.84 if hits == 2 else 0.96 + out.append({**c, "score": score}) + out.sort(key=lambda x: (-x["score"], x["id"])); self.trace.emit("offline_scores", stage=stage, scores=[{"id":x["id"],"score":x["score"]} for x in out]) + return out, {"model_calls":0,"input_tokens":0,"output_tokens":0} + +def directories(root): + root = Path(root).resolve(); out = [] + for current, dirs, files in os.walk(root): + dirs[:] = sorted(d for d in dirs if d not in IGNORE and not d.startswith(".")) + p = Path(current) + if p == root: continue + rel = p.relative_to(root).as_posix() + out.append({"id": rel, "payload": {"path": rel, "name": p.name, "child_directories": dirs[:24], "direct_files": sorted(f for f in files if not f.startswith("."))[:40]}}) + return out + +def files(root, selected_dirs): + root = Path(root).resolve(); found = {} + for d in selected_dirs: + base = root / d["payload"]["path"] + for current, dirs, names in os.walk(base): + dirs[:] = sorted(x for x in dirs if x not in IGNORE and not x.startswith(".")) + for name in names: + p = Path(current) / name + if name.startswith(".") or p.suffix.lower() not in SUFFIXES: continue + try: size = p.stat().st_size + except OSError: continue + rel = p.relative_to(root).as_posix() + found[rel] = {"id": rel, "payload": {"path": rel, "filename": name, "extension": p.suffix.lower(), "size_bytes": size}} + return [found[k] for k in sorted(found)] + +def lines(root, file, radius=2): + path = Path(root).resolve() / file["payload"]["path"] + source = path.read_text(encoding="utf-8", errors="replace").splitlines(); out = [] + for i, line in enumerate(source): + if not line.strip(): continue + start, end = max(0, i-radius), min(len(source), i+radius+1) + context = "\n".join(f"{n+1}: {source[n]}" for n in range(start, end)) + out.append({"id": f"{file['id']}:{i+1}", "payload": {"path": file["payload"]["path"], "line": i+1, "text": line[:1200], "nearby_lines": context[:6000]}}) + return out + +def snippets(root, path, scored, threshold, radius=2): + relevant = sorted((x for x in scored if x["score"] >= threshold), key=lambda x: x["payload"]["line"]) + if not relevant: return [] + source = (Path(root).resolve()/path).read_text(encoding="utf-8", errors="replace").splitlines(); ranges=[] + for item in relevant: + line=item["payload"]["line"]; start=max(1,line-radius); end=min(len(source),line+radius) + if ranges and start <= ranges[-1][1]+1: ranges[-1]=(ranges[-1][0], max(ranges[-1][1],end), max(ranges[-1][2],item["score"])) + else: ranges.append((start,end,item["score"])) + return [{"path":path,"start_line":s,"end_line":e,"score":score,"content":"\n".join(f"{n}: {source[n-1]}" for n in range(s,e+1))} for s,e,score in ranges] + +def run(root, query, scorer, trace, dt, ft, lt): + started=time.perf_counter(); usage={"model_calls":0,"input_tokens":0,"output_tokens":0} + def stage(name, candidates, threshold): + trace.emit("candidates_exposed", stage=name, count=len(candidates), candidates=candidates) + scored,u=scorer.score(query,name,candidates) + for k in usage: usage[k]+=u[k] + selected=[x for x in scored if x["score"]>=threshold] + trace.emit("threshold_applied", stage=name, threshold=threshold, input_count=len(scored), selected_count=len(selected), selected=selected) + return selected + trace.emit("search_started", root=str(Path(root).resolve()), query=query, model=scorer.model, thresholds={"directory":dt,"file":ft,"line":lt}) + ds=stage("directory", directories(root), dt); fs=stage("file", files(root,ds), ft); ss=[]; line_count=0; line_kept=0 + for f in fs: + lc=lines(root,f); line_count += len(lc); scored,u=scorer.score(query,"line",lc) + for k in usage: usage[k]+=u[k] + kept=[x for x in scored if x["score"]>=lt]; line_kept += len(kept) + trace.emit("threshold_applied", stage="line", parent=f["id"], threshold=lt, input_count=len(scored), selected_count=len(kept), selected=kept) + ss += snippets(root,f["payload"]["path"],scored,lt) + ss.sort(key=lambda x:(-x["score"],x["path"],x["start_line"])) + result={"query":query,"root":str(Path(root).resolve()),"model":scorer.model,"thresholds":{"directory":dt,"file":ft,"line":lt},"directories":ds,"files":fs,"snippets":ss,"metrics":{**usage,"directories_selected":len(ds),"files_selected":len(fs),"lines_exposed":line_count,"lines_selected":line_kept,"snippets":len(ss),"elapsed_ms":round((time.perf_counter()-started)*1000,3)}} + trace.emit("search_completed", result=result); return result + +def main(argv=None): + p=argparse.ArgumentParser(); p.add_argument("root"); p.add_argument("query"); p.add_argument("--directory-threshold",type=float,default=.35); p.add_argument("--file-threshold",type=float,default=.50); p.add_argument("--line-threshold",type=float,default=.70); p.add_argument("--batch-size",type=int,default=48); p.add_argument("--offline-decider",action="store_true"); p.add_argument("--trace-file"); p.add_argument("--output-json"); p.add_argument("--json",action="store_true"); p.add_argument("--typesafe-endpoint",default=os.getenv("TYPESAFE_API_URL",API_URL)); p.add_argument("--model",default=os.getenv("TYPESAFE_MODEL",MODEL)); a=p.parse_args(argv) + trace=Trace(a.trace_file) + if a.offline_decider: scorer=OfflineScorer(trace) + else: + key=os.getenv("TYPESAFE_API_KEY","") + if not key: print("TYPESAFE_API_KEY is required unless --offline-decider is used.",file=sys.stderr); return 2 + scorer=SystemOneScorer(key,trace,a.typesafe_endpoint,a.model,a.batch_size) + result=run(a.root,a.query,scorer,trace,a.directory_threshold,a.file_threshold,a.line_threshold); payload=json.dumps(result,indent=2,ensure_ascii=False) + if a.output_json: Path(a.output_json).write_text(payload+"\n",encoding="utf-8") + if a.json: print(payload) + else: + print("relevant directories:"); [print(f" {x['score']:.3f} {x['id']}") for x in result["directories"]] + print("relevant files:"); [print(f" {x['score']:.3f} {x['id']}") for x in result["files"]] + print("relevant snippets:"); [print(f" {x['score']:.3f} {x['path']}:{x['start_line']}-{x['end_line']}\n{x['content']}") for x in result["snippets"]] + print("metrics:",json.dumps(result["metrics"],ensure_ascii=False)) + return 0 if result["files"] and result["snippets"] else 1 +if __name__ == "__main__": raise SystemExit(main()) From 0f35379af2e126161035db3c4dfa7ea20523238d Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 11:52:01 +0800 Subject: [PATCH 05/46] test: cover System One code locator --- .../test_system_one_code_locator.py | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 examples/system-one-code-locator/test_system_one_code_locator.py diff --git a/examples/system-one-code-locator/test_system_one_code_locator.py b/examples/system-one-code-locator/test_system_one_code_locator.py new file mode 100644 index 00000000..2e9b21a9 --- /dev/null +++ b/examples/system-one-code-locator/test_system_one_code_locator.py @@ -0,0 +1,66 @@ +import importlib.util, pathlib, sys, tempfile, unittest + +MODULE_PATH=pathlib.Path(__file__).with_name('system_one_code_locator.py') +SPEC=importlib.util.spec_from_file_location('system_one_code_locator',MODULE_PATH) +MODULE=importlib.util.module_from_spec(SPEC) +sys.modules[SPEC.name]=MODULE +SPEC.loader.exec_module(MODULE) + +class DemoTest(unittest.TestCase): + def fixture(self): + return pathlib.Path(__file__).with_name('fixtures')/'repository' + + def test_progressive_localization(self): + with tempfile.TemporaryDirectory() as temp: + trace=MODULE.Trace(pathlib.Path(temp)/'trace.jsonl') + scorer=MODULE.OfflineScorer(trace) + result=MODULE.run( + self.fixture(), + 'Help me optimize the websocket connection implementation', + scorer,trace,.35,.50,.60, + ) + self.assertIn('web/src/ws',[x['id'] for x in result['directories']]) + self.assertIn('web/src/ws/client.ts',[x['id'] for x in result['files']]) + self.assertTrue(any( + x['path']=='web/src/ws/client.ts' and 'WebSocket' in x['content'] + for x in result['snippets'] + )) + events=[ + __import__('json').loads(x)['event'] + for x in pathlib.Path(trace.path).read_text().splitlines() + ] + self.assertIn('search_started',events) + self.assertIn('threshold_applied',events) + self.assertIn('search_completed',events) + + def test_request_uses_noul(self): + with tempfile.TemporaryDirectory() as temp: + trace=MODULE.Trace(pathlib.Path(temp)/'trace.jsonl') + scorer=MODULE.SystemOneScorer('test',trace) + candidates=[ + {'id':'web/src/ws','payload':{'path':'web/src/ws'}}, + {'id':'server','payload':{'path':'server'}}, + ] + scorer._request=lambda payload: { + 'model':'jev-test', + 'answers':{ + f'candidate_{i}':{'type':'noul','noul':0.5} + for i in range(2) + }, + 'usage':{'input_tokens':1,'output_tokens':1}, + } + scored,_=scorer.score('optimize websocket','directory',candidates) + self.assertEqual(2,len(scored)) + records=[ + __import__('json').loads(x) + for x in pathlib.Path(trace.path).read_text().splitlines() + ] + request=next( + x for x in records if x['event']=='system_one_request' + )['request'] + self.assertTrue(all( + q['type']=='noul' for q in request['questions'].values() + )) + +if __name__=='__main__': + unittest.main() From 700543fc3bad39fffe8c3833ff20dafde215d2a2 Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 11:52:20 +0800 Subject: [PATCH 06/46] docs: document System One code locator --- examples/system-one-code-locator/README.md | 168 +++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 examples/system-one-code-locator/README.md diff --git a/examples/system-one-code-locator/README.md b/examples/system-one-code-locator/README.md new file mode 100644 index 00000000..bd9c1e9f --- /dev/null +++ b/examples/system-one-code-locator/README.md @@ -0,0 +1,168 @@ +# System One Code Locator + +> Experimental research prototype. This is a localization harness, not a code-changing agent and not part of the canonical Narness runtime. + +This example explores whether a fast System One model can localize code by repeatedly judging a progressively disclosed search space rather than driving repository browsing through a ReAct loop. + +Given a request such as: + +> Help me optimize the websocket connection implementation. + +and a repository root, the harness performs: + +```text +repository + -> enumerate directory candidates + -> System One relevance scores + -> keep directories above threshold + -> enumerate files under retained directories + -> System One relevance scores + -> keep files above threshold + -> split retained files into source lines with small local context + -> System One relevance scores + -> merge adjacent relevant lines into snippets +``` + +The model never chooses filesystem tools, constructs paths, or controls traversal. The harness owns state expansion, thresholds, IO, provenance, batching, and result assembly. + +## Why Noul instead of Choice + +Directory, file, and line relevance are independent judgments: several candidates may all be relevant. The TypeSafe System One API's `noul` primitive returns a yes-probability for each question, so the runtime can retain every candidate whose score crosses the stage threshold. + +`choice` would instead normalize probability across candidates and force one winner, which is appropriate for the Kubernetes action-frontier demo but not for multi-hit code localization. + +## State progression + +```text +RepositoryState + | + | deterministic enumeration + v +DirectoryCandidate[] + | + | Noul relevance + low threshold + v +RelevantDirectory[] + | + | deterministic enumeration + v +FileCandidate[] + | + | Noul relevance + medium threshold + v +RelevantFile[] + | + | read source + split on newlines + v +LineCandidate[] + | + | Noul relevance + higher threshold + v +RelevantLine[] + | + | deterministic range merge + v +CodeSnippet[] +``` + +The defaults intentionally become stricter as the search gets deeper: + +```text +directory >= 0.35 +file >= 0.50 +line >= 0.70 +``` + +These are experiment parameters, not claimed optimal values. Early false negatives are especially expensive because pruning a directory removes its entire subtree. A future experiment should compare simple thresholds against threshold-plus-beam retention. + +## Run the deterministic fixture + +No API key is required: + +```bash +python3 examples/system-one-code-locator/system_one_code_locator.py \ + examples/system-one-code-locator/fixtures/repository \ + "Help me optimize the websocket connection implementation" \ + --offline-decider \ + --line-threshold 0.60 +``` + +The offline scorer is only a deterministic fixture implementation. It is not intended to emulate System One quality. + +## Run with TypeSafe System One + +```bash +export TYPESAFE_API_KEY=... + +python3 examples/system-one-code-locator/system_one_code_locator.py \ + /path/to/repository \ + "Help me optimize the websocket connection implementation" +``` + +Optional environment variables: + +```bash +export TYPESAFE_API_URL=https://api.typesafe.ai/v1/systemone +export TYPESAFE_MODEL=jev-latest +``` + +## Research trace + +Use `--trace-file` to create an append-only JSONL trace and `--output-json` to persist the final result: + +```bash +python3 examples/system-one-code-locator/system_one_code_locator.py \ + /path/to/repository \ + "Help me optimize the websocket connection implementation" \ + --trace-file evidence/code-locator.trace.jsonl \ + --output-json evidence/code-locator.result.json +``` + +The trace records: + +- the query, model, root, and thresholds; +- every directory/file/line candidate disclosed by the harness; +- every TypeSafe request body without credentials; +- model responses reduced to candidate scores, latency, and token usage; +- every threshold application and retained candidate set; +- the final result and aggregate metrics. + +This makes a workflow run useful as research evidence rather than only as a pass/fail CI event. + +## Output contract + +The final result contains three provenance-preserving layers: + +```text +relevant directories +relevant files +relevant snippets { path, start_line, end_line, score, content } +``` + +It also reports exposed/selected counts, model calls, token usage, and elapsed time. + +## Tests + +```bash +python3 -m unittest discover \ + -s examples/system-one-code-locator \ + -p 'test_*.py' \ + -v +``` + +The tests verify that the deterministic fixture finds the websocket client and that real API requests use independent Noul questions. + +## Research limitations + +The current prototype intentionally leaves several questions open: + +- whether whole-tree directory enumeration is better than recursive frontier expansion; +- threshold calibration and compounding false-negative risk; +- threshold-only pruning versus keeping a minimum semantic beam; +- line-level scoring versus symbol/block/chunk-level scoring; +- caching repeated judgments across nearby queries; +- comparison against ripgrep, embeddings, language-server indexes, and System Two browsing; +- evaluation against gold relevant-file and relevant-range labels; +- escalation when no candidate survives a stage. + +See the [System One Progressive Action Spaces topic](../../docs/topics/system-one-progressive-action-space/README.md) for the shared model behind this demo and the Kubernetes command generator. From 5d919bcc9fb0f1f4cb474855fe3d38f1f6604e8e Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 11:54:13 +0800 Subject: [PATCH 07/46] research: record full code locator candidate evidence --- .../system-one-code-locator/system_one_code_locator.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/system-one-code-locator/system_one_code_locator.py b/examples/system-one-code-locator/system_one_code_locator.py index 2bc6f82b..5b815fe4 100644 --- a/examples/system-one-code-locator/system_one_code_locator.py +++ b/examples/system-one-code-locator/system_one_code_locator.py @@ -130,15 +130,18 @@ def stage(name, candidates, threshold): trace.emit("threshold_applied", stage=name, threshold=threshold, input_count=len(scored), selected_count=len(selected), selected=selected) return selected trace.emit("search_started", root=str(Path(root).resolve()), query=query, model=scorer.model, thresholds={"directory":dt,"file":ft,"line":lt}) - ds=stage("directory", directories(root), dt); fs=stage("file", files(root,ds), ft); ss=[]; line_count=0; line_kept=0 + directory_candidates=directories(root); ds=stage("directory", directory_candidates, dt) + file_candidates=files(root,ds); fs=stage("file", file_candidates, ft); ss=[]; line_count=0; line_kept=0 for f in fs: - lc=lines(root,f); line_count += len(lc); scored,u=scorer.score(query,"line",lc) + lc=lines(root,f); line_count += len(lc) + trace.emit("candidates_exposed", stage="line", parent=f["id"], count=len(lc), candidates=lc) + scored,u=scorer.score(query,"line",lc) for k in usage: usage[k]+=u[k] kept=[x for x in scored if x["score"]>=lt]; line_kept += len(kept) trace.emit("threshold_applied", stage="line", parent=f["id"], threshold=lt, input_count=len(scored), selected_count=len(kept), selected=kept) ss += snippets(root,f["payload"]["path"],scored,lt) ss.sort(key=lambda x:(-x["score"],x["path"],x["start_line"])) - result={"query":query,"root":str(Path(root).resolve()),"model":scorer.model,"thresholds":{"directory":dt,"file":ft,"line":lt},"directories":ds,"files":fs,"snippets":ss,"metrics":{**usage,"directories_selected":len(ds),"files_selected":len(fs),"lines_exposed":line_count,"lines_selected":line_kept,"snippets":len(ss),"elapsed_ms":round((time.perf_counter()-started)*1000,3)}} + result={"query":query,"root":str(Path(root).resolve()),"model":scorer.model,"thresholds":{"directory":dt,"file":ft,"line":lt},"directories":ds,"files":fs,"snippets":ss,"metrics":{**usage,"directories_exposed":len(directory_candidates),"directories_selected":len(ds),"files_exposed":len(file_candidates),"files_selected":len(fs),"lines_exposed":line_count,"lines_selected":line_kept,"snippets":len(ss),"elapsed_ms":round((time.perf_counter()-started)*1000,3)}} trace.emit("search_completed", result=result); return result def main(argv=None): From 37f3ffd8efde0024f36e93af62388f35e4cb1b1c Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 11:54:42 +0800 Subject: [PATCH 08/46] docs: add System One code localization research note --- .../research/code-localization.md | 259 ++++++++++++++++++ 1 file changed, 259 insertions(+) create mode 100644 docs/topics/system-one-progressive-action-space/research/code-localization.md diff --git a/docs/topics/system-one-progressive-action-space/research/code-localization.md b/docs/topics/system-one-progressive-action-space/research/code-localization.md new file mode 100644 index 00000000..43708fe5 --- /dev/null +++ b/docs/topics/system-one-progressive-action-space/research/code-localization.md @@ -0,0 +1,259 @@ +# Hierarchical Code Localization with System One + +> Research note for the System One Progressive Action Spaces topic. + +## Question + +Can a fast System One model locate task-relevant source code without running an open-ended ReAct browsing loop? + +The concrete example is: + +> Help me optimize the websocket connection implementation. + +The experiment treats repository exploration as progressive state disclosure. The harness deterministically exposes the next bounded candidate set; System One only estimates semantic relevance inside that set. + +## Working model + +```text +Goal + + +Observed repository structure + | + v +Harness expands state + | + v +Finite candidate set + | + v +System One relevance judgment + | + v +Harness prunes and expands again +``` + +For the initial prototype: + +```text +repository + -> directories + -> files + -> source lines + -> merged code ranges +``` + +This is the same underlying shape as the Kubernetes experiment: + +```text +Kubernetes: +cluster -> namespaces -> pods -> containers -> grounded command + +Code localization: +repository -> directories -> files -> lines -> grounded snippets +``` + +The domain adapter changes; the harness pattern does not. + +## System One is a semantic filter, not the navigator + +A ReAct implementation could repeatedly ask a model to decide which directory to list, which file to open, and which command to run. That gives the model control of both semantic judgment and exploration mechanics. + +The prototype separates those responsibilities: + +```text +Harness + - enumerate candidates + - read files + - split content + - preserve provenance + - apply thresholds + - batch requests + - merge final ranges + - record evidence + +System One + - estimate whether each exposed candidate is relevant to the goal +``` + +This keeps deterministic operations outside the model and makes each model call independently inspectable. + +## Why independent probabilities matter + +Unlike action selection, localization is not a single-winner problem. A websocket change may involve a connection manager, hook, protocol type, retry policy, and tests at the same time. + +The experiment therefore uses one Noul question per candidate. Each candidate gets an independent relevance probability and the harness retains all candidates above the current threshold. + +This also makes threshold behavior explicit and measurable. + +## Threshold schedule and recall risk + +The initial schedule is deliberately recall-biased at the top and precision-biased near source content: + +```text +directory >= 0.35 +file >= 0.50 +line >= 0.70 +``` + +The exact values are experimental. + +A false positive at the directory stage only creates more downstream work. A false negative at the directory stage can permanently hide every relevant file below it. Therefore early-stage threshold calibration is a first-class runtime concern, not merely a model-tuning detail. + +A likely next design is: + +```text +retain(all candidates >= threshold) ++ +retain(top_k minimum beam) +``` + +That would bound catastrophic early pruning while still reducing the search space. + +## Progressive disclosure is also a cost policy + +The model does not receive source code until a file survives earlier stages: + +```text +directory stage + path + direct child names + +file stage + path + filename + extension + size + +line stage + line + small neighboring context +``` + +This means context volume grows only for candidates that survive previous semantic gates. + +The key hypothesis is not merely that System One is fast. It is that the harness can spend semantic judgment only where the current state justifies further disclosure. + +## Result provenance + +The final answer is not a bag of strings. It retains the path from coarse state to source evidence: + +```text +RelevantDirectory + -> RelevantFile + -> RelevantLine + -> CodeSnippet(path, line range, score, content) +``` + +That provenance is required for later evaluation, explainability, cache design, and any System Two handoff. + +## Research hypotheses + +### H6: Progressive semantic pruning can replace agent-driven browsing for localization + +For tasks whose relevant code can be found through repository structure and local semantic evidence, repeated expand -> score -> prune transitions may locate useful source ranges without free-form planning. + +### H7: Early high recall matters more than uniform precision + +A stage-specific threshold schedule should outperform one global threshold because false-negative cost is asymmetric across the search tree. + +### H8: Harness-controlled disclosure reduces unnecessary context + +Reading source only after structural candidates survive should reduce model input compared with broad repository ingestion while retaining enough semantic signal to localize the implementation. + +### H9: The same runtime abstraction can support action selection and relevance filtering + +Kubernetes uses a grounded `Choice` frontier. Code localization uses independent `Noul` judgments. Both can share: + +```text +StateSpaceGenerator + -> CandidateSet + -> DecisionPrimitive + -> TransitionPolicy + -> EvidenceRecorder +``` + +The important abstraction may therefore be broader than a state machine with a single decision type. + +## Evidence contract + +Every experiment run should preserve enough data to replay the reasoning surface without relying on GitHub Actions console retention. + +The workflow artifact should contain: + +```text +run-manifest.json + +k8s/ + stdout.log + result.json + +code-locator/ + stdout.log + result.json + trace.jsonl + +summary.md +``` + +The manifest records repository and revision identity, workflow run identity, query, thresholds, model, and subject-repository revision. + +For code localization, JSONL events include candidate disclosure, model requests, score responses, threshold decisions, latency, token usage, and final results. Authorization data is never recorded. + +The Kubernetes demo contributes its final runtime state and human-readable decision log. Its `Decision` records preserve selected action, source, confidence, and probability distribution. + +## Workflow experiment design + +The GitHub Actions workflow has two roles. + +First, deterministic fixture validation runs on every relevant change so the research harness itself remains reproducible without external services. + +Second, a manual evidence collection job can run the real System One model against: + +- the deterministic Kubernetes fixture; and +- a checked-out subject repository such as `BestNathan/nession`, with a natural-language code-localization query. + +The subject repository, ref, query, thresholds, batch size, and online/offline mode are workflow inputs so repeated runs can vary one parameter while preserving the rest in the manifest. + +Artifacts are retained for 90 days. Each run should be treated as raw research evidence, not as proof that the hypotheses are already true. + +## Metrics available immediately + +Without gold labels, the workflow can already measure operational behavior: + +- candidates exposed and retained at each stage; +- pruning ratio by stage; +- total model calls; +- TypeSafe input/output tokens; +- end-to-end elapsed time; +- selected directories/files/source ranges; +- stability across repeated runs and threshold settings; +- Kubernetes selected actions and confidence distributions. + +## Metrics requiring a benchmark dataset + +Claims about localization quality require pre-registered expected evidence, for example: + +```text +query +expected relevant files +expected relevant line ranges or symbols +allowed supporting files +``` + +That enables: + +- relevant-file recall; +- relevant-file precision; +- range recall / overlap; +- false-prune stage attribution; +- cost per successfully localized task; +- comparison with ripgrep, embedding retrieval, LSP/index retrieval, and System Two browsing. + +## Next experiments + +1. Build a small gold dataset from real Nession changes and issue/PR history. +2. Compare threshold-only pruning with threshold + minimum beam retention. +3. Compare whole-tree directory scoring with recursively expanded directory frontiers. +4. Replace line candidates with syntax-aware symbols or blocks while retaining line provenance. +5. Add cache keys based on repository revision, goal, stage, and candidate content hash. +6. Compare System One localization against a System Two coding agent under the same gold tasks and evidence contract. +7. Test a System One -> System Two handoff where the fast locator supplies grounded code context to the reasoning model. + +## Reference implementation + +See [System One Code Locator](../../../examples/system-one-code-locator/README.md). From 3394a44f7aba911b034841a333893fb973c1e937 Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 11:55:27 +0800 Subject: [PATCH 09/46] ci: collect System One research evidence --- .github/workflows/system-one-research.yml | 288 ++++++++++++++++++++++ 1 file changed, 288 insertions(+) create mode 100644 .github/workflows/system-one-research.yml diff --git a/.github/workflows/system-one-research.yml b/.github/workflows/system-one-research.yml new file mode 100644 index 00000000..7f09ad6d --- /dev/null +++ b/.github/workflows/system-one-research.yml @@ -0,0 +1,288 @@ +name: System One Research Demos + +on: + push: + paths: + - 'examples/system-one-k8s/**' + - 'examples/system-one-code-locator/**' + - 'docs/topics/system-one-progressive-action-space/**' + - '.github/workflows/system-one-research.yml' + pull_request: + paths: + - 'examples/system-one-k8s/**' + - 'examples/system-one-code-locator/**' + - 'docs/topics/system-one-progressive-action-space/**' + - '.github/workflows/system-one-research.yml' + workflow_dispatch: + inputs: + subject_repository: + description: Repository used by the code-localization experiment + required: true + default: BestNathan/nession + type: string + subject_ref: + description: Git ref of the subject repository + required: true + default: staging + type: string + query: + description: Code-localization task + required: true + default: Help me optimize the websocket connection implementation + type: string + directory_threshold: + description: Directory Noul threshold + required: true + default: '0.35' + type: string + file_threshold: + description: File Noul threshold + required: true + default: '0.50' + type: string + line_threshold: + description: Source-line Noul threshold + required: true + default: '0.70' + type: string + batch_size: + description: Noul questions per TypeSafe request + required: true + default: '48' + type: string + collect_system_one: + description: Call the real TypeSafe System One API + required: true + default: true + type: boolean + +permissions: + contents: read + +jobs: + fixtures: + name: Deterministic fixture evidence + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.13' + + - name: Run demo tests + run: | + set -euo pipefail + python3 -m unittest discover -s examples/system-one-k8s -p 'test_*.py' -v + python3 -m unittest discover -s examples/system-one-code-locator -p 'test_*.py' -v + + - name: Collect deterministic evidence + run: | + set -euo pipefail + evidence="$RUNNER_TEMP/system-one-fixtures-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT" + mkdir -p "$evidence/k8s" "$evidence/code-locator" + echo "EVIDENCE_DIR=$evidence" >> "$GITHUB_ENV" + + python3 examples/system-one-k8s/system_one_k8s.py "Show me the Kubernetes logs for nession in staging." --fixture examples/system-one-k8s/fixtures/cluster.json --offline-decider --json | tee "$evidence/k8s/result.json" + + python3 examples/system-one-k8s/system_one_k8s.py "Show me the Kubernetes logs for nession in staging." --fixture examples/system-one-k8s/fixtures/cluster.json --offline-decider | tee "$evidence/k8s/stdout.log" + + python3 examples/system-one-code-locator/system_one_code_locator.py examples/system-one-code-locator/fixtures/repository "Help me optimize the websocket connection implementation" --offline-decider --line-threshold 0.60 --trace-file "$evidence/code-locator/trace.jsonl" --output-json "$evidence/code-locator/result.json" | tee "$evidence/code-locator/stdout.log" + + python3 - <<'PY' + import json, os + from pathlib import Path + root = Path(os.environ["EVIDENCE_DIR"]) + manifest = { + "schema_version": 1, + "kind": "system-one-deterministic-fixture-evidence", + "github": { + "repository": os.environ.get("GITHUB_REPOSITORY"), + "sha": os.environ.get("GITHUB_SHA"), + "run_id": os.environ.get("GITHUB_RUN_ID"), + "run_attempt": os.environ.get("GITHUB_RUN_ATTEMPT"), + }, + "experiments": ["system-one-k8s", "system-one-code-locator"], + } + (root / "run-manifest.json").write_text(json.dumps(manifest, indent=2) + "\n") + PY + + - name: Upload deterministic research evidence + if: always() + uses: actions/upload-artifact@v4 + with: + name: system-one-fixtures-${{ github.run_id }}-${{ github.run_attempt }} + path: ${{ env.EVIDENCE_DIR }} + retention-days: 90 + if-no-files-found: warn + + system-one: + name: Real System One evidence + if: ${{ github.event_name == 'workflow_dispatch' && inputs.collect_system_one }} + runs-on: ubuntu-24.04 + environment: ds + timeout-minutes: 120 + steps: + - name: Checkout Narness harness + uses: actions/checkout@v4 + with: + path: narness + fetch-depth: 0 + persist-credentials: false + + - name: Checkout subject repository + uses: actions/checkout@v4 + with: + repository: ${{ inputs.subject_repository }} + ref: ${{ inputs.subject_ref }} + path: subject + fetch-depth: 1 + persist-credentials: false + + - uses: actions/setup-python@v5 + with: + python-version: '3.13' + + - name: Require TypeSafe credentials + env: + TYPESAFE_API_KEY: ${{ secrets.TYPESAFE_API_KEY }} + run: | + set -euo pipefail + test -n "$TYPESAFE_API_KEY" || { + echo 'Set TYPESAFE_API_KEY in the ds environment.' >&2 + exit 2 + } + + - name: Initialize evidence manifest + env: + QUERY: ${{ inputs.query }} + SUBJECT_REPOSITORY: ${{ inputs.subject_repository }} + SUBJECT_REF: ${{ inputs.subject_ref }} + DIRECTORY_THRESHOLD: ${{ inputs.directory_threshold }} + FILE_THRESHOLD: ${{ inputs.file_threshold }} + LINE_THRESHOLD: ${{ inputs.line_threshold }} + BATCH_SIZE: ${{ inputs.batch_size }} + TYPESAFE_MODEL: ${{ vars.TYPESAFE_MODEL || 'jev-latest' }} + run: | + set -euo pipefail + evidence="$RUNNER_TEMP/system-one-research-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT" + mkdir -p "$evidence/k8s" "$evidence/code-locator" + echo "EVIDENCE_DIR=$evidence" >> "$GITHUB_ENV" + + python3 - <<'PY' + import json, os, subprocess + from pathlib import Path + + def revision(path): + return subprocess.check_output( + ["git", "-C", path, "rev-parse", "HEAD"], text=True + ).strip() + + manifest = { + "schema_version": 1, + "kind": "system-one-research-evidence", + "github": { + "repository": os.environ.get("GITHUB_REPOSITORY"), + "sha": os.environ.get("GITHUB_SHA"), + "run_id": os.environ.get("GITHUB_RUN_ID"), + "run_attempt": os.environ.get("GITHUB_RUN_ATTEMPT"), + }, + "harness_revision": revision("narness"), + "subject": { + "repository": os.environ["SUBJECT_REPOSITORY"], + "requested_ref": os.environ["SUBJECT_REF"], + "revision": revision("subject"), + }, + "code_locator": { + "query": os.environ["QUERY"], + "thresholds": { + "directory": float(os.environ["DIRECTORY_THRESHOLD"]), + "file": float(os.environ["FILE_THRESHOLD"]), + "line": float(os.environ["LINE_THRESHOLD"]), + }, + "batch_size": int(os.environ["BATCH_SIZE"]), + }, + "model": os.environ["TYPESAFE_MODEL"], + } + root = Path(os.environ["EVIDENCE_DIR"]) + (root / "run-manifest.json").write_text( + json.dumps(manifest, indent=2) + "\n" + ) + PY + + - name: Run Kubernetes System One demo + env: + TYPESAFE_API_KEY: ${{ secrets.TYPESAFE_API_KEY }} + TYPESAFE_API_URL: ${{ vars.TYPESAFE_API_URL || 'https://api.typesafe.ai/v1/systemone' }} + TYPESAFE_MODEL: ${{ vars.TYPESAFE_MODEL || 'jev-latest' }} + run: | + set -euo pipefail + python3 narness/examples/system-one-k8s/system_one_k8s.py "Show me the Kubernetes logs for nession in staging." --fixture narness/examples/system-one-k8s/fixtures/cluster.json --json | tee "$EVIDENCE_DIR/k8s/result.json" + + python3 narness/examples/system-one-k8s/system_one_k8s.py "Show me the Kubernetes logs for nession in staging." --fixture narness/examples/system-one-k8s/fixtures/cluster.json | tee "$EVIDENCE_DIR/k8s/stdout.log" + + - name: Run code-localization System One demo + env: + TYPESAFE_API_KEY: ${{ secrets.TYPESAFE_API_KEY }} + TYPESAFE_API_URL: ${{ vars.TYPESAFE_API_URL || 'https://api.typesafe.ai/v1/systemone' }} + TYPESAFE_MODEL: ${{ vars.TYPESAFE_MODEL || 'jev-latest' }} + QUERY: ${{ inputs.query }} + DIRECTORY_THRESHOLD: ${{ inputs.directory_threshold }} + FILE_THRESHOLD: ${{ inputs.file_threshold }} + LINE_THRESHOLD: ${{ inputs.line_threshold }} + BATCH_SIZE: ${{ inputs.batch_size }} + run: | + set -euo pipefail + python3 narness/examples/system-one-code-locator/system_one_code_locator.py subject "$QUERY" --directory-threshold "$DIRECTORY_THRESHOLD" --file-threshold "$FILE_THRESHOLD" --line-threshold "$LINE_THRESHOLD" --batch-size "$BATCH_SIZE" --trace-file "$EVIDENCE_DIR/code-locator/trace.jsonl" --output-json "$EVIDENCE_DIR/code-locator/result.json" | tee "$EVIDENCE_DIR/code-locator/stdout.log" + + - name: Build research summary + if: always() + run: | + set -euo pipefail + python3 - <<'PY' + import json, os + from pathlib import Path + + root = Path(os.environ["EVIDENCE_DIR"]) + lines = ["# System One research run", ""] + manifest = root / "run-manifest.json" + if manifest.exists(): + data = json.loads(manifest.read_text()) + lines += [ + f"- Subject: `{data['subject']['repository']}@{data['subject']['revision']}`", + f"- Query: `{data['code_locator']['query']}`", + f"- Model: `{data['model']}`", + f"- Thresholds: `{data['code_locator']['thresholds']}`", + "", + ] + result = root / "code-locator/result.json" + if result.exists(): + data = json.loads(result.read_text()) + lines += [ + "## Code locator", + "", + f"- Directories: {len(data.get('directories', []))}", + f"- Files: {len(data.get('files', []))}", + f"- Snippets: {len(data.get('snippets', []))}", + f"- Metrics: `{data.get('metrics', {})}`", + "", + "### Selected files", + "", + ] + lines += [ + f"- `{item['id']}` ({item['score']:.3f})" + for item in data.get("files", []) + ] + summary = "\n".join(lines) + "\n" + (root / "summary.md").write_text(summary) + with open(os.environ["GITHUB_STEP_SUMMARY"], "a") as handle: + handle.write(summary) + PY + + - name: Upload System One research evidence + if: always() + uses: actions/upload-artifact@v4 + with: + name: system-one-research-${{ github.run_id }}-${{ github.run_attempt }} + path: ${{ env.EVIDENCE_DIR }} + retention-days: 90 + if-no-files-found: warn From 3f7b269ec8d41330e267556f05ef6d29627db151 Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 11:55:47 +0800 Subject: [PATCH 10/46] docs: extend System One topic with code localization --- .../README.md | 58 ++++++++++++++++++- 1 file changed, 55 insertions(+), 3 deletions(-) diff --git a/docs/topics/system-one-progressive-action-space/README.md b/docs/topics/system-one-progressive-action-space/README.md index f13ae080..34d9a47d 100644 --- a/docs/topics/system-one-progressive-action-space/README.md +++ b/docs/topics/system-one-progressive-action-space/README.md @@ -587,7 +587,56 @@ The result should distinguish between tasks that are naturally frontier-driven a - Can the same runtime interface serve Kubernetes, coding, and browser environments? - How much state should be sent to System One at each branch? -## 18. Relationship to Narness +## 18. Code localization experiment + +The second reference experiment applies the same progressive-disclosure idea to source-code localization. + +```text +repository + -> directory candidates + -> relevant directories + -> file candidates + -> relevant files + -> source-line candidates + -> grounded code snippets +``` + +Unlike Kubernetes action selection, this stage is not a single-winner decision. Multiple directories, files, and source ranges can all be relevant, so the prototype uses independent Noul judgments rather than Choice. + +The harness owns traversal, filesystem IO, batching, thresholds, provenance, and range merging. System One only estimates candidate relevance. + +This broadens the working runtime abstraction: + +```text +StateSpaceGenerator + -> CandidateSet + -> DecisionPrimitive + -> TransitionPolicy + -> EvidenceRecorder +``` + +The decision primitive can therefore vary by state: + +- `Choice` for selecting one grounded action from a local frontier; +- `Noul` for independently retaining multiple relevant candidates; +- deterministic short-circuiting where model judgment is unnecessary. + +See [Hierarchical Code Localization with System One](research/code-localization.md) for the hypotheses, threshold/recall analysis, evidence contract, and experiment plan. + +## 19. Research evidence workflow + +The repository includes a dedicated workflow for these prototypes: [System One Research Demos](../../../.github/workflows/system-one-research.yml). + +It has two layers: + +1. deterministic fixture runs on relevant pushes and pull requests, requiring no external model service; +2. manually dispatched real-System-One collection against the Kubernetes fixture and a configurable subject repository. + +Each run preserves machine-readable artifacts instead of treating console output as the research record. The code-localization trace records exposed candidates, model requests without credentials, relevance scores, thresholds, latency, token usage, and final grounded snippets. + +This makes repeated runs comparable by repository revision, subject revision, query, thresholds, batch size, model, and workflow identity. + +## 20. Relationship to Narness Narness currently defines itself as AI Workspace Engineering and explicitly does not aim to become a general Agent Runtime. @@ -599,9 +648,12 @@ It is still relevant because it explores a neighboring harness-engineering quest If the conclusions stabilize, some of them may graduate into Narness concepts around progressive disclosure, capability representation, deterministic execution, policy, evidence, and agent observability without requiring Narness itself to own a runtime. -## Reference implementation +## Reference implementations -See [System One Kubernetes Command Generator](../../../examples/system-one-k8s/README.md). +- [System One Kubernetes Command Generator](../../../examples/system-one-k8s/README.md) +- [System One Code Locator](../../../examples/system-one-code-locator/README.md) +- [Code localization research note](research/code-localization.md) +- [System One research workflow](../../../.github/workflows/system-one-research.yml) ## Related Narness topics From a1d620a6a74205db10c212a091ad9fa4fff5ed69 Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 11:55:49 +0800 Subject: [PATCH 11/46] docs: index System One code locator --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 06ec4a77..2fb4dc6e 100644 --- a/README.md +++ b/README.md @@ -224,7 +224,7 @@ bash plugins/narness/scripts/narness-rust-test-integration.sh examples/rust-work The example contains a root workspace contract, a task Skill with progressive disclosure, unit and integration evidence, an environment declaration, and a stable CI required gate. -The repository also contains research prototypes that are intentionally outside the canonical Narness runtime scope, including the [System One Kubernetes command generator](examples/system-one-k8s/README.md) used by the progressive-action-space topic. +The repository also contains research prototypes that are intentionally outside the canonical Narness runtime scope, including the [System One Kubernetes command generator](examples/system-one-k8s/README.md) and [System One code locator](examples/system-one-code-locator/README.md) used by the progressive-action-space topic. ## Adopt Narness @@ -259,6 +259,7 @@ Start with [docs/adoption.md](docs/adoption.md): - [Change-to-Evidence Planning topic](docs/topics/change-to-evidence-planning/README.md) - [System One Progressive Action Spaces topic](docs/topics/system-one-progressive-action-space/README.md) - [System One Kubernetes command generator](examples/system-one-k8s/README.md) +- [System One code locator](examples/system-one-code-locator/README.md) - [AI Workspace architecture](docs/architecture.md) - [Adoption guide](docs/adoption.md) - [Runnable Rust example](examples/rust-workspace/README.md) From b9f3ce57099f0c01b7902eb950aa0c2902ee0bd6 Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 11:57:07 +0800 Subject: [PATCH 12/46] ci: harden System One evidence collection --- .github/workflows/system-one-research.yml | 26 ++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/.github/workflows/system-one-research.yml b/.github/workflows/system-one-research.yml index 7f09ad6d..812d5927 100644 --- a/.github/workflows/system-one-research.yml +++ b/.github/workflows/system-one-research.yml @@ -69,6 +69,8 @@ jobs: with: python-version: '3.13' + - name: Initialize deterministic evidence directory + run: | - name: Run demo tests run: | set -euo pipefail @@ -142,6 +144,8 @@ jobs: with: python-version: '3.13' + - name: Initialize System One evidence directory + run: | - name: Require TypeSafe credentials env: TYPESAFE_API_KEY: ${{ secrets.TYPESAFE_API_KEY }} @@ -218,7 +222,27 @@ jobs: set -euo pipefail python3 narness/examples/system-one-k8s/system_one_k8s.py "Show me the Kubernetes logs for nession in staging." --fixture narness/examples/system-one-k8s/fixtures/cluster.json --json | tee "$EVIDENCE_DIR/k8s/result.json" - python3 narness/examples/system-one-k8s/system_one_k8s.py "Show me the Kubernetes logs for nession in staging." --fixture narness/examples/system-one-k8s/fixtures/cluster.json | tee "$EVIDENCE_DIR/k8s/stdout.log" + python3 - <<'PY' + import json, os + from pathlib import Path + root = Path(os.environ["EVIDENCE_DIR"]) + state = json.loads((root / "k8s/result.json").read_text()) + lines = [ + f"goal: {state['goal']}", + f"context: {state.get('context') or '-'}", + f"phase: {state['phase']}", + "decisions:", + ] + for index, decision in enumerate(state.get("decisions", []), start=1): + confidence = decision.get("confidence") + suffix = f" confidence={confidence:.3f}" if confidence is not None else "" + lines.append( + f" {index}. {decision['action_id']} [{decision['source']}]{suffix}" + ) + if state.get("final_command"): + lines.append("final command: " + " ".join(state["final_command"])) + (root / "k8s/stdout.log").write_text("\n".join(lines) + "\n") + PY - name: Run code-localization System One demo env: From af15b3902e34b06cacbbdb3d77bf04c1867af02e Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 11:57:21 +0800 Subject: [PATCH 13/46] ci: initialize evidence roots before fallible steps --- .github/workflows/system-one-research.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/system-one-research.yml b/.github/workflows/system-one-research.yml index 812d5927..d82546d6 100644 --- a/.github/workflows/system-one-research.yml +++ b/.github/workflows/system-one-research.yml @@ -71,6 +71,10 @@ jobs: - name: Initialize deterministic evidence directory run: | + evidence="$RUNNER_TEMP/system-one-fixtures-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT" + mkdir -p "$evidence/k8s" "$evidence/code-locator" + echo "EVIDENCE_DIR=$evidence" >> "$GITHUB_ENV" + - name: Run demo tests run: | set -euo pipefail @@ -146,6 +150,10 @@ jobs: - name: Initialize System One evidence directory run: | + evidence="$RUNNER_TEMP/system-one-research-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT" + mkdir -p "$evidence/k8s" "$evidence/code-locator" + echo "EVIDENCE_DIR=$evidence" >> "$GITHUB_ENV" + - name: Require TypeSafe credentials env: TYPESAFE_API_KEY: ${{ secrets.TYPESAFE_API_KEY }} From 173ad903f50aea0c751a3ade0be2d9e13550ecb9 Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:04:12 +0800 Subject: [PATCH 14/46] ci: use typesave environment for System One [system-one-e2e] --- .github/workflows/system-one-research.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/system-one-research.yml b/.github/workflows/system-one-research.yml index d82546d6..989c5d3c 100644 --- a/.github/workflows/system-one-research.yml +++ b/.github/workflows/system-one-research.yml @@ -123,9 +123,9 @@ jobs: system-one: name: Real System One evidence - if: ${{ github.event_name == 'workflow_dispatch' && inputs.collect_system_one }} + if: ${{ (github.event_name == 'workflow_dispatch' && inputs.collect_system_one) || (github.event_name == 'push' && github.ref == 'refs/heads/research/system-one-code-localization' && contains(github.event.head_commit.message, '[system-one-e2e]')) }} runs-on: ubuntu-24.04 - environment: ds + environment: typesave timeout-minutes: 120 steps: - name: Checkout Narness harness @@ -138,8 +138,8 @@ jobs: - name: Checkout subject repository uses: actions/checkout@v4 with: - repository: ${{ inputs.subject_repository }} - ref: ${{ inputs.subject_ref }} + repository: ${{ inputs.subject_repository || 'BestNathan/nession' }} + ref: ${{ inputs.subject_ref || 'staging' }} path: subject fetch-depth: 1 persist-credentials: false @@ -166,13 +166,13 @@ jobs: - name: Initialize evidence manifest env: - QUERY: ${{ inputs.query }} - SUBJECT_REPOSITORY: ${{ inputs.subject_repository }} - SUBJECT_REF: ${{ inputs.subject_ref }} - DIRECTORY_THRESHOLD: ${{ inputs.directory_threshold }} - FILE_THRESHOLD: ${{ inputs.file_threshold }} - LINE_THRESHOLD: ${{ inputs.line_threshold }} - BATCH_SIZE: ${{ inputs.batch_size }} + QUERY: ${{ inputs.query || 'Help me optimize the websocket connection implementation' }} + SUBJECT_REPOSITORY: ${{ inputs.subject_repository || 'BestNathan/nession' }} + SUBJECT_REF: ${{ inputs.subject_ref || 'staging' }} + DIRECTORY_THRESHOLD: ${{ inputs.directory_threshold || '0.35' }} + FILE_THRESHOLD: ${{ inputs.file_threshold || '0.50' }} + LINE_THRESHOLD: ${{ inputs.line_threshold || '0.70' }} + BATCH_SIZE: ${{ inputs.batch_size || '48' }} TYPESAFE_MODEL: ${{ vars.TYPESAFE_MODEL || 'jev-latest' }} run: | set -euo pipefail From 552013a986d7d471b74c1e8b2a6589f7df3cf032 Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:04:48 +0800 Subject: [PATCH 15/46] ci: read TypeSafe key from typesave env [system-one-e2e] --- .github/workflows/system-one-research.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/system-one-research.yml b/.github/workflows/system-one-research.yml index 989c5d3c..c3cad0e3 100644 --- a/.github/workflows/system-one-research.yml +++ b/.github/workflows/system-one-research.yml @@ -156,11 +156,11 @@ jobs: - name: Require TypeSafe credentials env: - TYPESAFE_API_KEY: ${{ secrets.TYPESAFE_API_KEY }} + TYPESAFE_API_KEY: ${{ secrets.TYPESAFE_API_KEY || vars.TYPESAFE_API_KEY }} run: | set -euo pipefail test -n "$TYPESAFE_API_KEY" || { - echo 'Set TYPESAFE_API_KEY in the ds environment.' >&2 + echo 'Set TYPESAFE_API_KEY in the typesave environment.' >&2 exit 2 } @@ -223,7 +223,7 @@ jobs: - name: Run Kubernetes System One demo env: - TYPESAFE_API_KEY: ${{ secrets.TYPESAFE_API_KEY }} + TYPESAFE_API_KEY: ${{ secrets.TYPESAFE_API_KEY || vars.TYPESAFE_API_KEY }} TYPESAFE_API_URL: ${{ vars.TYPESAFE_API_URL || 'https://api.typesafe.ai/v1/systemone' }} TYPESAFE_MODEL: ${{ vars.TYPESAFE_MODEL || 'jev-latest' }} run: | @@ -254,7 +254,7 @@ jobs: - name: Run code-localization System One demo env: - TYPESAFE_API_KEY: ${{ secrets.TYPESAFE_API_KEY }} + TYPESAFE_API_KEY: ${{ secrets.TYPESAFE_API_KEY || vars.TYPESAFE_API_KEY }} TYPESAFE_API_URL: ${{ vars.TYPESAFE_API_URL || 'https://api.typesafe.ai/v1/systemone' }} TYPESAFE_MODEL: ${{ vars.TYPESAFE_MODEL || 'jev-latest' }} QUERY: ${{ inputs.query }} From f276455de923a8328a636ab942e0c836dd60d7eb Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:05:53 +0800 Subject: [PATCH 16/46] ci: bind System One research to typesafe env [system-one-e2e] --- .github/workflows/system-one-research.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/system-one-research.yml b/.github/workflows/system-one-research.yml index c3cad0e3..c71d2bfe 100644 --- a/.github/workflows/system-one-research.yml +++ b/.github/workflows/system-one-research.yml @@ -125,7 +125,7 @@ jobs: name: Real System One evidence if: ${{ (github.event_name == 'workflow_dispatch' && inputs.collect_system_one) || (github.event_name == 'push' && github.ref == 'refs/heads/research/system-one-code-localization' && contains(github.event.head_commit.message, '[system-one-e2e]')) }} runs-on: ubuntu-24.04 - environment: typesave + environment: typesafe timeout-minutes: 120 steps: - name: Checkout Narness harness From fc44a79478174b86f7c74616a1cce3cbb15d562c Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:06:41 +0800 Subject: [PATCH 17/46] ci: keep System One collection manual on typesave env --- .github/workflows/system-one-research.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/system-one-research.yml b/.github/workflows/system-one-research.yml index c71d2bfe..af076150 100644 --- a/.github/workflows/system-one-research.yml +++ b/.github/workflows/system-one-research.yml @@ -123,9 +123,9 @@ jobs: system-one: name: Real System One evidence - if: ${{ (github.event_name == 'workflow_dispatch' && inputs.collect_system_one) || (github.event_name == 'push' && github.ref == 'refs/heads/research/system-one-code-localization' && contains(github.event.head_commit.message, '[system-one-e2e]')) }} + if: ${{ github.event_name == 'workflow_dispatch' && inputs.collect_system_one }} runs-on: ubuntu-24.04 - environment: typesafe + environment: typesave timeout-minutes: 120 steps: - name: Checkout Narness harness From 2c51ccffb21d037922bb2e3d9f0d8acf5ae27976 Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:08:17 +0800 Subject: [PATCH 18/46] ci: use correct typesafe environment --- .github/workflows/system-one-research.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/system-one-research.yml b/.github/workflows/system-one-research.yml index af076150..979714bb 100644 --- a/.github/workflows/system-one-research.yml +++ b/.github/workflows/system-one-research.yml @@ -125,7 +125,7 @@ jobs: name: Real System One evidence if: ${{ github.event_name == 'workflow_dispatch' && inputs.collect_system_one }} runs-on: ubuntu-24.04 - environment: typesave + environment: typesafe timeout-minutes: 120 steps: - name: Checkout Narness harness From 138dac2a64b8994eb55177358a02da29992115f6 Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:08:30 +0800 Subject: [PATCH 19/46] ci: trigger System One e2e on typesafe [system-one-e2e] --- .github/workflows/system-one-research.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/system-one-research.yml b/.github/workflows/system-one-research.yml index 979714bb..c71d2bfe 100644 --- a/.github/workflows/system-one-research.yml +++ b/.github/workflows/system-one-research.yml @@ -123,7 +123,7 @@ jobs: system-one: name: Real System One evidence - if: ${{ github.event_name == 'workflow_dispatch' && inputs.collect_system_one }} + if: ${{ (github.event_name == 'workflow_dispatch' && inputs.collect_system_one) || (github.event_name == 'push' && github.ref == 'refs/heads/research/system-one-code-localization' && contains(github.event.head_commit.message, '[system-one-e2e]')) }} runs-on: ubuntu-24.04 environment: typesafe timeout-minutes: 120 From 367121ab5a28ec4c603970c318795667eea91b4f Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:09:19 +0800 Subject: [PATCH 20/46] ci: finalize typesafe environment wiring --- .github/workflows/system-one-research.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/system-one-research.yml b/.github/workflows/system-one-research.yml index c71d2bfe..d7fa6ae9 100644 --- a/.github/workflows/system-one-research.yml +++ b/.github/workflows/system-one-research.yml @@ -123,7 +123,7 @@ jobs: system-one: name: Real System One evidence - if: ${{ (github.event_name == 'workflow_dispatch' && inputs.collect_system_one) || (github.event_name == 'push' && github.ref == 'refs/heads/research/system-one-code-localization' && contains(github.event.head_commit.message, '[system-one-e2e]')) }} + if: ${{ github.event_name == 'workflow_dispatch' && inputs.collect_system_one }} runs-on: ubuntu-24.04 environment: typesafe timeout-minutes: 120 @@ -160,7 +160,7 @@ jobs: run: | set -euo pipefail test -n "$TYPESAFE_API_KEY" || { - echo 'Set TYPESAFE_API_KEY in the typesave environment.' >&2 + echo 'Set TYPESAFE_API_KEY in the typesafe environment.' >&2 exit 2 } From 7f8f3e14cc9d8e38e4809a2bc41fa2194111841b Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:15:58 +0800 Subject: [PATCH 21/46] ci: rerun System One e2e [system-one-e2e] --- .github/workflows/system-one-research.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/system-one-research.yml b/.github/workflows/system-one-research.yml index d7fa6ae9..ca02b07f 100644 --- a/.github/workflows/system-one-research.yml +++ b/.github/workflows/system-one-research.yml @@ -123,7 +123,7 @@ jobs: system-one: name: Real System One evidence - if: ${{ github.event_name == 'workflow_dispatch' && inputs.collect_system_one }} + if: ${{ (github.event_name == 'workflow_dispatch' && inputs.collect_system_one) || (github.event_name == 'push' && github.ref == 'refs/heads/research/system-one-code-localization' && contains(github.event.head_commit.message, '[system-one-e2e]')) }} runs-on: ubuntu-24.04 environment: typesafe timeout-minutes: 120 From 0799b2c44b841474d33de844d61c15cc67d6e77d Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:16:57 +0800 Subject: [PATCH 22/46] ci: default code locator inputs during e2e [system-one-e2e] --- .github/workflows/system-one-research.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/system-one-research.yml b/.github/workflows/system-one-research.yml index ca02b07f..e0377b08 100644 --- a/.github/workflows/system-one-research.yml +++ b/.github/workflows/system-one-research.yml @@ -257,11 +257,11 @@ jobs: TYPESAFE_API_KEY: ${{ secrets.TYPESAFE_API_KEY || vars.TYPESAFE_API_KEY }} TYPESAFE_API_URL: ${{ vars.TYPESAFE_API_URL || 'https://api.typesafe.ai/v1/systemone' }} TYPESAFE_MODEL: ${{ vars.TYPESAFE_MODEL || 'jev-latest' }} - QUERY: ${{ inputs.query }} - DIRECTORY_THRESHOLD: ${{ inputs.directory_threshold }} - FILE_THRESHOLD: ${{ inputs.file_threshold }} - LINE_THRESHOLD: ${{ inputs.line_threshold }} - BATCH_SIZE: ${{ inputs.batch_size }} + QUERY: ${{ inputs.query || 'Help me optimize the websocket connection implementation' }} + DIRECTORY_THRESHOLD: ${{ inputs.directory_threshold || '0.35' }} + FILE_THRESHOLD: ${{ inputs.file_threshold || '0.50' }} + LINE_THRESHOLD: ${{ inputs.line_threshold || '0.70' }} + BATCH_SIZE: ${{ inputs.batch_size || '48' }} run: | set -euo pipefail python3 narness/examples/system-one-code-locator/system_one_code_locator.py subject "$QUERY" --directory-threshold "$DIRECTORY_THRESHOLD" --file-threshold "$FILE_THRESHOLD" --line-threshold "$LINE_THRESHOLD" --batch-size "$BATCH_SIZE" --trace-file "$EVIDENCE_DIR/code-locator/trace.jsonl" --output-json "$EVIDENCE_DIR/code-locator/result.json" | tee "$EVIDENCE_DIR/code-locator/stdout.log" From 13d1221d6756fef5625c0c667a5e2fe5cc835a8b Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:20:14 +0800 Subject: [PATCH 23/46] fix: project code literals before System One transport [system-one-e2e] --- .../system_one_code_locator.py | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/examples/system-one-code-locator/system_one_code_locator.py b/examples/system-one-code-locator/system_one_code_locator.py index 5b815fe4..60b90a80 100644 --- a/examples/system-one-code-locator/system_one_code_locator.py +++ b/examples/system-one-code-locator/system_one_code_locator.py @@ -22,6 +22,31 @@ def emit(self, event, **data): with self.path.open("a", encoding="utf-8") as f: f.write(json.dumps(record, ensure_ascii=False, sort_keys=True) + "\n") +def model_projection(stage, payload): + """Project raw candidates into a transport-safe semantic view for the model. + + Raw candidates remain in the local evidence trace. Source-line projections + normalize literal values so repository security tests do not look like live + attack payloads to an upstream WAF, while identifiers and code structure + remain visible to System One. + """ + if stage != "line": + return payload + projected = dict(payload) + patterns = [ + (r'"(?:\\.|[^"\\])*"', '""'), + (r"'(?:\\.|[^'\\])*'", "''"), + (r'`(?:\\.|[^`\\])*`', '``'), + ] + for key in ("text", "nearby_lines"): + value = projected.get(key) + if not isinstance(value, str): + continue + for pattern, replacement in patterns: + value = re.sub(pattern, replacement, value) + projected[key] = value + return projected + class SystemOneScorer: def __init__(self, key, trace, endpoint=API_URL, model=MODEL, batch_size=48): self.key, self.trace, self.endpoint, self.model, self.batch_size = key, trace, endpoint, model, batch_size @@ -45,7 +70,7 @@ def score(self, query, stage, candidates): for i, candidate in enumerate(batch): questions[f"candidate_{i}"] = { "type": "noul", - "instructions": {"task": query, "stage": stage, "candidate": candidate["payload"], "question": "Would retaining this candidate materially help locate or understand source code relevant to the task?"}, + "instructions": {"task": query, "stage": stage, "candidate": model_projection(stage, candidate["payload"]), "question": "Would retaining this candidate materially help locate or understand source code relevant to the task?"}, "criteria": {"true": "Plausibly relevant; keep it, including indirect supporting code.", "false": "Unlikely to help locate or understand the requested implementation."}, } payload = {"state": {"goal": query, "stage": stage, "candidate_count": len(batch)}, "model": self.model, "questions": questions} From 852abe8cb8d340128d4e1de590e5d2e21723987d Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:23:44 +0800 Subject: [PATCH 24/46] ci: restore manual System One collection --- .github/workflows/system-one-research.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/system-one-research.yml b/.github/workflows/system-one-research.yml index e0377b08..f52aa25b 100644 --- a/.github/workflows/system-one-research.yml +++ b/.github/workflows/system-one-research.yml @@ -123,7 +123,7 @@ jobs: system-one: name: Real System One evidence - if: ${{ (github.event_name == 'workflow_dispatch' && inputs.collect_system_one) || (github.event_name == 'push' && github.ref == 'refs/heads/research/system-one-code-localization' && contains(github.event.head_commit.message, '[system-one-e2e]')) }} + if: ${{ github.event_name == 'workflow_dispatch' && inputs.collect_system_one }} runs-on: ubuntu-24.04 environment: typesafe timeout-minutes: 120 From 86e6503826771047be5be60850a9d3c43c0e44d5 Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:24:18 +0800 Subject: [PATCH 25/46] docs: record first real System One localization pilot --- .../nession-websocket-pilot-2026-09-23.md | 188 ++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100644 docs/topics/system-one-progressive-action-space/research/nession-websocket-pilot-2026-09-23.md diff --git a/docs/topics/system-one-progressive-action-space/research/nession-websocket-pilot-2026-09-23.md b/docs/topics/system-one-progressive-action-space/research/nession-websocket-pilot-2026-09-23.md new file mode 100644 index 00000000..07867814 --- /dev/null +++ b/docs/topics/system-one-progressive-action-space/research/nession-websocket-pilot-2026-09-23.md @@ -0,0 +1,188 @@ +# Pilot Run: Nession WebSocket Localization + +> Date: 2026-09-23 +> Workflow run: 35817921653 +> Subject: `BestNathan/nession@f6a08b41c946574cc14343c4c3bb808bc402e49f` +> Model: `jev-latest` + +## Query + +> Help me optimize the websocket connection implementation + +## Parameters + +```text +directory threshold = 0.35 +file threshold = 0.50 +line threshold = 0.70 +batch size = 48 +``` + +## Outcome + +The real System One workflow completed successfully and produced a full research artifact. + +The highest-scoring files were strongly aligned with the requested implementation: + +| Score | File | +|---:|---| +| 0.93 | `crates/nession-server/src/server/websocket.rs` | +| 0.92 | `crates/nession-agent/src/server/websocket.rs` | +| 0.91 | `web/src/platform/socket/WebSocketService.ts` | +| 0.88 | `web/src/shared/hooks/useWebSocket.ts` | +| 0.86 | `crates/nession-cli/src/client/connection.rs` | +| 0.86 | `web/src/app/useAppConnection.ts` | +| 0.86 | `web/src/platform/terminal-runtime/ConnectionManager.ts` | +| 0.84 | `web/src/platform/attach/relayServerConnection.ts` | + +The top snippets also landed on concrete WebSocket lifecycle behavior, including: + +- server-side ping/heartbeat handling; +- WebSocket accept/split and connection setup; +- reconnect and visibility-reconnect behavior; +- client/agent WebSocket message loops; +- connection-management code. + +This is evidence that repeated System One relevance judgments can recover semantically useful implementation surfaces without a ReAct browsing loop. + +## Cost and search-space behavior + +The same run also exposed a major weakness in the first prototype: + +```text +directories exposed = 382 +directories selected = 88 + +files exposed = 1040 +files selected = 92 + +lines exposed = 25,189 +lines selected = 1,308 + +snippets = 370 + +model calls = 601 +input tokens = 5,808,879 +output tokens = 502,109 +elapsed = 125.7 s +``` + +The result quality was promising, but the search policy was too permissive. + +The main problem is not System One latency itself. The harness exposes too much state before applying a sufficiently strong budget. + +In particular: + +1. the prototype enumerates the whole directory tree before semantic pruning; +2. a low directory threshold retains many overlapping parent/child directories; +3. file discovery under those directories exposes a very large union of files; +4. every retained file is then expanded into line candidates. + +This creates multiplicative fan-out: + +```text +weak early pruning + -> many directories + -> many files + -> many lines + -> many System One questions +``` + +The pilot therefore supports the original hypothesis that early-stage recall matters, but also shows that threshold-only retention is not enough. + +## Transport-boundary finding + +An earlier attempt reached a Cloudflare 403 while scoring source lines. + +The blocked batch contained security-test code such as a path-traversal fixture: + +```text +../etc/passwd +``` + +The API key and endpoint were valid: the Kubernetes System One experiment completed successfully in the same job. + +The fix was to separate **raw evidence** from the **model transport projection**: + +```text +raw source candidate + -> preserved in local trace + +model projection + -> normalize string literal values + -> preserve identifiers / types / control flow + -> send to System One +``` + +This allowed the real code-localization run to complete while keeping the original source in the research artifact. + +This suggests a broader harness principle: + +> External model transport is itself an execution boundary. The runtime may need a safe semantic projection of observed state instead of blindly forwarding raw environment bytes. + +## Updated working hypothesis + +The pilot suggests that the next version should move from threshold-only breadth-first filtering toward a bounded semantic search policy. + +A stronger policy is: + +```text +current frontier + -> System One score + -> retain above threshold + -> guarantee a minimum beam + -> enforce a maximum expansion budget + -> expand only retained states +``` + +For repository localization, the likely next hierarchy is: + +```text +root + -> immediate child directories + -> recursively selected directories + -> files + -> symbols / blocks + -> lines +``` + +This is preferable to globally enumerating every directory before the first judgment. + +## Next experiment + +The next comparison should hold the query and subject revision constant and compare: + +### Baseline A — current prototype + +```text +whole-tree directories +-> threshold +-> files +-> threshold +-> lines +``` + +### Candidate B — recursive semantic beam + +```text +root children +-> score +-> threshold + top-k +-> expand selected children +-> repeat +-> files +-> symbols +-> lines +``` + +Measure: + +- relevant-file recall; +- model calls; +- input/output tokens; +- elapsed time; +- candidates exposed at each level; +- stage where any expected file is first pruned; +- final snippet quality. + +The goal is not merely to make the current search cheaper. It is to test whether **progressive state disclosure plus a bounded semantic frontier** is the right primitive for System One code navigation. From a8e3e270deb59f392f816ebb862ffdd7c1f25c8e Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:24:49 +0800 Subject: [PATCH 26/46] docs: add stage cost breakdown to System One pilot --- .../research/nession-websocket-pilot-2026-09-23.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/topics/system-one-progressive-action-space/research/nession-websocket-pilot-2026-09-23.md b/docs/topics/system-one-progressive-action-space/research/nession-websocket-pilot-2026-09-23.md index 07867814..a6c6a1e1 100644 --- a/docs/topics/system-one-progressive-action-space/research/nession-websocket-pilot-2026-09-23.md +++ b/docs/topics/system-one-progressive-action-space/research/nession-websocket-pilot-2026-09-23.md @@ -62,12 +62,19 @@ lines selected = 1,308 snippets = 370 model calls = 601 + directory = 8 + file = 22 + line = 571 + input tokens = 5,808,879 + directory = 67,063 + file = 165,449 + line = 5,576,367 output tokens = 502,109 elapsed = 125.7 s ``` -The result quality was promising, but the search policy was too permissive. +The result quality was promising, but the search policy was too permissive. Line expansion alone accounted for 571 of 601 model calls and about 96% of input tokens. The main problem is not System One latency itself. The harness exposes too much state before applying a sufficiently strong budget. From 0ce60909236d8a24c7d9532d0c5d4ae48821ff81 Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:24:52 +0800 Subject: [PATCH 27/46] docs: link real System One localization evidence --- .../research/code-localization.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/topics/system-one-progressive-action-space/research/code-localization.md b/docs/topics/system-one-progressive-action-space/research/code-localization.md index 43708fe5..9ba9e583 100644 --- a/docs/topics/system-one-progressive-action-space/research/code-localization.md +++ b/docs/topics/system-one-progressive-action-space/research/code-localization.md @@ -254,6 +254,12 @@ That enables: 6. Compare System One localization against a System Two coding agent under the same gold tasks and evidence contract. 7. Test a System One -> System Two handoff where the fast locator supplies grounded code context to the reasoning model. +## Pilot evidence + +- [Nession WebSocket localization pilot — 2026-09-23](nession-websocket-pilot-2026-09-23.md) + +The first real run confirmed useful semantic localization, while also showing that threshold-only whole-tree search spends most of its cost at the line layer. This is the baseline for the next recursive-beam / symbol-level experiment. + ## Reference implementation See [System One Code Locator](../../../examples/system-one-code-locator/README.md). From aeed8843248d5f693bddcd58642ab1e09280940d Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:29:18 +0800 Subject: [PATCH 28/46] ci: split code locator into dedicated workflow --- .github/workflows/system-one-code-locator.yml | 332 ++++++++++++++++++ 1 file changed, 332 insertions(+) create mode 100644 .github/workflows/system-one-code-locator.yml diff --git a/.github/workflows/system-one-code-locator.yml b/.github/workflows/system-one-code-locator.yml new file mode 100644 index 00000000..040da178 --- /dev/null +++ b/.github/workflows/system-one-code-locator.yml @@ -0,0 +1,332 @@ +name: system-one-code-locator-experiment + +on: + push: + paths: + - "examples/system-one-code-locator/**" + - "docs/topics/system-one-progressive-action-space/research/code-localization.md" + - "docs/topics/system-one-progressive-action-space/research/nession-websocket-pilot-2026-09-23.md" + - ".github/workflows/system-one-code-locator.yml" + pull_request: + paths: + - "examples/system-one-code-locator/**" + - "docs/topics/system-one-progressive-action-space/research/code-localization.md" + - "docs/topics/system-one-progressive-action-space/research/nession-websocket-pilot-2026-09-23.md" + - ".github/workflows/system-one-code-locator.yml" + workflow_dispatch: + inputs: + subject_repository: + description: Repository used by the code-localization experiment + required: true + default: BestNathan/nession + type: string + subject_ref: + description: Git ref of the subject repository + required: true + default: staging + type: string + query: + description: Code-localization task + required: true + default: Help me optimize the websocket connection implementation + type: string + directory_threshold: + description: Directory Noul threshold + required: true + default: "0.35" + type: string + file_threshold: + description: File Noul threshold + required: true + default: "0.50" + type: string + line_threshold: + description: Source-line Noul threshold + required: true + default: "0.70" + type: string + batch_size: + description: Noul questions per TypeSafe request + required: true + default: "48" + type: string + model: + description: TypeSafe model alias + required: true + default: jev-latest + type: string + run_typesafe: + description: Run the real TypeSafe System One experiment + required: true + default: false + type: boolean + +permissions: + contents: read + +concurrency: + group: system-one-code-locator-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + +env: + QUERY: ${{ inputs.query || 'Help me optimize the websocket connection implementation' }} + DIRECTORY_THRESHOLD: ${{ inputs.directory_threshold || '0.35' }} + FILE_THRESHOLD: ${{ inputs.file_threshold || '0.50' }} + LINE_THRESHOLD: ${{ inputs.line_threshold || '0.70' }} + BATCH_SIZE: ${{ inputs.batch_size || '48' }} + TYPESAFE_MODEL: ${{ inputs.model || vars.TYPESAFE_MODEL || 'jev-latest' }} + +jobs: + offline: + name: Offline code-locator validation + runs-on: ubuntu-24.04 + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.13" + + - name: Prepare artifact directory + run: mkdir -p artifacts/system-one-code-locator/offline + + - name: Run unit tests + shell: bash + run: | + set -o pipefail + python3 -m unittest discover -s examples/system-one-code-locator -p 'test_*.py' -v 2>&1 | tee artifacts/system-one-code-locator/offline/tests.log + + - name: Run deterministic fixture experiment + shell: bash + run: | + set -o pipefail + python3 examples/system-one-code-locator/system_one_code_locator.py examples/system-one-code-locator/fixtures/repository "$QUERY" --offline-decider --directory-threshold "$DIRECTORY_THRESHOLD" --file-threshold "$FILE_THRESHOLD" --line-threshold 0.60 --batch-size "$BATCH_SIZE" --trace-file artifacts/system-one-code-locator/offline/trace.jsonl --output-json artifacts/system-one-code-locator/offline/result.json 2>&1 | tee artifacts/system-one-code-locator/offline/run.log + + - name: Save run metadata and summary + env: + RUN_ID: ${{ github.run_id }} + RUN_ATTEMPT: ${{ github.run_attempt }} + COMMIT_SHA: ${{ github.sha }} + REF_NAME: ${{ github.ref_name }} + run: | + python3 - <<'PY' + import json + import os + from pathlib import Path + + root = Path("artifacts/system-one-code-locator/offline") + result = json.loads((root / "result.json").read_text()) + + metadata = { + "schema_version": 1, + "mode": "offline", + "query": os.environ["QUERY"], + "model": "offline-lexical-fixture", + "thresholds": { + "directory": float(os.environ["DIRECTORY_THRESHOLD"]), + "file": float(os.environ["FILE_THRESHOLD"]), + "line": 0.60, + }, + "batch_size": int(os.environ["BATCH_SIZE"]), + "github_run_id": os.environ["RUN_ID"], + "github_run_attempt": os.environ["RUN_ATTEMPT"], + "commit_sha": os.environ["COMMIT_SHA"], + "ref_name": os.environ["REF_NAME"], + } + (root / "run-manifest.json").write_text( + json.dumps(metadata, indent=2) + "\n", + encoding="utf-8", + ) + + lines = [ + "# System One Code Locator — offline fixture", + "", + f"- Query: `{metadata['query']}`", + f"- Directories: {len(result.get('directories', []))}", + f"- Files: {len(result.get('files', []))}", + f"- Snippets: {len(result.get('snippets', []))}", + f"- Metrics: `{result.get('metrics', {})}`", + ] + (root / "summary.md").write_text("\n".join(lines) + "\n") + PY + + - name: Publish summary + if: always() + run: | + if test -f artifacts/system-one-code-locator/offline/summary.md; then + cat artifacts/system-one-code-locator/offline/summary.md >> "$GITHUB_STEP_SUMMARY" + fi + + - name: Upload offline experiment artifacts + if: always() + uses: actions/upload-artifact@v4 + with: + name: system-one-code-locator-offline-${{ github.run_id }}-${{ github.run_attempt }} + path: artifacts/system-one-code-locator/offline/ + if-no-files-found: error + retention-days: 90 + + typesafe: + name: Real TypeSafe code-locator experiment + if: ${{ github.event_name == 'workflow_dispatch' && inputs.run_typesafe }} + runs-on: ubuntu-24.04 + environment: typesafe + timeout-minutes: 120 + + steps: + - name: Checkout Narness harness + uses: actions/checkout@v4 + with: + path: narness + fetch-depth: 1 + persist-credentials: false + + - name: Checkout subject repository + uses: actions/checkout@v4 + with: + repository: ${{ inputs.subject_repository }} + ref: ${{ inputs.subject_ref }} + path: subject + fetch-depth: 1 + persist-credentials: false + + - uses: actions/setup-python@v5 + with: + python-version: "3.13" + + - name: Require TypeSafe credentials + env: + TYPESAFE_API_KEY: ${{ secrets.TYPESAFE_API_KEY || vars.TYPESAFE_API_KEY }} + run: | + test -n "$TYPESAFE_API_KEY" || { + echo "TYPESAFE_API_KEY is required in the typesafe environment." >&2 + exit 2 + } + + - name: Prepare artifact directory + run: mkdir -p artifacts/system-one-code-locator/typesafe + + - name: Save run manifest + env: + SUBJECT_REPOSITORY: ${{ inputs.subject_repository }} + SUBJECT_REF: ${{ inputs.subject_ref }} + RUN_ID: ${{ github.run_id }} + RUN_ATTEMPT: ${{ github.run_attempt }} + HARNESS_SHA: ${{ github.sha }} + run: | + python3 - <<'PY' + import json + import os + import subprocess + from pathlib import Path + + def revision(path): + return subprocess.check_output( + ["git", "-C", path, "rev-parse", "HEAD"], + text=True, + ).strip() + + payload = { + "schema_version": 1, + "mode": "typesafe", + "query": os.environ["QUERY"], + "model": os.environ["TYPESAFE_MODEL"], + "thresholds": { + "directory": float(os.environ["DIRECTORY_THRESHOLD"]), + "file": float(os.environ["FILE_THRESHOLD"]), + "line": float(os.environ["LINE_THRESHOLD"]), + }, + "batch_size": int(os.environ["BATCH_SIZE"]), + "harness": { + "repository": os.environ.get("GITHUB_REPOSITORY"), + "revision": revision("narness"), + }, + "subject": { + "repository": os.environ["SUBJECT_REPOSITORY"], + "requested_ref": os.environ["SUBJECT_REF"], + "revision": revision("subject"), + }, + "github_run_id": os.environ["RUN_ID"], + "github_run_attempt": os.environ["RUN_ATTEMPT"], + } + root = Path("artifacts/system-one-code-locator/typesafe") + (root / "run-manifest.json").write_text( + json.dumps(payload, indent=2) + "\n", + encoding="utf-8", + ) + PY + + - name: Run real System One code locator + env: + TYPESAFE_API_KEY: ${{ secrets.TYPESAFE_API_KEY || vars.TYPESAFE_API_KEY }} + TYPESAFE_API_URL: ${{ vars.TYPESAFE_API_URL || 'https://api.typesafe.ai/v1/systemone' }} + shell: bash + run: | + set -o pipefail + python3 narness/examples/system-one-code-locator/system_one_code_locator.py subject "$QUERY" --directory-threshold "$DIRECTORY_THRESHOLD" --file-threshold "$FILE_THRESHOLD" --line-threshold "$LINE_THRESHOLD" --batch-size "$BATCH_SIZE" --model "$TYPESAFE_MODEL" --trace-file artifacts/system-one-code-locator/typesafe/trace.jsonl --output-json artifacts/system-one-code-locator/typesafe/result.json 2>&1 | tee artifacts/system-one-code-locator/typesafe/run.log + + - name: Build research summary + if: always() + run: | + python3 - <<'PY' + import json + from pathlib import Path + + root = Path("artifacts/system-one-code-locator/typesafe") + manifest_path = root / "run-manifest.json" + result_path = root / "result.json" + + lines = ["# System One Code Locator — TypeSafe run", ""] + + if manifest_path.exists(): + manifest = json.loads(manifest_path.read_text()) + lines += [ + f"- Subject: `{manifest['subject']['repository']}@{manifest['subject']['revision']}`", + f"- Query: `{manifest['query']}`", + f"- Model: `{manifest['model']}`", + f"- Thresholds: `{manifest['thresholds']}`", + "", + ] + + if result_path.exists(): + result = json.loads(result_path.read_text()) + lines += [ + "## Result", + "", + f"- Directories: {len(result.get('directories', []))}", + f"- Files: {len(result.get('files', []))}", + f"- Snippets: {len(result.get('snippets', []))}", + f"- Metrics: `{result.get('metrics', {})}`", + "", + "### Selected files", + "", + ] + lines += [ + f"- `{item['id']}` ({item['score']:.3f})" + for item in result.get("files", []) + ] + else: + lines += [ + "## Result", + "", + "The experiment did not produce result.json. Inspect run.log and trace.jsonl.", + ] + + summary = "\n".join(lines) + "\n" + (root / "summary.md").write_text(summary) + with open(Path(os.environ["GITHUB_STEP_SUMMARY"]), "a") as handle: + handle.write(summary) + PY + env: + PYTHONUNBUFFERED: "1" + + - name: Upload TypeSafe experiment artifacts + if: always() + uses: actions/upload-artifact@v4 + with: + name: system-one-code-locator-typesafe-${{ github.run_id }}-${{ github.run_attempt }} + path: artifacts/system-one-code-locator/typesafe/ + if-no-files-found: warn + retention-days: 90 From 9d35fd2e05ae183ad8ec16c874b47a4c2261af4a Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:29:45 +0800 Subject: [PATCH 29/46] ci: finalize dedicated code locator workflow --- .github/workflows/system-one-code-locator.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/system-one-code-locator.yml b/.github/workflows/system-one-code-locator.yml index 040da178..c1c236ae 100644 --- a/.github/workflows/system-one-code-locator.yml +++ b/.github/workflows/system-one-code-locator.yml @@ -272,6 +272,7 @@ jobs: run: | python3 - <<'PY' import json + import os from pathlib import Path root = Path("artifacts/system-one-code-locator/typesafe") From f388d6de5e988c0ff10a2c42b3def67257ba2828 Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:29:53 +0800 Subject: [PATCH 30/46] ci: remove mixed System One research workflow --- .github/workflows/system-one-research.yml | 320 ---------------------- 1 file changed, 320 deletions(-) delete mode 100644 .github/workflows/system-one-research.yml diff --git a/.github/workflows/system-one-research.yml b/.github/workflows/system-one-research.yml deleted file mode 100644 index f52aa25b..00000000 --- a/.github/workflows/system-one-research.yml +++ /dev/null @@ -1,320 +0,0 @@ -name: System One Research Demos - -on: - push: - paths: - - 'examples/system-one-k8s/**' - - 'examples/system-one-code-locator/**' - - 'docs/topics/system-one-progressive-action-space/**' - - '.github/workflows/system-one-research.yml' - pull_request: - paths: - - 'examples/system-one-k8s/**' - - 'examples/system-one-code-locator/**' - - 'docs/topics/system-one-progressive-action-space/**' - - '.github/workflows/system-one-research.yml' - workflow_dispatch: - inputs: - subject_repository: - description: Repository used by the code-localization experiment - required: true - default: BestNathan/nession - type: string - subject_ref: - description: Git ref of the subject repository - required: true - default: staging - type: string - query: - description: Code-localization task - required: true - default: Help me optimize the websocket connection implementation - type: string - directory_threshold: - description: Directory Noul threshold - required: true - default: '0.35' - type: string - file_threshold: - description: File Noul threshold - required: true - default: '0.50' - type: string - line_threshold: - description: Source-line Noul threshold - required: true - default: '0.70' - type: string - batch_size: - description: Noul questions per TypeSafe request - required: true - default: '48' - type: string - collect_system_one: - description: Call the real TypeSafe System One API - required: true - default: true - type: boolean - -permissions: - contents: read - -jobs: - fixtures: - name: Deterministic fixture evidence - runs-on: ubuntu-24.04 - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: '3.13' - - - name: Initialize deterministic evidence directory - run: | - evidence="$RUNNER_TEMP/system-one-fixtures-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT" - mkdir -p "$evidence/k8s" "$evidence/code-locator" - echo "EVIDENCE_DIR=$evidence" >> "$GITHUB_ENV" - - - name: Run demo tests - run: | - set -euo pipefail - python3 -m unittest discover -s examples/system-one-k8s -p 'test_*.py' -v - python3 -m unittest discover -s examples/system-one-code-locator -p 'test_*.py' -v - - - name: Collect deterministic evidence - run: | - set -euo pipefail - evidence="$RUNNER_TEMP/system-one-fixtures-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT" - mkdir -p "$evidence/k8s" "$evidence/code-locator" - echo "EVIDENCE_DIR=$evidence" >> "$GITHUB_ENV" - - python3 examples/system-one-k8s/system_one_k8s.py "Show me the Kubernetes logs for nession in staging." --fixture examples/system-one-k8s/fixtures/cluster.json --offline-decider --json | tee "$evidence/k8s/result.json" - - python3 examples/system-one-k8s/system_one_k8s.py "Show me the Kubernetes logs for nession in staging." --fixture examples/system-one-k8s/fixtures/cluster.json --offline-decider | tee "$evidence/k8s/stdout.log" - - python3 examples/system-one-code-locator/system_one_code_locator.py examples/system-one-code-locator/fixtures/repository "Help me optimize the websocket connection implementation" --offline-decider --line-threshold 0.60 --trace-file "$evidence/code-locator/trace.jsonl" --output-json "$evidence/code-locator/result.json" | tee "$evidence/code-locator/stdout.log" - - python3 - <<'PY' - import json, os - from pathlib import Path - root = Path(os.environ["EVIDENCE_DIR"]) - manifest = { - "schema_version": 1, - "kind": "system-one-deterministic-fixture-evidence", - "github": { - "repository": os.environ.get("GITHUB_REPOSITORY"), - "sha": os.environ.get("GITHUB_SHA"), - "run_id": os.environ.get("GITHUB_RUN_ID"), - "run_attempt": os.environ.get("GITHUB_RUN_ATTEMPT"), - }, - "experiments": ["system-one-k8s", "system-one-code-locator"], - } - (root / "run-manifest.json").write_text(json.dumps(manifest, indent=2) + "\n") - PY - - - name: Upload deterministic research evidence - if: always() - uses: actions/upload-artifact@v4 - with: - name: system-one-fixtures-${{ github.run_id }}-${{ github.run_attempt }} - path: ${{ env.EVIDENCE_DIR }} - retention-days: 90 - if-no-files-found: warn - - system-one: - name: Real System One evidence - if: ${{ github.event_name == 'workflow_dispatch' && inputs.collect_system_one }} - runs-on: ubuntu-24.04 - environment: typesafe - timeout-minutes: 120 - steps: - - name: Checkout Narness harness - uses: actions/checkout@v4 - with: - path: narness - fetch-depth: 0 - persist-credentials: false - - - name: Checkout subject repository - uses: actions/checkout@v4 - with: - repository: ${{ inputs.subject_repository || 'BestNathan/nession' }} - ref: ${{ inputs.subject_ref || 'staging' }} - path: subject - fetch-depth: 1 - persist-credentials: false - - - uses: actions/setup-python@v5 - with: - python-version: '3.13' - - - name: Initialize System One evidence directory - run: | - evidence="$RUNNER_TEMP/system-one-research-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT" - mkdir -p "$evidence/k8s" "$evidence/code-locator" - echo "EVIDENCE_DIR=$evidence" >> "$GITHUB_ENV" - - - name: Require TypeSafe credentials - env: - TYPESAFE_API_KEY: ${{ secrets.TYPESAFE_API_KEY || vars.TYPESAFE_API_KEY }} - run: | - set -euo pipefail - test -n "$TYPESAFE_API_KEY" || { - echo 'Set TYPESAFE_API_KEY in the typesafe environment.' >&2 - exit 2 - } - - - name: Initialize evidence manifest - env: - QUERY: ${{ inputs.query || 'Help me optimize the websocket connection implementation' }} - SUBJECT_REPOSITORY: ${{ inputs.subject_repository || 'BestNathan/nession' }} - SUBJECT_REF: ${{ inputs.subject_ref || 'staging' }} - DIRECTORY_THRESHOLD: ${{ inputs.directory_threshold || '0.35' }} - FILE_THRESHOLD: ${{ inputs.file_threshold || '0.50' }} - LINE_THRESHOLD: ${{ inputs.line_threshold || '0.70' }} - BATCH_SIZE: ${{ inputs.batch_size || '48' }} - TYPESAFE_MODEL: ${{ vars.TYPESAFE_MODEL || 'jev-latest' }} - run: | - set -euo pipefail - evidence="$RUNNER_TEMP/system-one-research-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT" - mkdir -p "$evidence/k8s" "$evidence/code-locator" - echo "EVIDENCE_DIR=$evidence" >> "$GITHUB_ENV" - - python3 - <<'PY' - import json, os, subprocess - from pathlib import Path - - def revision(path): - return subprocess.check_output( - ["git", "-C", path, "rev-parse", "HEAD"], text=True - ).strip() - - manifest = { - "schema_version": 1, - "kind": "system-one-research-evidence", - "github": { - "repository": os.environ.get("GITHUB_REPOSITORY"), - "sha": os.environ.get("GITHUB_SHA"), - "run_id": os.environ.get("GITHUB_RUN_ID"), - "run_attempt": os.environ.get("GITHUB_RUN_ATTEMPT"), - }, - "harness_revision": revision("narness"), - "subject": { - "repository": os.environ["SUBJECT_REPOSITORY"], - "requested_ref": os.environ["SUBJECT_REF"], - "revision": revision("subject"), - }, - "code_locator": { - "query": os.environ["QUERY"], - "thresholds": { - "directory": float(os.environ["DIRECTORY_THRESHOLD"]), - "file": float(os.environ["FILE_THRESHOLD"]), - "line": float(os.environ["LINE_THRESHOLD"]), - }, - "batch_size": int(os.environ["BATCH_SIZE"]), - }, - "model": os.environ["TYPESAFE_MODEL"], - } - root = Path(os.environ["EVIDENCE_DIR"]) - (root / "run-manifest.json").write_text( - json.dumps(manifest, indent=2) + "\n" - ) - PY - - - name: Run Kubernetes System One demo - env: - TYPESAFE_API_KEY: ${{ secrets.TYPESAFE_API_KEY || vars.TYPESAFE_API_KEY }} - TYPESAFE_API_URL: ${{ vars.TYPESAFE_API_URL || 'https://api.typesafe.ai/v1/systemone' }} - TYPESAFE_MODEL: ${{ vars.TYPESAFE_MODEL || 'jev-latest' }} - run: | - set -euo pipefail - python3 narness/examples/system-one-k8s/system_one_k8s.py "Show me the Kubernetes logs for nession in staging." --fixture narness/examples/system-one-k8s/fixtures/cluster.json --json | tee "$EVIDENCE_DIR/k8s/result.json" - - python3 - <<'PY' - import json, os - from pathlib import Path - root = Path(os.environ["EVIDENCE_DIR"]) - state = json.loads((root / "k8s/result.json").read_text()) - lines = [ - f"goal: {state['goal']}", - f"context: {state.get('context') or '-'}", - f"phase: {state['phase']}", - "decisions:", - ] - for index, decision in enumerate(state.get("decisions", []), start=1): - confidence = decision.get("confidence") - suffix = f" confidence={confidence:.3f}" if confidence is not None else "" - lines.append( - f" {index}. {decision['action_id']} [{decision['source']}]{suffix}" - ) - if state.get("final_command"): - lines.append("final command: " + " ".join(state["final_command"])) - (root / "k8s/stdout.log").write_text("\n".join(lines) + "\n") - PY - - - name: Run code-localization System One demo - env: - TYPESAFE_API_KEY: ${{ secrets.TYPESAFE_API_KEY || vars.TYPESAFE_API_KEY }} - TYPESAFE_API_URL: ${{ vars.TYPESAFE_API_URL || 'https://api.typesafe.ai/v1/systemone' }} - TYPESAFE_MODEL: ${{ vars.TYPESAFE_MODEL || 'jev-latest' }} - QUERY: ${{ inputs.query || 'Help me optimize the websocket connection implementation' }} - DIRECTORY_THRESHOLD: ${{ inputs.directory_threshold || '0.35' }} - FILE_THRESHOLD: ${{ inputs.file_threshold || '0.50' }} - LINE_THRESHOLD: ${{ inputs.line_threshold || '0.70' }} - BATCH_SIZE: ${{ inputs.batch_size || '48' }} - run: | - set -euo pipefail - python3 narness/examples/system-one-code-locator/system_one_code_locator.py subject "$QUERY" --directory-threshold "$DIRECTORY_THRESHOLD" --file-threshold "$FILE_THRESHOLD" --line-threshold "$LINE_THRESHOLD" --batch-size "$BATCH_SIZE" --trace-file "$EVIDENCE_DIR/code-locator/trace.jsonl" --output-json "$EVIDENCE_DIR/code-locator/result.json" | tee "$EVIDENCE_DIR/code-locator/stdout.log" - - - name: Build research summary - if: always() - run: | - set -euo pipefail - python3 - <<'PY' - import json, os - from pathlib import Path - - root = Path(os.environ["EVIDENCE_DIR"]) - lines = ["# System One research run", ""] - manifest = root / "run-manifest.json" - if manifest.exists(): - data = json.loads(manifest.read_text()) - lines += [ - f"- Subject: `{data['subject']['repository']}@{data['subject']['revision']}`", - f"- Query: `{data['code_locator']['query']}`", - f"- Model: `{data['model']}`", - f"- Thresholds: `{data['code_locator']['thresholds']}`", - "", - ] - result = root / "code-locator/result.json" - if result.exists(): - data = json.loads(result.read_text()) - lines += [ - "## Code locator", - "", - f"- Directories: {len(data.get('directories', []))}", - f"- Files: {len(data.get('files', []))}", - f"- Snippets: {len(data.get('snippets', []))}", - f"- Metrics: `{data.get('metrics', {})}`", - "", - "### Selected files", - "", - ] - lines += [ - f"- `{item['id']}` ({item['score']:.3f})" - for item in data.get("files", []) - ] - summary = "\n".join(lines) + "\n" - (root / "summary.md").write_text(summary) - with open(os.environ["GITHUB_STEP_SUMMARY"], "a") as handle: - handle.write(summary) - PY - - - name: Upload System One research evidence - if: always() - uses: actions/upload-artifact@v4 - with: - name: system-one-research-${{ github.run_id }}-${{ github.run_attempt }} - path: ${{ env.EVIDENCE_DIR }} - retention-days: 90 - if-no-files-found: warn From 50aaa21569e42aa81800af126b556c978ffa6355 Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:30:10 +0800 Subject: [PATCH 31/46] docs: separate System One experiment workflows --- .../README.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/topics/system-one-progressive-action-space/README.md b/docs/topics/system-one-progressive-action-space/README.md index 34d9a47d..0bb6c707 100644 --- a/docs/topics/system-one-progressive-action-space/README.md +++ b/docs/topics/system-one-progressive-action-space/README.md @@ -623,18 +623,19 @@ The decision primitive can therefore vary by state: See [Hierarchical Code Localization with System One](research/code-localization.md) for the hypotheses, threshold/recall analysis, evidence contract, and experiment plan. -## 19. Research evidence workflow +## 19. Research evidence workflows -The repository includes a dedicated workflow for these prototypes: [System One Research Demos](../../../.github/workflows/system-one-research.yml). +The experiments use separate workflows because they exercise different decision primitives, inputs, costs, and failure modes. -It has two layers: +- [System One Kubernetes experiment](../../../.github/workflows/system-one-k8s-experiment.yml) owns only the Kubernetes state-machine demo. +- [System One Code Locator experiment](../../../.github/workflows/system-one-code-locator.yml) owns only hierarchical code localization. -1. deterministic fixture runs on relevant pushes and pull requests, requiring no external model service; -2. manually dispatched real-System-One collection against the Kubernetes fixture and a configurable subject repository. +The Code Locator workflow has two layers: -Each run preserves machine-readable artifacts instead of treating console output as the research record. The code-localization trace records exposed candidates, model requests without credentials, relevance scores, thresholds, latency, token usage, and final grounded snippets. +1. deterministic fixture validation on Code Locator changes, requiring no external model service; +2. manually dispatched real-System-One localization against a configurable subject repository. -This makes repeated runs comparable by repository revision, subject revision, query, thresholds, batch size, model, and workflow identity. +Its artifact contains only Code Locator evidence: run metadata, execution log, `trace.jsonl`, `result.json`, and `summary.md`. This keeps repository-localization research independent from Kubernetes results and makes failures, costs, and parameter sweeps attributable to one experiment. ## 20. Relationship to Narness @@ -653,7 +654,8 @@ If the conclusions stabilize, some of them may graduate into Narness concepts ar - [System One Kubernetes Command Generator](../../../examples/system-one-k8s/README.md) - [System One Code Locator](../../../examples/system-one-code-locator/README.md) - [Code localization research note](research/code-localization.md) -- [System One research workflow](../../../.github/workflows/system-one-research.yml) +- [System One Kubernetes experiment workflow](../../../.github/workflows/system-one-k8s-experiment.yml) +- [System One Code Locator experiment workflow](../../../.github/workflows/system-one-code-locator.yml) ## Related Narness topics From ed5ae0ee2e2a6fa70e6f819d48ace3bbd58a4d37 Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:30:33 +0800 Subject: [PATCH 32/46] docs: scope evidence contract to code locator workflow --- .../research/code-localization.md | 40 +++++++------------ 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/docs/topics/system-one-progressive-action-space/research/code-localization.md b/docs/topics/system-one-progressive-action-space/research/code-localization.md index 9ba9e583..cb90e239 100644 --- a/docs/topics/system-one-progressive-action-space/research/code-localization.md +++ b/docs/topics/system-one-progressive-action-space/research/code-localization.md @@ -171,45 +171,36 @@ The important abstraction may therefore be broader than a state machine with a s ## Evidence contract -Every experiment run should preserve enough data to replay the reasoning surface without relying on GitHub Actions console retention. +Every Code Locator run should preserve enough data to replay the localization surface without relying on GitHub Actions console retention. -The workflow artifact should contain: +The dedicated Code Locator artifact contains only this experiment: ```text run-manifest.json - -k8s/ - stdout.log - result.json - -code-locator/ - stdout.log - result.json - trace.jsonl - +tests.log # offline job +run.log +result.json +trace.jsonl summary.md ``` -The manifest records repository and revision identity, workflow run identity, query, thresholds, model, and subject-repository revision. +The manifest records harness revision, subject repository and revision, workflow run identity, query, thresholds, batch size, and model. -For code localization, JSONL events include candidate disclosure, model requests, score responses, threshold decisions, latency, token usage, and final results. Authorization data is never recorded. +The JSONL trace records candidate disclosure, model requests, score responses, threshold decisions, latency, token usage, and final results. Authorization data is never recorded. -The Kubernetes demo contributes its final runtime state and human-readable decision log. Its `Decision` records preserve selected action, source, confidence, and probability distribution. +Kubernetes evidence is intentionally excluded and is owned by the separate `system-one-k8s-experiment` workflow. ## Workflow experiment design -The GitHub Actions workflow has two roles. - -First, deterministic fixture validation runs on every relevant change so the research harness itself remains reproducible without external services. +The dedicated [System One Code Locator workflow](../../../.github/workflows/system-one-code-locator.yml) has two roles. -Second, a manual evidence collection job can run the real System One model against: +First, deterministic fixture validation runs only when the Code Locator implementation, its research notes, or its workflow changes. -- the deterministic Kubernetes fixture; and -- a checked-out subject repository such as `BestNathan/nession`, with a natural-language code-localization query. +Second, a manual TypeSafe job runs the real System One model against a checked-out subject repository such as `BestNathan/nession`. -The subject repository, ref, query, thresholds, batch size, and online/offline mode are workflow inputs so repeated runs can vary one parameter while preserving the rest in the manifest. +The subject repository, ref, query, thresholds, batch size, and model are workflow inputs so repeated runs can vary one parameter while preserving the rest in the manifest. -Artifacts are retained for 90 days. Each run should be treated as raw research evidence, not as proof that the hypotheses are already true. +Artifacts are retained for 90 days. Each run should be treated as raw Code Locator research evidence, not as proof that the hypotheses are already true. ## Metrics available immediately @@ -221,8 +212,7 @@ Without gold labels, the workflow can already measure operational behavior: - TypeSafe input/output tokens; - end-to-end elapsed time; - selected directories/files/source ranges; -- stability across repeated runs and threshold settings; -- Kubernetes selected actions and confidence distributions. +- stability across repeated runs and threshold settings. ## Metrics requiring a benchmark dataset From eb9ef976a5a23d6caae74012ac9654bdbff6cce7 Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:31:07 +0800 Subject: [PATCH 33/46] ci: isolate Kubernetes experiment triggers --- .../workflows/system-one-k8s-experiment.yml | 224 ++++++++++++++++++ 1 file changed, 224 insertions(+) create mode 100644 .github/workflows/system-one-k8s-experiment.yml diff --git a/.github/workflows/system-one-k8s-experiment.yml b/.github/workflows/system-one-k8s-experiment.yml new file mode 100644 index 00000000..437df7e6 --- /dev/null +++ b/.github/workflows/system-one-k8s-experiment.yml @@ -0,0 +1,224 @@ +name: system-one-k8s-experiment + +on: + push: + paths: + - "examples/system-one-k8s/**" + - ".github/workflows/system-one-k8s-experiment.yml" + pull_request: + paths: + - "examples/system-one-k8s/**" + - ".github/workflows/system-one-k8s-experiment.yml" + workflow_dispatch: + inputs: + goal: + description: Natural-language Kubernetes request evaluated by the demo + required: true + default: Show me the Kubernetes logs for nession in staging. + type: string + run_typesafe: + description: Also run the real TypeSafe System One API experiment + required: true + default: false + type: boolean + model: + description: TypeSafe model alias + required: true + default: jev-latest + type: string + +permissions: + contents: read + +concurrency: + group: system-one-k8s-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + +env: + EXPERIMENT_GOAL: ${{ inputs.goal || 'Show me the Kubernetes logs for nession in staging.' }} + TYPESAFE_MODEL: ${{ inputs.model || 'jev-latest' }} + FIXTURE: examples/system-one-k8s/fixtures/cluster.json + +jobs: + offline: + name: Offline state-machine validation + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.13" + + - name: Prepare artifact directory + run: mkdir -p artifacts/system-one-k8s/offline + + - name: Run unit tests + shell: bash + run: | + set -o pipefail + python3 -m unittest discover \ + -s examples/system-one-k8s \ + -p 'test_*.py' \ + -v 2>&1 | tee artifacts/system-one-k8s/offline/tests.log + + - name: Run deterministic fixture experiment + shell: bash + run: | + set -o pipefail + python3 examples/system-one-k8s/system_one_k8s.py \ + "$EXPERIMENT_GOAL" \ + --fixture "$FIXTURE" \ + --offline-decider \ + --state-output artifacts/system-one-k8s/offline/state.json \ + --trace-output artifacts/system-one-k8s/offline/trace.jsonl \ + 2>&1 | tee artifacts/system-one-k8s/offline/run.log + + - name: Analyze trace + shell: bash + run: | + set -o pipefail + python3 examples/system-one-k8s/analyze_trace.py \ + --trace artifacts/system-one-k8s/offline/trace.jsonl \ + --state artifacts/system-one-k8s/offline/state.json \ + --json-output artifacts/system-one-k8s/offline/analysis.json \ + --markdown-output artifacts/system-one-k8s/offline/analysis.md \ + 2>&1 | tee artifacts/system-one-k8s/offline/analyze.log + + - name: Save run metadata + env: + RUN_ID: ${{ github.run_id }} + RUN_ATTEMPT: ${{ github.run_attempt }} + COMMIT_SHA: ${{ github.sha }} + REF_NAME: ${{ github.ref_name }} + run: | + python3 - <<'PY' + import json + import os + from pathlib import Path + + payload = { + "mode": "offline", + "goal": os.environ["EXPERIMENT_GOAL"], + "model": None, + "github_run_id": os.environ["RUN_ID"], + "github_run_attempt": os.environ["RUN_ATTEMPT"], + "commit_sha": os.environ["COMMIT_SHA"], + "ref_name": os.environ["REF_NAME"], + } + Path("artifacts/system-one-k8s/offline/metadata.json").write_text( + json.dumps(payload, indent=2) + "\n", + encoding="utf-8", + ) + PY + + - name: Publish analysis to job summary + if: always() + run: | + if test -f artifacts/system-one-k8s/offline/analysis.md; then + cat artifacts/system-one-k8s/offline/analysis.md >> "$GITHUB_STEP_SUMMARY" + fi + + - name: Upload offline experiment artifacts + if: always() + uses: actions/upload-artifact@v4 + with: + name: system-one-k8s-offline-${{ github.run_id }}-${{ github.run_attempt }} + path: artifacts/system-one-k8s/offline/ + if-no-files-found: error + retention-days: 30 + + typesafe: + name: Real TypeSafe System One experiment + if: ${{ github.event_name == 'workflow_dispatch' && inputs.run_typesafe }} + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.13" + + - name: Require TypeSafe API secret + env: + TYPESAFE_API_KEY: ${{ secrets.TYPESAFE_API_KEY }} + run: | + if test -z "$TYPESAFE_API_KEY"; then + echo "Repository secret TYPESAFE_API_KEY is required for run_typesafe=true." >&2 + exit 1 + fi + + - name: Prepare artifact directory + run: mkdir -p artifacts/system-one-k8s/typesafe + + - name: Run real System One experiment + env: + TYPESAFE_API_KEY: ${{ secrets.TYPESAFE_API_KEY }} + shell: bash + run: | + set -o pipefail + python3 examples/system-one-k8s/system_one_k8s.py \ + "$EXPERIMENT_GOAL" \ + --fixture "$FIXTURE" \ + --model "$TYPESAFE_MODEL" \ + --state-output artifacts/system-one-k8s/typesafe/state.json \ + --trace-output artifacts/system-one-k8s/typesafe/trace.jsonl \ + 2>&1 | tee artifacts/system-one-k8s/typesafe/run.log + + - name: Analyze trace + shell: bash + run: | + set -o pipefail + python3 examples/system-one-k8s/analyze_trace.py \ + --trace artifacts/system-one-k8s/typesafe/trace.jsonl \ + --state artifacts/system-one-k8s/typesafe/state.json \ + --json-output artifacts/system-one-k8s/typesafe/analysis.json \ + --markdown-output artifacts/system-one-k8s/typesafe/analysis.md \ + 2>&1 | tee artifacts/system-one-k8s/typesafe/analyze.log + + - name: Save run metadata + env: + RUN_ID: ${{ github.run_id }} + RUN_ATTEMPT: ${{ github.run_attempt }} + COMMIT_SHA: ${{ github.sha }} + REF_NAME: ${{ github.ref_name }} + run: | + python3 - <<'PY' + import json + import os + from pathlib import Path + + payload = { + "mode": "typesafe", + "goal": os.environ["EXPERIMENT_GOAL"], + "model": os.environ["TYPESAFE_MODEL"], + "github_run_id": os.environ["RUN_ID"], + "github_run_attempt": os.environ["RUN_ATTEMPT"], + "commit_sha": os.environ["COMMIT_SHA"], + "ref_name": os.environ["REF_NAME"], + } + Path("artifacts/system-one-k8s/typesafe/metadata.json").write_text( + json.dumps(payload, indent=2) + "\n", + encoding="utf-8", + ) + PY + + - name: Publish analysis to job summary + if: always() + run: | + if test -f artifacts/system-one-k8s/typesafe/analysis.md; then + cat artifacts/system-one-k8s/typesafe/analysis.md >> "$GITHUB_STEP_SUMMARY" + fi + + - name: Upload TypeSafe experiment artifacts + if: always() + uses: actions/upload-artifact@v4 + with: + name: system-one-k8s-typesafe-${{ github.run_id }}-${{ github.run_attempt }} + path: artifacts/system-one-k8s/typesafe/ + if-no-files-found: warn + retention-days: 30 From 9f021846e37a1f6521dc7663b84597c65b2dfbd4 Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:32:21 +0800 Subject: [PATCH 34/46] ci: isolate Kubernetes workflow from code locator changes --- .github/workflows/system-one-k8s-experiment.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/system-one-k8s-experiment.yml b/.github/workflows/system-one-k8s-experiment.yml index 437df7e6..06afa39f 100644 --- a/.github/workflows/system-one-k8s-experiment.yml +++ b/.github/workflows/system-one-k8s-experiment.yml @@ -4,7 +4,6 @@ on: push: paths: - "examples/system-one-k8s/**" - - ".github/workflows/system-one-k8s-experiment.yml" pull_request: paths: - "examples/system-one-k8s/**" From e313750c688c8deb54a652a4a52a10fdf1d08070 Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:32:58 +0800 Subject: [PATCH 35/46] docs: document dedicated code locator workflow --- examples/system-one-code-locator/README.md | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/examples/system-one-code-locator/README.md b/examples/system-one-code-locator/README.md index bd9c1e9f..5c9df1ed 100644 --- a/examples/system-one-code-locator/README.md +++ b/examples/system-one-code-locator/README.md @@ -152,6 +152,30 @@ python3 -m unittest discover \ The tests verify that the deterministic fixture finds the websocket client and that real API requests use independent Noul questions. +## Dedicated research workflow + +Code Locator has its own GitHub Actions workflow: + +```text +.github/workflows/system-one-code-locator.yml +``` + +It does not run the Kubernetes experiment. + +On relevant pushes and pull requests it runs only the deterministic Code Locator fixture and uploads: + +```text +system-one-code-locator-offline--/ + run-manifest.json + tests.log + run.log + result.json + trace.jsonl + summary.md +``` + +A manual `workflow_dispatch` can additionally run the real TypeSafe experiment against a configurable subject repository. That job uses the `typesafe` environment and uploads a separate `system-one-code-locator-typesafe-*` artifact. + ## Research limitations The current prototype intentionally leaves several questions open: From 629bba49ab53947673a1497b6e718d237ad20bfd Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:33:41 +0800 Subject: [PATCH 36/46] ci: keep Kubernetes workflow out of code locator PR --- .../workflows/system-one-k8s-experiment.yml | 223 ------------------ 1 file changed, 223 deletions(-) delete mode 100644 .github/workflows/system-one-k8s-experiment.yml diff --git a/.github/workflows/system-one-k8s-experiment.yml b/.github/workflows/system-one-k8s-experiment.yml deleted file mode 100644 index 06afa39f..00000000 --- a/.github/workflows/system-one-k8s-experiment.yml +++ /dev/null @@ -1,223 +0,0 @@ -name: system-one-k8s-experiment - -on: - push: - paths: - - "examples/system-one-k8s/**" - pull_request: - paths: - - "examples/system-one-k8s/**" - - ".github/workflows/system-one-k8s-experiment.yml" - workflow_dispatch: - inputs: - goal: - description: Natural-language Kubernetes request evaluated by the demo - required: true - default: Show me the Kubernetes logs for nession in staging. - type: string - run_typesafe: - description: Also run the real TypeSafe System One API experiment - required: true - default: false - type: boolean - model: - description: TypeSafe model alias - required: true - default: jev-latest - type: string - -permissions: - contents: read - -concurrency: - group: system-one-k8s-${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: false - -env: - EXPERIMENT_GOAL: ${{ inputs.goal || 'Show me the Kubernetes logs for nession in staging.' }} - TYPESAFE_MODEL: ${{ inputs.model || 'jev-latest' }} - FIXTURE: examples/system-one-k8s/fixtures/cluster.json - -jobs: - offline: - name: Offline state-machine validation - runs-on: ubuntu-latest - timeout-minutes: 10 - - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-python@v5 - with: - python-version: "3.13" - - - name: Prepare artifact directory - run: mkdir -p artifacts/system-one-k8s/offline - - - name: Run unit tests - shell: bash - run: | - set -o pipefail - python3 -m unittest discover \ - -s examples/system-one-k8s \ - -p 'test_*.py' \ - -v 2>&1 | tee artifacts/system-one-k8s/offline/tests.log - - - name: Run deterministic fixture experiment - shell: bash - run: | - set -o pipefail - python3 examples/system-one-k8s/system_one_k8s.py \ - "$EXPERIMENT_GOAL" \ - --fixture "$FIXTURE" \ - --offline-decider \ - --state-output artifacts/system-one-k8s/offline/state.json \ - --trace-output artifacts/system-one-k8s/offline/trace.jsonl \ - 2>&1 | tee artifacts/system-one-k8s/offline/run.log - - - name: Analyze trace - shell: bash - run: | - set -o pipefail - python3 examples/system-one-k8s/analyze_trace.py \ - --trace artifacts/system-one-k8s/offline/trace.jsonl \ - --state artifacts/system-one-k8s/offline/state.json \ - --json-output artifacts/system-one-k8s/offline/analysis.json \ - --markdown-output artifacts/system-one-k8s/offline/analysis.md \ - 2>&1 | tee artifacts/system-one-k8s/offline/analyze.log - - - name: Save run metadata - env: - RUN_ID: ${{ github.run_id }} - RUN_ATTEMPT: ${{ github.run_attempt }} - COMMIT_SHA: ${{ github.sha }} - REF_NAME: ${{ github.ref_name }} - run: | - python3 - <<'PY' - import json - import os - from pathlib import Path - - payload = { - "mode": "offline", - "goal": os.environ["EXPERIMENT_GOAL"], - "model": None, - "github_run_id": os.environ["RUN_ID"], - "github_run_attempt": os.environ["RUN_ATTEMPT"], - "commit_sha": os.environ["COMMIT_SHA"], - "ref_name": os.environ["REF_NAME"], - } - Path("artifacts/system-one-k8s/offline/metadata.json").write_text( - json.dumps(payload, indent=2) + "\n", - encoding="utf-8", - ) - PY - - - name: Publish analysis to job summary - if: always() - run: | - if test -f artifacts/system-one-k8s/offline/analysis.md; then - cat artifacts/system-one-k8s/offline/analysis.md >> "$GITHUB_STEP_SUMMARY" - fi - - - name: Upload offline experiment artifacts - if: always() - uses: actions/upload-artifact@v4 - with: - name: system-one-k8s-offline-${{ github.run_id }}-${{ github.run_attempt }} - path: artifacts/system-one-k8s/offline/ - if-no-files-found: error - retention-days: 30 - - typesafe: - name: Real TypeSafe System One experiment - if: ${{ github.event_name == 'workflow_dispatch' && inputs.run_typesafe }} - runs-on: ubuntu-latest - timeout-minutes: 10 - - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-python@v5 - with: - python-version: "3.13" - - - name: Require TypeSafe API secret - env: - TYPESAFE_API_KEY: ${{ secrets.TYPESAFE_API_KEY }} - run: | - if test -z "$TYPESAFE_API_KEY"; then - echo "Repository secret TYPESAFE_API_KEY is required for run_typesafe=true." >&2 - exit 1 - fi - - - name: Prepare artifact directory - run: mkdir -p artifacts/system-one-k8s/typesafe - - - name: Run real System One experiment - env: - TYPESAFE_API_KEY: ${{ secrets.TYPESAFE_API_KEY }} - shell: bash - run: | - set -o pipefail - python3 examples/system-one-k8s/system_one_k8s.py \ - "$EXPERIMENT_GOAL" \ - --fixture "$FIXTURE" \ - --model "$TYPESAFE_MODEL" \ - --state-output artifacts/system-one-k8s/typesafe/state.json \ - --trace-output artifacts/system-one-k8s/typesafe/trace.jsonl \ - 2>&1 | tee artifacts/system-one-k8s/typesafe/run.log - - - name: Analyze trace - shell: bash - run: | - set -o pipefail - python3 examples/system-one-k8s/analyze_trace.py \ - --trace artifacts/system-one-k8s/typesafe/trace.jsonl \ - --state artifacts/system-one-k8s/typesafe/state.json \ - --json-output artifacts/system-one-k8s/typesafe/analysis.json \ - --markdown-output artifacts/system-one-k8s/typesafe/analysis.md \ - 2>&1 | tee artifacts/system-one-k8s/typesafe/analyze.log - - - name: Save run metadata - env: - RUN_ID: ${{ github.run_id }} - RUN_ATTEMPT: ${{ github.run_attempt }} - COMMIT_SHA: ${{ github.sha }} - REF_NAME: ${{ github.ref_name }} - run: | - python3 - <<'PY' - import json - import os - from pathlib import Path - - payload = { - "mode": "typesafe", - "goal": os.environ["EXPERIMENT_GOAL"], - "model": os.environ["TYPESAFE_MODEL"], - "github_run_id": os.environ["RUN_ID"], - "github_run_attempt": os.environ["RUN_ATTEMPT"], - "commit_sha": os.environ["COMMIT_SHA"], - "ref_name": os.environ["REF_NAME"], - } - Path("artifacts/system-one-k8s/typesafe/metadata.json").write_text( - json.dumps(payload, indent=2) + "\n", - encoding="utf-8", - ) - PY - - - name: Publish analysis to job summary - if: always() - run: | - if test -f artifacts/system-one-k8s/typesafe/analysis.md; then - cat artifacts/system-one-k8s/typesafe/analysis.md >> "$GITHUB_STEP_SUMMARY" - fi - - - name: Upload TypeSafe experiment artifacts - if: always() - uses: actions/upload-artifact@v4 - with: - name: system-one-k8s-typesafe-${{ github.run_id }}-${{ github.run_attempt }} - path: artifacts/system-one-k8s/typesafe/ - if-no-files-found: warn - retention-days: 30 From 805e169a08f0eb524d312842288458d074ecf61f Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:40:08 +0800 Subject: [PATCH 37/46] ci: persist code locator experiment records --- .github/workflows/system-one-code-locator.yml | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/.github/workflows/system-one-code-locator.yml b/.github/workflows/system-one-code-locator.yml index c1c236ae..4daa527a 100644 --- a/.github/workflows/system-one-code-locator.yml +++ b/.github/workflows/system-one-code-locator.yml @@ -331,3 +331,100 @@ jobs: path: artifacts/system-one-code-locator/typesafe/ if-no-files-found: warn retention-days: 90 + + persist-record: + name: Persist experiment record + needs: + - offline + - typesafe + if: ${{ always() && github.event_name != 'pull_request' }} + runs-on: ubuntu-24.04 + timeout-minutes: 10 + permissions: + contents: write + + steps: + - name: Checkout experiment branch + uses: actions/checkout@v4 + with: + ref: ${{ github.ref_name }} + fetch-depth: 1 + persist-credentials: true + + - name: Download offline evidence + uses: actions/download-artifact@v4 + continue-on-error: true + with: + name: system-one-code-locator-offline-${{ github.run_id }}-${{ github.run_attempt }} + path: .experiment-record/offline + + - name: Download TypeSafe evidence + if: ${{ github.event_name == 'workflow_dispatch' && inputs.run_typesafe }} + uses: actions/download-artifact@v4 + continue-on-error: true + with: + name: system-one-code-locator-typesafe-${{ github.run_id }}-${{ github.run_attempt }} + path: .experiment-record/typesafe + + - name: Materialize repository record + env: + OFFLINE_RESULT: ${{ needs.offline.result }} + TYPESAFE_RESULT: ${{ needs.typesafe.result }} + RUN_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + shell: bash + run: | + set -euo pipefail + + stamp="$(TZ=Asia/Shanghai date +'%Y%m%dT%H%M%S%z')" + record="docs/topics/system-one-progressive-action-space/research/runs/code-locator/${stamp}-run-${GITHUB_RUN_ID}-attempt-${GITHUB_RUN_ATTEMPT}" + mkdir -p "$record" + + if test -d .experiment-record/offline; then + mkdir -p "$record/offline" + cp -a .experiment-record/offline/. "$record/offline/" + fi + + if test -d .experiment-record/typesafe; then + mkdir -p "$record/typesafe" + cp -a .experiment-record/typesafe/. "$record/typesafe/" + fi + + cat > "$record/README.md" <> "$GITHUB_ENV" + + - name: Commit experiment record + shell: bash + run: | + set -euo pipefail + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + + git add "$RECORD_DIR" + + if git diff --cached --quiet; then + echo "No experiment evidence to commit." + exit 0 + fi + + git commit -m "research: record code locator run ${GITHUB_RUN_ID}" + git push origin "HEAD:${GITHUB_REF_NAME}" From fd71e36229d6ad2a0f4c27f9dfe24e9bcb0146d3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 23 Sep 2026 04:40:28 +0000 Subject: [PATCH 38/46] research: record code locator run 35819260887 --- .../README.md | 18 +++ .../offline/result.json | 139 ++++++++++++++++++ .../offline/run-manifest.json | 16 ++ .../offline/run.log | 33 +++++ .../offline/summary.md | 7 + .../offline/tests.log | 7 + .../offline/trace.jsonl | 17 +++ 7 files changed, 237 insertions(+) create mode 100644 docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/README.md create mode 100644 docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/result.json create mode 100644 docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/run-manifest.json create mode 100644 docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/run.log create mode 100644 docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/summary.md create mode 100644 docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/tests.log create mode 100644 docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/trace.jsonl diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/README.md b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/README.md new file mode 100644 index 00000000..9bea06ea --- /dev/null +++ b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/README.md @@ -0,0 +1,18 @@ +# System One Code Locator experiment + +- Recorded at: (UTC+8) +- GitHub run: [35819260887](https://github.com/BestNathan/narness-engineering/actions/runs/35819260887) +- Run attempt: +- Event: +- Repository: +- Ref: +- Trigger SHA: +- Offline job: +- TypeSafe job: + +## Evidence + +- [Offline evidence](offline/) when the offline validation produced an artifact. +- [TypeSafe evidence](typesafe/) when a real TypeSafe experiment was requested. + +The files in this directory are an immutable snapshot of the evidence produced by this workflow run. diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/result.json b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/result.json new file mode 100644 index 00000000..bf1a55c4 --- /dev/null +++ b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/result.json @@ -0,0 +1,139 @@ +{ + "query": "Help me optimize the websocket connection implementation", + "root": "/home/runner/work/narness-engineering/narness-engineering/examples/system-one-code-locator/fixtures/repository", + "model": "offline-lexical-fixture", + "thresholds": { + "directory": 0.35, + "file": 0.5, + "line": 0.6 + }, + "directories": [ + { + "id": "web/src", + "payload": { + "path": "web/src", + "name": "src", + "child_directories": [ + "api", + "ws" + ], + "direct_files": [] + }, + "score": 0.84 + }, + { + "id": "web/src/ws", + "payload": { + "path": "web/src/ws", + "name": "ws", + "child_directories": [], + "direct_files": [ + "client.ts" + ] + }, + "score": 0.84 + }, + { + "id": "server", + "payload": { + "path": "server", + "name": "server", + "child_directories": [ + "src" + ], + "direct_files": [] + }, + "score": 0.62 + }, + { + "id": "server/src", + "payload": { + "path": "server/src", + "name": "src", + "child_directories": [], + "direct_files": [ + "http.ts" + ] + }, + "score": 0.62 + }, + { + "id": "web", + "payload": { + "path": "web", + "name": "web", + "child_directories": [ + "src" + ], + "direct_files": [] + }, + "score": 0.62 + }, + { + "id": "web/src/api", + "payload": { + "path": "web/src/api", + "name": "api", + "child_directories": [], + "direct_files": [ + "user.ts" + ] + }, + "score": 0.62 + } + ], + "files": [ + { + "id": "web/src/ws/client.ts", + "payload": { + "path": "web/src/ws/client.ts", + "filename": "client.ts", + "extension": ".ts", + "size_bytes": 573 + }, + "score": 0.84 + }, + { + "id": "server/src/http.ts", + "payload": { + "path": "server/src/http.ts", + "filename": "http.ts", + "extension": ".ts", + "size_bytes": 76 + }, + "score": 0.62 + }, + { + "id": "web/src/api/user.ts", + "payload": { + "path": "web/src/api/user.ts", + "filename": "user.ts", + "extension": ".ts", + "size_bytes": 125 + }, + "score": 0.62 + } + ], + "snippets": [ + { + "path": "web/src/ws/client.ts", + "start_line": 1, + "end_line": 19, + "score": 0.96, + "content": "1: export class WebSocketClient {\n2: private socket?: WebSocket;\n3: private reconnectTimer?: ReturnType;\n4: \n5: connect(url: string) {\n6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();\n10: }\n11: \n12: private scheduleReconnect(url: string) {\n13: this.reconnectTimer = setTimeout(() => this.connect(url), 1000);\n14: }\n15: \n16: private clearReconnect() {\n17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }\n19: }" + } + ], + "metrics": { + "model_calls": 0, + "input_tokens": 0, + "output_tokens": 0, + "directories_exposed": 6, + "directories_selected": 6, + "files_exposed": 3, + "files_selected": 3, + "lines_exposed": 23, + "lines_selected": 16, + "snippets": 1, + "elapsed_ms": 1.884 + } +} diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/run-manifest.json b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/run-manifest.json new file mode 100644 index 00000000..8cb5ed15 --- /dev/null +++ b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/run-manifest.json @@ -0,0 +1,16 @@ +{ + "schema_version": 1, + "mode": "offline", + "query": "Help me optimize the websocket connection implementation", + "model": "offline-lexical-fixture", + "thresholds": { + "directory": 0.35, + "file": 0.5, + "line": 0.6 + }, + "batch_size": 48, + "github_run_id": "35819260887", + "github_run_attempt": "1", + "commit_sha": "805e169a08f0eb524d312842288458d074ecf61f", + "ref_name": "research/system-one-code-localization" +} diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/run.log b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/run.log new file mode 100644 index 00000000..87fd7c7f --- /dev/null +++ b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/run.log @@ -0,0 +1,33 @@ +relevant directories: + 0.840 web/src + 0.840 web/src/ws + 0.620 server + 0.620 server/src + 0.620 web + 0.620 web/src/api +relevant files: + 0.840 web/src/ws/client.ts + 0.620 server/src/http.ts + 0.620 web/src/api/user.ts +relevant snippets: + 0.960 web/src/ws/client.ts:1-19 +1: export class WebSocketClient { +2: private socket?: WebSocket; +3: private reconnectTimer?: ReturnType; +4: +5: connect(url: string) { +6: this.socket = new WebSocket(url); +7: this.socket.onopen = () => this.clearReconnect(); +8: this.socket.onclose = () => this.scheduleReconnect(url); +9: this.socket.onerror = () => this.socket?.close(); +10: } +11: +12: private scheduleReconnect(url: string) { +13: this.reconnectTimer = setTimeout(() => this.connect(url), 1000); +14: } +15: +16: private clearReconnect() { +17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer); +18: } +19: } +metrics: {"model_calls": 0, "input_tokens": 0, "output_tokens": 0, "directories_exposed": 6, "directories_selected": 6, "files_exposed": 3, "files_selected": 3, "lines_exposed": 23, "lines_selected": 16, "snippets": 1, "elapsed_ms": 1.884} diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/summary.md b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/summary.md new file mode 100644 index 00000000..2909f769 --- /dev/null +++ b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/summary.md @@ -0,0 +1,7 @@ +# System One Code Locator — offline fixture + +- Query: `Help me optimize the websocket connection implementation` +- Directories: 6 +- Files: 3 +- Snippets: 1 +- Metrics: `{'model_calls': 0, 'input_tokens': 0, 'output_tokens': 0, 'directories_exposed': 6, 'directories_selected': 6, 'files_exposed': 3, 'files_selected': 3, 'lines_exposed': 23, 'lines_selected': 16, 'snippets': 1, 'elapsed_ms': 1.884}` diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/tests.log b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/tests.log new file mode 100644 index 00000000..e7b5dbe7 --- /dev/null +++ b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/tests.log @@ -0,0 +1,7 @@ +test_progressive_localization (test_system_one_code_locator.DemoTest.test_progressive_localization) ... ok +test_request_uses_noul (test_system_one_code_locator.DemoTest.test_request_uses_noul) ... ok + +---------------------------------------------------------------------- +Ran 2 tests in 0.010s + +OK diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/trace.jsonl b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/trace.jsonl new file mode 100644 index 00000000..ebf28b06 --- /dev/null +++ b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/trace.jsonl @@ -0,0 +1,17 @@ +{"event": "search_started", "model": "offline-lexical-fixture", "query": "Help me optimize the websocket connection implementation", "root": "/home/runner/work/narness-engineering/narness-engineering/examples/system-one-code-locator/fixtures/repository", "thresholds": {"directory": 0.35, "file": 0.5, "line": 0.6}, "timestamp": "2026-09-23T04:40:17.600455+00:00"} +{"candidates": [{"id": "server", "payload": {"child_directories": ["src"], "direct_files": [], "name": "server", "path": "server"}}, {"id": "server/src", "payload": {"child_directories": [], "direct_files": ["http.ts"], "name": "src", "path": "server/src"}}, {"id": "web", "payload": {"child_directories": ["src"], "direct_files": [], "name": "web", "path": "web"}}, {"id": "web/src", "payload": {"child_directories": ["api", "ws"], "direct_files": [], "name": "src", "path": "web/src"}}, {"id": "web/src/api", "payload": {"child_directories": [], "direct_files": ["user.ts"], "name": "api", "path": "web/src/api"}}, {"id": "web/src/ws", "payload": {"child_directories": [], "direct_files": ["client.ts"], "name": "ws", "path": "web/src/ws"}}], "count": 6, "event": "candidates_exposed", "stage": "directory", "timestamp": "2026-09-23T04:40:17.600785+00:00"} +{"event": "offline_scores", "scores": [{"id": "web/src", "score": 0.84}, {"id": "web/src/ws", "score": 0.84}, {"id": "server", "score": 0.62}, {"id": "server/src", "score": 0.62}, {"id": "web", "score": 0.62}, {"id": "web/src/api", "score": 0.62}], "stage": "directory", "timestamp": "2026-09-23T04:40:17.600939+00:00"} +{"event": "threshold_applied", "input_count": 6, "selected": [{"id": "web/src", "payload": {"child_directories": ["api", "ws"], "direct_files": [], "name": "src", "path": "web/src"}, "score": 0.84}, {"id": "web/src/ws", "payload": {"child_directories": [], "direct_files": ["client.ts"], "name": "ws", "path": "web/src/ws"}, "score": 0.84}, {"id": "server", "payload": {"child_directories": ["src"], "direct_files": [], "name": "server", "path": "server"}, "score": 0.62}, {"id": "server/src", "payload": {"child_directories": [], "direct_files": ["http.ts"], "name": "src", "path": "server/src"}, "score": 0.62}, {"id": "web", "payload": {"child_directories": ["src"], "direct_files": [], "name": "web", "path": "web"}, "score": 0.62}, {"id": "web/src/api", "payload": {"child_directories": [], "direct_files": ["user.ts"], "name": "api", "path": "web/src/api"}, "score": 0.62}], "selected_count": 6, "stage": "directory", "threshold": 0.35, "timestamp": "2026-09-23T04:40:17.600975+00:00"} +{"candidates": [{"id": "server/src/http.ts", "payload": {"extension": ".ts", "filename": "http.ts", "path": "server/src/http.ts", "size_bytes": 76}}, {"id": "web/src/api/user.ts", "payload": {"extension": ".ts", "filename": "user.ts", "path": "web/src/api/user.ts", "size_bytes": 125}}, {"id": "web/src/ws/client.ts", "payload": {"extension": ".ts", "filename": "client.ts", "path": "web/src/ws/client.ts", "size_bytes": 573}}], "count": 3, "event": "candidates_exposed", "stage": "file", "timestamp": "2026-09-23T04:40:17.601441+00:00"} +{"event": "offline_scores", "scores": [{"id": "web/src/ws/client.ts", "score": 0.84}, {"id": "server/src/http.ts", "score": 0.62}, {"id": "web/src/api/user.ts", "score": 0.62}], "stage": "file", "timestamp": "2026-09-23T04:40:17.601499+00:00"} +{"event": "threshold_applied", "input_count": 3, "selected": [{"id": "web/src/ws/client.ts", "payload": {"extension": ".ts", "filename": "client.ts", "path": "web/src/ws/client.ts", "size_bytes": 573}, "score": 0.84}, {"id": "server/src/http.ts", "payload": {"extension": ".ts", "filename": "http.ts", "path": "server/src/http.ts", "size_bytes": 76}, "score": 0.62}, {"id": "web/src/api/user.ts", "payload": {"extension": ".ts", "filename": "user.ts", "path": "web/src/api/user.ts", "size_bytes": 125}, "score": 0.62}], "selected_count": 3, "stage": "file", "threshold": 0.5, "timestamp": "2026-09-23T04:40:17.601523+00:00"} +{"candidates": [{"id": "web/src/ws/client.ts:1", "payload": {"line": 1, "nearby_lines": "1: export class WebSocketClient {\n2: private socket?: WebSocket;\n3: private reconnectTimer?: ReturnType;", "path": "web/src/ws/client.ts", "text": "export class WebSocketClient {"}}, {"id": "web/src/ws/client.ts:2", "payload": {"line": 2, "nearby_lines": "1: export class WebSocketClient {\n2: private socket?: WebSocket;\n3: private reconnectTimer?: ReturnType;\n4: ", "path": "web/src/ws/client.ts", "text": " private socket?: WebSocket;"}}, {"id": "web/src/ws/client.ts:3", "payload": {"line": 3, "nearby_lines": "1: export class WebSocketClient {\n2: private socket?: WebSocket;\n3: private reconnectTimer?: ReturnType;\n4: \n5: connect(url: string) {", "path": "web/src/ws/client.ts", "text": " private reconnectTimer?: ReturnType;"}}, {"id": "web/src/ws/client.ts:5", "payload": {"line": 5, "nearby_lines": "3: private reconnectTimer?: ReturnType;\n4: \n5: connect(url: string) {\n6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();", "path": "web/src/ws/client.ts", "text": " connect(url: string) {"}}, {"id": "web/src/ws/client.ts:6", "payload": {"line": 6, "nearby_lines": "4: \n5: connect(url: string) {\n6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);", "path": "web/src/ws/client.ts", "text": " this.socket = new WebSocket(url);"}}, {"id": "web/src/ws/client.ts:7", "payload": {"line": 7, "nearby_lines": "5: connect(url: string) {\n6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();", "path": "web/src/ws/client.ts", "text": " this.socket.onopen = () => this.clearReconnect();"}}, {"id": "web/src/ws/client.ts:8", "payload": {"line": 8, "nearby_lines": "6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();\n10: }", "path": "web/src/ws/client.ts", "text": " this.socket.onclose = () => this.scheduleReconnect(url);"}}, {"id": "web/src/ws/client.ts:9", "payload": {"line": 9, "nearby_lines": "7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();\n10: }\n11: ", "path": "web/src/ws/client.ts", "text": " this.socket.onerror = () => this.socket?.close();"}}, {"id": "web/src/ws/client.ts:10", "payload": {"line": 10, "nearby_lines": "8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();\n10: }\n11: \n12: private scheduleReconnect(url: string) {", "path": "web/src/ws/client.ts", "text": " }"}}, {"id": "web/src/ws/client.ts:12", "payload": {"line": 12, "nearby_lines": "10: }\n11: \n12: private scheduleReconnect(url: string) {\n13: this.reconnectTimer = setTimeout(() => this.connect(url), 1000);\n14: }", "path": "web/src/ws/client.ts", "text": " private scheduleReconnect(url: string) {"}}, {"id": "web/src/ws/client.ts:13", "payload": {"line": 13, "nearby_lines": "11: \n12: private scheduleReconnect(url: string) {\n13: this.reconnectTimer = setTimeout(() => this.connect(url), 1000);\n14: }\n15: ", "path": "web/src/ws/client.ts", "text": " this.reconnectTimer = setTimeout(() => this.connect(url), 1000);"}}, {"id": "web/src/ws/client.ts:14", "payload": {"line": 14, "nearby_lines": "12: private scheduleReconnect(url: string) {\n13: this.reconnectTimer = setTimeout(() => this.connect(url), 1000);\n14: }\n15: \n16: private clearReconnect() {", "path": "web/src/ws/client.ts", "text": " }"}}, {"id": "web/src/ws/client.ts:16", "payload": {"line": 16, "nearby_lines": "14: }\n15: \n16: private clearReconnect() {\n17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }", "path": "web/src/ws/client.ts", "text": " private clearReconnect() {"}}, {"id": "web/src/ws/client.ts:17", "payload": {"line": 17, "nearby_lines": "15: \n16: private clearReconnect() {\n17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }\n19: }", "path": "web/src/ws/client.ts", "text": " if (this.reconnectTimer) clearTimeout(this.reconnectTimer);"}}, {"id": "web/src/ws/client.ts:18", "payload": {"line": 18, "nearby_lines": "16: private clearReconnect() {\n17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }\n19: }", "path": "web/src/ws/client.ts", "text": " }"}}, {"id": "web/src/ws/client.ts:19", "payload": {"line": 19, "nearby_lines": "17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }\n19: }", "path": "web/src/ws/client.ts", "text": "}"}}], "count": 16, "event": "candidates_exposed", "parent": "web/src/ws/client.ts", "stage": "line", "timestamp": "2026-09-23T04:40:17.601639+00:00"} +{"event": "offline_scores", "scores": [{"id": "web/src/ws/client.ts:1", "score": 0.96}, {"id": "web/src/ws/client.ts:10", "score": 0.96}, {"id": "web/src/ws/client.ts:12", "score": 0.96}, {"id": "web/src/ws/client.ts:13", "score": 0.96}, {"id": "web/src/ws/client.ts:14", "score": 0.96}, {"id": "web/src/ws/client.ts:16", "score": 0.96}, {"id": "web/src/ws/client.ts:17", "score": 0.96}, {"id": "web/src/ws/client.ts:18", "score": 0.96}, {"id": "web/src/ws/client.ts:19", "score": 0.96}, {"id": "web/src/ws/client.ts:2", "score": 0.96}, {"id": "web/src/ws/client.ts:3", "score": 0.96}, {"id": "web/src/ws/client.ts:5", "score": 0.96}, {"id": "web/src/ws/client.ts:6", "score": 0.96}, {"id": "web/src/ws/client.ts:7", "score": 0.96}, {"id": "web/src/ws/client.ts:8", "score": 0.96}, {"id": "web/src/ws/client.ts:9", "score": 0.96}], "stage": "line", "timestamp": "2026-09-23T04:40:17.601809+00:00"} +{"event": "threshold_applied", "input_count": 16, "parent": "web/src/ws/client.ts", "selected": [{"id": "web/src/ws/client.ts:1", "payload": {"line": 1, "nearby_lines": "1: export class WebSocketClient {\n2: private socket?: WebSocket;\n3: private reconnectTimer?: ReturnType;", "path": "web/src/ws/client.ts", "text": "export class WebSocketClient {"}, "score": 0.96}, {"id": "web/src/ws/client.ts:10", "payload": {"line": 10, "nearby_lines": "8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();\n10: }\n11: \n12: private scheduleReconnect(url: string) {", "path": "web/src/ws/client.ts", "text": " }"}, "score": 0.96}, {"id": "web/src/ws/client.ts:12", "payload": {"line": 12, "nearby_lines": "10: }\n11: \n12: private scheduleReconnect(url: string) {\n13: this.reconnectTimer = setTimeout(() => this.connect(url), 1000);\n14: }", "path": "web/src/ws/client.ts", "text": " private scheduleReconnect(url: string) {"}, "score": 0.96}, {"id": "web/src/ws/client.ts:13", "payload": {"line": 13, "nearby_lines": "11: \n12: private scheduleReconnect(url: string) {\n13: this.reconnectTimer = setTimeout(() => this.connect(url), 1000);\n14: }\n15: ", "path": "web/src/ws/client.ts", "text": " this.reconnectTimer = setTimeout(() => this.connect(url), 1000);"}, "score": 0.96}, {"id": "web/src/ws/client.ts:14", "payload": {"line": 14, "nearby_lines": "12: private scheduleReconnect(url: string) {\n13: this.reconnectTimer = setTimeout(() => this.connect(url), 1000);\n14: }\n15: \n16: private clearReconnect() {", "path": "web/src/ws/client.ts", "text": " }"}, "score": 0.96}, {"id": "web/src/ws/client.ts:16", "payload": {"line": 16, "nearby_lines": "14: }\n15: \n16: private clearReconnect() {\n17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }", "path": "web/src/ws/client.ts", "text": " private clearReconnect() {"}, "score": 0.96}, {"id": "web/src/ws/client.ts:17", "payload": {"line": 17, "nearby_lines": "15: \n16: private clearReconnect() {\n17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }\n19: }", "path": "web/src/ws/client.ts", "text": " if (this.reconnectTimer) clearTimeout(this.reconnectTimer);"}, "score": 0.96}, {"id": "web/src/ws/client.ts:18", "payload": {"line": 18, "nearby_lines": "16: private clearReconnect() {\n17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }\n19: }", "path": "web/src/ws/client.ts", "text": " }"}, "score": 0.96}, {"id": "web/src/ws/client.ts:19", "payload": {"line": 19, "nearby_lines": "17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }\n19: }", "path": "web/src/ws/client.ts", "text": "}"}, "score": 0.96}, {"id": "web/src/ws/client.ts:2", "payload": {"line": 2, "nearby_lines": "1: export class WebSocketClient {\n2: private socket?: WebSocket;\n3: private reconnectTimer?: ReturnType;\n4: ", "path": "web/src/ws/client.ts", "text": " private socket?: WebSocket;"}, "score": 0.96}, {"id": "web/src/ws/client.ts:3", "payload": {"line": 3, "nearby_lines": "1: export class WebSocketClient {\n2: private socket?: WebSocket;\n3: private reconnectTimer?: ReturnType;\n4: \n5: connect(url: string) {", "path": "web/src/ws/client.ts", "text": " private reconnectTimer?: ReturnType;"}, "score": 0.96}, {"id": "web/src/ws/client.ts:5", "payload": {"line": 5, "nearby_lines": "3: private reconnectTimer?: ReturnType;\n4: \n5: connect(url: string) {\n6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();", "path": "web/src/ws/client.ts", "text": " connect(url: string) {"}, "score": 0.96}, {"id": "web/src/ws/client.ts:6", "payload": {"line": 6, "nearby_lines": "4: \n5: connect(url: string) {\n6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);", "path": "web/src/ws/client.ts", "text": " this.socket = new WebSocket(url);"}, "score": 0.96}, {"id": "web/src/ws/client.ts:7", "payload": {"line": 7, "nearby_lines": "5: connect(url: string) {\n6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();", "path": "web/src/ws/client.ts", "text": " this.socket.onopen = () => this.clearReconnect();"}, "score": 0.96}, {"id": "web/src/ws/client.ts:8", "payload": {"line": 8, "nearby_lines": "6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();\n10: }", "path": "web/src/ws/client.ts", "text": " this.socket.onclose = () => this.scheduleReconnect(url);"}, "score": 0.96}, {"id": "web/src/ws/client.ts:9", "payload": {"line": 9, "nearby_lines": "7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();\n10: }\n11: ", "path": "web/src/ws/client.ts", "text": " this.socket.onerror = () => this.socket?.close();"}, "score": 0.96}], "selected_count": 16, "stage": "line", "threshold": 0.6, "timestamp": "2026-09-23T04:40:17.601842+00:00"} +{"candidates": [{"id": "server/src/http.ts:1", "payload": {"line": 1, "nearby_lines": "1: export function startHttpServer() {\n2: console.log('http server started');\n3: }", "path": "server/src/http.ts", "text": "export function startHttpServer() {"}}, {"id": "server/src/http.ts:2", "payload": {"line": 2, "nearby_lines": "1: export function startHttpServer() {\n2: console.log('http server started');\n3: }", "path": "server/src/http.ts", "text": " console.log('http server started');"}}, {"id": "server/src/http.ts:3", "payload": {"line": 3, "nearby_lines": "1: export function startHttpServer() {\n2: console.log('http server started');\n3: }", "path": "server/src/http.ts", "text": "}"}}], "count": 3, "event": "candidates_exposed", "parent": "server/src/http.ts", "stage": "line", "timestamp": "2026-09-23T04:40:17.602025+00:00"} +{"event": "offline_scores", "scores": [{"id": "server/src/http.ts:1", "score": 0.05}, {"id": "server/src/http.ts:2", "score": 0.05}, {"id": "server/src/http.ts:3", "score": 0.05}], "stage": "line", "timestamp": "2026-09-23T04:40:17.602081+00:00"} +{"event": "threshold_applied", "input_count": 3, "parent": "server/src/http.ts", "selected": [], "selected_count": 0, "stage": "line", "threshold": 0.6, "timestamp": "2026-09-23T04:40:17.602104+00:00"} +{"candidates": [{"id": "web/src/api/user.ts:1", "payload": {"line": 1, "nearby_lines": "1: export async function loadUser(id: string) {\n2: const response = await fetch(`/api/users/${id}`);\n3: return response.json();", "path": "web/src/api/user.ts", "text": "export async function loadUser(id: string) {"}}, {"id": "web/src/api/user.ts:2", "payload": {"line": 2, "nearby_lines": "1: export async function loadUser(id: string) {\n2: const response = await fetch(`/api/users/${id}`);\n3: return response.json();\n4: }", "path": "web/src/api/user.ts", "text": " const response = await fetch(`/api/users/${id}`);"}}, {"id": "web/src/api/user.ts:3", "payload": {"line": 3, "nearby_lines": "1: export async function loadUser(id: string) {\n2: const response = await fetch(`/api/users/${id}`);\n3: return response.json();\n4: }", "path": "web/src/api/user.ts", "text": " return response.json();"}}, {"id": "web/src/api/user.ts:4", "payload": {"line": 4, "nearby_lines": "2: const response = await fetch(`/api/users/${id}`);\n3: return response.json();\n4: }", "path": "web/src/api/user.ts", "text": "}"}}], "count": 4, "event": "candidates_exposed", "parent": "web/src/api/user.ts", "stage": "line", "timestamp": "2026-09-23T04:40:17.602173+00:00"} +{"event": "offline_scores", "scores": [{"id": "web/src/api/user.ts:1", "score": 0.05}, {"id": "web/src/api/user.ts:2", "score": 0.05}, {"id": "web/src/api/user.ts:3", "score": 0.05}, {"id": "web/src/api/user.ts:4", "score": 0.05}], "stage": "line", "timestamp": "2026-09-23T04:40:17.602230+00:00"} +{"event": "threshold_applied", "input_count": 4, "parent": "web/src/api/user.ts", "selected": [], "selected_count": 0, "stage": "line", "threshold": 0.6, "timestamp": "2026-09-23T04:40:17.602251+00:00"} +{"event": "search_completed", "result": {"directories": [{"id": "web/src", "payload": {"child_directories": ["api", "ws"], "direct_files": [], "name": "src", "path": "web/src"}, "score": 0.84}, {"id": "web/src/ws", "payload": {"child_directories": [], "direct_files": ["client.ts"], "name": "ws", "path": "web/src/ws"}, "score": 0.84}, {"id": "server", "payload": {"child_directories": ["src"], "direct_files": [], "name": "server", "path": "server"}, "score": 0.62}, {"id": "server/src", "payload": {"child_directories": [], "direct_files": ["http.ts"], "name": "src", "path": "server/src"}, "score": 0.62}, {"id": "web", "payload": {"child_directories": ["src"], "direct_files": [], "name": "web", "path": "web"}, "score": 0.62}, {"id": "web/src/api", "payload": {"child_directories": [], "direct_files": ["user.ts"], "name": "api", "path": "web/src/api"}, "score": 0.62}], "files": [{"id": "web/src/ws/client.ts", "payload": {"extension": ".ts", "filename": "client.ts", "path": "web/src/ws/client.ts", "size_bytes": 573}, "score": 0.84}, {"id": "server/src/http.ts", "payload": {"extension": ".ts", "filename": "http.ts", "path": "server/src/http.ts", "size_bytes": 76}, "score": 0.62}, {"id": "web/src/api/user.ts", "payload": {"extension": ".ts", "filename": "user.ts", "path": "web/src/api/user.ts", "size_bytes": 125}, "score": 0.62}], "metrics": {"directories_exposed": 6, "directories_selected": 6, "elapsed_ms": 1.884, "files_exposed": 3, "files_selected": 3, "input_tokens": 0, "lines_exposed": 23, "lines_selected": 16, "model_calls": 0, "output_tokens": 0, "snippets": 1}, "model": "offline-lexical-fixture", "query": "Help me optimize the websocket connection implementation", "root": "/home/runner/work/narness-engineering/narness-engineering/examples/system-one-code-locator/fixtures/repository", "snippets": [{"content": "1: export class WebSocketClient {\n2: private socket?: WebSocket;\n3: private reconnectTimer?: ReturnType;\n4: \n5: connect(url: string) {\n6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();\n10: }\n11: \n12: private scheduleReconnect(url: string) {\n13: this.reconnectTimer = setTimeout(() => this.connect(url), 1000);\n14: }\n15: \n16: private clearReconnect() {\n17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }\n19: }", "end_line": 19, "path": "web/src/ws/client.ts", "score": 0.96, "start_line": 1}], "thresholds": {"directory": 0.35, "file": 0.5, "line": 0.6}}, "timestamp": "2026-09-23T04:40:17.602298+00:00"} From 63aee26c65438d3b5a8bcff5e87fdd2f54f4bef1 Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:42:02 +0800 Subject: [PATCH 39/46] fix: render persisted experiment metadata safely --- .github/workflows/system-one-code-locator.yml | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/.github/workflows/system-one-code-locator.yml b/.github/workflows/system-one-code-locator.yml index 4daa527a..014fc64c 100644 --- a/.github/workflows/system-one-code-locator.yml +++ b/.github/workflows/system-one-code-locator.yml @@ -389,26 +389,26 @@ jobs: cp -a .experiment-record/typesafe/. "$record/typesafe/" fi - cat > "$record/README.md" < "$record/README.md" echo "RECORD_DIR=$record" >> "$GITHUB_ENV" @@ -427,4 +427,5 @@ jobs: fi git commit -m "research: record code locator run ${GITHUB_RUN_ID}" + git pull --rebase origin "${GITHUB_REF_NAME}" git push origin "HEAD:${GITHUB_REF_NAME}" From 85c049af51a35c4938f272db5c48242623ede3af Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:42:11 +0800 Subject: [PATCH 40/46] research: repair metadata for code locator run 35819260887 --- .../README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/README.md b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/README.md index 9bea06ea..0b0be0a1 100644 --- a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/README.md +++ b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/README.md @@ -1,14 +1,14 @@ # System One Code Locator experiment -- Recorded at: (UTC+8) +- Recorded at: `20260923T124028+0800` (UTC+8) - GitHub run: [35819260887](https://github.com/BestNathan/narness-engineering/actions/runs/35819260887) -- Run attempt: -- Event: -- Repository: -- Ref: -- Trigger SHA: -- Offline job: -- TypeSafe job: +- Run attempt: `1` +- Event: `push` +- Repository: `BestNathan/narness-engineering` +- Ref: `research/system-one-code-localization` +- Trigger SHA: `805e169a08f0eb524d312842288458d074ecf61f` +- Offline job: `success` +- TypeSafe job: `skipped` ## Evidence From 56203069cd5335d1a8b1618d4b8dc28c67170414 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 23 Sep 2026 04:42:23 +0000 Subject: [PATCH 41/46] research: record code locator run 35819390521 --- .../README.md | 18 +++ .../offline/result.json | 139 ++++++++++++++++++ .../offline/run-manifest.json | 16 ++ .../offline/run.log | 33 +++++ .../offline/summary.md | 7 + .../offline/tests.log | 7 + .../offline/trace.jsonl | 17 +++ 7 files changed, 237 insertions(+) create mode 100644 docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/README.md create mode 100644 docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/result.json create mode 100644 docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/run-manifest.json create mode 100644 docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/run.log create mode 100644 docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/summary.md create mode 100644 docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/tests.log create mode 100644 docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/trace.jsonl diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/README.md b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/README.md new file mode 100644 index 00000000..8945b881 --- /dev/null +++ b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/README.md @@ -0,0 +1,18 @@ +# System One Code Locator experiment + +- Recorded at: `20260923T124223+0800` (UTC+8) +- GitHub run: [35819390521](https://github.com/BestNathan/narness-engineering/actions/runs/35819390521) +- Run attempt: `1` +- Event: `push` +- Repository: `BestNathan/narness-engineering` +- Ref: `research/system-one-code-localization` +- Trigger SHA: `63aee26c65438d3b5a8bcff5e87fdd2f54f4bef1` +- Offline job: `success` +- TypeSafe job: `skipped` + +## Evidence + +- [Offline evidence](offline/) when the offline validation produced an artifact. +- [TypeSafe evidence](typesafe/) when a real TypeSafe experiment was requested. + +The files in this directory are an immutable snapshot of the evidence produced by this workflow run. diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/result.json b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/result.json new file mode 100644 index 00000000..be7127d4 --- /dev/null +++ b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/result.json @@ -0,0 +1,139 @@ +{ + "query": "Help me optimize the websocket connection implementation", + "root": "/home/runner/work/narness-engineering/narness-engineering/examples/system-one-code-locator/fixtures/repository", + "model": "offline-lexical-fixture", + "thresholds": { + "directory": 0.35, + "file": 0.5, + "line": 0.6 + }, + "directories": [ + { + "id": "web/src", + "payload": { + "path": "web/src", + "name": "src", + "child_directories": [ + "api", + "ws" + ], + "direct_files": [] + }, + "score": 0.84 + }, + { + "id": "web/src/ws", + "payload": { + "path": "web/src/ws", + "name": "ws", + "child_directories": [], + "direct_files": [ + "client.ts" + ] + }, + "score": 0.84 + }, + { + "id": "server", + "payload": { + "path": "server", + "name": "server", + "child_directories": [ + "src" + ], + "direct_files": [] + }, + "score": 0.62 + }, + { + "id": "server/src", + "payload": { + "path": "server/src", + "name": "src", + "child_directories": [], + "direct_files": [ + "http.ts" + ] + }, + "score": 0.62 + }, + { + "id": "web", + "payload": { + "path": "web", + "name": "web", + "child_directories": [ + "src" + ], + "direct_files": [] + }, + "score": 0.62 + }, + { + "id": "web/src/api", + "payload": { + "path": "web/src/api", + "name": "api", + "child_directories": [], + "direct_files": [ + "user.ts" + ] + }, + "score": 0.62 + } + ], + "files": [ + { + "id": "web/src/ws/client.ts", + "payload": { + "path": "web/src/ws/client.ts", + "filename": "client.ts", + "extension": ".ts", + "size_bytes": 573 + }, + "score": 0.84 + }, + { + "id": "server/src/http.ts", + "payload": { + "path": "server/src/http.ts", + "filename": "http.ts", + "extension": ".ts", + "size_bytes": 76 + }, + "score": 0.62 + }, + { + "id": "web/src/api/user.ts", + "payload": { + "path": "web/src/api/user.ts", + "filename": "user.ts", + "extension": ".ts", + "size_bytes": 125 + }, + "score": 0.62 + } + ], + "snippets": [ + { + "path": "web/src/ws/client.ts", + "start_line": 1, + "end_line": 19, + "score": 0.96, + "content": "1: export class WebSocketClient {\n2: private socket?: WebSocket;\n3: private reconnectTimer?: ReturnType;\n4: \n5: connect(url: string) {\n6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();\n10: }\n11: \n12: private scheduleReconnect(url: string) {\n13: this.reconnectTimer = setTimeout(() => this.connect(url), 1000);\n14: }\n15: \n16: private clearReconnect() {\n17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }\n19: }" + } + ], + "metrics": { + "model_calls": 0, + "input_tokens": 0, + "output_tokens": 0, + "directories_exposed": 6, + "directories_selected": 6, + "files_exposed": 3, + "files_selected": 3, + "lines_exposed": 23, + "lines_selected": 16, + "snippets": 1, + "elapsed_ms": 3.504 + } +} diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/run-manifest.json b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/run-manifest.json new file mode 100644 index 00000000..d8dd43f3 --- /dev/null +++ b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/run-manifest.json @@ -0,0 +1,16 @@ +{ + "schema_version": 1, + "mode": "offline", + "query": "Help me optimize the websocket connection implementation", + "model": "offline-lexical-fixture", + "thresholds": { + "directory": 0.35, + "file": 0.5, + "line": 0.6 + }, + "batch_size": 48, + "github_run_id": "35819390521", + "github_run_attempt": "1", + "commit_sha": "63aee26c65438d3b5a8bcff5e87fdd2f54f4bef1", + "ref_name": "research/system-one-code-localization" +} diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/run.log b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/run.log new file mode 100644 index 00000000..7e3c4b63 --- /dev/null +++ b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/run.log @@ -0,0 +1,33 @@ +relevant directories: + 0.840 web/src + 0.840 web/src/ws + 0.620 server + 0.620 server/src + 0.620 web + 0.620 web/src/api +relevant files: + 0.840 web/src/ws/client.ts + 0.620 server/src/http.ts + 0.620 web/src/api/user.ts +relevant snippets: + 0.960 web/src/ws/client.ts:1-19 +1: export class WebSocketClient { +2: private socket?: WebSocket; +3: private reconnectTimer?: ReturnType; +4: +5: connect(url: string) { +6: this.socket = new WebSocket(url); +7: this.socket.onopen = () => this.clearReconnect(); +8: this.socket.onclose = () => this.scheduleReconnect(url); +9: this.socket.onerror = () => this.socket?.close(); +10: } +11: +12: private scheduleReconnect(url: string) { +13: this.reconnectTimer = setTimeout(() => this.connect(url), 1000); +14: } +15: +16: private clearReconnect() { +17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer); +18: } +19: } +metrics: {"model_calls": 0, "input_tokens": 0, "output_tokens": 0, "directories_exposed": 6, "directories_selected": 6, "files_exposed": 3, "files_selected": 3, "lines_exposed": 23, "lines_selected": 16, "snippets": 1, "elapsed_ms": 3.504} diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/summary.md b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/summary.md new file mode 100644 index 00000000..3383623c --- /dev/null +++ b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/summary.md @@ -0,0 +1,7 @@ +# System One Code Locator — offline fixture + +- Query: `Help me optimize the websocket connection implementation` +- Directories: 6 +- Files: 3 +- Snippets: 1 +- Metrics: `{'model_calls': 0, 'input_tokens': 0, 'output_tokens': 0, 'directories_exposed': 6, 'directories_selected': 6, 'files_exposed': 3, 'files_selected': 3, 'lines_exposed': 23, 'lines_selected': 16, 'snippets': 1, 'elapsed_ms': 3.504}` diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/tests.log b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/tests.log new file mode 100644 index 00000000..89daae97 --- /dev/null +++ b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/tests.log @@ -0,0 +1,7 @@ +test_progressive_localization (test_system_one_code_locator.DemoTest.test_progressive_localization) ... ok +test_request_uses_noul (test_system_one_code_locator.DemoTest.test_request_uses_noul) ... ok + +---------------------------------------------------------------------- +Ran 2 tests in 0.006s + +OK diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/trace.jsonl b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/trace.jsonl new file mode 100644 index 00000000..e5dda16d --- /dev/null +++ b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/trace.jsonl @@ -0,0 +1,17 @@ +{"event": "search_started", "model": "offline-lexical-fixture", "query": "Help me optimize the websocket connection implementation", "root": "/home/runner/work/narness-engineering/narness-engineering/examples/system-one-code-locator/fixtures/repository", "thresholds": {"directory": 0.35, "file": 0.5, "line": 0.6}, "timestamp": "2026-09-23T04:42:11.954266+00:00"} +{"candidates": [{"id": "server", "payload": {"child_directories": ["src"], "direct_files": [], "name": "server", "path": "server"}}, {"id": "server/src", "payload": {"child_directories": [], "direct_files": ["http.ts"], "name": "src", "path": "server/src"}}, {"id": "web", "payload": {"child_directories": ["src"], "direct_files": [], "name": "web", "path": "web"}}, {"id": "web/src", "payload": {"child_directories": ["api", "ws"], "direct_files": [], "name": "src", "path": "web/src"}}, {"id": "web/src/api", "payload": {"child_directories": [], "direct_files": ["user.ts"], "name": "api", "path": "web/src/api"}}, {"id": "web/src/ws", "payload": {"child_directories": [], "direct_files": ["client.ts"], "name": "ws", "path": "web/src/ws"}}], "count": 6, "event": "candidates_exposed", "stage": "directory", "timestamp": "2026-09-23T04:42:11.954915+00:00"} +{"event": "offline_scores", "scores": [{"id": "web/src", "score": 0.84}, {"id": "web/src/ws", "score": 0.84}, {"id": "server", "score": 0.62}, {"id": "server/src", "score": 0.62}, {"id": "web", "score": 0.62}, {"id": "web/src/api", "score": 0.62}], "stage": "directory", "timestamp": "2026-09-23T04:42:11.955139+00:00"} +{"event": "threshold_applied", "input_count": 6, "selected": [{"id": "web/src", "payload": {"child_directories": ["api", "ws"], "direct_files": [], "name": "src", "path": "web/src"}, "score": 0.84}, {"id": "web/src/ws", "payload": {"child_directories": [], "direct_files": ["client.ts"], "name": "ws", "path": "web/src/ws"}, "score": 0.84}, {"id": "server", "payload": {"child_directories": ["src"], "direct_files": [], "name": "server", "path": "server"}, "score": 0.62}, {"id": "server/src", "payload": {"child_directories": [], "direct_files": ["http.ts"], "name": "src", "path": "server/src"}, "score": 0.62}, {"id": "web", "payload": {"child_directories": ["src"], "direct_files": [], "name": "web", "path": "web"}, "score": 0.62}, {"id": "web/src/api", "payload": {"child_directories": [], "direct_files": ["user.ts"], "name": "api", "path": "web/src/api"}, "score": 0.62}], "selected_count": 6, "stage": "directory", "threshold": 0.35, "timestamp": "2026-09-23T04:42:11.955205+00:00"} +{"candidates": [{"id": "server/src/http.ts", "payload": {"extension": ".ts", "filename": "http.ts", "path": "server/src/http.ts", "size_bytes": 76}}, {"id": "web/src/api/user.ts", "payload": {"extension": ".ts", "filename": "user.ts", "path": "web/src/api/user.ts", "size_bytes": 125}}, {"id": "web/src/ws/client.ts", "payload": {"extension": ".ts", "filename": "client.ts", "path": "web/src/ws/client.ts", "size_bytes": 573}}], "count": 3, "event": "candidates_exposed", "stage": "file", "timestamp": "2026-09-23T04:42:11.956097+00:00"} +{"event": "offline_scores", "scores": [{"id": "web/src/ws/client.ts", "score": 0.84}, {"id": "server/src/http.ts", "score": 0.62}, {"id": "web/src/api/user.ts", "score": 0.62}], "stage": "file", "timestamp": "2026-09-23T04:42:11.956198+00:00"} +{"event": "threshold_applied", "input_count": 3, "selected": [{"id": "web/src/ws/client.ts", "payload": {"extension": ".ts", "filename": "client.ts", "path": "web/src/ws/client.ts", "size_bytes": 573}, "score": 0.84}, {"id": "server/src/http.ts", "payload": {"extension": ".ts", "filename": "http.ts", "path": "server/src/http.ts", "size_bytes": 76}, "score": 0.62}, {"id": "web/src/api/user.ts", "payload": {"extension": ".ts", "filename": "user.ts", "path": "web/src/api/user.ts", "size_bytes": 125}, "score": 0.62}], "selected_count": 3, "stage": "file", "threshold": 0.5, "timestamp": "2026-09-23T04:42:11.956252+00:00"} +{"candidates": [{"id": "web/src/ws/client.ts:1", "payload": {"line": 1, "nearby_lines": "1: export class WebSocketClient {\n2: private socket?: WebSocket;\n3: private reconnectTimer?: ReturnType;", "path": "web/src/ws/client.ts", "text": "export class WebSocketClient {"}}, {"id": "web/src/ws/client.ts:2", "payload": {"line": 2, "nearby_lines": "1: export class WebSocketClient {\n2: private socket?: WebSocket;\n3: private reconnectTimer?: ReturnType;\n4: ", "path": "web/src/ws/client.ts", "text": " private socket?: WebSocket;"}}, {"id": "web/src/ws/client.ts:3", "payload": {"line": 3, "nearby_lines": "1: export class WebSocketClient {\n2: private socket?: WebSocket;\n3: private reconnectTimer?: ReturnType;\n4: \n5: connect(url: string) {", "path": "web/src/ws/client.ts", "text": " private reconnectTimer?: ReturnType;"}}, {"id": "web/src/ws/client.ts:5", "payload": {"line": 5, "nearby_lines": "3: private reconnectTimer?: ReturnType;\n4: \n5: connect(url: string) {\n6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();", "path": "web/src/ws/client.ts", "text": " connect(url: string) {"}}, {"id": "web/src/ws/client.ts:6", "payload": {"line": 6, "nearby_lines": "4: \n5: connect(url: string) {\n6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);", "path": "web/src/ws/client.ts", "text": " this.socket = new WebSocket(url);"}}, {"id": "web/src/ws/client.ts:7", "payload": {"line": 7, "nearby_lines": "5: connect(url: string) {\n6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();", "path": "web/src/ws/client.ts", "text": " this.socket.onopen = () => this.clearReconnect();"}}, {"id": "web/src/ws/client.ts:8", "payload": {"line": 8, "nearby_lines": "6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();\n10: }", "path": "web/src/ws/client.ts", "text": " this.socket.onclose = () => this.scheduleReconnect(url);"}}, {"id": "web/src/ws/client.ts:9", "payload": {"line": 9, "nearby_lines": "7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();\n10: }\n11: ", "path": "web/src/ws/client.ts", "text": " this.socket.onerror = () => this.socket?.close();"}}, {"id": "web/src/ws/client.ts:10", "payload": {"line": 10, "nearby_lines": "8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();\n10: }\n11: \n12: private scheduleReconnect(url: string) {", "path": "web/src/ws/client.ts", "text": " }"}}, {"id": "web/src/ws/client.ts:12", "payload": {"line": 12, "nearby_lines": "10: }\n11: \n12: private scheduleReconnect(url: string) {\n13: this.reconnectTimer = setTimeout(() => this.connect(url), 1000);\n14: }", "path": "web/src/ws/client.ts", "text": " private scheduleReconnect(url: string) {"}}, {"id": "web/src/ws/client.ts:13", "payload": {"line": 13, "nearby_lines": "11: \n12: private scheduleReconnect(url: string) {\n13: this.reconnectTimer = setTimeout(() => this.connect(url), 1000);\n14: }\n15: ", "path": "web/src/ws/client.ts", "text": " this.reconnectTimer = setTimeout(() => this.connect(url), 1000);"}}, {"id": "web/src/ws/client.ts:14", "payload": {"line": 14, "nearby_lines": "12: private scheduleReconnect(url: string) {\n13: this.reconnectTimer = setTimeout(() => this.connect(url), 1000);\n14: }\n15: \n16: private clearReconnect() {", "path": "web/src/ws/client.ts", "text": " }"}}, {"id": "web/src/ws/client.ts:16", "payload": {"line": 16, "nearby_lines": "14: }\n15: \n16: private clearReconnect() {\n17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }", "path": "web/src/ws/client.ts", "text": " private clearReconnect() {"}}, {"id": "web/src/ws/client.ts:17", "payload": {"line": 17, "nearby_lines": "15: \n16: private clearReconnect() {\n17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }\n19: }", "path": "web/src/ws/client.ts", "text": " if (this.reconnectTimer) clearTimeout(this.reconnectTimer);"}}, {"id": "web/src/ws/client.ts:18", "payload": {"line": 18, "nearby_lines": "16: private clearReconnect() {\n17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }\n19: }", "path": "web/src/ws/client.ts", "text": " }"}}, {"id": "web/src/ws/client.ts:19", "payload": {"line": 19, "nearby_lines": "17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }\n19: }", "path": "web/src/ws/client.ts", "text": "}"}}], "count": 16, "event": "candidates_exposed", "parent": "web/src/ws/client.ts", "stage": "line", "timestamp": "2026-09-23T04:42:11.956484+00:00"} +{"event": "offline_scores", "scores": [{"id": "web/src/ws/client.ts:1", "score": 0.96}, {"id": "web/src/ws/client.ts:10", "score": 0.96}, {"id": "web/src/ws/client.ts:12", "score": 0.96}, {"id": "web/src/ws/client.ts:13", "score": 0.96}, {"id": "web/src/ws/client.ts:14", "score": 0.96}, {"id": "web/src/ws/client.ts:16", "score": 0.96}, {"id": "web/src/ws/client.ts:17", "score": 0.96}, {"id": "web/src/ws/client.ts:18", "score": 0.96}, {"id": "web/src/ws/client.ts:19", "score": 0.96}, {"id": "web/src/ws/client.ts:2", "score": 0.96}, {"id": "web/src/ws/client.ts:3", "score": 0.96}, {"id": "web/src/ws/client.ts:5", "score": 0.96}, {"id": "web/src/ws/client.ts:6", "score": 0.96}, {"id": "web/src/ws/client.ts:7", "score": 0.96}, {"id": "web/src/ws/client.ts:8", "score": 0.96}, {"id": "web/src/ws/client.ts:9", "score": 0.96}], "stage": "line", "timestamp": "2026-09-23T04:42:11.956728+00:00"} +{"event": "threshold_applied", "input_count": 16, "parent": "web/src/ws/client.ts", "selected": [{"id": "web/src/ws/client.ts:1", "payload": {"line": 1, "nearby_lines": "1: export class WebSocketClient {\n2: private socket?: WebSocket;\n3: private reconnectTimer?: ReturnType;", "path": "web/src/ws/client.ts", "text": "export class WebSocketClient {"}, "score": 0.96}, {"id": "web/src/ws/client.ts:10", "payload": {"line": 10, "nearby_lines": "8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();\n10: }\n11: \n12: private scheduleReconnect(url: string) {", "path": "web/src/ws/client.ts", "text": " }"}, "score": 0.96}, {"id": "web/src/ws/client.ts:12", "payload": {"line": 12, "nearby_lines": "10: }\n11: \n12: private scheduleReconnect(url: string) {\n13: this.reconnectTimer = setTimeout(() => this.connect(url), 1000);\n14: }", "path": "web/src/ws/client.ts", "text": " private scheduleReconnect(url: string) {"}, "score": 0.96}, {"id": "web/src/ws/client.ts:13", "payload": {"line": 13, "nearby_lines": "11: \n12: private scheduleReconnect(url: string) {\n13: this.reconnectTimer = setTimeout(() => this.connect(url), 1000);\n14: }\n15: ", "path": "web/src/ws/client.ts", "text": " this.reconnectTimer = setTimeout(() => this.connect(url), 1000);"}, "score": 0.96}, {"id": "web/src/ws/client.ts:14", "payload": {"line": 14, "nearby_lines": "12: private scheduleReconnect(url: string) {\n13: this.reconnectTimer = setTimeout(() => this.connect(url), 1000);\n14: }\n15: \n16: private clearReconnect() {", "path": "web/src/ws/client.ts", "text": " }"}, "score": 0.96}, {"id": "web/src/ws/client.ts:16", "payload": {"line": 16, "nearby_lines": "14: }\n15: \n16: private clearReconnect() {\n17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }", "path": "web/src/ws/client.ts", "text": " private clearReconnect() {"}, "score": 0.96}, {"id": "web/src/ws/client.ts:17", "payload": {"line": 17, "nearby_lines": "15: \n16: private clearReconnect() {\n17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }\n19: }", "path": "web/src/ws/client.ts", "text": " if (this.reconnectTimer) clearTimeout(this.reconnectTimer);"}, "score": 0.96}, {"id": "web/src/ws/client.ts:18", "payload": {"line": 18, "nearby_lines": "16: private clearReconnect() {\n17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }\n19: }", "path": "web/src/ws/client.ts", "text": " }"}, "score": 0.96}, {"id": "web/src/ws/client.ts:19", "payload": {"line": 19, "nearby_lines": "17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }\n19: }", "path": "web/src/ws/client.ts", "text": "}"}, "score": 0.96}, {"id": "web/src/ws/client.ts:2", "payload": {"line": 2, "nearby_lines": "1: export class WebSocketClient {\n2: private socket?: WebSocket;\n3: private reconnectTimer?: ReturnType;\n4: ", "path": "web/src/ws/client.ts", "text": " private socket?: WebSocket;"}, "score": 0.96}, {"id": "web/src/ws/client.ts:3", "payload": {"line": 3, "nearby_lines": "1: export class WebSocketClient {\n2: private socket?: WebSocket;\n3: private reconnectTimer?: ReturnType;\n4: \n5: connect(url: string) {", "path": "web/src/ws/client.ts", "text": " private reconnectTimer?: ReturnType;"}, "score": 0.96}, {"id": "web/src/ws/client.ts:5", "payload": {"line": 5, "nearby_lines": "3: private reconnectTimer?: ReturnType;\n4: \n5: connect(url: string) {\n6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();", "path": "web/src/ws/client.ts", "text": " connect(url: string) {"}, "score": 0.96}, {"id": "web/src/ws/client.ts:6", "payload": {"line": 6, "nearby_lines": "4: \n5: connect(url: string) {\n6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);", "path": "web/src/ws/client.ts", "text": " this.socket = new WebSocket(url);"}, "score": 0.96}, {"id": "web/src/ws/client.ts:7", "payload": {"line": 7, "nearby_lines": "5: connect(url: string) {\n6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();", "path": "web/src/ws/client.ts", "text": " this.socket.onopen = () => this.clearReconnect();"}, "score": 0.96}, {"id": "web/src/ws/client.ts:8", "payload": {"line": 8, "nearby_lines": "6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();\n10: }", "path": "web/src/ws/client.ts", "text": " this.socket.onclose = () => this.scheduleReconnect(url);"}, "score": 0.96}, {"id": "web/src/ws/client.ts:9", "payload": {"line": 9, "nearby_lines": "7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();\n10: }\n11: ", "path": "web/src/ws/client.ts", "text": " this.socket.onerror = () => this.socket?.close();"}, "score": 0.96}], "selected_count": 16, "stage": "line", "threshold": 0.6, "timestamp": "2026-09-23T04:42:11.956801+00:00"} +{"candidates": [{"id": "server/src/http.ts:1", "payload": {"line": 1, "nearby_lines": "1: export function startHttpServer() {\n2: console.log('http server started');\n3: }", "path": "server/src/http.ts", "text": "export function startHttpServer() {"}}, {"id": "server/src/http.ts:2", "payload": {"line": 2, "nearby_lines": "1: export function startHttpServer() {\n2: console.log('http server started');\n3: }", "path": "server/src/http.ts", "text": " console.log('http server started');"}}, {"id": "server/src/http.ts:3", "payload": {"line": 3, "nearby_lines": "1: export function startHttpServer() {\n2: console.log('http server started');\n3: }", "path": "server/src/http.ts", "text": "}"}}], "count": 3, "event": "candidates_exposed", "parent": "server/src/http.ts", "stage": "line", "timestamp": "2026-09-23T04:42:11.957111+00:00"} +{"event": "offline_scores", "scores": [{"id": "server/src/http.ts:1", "score": 0.05}, {"id": "server/src/http.ts:2", "score": 0.05}, {"id": "server/src/http.ts:3", "score": 0.05}], "stage": "line", "timestamp": "2026-09-23T04:42:11.957215+00:00"} +{"event": "threshold_applied", "input_count": 3, "parent": "server/src/http.ts", "selected": [], "selected_count": 0, "stage": "line", "threshold": 0.6, "timestamp": "2026-09-23T04:42:11.957269+00:00"} +{"candidates": [{"id": "web/src/api/user.ts:1", "payload": {"line": 1, "nearby_lines": "1: export async function loadUser(id: string) {\n2: const response = await fetch(`/api/users/${id}`);\n3: return response.json();", "path": "web/src/api/user.ts", "text": "export async function loadUser(id: string) {"}}, {"id": "web/src/api/user.ts:2", "payload": {"line": 2, "nearby_lines": "1: export async function loadUser(id: string) {\n2: const response = await fetch(`/api/users/${id}`);\n3: return response.json();\n4: }", "path": "web/src/api/user.ts", "text": " const response = await fetch(`/api/users/${id}`);"}}, {"id": "web/src/api/user.ts:3", "payload": {"line": 3, "nearby_lines": "1: export async function loadUser(id: string) {\n2: const response = await fetch(`/api/users/${id}`);\n3: return response.json();\n4: }", "path": "web/src/api/user.ts", "text": " return response.json();"}}, {"id": "web/src/api/user.ts:4", "payload": {"line": 4, "nearby_lines": "2: const response = await fetch(`/api/users/${id}`);\n3: return response.json();\n4: }", "path": "web/src/api/user.ts", "text": "}"}}], "count": 4, "event": "candidates_exposed", "parent": "web/src/api/user.ts", "stage": "line", "timestamp": "2026-09-23T04:42:11.957440+00:00"} +{"event": "offline_scores", "scores": [{"id": "web/src/api/user.ts:1", "score": 0.05}, {"id": "web/src/api/user.ts:2", "score": 0.05}, {"id": "web/src/api/user.ts:3", "score": 0.05}, {"id": "web/src/api/user.ts:4", "score": 0.05}], "stage": "line", "timestamp": "2026-09-23T04:42:11.957545+00:00"} +{"event": "threshold_applied", "input_count": 4, "parent": "web/src/api/user.ts", "selected": [], "selected_count": 0, "stage": "line", "threshold": 0.6, "timestamp": "2026-09-23T04:42:11.957598+00:00"} +{"event": "search_completed", "result": {"directories": [{"id": "web/src", "payload": {"child_directories": ["api", "ws"], "direct_files": [], "name": "src", "path": "web/src"}, "score": 0.84}, {"id": "web/src/ws", "payload": {"child_directories": [], "direct_files": ["client.ts"], "name": "ws", "path": "web/src/ws"}, "score": 0.84}, {"id": "server", "payload": {"child_directories": ["src"], "direct_files": [], "name": "server", "path": "server"}, "score": 0.62}, {"id": "server/src", "payload": {"child_directories": [], "direct_files": ["http.ts"], "name": "src", "path": "server/src"}, "score": 0.62}, {"id": "web", "payload": {"child_directories": ["src"], "direct_files": [], "name": "web", "path": "web"}, "score": 0.62}, {"id": "web/src/api", "payload": {"child_directories": [], "direct_files": ["user.ts"], "name": "api", "path": "web/src/api"}, "score": 0.62}], "files": [{"id": "web/src/ws/client.ts", "payload": {"extension": ".ts", "filename": "client.ts", "path": "web/src/ws/client.ts", "size_bytes": 573}, "score": 0.84}, {"id": "server/src/http.ts", "payload": {"extension": ".ts", "filename": "http.ts", "path": "server/src/http.ts", "size_bytes": 76}, "score": 0.62}, {"id": "web/src/api/user.ts", "payload": {"extension": ".ts", "filename": "user.ts", "path": "web/src/api/user.ts", "size_bytes": 125}, "score": 0.62}], "metrics": {"directories_exposed": 6, "directories_selected": 6, "elapsed_ms": 3.504, "files_exposed": 3, "files_selected": 3, "input_tokens": 0, "lines_exposed": 23, "lines_selected": 16, "model_calls": 0, "output_tokens": 0, "snippets": 1}, "model": "offline-lexical-fixture", "query": "Help me optimize the websocket connection implementation", "root": "/home/runner/work/narness-engineering/narness-engineering/examples/system-one-code-locator/fixtures/repository", "snippets": [{"content": "1: export class WebSocketClient {\n2: private socket?: WebSocket;\n3: private reconnectTimer?: ReturnType;\n4: \n5: connect(url: string) {\n6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();\n10: }\n11: \n12: private scheduleReconnect(url: string) {\n13: this.reconnectTimer = setTimeout(() => this.connect(url), 1000);\n14: }\n15: \n16: private clearReconnect() {\n17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }\n19: }", "end_line": 19, "path": "web/src/ws/client.ts", "score": 0.96, "start_line": 1}], "thresholds": {"directory": 0.35, "file": 0.5, "line": 0.6}}, "timestamp": "2026-09-23T04:42:11.957700+00:00"} From 5112470132c35669d69225367a859a29e1048d09 Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:43:03 +0800 Subject: [PATCH 42/46] docs: define code locator experiment record layout --- .../research/runs/code-locator/README.md | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 docs/topics/system-one-progressive-action-space/research/runs/code-locator/README.md diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/README.md b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/README.md new file mode 100644 index 00000000..9fb2306b --- /dev/null +++ b/docs/topics/system-one-progressive-action-space/research/runs/code-locator/README.md @@ -0,0 +1,43 @@ +# System One Code Locator experiment records + +This directory contains repository-persisted evidence for Code Locator experiment runs. + +Each recorded workflow run uses a time + GitHub run ID directory: + +```text +YYYYMMDDTHHMMSS+0800-run--attempt-/ +``` + +Example: + +```text +20260923T124223+0800-run-35819390521-attempt-1/ +├── README.md +├── offline/ +│ ├── run-manifest.json +│ ├── tests.log +│ ├── run.log +│ ├── result.json +│ ├── trace.jsonl +│ └── summary.md +└── typesafe/ + ├── run-manifest.json + ├── run.log + ├── result.json + ├── trace.jsonl + └── summary.md +``` + +The timestamp is generated in UTC+8. + +The workflow persists records after experiment jobs complete. Push and manually dispatched runs are written back to the triggering branch. Pull-request validation does not write to the repository. + +The record commit is produced by `github-actions[bot]` and uses: + +```text +research: record code locator run +``` + +The records path is intentionally excluded from the Code Locator workflow path filters, so persisting a record does not recursively start another Code Locator experiment. + +Artifacts are still uploaded to GitHub Actions for convenient download, but the files here are the durable research history owned by the repository. From 4b25c9201595d49324844d7a72ceee393805c9de Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:47:52 +0800 Subject: [PATCH 43/46] research: move code locator records to root research directory --- .github/workflows/system-one-code-locator.yml | 2 +- .../20260923T124028+0800-run-35819260887-attempt-1/README.md | 0 .../offline/result.json | 0 .../offline/run-manifest.json | 0 .../offline/run.log | 0 .../offline/summary.md | 0 .../offline/tests.log | 0 .../offline/trace.jsonl | 0 .../20260923T124223+0800-run-35819390521-attempt-1/README.md | 0 .../offline/result.json | 0 .../offline/run-manifest.json | 0 .../offline/run.log | 0 .../offline/summary.md | 0 .../offline/tests.log | 0 .../offline/trace.jsonl | 0 .../research/runs => research}/code-locator/README.md | 0 16 files changed, 1 insertion(+), 1 deletion(-) rename {docs/topics/system-one-progressive-action-space/research/runs => research}/code-locator/20260923T124028+0800-run-35819260887-attempt-1/README.md (100%) rename {docs/topics/system-one-progressive-action-space/research/runs => research}/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/result.json (100%) rename {docs/topics/system-one-progressive-action-space/research/runs => research}/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/run-manifest.json (100%) rename {docs/topics/system-one-progressive-action-space/research/runs => research}/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/run.log (100%) rename {docs/topics/system-one-progressive-action-space/research/runs => research}/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/summary.md (100%) rename {docs/topics/system-one-progressive-action-space/research/runs => research}/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/tests.log (100%) rename {docs/topics/system-one-progressive-action-space/research/runs => research}/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/trace.jsonl (100%) rename {docs/topics/system-one-progressive-action-space/research/runs => research}/code-locator/20260923T124223+0800-run-35819390521-attempt-1/README.md (100%) rename {docs/topics/system-one-progressive-action-space/research/runs => research}/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/result.json (100%) rename {docs/topics/system-one-progressive-action-space/research/runs => research}/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/run-manifest.json (100%) rename {docs/topics/system-one-progressive-action-space/research/runs => research}/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/run.log (100%) rename {docs/topics/system-one-progressive-action-space/research/runs => research}/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/summary.md (100%) rename {docs/topics/system-one-progressive-action-space/research/runs => research}/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/tests.log (100%) rename {docs/topics/system-one-progressive-action-space/research/runs => research}/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/trace.jsonl (100%) rename {docs/topics/system-one-progressive-action-space/research/runs => research}/code-locator/README.md (100%) diff --git a/.github/workflows/system-one-code-locator.yml b/.github/workflows/system-one-code-locator.yml index 014fc64c..d1546e72 100644 --- a/.github/workflows/system-one-code-locator.yml +++ b/.github/workflows/system-one-code-locator.yml @@ -376,7 +376,7 @@ jobs: set -euo pipefail stamp="$(TZ=Asia/Shanghai date +'%Y%m%dT%H%M%S%z')" - record="docs/topics/system-one-progressive-action-space/research/runs/code-locator/${stamp}-run-${GITHUB_RUN_ID}-attempt-${GITHUB_RUN_ATTEMPT}" + record="research/code-locator/${stamp}-run-${GITHUB_RUN_ID}-attempt-${GITHUB_RUN_ATTEMPT}" mkdir -p "$record" if test -d .experiment-record/offline; then diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/README.md b/research/code-locator/20260923T124028+0800-run-35819260887-attempt-1/README.md similarity index 100% rename from docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/README.md rename to research/code-locator/20260923T124028+0800-run-35819260887-attempt-1/README.md diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/result.json b/research/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/result.json similarity index 100% rename from docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/result.json rename to research/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/result.json diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/run-manifest.json b/research/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/run-manifest.json similarity index 100% rename from docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/run-manifest.json rename to research/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/run-manifest.json diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/run.log b/research/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/run.log similarity index 100% rename from docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/run.log rename to research/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/run.log diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/summary.md b/research/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/summary.md similarity index 100% rename from docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/summary.md rename to research/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/summary.md diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/tests.log b/research/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/tests.log similarity index 100% rename from docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/tests.log rename to research/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/tests.log diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/trace.jsonl b/research/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/trace.jsonl similarity index 100% rename from docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/trace.jsonl rename to research/code-locator/20260923T124028+0800-run-35819260887-attempt-1/offline/trace.jsonl diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/README.md b/research/code-locator/20260923T124223+0800-run-35819390521-attempt-1/README.md similarity index 100% rename from docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/README.md rename to research/code-locator/20260923T124223+0800-run-35819390521-attempt-1/README.md diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/result.json b/research/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/result.json similarity index 100% rename from docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/result.json rename to research/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/result.json diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/run-manifest.json b/research/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/run-manifest.json similarity index 100% rename from docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/run-manifest.json rename to research/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/run-manifest.json diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/run.log b/research/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/run.log similarity index 100% rename from docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/run.log rename to research/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/run.log diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/summary.md b/research/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/summary.md similarity index 100% rename from docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/summary.md rename to research/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/summary.md diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/tests.log b/research/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/tests.log similarity index 100% rename from docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/tests.log rename to research/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/tests.log diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/trace.jsonl b/research/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/trace.jsonl similarity index 100% rename from docs/topics/system-one-progressive-action-space/research/runs/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/trace.jsonl rename to research/code-locator/20260923T124223+0800-run-35819390521-attempt-1/offline/trace.jsonl diff --git a/docs/topics/system-one-progressive-action-space/research/runs/code-locator/README.md b/research/code-locator/README.md similarity index 100% rename from docs/topics/system-one-progressive-action-space/research/runs/code-locator/README.md rename to research/code-locator/README.md From 84b338e07e5d09bf4b399879544de43b43d069e3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 23 Sep 2026 04:48:13 +0000 Subject: [PATCH 44/46] research: record code locator run 35819796535 --- .../README.md | 18 +++ .../offline/result.json | 139 ++++++++++++++++++ .../offline/run-manifest.json | 16 ++ .../offline/run.log | 33 +++++ .../offline/summary.md | 7 + .../offline/tests.log | 7 + .../offline/trace.jsonl | 17 +++ 7 files changed, 237 insertions(+) create mode 100644 research/code-locator/20260923T124813+0800-run-35819796535-attempt-1/README.md create mode 100644 research/code-locator/20260923T124813+0800-run-35819796535-attempt-1/offline/result.json create mode 100644 research/code-locator/20260923T124813+0800-run-35819796535-attempt-1/offline/run-manifest.json create mode 100644 research/code-locator/20260923T124813+0800-run-35819796535-attempt-1/offline/run.log create mode 100644 research/code-locator/20260923T124813+0800-run-35819796535-attempt-1/offline/summary.md create mode 100644 research/code-locator/20260923T124813+0800-run-35819796535-attempt-1/offline/tests.log create mode 100644 research/code-locator/20260923T124813+0800-run-35819796535-attempt-1/offline/trace.jsonl diff --git a/research/code-locator/20260923T124813+0800-run-35819796535-attempt-1/README.md b/research/code-locator/20260923T124813+0800-run-35819796535-attempt-1/README.md new file mode 100644 index 00000000..2313103a --- /dev/null +++ b/research/code-locator/20260923T124813+0800-run-35819796535-attempt-1/README.md @@ -0,0 +1,18 @@ +# System One Code Locator experiment + +- Recorded at: `20260923T124813+0800` (UTC+8) +- GitHub run: [35819796535](https://github.com/BestNathan/narness-engineering/actions/runs/35819796535) +- Run attempt: `1` +- Event: `push` +- Repository: `BestNathan/narness-engineering` +- Ref: `research/system-one-code-localization` +- Trigger SHA: `4b25c9201595d49324844d7a72ceee393805c9de` +- Offline job: `success` +- TypeSafe job: `skipped` + +## Evidence + +- [Offline evidence](offline/) when the offline validation produced an artifact. +- [TypeSafe evidence](typesafe/) when a real TypeSafe experiment was requested. + +The files in this directory are an immutable snapshot of the evidence produced by this workflow run. diff --git a/research/code-locator/20260923T124813+0800-run-35819796535-attempt-1/offline/result.json b/research/code-locator/20260923T124813+0800-run-35819796535-attempt-1/offline/result.json new file mode 100644 index 00000000..18d5fe4f --- /dev/null +++ b/research/code-locator/20260923T124813+0800-run-35819796535-attempt-1/offline/result.json @@ -0,0 +1,139 @@ +{ + "query": "Help me optimize the websocket connection implementation", + "root": "/home/runner/work/narness-engineering/narness-engineering/examples/system-one-code-locator/fixtures/repository", + "model": "offline-lexical-fixture", + "thresholds": { + "directory": 0.35, + "file": 0.5, + "line": 0.6 + }, + "directories": [ + { + "id": "web/src", + "payload": { + "path": "web/src", + "name": "src", + "child_directories": [ + "api", + "ws" + ], + "direct_files": [] + }, + "score": 0.84 + }, + { + "id": "web/src/ws", + "payload": { + "path": "web/src/ws", + "name": "ws", + "child_directories": [], + "direct_files": [ + "client.ts" + ] + }, + "score": 0.84 + }, + { + "id": "server", + "payload": { + "path": "server", + "name": "server", + "child_directories": [ + "src" + ], + "direct_files": [] + }, + "score": 0.62 + }, + { + "id": "server/src", + "payload": { + "path": "server/src", + "name": "src", + "child_directories": [], + "direct_files": [ + "http.ts" + ] + }, + "score": 0.62 + }, + { + "id": "web", + "payload": { + "path": "web", + "name": "web", + "child_directories": [ + "src" + ], + "direct_files": [] + }, + "score": 0.62 + }, + { + "id": "web/src/api", + "payload": { + "path": "web/src/api", + "name": "api", + "child_directories": [], + "direct_files": [ + "user.ts" + ] + }, + "score": 0.62 + } + ], + "files": [ + { + "id": "web/src/ws/client.ts", + "payload": { + "path": "web/src/ws/client.ts", + "filename": "client.ts", + "extension": ".ts", + "size_bytes": 573 + }, + "score": 0.84 + }, + { + "id": "server/src/http.ts", + "payload": { + "path": "server/src/http.ts", + "filename": "http.ts", + "extension": ".ts", + "size_bytes": 76 + }, + "score": 0.62 + }, + { + "id": "web/src/api/user.ts", + "payload": { + "path": "web/src/api/user.ts", + "filename": "user.ts", + "extension": ".ts", + "size_bytes": 125 + }, + "score": 0.62 + } + ], + "snippets": [ + { + "path": "web/src/ws/client.ts", + "start_line": 1, + "end_line": 19, + "score": 0.96, + "content": "1: export class WebSocketClient {\n2: private socket?: WebSocket;\n3: private reconnectTimer?: ReturnType;\n4: \n5: connect(url: string) {\n6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();\n10: }\n11: \n12: private scheduleReconnect(url: string) {\n13: this.reconnectTimer = setTimeout(() => this.connect(url), 1000);\n14: }\n15: \n16: private clearReconnect() {\n17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }\n19: }" + } + ], + "metrics": { + "model_calls": 0, + "input_tokens": 0, + "output_tokens": 0, + "directories_exposed": 6, + "directories_selected": 6, + "files_exposed": 3, + "files_selected": 3, + "lines_exposed": 23, + "lines_selected": 16, + "snippets": 1, + "elapsed_ms": 3.061 + } +} diff --git a/research/code-locator/20260923T124813+0800-run-35819796535-attempt-1/offline/run-manifest.json b/research/code-locator/20260923T124813+0800-run-35819796535-attempt-1/offline/run-manifest.json new file mode 100644 index 00000000..fe41255d --- /dev/null +++ b/research/code-locator/20260923T124813+0800-run-35819796535-attempt-1/offline/run-manifest.json @@ -0,0 +1,16 @@ +{ + "schema_version": 1, + "mode": "offline", + "query": "Help me optimize the websocket connection implementation", + "model": "offline-lexical-fixture", + "thresholds": { + "directory": 0.35, + "file": 0.5, + "line": 0.6 + }, + "batch_size": 48, + "github_run_id": "35819796535", + "github_run_attempt": "1", + "commit_sha": "4b25c9201595d49324844d7a72ceee393805c9de", + "ref_name": "research/system-one-code-localization" +} diff --git a/research/code-locator/20260923T124813+0800-run-35819796535-attempt-1/offline/run.log b/research/code-locator/20260923T124813+0800-run-35819796535-attempt-1/offline/run.log new file mode 100644 index 00000000..53094705 --- /dev/null +++ b/research/code-locator/20260923T124813+0800-run-35819796535-attempt-1/offline/run.log @@ -0,0 +1,33 @@ +relevant directories: + 0.840 web/src + 0.840 web/src/ws + 0.620 server + 0.620 server/src + 0.620 web + 0.620 web/src/api +relevant files: + 0.840 web/src/ws/client.ts + 0.620 server/src/http.ts + 0.620 web/src/api/user.ts +relevant snippets: + 0.960 web/src/ws/client.ts:1-19 +1: export class WebSocketClient { +2: private socket?: WebSocket; +3: private reconnectTimer?: ReturnType; +4: +5: connect(url: string) { +6: this.socket = new WebSocket(url); +7: this.socket.onopen = () => this.clearReconnect(); +8: this.socket.onclose = () => this.scheduleReconnect(url); +9: this.socket.onerror = () => this.socket?.close(); +10: } +11: +12: private scheduleReconnect(url: string) { +13: this.reconnectTimer = setTimeout(() => this.connect(url), 1000); +14: } +15: +16: private clearReconnect() { +17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer); +18: } +19: } +metrics: {"model_calls": 0, "input_tokens": 0, "output_tokens": 0, "directories_exposed": 6, "directories_selected": 6, "files_exposed": 3, "files_selected": 3, "lines_exposed": 23, "lines_selected": 16, "snippets": 1, "elapsed_ms": 3.061} diff --git a/research/code-locator/20260923T124813+0800-run-35819796535-attempt-1/offline/summary.md b/research/code-locator/20260923T124813+0800-run-35819796535-attempt-1/offline/summary.md new file mode 100644 index 00000000..51edd5e4 --- /dev/null +++ b/research/code-locator/20260923T124813+0800-run-35819796535-attempt-1/offline/summary.md @@ -0,0 +1,7 @@ +# System One Code Locator — offline fixture + +- Query: `Help me optimize the websocket connection implementation` +- Directories: 6 +- Files: 3 +- Snippets: 1 +- Metrics: `{'model_calls': 0, 'input_tokens': 0, 'output_tokens': 0, 'directories_exposed': 6, 'directories_selected': 6, 'files_exposed': 3, 'files_selected': 3, 'lines_exposed': 23, 'lines_selected': 16, 'snippets': 1, 'elapsed_ms': 3.061}` diff --git a/research/code-locator/20260923T124813+0800-run-35819796535-attempt-1/offline/tests.log b/research/code-locator/20260923T124813+0800-run-35819796535-attempt-1/offline/tests.log new file mode 100644 index 00000000..acc7996d --- /dev/null +++ b/research/code-locator/20260923T124813+0800-run-35819796535-attempt-1/offline/tests.log @@ -0,0 +1,7 @@ +test_progressive_localization (test_system_one_code_locator.DemoTest.test_progressive_localization) ... ok +test_request_uses_noul (test_system_one_code_locator.DemoTest.test_request_uses_noul) ... ok + +---------------------------------------------------------------------- +Ran 2 tests in 0.011s + +OK diff --git a/research/code-locator/20260923T124813+0800-run-35819796535-attempt-1/offline/trace.jsonl b/research/code-locator/20260923T124813+0800-run-35819796535-attempt-1/offline/trace.jsonl new file mode 100644 index 00000000..6ffedf16 --- /dev/null +++ b/research/code-locator/20260923T124813+0800-run-35819796535-attempt-1/offline/trace.jsonl @@ -0,0 +1,17 @@ +{"event": "search_started", "model": "offline-lexical-fixture", "query": "Help me optimize the websocket connection implementation", "root": "/home/runner/work/narness-engineering/narness-engineering/examples/system-one-code-locator/fixtures/repository", "thresholds": {"directory": 0.35, "file": 0.5, "line": 0.6}, "timestamp": "2026-09-23T04:48:04.435734+00:00"} +{"candidates": [{"id": "server", "payload": {"child_directories": ["src"], "direct_files": [], "name": "server", "path": "server"}}, {"id": "server/src", "payload": {"child_directories": [], "direct_files": ["http.ts"], "name": "src", "path": "server/src"}}, {"id": "web", "payload": {"child_directories": ["src"], "direct_files": [], "name": "web", "path": "web"}}, {"id": "web/src", "payload": {"child_directories": ["api", "ws"], "direct_files": [], "name": "src", "path": "web/src"}}, {"id": "web/src/api", "payload": {"child_directories": [], "direct_files": ["user.ts"], "name": "api", "path": "web/src/api"}}, {"id": "web/src/ws", "payload": {"child_directories": [], "direct_files": ["client.ts"], "name": "ws", "path": "web/src/ws"}}], "count": 6, "event": "candidates_exposed", "stage": "directory", "timestamp": "2026-09-23T04:48:04.436271+00:00"} +{"event": "offline_scores", "scores": [{"id": "web/src", "score": 0.84}, {"id": "web/src/ws", "score": 0.84}, {"id": "server", "score": 0.62}, {"id": "server/src", "score": 0.62}, {"id": "web", "score": 0.62}, {"id": "web/src/api", "score": 0.62}], "stage": "directory", "timestamp": "2026-09-23T04:48:04.436487+00:00"} +{"event": "threshold_applied", "input_count": 6, "selected": [{"id": "web/src", "payload": {"child_directories": ["api", "ws"], "direct_files": [], "name": "src", "path": "web/src"}, "score": 0.84}, {"id": "web/src/ws", "payload": {"child_directories": [], "direct_files": ["client.ts"], "name": "ws", "path": "web/src/ws"}, "score": 0.84}, {"id": "server", "payload": {"child_directories": ["src"], "direct_files": [], "name": "server", "path": "server"}, "score": 0.62}, {"id": "server/src", "payload": {"child_directories": [], "direct_files": ["http.ts"], "name": "src", "path": "server/src"}, "score": 0.62}, {"id": "web", "payload": {"child_directories": ["src"], "direct_files": [], "name": "web", "path": "web"}, "score": 0.62}, {"id": "web/src/api", "payload": {"child_directories": [], "direct_files": ["user.ts"], "name": "api", "path": "web/src/api"}, "score": 0.62}], "selected_count": 6, "stage": "directory", "threshold": 0.35, "timestamp": "2026-09-23T04:48:04.436564+00:00"} +{"candidates": [{"id": "server/src/http.ts", "payload": {"extension": ".ts", "filename": "http.ts", "path": "server/src/http.ts", "size_bytes": 76}}, {"id": "web/src/api/user.ts", "payload": {"extension": ".ts", "filename": "user.ts", "path": "web/src/api/user.ts", "size_bytes": 125}}, {"id": "web/src/ws/client.ts", "payload": {"extension": ".ts", "filename": "client.ts", "path": "web/src/ws/client.ts", "size_bytes": 573}}], "count": 3, "event": "candidates_exposed", "stage": "file", "timestamp": "2026-09-23T04:48:04.437284+00:00"} +{"event": "offline_scores", "scores": [{"id": "web/src/ws/client.ts", "score": 0.84}, {"id": "server/src/http.ts", "score": 0.62}, {"id": "web/src/api/user.ts", "score": 0.62}], "stage": "file", "timestamp": "2026-09-23T04:48:04.437378+00:00"} +{"event": "threshold_applied", "input_count": 3, "selected": [{"id": "web/src/ws/client.ts", "payload": {"extension": ".ts", "filename": "client.ts", "path": "web/src/ws/client.ts", "size_bytes": 573}, "score": 0.84}, {"id": "server/src/http.ts", "payload": {"extension": ".ts", "filename": "http.ts", "path": "server/src/http.ts", "size_bytes": 76}, "score": 0.62}, {"id": "web/src/api/user.ts", "payload": {"extension": ".ts", "filename": "user.ts", "path": "web/src/api/user.ts", "size_bytes": 125}, "score": 0.62}], "selected_count": 3, "stage": "file", "threshold": 0.5, "timestamp": "2026-09-23T04:48:04.437423+00:00"} +{"candidates": [{"id": "web/src/ws/client.ts:1", "payload": {"line": 1, "nearby_lines": "1: export class WebSocketClient {\n2: private socket?: WebSocket;\n3: private reconnectTimer?: ReturnType;", "path": "web/src/ws/client.ts", "text": "export class WebSocketClient {"}}, {"id": "web/src/ws/client.ts:2", "payload": {"line": 2, "nearby_lines": "1: export class WebSocketClient {\n2: private socket?: WebSocket;\n3: private reconnectTimer?: ReturnType;\n4: ", "path": "web/src/ws/client.ts", "text": " private socket?: WebSocket;"}}, {"id": "web/src/ws/client.ts:3", "payload": {"line": 3, "nearby_lines": "1: export class WebSocketClient {\n2: private socket?: WebSocket;\n3: private reconnectTimer?: ReturnType;\n4: \n5: connect(url: string) {", "path": "web/src/ws/client.ts", "text": " private reconnectTimer?: ReturnType;"}}, {"id": "web/src/ws/client.ts:5", "payload": {"line": 5, "nearby_lines": "3: private reconnectTimer?: ReturnType;\n4: \n5: connect(url: string) {\n6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();", "path": "web/src/ws/client.ts", "text": " connect(url: string) {"}}, {"id": "web/src/ws/client.ts:6", "payload": {"line": 6, "nearby_lines": "4: \n5: connect(url: string) {\n6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);", "path": "web/src/ws/client.ts", "text": " this.socket = new WebSocket(url);"}}, {"id": "web/src/ws/client.ts:7", "payload": {"line": 7, "nearby_lines": "5: connect(url: string) {\n6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();", "path": "web/src/ws/client.ts", "text": " this.socket.onopen = () => this.clearReconnect();"}}, {"id": "web/src/ws/client.ts:8", "payload": {"line": 8, "nearby_lines": "6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();\n10: }", "path": "web/src/ws/client.ts", "text": " this.socket.onclose = () => this.scheduleReconnect(url);"}}, {"id": "web/src/ws/client.ts:9", "payload": {"line": 9, "nearby_lines": "7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();\n10: }\n11: ", "path": "web/src/ws/client.ts", "text": " this.socket.onerror = () => this.socket?.close();"}}, {"id": "web/src/ws/client.ts:10", "payload": {"line": 10, "nearby_lines": "8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();\n10: }\n11: \n12: private scheduleReconnect(url: string) {", "path": "web/src/ws/client.ts", "text": " }"}}, {"id": "web/src/ws/client.ts:12", "payload": {"line": 12, "nearby_lines": "10: }\n11: \n12: private scheduleReconnect(url: string) {\n13: this.reconnectTimer = setTimeout(() => this.connect(url), 1000);\n14: }", "path": "web/src/ws/client.ts", "text": " private scheduleReconnect(url: string) {"}}, {"id": "web/src/ws/client.ts:13", "payload": {"line": 13, "nearby_lines": "11: \n12: private scheduleReconnect(url: string) {\n13: this.reconnectTimer = setTimeout(() => this.connect(url), 1000);\n14: }\n15: ", "path": "web/src/ws/client.ts", "text": " this.reconnectTimer = setTimeout(() => this.connect(url), 1000);"}}, {"id": "web/src/ws/client.ts:14", "payload": {"line": 14, "nearby_lines": "12: private scheduleReconnect(url: string) {\n13: this.reconnectTimer = setTimeout(() => this.connect(url), 1000);\n14: }\n15: \n16: private clearReconnect() {", "path": "web/src/ws/client.ts", "text": " }"}}, {"id": "web/src/ws/client.ts:16", "payload": {"line": 16, "nearby_lines": "14: }\n15: \n16: private clearReconnect() {\n17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }", "path": "web/src/ws/client.ts", "text": " private clearReconnect() {"}}, {"id": "web/src/ws/client.ts:17", "payload": {"line": 17, "nearby_lines": "15: \n16: private clearReconnect() {\n17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }\n19: }", "path": "web/src/ws/client.ts", "text": " if (this.reconnectTimer) clearTimeout(this.reconnectTimer);"}}, {"id": "web/src/ws/client.ts:18", "payload": {"line": 18, "nearby_lines": "16: private clearReconnect() {\n17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }\n19: }", "path": "web/src/ws/client.ts", "text": " }"}}, {"id": "web/src/ws/client.ts:19", "payload": {"line": 19, "nearby_lines": "17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }\n19: }", "path": "web/src/ws/client.ts", "text": "}"}}], "count": 16, "event": "candidates_exposed", "parent": "web/src/ws/client.ts", "stage": "line", "timestamp": "2026-09-23T04:48:04.437633+00:00"} +{"event": "offline_scores", "scores": [{"id": "web/src/ws/client.ts:1", "score": 0.96}, {"id": "web/src/ws/client.ts:10", "score": 0.96}, {"id": "web/src/ws/client.ts:12", "score": 0.96}, {"id": "web/src/ws/client.ts:13", "score": 0.96}, {"id": "web/src/ws/client.ts:14", "score": 0.96}, {"id": "web/src/ws/client.ts:16", "score": 0.96}, {"id": "web/src/ws/client.ts:17", "score": 0.96}, {"id": "web/src/ws/client.ts:18", "score": 0.96}, {"id": "web/src/ws/client.ts:19", "score": 0.96}, {"id": "web/src/ws/client.ts:2", "score": 0.96}, {"id": "web/src/ws/client.ts:3", "score": 0.96}, {"id": "web/src/ws/client.ts:5", "score": 0.96}, {"id": "web/src/ws/client.ts:6", "score": 0.96}, {"id": "web/src/ws/client.ts:7", "score": 0.96}, {"id": "web/src/ws/client.ts:8", "score": 0.96}, {"id": "web/src/ws/client.ts:9", "score": 0.96}], "stage": "line", "timestamp": "2026-09-23T04:48:04.437871+00:00"} +{"event": "threshold_applied", "input_count": 16, "parent": "web/src/ws/client.ts", "selected": [{"id": "web/src/ws/client.ts:1", "payload": {"line": 1, "nearby_lines": "1: export class WebSocketClient {\n2: private socket?: WebSocket;\n3: private reconnectTimer?: ReturnType;", "path": "web/src/ws/client.ts", "text": "export class WebSocketClient {"}, "score": 0.96}, {"id": "web/src/ws/client.ts:10", "payload": {"line": 10, "nearby_lines": "8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();\n10: }\n11: \n12: private scheduleReconnect(url: string) {", "path": "web/src/ws/client.ts", "text": " }"}, "score": 0.96}, {"id": "web/src/ws/client.ts:12", "payload": {"line": 12, "nearby_lines": "10: }\n11: \n12: private scheduleReconnect(url: string) {\n13: this.reconnectTimer = setTimeout(() => this.connect(url), 1000);\n14: }", "path": "web/src/ws/client.ts", "text": " private scheduleReconnect(url: string) {"}, "score": 0.96}, {"id": "web/src/ws/client.ts:13", "payload": {"line": 13, "nearby_lines": "11: \n12: private scheduleReconnect(url: string) {\n13: this.reconnectTimer = setTimeout(() => this.connect(url), 1000);\n14: }\n15: ", "path": "web/src/ws/client.ts", "text": " this.reconnectTimer = setTimeout(() => this.connect(url), 1000);"}, "score": 0.96}, {"id": "web/src/ws/client.ts:14", "payload": {"line": 14, "nearby_lines": "12: private scheduleReconnect(url: string) {\n13: this.reconnectTimer = setTimeout(() => this.connect(url), 1000);\n14: }\n15: \n16: private clearReconnect() {", "path": "web/src/ws/client.ts", "text": " }"}, "score": 0.96}, {"id": "web/src/ws/client.ts:16", "payload": {"line": 16, "nearby_lines": "14: }\n15: \n16: private clearReconnect() {\n17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }", "path": "web/src/ws/client.ts", "text": " private clearReconnect() {"}, "score": 0.96}, {"id": "web/src/ws/client.ts:17", "payload": {"line": 17, "nearby_lines": "15: \n16: private clearReconnect() {\n17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }\n19: }", "path": "web/src/ws/client.ts", "text": " if (this.reconnectTimer) clearTimeout(this.reconnectTimer);"}, "score": 0.96}, {"id": "web/src/ws/client.ts:18", "payload": {"line": 18, "nearby_lines": "16: private clearReconnect() {\n17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }\n19: }", "path": "web/src/ws/client.ts", "text": " }"}, "score": 0.96}, {"id": "web/src/ws/client.ts:19", "payload": {"line": 19, "nearby_lines": "17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }\n19: }", "path": "web/src/ws/client.ts", "text": "}"}, "score": 0.96}, {"id": "web/src/ws/client.ts:2", "payload": {"line": 2, "nearby_lines": "1: export class WebSocketClient {\n2: private socket?: WebSocket;\n3: private reconnectTimer?: ReturnType;\n4: ", "path": "web/src/ws/client.ts", "text": " private socket?: WebSocket;"}, "score": 0.96}, {"id": "web/src/ws/client.ts:3", "payload": {"line": 3, "nearby_lines": "1: export class WebSocketClient {\n2: private socket?: WebSocket;\n3: private reconnectTimer?: ReturnType;\n4: \n5: connect(url: string) {", "path": "web/src/ws/client.ts", "text": " private reconnectTimer?: ReturnType;"}, "score": 0.96}, {"id": "web/src/ws/client.ts:5", "payload": {"line": 5, "nearby_lines": "3: private reconnectTimer?: ReturnType;\n4: \n5: connect(url: string) {\n6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();", "path": "web/src/ws/client.ts", "text": " connect(url: string) {"}, "score": 0.96}, {"id": "web/src/ws/client.ts:6", "payload": {"line": 6, "nearby_lines": "4: \n5: connect(url: string) {\n6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);", "path": "web/src/ws/client.ts", "text": " this.socket = new WebSocket(url);"}, "score": 0.96}, {"id": "web/src/ws/client.ts:7", "payload": {"line": 7, "nearby_lines": "5: connect(url: string) {\n6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();", "path": "web/src/ws/client.ts", "text": " this.socket.onopen = () => this.clearReconnect();"}, "score": 0.96}, {"id": "web/src/ws/client.ts:8", "payload": {"line": 8, "nearby_lines": "6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();\n10: }", "path": "web/src/ws/client.ts", "text": " this.socket.onclose = () => this.scheduleReconnect(url);"}, "score": 0.96}, {"id": "web/src/ws/client.ts:9", "payload": {"line": 9, "nearby_lines": "7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();\n10: }\n11: ", "path": "web/src/ws/client.ts", "text": " this.socket.onerror = () => this.socket?.close();"}, "score": 0.96}], "selected_count": 16, "stage": "line", "threshold": 0.6, "timestamp": "2026-09-23T04:48:04.437932+00:00"} +{"candidates": [{"id": "server/src/http.ts:1", "payload": {"line": 1, "nearby_lines": "1: export function startHttpServer() {\n2: console.log('http server started');\n3: }", "path": "server/src/http.ts", "text": "export function startHttpServer() {"}}, {"id": "server/src/http.ts:2", "payload": {"line": 2, "nearby_lines": "1: export function startHttpServer() {\n2: console.log('http server started');\n3: }", "path": "server/src/http.ts", "text": " console.log('http server started');"}}, {"id": "server/src/http.ts:3", "payload": {"line": 3, "nearby_lines": "1: export function startHttpServer() {\n2: console.log('http server started');\n3: }", "path": "server/src/http.ts", "text": "}"}}], "count": 3, "event": "candidates_exposed", "parent": "server/src/http.ts", "stage": "line", "timestamp": "2026-09-23T04:48:04.438205+00:00"} +{"event": "offline_scores", "scores": [{"id": "server/src/http.ts:1", "score": 0.05}, {"id": "server/src/http.ts:2", "score": 0.05}, {"id": "server/src/http.ts:3", "score": 0.05}], "stage": "line", "timestamp": "2026-09-23T04:48:04.438293+00:00"} +{"event": "threshold_applied", "input_count": 3, "parent": "server/src/http.ts", "selected": [], "selected_count": 0, "stage": "line", "threshold": 0.6, "timestamp": "2026-09-23T04:48:04.438336+00:00"} +{"candidates": [{"id": "web/src/api/user.ts:1", "payload": {"line": 1, "nearby_lines": "1: export async function loadUser(id: string) {\n2: const response = await fetch(`/api/users/${id}`);\n3: return response.json();", "path": "web/src/api/user.ts", "text": "export async function loadUser(id: string) {"}}, {"id": "web/src/api/user.ts:2", "payload": {"line": 2, "nearby_lines": "1: export async function loadUser(id: string) {\n2: const response = await fetch(`/api/users/${id}`);\n3: return response.json();\n4: }", "path": "web/src/api/user.ts", "text": " const response = await fetch(`/api/users/${id}`);"}}, {"id": "web/src/api/user.ts:3", "payload": {"line": 3, "nearby_lines": "1: export async function loadUser(id: string) {\n2: const response = await fetch(`/api/users/${id}`);\n3: return response.json();\n4: }", "path": "web/src/api/user.ts", "text": " return response.json();"}}, {"id": "web/src/api/user.ts:4", "payload": {"line": 4, "nearby_lines": "2: const response = await fetch(`/api/users/${id}`);\n3: return response.json();\n4: }", "path": "web/src/api/user.ts", "text": "}"}}], "count": 4, "event": "candidates_exposed", "parent": "web/src/api/user.ts", "stage": "line", "timestamp": "2026-09-23T04:48:04.438460+00:00"} +{"event": "offline_scores", "scores": [{"id": "web/src/api/user.ts:1", "score": 0.05}, {"id": "web/src/api/user.ts:2", "score": 0.05}, {"id": "web/src/api/user.ts:3", "score": 0.05}, {"id": "web/src/api/user.ts:4", "score": 0.05}], "stage": "line", "timestamp": "2026-09-23T04:48:04.438577+00:00"} +{"event": "threshold_applied", "input_count": 4, "parent": "web/src/api/user.ts", "selected": [], "selected_count": 0, "stage": "line", "threshold": 0.6, "timestamp": "2026-09-23T04:48:04.438636+00:00"} +{"event": "search_completed", "result": {"directories": [{"id": "web/src", "payload": {"child_directories": ["api", "ws"], "direct_files": [], "name": "src", "path": "web/src"}, "score": 0.84}, {"id": "web/src/ws", "payload": {"child_directories": [], "direct_files": ["client.ts"], "name": "ws", "path": "web/src/ws"}, "score": 0.84}, {"id": "server", "payload": {"child_directories": ["src"], "direct_files": [], "name": "server", "path": "server"}, "score": 0.62}, {"id": "server/src", "payload": {"child_directories": [], "direct_files": ["http.ts"], "name": "src", "path": "server/src"}, "score": 0.62}, {"id": "web", "payload": {"child_directories": ["src"], "direct_files": [], "name": "web", "path": "web"}, "score": 0.62}, {"id": "web/src/api", "payload": {"child_directories": [], "direct_files": ["user.ts"], "name": "api", "path": "web/src/api"}, "score": 0.62}], "files": [{"id": "web/src/ws/client.ts", "payload": {"extension": ".ts", "filename": "client.ts", "path": "web/src/ws/client.ts", "size_bytes": 573}, "score": 0.84}, {"id": "server/src/http.ts", "payload": {"extension": ".ts", "filename": "http.ts", "path": "server/src/http.ts", "size_bytes": 76}, "score": 0.62}, {"id": "web/src/api/user.ts", "payload": {"extension": ".ts", "filename": "user.ts", "path": "web/src/api/user.ts", "size_bytes": 125}, "score": 0.62}], "metrics": {"directories_exposed": 6, "directories_selected": 6, "elapsed_ms": 3.061, "files_exposed": 3, "files_selected": 3, "input_tokens": 0, "lines_exposed": 23, "lines_selected": 16, "model_calls": 0, "output_tokens": 0, "snippets": 1}, "model": "offline-lexical-fixture", "query": "Help me optimize the websocket connection implementation", "root": "/home/runner/work/narness-engineering/narness-engineering/examples/system-one-code-locator/fixtures/repository", "snippets": [{"content": "1: export class WebSocketClient {\n2: private socket?: WebSocket;\n3: private reconnectTimer?: ReturnType;\n4: \n5: connect(url: string) {\n6: this.socket = new WebSocket(url);\n7: this.socket.onopen = () => this.clearReconnect();\n8: this.socket.onclose = () => this.scheduleReconnect(url);\n9: this.socket.onerror = () => this.socket?.close();\n10: }\n11: \n12: private scheduleReconnect(url: string) {\n13: this.reconnectTimer = setTimeout(() => this.connect(url), 1000);\n14: }\n15: \n16: private clearReconnect() {\n17: if (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n18: }\n19: }", "end_line": 19, "path": "web/src/ws/client.ts", "score": 0.96, "start_line": 1}], "thresholds": {"directory": 0.35, "file": 0.5, "line": 0.6}}, "timestamp": "2026-09-23T04:48:04.438729+00:00"} From fbf5c0f981e65a0d88ecb76ff8a8c9ea04958057 Mon Sep 17 00:00:00 2001 From: Nathan <308719298@qq.com> Date: Wed, 23 Sep 2026 12:50:57 +0800 Subject: [PATCH 45/46] research: make code locator a self-contained research unit --- .github/workflows/system-one-code-locator.yml | 24 +- README.md | 4 +- .../README.md | 6 +- examples/system-one-code-locator/README.md | 192 --------------- research/code-locator/README.md | 228 ++++++++++++++++-- .../code-locator/docs/design.md | 4 +- .../pilots/nession-websocket-2026-09-23.md | 0 .../fixtures/repository/server/src/http.ts | 0 .../fixtures/repository/web/src/api/user.ts | 0 .../fixtures/repository/web/src/ws/client.ts | 0 .../README.md | 0 .../offline/result.json | 0 .../offline/run-manifest.json | 0 .../offline/run.log | 0 .../offline/summary.md | 0 .../offline/tests.log | 0 .../offline/trace.jsonl | 0 .../README.md | 0 .../offline/result.json | 0 .../offline/run-manifest.json | 0 .../offline/run.log | 0 .../offline/summary.md | 0 .../offline/tests.log | 0 .../offline/trace.jsonl | 0 .../README.md | 0 .../offline/result.json | 0 .../offline/run-manifest.json | 0 .../offline/run.log | 0 .../offline/summary.md | 0 .../offline/tests.log | 0 .../offline/trace.jsonl | 0 .../src}/system_one_code_locator.py | 0 .../tests}/test_system_one_code_locator.py | 5 +- 33 files changed, 226 insertions(+), 237 deletions(-) delete mode 100644 examples/system-one-code-locator/README.md rename docs/topics/system-one-progressive-action-space/research/code-localization.md => research/code-locator/docs/design.md (97%) rename docs/topics/system-one-progressive-action-space/research/nession-websocket-pilot-2026-09-23.md => research/code-locator/docs/pilots/nession-websocket-2026-09-23.md (100%) rename {examples/system-one-code-locator => research/code-locator}/fixtures/repository/server/src/http.ts (100%) rename {examples/system-one-code-locator => research/code-locator}/fixtures/repository/web/src/api/user.ts (100%) rename {examples/system-one-code-locator => research/code-locator}/fixtures/repository/web/src/ws/client.ts (100%) rename research/code-locator/{ => runs}/20260923T124028+0800-run-35819260887-attempt-1/README.md (100%) rename research/code-locator/{ => runs}/20260923T124028+0800-run-35819260887-attempt-1/offline/result.json (100%) rename research/code-locator/{ => runs}/20260923T124028+0800-run-35819260887-attempt-1/offline/run-manifest.json (100%) rename research/code-locator/{ => runs}/20260923T124028+0800-run-35819260887-attempt-1/offline/run.log (100%) rename research/code-locator/{ => runs}/20260923T124028+0800-run-35819260887-attempt-1/offline/summary.md (100%) rename research/code-locator/{ => runs}/20260923T124028+0800-run-35819260887-attempt-1/offline/tests.log (100%) rename research/code-locator/{ => runs}/20260923T124028+0800-run-35819260887-attempt-1/offline/trace.jsonl (100%) rename research/code-locator/{ => runs}/20260923T124223+0800-run-35819390521-attempt-1/README.md (100%) rename research/code-locator/{ => runs}/20260923T124223+0800-run-35819390521-attempt-1/offline/result.json (100%) rename research/code-locator/{ => runs}/20260923T124223+0800-run-35819390521-attempt-1/offline/run-manifest.json (100%) rename research/code-locator/{ => runs}/20260923T124223+0800-run-35819390521-attempt-1/offline/run.log (100%) rename research/code-locator/{ => runs}/20260923T124223+0800-run-35819390521-attempt-1/offline/summary.md (100%) rename research/code-locator/{ => runs}/20260923T124223+0800-run-35819390521-attempt-1/offline/tests.log (100%) rename research/code-locator/{ => runs}/20260923T124223+0800-run-35819390521-attempt-1/offline/trace.jsonl (100%) rename research/code-locator/{ => runs}/20260923T124813+0800-run-35819796535-attempt-1/README.md (100%) rename research/code-locator/{ => runs}/20260923T124813+0800-run-35819796535-attempt-1/offline/result.json (100%) rename research/code-locator/{ => runs}/20260923T124813+0800-run-35819796535-attempt-1/offline/run-manifest.json (100%) rename research/code-locator/{ => runs}/20260923T124813+0800-run-35819796535-attempt-1/offline/run.log (100%) rename research/code-locator/{ => runs}/20260923T124813+0800-run-35819796535-attempt-1/offline/summary.md (100%) rename research/code-locator/{ => runs}/20260923T124813+0800-run-35819796535-attempt-1/offline/tests.log (100%) rename research/code-locator/{ => runs}/20260923T124813+0800-run-35819796535-attempt-1/offline/trace.jsonl (100%) rename {examples/system-one-code-locator => research/code-locator/src}/system_one_code_locator.py (100%) rename {examples/system-one-code-locator => research/code-locator/tests}/test_system_one_code_locator.py (93%) diff --git a/.github/workflows/system-one-code-locator.yml b/.github/workflows/system-one-code-locator.yml index d1546e72..c6c00577 100644 --- a/.github/workflows/system-one-code-locator.yml +++ b/.github/workflows/system-one-code-locator.yml @@ -3,15 +3,19 @@ name: system-one-code-locator-experiment on: push: paths: - - "examples/system-one-code-locator/**" - - "docs/topics/system-one-progressive-action-space/research/code-localization.md" - - "docs/topics/system-one-progressive-action-space/research/nession-websocket-pilot-2026-09-23.md" + - "research/code-locator/src/**" + - "research/code-locator/tests/**" + - "research/code-locator/fixtures/**" + - "research/code-locator/docs/**" + - "research/code-locator/README.md" - ".github/workflows/system-one-code-locator.yml" pull_request: paths: - - "examples/system-one-code-locator/**" - - "docs/topics/system-one-progressive-action-space/research/code-localization.md" - - "docs/topics/system-one-progressive-action-space/research/nession-websocket-pilot-2026-09-23.md" + - "research/code-locator/src/**" + - "research/code-locator/tests/**" + - "research/code-locator/fixtures/**" + - "research/code-locator/docs/**" + - "research/code-locator/README.md" - ".github/workflows/system-one-code-locator.yml" workflow_dispatch: inputs: @@ -96,13 +100,13 @@ jobs: shell: bash run: | set -o pipefail - python3 -m unittest discover -s examples/system-one-code-locator -p 'test_*.py' -v 2>&1 | tee artifacts/system-one-code-locator/offline/tests.log + python3 -m unittest discover -s research/code-locator/tests -p 'test_*.py' -v 2>&1 | tee artifacts/system-one-code-locator/offline/tests.log - name: Run deterministic fixture experiment shell: bash run: | set -o pipefail - python3 examples/system-one-code-locator/system_one_code_locator.py examples/system-one-code-locator/fixtures/repository "$QUERY" --offline-decider --directory-threshold "$DIRECTORY_THRESHOLD" --file-threshold "$FILE_THRESHOLD" --line-threshold 0.60 --batch-size "$BATCH_SIZE" --trace-file artifacts/system-one-code-locator/offline/trace.jsonl --output-json artifacts/system-one-code-locator/offline/result.json 2>&1 | tee artifacts/system-one-code-locator/offline/run.log + python3 research/code-locator/src/system_one_code_locator.py research/code-locator/fixtures/repository "$QUERY" --offline-decider --directory-threshold "$DIRECTORY_THRESHOLD" --file-threshold "$FILE_THRESHOLD" --line-threshold 0.60 --batch-size "$BATCH_SIZE" --trace-file artifacts/system-one-code-locator/offline/trace.jsonl --output-json artifacts/system-one-code-locator/offline/result.json 2>&1 | tee artifacts/system-one-code-locator/offline/run.log - name: Save run metadata and summary env: @@ -265,7 +269,7 @@ jobs: shell: bash run: | set -o pipefail - python3 narness/examples/system-one-code-locator/system_one_code_locator.py subject "$QUERY" --directory-threshold "$DIRECTORY_THRESHOLD" --file-threshold "$FILE_THRESHOLD" --line-threshold "$LINE_THRESHOLD" --batch-size "$BATCH_SIZE" --model "$TYPESAFE_MODEL" --trace-file artifacts/system-one-code-locator/typesafe/trace.jsonl --output-json artifacts/system-one-code-locator/typesafe/result.json 2>&1 | tee artifacts/system-one-code-locator/typesafe/run.log + python3 narness/research/code-locator/src/system_one_code_locator.py subject "$QUERY" --directory-threshold "$DIRECTORY_THRESHOLD" --file-threshold "$FILE_THRESHOLD" --line-threshold "$LINE_THRESHOLD" --batch-size "$BATCH_SIZE" --model "$TYPESAFE_MODEL" --trace-file artifacts/system-one-code-locator/typesafe/trace.jsonl --output-json artifacts/system-one-code-locator/typesafe/result.json 2>&1 | tee artifacts/system-one-code-locator/typesafe/run.log - name: Build research summary if: always() @@ -376,7 +380,7 @@ jobs: set -euo pipefail stamp="$(TZ=Asia/Shanghai date +'%Y%m%dT%H%M%S%z')" - record="research/code-locator/${stamp}-run-${GITHUB_RUN_ID}-attempt-${GITHUB_RUN_ATTEMPT}" + record="research/code-locator/runs/${stamp}-run-${GITHUB_RUN_ID}-attempt-${GITHUB_RUN_ATTEMPT}" mkdir -p "$record" if test -d .experiment-record/offline; then diff --git a/README.md b/README.md index 2fb4dc6e..d80e5dc7 100644 --- a/README.md +++ b/README.md @@ -224,7 +224,7 @@ bash plugins/narness/scripts/narness-rust-test-integration.sh examples/rust-work The example contains a root workspace contract, a task Skill with progressive disclosure, unit and integration evidence, an environment declaration, and a stable CI required gate. -The repository also contains research prototypes that are intentionally outside the canonical Narness runtime scope, including the [System One Kubernetes command generator](examples/system-one-k8s/README.md) and [System One code locator](examples/system-one-code-locator/README.md) used by the progressive-action-space topic. +The repository also contains research prototypes that are intentionally outside the canonical Narness runtime scope, including the [System One Kubernetes command generator](examples/system-one-k8s/README.md) and [System One code locator](research/code-locator/README.md) used by the progressive-action-space topic. ## Adopt Narness @@ -259,7 +259,7 @@ Start with [docs/adoption.md](docs/adoption.md): - [Change-to-Evidence Planning topic](docs/topics/change-to-evidence-planning/README.md) - [System One Progressive Action Spaces topic](docs/topics/system-one-progressive-action-space/README.md) - [System One Kubernetes command generator](examples/system-one-k8s/README.md) -- [System One code locator](examples/system-one-code-locator/README.md) +- [System One code locator](research/code-locator/README.md) - [AI Workspace architecture](docs/architecture.md) - [Adoption guide](docs/adoption.md) - [Runnable Rust example](examples/rust-workspace/README.md) diff --git a/docs/topics/system-one-progressive-action-space/README.md b/docs/topics/system-one-progressive-action-space/README.md index 0bb6c707..e5e5efd4 100644 --- a/docs/topics/system-one-progressive-action-space/README.md +++ b/docs/topics/system-one-progressive-action-space/README.md @@ -621,7 +621,7 @@ The decision primitive can therefore vary by state: - `Noul` for independently retaining multiple relevant candidates; - deterministic short-circuiting where model judgment is unnecessary. -See [Hierarchical Code Localization with System One](research/code-localization.md) for the hypotheses, threshold/recall analysis, evidence contract, and experiment plan. +See [Hierarchical Code Localization with System One](../../../research/code-locator/docs/design.md) for the hypotheses, threshold/recall analysis, evidence contract, and experiment plan. ## 19. Research evidence workflows @@ -652,8 +652,8 @@ If the conclusions stabilize, some of them may graduate into Narness concepts ar ## Reference implementations - [System One Kubernetes Command Generator](../../../examples/system-one-k8s/README.md) -- [System One Code Locator](../../../examples/system-one-code-locator/README.md) -- [Code localization research note](research/code-localization.md) +- [System One Code Locator](../../../research/code-locator/README.md) +- [Code localization research note](../../../research/code-locator/docs/design.md) - [System One Kubernetes experiment workflow](../../../.github/workflows/system-one-k8s-experiment.yml) - [System One Code Locator experiment workflow](../../../.github/workflows/system-one-code-locator.yml) diff --git a/examples/system-one-code-locator/README.md b/examples/system-one-code-locator/README.md deleted file mode 100644 index 5c9df1ed..00000000 --- a/examples/system-one-code-locator/README.md +++ /dev/null @@ -1,192 +0,0 @@ -# System One Code Locator - -> Experimental research prototype. This is a localization harness, not a code-changing agent and not part of the canonical Narness runtime. - -This example explores whether a fast System One model can localize code by repeatedly judging a progressively disclosed search space rather than driving repository browsing through a ReAct loop. - -Given a request such as: - -> Help me optimize the websocket connection implementation. - -and a repository root, the harness performs: - -```text -repository - -> enumerate directory candidates - -> System One relevance scores - -> keep directories above threshold - -> enumerate files under retained directories - -> System One relevance scores - -> keep files above threshold - -> split retained files into source lines with small local context - -> System One relevance scores - -> merge adjacent relevant lines into snippets -``` - -The model never chooses filesystem tools, constructs paths, or controls traversal. The harness owns state expansion, thresholds, IO, provenance, batching, and result assembly. - -## Why Noul instead of Choice - -Directory, file, and line relevance are independent judgments: several candidates may all be relevant. The TypeSafe System One API's `noul` primitive returns a yes-probability for each question, so the runtime can retain every candidate whose score crosses the stage threshold. - -`choice` would instead normalize probability across candidates and force one winner, which is appropriate for the Kubernetes action-frontier demo but not for multi-hit code localization. - -## State progression - -```text -RepositoryState - | - | deterministic enumeration - v -DirectoryCandidate[] - | - | Noul relevance + low threshold - v -RelevantDirectory[] - | - | deterministic enumeration - v -FileCandidate[] - | - | Noul relevance + medium threshold - v -RelevantFile[] - | - | read source + split on newlines - v -LineCandidate[] - | - | Noul relevance + higher threshold - v -RelevantLine[] - | - | deterministic range merge - v -CodeSnippet[] -``` - -The defaults intentionally become stricter as the search gets deeper: - -```text -directory >= 0.35 -file >= 0.50 -line >= 0.70 -``` - -These are experiment parameters, not claimed optimal values. Early false negatives are especially expensive because pruning a directory removes its entire subtree. A future experiment should compare simple thresholds against threshold-plus-beam retention. - -## Run the deterministic fixture - -No API key is required: - -```bash -python3 examples/system-one-code-locator/system_one_code_locator.py \ - examples/system-one-code-locator/fixtures/repository \ - "Help me optimize the websocket connection implementation" \ - --offline-decider \ - --line-threshold 0.60 -``` - -The offline scorer is only a deterministic fixture implementation. It is not intended to emulate System One quality. - -## Run with TypeSafe System One - -```bash -export TYPESAFE_API_KEY=... - -python3 examples/system-one-code-locator/system_one_code_locator.py \ - /path/to/repository \ - "Help me optimize the websocket connection implementation" -``` - -Optional environment variables: - -```bash -export TYPESAFE_API_URL=https://api.typesafe.ai/v1/systemone -export TYPESAFE_MODEL=jev-latest -``` - -## Research trace - -Use `--trace-file` to create an append-only JSONL trace and `--output-json` to persist the final result: - -```bash -python3 examples/system-one-code-locator/system_one_code_locator.py \ - /path/to/repository \ - "Help me optimize the websocket connection implementation" \ - --trace-file evidence/code-locator.trace.jsonl \ - --output-json evidence/code-locator.result.json -``` - -The trace records: - -- the query, model, root, and thresholds; -- every directory/file/line candidate disclosed by the harness; -- every TypeSafe request body without credentials; -- model responses reduced to candidate scores, latency, and token usage; -- every threshold application and retained candidate set; -- the final result and aggregate metrics. - -This makes a workflow run useful as research evidence rather than only as a pass/fail CI event. - -## Output contract - -The final result contains three provenance-preserving layers: - -```text -relevant directories -relevant files -relevant snippets { path, start_line, end_line, score, content } -``` - -It also reports exposed/selected counts, model calls, token usage, and elapsed time. - -## Tests - -```bash -python3 -m unittest discover \ - -s examples/system-one-code-locator \ - -p 'test_*.py' \ - -v -``` - -The tests verify that the deterministic fixture finds the websocket client and that real API requests use independent Noul questions. - -## Dedicated research workflow - -Code Locator has its own GitHub Actions workflow: - -```text -.github/workflows/system-one-code-locator.yml -``` - -It does not run the Kubernetes experiment. - -On relevant pushes and pull requests it runs only the deterministic Code Locator fixture and uploads: - -```text -system-one-code-locator-offline--/ - run-manifest.json - tests.log - run.log - result.json - trace.jsonl - summary.md -``` - -A manual `workflow_dispatch` can additionally run the real TypeSafe experiment against a configurable subject repository. That job uses the `typesafe` environment and uploads a separate `system-one-code-locator-typesafe-*` artifact. - -## Research limitations - -The current prototype intentionally leaves several questions open: - -- whether whole-tree directory enumeration is better than recursive frontier expansion; -- threshold calibration and compounding false-negative risk; -- threshold-only pruning versus keeping a minimum semantic beam; -- line-level scoring versus symbol/block/chunk-level scoring; -- caching repeated judgments across nearby queries; -- comparison against ripgrep, embeddings, language-server indexes, and System Two browsing; -- evaluation against gold relevant-file and relevant-range labels; -- escalation when no candidate survives a stage. - -See the [System One Progressive Action Spaces topic](../../docs/topics/system-one-progressive-action-space/README.md) for the shared model behind this demo and the Kubernetes command generator. diff --git a/research/code-locator/README.md b/research/code-locator/README.md index 9fb2306b..9c534649 100644 --- a/research/code-locator/README.md +++ b/research/code-locator/README.md @@ -1,43 +1,219 @@ -# System One Code Locator experiment records +# System One Code Locator -This directory contains repository-persisted evidence for Code Locator experiment runs. +> Experimental research project. This is a localization harness, not a code-changing agent and not part of the canonical Narness runtime. -Each recorded workflow run uses a time + GitHub run ID directory: +This directory is the complete Code Locator research unit: implementation, fixtures, tests, design notes, pilot analyses, and immutable run records live together here. + +## Project layout ```text -YYYYMMDDTHHMMSS+0800-run--attempt-/ +research/code-locator/ +├── README.md +├── src/ +│ └── system_one_code_locator.py +├── tests/ +│ └── test_system_one_code_locator.py +├── fixtures/ +│ └── repository/ +├── docs/ +│ ├── design.md +│ └── pilots/ +│ └── nession-websocket-2026-09-23.md +└── runs/ + └──