Account readiness review in Bifrost ledger
This commit is contained in:
parent
0cde0ed529
commit
85197fe86d
7 changed files with 196 additions and 10 deletions
|
|
@ -562,6 +562,33 @@ fn run_smoke(args: Args) -> Result<Value> {
|
|||
)?;
|
||||
require_tui_row_contains(&receipt_directory, &["tuiRows"], "artifact=present")?;
|
||||
require_bool(&receipt_directory, &["privateStateExposed"], false)?;
|
||||
let bifrost_ledger = cargo_json(
|
||||
&manifest,
|
||||
"epiphany-verse-query",
|
||||
&[
|
||||
"bifrost-ledger",
|
||||
"--store",
|
||||
path_str(&local_verse)?,
|
||||
"--runtime-id",
|
||||
"repo-work-readiness-smoke",
|
||||
],
|
||||
&root,
|
||||
)?;
|
||||
require_bifrost_accounting_row(
|
||||
&bifrost_ledger,
|
||||
"repo-work-readiness-review",
|
||||
"closed",
|
||||
"repo-work-readiness-review-repo-work-readiness",
|
||||
4,
|
||||
1,
|
||||
)?;
|
||||
require_tui_row_contains(
|
||||
&bifrost_ledger,
|
||||
&["accountingTuiRows"],
|
||||
"BIFROST-ACCOUNTING | repo-work-readiness-review",
|
||||
)?;
|
||||
require_tui_row_contains(&bifrost_ledger, &["accountingTuiRows"], "status=closed")?;
|
||||
require_bool(&bifrost_ledger, &["privateStateExposed"], false)?;
|
||||
|
||||
let summary = json!({
|
||||
"schemaVersion": "epiphany.repo_work_readiness_smoke.v0",
|
||||
|
|
@ -586,6 +613,8 @@ fn run_smoke(args: Args) -> Result<Value> {
|
|||
"gjallarLatestRepoWorkReadinessReview": gjallar["latestRepoWorkReadinessReview"],
|
||||
"receiptDirectoryRowCount": receipt_directory["rowCount"],
|
||||
"receiptDirectoryReadinessReviewRow": receipt_directory_row_value(&receipt_directory, "repo-work-readiness-review")?,
|
||||
"bifrostLedgerAccountingRowCount": bifrost_ledger["accountingRowCount"],
|
||||
"bifrostReadinessReviewAccountingRow": bifrost_accounting_row_value(&bifrost_ledger, "repo-work-readiness-review")?,
|
||||
"sightOnly": readiness["authority"]["sightOnly"],
|
||||
"readinessApprovalAuthorized": readiness["authority"]["readinessApprovalAuthorized"],
|
||||
"publicationAuthorized": readiness["authority"]["publicationAuthorized"],
|
||||
|
|
@ -855,6 +884,60 @@ fn require_receipt_directory_row(
|
|||
}
|
||||
}
|
||||
|
||||
fn bifrost_accounting_row_value<'a>(value: &'a Value, lane: &str) -> Result<&'a Value> {
|
||||
value
|
||||
.get("accountingRows")
|
||||
.and_then(Value::as_array)
|
||||
.and_then(|rows| {
|
||||
rows.iter()
|
||||
.find(|row| row.get("lane").and_then(Value::as_str) == Some(lane))
|
||||
})
|
||||
.ok_or_else(|| anyhow!("missing Bifrost accounting row {lane:?}"))
|
||||
}
|
||||
|
||||
fn require_bifrost_accounting_row(
|
||||
value: &Value,
|
||||
lane: &str,
|
||||
status: &str,
|
||||
latest_receipt_id: &str,
|
||||
review_receipt_count: u64,
|
||||
public_artifact_count: u64,
|
||||
) -> Result<()> {
|
||||
let row = bifrost_accounting_row_value(value, lane)?;
|
||||
let actual_status = row
|
||||
.get("status")
|
||||
.and_then(Value::as_str)
|
||||
.unwrap_or("<missing>");
|
||||
let actual_latest_receipt_id = row
|
||||
.get("latestReceiptId")
|
||||
.and_then(Value::as_str)
|
||||
.unwrap_or("<missing>");
|
||||
let actual_review_receipt_count = row
|
||||
.get("reviewReceiptCount")
|
||||
.and_then(Value::as_u64)
|
||||
.unwrap_or(0);
|
||||
let actual_public_artifact_count = row
|
||||
.get("publicArtifactCount")
|
||||
.and_then(Value::as_u64)
|
||||
.unwrap_or(0);
|
||||
let actual_private = row
|
||||
.get("privateStateExposed")
|
||||
.and_then(Value::as_bool)
|
||||
.unwrap_or(true);
|
||||
if actual_status == status
|
||||
&& actual_latest_receipt_id == latest_receipt_id
|
||||
&& actual_review_receipt_count == review_receipt_count
|
||||
&& actual_public_artifact_count == public_artifact_count
|
||||
&& !actual_private
|
||||
{
|
||||
Ok(())
|
||||
} else {
|
||||
Err(anyhow!(
|
||||
"Bifrost accounting row {lane:?} mismatch: status={actual_status:?}, latestReceiptId={actual_latest_receipt_id:?}, reviewReceiptCount={actual_review_receipt_count}, publicArtifactCount={actual_public_artifact_count}, privateStateExposed={actual_private}"
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn take_path(
|
||||
args: &mut std::iter::Peekable<impl Iterator<Item = String>>,
|
||||
flag: &str,
|
||||
|
|
|
|||
|
|
@ -1236,6 +1236,7 @@ fn run_cli() -> Result<()> {
|
|||
"latestBifrostPublicationReceipt": report.latest_publication_receipt_id,
|
||||
"latestBifrostGithubReceipt": report.latest_github_receipt_id,
|
||||
"latestBifrostPublicProofPublicationReceipt": report.latest_public_proof_publication_receipt_id,
|
||||
"latestRepoWorkReadinessReview": report.latest_readiness_review_id,
|
||||
"latestBifrostCollaborationFeedback": report.latest_feedback_id,
|
||||
"latestImaginationConsensusReceipt": report.latest_consensus_receipt_id,
|
||||
"accountingTuiRows": report.accounting_tui_rows,
|
||||
|
|
@ -2714,7 +2715,7 @@ fn run_cli() -> Result<()> {
|
|||
if bifrost_ledger_report.status != "ok"
|
||||
|| bifrost_ledger_report.publication_chain_count != 3
|
||||
|| bifrost_ledger_report.collaboration_chain_count != 2
|
||||
|| bifrost_ledger_report.accounting_rows.len() != 3
|
||||
|| bifrost_ledger_report.accounting_rows.len() != 4
|
||||
|| bifrost_ledger_report.closed_accounting_row_count != 2
|
||||
|| bifrost_ledger_report.attention_accounting_row_count != 0
|
||||
|| bifrost_ledger_report.rows.len() != 5
|
||||
|
|
@ -2749,6 +2750,13 @@ fn run_cli() -> Result<()> {
|
|||
&& row.contains("proof=missing")
|
||||
&& row.contains("private=false")
|
||||
})
|
||||
|| !bifrost_ledger_report.accounting_tui_rows.iter().any(|row| {
|
||||
row.contains("BIFROST-ACCOUNTING | repo-work-readiness-review")
|
||||
&& row.contains("status=missing")
|
||||
&& row.contains("review=0")
|
||||
&& row.contains("approval=missing")
|
||||
&& row.contains("private=false")
|
||||
})
|
||||
|| !bifrost_ledger_report.accounting_tui_rows.iter().any(|row| {
|
||||
row.contains("BIFROST-ACCOUNTING | collaboration-consensus")
|
||||
&& row.contains("status=closed")
|
||||
|
|
@ -4928,6 +4936,7 @@ struct BifrostLedgerReport {
|
|||
latest_publication_receipt_id: Option<String>,
|
||||
latest_github_receipt_id: Option<String>,
|
||||
latest_public_proof_publication_receipt_id: Option<String>,
|
||||
latest_readiness_review_id: Option<String>,
|
||||
latest_feedback_id: Option<String>,
|
||||
latest_consensus_receipt_id: Option<String>,
|
||||
private_state_exposed: bool,
|
||||
|
|
@ -8524,6 +8533,10 @@ fn load_bifrost_ledger_report(args: &Args) -> Result<BifrostLedgerReport> {
|
|||
&args.store,
|
||||
args.runtime_id.clone(),
|
||||
)?;
|
||||
let latest_readiness_review = load_latest_epiphany_cultmesh_repo_work_readiness_review(
|
||||
&args.store,
|
||||
args.runtime_id.clone(),
|
||||
)?;
|
||||
let latest_feedback = load_latest_epiphany_cultmesh_bifrost_collaboration_feedback(
|
||||
&args.store,
|
||||
args.runtime_id.clone(),
|
||||
|
|
@ -8537,6 +8550,7 @@ fn load_bifrost_ledger_report(args: &Args) -> Result<BifrostLedgerReport> {
|
|||
latest_publication.as_ref(),
|
||||
latest_github.as_ref(),
|
||||
latest_public_proof_publication.as_ref(),
|
||||
latest_readiness_review.as_ref(),
|
||||
latest_feedback.as_ref(),
|
||||
latest_consensus.as_ref(),
|
||||
))
|
||||
|
|
@ -8549,6 +8563,7 @@ fn bifrost_ledger_report(
|
|||
latest_public_proof_publication: Option<
|
||||
&EpiphanyCultMeshBifrostPublicProofPublicationReceiptEntry,
|
||||
>,
|
||||
latest_readiness_review: Option<&EpiphanyCultMeshRepoWorkReadinessReviewEntry>,
|
||||
latest_feedback: Option<&EpiphanyCultMeshBifrostCollaborationFeedbackEntry>,
|
||||
latest_consensus: Option<&EpiphanyCultMeshImaginationConsensusReceiptEntry>,
|
||||
) -> BifrostLedgerReport {
|
||||
|
|
@ -8674,6 +8689,7 @@ fn bifrost_ledger_report(
|
|||
latest_publication,
|
||||
latest_github,
|
||||
latest_public_proof_publication,
|
||||
latest_readiness_review,
|
||||
latest_feedback,
|
||||
latest_consensus,
|
||||
);
|
||||
|
|
@ -8685,7 +8701,8 @@ fn bifrost_ledger_report(
|
|||
.iter()
|
||||
.filter(|row| row.status == "attention" || row.private_state_exposed)
|
||||
.count();
|
||||
let private_state_exposed = rows.iter().any(|row| row.private_state_exposed);
|
||||
let private_state_exposed = rows.iter().any(|row| row.private_state_exposed)
|
||||
|| accounting_rows.iter().any(|row| row.private_state_exposed);
|
||||
let status = if rows.is_empty() {
|
||||
"empty"
|
||||
} else if private_state_exposed {
|
||||
|
|
@ -8711,6 +8728,7 @@ fn bifrost_ledger_report(
|
|||
latest_github_receipt_id: latest_github.map(|receipt| receipt.receipt_id.clone()),
|
||||
latest_public_proof_publication_receipt_id: latest_public_proof_publication
|
||||
.map(|receipt| receipt.receipt_id.clone()),
|
||||
latest_readiness_review_id: latest_readiness_review.map(|review| review.review_id.clone()),
|
||||
latest_feedback_id: latest_feedback.map(|feedback| feedback.feedback_id.clone()),
|
||||
latest_consensus_receipt_id: latest_consensus.map(|receipt| receipt.receipt_id.clone()),
|
||||
private_state_exposed,
|
||||
|
|
@ -8746,6 +8764,7 @@ fn bifrost_accounting_rows(
|
|||
latest_public_proof_publication: Option<
|
||||
&EpiphanyCultMeshBifrostPublicProofPublicationReceiptEntry,
|
||||
>,
|
||||
latest_readiness_review: Option<&EpiphanyCultMeshRepoWorkReadinessReviewEntry>,
|
||||
latest_feedback: Option<&EpiphanyCultMeshBifrostCollaborationFeedbackEntry>,
|
||||
latest_consensus: Option<&EpiphanyCultMeshImaginationConsensusReceiptEntry>,
|
||||
) -> (Vec<BifrostAccountingRow>, Vec<String>) {
|
||||
|
|
@ -8862,6 +8881,75 @@ fn bifrost_accounting_rows(
|
|||
},
|
||||
);
|
||||
|
||||
let readiness_private = latest_readiness_review
|
||||
.map(|review| review.private_state_exposed)
|
||||
.unwrap_or(false);
|
||||
let readiness_review_count = latest_readiness_review
|
||||
.map(|review| {
|
||||
[
|
||||
&review.maintainer_review_receipt,
|
||||
&review.soul_review_receipt,
|
||||
&review.mind_review_receipt,
|
||||
&review.bifrost_review_receipt,
|
||||
]
|
||||
.iter()
|
||||
.filter(|receipt| !receipt.trim().is_empty() && receipt.as_str() != "none")
|
||||
.count()
|
||||
})
|
||||
.unwrap_or(0);
|
||||
let readiness_artifact_present = latest_readiness_review
|
||||
.map(|review| operator_artifact_status(&review.readiness_review_receipt_ref) == "present")
|
||||
.unwrap_or(false);
|
||||
let readiness_closed = latest_readiness_review
|
||||
.map(|review| {
|
||||
review.status == "readiness-approved"
|
||||
&& review.missing_required_count == 0
|
||||
&& review.readiness_approval_authorized
|
||||
&& !review.durable_state_commit_authorized
|
||||
&& !review.publication_authorized
|
||||
&& !review.merge_authorized
|
||||
&& !review.upstream_sync_authorized
|
||||
&& !review.deployment_authority
|
||||
&& !review.service_lifecycle_authority
|
||||
&& !review.hands_action_authorized
|
||||
&& readiness_review_count == 4
|
||||
&& readiness_artifact_present
|
||||
&& !readiness_private
|
||||
})
|
||||
.unwrap_or(false);
|
||||
push_bifrost_accounting_row(
|
||||
&mut rows,
|
||||
&mut tui_rows,
|
||||
BifrostAccountingRow {
|
||||
lane: "repo-work-readiness-review".to_string(),
|
||||
owner: "Maintainer/Soul/Mind/Bifrost".to_string(),
|
||||
status: bifrost_accounting_status(
|
||||
readiness_closed,
|
||||
latest_readiness_review.is_some(),
|
||||
readiness_private,
|
||||
),
|
||||
closure: format!(
|
||||
"review={} approval={} artifact={}",
|
||||
readiness_review_count,
|
||||
latest_readiness_review
|
||||
.map(|review| review.status.as_str())
|
||||
.unwrap_or("missing"),
|
||||
present_word(readiness_artifact_present)
|
||||
),
|
||||
ledger_entry_id: "none".to_string(),
|
||||
latest_receipt_id: latest_readiness_review
|
||||
.map(|review| review.review_id.clone())
|
||||
.unwrap_or_else(|| "none".to_string()),
|
||||
public_ref: latest_readiness_review
|
||||
.map(|review| review.readiness_review_receipt_ref.clone())
|
||||
.unwrap_or_else(|| "none".to_string()),
|
||||
review_receipt_count: readiness_review_count,
|
||||
credit_receipt_count: 0,
|
||||
public_artifact_count: usize::from(readiness_artifact_present),
|
||||
private_state_exposed: readiness_private,
|
||||
},
|
||||
);
|
||||
|
||||
let collaboration_private = latest_feedback
|
||||
.map(|feedback| feedback.private_state_included)
|
||||
.unwrap_or(false)
|
||||
|
|
|
|||
Reference in a new issue