@@ -86,6 +86,7 @@ interface AutomationProof {
8686interface SecretConfigProof {
8787 readonly intent : Readonly < LocalReconciliationSecretConfigApplyIntent > ;
8888 readonly receipt : Readonly < LocalReconciliationSecretConfigApplyReceipt > ;
89+ readonly preparedHeadDigest : string ;
8990 readonly paths : ReturnType < typeof localReconciliationSecretConfigApplyPaths > ;
9091 readonly storageState : 'applied' | 'completed' ;
9192}
@@ -107,6 +108,7 @@ export interface LocalReconciliationCompletionDependencies
107108async function runHistoryProof (
108109 command : Readonly < LocalReconciliationCompleteCommand > ,
109110 terminal : Readonly < LocalReconciliationApplicationTerminal > ,
111+ secretConfig : Readonly < SecretConfigProof > | null ,
110112 uid : number ,
111113 dependencies : LocalReconciliationCompletionDependencies ,
112114) : Promise < Readonly < RunHistoryProof > | null > {
@@ -153,7 +155,8 @@ async function runHistoryProof(
153155 command . request . runHistory . expectedPreservationDigest ||
154156 history . receipt . applicationPlanDigest !==
155157 terminal . plan . applicationPlanDigest ||
156- history . receipt . sourceHeadDigest !== command . request . expectedHeadDigest
158+ history . receipt . sourceHeadDigest !==
159+ ( secretConfig ?. preparedHeadDigest ?? command . request . expectedHeadDigest )
157160 ) {
158161 fail ( 'run history preservation evidence is detached' ) ;
159162 }
@@ -571,6 +574,7 @@ async function secretConfigProof(
571574 selected ,
572575 uid ,
573576 ) ;
577+ const targetSnapshotSha256 = decision . context . planHeader . targetSnapshotSha256 ;
574578 if (
575579 intent . command . options . deploymentRoot !== command . options . deploymentRoot ||
576580 intent . command . options . applicationRoot !==
@@ -589,8 +593,9 @@ async function secretConfigProof(
589593 receipt . decisionId !== binding . decisionId ||
590594 receipt . applyDigest !== binding . expectedApplyDigest ||
591595 receipt . preparationDigest !== intent . preparationDigest ||
592- ( automation !== null &&
593- intent . backup . sha256 !== automation . receipt . targetAfter . sha256 ) ||
596+ ( automation === null
597+ ? targetSnapshotSha256 !== null
598+ : targetSnapshotSha256 !== automation . receipt . targetAfter . sha256 ) ||
594599 fs . existsSync ( selected . rollbackReceipt )
595600 ) {
596601 fail ( 'secret config apply evidence is detached' ) ;
@@ -623,6 +628,7 @@ async function secretConfigProof(
623628 return Object . freeze ( {
624629 intent,
625630 receipt,
631+ preparedHeadDigest : decision . context . planHeader . preparedHeadDigest ,
626632 paths : selected ,
627633 storageState,
628634 } ) ;
@@ -820,6 +826,7 @@ export async function completeLocalReconciliation(
820826 const runHistory = await runHistoryProof (
821827 command ,
822828 terminal ,
829+ secretConfig ,
823830 uid ,
824831 dependencies ,
825832 ) ;
@@ -1015,6 +1022,7 @@ export async function verifyLocalReconciliationCompletion(
10151022 const runHistory = await runHistoryProof (
10161023 syntheticCompleteCommand ,
10171024 terminal ,
1025+ secretConfig ,
10181026 uid ,
10191027 dependencies ,
10201028 ) ;
0 commit comments