\nusing namespace std;\nint main(){ return 0; }"; $substantial = <<<'CPP' #include using namespace std; int main() { int n, answer = 0; cin >> n; for (int i = 0; i < n; ++i) { int value; cin >> value; answer += value; } cout << answer << "\n"; return 0; } CPP; guidance_assert(llm_guidance_assess($substantial, 4, 1)['mode'] === 'hidden', 'AC must hide guidance'); guidance_assert(llm_guidance_assess($substantial, 3, 0)['mode'] === 'hidden', 'pending must hide guidance'); guidance_assert(llm_guidance_assess($substantial, 13, 0)['mode'] === 'hidden', 'test run must hide guidance'); $blank_wa = llm_guidance_assess($blank, 6, 0); guidance_assert($blank_wa['mode'] === 'flowchart', 'blank/template WA must receive flowchart guidance'); guidance_assert($blank_wa['show_output_diff'] === false, 'blank/template WA must not expose expected-output diff'); $comment_only = "// for if while cin cout answer = 42\n/* int main() { cout << answer; } */"; guidance_assert(llm_guidance_assess($comment_only, 6, 0)['mode'] === 'flowchart', 'comment-only submissions must stay low completion'); $hash_comment_only = "# for if while input print answer = 1\n# if answer: print(answer)\n# more comments\n# still no code"; guidance_assert(llm_guidance_assess($hash_comment_only, 6, 0)['mode'] === 'flowchart', '# comment-only submissions must stay low completion'); $high_wa = llm_guidance_assess($substantial, 6, 0.85); guidance_assert($high_wa['mode'] === 'output_diff', 'WA with a high judged pass rate must open output diff'); guidance_assert($high_wa['show_output_diff'] === true, 'high-completion WA must expose output diff'); $non_oi_wa = llm_guidance_assess($substantial, 6, 0); guidance_assert($non_oi_wa['mode'] === 'focused_hint', 'pass_rate=0 must not unlock hidden output from source shape alone'); $high_pe = llm_guidance_assess($substantial, 5, 0); guidance_assert($high_pe['mode'] === 'output_diff', 'substantial PE must open output diff'); $compact_pe = llm_guidance_assess('print(1)', 5, 0); guidance_assert($compact_pe['mode'] === 'output_diff', 'judge-proven compact PE must open output diff'); $empty_output_info = "========[1.out]========\nExpected | Yours\n42 | \n========================\n"; $empty_attempt = llm_guidance_output_attempt($empty_output_info); guidance_assert($empty_attempt['available'] && $empty_attempt['yours_chars'] === 0, 'empty judge output must be detected'); $padded_blank = llm_guidance_refine_with_output_attempt($non_oi_wa, 6, $empty_attempt); guidance_assert($padded_blank['mode'] === 'flowchart', 'long source with empty output must be downgraded to flowchart'); guidance_assert($padded_blank['show_output_diff'] === false, 'long source with empty output must not expose expected output'); $trusted_empty_case = llm_guidance_refine_with_output_attempt($high_wa, 6, $empty_attempt); guidance_assert($trusted_empty_case['mode'] === 'output_diff', 'one empty failing case must not erase authoritative overall pass progress'); $near_output_info = "========[1.out]========\nExpected | Yours\n12345 | 12346\n========================\n"; $near_attempt = llm_guidance_output_attempt($near_output_info); $near_non_oi = llm_guidance_refine_with_output_attempt($non_oi_wa, 6, $near_attempt); guidance_assert($near_non_oi['mode'] === 'focused_hint', 'a near-looking hidden output must not unlock diff'); $oracle_output_info = "========[1.out]========\nExpected | Yours\n1000000000 | 0000000000\n========================\n"; $oracle_attempt = llm_guidance_output_attempt($oracle_output_info); $oracle_non_oi = llm_guidance_refine_with_output_attempt($non_oi_wa, 6, $oracle_attempt); guidance_assert($oracle_non_oi['mode'] === 'focused_hint', 'a repeated-output guess must not unlock hidden expected output'); $two_case_info = "1.out\n--\n|Expected|Yours\n|--|--\n|1|0\n\n2.out\n--\n|Expected|Yours\n|--|--\n|2|3\n"; $two_case_names = llm_guidance_diff_testcase_names($two_case_info); guidance_assert($two_case_names === array('1', '2'), 'only judge-recorded simple diff testcase names may be authorized'); guidance_assert(llm_guidance_testcase_base('../2.out') === null, 'testcase paths and traversal must be rejected'); guidance_assert(llm_guidance_testcase_base('2.out') === '2', 'a normal testcase request must normalize to its basename'); $judge_rows_text = "|Expected|Yours\n|--|--\n|a|b|student \t\n"; $judge_rows = llm_guidance_parse_diff_rows($judge_rows_text); guidance_assert(count($judge_rows['expected']) === 1, 'the Markdown separator must not become a fake diff row'); guidance_assert($judge_rows['expected'][0] === 'a|b', 'pipes in expected output must stay on the expected side'); guidance_assert($judge_rows['yours'][0] === "student \t", 'trailing student whitespace must remain visible to PE comparison'); $judge_rows_attempt = llm_guidance_output_attempt($judge_rows_text); guidance_assert($judge_rows_attempt['pairs'] === 1 && $judge_rows_attempt['expected_chars'] === 3, 'completion metrics must use the same final-pipe judge delimiter'); $full_diff_info = "========[3.out]=========\n\n------test in top 100 lines------\nsecret input\n\n------test out top 100 lines-----\nsecret answer\n\n------user out top 100 lines-----\nguess\n\n------diff out 200 lines-----\nsecret answer | guess\n\n==============================\n"; guidance_assert(llm_guidance_has_full_diff_sections($full_diff_info), 'OJ_FULL_DIFF hidden sections must be detected'); guidance_assert(llm_guidance_diff_testcase_names($full_diff_info) === array('3'), 'full diff testcase header must be recognized without returning hidden values'); $truncated_full_diff = "========[3.out]=========\n\n------test in top 100 lines------\nsecret input\n\n3.out\n--\n|Expected|Yours\n|--|--\n|secret|guess\n"; guidance_assert(llm_guidance_has_full_diff_sections($truncated_full_diff), 'a truncated full diff must fail closed after its first section marker'); $literal_newline_full_diff = "========[3.out]=========\\n------test in top 100 lines------\\nsecret input"; guidance_assert(llm_guidance_has_full_diff_sections($literal_newline_full_diff), 'a shell-preserved literal-newline full marker must fail closed'); $tail_only_full_diff = "\\n------diff out 200 lines-----\\nsecret answer | guess"; guidance_assert(llm_guidance_has_full_diff_sections($tail_only_full_diff), 'a tail-only full diff marker must also fail closed'); $garbage_output_info = "========[1.out]========\nExpected | Yours\n42 | 00\n========================\n"; $garbage_attempt = llm_guidance_output_attempt($garbage_output_info); $garbage_non_oi = llm_guidance_refine_with_output_attempt($non_oi_wa, 6, $garbage_attempt); guidance_assert($garbage_non_oi['mode'] === 'focused_hint', 'equal-length unrelated output must not unlock diff'); $compact_wa_source = 'int main(){int n;cin>>n;cout<<(n+1);}'; $compact_wa = llm_guidance_assess($compact_wa_source, 6, 0); $compact_near_wa = llm_guidance_refine_with_output_attempt($compact_wa, 6, $near_attempt); guidance_assert($compact_near_wa['mode'] !== 'output_diff', 'compact source plus a near-looking output must not unlock diff'); $compact_high_wa = llm_guidance_assess('print(1)', 6, 0.85); guidance_assert($compact_high_wa['mode'] === 'output_diff', 'compact WA with authoritative high pass rate must open diff'); $missing_diff = llm_guidance_refine_with_output_attempt($high_wa, 6, llm_guidance_output_attempt('')); guidance_assert($missing_diff['mode'] === 'focused_hint' && !$missing_diff['show_output_diff'], 'high completion without a structured diff must use focused guidance'); $safe_focus = llm_guidance_render_focus_payload('{"category":"condition","line":7,"extra":""}', $substantial); guidance_assert(strpos($safe_focus, '第 7 行附近') !== false, 'allowlisted focus payload must preserve a valid student line'); guidance_assert(strpos($safe_focus, '