Reject target conflicts and post-application scope evidence drift
Metadata integrity checks / metadata (push) Successful in 2m3s

This commit is contained in:
2026-11-08 23:48:40 +08:00
parent ea3393144d
commit d2c016e309
2 changed files with 27 additions and 1 deletions
+24
View File
@@ -105,6 +105,30 @@ class TrackCases:
with self.assertRaisesRegex(ValueError,'Recollect'):ingest_file(self.target.get('db'),path,**{k:v for k,v in self.target.items()if k!='db'})
with closing(self.store().conn)as c:verify(c,plan)
def test_nonempty_target_and_alias_drift_fail_before_moving(self):
with closing(self.store().conn)as c:
c.execute("INSERT INTO venue_aliases VALUES((SELECT id FROM venues WHERE acronym='JOINT'),'ADDED')")
with self.assertRaisesRegex(ValueError,'aliases'):self.plan(c)
c.rollback()
s=object.__new__(Store);s.conn=c;s.event_identity=True
p,r=s.record('fixture','collision','https://example.org/collision','Distinct contribution',None,[],{'doi':'10.1234/collision'})
s.decision(p,r,'JOINT',2022,'survey','collision','https://example.org/collision','accepted','published')
with self.assertRaisesRegex(ValueError,'Nonempty target'):self.plan(c)
c.rollback()
self.assertEqual(c.execute('SELECT count(*) FROM submissions').fetchone()[0],4)
def test_repeated_plan_detects_coverage_or_scope_evidence_drift(self):
with closing(self.store().conn)as c:
plan=self.plan(c);apply_plan(c,plan);c.commit()
c.execute("UPDATE edition_sources SET imported_count=99")
with self.assertRaisesRegex(ValueError,'coverage'):apply_plan(c,plan)
c.rollback()
record=self.inventory['records'][0]['source_record_id']
m=json.loads(c.execute('SELECT metadata_json FROM source_records WHERE id=?',(record,)).fetchone()[0]);m[KEY]=[]
c.execute('UPDATE source_records SET metadata_json=? WHERE id=?',(json.dumps(m),record))
with self.assertRaisesRegex(ValueError,'unchanged track'):apply_plan(c,plan)
c.rollback()
def test_cli_hash_binding_preflight_and_duplicate_inventory(self):
inventory=self.root/'inventory.json';inventory.write_text(json.dumps(self.inventory))
planfile=self.root/'plan.json';p=run(self.target.get('db'),planfile,inventory=inventory,**{k:v for k,v in self.target.items()if k!='db'})