Secrets stay in the injected local store and are never part of the response.
(
repo: &Repository,
request: &ReviewApprovalRequest,
store: &IdentityStore,
)
| 153 | |
| 154 | /// Secrets stay in the injected local store and are never part of the response. |
| 155 | pub fn approve( |
| 156 | repo: &Repository, |
| 157 | request: &ReviewApprovalRequest, |
| 158 | store: &IdentityStore, |
| 159 | ) -> ReviewResult<ApprovalResult> { |
| 160 | if !request.confirm |
| 161 | || request.identity.trim().is_empty() |
| 162 | || request.expected_subject.is_empty() |
| 163 | || request.expected_review_source_hash.is_empty() |
| 164 | { |
| 165 | return Err(invalid("approval requires explicit human confirmation, local identity and exact subject/review revision pins")); |
| 166 | } |
| 167 | let _boundary = repo.lock_review_publication()?; |
| 168 | let detail = get(repo, &request.review)?; |
| 169 | let identity = store.load_by_name(&request.identity).map_err(invalid)?; |
| 170 | let did = atomic_canonical::did::did_for_public_key(&identity.public_key); |
| 171 | let resumed = detail.node.status == "done" |
| 172 | && repo.review_workflow_approvals()?.iter().any(|approval| { |
| 173 | approval["review"] == detail.node.id |
| 174 | && approval["subject"] == request.expected_subject |
| 175 | && approval["reviewSourceHash"] == request.expected_review_source_hash |
| 176 | && approval["approvedBy"] == did |
| 177 | && approval["acceptedFindings"] == json!(request.accepted_findings) |
| 178 | }); |
| 179 | if detail.subject.urn()? != request.expected_subject |
| 180 | || (detail.source_hash != request.expected_review_source_hash && !resumed) |
| 181 | { |
| 182 | return Err(invalid( |
| 183 | "review changed since inspection; read the exact current review before approving", |
| 184 | )); |
| 185 | } |
| 186 | let pair = store.load_keypair(&identity.id, None).map_err(invalid)?; |
| 187 | Ok(repo.approve_review_intent( |
| 188 | &request.review, |
| 189 | &identity, |
| 190 | &pair, |
| 191 | &request.accepted_findings, |
| 192 | )?) |
| 193 | } |
| 194 | |
| 195 | /// Inspect signed current and historical artifacts without rewriting them. |
| 196 | /// Signature authentication and present-day applicability remain distinct. |
no test coverage detected