namespace AIStudio.Assistants.VisualBriefing; /// /// Computes the payload hashes that decide whether a stored intermediate artifact is still usable. /// /// /// Each formula lives here exactly once. The stage that writes an artifact and the store that reads it /// back have to agree on the sections down to their order, and they used to spell the formula out on /// both sides with a comment asking the next developer to keep them aligned. A single misplaced section /// makes the store discard every stored artifact of that kind, and it reports that as a missing /// artifact rather than as an error, so the mistake surfaces as a briefing that silently refuses to be /// reused. Sections are canonical JSON, which additionally makes the hashes independent of the order in /// which the artifact properties are declared. /// internal static class VisualBriefingPayloadHash { /// /// Computes the payload hash of an evidence artifact. /// /// The extracted facts. /// The extracted metrics. /// The extracted tables. /// The per-source coverage. /// The planned visual assets. /// The payload hash. internal static string ForEvidence( List facts, List metrics, List tables, List sourceCoverage, List assetPlan) => VisualBriefingHashing.ComputeSections( VisualBriefingHashing.CanonicalJson(facts), VisualBriefingHashing.CanonicalJson(metrics), VisualBriefingHashing.CanonicalJson(tables), VisualBriefingHashing.CanonicalJson(sourceCoverage), VisualBriefingHashing.CanonicalJson(assetPlan)); /// /// Computes the payload hash of a plan artifact. /// /// The planned sections. /// The structural signature of the plan. /// The payload hash. internal static string ForPlan( List sections, string structuralSignature) => VisualBriefingHashing.ComputeSections(VisualBriefingHashing.CanonicalJson(sections), structuralSignature); /// /// Computes the payload hash of a content artifact. /// /// The filled content slots. /// The chart specifications. /// The interactive control specifications. /// The formula specifications. /// The accessibility texts per component. /// The source references per component. /// The localized reset label. /// The per-source coverage. /// The planned visual assets. /// The structural signature of the business data. /// The payload hash. internal static string ForContent( List slots, List charts, List controls, List formulas, Dictionary accessibilityTexts, Dictionary> sourceReferences, string resetLabel, List sourceCoverage, List assetPlan, string structuralSignature) => VisualBriefingHashing.ComputeSections( VisualBriefingHashing.CanonicalJson(slots), VisualBriefingHashing.CanonicalJson(charts), VisualBriefingHashing.CanonicalJson(controls), VisualBriefingHashing.CanonicalJson(formulas), VisualBriefingHashing.CanonicalJson(accessibilityTexts), VisualBriefingHashing.CanonicalJson(sourceReferences), resetLabel, VisualBriefingHashing.CanonicalJson(sourceCoverage), VisualBriefingHashing.CanonicalJson(assetPlan), structuralSignature); /// /// Computes the payload hash of a presentation artifact. /// /// The compiled layout tree. /// The design profile. /// The hash of the compiled template. /// The hash of the compiled CSS. /// The payload hash. internal static string ForPresentation( VisualBriefingLayoutNode layout, VisualBriefingDesignProfile profile, string templateHash, string cssHash) => VisualBriefingHashing.ComputeSections( VisualBriefingHashing.CanonicalJson(layout), profile.ToString(), templateHash, cssHash); }