Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 41 additions & 11 deletions examples/release/release-readiness-doc-smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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=[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
Loading