Repository navigation
fix(harness): keep reading_inputs through every re-save of a seeded contract (TH-8952) - #296
Open
khushalsonawat wants to merge 2 commits into
Open
khushalsonawat wants to merge 2 commits into
khushalsonawat wants to merge 2 commits into
Conversation
…ontract (TH-8952) Every save of contract.json goes through write_contract, which wrote only the model's fields. reading_inputs isn't one, so a re-save after the seed (the runtime-plan repair, the data-store repair, submit_contract, the amend tools) dropped it, and the platform, which reads the key as "seeded", kept the reading's contract instead. write_contract now keeps the record held by the contract already saved at the destination, first and with the same value; a save where none is held writes none. No model field is added, so the schema and the repair's contract hash are unchanged. An unexpected error reading the old file is logged by class name and the save goes on. Tests run the seed on the upload and GitHub paths, then each re-save, and check the key survives; a contract without a record, a reading's own saves, and a build after a take-back gain none. TH-8952 Signed-off-by: khushalsonawat <khushalsonawat@gmail.com>
… its trace (TH-8952) A contract.json that can't be read back drops the reading record, so the save turns a seeded build into an unseeded one. Log the error with its traceback, not the class alone, and say why in the comment. 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, where #269's seed contract is (it isn't ondevyet).Summary
Dileep's end-to-end run on an uploaded folder found that a seeded build's final contract had lost
reading_inputs. The seed was taken and understanding was skipped, but a later step rewrotecontract.jsonwithout the key. The platform decides "seeded" by that key, so it kept the reading's contract. The GitHub path kept the key only because no re-save happened to run after the seed there; nothing in the code protected it.Every save of the contract goes through
contract.write_contract, which writesAgentContract.model_dump(). The record isn't a model field, so each re-save dropped it: the runtime-plan repair, the data-store repair,submit_contract, and the amend tools (declare_tool, nudge, the source-facts refresh).Now
write_contractkeeps the record: when the contract already saved at the destination holdsreading_inputs, the new save writes it back, first, with the same value. A save where none is held writes none. No model field is added, so the schema the model sees and the repair's contract hash are unchanged. An unexpected error reading the old file is logged by class name and the save goes on.runtime.dockerfilegoing from"Dockerfile"to""is the runtime-plan repair doing its job, seeded or not. An upload with a Dockerfile and no Compose file is refused asruntime_dockerfile_unsupportedin the process lane, which starts the repair, and the repaired runtime has no Dockerfile. A probe reproduces it, and the reviewer re-ran it. Nothing is changed for it.Ticket: TH-8952. No platform change is needed.
Tests
test_seed_contract.py: on the upload path (archive_artifact_id), the seed is installed withuse_seed, then each re-save runs (the runtime-plan repair, the data-store repair,submit_contract,add_rule,declare_tool, the nudge's stale-reference drop, the source-facts refresh), andreading_inputssurvives each one unchanged. One row runs the same on the GitHub path.test_contract_writer.py: the writer keeps a record and writes none where there was none.Known limits
subfolder_requires_github_source), so the upload rows have none.Review
usedsentence, the take-back test).Verification
67a99e52 (Dileep's P3: the read error logged with its trace).67a99e52, Python 3.12.3: test_seed_contract.py and test_contract_writer.py, 177 passed.test_seed_contract.pyon every push.test_contract_writer.pyand the runtime files ran locally on Python 3.12.3, as listed; addingtest_contract_writer.pyto the smoke list is pending its run on the base._saved_record, the spec sentence (seed-contract 0.9 S4) and the two tests.test_seed_contract.py126,test_contract_writer.py51,test_runtime_repair.py213,test_runtime_repair_decision.py3,test_authoring_runtime_validation.py112 passed.ruff checkclean on the changed files; lines wrapped at 99.