merge: reconcile Wave 1.1 with post-PR40 lab

Merge canonical lab 9557b8d5909eb4a885c3bf49e19a65dd904f8c1d exactly once.
Retain invocation journal ownership and lineage, provider terminal ordering,
teacher handoff, framed DONE handling, and canonical authority/Ajax routing.

Combine dynamic dispatch receipts with lab policy forwarding. Adapt native
shell/patch evidence, explicit TUI verifiers, and artifact recovery presentation.
Refresh generated configuration source links and strengthen adapter regressions.

Validation: focused 2118 passed; Wave 1.1 script 2291 passed; broad runtime
5649 passed; full pytest 11581 passed, 53 skipped, 2 xfailed, 6 subtests passed.
Compileall 1689 Python files; syntax 279 JS and 82 MJS files; diff and
conflict-marker checks passed.
This commit is contained in:
Alexandre Teixeira
2026-10-01 09:09:55 +01:00
304 changed files with 41744 additions and 24384 deletions
+16 -1
View File
@@ -267,6 +267,21 @@ def with_completion_gate(func):
if provider_error and not answer_events and not metrics_events:
yield provider_error
return
presentation_replaced = False
if not provider_error and not has_final and requirements.required_artifacts:
terminal_texts = next((event.get('data', {}).get('round_texts')
for event in reversed(metrics_events)
if isinstance(event.get('data', {}).get('round_texts'), list)
and all(isinstance(text, str) for text in event['data']['round_texts'])), None)
if terminal_texts is not None:
terminal_answer = '\n\n'.join(text for text in terminal_texts if text.strip())
if terminal_answer != answer:
# The loop can retract a rejected round while retaining
# its live deltas. Do not resurrect those buffered drafts
# after recovery. Terminal prose still passes this gate.
presentation_replaced = True
answer = terminal_answer
answer_events = [event for event in answer_events if event.get('thinking') is True]
ledger = EvidenceLedger.from_tool_events(journal.evidence_events(), requirements)
decision = ledger.evaluate(exhausted=exhausted, awaiting_user=awaiting)
if provider_error:
@@ -291,7 +306,7 @@ def with_completion_gate(func):
released_at = perf_counter()
if not provider_error:
yield _event({'type': 'completion_decision', 'data': decision.to_dict()})
replaced_answer = bool(reason or unsafe_draft or safe_answer != answer)
replaced_answer = bool(presentation_replaced or reason or unsafe_draft or safe_answer != answer)
if replaced_answer:
reasoning = [event for event in answer_events if event.get('thinking') is True]
_, unsafe_reasoning = completion_answer(
+23 -2
View File
@@ -11,6 +11,17 @@ import stat
from .path_policy import _is_sensitive_path
TUI_PYTHON_RUNNER_SETUP = (
"runner=''; "
"if [ -x .venv/bin/python ]; then runner=.venv/bin/python; "
"elif [ -x venv/bin/python ]; then runner=venv/bin/python; "
"elif git_common=$(git rev-parse --path-format=absolute --git-common-dir 2>/dev/null) "
"&& [ -x \"$(dirname \"$git_common\")/.venv/bin/python\" ]; then "
"runner=\"$(dirname \"$git_common\")/.venv/bin/python\"; "
"else runner=python; fi; "
)
def digest(value: object) -> str:
return hashlib.sha256(json.dumps(value, sort_keys=True, ensure_ascii=False,
separators=(",", ":"), default=str).encode()).hexdigest()
@@ -85,13 +96,23 @@ def artifact_identity(value: str, workspace: str = "") -> str:
def executable_words(command: str) -> tuple[str, ...]:
"""Recognize one foreground command, optionally after safe cd/set prefixes.
"""Recognize one foreground command after exact interpreter or cd/set prefixes.
This is deliberately conservative evidence parsing, not shell authorization.
Pipelines, control flow, substitutions and status-masking tails are not proof
Other control flow, substitutions, pipelines and status-masking tails are not proof
that a verifier returned the recorded shell status.
"""
text = str(command or '').strip()
if text.startswith(TUI_PYTHON_RUNNER_SETUP):
remainder = text[len(TUI_PYTHON_RUNNER_SETUP):]
# This exact server-owned prelude only selects the interpreter. The
# trailing command must still be a single foreground invocation whose
# status is returned unchanged; the generic discovery fallback is not.
if remainder.startswith('"$runner" '):
arguments = remainder[len('"$runner" '):]
if '$' in arguments:
return ()
text = 'python ' + arguments
if any(marker in text for marker in ('`', '$(', '${', '\n', '\r')):
return ()
try: