Close first librarian promote round-trip + add --accept flag

scripts/librarian_promote.py gains a --accept flag that copies the
generated draft to the suggested docs/research/ target in the same
invocation. This is explicit per-invocation opt-in, not auto-apply:
the operator types --accept knowingly, the cp is still a deliberate
acceptance decision, just expressed in one command instead of two.

docs/research/option-a-bench-result.md is the first promoted note,
generated by gemini from
docs/archive/option-a-bench-result-2026-05-07.md and accepted
verbatim. Spot-check verified that cited file:line locations match
current source (traversal.pyx:473-475 and
inference_server.py:226-228 carry the cited code), the Last-verified
header reflects today's date and HEAD, and the durable conclusion
(sync-blocking policy boundary as the structural ceiling, not IPC
plumbing) is preserved.

This closes the end-to-end loop the librarian was designed for:
oversize check surfaced docs/performance.md, the routing pass split
durable analysis into the archive entry, the promote dispatcher
turned the archive entry into a research draft, and the human
accept step landed it as a tracked research note. Took one LLM call.

Removes the now-resolved ignore-list entry for
docs/research/option-a-bench-result.md (the file exists; the
forward reference is real).

scripts/librarian.sh exits 0 against the working tree.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-08 00:31:59 +09:00
co-authored by Claude Opus 4.7
parent 8bbed31670
commit f5ce49682e
4 changed files with 110 additions and 11 deletions
-5
View File
@@ -18,8 +18,3 @@ scripts/run_model_size_experiment.sh
# Future config described in docs/plans/torch_compile.md
configs/deep_cfr/default_compile.yaml
# Hypothetical accept target named in docs/plans/librarian.md as a
# smoke-test illustration; resolves naturally if Stage 2 promote is
# accepted, otherwise stays a forward reference.
docs/research/option-a-bench-result.md
+31 -6
View File
@@ -24,6 +24,7 @@ from __future__ import annotations
import argparse
import os
import re
import shutil
import subprocess
import sys
from datetime import datetime
@@ -32,7 +33,7 @@ from pathlib import Path
LLM_COMMANDS = {
"claude": ["claude", "-p"],
"codex": ["codex", "exec"],
"gemini": ["gemini", "-p"],
"gemini": ["gemini", "-p", ""],
}
DATE_SUFFIX = re.compile(r"-\d{4}-\d{2}-\d{2}$")
@@ -85,6 +86,16 @@ def main() -> int:
action="store_true",
help="Print the assembled prompt to stdout and exit; do not call the LLM.",
)
parser.add_argument(
"--accept",
action="store_true",
help=(
"After the draft lands in runs/tmp/, also copy it verbatim to the "
"suggested docs/research/ target. Explicit per-invocation opt-in: "
"still propose-only by design (you are choosing acceptance "
"knowingly), not auto-apply."
),
)
args = parser.parse_args()
root = _repo_root()
@@ -145,7 +156,8 @@ def main() -> int:
file=sys.stderr,
)
result = subprocess.run(
cmd + [prompt],
cmd,
input=prompt,
capture_output=True,
text=True,
check=False,
@@ -157,10 +169,23 @@ def main() -> int:
draft_path.write_text(result.stdout, encoding="utf-8")
print(f"Draft written to: {draft_path.relative_to(root)}")
print(f"Suggested target on accept: {rel_target}")
print()
print("Next: review the draft. To accept verbatim:")
print(f" cp {draft_path.relative_to(root)} {rel_target}")
if args.accept:
if target.exists():
print(
f"Refusing --accept: {rel_target} appeared while the LLM ran.",
file=sys.stderr,
)
return 1
shutil.copyfile(draft_path, target)
print(f"Copied to: {rel_target}")
print("Next: review the diff and `git add` + commit if you're satisfied.")
else:
print(f"Suggested target on accept: {rel_target}")
print()
print("Next: review the draft. To accept verbatim:")
print(f" cp {draft_path.relative_to(root)} {rel_target}")
print("Or rerun with --accept to copy in the same step.")
return 0