harness-everything 0.51.0 → 0.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.github/workflows/ci.yml +23 -0
  4. package/CHANGELOG.md +34 -0
  5. package/benchmarks/results/doc-evidence-e1/cycle-2026-11-11-a-evid-001.md +123 -0
  6. package/benchmarks/results/doc-evidence-e1/cycle-2026-11-11-b-route-001.md +130 -0
  7. package/ci/mechanism-2am-observations-session-import.test.js +4 -1
  8. package/ci/mechanism-34-observations.test.js +127 -23
  9. package/ci/mechanism-349-ci-change-scope.test.js +260 -0
  10. package/ci/mechanism-handoff-file.test.js +121 -0
  11. package/ci/mechanism-system-one-contract.test.js +9 -2
  12. package/ci/mechanism-system-one-curves.test.js +206 -0
  13. package/ci/mechanism-system-one-cycle.test.js +585 -0
  14. package/ci/mechanism-system-one-evaluation.test.js +32 -5
  15. package/ci/mechanism-system-one-handoff-input.test.js +208 -0
  16. package/ci/mechanism-system-one-install.test.js +202 -77
  17. package/ci/mechanism-system-one-live.test.js +361 -0
  18. package/ci/mechanism-system-one-relevance.test.js +11 -1
  19. package/ci/mechanism-system-one-train.test.js +136 -53
  20. package/ci/system-one-adapter-test.py +331 -0
  21. package/ci/system-one-train-test.py +116 -24
  22. package/docs/adr/EVID-001.md +123 -0
  23. package/docs/adr/ROUTE-001-error-lesson-delivery.md +305 -0
  24. package/docs/governed-index.md +2 -0
  25. package/docs/routing.md +2 -2
  26. package/docs/system-one-cycle.md +68 -0
  27. package/docs/system-one-observations.md +9 -8
  28. package/docs/system-one-routing.md +163 -115
  29. package/docs/system-one-suggestion-gates.md +6 -8
  30. package/docs/system-one-training.md +44 -7
  31. package/docs/workflow-runtime.md +19 -0
  32. package/harness-everything/SKILL.md +1 -1
  33. package/harness-everything/scripts/kernel-router.js +2 -1
  34. package/harness-everything/scripts/system-one/contract.js +19 -15
  35. package/harness-everything/scripts/system-one/cua_adapter.py +211 -17
  36. package/harness-everything/scripts/system-one/evaluate.js +4 -9
  37. package/harness-everything/scripts/system-one/handoff-input.js +76 -0
  38. package/harness-everything/scripts/system-one/install.js +281 -113
  39. package/harness-everything/scripts/system-one/manifest.js +58 -0
  40. package/harness-everything/scripts/system-one/provider.js +96 -2
  41. package/harness-everything/scripts/system-one/resident.js +47 -1
  42. package/harness-everything/scripts/system-one/router.js +80 -1
  43. package/harness-everything/scripts/tier-router.js +21 -6
  44. package/hooks/scripts/lib/observations.js +43 -4
  45. package/opencode-plugin/plugin.json +1 -1
  46. package/package.json +1 -1
  47. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  48. package/plugins/harness-everything/hooks/scripts/lib/observations.js +43 -4
  49. package/plugins/harness-everything/plugin.json +1 -1
  50. package/plugins/harness-everything/scripts/handoff-file.js +223 -0
  51. package/plugins/harness-everything/skills/harness-everything/SKILL.md +1 -1
  52. package/plugins/harness-everything/skills/harness-everything/scripts/kernel-router.js +2 -1
  53. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/contract.js +19 -15
  54. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/cua_adapter.py +211 -17
  55. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/evaluate.js +4 -9
  56. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/handoff-input.js +76 -0
  57. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/install.js +281 -113
  58. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/manifest.js +58 -0
  59. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/provider.js +96 -2
  60. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/resident.js +47 -1
  61. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/router.js +80 -1
  62. package/plugins/harness-everything/skills/harness-everything/scripts/tier-router.js +21 -6
  63. package/sbom.cdx.json +7 -7
  64. package/scripts/ci-change-scope.js +59 -0
  65. package/scripts/handoff-file.js +223 -0
  66. package/scripts/sync-openai-plugin.js +4 -0
  67. package/scripts/system-one-calibrate.js +108 -41
  68. package/scripts/system-one-curves.js +332 -0
  69. package/scripts/system-one-cycle/adjudication-input.js +65 -0
  70. package/scripts/system-one-cycle/build.js +165 -0
  71. package/scripts/system-one-cycle/collect.js +50 -0
  72. package/scripts/system-one-cycle/common.js +137 -0
  73. package/scripts/system-one-cycle/engines.js +62 -0
  74. package/scripts/system-one-cycle/evaluate.js +70 -0
  75. package/scripts/system-one-cycle/judge.js +106 -0
  76. package/scripts/system-one-cycle/label.js +59 -0
  77. package/scripts/system-one-cycle/package.js +173 -0
  78. package/scripts/system-one-cycle/score.py +111 -0
  79. package/scripts/system-one-cycle/train.js +136 -0
  80. package/scripts/system-one-cycle.js +131 -0
  81. package/scripts/system-one-observations-export.js +29 -6
  82. package/scripts/system-one-observations-review.js +4 -5
  83. package/scripts/system-one-train.py +117 -61
@@ -37,13 +37,12 @@ body{margin:0;background:var(--bg);color:var(--fg);font:16px/1.6 system-ui,-appl
37
37
  main{max-width:860px;margin:0 auto;padding:16px}.box{white-space:pre-wrap;word-break:break-word;background:var(--card);border:1px solid var(--bd);border-radius:10px;padding:14px;max-height:40vh;overflow:auto}
38
38
  .prev{font-size:14px;color:var(--mut)}label{margin-right:16px}select,button{font:inherit;padding:6px 10px;border-radius:8px;border:1px solid var(--bd);background:var(--card);color:var(--fg)}
39
39
  .row{display:flex;gap:12px;flex-wrap:wrap;align-items:center;margin:12px 0}</style></head><body><main>
40
- <p class="prev">Review the prompt with its previous assistant message. Decide validity, whether the prompt needs the earlier conversation to be understood, and the tier of the work it asked for.</p>
40
+ <p class="prev">Decide whether the prompt can be understood from its own text and the tier of the work it asks for. Agent-written dispatches and worker instructions are ordinary prompts.</p>
41
41
  <div class="row"><span id="pos"></span><button id="prev">&larr;</button><button id="next">&rarr;</button><button id="exp">Export JSON</button><span id="stat" class="prev"></span></div>
42
42
  <h3>Previous assistant message</h3><div class="box prev" id="previous"></div>
43
43
  <h3>Prompt</h3><div class="box" id="prompt"></div>
44
44
  <h3>Behavior evidence</h3><div class="box" id="behavior"></div>
45
45
  <div class="row"><label>Validity <select id="validity"><option value="">—</option><option>actionable</option><option>invalid</option><option>unsure</option></select></label>
46
- <label>Needs context <select id="contextDependent"><option value="">—</option><option value="true">yes</option><option value="false">no</option></select></label>
47
46
  <label>Tier <select id="tier"><option value="">—</option><option>tier1</option><option>tier2</option><option>tier3</option></select></label></div>
48
47
  </main><script>
49
48
  const ITEMS=${data};const KEY='harness-observation-review';
@@ -53,9 +52,9 @@ function save(){try{localStorage.setItem(KEY,JSON.stringify(st))}catch(e){}}
53
52
  function render(){if(!ITEMS.length){$('prompt').textContent='Nothing to review.';return}const it=ITEMS[i],d=st[it.id]||{};
54
53
  $('pos').textContent=(i+1)+' / '+ITEMS.length;$('prompt').textContent=it.prompt;$('previous').textContent=it.previous||'(none)';
55
54
  $('behavior').textContent=it.behaviorEvidence==='observed'?'Observed by local hook collection.':'Behavior evidence is unobserved; session backfill did not record tool events or file writes.';
56
- $('validity').value=d.validity||'';$('tier').value=d.tier||'';$('contextDependent').value=typeof d.contextDependent==='boolean'?String(d.contextDependent):'';$('stat').textContent='decided '+Object.keys(st).length}
57
- function set(){const it=ITEMS[i];const cd=$('contextDependent').value;st[it.id]={id:it.id,validity:$('validity').value||null,contextDependent:cd==='true'?true:cd==='false'?false:null,tier:$('tier').value||null,decidedAt:new Date().toISOString()};save();render()}
58
- $('validity').onchange=set;$('contextDependent').onchange=set;$('tier').onchange=set;$('prev').onclick=()=>{if(i>0)i--;render()};$('next').onclick=()=>{if(i<ITEMS.length-1)i++;render()};
55
+ $('validity').value=d.validity||'';$('tier').value=d.tier||'';$('stat').textContent='decided '+Object.keys(st).length}
56
+ function set(){const it=ITEMS[i];st[it.id]={id:it.id,validity:$('validity').value||null,tier:$('tier').value||null,decidedAt:new Date().toISOString()};save();render()}
57
+ $('validity').onchange=set;$('tier').onchange=set;$('prev').onclick=()=>{if(i>0)i--;render()};$('next').onclick=()=>{if(i<ITEMS.length-1)i++;render()};
59
58
  $('exp').onclick=()=>{const b=new Blob([JSON.stringify({schemaVersion:1,review:KEY,decisions:Object.values(st)},null,1)],{type:'application/json'});const a=document.createElement('a');a.href=URL.createObjectURL(b);a.download='observation-review-decisions.json';a.click()};
60
59
  render();
61
60
  </script></body></html>`;
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env python3
2
- """Train the System One harness-routing-v1 tier scorer (docs/system-one-training.md).
2
+ """Train the System One harness-routing-v1 scorer (docs/system-one-training.md).
3
3
 
4
4
  Run with the System One venv Python (torch + pinned cua_s1). Data handling is stdlib-only so it is
5
5
  tested without torch; torch and cua_s1 are imported only inside train().
@@ -14,6 +14,13 @@ import sys
14
14
  sys.dont_write_bytecode = True
15
15
  REPO = Path(__file__).resolve().parents[1]
16
16
  DEFAULT_HOLDOUT = REPO / 'benchmarks' / 'fixtures' / 'system-one-holdout.json'
17
+ DEFAULT_INTENT_HOLDOUT = REPO / 'benchmarks' / 'fixtures' / 'system-one-intent-holdout.json'
18
+ TIER_IDS = ('tier1', 'tier2', 'tier3')
19
+ OPTION_TOKENS = 96
20
+ # Whole-forward-pass budget: prompt tokens plus one pass over every option, per example. Attention memory
21
+ # grows with the square of the sequence length, so a large budget packs many long prompts into one batch
22
+ # and OOMs the 6 GB guard; 16,384 keeps the observed peak near 1.0-1.7 GB.
23
+ TOKEN_BUDGET = 16384
17
24
 
18
25
 
19
26
  def load_jsonl(path):
@@ -25,50 +32,87 @@ def sha256_file(path):
25
32
 
26
33
 
27
34
  def catalog_from_holdout(path):
28
- """The fixed tier catalog, taken from the evaluation corpus so training and inference match."""
35
+ """Read the fixed option catalog from the evaluation corpus."""
29
36
  corpus = json.loads(Path(path).read_text(encoding='utf-8'))
30
37
  return [{'id': o['id'], 'text': o['text']} for o in corpus['cases'][0]['request']['options']]
31
38
 
32
39
 
33
- def label_index(gold, catalog):
34
- target = 'unclassified' if gold is None else gold
35
- for i, option in enumerate(catalog):
36
- if option['id'] == target:
37
- return i
38
- raise ValueError(f'unknown gold label: {gold!r}')
40
+ def catalog_for(task, holdout=None):
41
+ if task == 'validity':
42
+ return [{'id': 'invalid', 'text': 'Needs previous conversation context to understand; the current text alone is insufficient.'}]
43
+ if task not in ('intent', 'tier'):
44
+ raise ValueError(f'unknown task: {task!r}')
45
+ path = holdout or (DEFAULT_INTENT_HOLDOUT if task == 'intent' else DEFAULT_HOLDOUT)
46
+ catalog = catalog_from_holdout(path)
47
+ if task == 'tier':
48
+ catalog = [option for option in catalog if option['id'] in TIER_IDS]
49
+ if tuple(option['id'] for option in catalog) != TIER_IDS:
50
+ raise ValueError('tier holdout must define tier1, tier2, and tier3')
51
+ return catalog
39
52
 
40
53
 
41
- def join(prompts, labels, overrides):
42
- """Labeled examples in prompt order; owner overrides replace LLM labels; duplicates are an error."""
43
- gold = {}
54
+ def join(prompts, labels):
55
+ """Join prompt text to its label row; duplicate label ids are an error."""
56
+ by_id = {}
44
57
  for row in labels:
45
- if row['id'] in gold:
58
+ if row['id'] in by_id:
46
59
  raise ValueError(f'duplicate label for {row["id"]}')
47
- gold[row['id']] = row['gold']
48
- for row in overrides:
49
- gold[row['id']] = row['gold']
50
- return [{'id': p['id'], 'split': p['split'], 'text': p['text'], 'gold': gold[p['id']]} for p in prompts if p['id'] in gold]
51
-
52
-
53
- def class_weights(label_indices, num_classes):
54
- """Inverse-frequency weights that average to 1 over the examples; absent classes get 0."""
55
- counts = [0] * num_classes
56
- for i in label_indices:
57
- counts[i] += 1
58
- present = sum(1 for c in counts if c)
59
- total = len(label_indices)
60
- return [total / (present * c) if c else 0.0 for c in counts]
61
-
62
-
63
- def make_batches(lengths, token_budget):
64
- """Length-bucketed batches: each batch's size times its longest item stays within the budget."""
65
- order = sorted(range(len(lengths)), key=lambda i: (lengths[i], i))
60
+ by_id[row['id']] = row
61
+ return [{**p, **by_id[p['id']]} for p in prompts if p['id'] in by_id]
62
+
63
+
64
+ def eligible_rows(rows, task):
65
+ return rows if task == 'validity' else [row for row in rows if row['gold'] is not None]
66
+
67
+
68
+ def build_targets(row, catalog, task, target='label'):
69
+ ids = [option['id'] for option in catalog]
70
+ if task == 'validity':
71
+ if row['gold'] is not None and row['gold'] not in TIER_IDS:
72
+ raise ValueError(f'unknown tier gold label: {row["gold"]!r}')
73
+ return [float(row['gold'] is None)]
74
+ if row['gold'] is None:
75
+ raise ValueError(f'null gold is not eligible for {task}')
76
+ if task == 'tier':
77
+ if row['gold'] not in ids:
78
+ raise ValueError(f'unknown gold label: {row["gold"]!r}')
79
+ return [float(option == row['gold']) for option in ids]
80
+ if task != 'intent':
81
+ raise ValueError(f'unknown task: {task!r}')
82
+ if target == 'scores':
83
+ scores = row.get('scores') or {}
84
+ values = [float(scores.get(option, 0.0)) for option in ids]
85
+ if any(not 0.0 <= value <= 1.0 for value in values):
86
+ raise ValueError('intent scores must be between 0 and 1')
87
+ return values
88
+ if target != 'label':
89
+ raise ValueError(f'unknown target: {target!r}')
90
+ positive = {row['gold'], *row.get('secondary', [])}
91
+ if not positive.issubset(ids):
92
+ raise ValueError(f'unknown intent label: {sorted(positive - set(ids))!r}')
93
+ return [float(option in positive) for option in ids]
94
+
95
+
96
+ def target_gold(row, task):
97
+ return ('invalid' if row['gold'] is None else 'actionable') if task == 'validity' else row['gold']
98
+
99
+
100
+ def validation_record(row, catalog, probabilities, task):
101
+ return {'id': row['id'], 'gold': target_gold(row, task),
102
+ 'scores': dict(zip((option['id'] for option in catalog), probabilities))}
103
+
104
+
105
+ def make_batches(lengths, token_budget, n_options, option_tokens):
106
+ """Length-bucketed batches: each batch's size times its longest item's forward-pass cost
107
+ (prompt tokens plus one pass over every option) stays within the whole-pass budget."""
108
+ costs = [length + n_options * option_tokens for length in lengths]
109
+ order = sorted(range(len(costs)), key=lambda i: (costs[i], i))
66
110
  batches, current, longest = [], [], 0
67
111
  for i in order:
68
- longest_if_added = max(longest, lengths[i])
112
+ longest_if_added = max(longest, costs[i])
69
113
  if current and (len(current) + 1) * longest_if_added > token_budget:
70
114
  batches.append(current)
71
- current, longest_if_added = [], lengths[i]
115
+ current, longest_if_added = [], costs[i]
72
116
  current.append(i)
73
117
  longest = longest_if_added
74
118
  if current:
@@ -84,28 +128,32 @@ def train(args):
84
128
  torch.manual_seed(args.seed)
85
129
  torch.set_num_threads(max(1, args.threads))
86
130
  data_dir = Path(args.data_dir)
87
- catalog = catalog_from_holdout(args.holdout)
88
- overrides_path = data_dir / 'owner-overrides.jsonl'
89
- examples = join(load_jsonl(data_dir / 'prompts.jsonl'), load_jsonl(data_dir / 'labels.jsonl'),
90
- load_jsonl(overrides_path) if overrides_path.exists() else [])
131
+ catalog = catalog_for(args.task, args.holdout)
132
+ labels_file = ('labels-intent-scores.jsonl' if args.target == 'scores' else 'labels-intent.jsonl') \
133
+ if args.task == 'intent' else 'labels.jsonl'
134
+ examples = eligible_rows(join(load_jsonl(data_dir / 'prompts.jsonl'), load_jsonl(data_dir / labels_file)), args.task)
91
135
  options = tuple(o['text'] for o in catalog)
92
136
  split = {name: [e for e in examples if e['split'] == name] for name in ('train', 'validation')}
93
137
  config = {'encoder': 'tinyx', 'width': 128, 'rank': 128, 'layers': 2, 'heads': 4, 'dropout': 0.1,
94
- 'context_tokens': args.context_tokens, 'option_tokens': 96}
138
+ 'context_tokens': args.context_tokens, 'option_tokens': OPTION_TOKENS}
95
139
  model, collator = make_system(config, 'cpu')
96
140
 
97
141
  def to_examples(rows):
98
- return [ChoiceExample(context=r['text'], options=options, label=label_index(r['gold'], catalog)) for r in rows]
142
+ examples = []
143
+ for row in rows:
144
+ targets = build_targets(row, catalog, args.task, args.target)
145
+ examples.append(ChoiceExample(context=row['text'], options=options, label=targets.index(max(targets))))
146
+ return examples
99
147
 
100
148
  def lengths(rows):
101
149
  return [min(len(r['text'].encode('utf-8')), args.context_tokens) or 1 for r in rows]
102
150
 
103
151
  train_x, val_x = to_examples(split['train']), to_examples(split['validation'])
104
- train_batches = make_batches(lengths(split['train']), args.token_budget)
105
- val_batches = make_batches(lengths(split['validation']), args.token_budget)
152
+ train_targets = torch.tensor([build_targets(r, catalog, args.task, args.target) for r in split['train']], dtype=torch.float)
153
+ val_targets = torch.tensor([build_targets(r, catalog, args.task, args.target) for r in split['validation']], dtype=torch.float)
154
+ train_batches = make_batches(lengths(split['train']), args.token_budget, len(catalog), config['option_tokens'])
155
+ val_batches = make_batches(lengths(split['validation']), args.token_budget, len(catalog), config['option_tokens'])
106
156
  optimizer = torch.optim.AdamW(model.parameters(), lr=args.lr, weight_decay=0.01)
107
- # Class balance counters the tier2-heavy labels; validation NLL stays unweighted so epochs remain comparable.
108
- weight = torch.tensor(class_weights([e.label for e in train_x], len(catalog)), dtype=torch.float) if args.balance else None
109
157
 
110
158
  def evaluate():
111
159
  model.eval()
@@ -114,9 +162,10 @@ def train(args):
114
162
  for batch in val_batches:
115
163
  tensors = collator([val_x[i] for i in batch])
116
164
  logits = model(tensors)
117
- nll += torch.nn.functional.cross_entropy(logits, tensors['labels'], reduction='sum').item()
118
- p = logits.softmax(-1)
119
- correct += (p.argmax(-1) == tensors['labels']).sum().item()
165
+ targets = val_targets[batch]
166
+ nll += torch.nn.functional.binary_cross_entropy_with_logits(logits, targets, reduction='sum').item()
167
+ p = logits.sigmoid()
168
+ correct += ((p >= 0.5) == targets.bool()).all(dim=-1).sum().item()
120
169
  for row, i in enumerate(batch):
121
170
  probs[i] = p[row].tolist()
122
171
  n = max(1, len(val_x))
@@ -129,35 +178,36 @@ def train(args):
129
178
  random.shuffle(order)
130
179
  total = 0.0
131
180
  for b in order:
132
- tensors = collator([train_x[i] for i in train_batches[b]])
133
- loss = torch.nn.functional.cross_entropy(model(tensors), tensors['labels'], weight=weight)
181
+ batch = train_batches[b]
182
+ tensors = collator([train_x[i] for i in batch])
183
+ loss = torch.nn.functional.binary_cross_entropy_with_logits(model(tensors), train_targets[batch])
134
184
  optimizer.zero_grad()
135
185
  loss.backward()
136
186
  torch.nn.utils.clip_grad_norm_(model.parameters(), 1.0)
137
187
  optimizer.step()
138
- total += loss.item() * len(train_batches[b])
188
+ total += loss.item() * len(batch)
139
189
  metrics, probs = evaluate()
140
190
  history.append({'epoch': epoch, 'trainLoss': total / max(1, len(train_x)), **metrics})
141
191
  print(json.dumps(history[-1]), flush=True)
142
192
  if best is None or metrics['nll'] < best['metrics']['nll']:
143
- best = {'epoch': epoch, 'metrics': metrics, 'probs': probs,
193
+ best = {'epoch': epoch, 'metrics': metrics, 'scores': probs,
144
194
  'state': {k: v.detach().clone() for k, v in model.state_dict().items()}}
145
195
 
146
196
  model.load_state_dict(best['state'])
147
197
  out = Path(args.out)
148
198
  out.mkdir(parents=True, exist_ok=True)
149
- datasets = {name: sha256_file(data_dir / name) for name in ('prompts.jsonl', 'labels.jsonl')}
150
- if overrides_path.exists():
151
- datasets['owner-overrides.jsonl'] = sha256_file(overrides_path)
199
+ datasets = {name: sha256_file(data_dir / name) for name in ('prompts.jsonl', labels_file)}
152
200
  metadata = {'domain': 'harness-routing-v1', 'bestEpoch': best['epoch'], 'validation': best['metrics'],
153
- 'datasets': datasets, 'seed': args.seed, 'catalog': [o['id'] for o in catalog]}
201
+ 'datasets': datasets, 'seed': args.seed, 'catalog': [o['id'] for o in catalog],
202
+ 'task': args.task, 'target': args.target, 'loss': 'binary_cross_entropy'}
154
203
  save_checkpoint(out / 'harness-routing-v1.safetensors', model, config, metadata)
155
204
  with (out / 'val-scores.jsonl').open('w', encoding='utf-8') as fh:
156
- for row, p in zip(split['validation'], best['probs']):
157
- fh.write(json.dumps({'id': row['id'], 'gold': row['gold'], 'probs': p}) + '\n')
205
+ for row, scores in zip(split['validation'], best['scores']):
206
+ fh.write(json.dumps(validation_record(row, catalog, scores, args.task)) + '\n')
158
207
  counts = {name: len(rows) for name, rows in split.items()}
159
208
  report = {'schemaVersion': 1, 'config': config, 'counts': counts, 'bestEpoch': best['epoch'], 'history': history,
160
- 'datasets': datasets, 'seed': args.seed}
209
+ 'datasets': datasets, 'seed': args.seed, 'task': args.task, 'target': args.target,
210
+ 'catalog': [o['id'] for o in catalog]}
161
211
  (out / 'train-report.json').write_text(json.dumps(report, indent=2) + '\n', encoding='utf-8')
162
212
  print(json.dumps({'counts': counts, 'bestEpoch': best['epoch'], 'validation': best['metrics']}))
163
213
 
@@ -166,15 +216,21 @@ def main(argv=None):
166
216
  parser = argparse.ArgumentParser(description=__doc__)
167
217
  parser.add_argument('--data-dir', required=True)
168
218
  parser.add_argument('--out', required=True)
169
- parser.add_argument('--holdout', default=str(DEFAULT_HOLDOUT))
219
+ parser.add_argument('--holdout', help='fixed option catalog source (defaults to the task holdout)')
170
220
  parser.add_argument('--epochs', type=int, default=12)
171
221
  parser.add_argument('--lr', type=float, default=1e-3)
172
222
  parser.add_argument('--seed', type=int, default=7)
173
223
  parser.add_argument('--threads', type=int, default=4)
174
224
  parser.add_argument('--context-tokens', type=int, default=1024)
175
- parser.add_argument('--token-budget', type=int, default=16384)
176
- parser.add_argument('--balance', action='store_true', help='inverse-frequency class weights in the training loss')
177
- train(parser.parse_args(argv))
225
+ parser.add_argument('--token-budget', type=int, default=TOKEN_BUDGET,
226
+ help='whole-forward-pass tokens per batch (prompt plus every option)')
227
+ parser.add_argument('--task', choices=['validity', 'intent', 'tier'], default='tier')
228
+ parser.add_argument('--target', choices=['label', 'scores'], default='label',
229
+ help='scores: per-intent soft labels from labels-intent-scores.jsonl (intent only)')
230
+ args = parser.parse_args(argv)
231
+ if args.target == 'scores' and args.task != 'intent':
232
+ parser.error('--target scores needs --task intent')
233
+ train(args)
178
234
 
179
235
 
180
236
  if __name__ == '__main__':