prevent discovery from rolling back governed binding head
CI / test (push) Failing after 27s

This commit is contained in:
m
2026-08-29 21:53:46 +03:00
parent 4bb6728dfe
commit 433cb2de2c
+3 -5
View File
@@ -568,11 +568,9 @@ func (r *CapabilityRepository) SaveCognitiveDiscovery(ctx context.Context, value
if err != nil {
return err
}
// Discovery creates immutable binding revisions. The durable head must
// follow the revision accepted by this transaction; leaving the
// existing head untouched strands refreshed providers behind an older
// inactive snapshot.
_, err = tx.Exec(ctx, `INSERT INTO capability.cognitive_binding_revision_heads (binding_id,revision) VALUES ($1,$2) ON CONFLICT (binding_id) DO UPDATE SET revision=EXCLUDED.revision,updated_at=CURRENT_TIMESTAMP`, binding.ID, binding.Revision)
// Discovery may advance a head, but must never roll back a governed
// CANARY/ACTIVE revision to an older discovered snapshot after restart.
_, err = tx.Exec(ctx, `INSERT INTO capability.cognitive_binding_revision_heads (binding_id,revision) VALUES ($1,$2) ON CONFLICT (binding_id) DO UPDATE SET revision=EXCLUDED.revision,updated_at=CURRENT_TIMESTAMP WHERE capability.cognitive_binding_revision_heads.revision < EXCLUDED.revision`, binding.ID, binding.Revision)
if err != nil {
return err
}