Require typed metrics receipt evidence
This commit is contained in:
parent
b3dc8a15c0
commit
0a0d428b0a
6 changed files with 130 additions and 2 deletions
|
|
@ -8310,6 +8310,32 @@ fn push_metrics_accounting_row(
|
|||
&& credit_count > 0
|
||||
&& !receipt.public_proof_ref.trim().is_empty()
|
||||
&& !receipt.metrics_summary.trim().is_empty()
|
||||
&& !receipt
|
||||
.token_summary_ref
|
||||
.as_deref()
|
||||
.unwrap_or_default()
|
||||
.trim()
|
||||
.is_empty()
|
||||
&& matches!(
|
||||
receipt.cost_availability_status.as_deref(),
|
||||
Some("known" | "unavailable")
|
||||
)
|
||||
&& ((receipt.cost_availability_status.as_deref() == Some("known")
|
||||
&& !receipt
|
||||
.cost_summary_ref
|
||||
.as_deref()
|
||||
.unwrap_or_default()
|
||||
.trim()
|
||||
.is_empty())
|
||||
|| (receipt.cost_availability_status.as_deref() == Some("unavailable")
|
||||
&& !receipt
|
||||
.cost_unavailable_reason
|
||||
.as_deref()
|
||||
.unwrap_or_default()
|
||||
.trim()
|
||||
.is_empty()))
|
||||
&& receipt.review_duration_ms.unwrap_or_default() > 0
|
||||
&& receipt.review_event_count.unwrap_or_default() > 0
|
||||
&& !receipt.private_state_exposed
|
||||
})
|
||||
.unwrap_or(false);
|
||||
|
|
@ -9785,6 +9811,12 @@ mod lifecycle_projection_tests {
|
|||
metrics_summary: "complete metrics".to_string(),
|
||||
status: "complete".to_string(),
|
||||
private_state_exposed: false,
|
||||
token_summary_ref: Some("metrics://tokens/1".to_string()),
|
||||
cost_availability_status: Some("known".to_string()),
|
||||
cost_summary_ref: Some("metrics://cost/1".to_string()),
|
||||
cost_unavailable_reason: None,
|
||||
review_duration_ms: Some(1_000),
|
||||
review_event_count: Some(1),
|
||||
notes: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
|
@ -9938,9 +9970,27 @@ mod lifecycle_projection_tests {
|
|||
let metrics = metrics_receipt();
|
||||
rows.clear();
|
||||
tui.clear();
|
||||
push_metrics_accounting_row(&mut rows, &mut tui, &[request], Some(&metrics));
|
||||
push_metrics_accounting_row(
|
||||
&mut rows,
|
||||
&mut tui,
|
||||
std::slice::from_ref(&request),
|
||||
Some(&metrics),
|
||||
);
|
||||
assert_eq!(rows[0].status, "open");
|
||||
assert!(rows[0].closure.contains("requestIdentity=missing"));
|
||||
assert!(rows[0].closure.contains("receiptProof=complete"));
|
||||
|
||||
let mut incomplete_metrics = metrics_receipt();
|
||||
incomplete_metrics.token_summary_ref = None;
|
||||
rows.clear();
|
||||
tui.clear();
|
||||
push_metrics_accounting_row(
|
||||
&mut rows,
|
||||
&mut tui,
|
||||
std::slice::from_ref(&request),
|
||||
Some(&incomplete_metrics),
|
||||
);
|
||||
assert_eq!(rows[0].status, "open");
|
||||
assert!(rows[0].closure.contains("receiptProof=incomplete"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2325,6 +2325,18 @@ pub struct EpiphanyCultMeshBifrostMetricsReceiptEntry {
|
|||
pub private_state_exposed: bool,
|
||||
#[cultcache(key = 13)]
|
||||
pub notes: Vec<String>,
|
||||
#[cultcache(key = 14)]
|
||||
pub token_summary_ref: Option<String>,
|
||||
#[cultcache(key = 15)]
|
||||
pub cost_availability_status: Option<String>,
|
||||
#[cultcache(key = 16)]
|
||||
pub cost_summary_ref: Option<String>,
|
||||
#[cultcache(key = 17)]
|
||||
pub cost_unavailable_reason: Option<String>,
|
||||
#[cultcache(key = 18)]
|
||||
pub review_duration_ms: Option<u64>,
|
||||
#[cultcache(key = 19)]
|
||||
pub review_event_count: Option<u64>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
|
||||
|
|
@ -4740,6 +4752,12 @@ pub fn epiphany_cultmesh_bifrost_metrics_receipt_for_map_entry(
|
|||
metrics_summary: metrics_summary.into(),
|
||||
status: status.into(),
|
||||
private_state_exposed: false,
|
||||
token_summary_ref: Some("metrics://model-spend/tokens".to_string()),
|
||||
cost_availability_status: Some("known".to_string()),
|
||||
cost_summary_ref: Some("metrics://model-spend/cost".to_string()),
|
||||
cost_unavailable_reason: None,
|
||||
review_duration_ms: Some(1),
|
||||
review_event_count: Some(1),
|
||||
notes: vec![
|
||||
"Bifrost metrics receipt closes model-spend, review-load, accepted-artifact, and credit-readback accounting for branch work.".to_string(),
|
||||
"Metrics are operator-safe refs and summaries, not private worker transcripts or raw model streams.".to_string(),
|
||||
|
|
@ -5162,6 +5180,53 @@ fn validate_bifrost_metrics_receipt(
|
|||
"Bifrost metrics receipts require a metrics summary"
|
||||
));
|
||||
}
|
||||
if receipt
|
||||
.token_summary_ref
|
||||
.as_deref()
|
||||
.unwrap_or_default()
|
||||
.trim()
|
||||
.is_empty()
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"Bifrost metrics receipts require a token summary ref"
|
||||
));
|
||||
}
|
||||
match receipt.cost_availability_status.as_deref() {
|
||||
Some("known")
|
||||
if receipt
|
||||
.cost_summary_ref
|
||||
.as_deref()
|
||||
.unwrap_or_default()
|
||||
.trim()
|
||||
.is_empty() =>
|
||||
{
|
||||
return Err(anyhow!("known metric cost requires a cost summary ref"));
|
||||
}
|
||||
Some("unavailable")
|
||||
if receipt
|
||||
.cost_unavailable_reason
|
||||
.as_deref()
|
||||
.unwrap_or_default()
|
||||
.trim()
|
||||
.is_empty() =>
|
||||
{
|
||||
return Err(anyhow!("unavailable metric cost requires a reason"));
|
||||
}
|
||||
Some("known" | "unavailable") => {}
|
||||
_ => {
|
||||
return Err(anyhow!(
|
||||
"metric cost availability must be known or unavailable"
|
||||
));
|
||||
}
|
||||
}
|
||||
if receipt.review_duration_ms.unwrap_or_default() == 0 {
|
||||
return Err(anyhow!("Bifrost metrics receipts require review duration"));
|
||||
}
|
||||
if receipt.review_event_count.unwrap_or_default() == 0 {
|
||||
return Err(anyhow!(
|
||||
"Bifrost metrics receipts require review event count"
|
||||
));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1442,3 +1442,10 @@ explicit cost availability status, review duration, and review-event count.
|
|||
Unknown vendor pricing may be reported as unavailable rather than fabricated;
|
||||
it may not erase token accounting. A review count may not erase elapsed load,
|
||||
and duration may not erase how many review events occurred.
|
||||
|
||||
The Bifrost metrics receipt and accounting projection now enforce the same
|
||||
model. The receipt carries token-summary ref, cost availability plus either a
|
||||
cost ref or unavailable reason, review duration, and review-event count.
|
||||
Fields are optional on the stored v0 shape so older receipts remain readable,
|
||||
but missing legacy dimensions make `receiptProof=incomplete`. Receipt IDs and a
|
||||
free-text metrics summary can no longer counterfeit measurement completeness.
|
||||
|
|
|
|||
|
|
@ -541,3 +541,9 @@ This permits honest unavailable pricing without treating cost and tokens—or
|
|||
duration and event count—as interchangeable. Next inspect projected accounting
|
||||
status to ensure receipt presence cannot close a row whose required dimensions
|
||||
are absent.
|
||||
|
||||
That projection check is implemented. Bifrost metrics receipts now expose the
|
||||
four typed dimensions; old receipts deserialize with absent optional fields but
|
||||
remain incomplete. A negative projection test proves a receipt with IDs and
|
||||
summary but no token evidence cannot report complete proof. Continue with
|
||||
scheduler/cache projections that derive consequential status from presence.
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -660,4 +660,4 @@ current_status:
|
|||
- Service lifecycle receipt history is now event-only: `load_epiphany_cultmesh_daemon_service_lifecycle_receipts` filters out the `epiphany-local/daemon-service-lifecycle-receipt/latest` mirror, while `load_latest_epiphany_cultmesh_daemon_service_lifecycle_receipt` remains the latest-state reader. Focused unit test `service_lifecycle_receipt_history_excludes_latest_mirror` proves two per-receipt writes return exactly two history records and latest points at the second. Fresh smoke `verse-query-lifecycle-history-filter-smoke` and live overview/triage `local-20260618-145632-497-efac6f0d` / `local-20260618-145632-321-867947af` prove compact swarm sights still expose service lifecycle attention plus the present elevated runbook artifact without daemon pokes or service mutation. Do not use a broad unscoped cargo test filter for this check on Windows; it fans out across bin harnesses and hit a broken pipe during this pass.
|
||||
- `epiphany-verse-query seed-compact` is the compact seed receipt for wrappers and read-only rites. The older `seed` command still prints the full local Verse context for explicit debugging, but compact wrapper modes now avoid full `seed`/final `query` readback after the combined overview proof exposed Windows debug stack overflow from full-context serialization pressure.
|
||||
last_completed_repo_swarm_cut: Huginn live-fire has crossed the first real repo Body from Persona pressure to branch-local Hands commit and Soul/Mind closure, and now has repeatable closure and redacted-public-proof mouths. On `E:\Projects\Huginn` branch `epiphany/huginn/first-awakening`, `tools/epiphany_local_run.ps1 -Mode repo-persona-intake` accepted item `huginn-inspection-readback-livefire`, Weksa/Persona intake remained sealed, and `epiphany-work derive-plan` lowered it to model-authored safe family `repo.status_section` for `README.md` only. `tools/epiphany_local_run.ps1 -Mode repo-swarm-run` advanced four bounded pulses: run-from-plan, adopt-from-plan, execute-from-plan, and close-from-execute. Huginn commit `e9b07c38fceabbdc89ea35c2156326c80c0393a2` updated only `README.md`; closure receipt `.epiphany\work\work-close-huginn-inspection-readback-livefire.json` records status `closed`, Soul verdict `passed`, Mind state commit `repo-work-close-huginn-inspection-readback-livefire-mind-commit`, safe family `repo.status_section`, path scope `README.md`, Bifrost publication gate, and `privateStateExposed=false`. Verification also ran Huginn's TypeScript compiler through concrete Node path: `C:\Program Files\nodejs\node.exe E:\Projects\Huginn\node_modules\typescript\bin\tsc -p tsconfig.json` passed. Native verifier `epiphany-repo-livefire-closure-smoke --workspace E:\Projects\Huginn --item huginn-inspection-readback-livefire --expected-path README.md --expected-family repo.status_section --expected-gate awaiting-publication --expected-blocker bifrost-publication-missing` checks closure receipt, Mind map entry, overview gate/blocker, authority seals, and `git show` changed paths, returning `status=ok`, `soulVerdict=passed`, `publicationGate=Bifrost`, and `privateStateExposed=false`. Wrapper `tools/epiphany_local_run.ps1 -Mode repo-livefire-closure -Workspace E:\Projects\Huginn -RepoWorkItem huginn-inspection-readback-livefire -SkipBuild` exposes the same read-only proof through the local operator mouth; artifact `local-20260621-190156-803-2f85ba15` printed commit, path, gate, blocker, Soul verdict, Mind commit receipt, and `privateStateExposed=False` without push, merge, publication, or target mutation. New wrapper `tools/epiphany_local_run.ps1 -Mode repo-work-public-proof -Workspace E:\Projects\Huginn -RepoWorkItem huginn-inspection-readback-livefire -SkipBuild` exports the redacted proof bundle and repo-local Verse index without publishing; artifact `local-20260621-190645-345-4555b1dc` wrote `.epiphany\public\proof-bundles\repo-work-public-proof-huginn-inspection-readback-livefire.json`, proof id `repo-work-public-proof-huginn-inspection-readback-livefire`, SHA-256 `857545b199f3e37eb06c2e757e5cfc201958e46667bb1f8403fd333a22620f63`, nine artifact rows, zero publication rows, and `privateStateExposed=False`. swarm overview readback `local-20260621-190701-140-b9519ec6` sees the `REPO-WORK-PUBLIC-PROOF` row and action row from Huginn's repo-local Verse with the same SHA-256 while Bifrost publication remains missing. Launcher compact modes are now named compact operator-context modes instead of read-only modes, and `bifrost-public-proof` summaries print item, target public Verse, room, proof SHA-256, review receipts, and credit receipts so publication receipts are auditable without claiming upstream sync.
|
||||
next_action: Continue the observation-to-consequence audit. Metrics requests now require token summary, explicit cost availability, review duration, and review-event count separately. Inspect Bifrost accounting projections next: receipt presence must not close metrics rows if required measurement dimensions are absent. Then continue scheduler/cache projection audit. Keep closure's zero-substring invariant.
|
||||
next_action: Continue the observation-to-consequence audit. Bifrost metrics receipts and accounting projections now require typed token, cost-availability, review-duration, and event-count evidence; legacy/missing dimensions remain readable but incomplete. Next inspect scheduler and cache projections for consequential status derived from presence, freshness, or free-text summaries. Keep closure's zero-substring invariant.
|
||||
|
|
|
|||
Reference in a new issue