@@ -166,6 +166,43 @@ def update_drift_workflow_test_contract(
166166 return True
167167
168168
169+ def update_qpk_test_pin_contracts (
170+ repo_dir : Path ,
171+ * ,
172+ qpk_sha : str ,
173+ previous_qpk_refs : set [str ],
174+ ) -> bool :
175+ """Refresh explicit QPK SHA assertions in consumer test contracts only.
176+
177+ Some P1 pipelines assert their declared QPK revision in a test instead of
178+ reading the declaration dynamically. Those assertions are part of the
179+ dependency surface, but must not leave a generated update red. Restrict
180+ replacement to test files that explicitly name QuantPlatformKit and to an
181+ SHA that was already declared by the repository before this sync.
182+ """
183+ tests_dir = repo_dir / "tests"
184+ if not tests_dir .is_dir ():
185+ return False
186+
187+ changed = False
188+ previous = {
189+ sha
190+ for sha in previous_qpk_refs
191+ if re .fullmatch (r"[a-f0-9]{40}" , sha ) and sha != qpk_sha
192+ }
193+ for path in sorted (tests_dir .rglob ("test_*.py" )):
194+ original = path .read_text (encoding = "utf-8" )
195+ if "QuantPlatformKit" not in original :
196+ continue
197+ updated = original
198+ for prior_sha in sorted (previous ):
199+ updated = updated .replace (prior_sha , qpk_sha )
200+ if updated != original :
201+ path .write_text (updated , encoding = "utf-8" )
202+ changed = True
203+ return changed
204+
205+
169206def update_strategy_dependency_pins (
170207 repo_dir : Path ,
171208 strategy_heads : dict [str , str ],
@@ -337,6 +374,11 @@ def update_repo(
337374 previous_qpk_refs = previous_qpk_refs ,
338375 )
339376 if strategy_heads :
377+ update_qpk_test_pin_contracts (
378+ repo_dir ,
379+ qpk_sha = get_qpk_pin_sha (pin_file = qpk_pin ),
380+ previous_qpk_refs = previous_qpk_refs ,
381+ )
340382 update_strategy_dependency_pins (repo_dir , strategy_heads )
341383 update_qsl_strategy_requires (repo_dir , strategy_heads )
342384 update_qsl_metadata_test_contract (
0 commit comments