From 8bd0528ec43d42465de17c91f609d06bb2297e8f Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Thu, 1 Oct 2026 18:07:49 +0530 Subject: [PATCH] test(cron): keep two invariant tests for framed context_from archives The salvaged stack added three tests for response framing. Keep the writer->reader round trip with nested frames (red on main: rpartition injects only the embedded subsection) and the truncated-outer-frame case. Drop the test and the in-test block that exercise "framed archive without a prompt length": that shape was only ever produced by the PR's own intermediate commits, never by a writer on main, and the follow-up removes the reader branch for it. --- .../test_context_from_response_extraction.py | 26 ------------------- 1 file changed, 26 deletions(-) diff --git a/tests/cron/test_context_from_response_extraction.py b/tests/cron/test_context_from_response_extraction.py index f1eaac653d..15dada32d8 100644 --- a/tests/cron/test_context_from_response_extraction.py +++ b/tests/cron/test_context_from_response_extraction.py @@ -130,23 +130,6 @@ def test_writer_reader_preserve_response_with_nested_frames(cron_env, monkeypatc assert "Original prompt noise" not in prompt -def test_truncated_framed_archive_falls_back_to_older_answer(cron_env): - import os - from cron.jobs import create_job, OUTPUT_DIR - from cron.scheduler_prompt import _inject_context_from - - job = create_job(prompt="Report", schedule="0 8 * * *", context_from="self") - _write_archive(cron_env, job["id"], "older.md", "## Response\n\nOLDER ANSWER\n") - _write_archive(cron_env, job["id"], "newer.md", - "**Response Characters:** 80\n## Response\n\nTRUNCATED\n") - os.utime(OUTPUT_DIR / job["id"] / "older.md", (1, 1)) - os.utime(OUTPUT_DIR / job["id"] / "newer.md", (2, 2)) - prompt, injected = _inject_context_from(job, "Report") - assert injected - assert "OLDER ANSWER" in prompt - assert "TRUNCATED" not in prompt - - def test_truncated_outer_frame_cannot_promote_a_quoted_inner_frame(cron_env, monkeypatch): import os from cron.jobs import create_job, save_job_output, OUTPUT_DIR @@ -191,15 +174,6 @@ def test_truncated_outer_frame_cannot_promote_a_quoted_inner_frame(cron_env, mon assert "OLDER COMPLETE ANSWER" in prompt assert quoted not in prompt - # Archives produced before prompt-length framing get the same conservative - # treatment: an invalid first response frame never promotes a later one. - saved.write_text(f"**Response Characters:** {len(answer)}\n## Response\n\n" - + answer[:-len(suffix)] + "\n", encoding="utf-8") - os.utime(saved, (2, 2)) - prompt, injected = _inject_context_from(job, "Next task") - assert injected and "OLDER COMPLETE ANSWER" in prompt - assert quoted not in prompt - # Losing the response boundary itself is also unusable, not a script archive. saved.write_text(complete.split("**Response Characters:**", 1)[0], encoding="utf-8") os.utime(saved, (2, 2))