Repository navigation
fix(harness): review follow-ups for #269 and #276 (TH-8952, TH-9490) - #297
Open
khushalsonawat wants to merge 5 commits into
Open
khushalsonawat wants to merge 5 commits into
khushalsonawat wants to merge 5 commits into
Conversation
…ack (TH-8952) Dileep's two P3s on #269, which merged before they could land there: - holds_seed prints the traceback before returning False, so a restart that can't compare contract.json with the seed says why it reports no seed-result.json; - _take_back prints the traceback when contract.json can't be removed, since a contract left behind is what makes the outcome `used`. Both catches see only the kit's own files (/work/authoring/contract.json and the platform-placed seed, which read_seed already parses safely), so no customer source reaches the trace. The two tests assert the trace reaches stderr. One fresh reviewer: clear; test_seed_contract 108 passed on 3.12.3, and each planted removal fails its named test. Signed-off-by: khushalsonawat <khushalsonawat@gmail.com>
…oo (TH-9490) - A coding line whose own bytes don't decode to it (EBCDIC, utf-16, utf-32) is read as `python file.py` reads it: the bytes after the coding line, decoded. A decode-first file whose head doesn't read as itself, or that holds any CR, is read both ways; the two texts are never joined, and the escape budget charges such a file at most twice. - Past the decode total, a WARNING is logged once per budget, naming the reader, with counts only. A file the whole decode refuses at the total's edge is read as any file past it is. - Tests skip a decoded-CR row when this Python no longer keeps the CR, and allow 3.14's bounded decode of the cut coding line; the walk parses each file's own readings only; the tool-evidence scan finds a tool spelled in utf-7. A docstring is rewrapped at 99. TH-9490 Signed-off-by: khushalsonawat <khushalsonawat@gmail.com>
…t/TH-9490-review-follow-ups Signed-off-by: khushalsonawat <khushalsonawat@gmail.com>
…al's edge (TH-9490) - The _decoded_readings and _head_reads_as_itself docstrings say an import and a script read a file alike only when it holds no CR. - A test pins what comes back when the total lasts for the first decode only: the import's reading, decoded, alone. - The walk test's comment names a.py's second reading as the script's. TH-9490 Signed-off-by: khushalsonawat <khushalsonawat@gmail.com>
1 task done
cdileep23
requested changes
Nov 12, 2026
| assert tool_evidence_problems(_entry_contract(), tmp_path) | ||
|
|
||
|
|
||
| def test_tool_check_decodes_a_utf_7_module_as_python_does(tmp_path): |
Member
There was a problem hiding this comment.
P3. This test still passes if the tool check stops decoding first. With source_tool_evidence.py:69 changed to read_module(path), it and ..._finds_a_def_a_utf_7_comment_hides stay green; only test_tool_check_reads_the_text_an_import_reads fails.
Fix: use a UTF-7 file where the plain read and the decode-first read give different text (one that depends on a CR or a NUL, for example), so this test pins the reader by itself.
…is Python refuses (TH-9490) From 3.14, Python refuses some UTF-16 coding lines itself, so no coding is right there: the length test skips those rows rather than asserting one. _decoded_first had no caller left but tests, which now take the first two items of _decoded_readings. A noqa reason moves above its line, to fit 99. Signed-off-by: khushalsonawat <khushalsonawat@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Into
feat/TH-8804-source-subfolder. Review follow-ups for #269 (TH-8952, merged) and #276 (TH-9490, merged through #283): Dileep's comments that landed after each merged. Four commits:43309843(#269),df2742cf(#276), the base merged in (8e1d9de1), and the confirming review's Lows (a8445f18).Summary
#269, the seed contract (two P3s).
holds_seedand_take_backswallowed an error with nothing logged. Each now prints the traceback to stderr throughprint_trace, which prints nothing when the error holds a validation error's values. So a restart that can't comparecontract.jsonwith the seed says why it writes noseed-result.json, and a contract that can't be removed (which makes the outcomeused) says why. Both catches see only the kit's own files (the authoringcontract.jsonand the platform-placed seed), never customer source. Two tests intest_seed_contract.pyassert the trace reaches stderr.#276, decoding a Python file before searching it (C2-C7).
compile()and import refuse cp037, cp500, cp1140, cp273, cp875, cp1026 and cp424 on a coding line, butpython main.pyruns them. A codec whose bytes for the coding line don't decode to that line (these seven, utf-16 and utf-32) is now read aspython file.pyreads it: the lines up to the coding line as they are, the rest decoded. Each codec is proven by a realpython3.12 file.pyrun against a stub module, and the codec sweep now asks the script route too.src/(709 files) and~/Desktop/future-agi(160,494 files) have no file read twice.compile()probe shows this Python doesn't keep it, rather than by version.detect_encodingrefuses the codec. The refused-codec walk test allows 3.14's bounded decode of the cut first line, and still asserts the file's body is never decoded._codingalso pads each cut line to its real length mod 4, so a utf-16 coding line reads on 3.14.source_tool_evidencereads decode-first files too: a test finds a@toolspelled with a utf-7+AEA-escape.Tickets: TH-8952, TH-9490.
Known limits
Merged with the base (
8e1d9de1)cde91b3f(#282 and 1132192) merged with no conflicts. 1132192 rewords comments inpython_source.pyand changes the import walk incredentials.py(workspace members, folder links); neither touches how a.pyis decoded, and the walk's per-file second texts are unchanged (traced by the confirming reviewer, and pinned bytest_the_walk_parses_each_files_own_readings).Review
Verification
bddd2668 (Dileep's P3s: the UTF-16 skip, _decoded_first removed, the noqa line).bddd2668, Python 3.12.3: test_python_source_codecs.py, test_seed_contract.py and test_source_tool_evidence.py, 395 passed; ruff check clean.test_python_source_codecs.py,test_source_tool_evidence.py,test_seed_contract.py,test_agent_type_refusal.py,test_scan_walk.py,test_instrumentation_evidence.pyandtests/test_harness_credentials.pyon every push.a8445f18(docstrings, a test comment and the edge test, added after the confirming review cleared).8e1d9de1(codecs re-run ona8445f18):test_python_source_codecs.py233,test_source_tool_evidence.py54,test_agent_type_refusal.py735,test_instrumentation_evidence.py48,test_scan_walk.py151,test_seed_contract.py108,tests/test_harness_credentials.py81 passed.ruff checkclean on the changed files. One line is 106 characters (seed_contract.py:370, anoqareason); it is fixed with Dileep's comments in the next push.