Skip to content

Commit 6012790

Browse files
committed
Add domain routed data pipeline and graph sidecars
1 parent 49f98a6 commit 6012790

1,071 files changed

Lines changed: 29110 additions & 463 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
outputs/**/*.bin filter=lfs diff=lfs merge=lfs -text
2+
outputs/conveyor/**/*.jsonl filter=lfs diff=lfs merge=lfs -text

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ outputs/sidecar_audit_commit_pr_8k_verified/sidecar_parquet_audit.md
118118
outputs/sidecar_audit_pr_1k_2k_4k_8k/sidecar_parquet_audit.json
119119
outputs/sidecar_audit_pr_1k_2k_4k_8k/sidecar_parquet_audit.md
120120
outputs/conveyor/progress_code.jsonl
121+
outputs/conveyor/extract_cache/kodi/kodi_commits.jsonl
121122
outputs/conveyor/progress_commits.jsonl
122123
outputs/conveyor/locks/code.lock
123124
outputs/conveyor/locks/commits.lock
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Domain-routed cppmega world-code training recipe.
2+
#
3+
# This config is intentionally declarative: runners may map these weights into
4+
# their own task-mixer implementation, but graph routes are not optional for
5+
# cppmega world/code model runs.
6+
7+
tokenizer_contract: cppmega_mlx/tokenizer/tokenizer_contract_v1.json
8+
sequence_curriculum: [1024, 2048, 4096, 8192, 16384]
9+
10+
requirements:
11+
require_domain_delimiters: true
12+
require_token_sidecars:
13+
- token_domain_ids
14+
- token_role_ids
15+
- token_confidence_ids
16+
- token_structure_ids
17+
- token_dep_levels
18+
require_graph_sidecars:
19+
- token_call_edges
20+
- token_type_edges
21+
- token_domain_edges
22+
- token_build_edges
23+
- token_shell_edges
24+
- token_diagnostic_edges
25+
- token_cross_domain_edges
26+
allow_token_only_baseline: false
27+
28+
model_inputs:
29+
side_embeddings:
30+
domain_ids: true
31+
role_ids: true
32+
confidence_ids: true
33+
structure_ids: true
34+
dep_levels: true
35+
ast_depth: true
36+
graph_bias:
37+
dense_gqa: true
38+
dsa_topk: true
39+
beta_code: 1.0
40+
beta_build: 1.0
41+
beta_shell: 0.75
42+
beta_diagnostic: 2.0
43+
beta_cross_domain: 2.0
44+
45+
stages:
46+
stage1_foundation:
47+
mix:
48+
cpp_code: 0.58
49+
build_files: 0.10
50+
shell_scripts: 0.04
51+
diagnostics: 0.03
52+
fim_ifim: 0.15
53+
graph_indexer: 0.10
54+
objectives:
55+
causal_lm: 1.0
56+
opener_domain_classification: 0.05
57+
graph_edge_prediction: 0.05
58+
graph_indexer_bce: 0.10
59+
graph_indexer_coverage: 0.05
60+
stage2_repair_midtrain:
61+
mix:
62+
cpp_code: 0.20
63+
commit_pr_transform: 0.45
64+
build_diagnostics: 0.15
65+
fim_ifim: 0.15
66+
graph_indexer: 0.05
67+
objectives:
68+
causal_lm: 1.0
69+
diff_prediction: 0.25
70+
cross_domain_retrieval: 0.10
71+
diagnostic_conditioned_ifim: 0.20
72+
stage3_world_trajectory:
73+
mix:
74+
tool_trajectories: 0.35
75+
compile_test_observations: 0.25
76+
commit_pr_transform: 0.25
77+
cpp_code: 0.15
78+
objectives:
79+
transition_model: 0.50
80+
reward_prediction: 0.05
81+
next_action_prediction: 0.15
82+
patch_generation: 0.30
83+
84+
domains:
85+
build_kinds:
86+
- cmake
87+
- make
88+
- ninja
89+
- bazel
90+
- autoconf
91+
- automake
92+
- meson
93+
- gn
94+
- scons
95+
- xmake
96+
shell_kinds:
97+
- sh
98+
- bash
99+
- zsh
100+
- tcsh
101+
diagnostics:
102+
raw_without_edges_allowed_only_with_parse_confidence_raw: true

cppmega_mlx/data/agent_trajectory.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@
3737
from pathlib import Path
3838
from typing import Any
3939

40+
from cppmega_mlx.data.build_parsers.base import ParsedDomainDocument
41+
from cppmega_mlx.data.diagnostic_parsers import (
42+
parse_build_error,
43+
parse_clang_diagnostic,
44+
parse_linker_error,
45+
)
46+
from cppmega_mlx.data.shell_parsers import parse_bash, parse_sh, parse_tcsh, parse_zsh
47+
4048
# --------------------------------------------------------------------------- #
4149
# Action-kind classification
4250
# --------------------------------------------------------------------------- #
@@ -116,6 +124,59 @@ def classify_action(tool_name: str, command: str | None) -> str:
116124
return ACTION_OTHER
117125

118126

127+
def parse_shell_action_domain(
128+
command: str,
129+
*,
130+
shell_kind: str | None = None,
131+
) -> ParsedDomainDocument:
132+
"""Parse a trajectory shell action into the matching shell domain.
133+
134+
Unknown shell stays POSIX ``sh``. We do not label it bash unless the caller
135+
or command itself gives evidence, because bash/zsh/tcsh have different
136+
syntax and should remain separate domains for training.
137+
"""
138+
139+
kind = (shell_kind or "").strip().lower()
140+
stripped = command.lstrip()
141+
if not kind:
142+
if stripped.startswith("#!"):
143+
first = stripped.splitlines()[0]
144+
if "zsh" in first:
145+
kind = "zsh"
146+
elif "tcsh" in first or "csh" in first:
147+
kind = "tcsh"
148+
elif "bash" in first:
149+
kind = "bash"
150+
else:
151+
kind = "sh"
152+
else:
153+
head = stripped.split(maxsplit=1)[0] if stripped else ""
154+
kind = head if head in {"bash", "zsh", "tcsh", "sh"} else "sh"
155+
156+
if kind == "bash":
157+
return parse_bash(command)
158+
if kind == "zsh":
159+
return parse_zsh(command)
160+
if kind == "tcsh":
161+
return parse_tcsh(command)
162+
return parse_sh(command)
163+
164+
165+
def parse_result_diagnostic_domain(result_text: str) -> ParsedDomainDocument | None:
166+
"""Parse a build/test/tool result into a diagnostic domain when possible."""
167+
168+
if not result_text.strip():
169+
return None
170+
lower = result_text.lower()
171+
if "undefined reference" in lower or "unresolved external symbol" in lower:
172+
return parse_linker_error(result_text)
173+
if re.search(r"^[^\n:]+:\d+:\d+:\s+(fatal error|error|warning|note):", result_text, re.MULTILINE):
174+
return parse_clang_diagnostic(result_text)
175+
if "cmake error" in lower or "ninja:" in lower or "build stopped" in lower:
176+
return parse_build_error(result_text)
177+
return None
178+
179+
119180
# --------------------------------------------------------------------------- #
120181
# Transition record (flat parquet-friendly schema)
121182
# --------------------------------------------------------------------------- #
@@ -799,6 +860,8 @@ def write_parquet(transitions: list[AgentTransition], out_path: Path) -> Path:
799860
"enumerate_remote_sessions",
800861
"extract_all",
801862
"extract_session",
863+
"parse_result_diagnostic_domain",
864+
"parse_shell_action_domain",
802865
"walk_claude",
803866
"walk_codex",
804867
"write_parquet",
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""Deterministic build-system domain parsers."""
2+
3+
from cppmega_mlx.data.build_parsers.autotools import parse_autoconf, parse_automake
4+
from cppmega_mlx.data.build_parsers.bazel import parse_bazel
5+
from cppmega_mlx.data.build_parsers.cmake import parse_cmake
6+
from cppmega_mlx.data.build_parsers.make import parse_make
7+
from cppmega_mlx.data.build_parsers.ninja import parse_ninja
8+
9+
__all__ = [
10+
"parse_autoconf",
11+
"parse_automake",
12+
"parse_bazel",
13+
"parse_cmake",
14+
"parse_make",
15+
"parse_ninja",
16+
]
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""Autoconf / Automake build-domain parser."""
2+
3+
from __future__ import annotations
4+
5+
from cppmega_mlx.data.build_parsers.base import ParsedDomainDocument
6+
from cppmega_mlx.data.build_parsers.make import parse_automake
7+
from cppmega_mlx.data.domain_schema import (
8+
DomainKind,
9+
DomainRoleKind,
10+
ParseConfidence,
11+
)
12+
13+
14+
_AUTOCONF_MACROS = {
15+
"AC_INIT",
16+
"AC_CONFIG_FILES",
17+
"AC_PROG_CC",
18+
"AC_PROG_CXX",
19+
"AM_INIT_AUTOMAKE",
20+
"PKG_CHECK_MODULES",
21+
}
22+
23+
24+
def parse_autoconf(text: str) -> ParsedDomainDocument:
25+
doc = ParsedDomainDocument.new(
26+
domain=DomainKind.AUTOCONF,
27+
text=text,
28+
confidence=ParseConfidence.HEURISTIC,
29+
metadata={"build_kind": "autoconf"},
30+
)
31+
next_entity = 1
32+
for idx, token in enumerate(doc.tokens):
33+
value = token.text
34+
if value in _AUTOCONF_MACROS or value.startswith("AC_") or value.startswith("AM_"):
35+
doc.set_role(idx, DomainRoleKind.COMMAND, entity=next_entity)
36+
next_entity += 1
37+
elif value.startswith("$"):
38+
doc.set_role(idx, DomainRoleKind.VARIABLE)
39+
return doc
40+
41+
42+
__all__ = ["parse_autoconf", "parse_automake"]

0 commit comments

Comments
 (0)