From 9dc4ad6edf9648893c631afd7b5ded982a47eb5a Mon Sep 17 00:00:00 2001 From: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> Date: Thu, 15 Oct 2026 13:57:38 +0800 Subject: [PATCH] test(release): preserve fenced commands and explicit settlement selection Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> --- .../release/release-readiness-doc-smoke.py | 52 +++++++++++++++---- .../admission-closeout.integration.spec.ts | 33 +++++++++++- 2 files changed, 72 insertions(+), 13 deletions(-) diff --git a/examples/release/release-readiness-doc-smoke.py b/examples/release/release-readiness-doc-smoke.py index a348bdb3bd..95cfc3bdcb 100644 --- a/examples/release/release-readiness-doc-smoke.py +++ b/examples/release/release-readiness-doc-smoke.py @@ -97,20 +97,32 @@ def heading_level(line: str) -> int | None: def section(text: str, heading: str) -> str: lines = text.splitlines() - try: - start = lines.index(heading) - except ValueError as exc: - raise AssertionError(f"release notes missing heading {heading!r}") from exc - level = heading_level(heading) assert level is not None - end = len(lines) - for index in range(start + 1, len(lines)): - candidate_level = heading_level(lines[index]) + start: int | None = None + fence: tuple[str, int] | None = None + for index, line in enumerate(lines): + marker = re.match(r"^ {0,3}(`{3,}|~{3,})(.*)$", line) + if marker: + delimiter, suffix = marker.groups() + if fence is None: + if delimiter[0] != "`" or "`" not in suffix: + fence = (delimiter[0], len(delimiter)) + elif delimiter[0] == fence[0] and len(delimiter) >= fence[1] and not suffix.strip(): + fence = None + continue + if fence is not None: + continue + if start is None: + if line == heading: + start = index + continue + candidate_level = heading_level(line) if candidate_level is not None and candidate_level <= level: - end = index - break - return "\n".join(lines[start + 1 : end]) + return "\n".join(lines[start + 1 : index]) + if start is None: + raise AssertionError(f"release notes missing heading {heading!r}") + return "\n".join(lines[start + 1 :]) def validate_surface_entry( @@ -311,6 +323,24 @@ def assert_rejected(path: Path, body: str, message: str) -> None: surfaces=["Example Surface"], expect_no_optional_capability_changes=False, ) + code_comments_path = tmp_path / "code-comments.md" + code_comments_path.write_text( + valid.replace( + "loopx example --check", + "# Prepare the readback\n## Validation\nloopx example --check", + ), + encoding="utf-8", + ) + validate_release_notes( + code_comments_path, + surfaces=["Example Surface"], + expect_no_optional_capability_changes=False, + ) + assert_rejected( + tmp_path / "code-only-surface.md", + valid.replace("### Example Surface", "```bash\n### Example Surface\n```", 1), + "release-note gate accepted a surface heading inside a code fence", + ) validate_release_notes( no_changes_path, surfaces=[], diff --git a/packages/dsh-loopx-plugin/tests/admission-closeout.integration.spec.ts b/packages/dsh-loopx-plugin/tests/admission-closeout.integration.spec.ts index d5818b460a..9e309196d6 100644 --- a/packages/dsh-loopx-plugin/tests/admission-closeout.integration.spec.ts +++ b/packages/dsh-loopx-plugin/tests/admission-closeout.integration.spec.ts @@ -289,19 +289,37 @@ describe('DSH admission-to-closeout integration', () => { ) expect(admission.kind).toBe('enter') - const guard = await runCli(testFixture, [ + const unselected = await runCli(testFixture, [ 'quota', 'should-run', '--goal-id', goalId, '--agent-id', agentId, '--runtime-profile', 'generic_cli', '--turn-instance-id', turnInstanceId, ]) + expect(unselected.exitCode).toBe(0) + const unselectedChannel = record(record(unselected.payload.interaction_contract).cli_channel) + expect(unselectedChannel.selection_required).toBe(true) + expect(unselectedChannel.settlement_plan).toBeUndefined() + + const guardArgs = [ + 'quota', 'should-run', + '--goal-id', goalId, + '--todo-id', todoId, + '--agent-id', agentId, + '--runtime-profile', 'generic_cli', + '--turn-instance-id', turnInstanceId, + ] + const guard = await runCli(testFixture, guardArgs) + const guardReplay = await runCli(testFixture, guardArgs) + expect(guardReplay.exitCode).toBe(0) expect(guard.exitCode).toBe(0) const heartbeatReceipt = record(guard.payload.heartbeat_receipt) expect(heartbeatReceipt.turn_instance_id).toBe(turnInstanceId) const cliChannel = record(record(guard.payload.interaction_contract).cli_channel) const rawPlan = record(cliChannel.settlement_plan) const identity = record(rawPlan.identity) + const replayChannel = record(record(guardReplay.payload.interaction_contract).cli_channel) + expect(record(record(replayChannel.settlement_plan).identity)).toEqual(identity) const effectId = String(identity.effect_id) expect(identity.turn_instance_id).toBe(turnInstanceId) expect(identity.todo_id).toBe(todoId) @@ -365,7 +383,18 @@ describe('DSH admission-to-closeout integration', () => { && event.agent_id === agentId && event.run_id === turnInstanceId )) - expect(admissionReceipts).toHaveLength(1) + expect(admissionReceipts).toHaveLength(2) + const initialAdmission = admissionReceipts.find(event => ( + record(event.details).settlement_effect_id === null + )) + const selectedAdmission = admissionReceipts.find(event => ( + record(event.details).settlement_effect_id === effectId + )) + expect(record(record(initialAdmission).details).delivery_allowed).toBe(false) + const selectedDetails = record(record(selectedAdmission).details) + expect(selectedDetails.todo_id).toBe(todoId) + expect(selectedDetails.settlement_receipt_revision).toBe('identity_upgrade') + expect(record(record(selectedAdmission).causality).caused_by).toBe(record(initialAdmission).event_id) expect(events.filter(event => ( event.event_kind === 'quota_should_run' && event.run_id !== turnInstanceId