diff --git a/backend/api/data.py b/backend/api/data.py index 727334090..e1aeda815 100644 --- a/backend/api/data.py +++ b/backend/api/data.py @@ -74,6 +74,39 @@ AcquisitionReadinessState = Literal["ready", "needs_attention", "pending"] EvidencePacketChecklistState = Literal["ready", "needs_attention", "pending"] DataRoomManifestState = Literal["ready", "needs_attention", "pending"] +DataRoomReleaseStatus = Literal["release_ready", "release_blocked"] +CommercialCloseReadinessStatus = Literal[ + "commercially_ready", + "commercially_blocked", +] +CommercialCloseReadinessCategoryStatus = Literal["ready", "needs_attention"] +CommercialCloseExecutionStatus = Literal["execution_ready", "execution_blocked"] +CommercialCloseExecutionLaneStatus = Literal["ready", "blocked"] +CommercialCloseKpiMetricKind = Literal["primary", "driver", "guardrail"] +CommercialCloseKpiMetricStatus = Literal["target_met", "needs_attention"] +CommercialCloseKpiOperatingStatus = Literal["operating_ready", "operating_blocked"] +CommercialCloseBuyerBriefStatus = Literal["brief_ready", "brief_blocked"] +CommercialCloseSignoffStatus = Literal["signed_off", "blocked"] +CommercialCloseSignoffMatrixStatus = Literal["signoff_ready", "signoff_blocked"] +CommercialCloseReleaseArtifactStatus = Literal["ready", "blocked"] +CommercialCloseReleasePackageStatus = Literal["release_ready", "release_blocked"] +CommercialCloseReleaseArtifactGroup = Literal[ + "core_evidence", + "commercial_close", + "buyer_diligence", + "guardrail", +] +CommercialCloseBuyerReviewRunbookStatus = Literal["review_ready", "review_blocked"] +CommercialCloseBuyerReviewStepStatus = Literal["ready", "blocked"] +CommercialCloseBuyerReviewStepLane = Literal[ + "intake", + "verification", + "privacy", + "data_room", + "commercial", + "signoff", + "release", +] DataRoomArtifactType = Literal[ "snapshot_json", "verifier_script", @@ -87,6 +120,7 @@ DiligenceCloseSeverity = Literal["critical", "high", "medium", "none"] DiligenceArtifactReviewStatus = Literal["blocked", "ready_for_review"] DiligenceOwnerHandoffStatus = Literal["blocked", "ready_for_handoff"] +DiligenceAcceptanceStatus = Literal["blocked", "ready_for_acceptance"] RemediationPriority = Literal["critical", "high", "medium"] DiligenceRecommendation = Literal[ "ready_for_diligence", @@ -466,6 +500,269 @@ class DataRoomPackageManifestEntry(BaseModel): provider_write_executed: bool +class DataRoomReleaseSummary(BaseModel): + release_key: str + release_status: DataRoomReleaseStatus + total_artifact_count: int + ready_artifact_count: int + needs_attention_artifact_count: int + required_for_close_count: int + blocked_artifact_files: list[str] + privacy_exposure_count: int + raw_content_exposure_count: int + stable_identifier_exposure_count: int + provider_credential_exposure_count: int + snapshot_verification_required: bool + verification_command: str + acceptance_blocker_count: int + acceptance_blocker_keys: list[str] + buyer_summary_text: str + next_action_text: str + provider_write_executed: bool + + +class DataCommercialCloseReadinessCategoryScore(BaseModel): + category_key: str + display_name: str + status_code: CommercialCloseReadinessCategoryStatus + score: int + max_score: int + detail_text: str + + +class DataCommercialCloseReadinessScorecard(BaseModel): + scorecard_key: str + target_contract_value_krw: int + target_contract_label: str + status_code: CommercialCloseReadinessStatus + total_score: int + max_score: int + category_scores: list[DataCommercialCloseReadinessCategoryScore] + blocked_artifact_count: int + blocked_artifact_files: list[str] + acceptance_blocker_count: int + acceptance_blocker_keys: list[str] + kpi_gap_count: int + kpi_gap_keys: list[str] + privacy_exposure_count: int + verifier_ready: bool + release_status: DataRoomReleaseStatus + close_gate_status: CloseGateStatus + buyer_summary_text: str + next_action_text: str + provider_write_executed: bool + + +class DataCommercialCloseExecutionLane(BaseModel): + lane_key: str + execution_order: int + display_name: str + owner_area: str + priority_code: RemediationPriority + status_code: CommercialCloseExecutionLaneStatus + related_artifact: str + artifact_ready: bool + action_count: int + action_keys: list[str] + blocking_check_keys: list[str] + acceptance_blocker_keys: list[str] + kpi_gap_keys: list[str] + acceptance_criteria: str + verification_command: str + next_action_text: str + provider_write_executed: bool + + +class DataCommercialCloseExecutionPlan(BaseModel): + plan_key: str + target_contract_value_krw: int + target_contract_label: str + status_code: CommercialCloseExecutionStatus + total_lane_count: int + blocked_lane_count: int + ready_lane_count: int + critical_lane_count: int + high_lane_count: int + medium_lane_count: int + related_artifact_count: int + related_artifacts: list[str] + total_action_count: int + kpi_gap_count: int + acceptance_blocker_count: int + verification_command: str + buyer_summary_text: str + next_action_text: str + lanes: list[DataCommercialCloseExecutionLane] + provider_write_executed: bool + + +class DataCommercialCloseKpiOperatingMetric(BaseModel): + metric_key: str + display_name: str + metric_kind: CommercialCloseKpiMetricKind + status_code: CommercialCloseKpiMetricStatus + current_value: int + target_value: int + unit_label: str + source_field: str + owner_area: str + buyer_implication: str + next_action_text: str + provider_write_executed: bool + + +class DataCommercialCloseKpiOperatingModel(BaseModel): + model_key: str + target_contract_value_krw: int + target_contract_label: str + status_code: CommercialCloseKpiOperatingStatus + primary_metric_key: str + total_metric_count: int + target_met_metric_count: int + needs_attention_metric_count: int + primary_metric_count: int + driver_metric_count: int + guardrail_metric_count: int + blocked_metric_keys: list[str] + guardrail_breach_count: int + buyer_summary_text: str + next_action_text: str + metrics: list[DataCommercialCloseKpiOperatingMetric] + provider_write_executed: bool + + +class DataCommercialCloseBuyerBriefBullet(BaseModel): + bullet_key: str + display_name: str + source_field: str + detail_text: str + provider_write_executed: bool + + +class DataCommercialCloseBuyerBrief(BaseModel): + brief_key: str + target_contract_value_krw: int + target_contract_label: str + status_code: CommercialCloseBuyerBriefStatus + readiness_headline_text: str + proof_thesis_text: str + evidence_basis_bullets: list[DataCommercialCloseBuyerBriefBullet] + blocker_bullets: list[DataCommercialCloseBuyerBriefBullet] + guardrail_bullets: list[DataCommercialCloseBuyerBriefBullet] + reviewer_handoff_text: str + next_action_text: str + provider_write_executed: bool + + +class DataCommercialCloseSignoffRow(BaseModel): + signoff_key: str + reviewer_role: str + owner_area: str + status_code: CommercialCloseSignoffStatus + source_field: str + required_artifact: str + blocker_keys: list[str] + acceptance_text: str + next_action_text: str + provider_write_executed: bool + + +class DataCommercialCloseSignoffMatrix(BaseModel): + matrix_key: str + target_contract_value_krw: int + target_contract_label: str + status_code: CommercialCloseSignoffMatrixStatus + required_signoff_count: int + signed_off_count: int + blocked_signoff_count: int + blocker_key_count: int + blocker_keys: list[str] + guardrail_summary_text: str + reviewer_handoff_text: str + next_action_text: str + signoffs: list[DataCommercialCloseSignoffRow] + provider_write_executed: bool + + +class DataCommercialCloseReleaseArtifact(BaseModel): + artifact_key: str + release_order: int + file_name: str + display_name: str + artifact_group: CommercialCloseReleaseArtifactGroup + status_code: CommercialCloseReleaseArtifactStatus + source_field: str + required_artifact: str + reviewer_role: str + blocker_keys: list[str] + release_instruction_text: str + contains_raw_content: bool + contains_stable_identifiers: bool + contains_provider_credentials: bool + provider_write_executed: bool + + +class DataCommercialCloseReleasePackage(BaseModel): + package_key: str + target_contract_value_krw: int + target_contract_label: str + status_code: CommercialCloseReleasePackageStatus + total_artifact_count: int + ready_artifact_count: int + blocked_artifact_count: int + signed_off_count: int + blocked_signoff_count: int + blocker_key_count: int + blocked_artifact_files: list[str] + blocker_keys: list[str] + first_release_file_name: str + verification_command: str + buyer_handoff_text: str + next_action_text: str + artifacts: list[DataCommercialCloseReleaseArtifact] + provider_write_executed: bool + + +class DataCommercialCloseBuyerReviewRunbookStep(BaseModel): + step_key: str + review_order: int + lane: CommercialCloseBuyerReviewStepLane + status_code: CommercialCloseBuyerReviewStepStatus + evidence_file_name: str + source_field: str + reviewer_role: str + owner_area: str + sla_hours: int + review_day: int + entry_criteria_text: str + exit_criteria_text: str + blocker_keys: list[str] + contains_raw_content: bool + contains_stable_identifiers: bool + contains_provider_credentials: bool + provider_write_executed: bool + + +class DataCommercialCloseBuyerReviewRunbook(BaseModel): + runbook_key: str + target_contract_value_krw: int + target_contract_label: str + status_code: CommercialCloseBuyerReviewRunbookStatus + total_step_count: int + ready_step_count: int + blocked_step_count: int + blocker_key_count: int + blocked_step_keys: list[str] + blocker_keys: list[str] + first_step_key: str + final_decision_step_key: str + verification_command: str + buyer_handoff_text: str + next_action_text: str + steps: list[DataCommercialCloseBuyerReviewRunbookStep] + provider_write_executed: bool + + class DataDiligenceExceptionRegisterEntry(BaseModel): exception_key: str blocking_check_key: str @@ -580,6 +877,43 @@ class DataDiligenceCloseTraceabilityMapEntry(BaseModel): provider_write_executed: bool +class DataDiligenceCloseAcceptanceChecklistEntry(BaseModel): + acceptance_key: str + trace_key: str + data_room_artifact: str + source_field: str + owner_area: str + reviewer_roles: list[str] + acceptance_status: DiligenceAcceptanceStatus + close_gate_status: CloseGateStatus + blocker_keys: list[str] + acceptance_criteria: str + verification_command: str + reviewer_evidence_summary: str + next_action: str + snapshot_verification_required: bool + provider_write_executed: bool + + +class DataDiligenceCloseAcceptanceSummary(BaseModel): + summary_key: str + decision_code: DiligenceCloseDecision + total_acceptance_count: int + blocked_acceptance_count: int + ready_acceptance_count: int + reviewer_role_count: int + reviewer_roles: list[str] + required_artifact_count: int + required_artifacts: list[str] + blocker_count: int + blocker_keys: list[str] + close_gate_status: CloseGateStatus + snapshot_verification_required: bool + buyer_summary_text: str + next_action_text: str + provider_write_executed: bool + + def _default_diligence_close_decision_summary() -> DataDiligenceCloseDecisionSummary: return DataDiligenceCloseDecisionSummary( summary_key="buyer_close_decision", @@ -600,6 +934,215 @@ def _default_diligence_close_decision_summary() -> DataDiligenceCloseDecisionSum ) +def _default_data_room_release_summary() -> DataRoomReleaseSummary: + return DataRoomReleaseSummary( + release_key="buyer_data_room_release", + release_status="release_blocked", + total_artifact_count=0, + ready_artifact_count=0, + needs_attention_artifact_count=0, + required_for_close_count=0, + blocked_artifact_files=[], + privacy_exposure_count=0, + raw_content_exposure_count=0, + stable_identifier_exposure_count=0, + provider_credential_exposure_count=0, + snapshot_verification_required=False, + verification_command="", + acceptance_blocker_count=0, + acceptance_blocker_keys=[], + buyer_summary_text="No buyer data-room release artifacts are present.", + next_action_text="Generate the evidence snapshot before release review.", + provider_write_executed=False, + ) + + +def _default_commercial_close_readiness_scorecard() -> ( + DataCommercialCloseReadinessScorecard +): + return DataCommercialCloseReadinessScorecard( + scorecard_key="commercial_close_readiness", + target_contract_value_krw=2_000_000_000, + target_contract_label="2,000,000,000 KRW", + status_code="commercially_blocked", + total_score=0, + max_score=100, + category_scores=[], + blocked_artifact_count=0, + blocked_artifact_files=[], + acceptance_blocker_count=0, + acceptance_blocker_keys=[], + kpi_gap_count=0, + kpi_gap_keys=[], + privacy_exposure_count=0, + verifier_ready=False, + release_status="release_blocked", + close_gate_status="blocked", + buyer_summary_text="No commercial close readiness evidence is present.", + next_action_text="Generate the evidence snapshot before commercial review.", + provider_write_executed=False, + ) + + +def _default_commercial_close_execution_plan() -> DataCommercialCloseExecutionPlan: + return DataCommercialCloseExecutionPlan( + plan_key="commercial_close_execution_plan", + target_contract_value_krw=2_000_000_000, + target_contract_label="2,000,000,000 KRW", + status_code="execution_blocked", + total_lane_count=0, + blocked_lane_count=0, + ready_lane_count=0, + critical_lane_count=0, + high_lane_count=0, + medium_lane_count=0, + related_artifact_count=0, + related_artifacts=[], + total_action_count=0, + kpi_gap_count=0, + acceptance_blocker_count=0, + verification_command="", + buyer_summary_text="No commercial close execution plan is present.", + next_action_text="Generate the evidence snapshot before execution review.", + lanes=[], + provider_write_executed=False, + ) + + +def _default_commercial_close_kpi_operating_model() -> ( + DataCommercialCloseKpiOperatingModel +): + return DataCommercialCloseKpiOperatingModel( + model_key="commercial_close_kpi_operating_model", + target_contract_value_krw=2_000_000_000, + target_contract_label="2,000,000,000 KRW", + status_code="operating_blocked", + primary_metric_key="commercial_close_readiness_score", + total_metric_count=0, + target_met_metric_count=0, + needs_attention_metric_count=0, + primary_metric_count=0, + driver_metric_count=0, + guardrail_metric_count=0, + blocked_metric_keys=[], + guardrail_breach_count=0, + buyer_summary_text="No commercial close KPI operating model is present.", + next_action_text="Generate the evidence snapshot before KPI operating review.", + metrics=[], + provider_write_executed=False, + ) + + +def _default_commercial_close_buyer_brief() -> DataCommercialCloseBuyerBrief: + return DataCommercialCloseBuyerBrief( + brief_key="commercial_close_buyer_brief", + target_contract_value_krw=2_000_000_000, + target_contract_label="2,000,000,000 KRW", + status_code="brief_blocked", + readiness_headline_text="No commercial close buyer brief is present.", + proof_thesis_text="Generate the evidence snapshot before buyer brief review.", + evidence_basis_bullets=[], + blocker_bullets=[], + guardrail_bullets=[], + reviewer_handoff_text="No reviewer handoff is present.", + next_action_text="Generate the evidence snapshot before buyer brief review.", + provider_write_executed=False, + ) + + +def _default_commercial_close_signoff_matrix() -> ( + DataCommercialCloseSignoffMatrix +): + return DataCommercialCloseSignoffMatrix( + matrix_key="commercial_close_signoff_matrix", + target_contract_value_krw=2_000_000_000, + target_contract_label="2,000,000,000 KRW", + status_code="signoff_blocked", + required_signoff_count=0, + signed_off_count=0, + blocked_signoff_count=0, + blocker_key_count=0, + blocker_keys=[], + guardrail_summary_text="No commercial close signoff matrix is present.", + reviewer_handoff_text="No reviewer handoff is present.", + next_action_text="Generate the evidence snapshot before signoff review.", + signoffs=[], + provider_write_executed=False, + ) + + +def _default_commercial_close_release_package() -> ( + DataCommercialCloseReleasePackage +): + return DataCommercialCloseReleasePackage( + package_key="commercial_close_release_package", + target_contract_value_krw=2_000_000_000, + target_contract_label="2,000,000,000 KRW", + status_code="release_blocked", + total_artifact_count=0, + ready_artifact_count=0, + blocked_artifact_count=0, + signed_off_count=0, + blocked_signoff_count=0, + blocker_key_count=0, + blocked_artifact_files=[], + blocker_keys=[], + first_release_file_name="", + verification_command="", + buyer_handoff_text="No commercial close release package is present.", + next_action_text="Generate the evidence snapshot before release package review.", + artifacts=[], + provider_write_executed=False, + ) + + +def _default_commercial_close_buyer_review_runbook() -> ( + DataCommercialCloseBuyerReviewRunbook +): + return DataCommercialCloseBuyerReviewRunbook( + runbook_key="commercial_close_buyer_review_runbook", + target_contract_value_krw=2_000_000_000, + target_contract_label="2,000,000,000 KRW", + status_code="review_blocked", + total_step_count=0, + ready_step_count=0, + blocked_step_count=0, + blocker_key_count=0, + blocked_step_keys=[], + blocker_keys=[], + first_step_key="", + final_decision_step_key="", + verification_command="", + buyer_handoff_text="No commercial close buyer review runbook is present.", + next_action_text="Generate the evidence snapshot before buyer review.", + steps=[], + provider_write_executed=False, + ) + + +def _default_diligence_close_acceptance_summary() -> ( + DataDiligenceCloseAcceptanceSummary +): + return DataDiligenceCloseAcceptanceSummary( + summary_key="buyer_close_acceptance", + decision_code="ready_to_close", + total_acceptance_count=0, + blocked_acceptance_count=0, + ready_acceptance_count=0, + reviewer_role_count=0, + reviewer_roles=[], + required_artifact_count=0, + required_artifacts=[], + blocker_count=0, + blocker_keys=[], + close_gate_status="ready", + snapshot_verification_required=False, + buyer_summary_text="No buyer acceptance requirements are present.", + next_action_text="Generate the evidence snapshot before buyer acceptance.", + provider_write_executed=False, + ) + + class DataEvidenceSnapshotQualityCheck(BaseModel): check_key: str display_name: str @@ -639,6 +1182,30 @@ class DataEvidenceSnapshotResponse(BaseModel): data_room_package_manifest: list[DataRoomPackageManifestEntry] = Field( default_factory=list ) + data_room_release_summary: DataRoomReleaseSummary = Field( + default_factory=_default_data_room_release_summary + ) + commercial_close_readiness_scorecard: ( + DataCommercialCloseReadinessScorecard + ) = Field(default_factory=_default_commercial_close_readiness_scorecard) + commercial_close_execution_plan: DataCommercialCloseExecutionPlan = Field( + default_factory=_default_commercial_close_execution_plan + ) + commercial_close_kpi_operating_model: ( + DataCommercialCloseKpiOperatingModel + ) = Field(default_factory=_default_commercial_close_kpi_operating_model) + commercial_close_buyer_brief: DataCommercialCloseBuyerBrief = Field( + default_factory=_default_commercial_close_buyer_brief + ) + commercial_close_signoff_matrix: DataCommercialCloseSignoffMatrix = Field( + default_factory=_default_commercial_close_signoff_matrix + ) + commercial_close_release_package: DataCommercialCloseReleasePackage = Field( + default_factory=_default_commercial_close_release_package + ) + commercial_close_buyer_review_runbook: ( + DataCommercialCloseBuyerReviewRunbook + ) = Field(default_factory=_default_commercial_close_buyer_review_runbook) diligence_exception_register: list[DataDiligenceExceptionRegisterEntry] = Field( default_factory=list ) @@ -660,6 +1227,12 @@ class DataEvidenceSnapshotResponse(BaseModel): diligence_close_traceability_map: list[ DataDiligenceCloseTraceabilityMapEntry ] = Field(default_factory=list) + diligence_close_acceptance_checklist: list[ + DataDiligenceCloseAcceptanceChecklistEntry + ] = Field(default_factory=list) + diligence_close_acceptance_summary: DataDiligenceCloseAcceptanceSummary = Field( + default_factory=_default_diligence_close_acceptance_summary + ) parser_manifest_summary: list[DataEvidenceSnapshotParserSummary] quality_checks: list[DataEvidenceSnapshotQualityCheck] content_graph_topology_counts: list[DataEvidenceSnapshotContentTopologyCount] @@ -1984,77 +2557,1855 @@ def _diligence_close_traceability_map( return entries -def _acquisition_remediation_actions( - quality_checks: list[DataQualityCheck], -) -> list[DataAcquisitionRemediationAction]: - actions: list[DataAcquisitionRemediationAction] = [] - for check in quality_checks: - if check.status_code == "pass" and check.issue_count <= 0: - continue - action = _REMEDIATION_ACTIONS_BY_CHECK_KEY.get(check.check_key) - if action is None: - continue - actions.append( - DataAcquisitionRemediationAction( - blocking_check_key=check.check_key, - provider_write_executed=False, - **action, - ) +def _diligence_close_acceptance_checklist( + snapshot: DataEvidenceSnapshotResponse, +) -> list[DataDiligenceCloseAcceptanceChecklistEntry]: + verification_command = snapshot.verification_handoff.verifier_command + return [ + DataDiligenceCloseAcceptanceChecklistEntry( + acceptance_key=f"accept_{trace.trace_key.removeprefix('trace_')}", + trace_key=trace.trace_key, + data_room_artifact=trace.data_room_artifact, + source_field=trace.source_field, + owner_area=trace.owner_area, + reviewer_roles=trace.buyer_review_roles, + acceptance_status=( + "blocked" + if trace.close_gate_status == "blocked" + else "ready_for_acceptance" + ), + close_gate_status=trace.close_gate_status, + blocker_keys=( + trace.exception_keys + if trace.close_gate_status == "blocked" + else [] + ), + acceptance_criteria=( + f"Resolve {trace.exception_count} exception(s), regenerate " + f"{trace.data_room_artifact} from {trace.source_field}, and " + "verify the copied snapshot digest before buyer acceptance." + ), + verification_command=verification_command, + reviewer_evidence_summary=( + f"{', '.join(trace.buyer_review_roles)} review " + f"{trace.data_room_artifact} for {trace.owner_area}; " + f"{trace.trace_key} covers {trace.exception_count} exception(s)." + ), + next_action=trace.next_action, + snapshot_verification_required=trace.snapshot_verification_required, + provider_write_executed=False, ) - return sorted(actions, key=lambda action: action.priority_rank) - + for trace in snapshot.diligence_close_traceability_map + ] -def _quality_check_completion_percent(check: DataQualityCheck) -> int: - if check.total_count <= 0: - return 0 - passed_count = max(check.total_count - check.issue_count, 0) - return round((passed_count / check.total_count) * 100) +def _diligence_close_acceptance_summary( + snapshot: DataEvidenceSnapshotResponse, +) -> DataDiligenceCloseAcceptanceSummary: + checklist = snapshot.diligence_close_acceptance_checklist + blocked = [item for item in checklist if item.acceptance_status == "blocked"] + ready = [ + item for item in checklist if item.acceptance_status == "ready_for_acceptance" + ] + reviewer_roles = sorted( + {role for item in checklist for role in item.reviewer_roles} + ) + required_artifacts = sorted({item.data_room_artifact for item in checklist}) + blocker_keys = sorted({key for item in blocked for key in item.blocker_keys}) + snapshot_verification_required = any( + item.snapshot_verification_required for item in checklist + ) -def _acquisition_readiness_kpis( - quality_checks: list[DataQualityCheck], -) -> list[DataAcquisitionReadinessKpi]: - kpis: list[DataAcquisitionReadinessKpi] = [] - for check in quality_checks: - target = _ACQUISITION_KPI_TARGETS_BY_CHECK_KEY.get(check.check_key) - if target is None: - continue - current_percent = _quality_check_completion_percent(check) - target_percent = int(target["target_percent"]) - kpis.append( - DataAcquisitionReadinessKpi( - source_check_key=check.check_key, - current_percent=current_percent, - target_met=( - check.status_code == "pass" and current_percent >= target_percent - ), - status_code=check.status_code, - provider_write_executed=False, - **target, - ) + if blocked: + buyer_summary_text = ( + f"Buyer acceptance remains blocked by {len(blocked)} item(s) " + f"across {len(required_artifacts)} artifact(s) and " + f"{len(blocker_keys)} blocker key(s)." + ) + next_action_text = ( + "Resolve blocker keys, regenerate the evidence snapshot, run the " + "offline verifier, and reissue the acceptance checklist." + ) + else: + buyer_summary_text = ( + f"Buyer acceptance is ready for {len(ready)} item(s) across " + f"{len(required_artifacts)} artifact(s)." + ) + next_action_text = ( + "Share the verified snapshot and acceptance checklist with buyer " + "reviewers." ) - return sorted(kpis, key=lambda kpi: kpi.priority_rank) + return DataDiligenceCloseAcceptanceSummary( + summary_key="buyer_close_acceptance", + decision_code="close_blocked" if blocked else "ready_to_close", + total_acceptance_count=len(checklist), + blocked_acceptance_count=len(blocked), + ready_acceptance_count=len(ready), + reviewer_role_count=len(reviewer_roles), + reviewer_roles=reviewer_roles, + required_artifact_count=len(required_artifacts), + required_artifacts=required_artifacts, + blocker_count=len(blocker_keys), + blocker_keys=blocker_keys, + close_gate_status="blocked" if blocked else "ready", + snapshot_verification_required=snapshot_verification_required, + buyer_summary_text=buyer_summary_text, + next_action_text=next_action_text, + provider_write_executed=False, + ) -def _acquisition_decision_summary( - *, - kpis: list[DataAcquisitionReadinessKpi], - remediation_actions: list[DataAcquisitionRemediationAction], - evidence_packet_ready: bool, - snapshot_verification_ready: bool, -) -> DataAcquisitionDecisionSummary: - target_gap_count = sum(1 for kpi in kpis if not kpi.target_met) - critical_action_count = sum( - 1 for action in remediation_actions if action.priority_code == "critical" + +def _data_room_release_summary( + snapshot: DataEvidenceSnapshotResponse, +) -> DataRoomReleaseSummary: + manifest = snapshot.data_room_package_manifest + ready_artifact_count = sum(1 for item in manifest if item.state_code == "ready") + blocked_artifact_files = sorted( + item.file_name for item in manifest if item.state_code != "ready" ) - high_action_count = sum( - 1 for action in remediation_actions if action.priority_code == "high" + required_for_close_count = sum(1 for item in manifest if item.required_for_close) + raw_content_exposure_count = sum( + 1 for item in manifest if item.contains_raw_content + ) + int(snapshot.privacy_redaction_policy.raw_content_exposed) + stable_identifier_exposure_count = sum( + 1 for item in manifest if item.contains_stable_identifiers + ) + int(snapshot.privacy_redaction_policy.stable_identifiers_exposed) + provider_credential_exposure_count = int( + snapshot.privacy_redaction_policy.provider_credentials_exposed ) - medium_action_count = sum( - 1 for action in remediation_actions if action.priority_code == "medium" + privacy_exposure_count = ( + raw_content_exposure_count + + stable_identifier_exposure_count + + provider_credential_exposure_count ) - if not evidence_packet_ready or not snapshot_verification_ready: - recommendation_code: DiligenceRecommendation = "insufficient_evidence" + acceptance_summary = snapshot.diligence_close_acceptance_summary + release_blocked = bool( + blocked_artifact_files + or privacy_exposure_count + or acceptance_summary.blocker_count + ) + + if release_blocked: + buyer_summary_text = ( + f"Data-room release remains blocked by {len(blocked_artifact_files)} " + f"artifact(s), {acceptance_summary.blocker_count} blocker key(s), and " + f"{privacy_exposure_count} privacy exposure(s)." + ) + next_action_text = ( + "Resolve blocked artifact states, clear acceptance blockers, run the " + "offline verifier, and reissue the release bundle." + ) + else: + buyer_summary_text = ( + f"Data-room release is ready with {len(manifest)} verified artifact(s)." + ) + next_action_text = ( + "Share the verified release bundle with buyer diligence reviewers." + ) + + return DataRoomReleaseSummary( + release_key="buyer_data_room_release", + release_status="release_blocked" if release_blocked else "release_ready", + total_artifact_count=len(manifest), + ready_artifact_count=ready_artifact_count, + needs_attention_artifact_count=len(blocked_artifact_files), + required_for_close_count=required_for_close_count, + blocked_artifact_files=blocked_artifact_files, + privacy_exposure_count=privacy_exposure_count, + raw_content_exposure_count=raw_content_exposure_count, + stable_identifier_exposure_count=stable_identifier_exposure_count, + provider_credential_exposure_count=provider_credential_exposure_count, + snapshot_verification_required=( + acceptance_summary.snapshot_verification_required + ), + verification_command=snapshot.verification_handoff.verifier_command, + acceptance_blocker_count=acceptance_summary.blocker_count, + acceptance_blocker_keys=acceptance_summary.blocker_keys, + buyer_summary_text=buyer_summary_text, + next_action_text=next_action_text, + provider_write_executed=False, + ) + + +def _weighted_readiness_score( + ready_count: int, + total_count: int, + max_score: int, +) -> int: + if total_count <= 0: + return 0 + return round((ready_count / total_count) * max_score) + + +def _commercial_category_score( + *, + category_key: str, + display_name: str, + score: int, + max_score: int, + detail_text: str, +) -> DataCommercialCloseReadinessCategoryScore: + return DataCommercialCloseReadinessCategoryScore( + category_key=category_key, + display_name=display_name, + status_code="ready" if score == max_score else "needs_attention", + score=score, + max_score=max_score, + detail_text=detail_text, + ) + + +def _commercial_close_readiness_scorecard( + snapshot: DataEvidenceSnapshotResponse, +) -> DataCommercialCloseReadinessScorecard: + release_summary = snapshot.data_room_release_summary + acceptance_summary = snapshot.diligence_close_acceptance_summary + acquisition_gate = snapshot.acquisition_readiness_gate + evidence_checklist = snapshot.evidence_packet_checklist + ready_packet_count = sum( + 1 for item in evidence_checklist if item.state_code == "ready" + ) + evidence_packet_score = _weighted_readiness_score( + ready_packet_count, + len(evidence_checklist), + 15, + ) + data_room_score = _weighted_readiness_score( + release_summary.ready_artifact_count, + release_summary.total_artifact_count, + 20, + ) + acceptance_score = ( + 20 + if ( + acceptance_summary.close_gate_status == "ready" + and acceptance_summary.blocker_count == 0 + ) + else 0 + ) + privacy_exposure_count = release_summary.privacy_exposure_count + privacy_score = 20 if privacy_exposure_count == 0 else 0 + verifier_ready = ( + snapshot.verification_handoff.digest_algorithm == "sha256" + and snapshot.verification_handoff.success_exit_code == 0 + and bool(snapshot.verification_handoff.verifier_command) + and "digest_mismatch" in snapshot.verification_handoff.failure_exit_codes + ) + verifier_score = 10 if verifier_ready else 0 + kpi_gap_keys = sorted( + kpi.source_check_key for kpi in acquisition_gate.kpis if not kpi.target_met + ) + kpi_score = _weighted_readiness_score( + sum(1 for kpi in acquisition_gate.kpis if kpi.target_met), + len(acquisition_gate.kpis), + 15, + ) + category_scores = [ + _commercial_category_score( + category_key="evidence_packet_integrity", + display_name="Evidence packet integrity", + score=evidence_packet_score, + max_score=15, + detail_text=( + f"{ready_packet_count} of {len(evidence_checklist)} evidence " + "packet checks are ready." + ), + ), + _commercial_category_score( + category_key="data_room_release_integrity", + display_name="Data room release integrity", + score=data_room_score, + max_score=20, + detail_text=( + f"{release_summary.ready_artifact_count} of " + f"{release_summary.total_artifact_count} data-room artifacts " + "are ready." + ), + ), + _commercial_category_score( + category_key="buyer_acceptance_clearance", + display_name="Buyer acceptance clearance", + score=acceptance_score, + max_score=20, + detail_text=( + f"{acceptance_summary.blocker_count} acceptance blocker key(s) " + "remain." + ), + ), + _commercial_category_score( + category_key="privacy_boundary", + display_name="Privacy boundary", + score=privacy_score, + max_score=20, + detail_text=f"{privacy_exposure_count} privacy exposure(s) remain.", + ), + _commercial_category_score( + category_key="offline_verification", + display_name="Offline verification", + score=verifier_score, + max_score=10, + detail_text=( + "Offline verifier contract is ready." + if verifier_ready + else "Offline verifier contract needs attention." + ), + ), + _commercial_category_score( + category_key="product_kpi_attainment", + display_name="Product KPI attainment", + score=kpi_score, + max_score=15, + detail_text=( + f"{len(kpi_gap_keys)} KPI target gap(s) remain for buyer review." + ), + ), + ] + total_score = sum(category.score for category in category_scores) + commercially_blocked = bool( + release_summary.release_status != "release_ready" + or acceptance_summary.close_gate_status != "ready" + or kpi_gap_keys + or privacy_exposure_count + or not verifier_ready + ) + target_contract_label = "2,000,000,000 KRW" + + if commercially_blocked: + buyer_summary_text = ( + "Commercial close remains blocked for " + f"{target_contract_label} target review: score " + f"{total_score}/100 with {len(kpi_gap_keys)} KPI gap(s), " + f"{acceptance_summary.blocker_count} acceptance blocker key(s), and " + f"{release_summary.needs_attention_artifact_count} blocked " + "data-room artifact(s)." + ) + next_action_text = ( + "Resolve KPI gaps and acceptance blockers, regenerate the data-room " + "bundle, run the offline verifier, and reissue the buyer scorecard." + ) + else: + buyer_summary_text = ( + "Commercial close readiness is ready for " + f"{target_contract_label} target review with score {total_score}/100." + ) + next_action_text = ( + "Share the verified data-room bundle and buyer scorecard with " + "commercial diligence reviewers." + ) + + return DataCommercialCloseReadinessScorecard( + scorecard_key="commercial_close_readiness", + target_contract_value_krw=2_000_000_000, + target_contract_label=target_contract_label, + status_code=( + "commercially_blocked" if commercially_blocked else "commercially_ready" + ), + total_score=total_score, + max_score=100, + category_scores=category_scores, + blocked_artifact_count=release_summary.needs_attention_artifact_count, + blocked_artifact_files=release_summary.blocked_artifact_files, + acceptance_blocker_count=acceptance_summary.blocker_count, + acceptance_blocker_keys=acceptance_summary.blocker_keys, + kpi_gap_count=len(kpi_gap_keys), + kpi_gap_keys=kpi_gap_keys, + privacy_exposure_count=privacy_exposure_count, + verifier_ready=verifier_ready, + release_status=release_summary.release_status, + close_gate_status=acceptance_summary.close_gate_status, + buyer_summary_text=buyer_summary_text, + next_action_text=next_action_text, + provider_write_executed=False, + ) + + +def _commercial_close_execution_plan( + snapshot: DataEvidenceSnapshotResponse, +) -> DataCommercialCloseExecutionPlan: + scorecard = snapshot.commercial_close_readiness_scorecard + manifest_ready_by_file = { + entry.file_name: entry.state_code == "ready" + for entry in snapshot.data_room_package_manifest + } + acceptance_blocker_set = set(scorecard.acceptance_blocker_keys) + kpi_gap_set = set(scorecard.kpi_gap_keys) + grouped_actions: dict[ + tuple[RemediationPriority, str, str], + list[DataAcquisitionRemediationAction], + ] = {} + for action in snapshot.acquisition_readiness_gate.remediation_actions: + related_artifact = _EXCEPTION_ARTIFACT_BY_CHECK_KEY.get( + action.blocking_check_key, + "remediation-actions.json", + ) + key = (action.priority_code, action.owner_area, related_artifact) + grouped_actions.setdefault(key, []).append(action) + + sorted_groups = sorted( + grouped_actions.items(), + key=lambda group: ( + min(action.priority_rank for action in group[1]), + _RISK_SEVERITY_RANK[group[0][0]], + group[0][1], + group[0][2], + ), + ) + lanes: list[DataCommercialCloseExecutionLane] = [] + verification_command = snapshot.verification_handoff.verifier_command + for execution_order, ((priority_code, owner_area, artifact), actions) in enumerate( + sorted_groups, + start=1, + ): + action_keys = [action.action_key for action in actions] + blocking_check_keys = [action.blocking_check_key for action in actions] + acceptance_blocker_keys = [ + f"exception_{action.action_key}" + for action in actions + if f"exception_{action.action_key}" in acceptance_blocker_set + ] + kpi_gap_keys = [ + action.blocking_check_key + for action in actions + if action.blocking_check_key in kpi_gap_set + ] + artifact_ready = manifest_ready_by_file.get(artifact, False) + status_code: CommercialCloseExecutionLaneStatus = ( + "blocked" + if ( + action_keys + or acceptance_blocker_keys + or kpi_gap_keys + or not artifact_ready + ) + else "ready" + ) + lanes.append( + DataCommercialCloseExecutionLane( + lane_key=( + f"lane_{priority_code}_{owner_area}_" + f"{_risk_matrix_key_part(artifact)}" + ), + execution_order=execution_order, + display_name=( + f"{priority_code.title()} {owner_area} execution for {artifact}" + ), + owner_area=owner_area, + priority_code=priority_code, + status_code=status_code, + related_artifact=artifact, + artifact_ready=artifact_ready, + action_count=len(action_keys), + action_keys=action_keys, + blocking_check_keys=blocking_check_keys, + acceptance_blocker_keys=acceptance_blocker_keys, + kpi_gap_keys=kpi_gap_keys, + acceptance_criteria=( + f"Resolve {len(action_keys)} action(s), regenerate {artifact}, " + f"run {verification_command}, and reissue the buyer scorecard." + ), + verification_command=verification_command, + next_action_text=" ".join( + action.recommended_next_step for action in actions + ), + provider_write_executed=False, + ) + ) + + blocked_lane_count = sum(1 for lane in lanes if lane.status_code == "blocked") + total_action_count = sum(lane.action_count for lane in lanes) + related_artifacts = sorted({lane.related_artifact for lane in lanes}) + status_code: CommercialCloseExecutionStatus = ( + "execution_ready" + if ( + scorecard.status_code == "commercially_ready" + and blocked_lane_count == 0 + and scorecard.kpi_gap_count == 0 + and scorecard.acceptance_blocker_count == 0 + ) + else "execution_blocked" + ) + if status_code == "execution_ready": + buyer_summary_text = ( + "Commercial close execution is ready for " + f"{scorecard.target_contract_label} target review with " + f"{len(lanes)} lane(s) cleared." + ) + next_action_text = ( + "Share the verified data-room bundle and execution plan with buyer " + "reviewers." + ) + else: + buyer_summary_text = ( + "Commercial close execution remains blocked for " + f"{scorecard.target_contract_label} target review: {len(lanes)} lane(s), " + f"{total_action_count} action(s), and {len(related_artifacts)} " + "artifact(s) require remediation." + ) + next_action_text = ( + "Execute lanes in priority order, regenerate affected artifacts, run " + "the offline verifier, and reissue the buyer scorecard." + ) + + return DataCommercialCloseExecutionPlan( + plan_key="commercial_close_execution_plan", + target_contract_value_krw=scorecard.target_contract_value_krw, + target_contract_label=scorecard.target_contract_label, + status_code=status_code, + total_lane_count=len(lanes), + blocked_lane_count=blocked_lane_count, + ready_lane_count=len(lanes) - blocked_lane_count, + critical_lane_count=sum(1 for lane in lanes if lane.priority_code == "critical"), + high_lane_count=sum(1 for lane in lanes if lane.priority_code == "high"), + medium_lane_count=sum(1 for lane in lanes if lane.priority_code == "medium"), + related_artifact_count=len(related_artifacts), + related_artifacts=related_artifacts, + total_action_count=total_action_count, + kpi_gap_count=scorecard.kpi_gap_count, + acceptance_blocker_count=scorecard.acceptance_blocker_count, + verification_command=verification_command, + buyer_summary_text=buyer_summary_text, + next_action_text=next_action_text, + lanes=lanes, + provider_write_executed=False, + ) + + +def _commercial_close_kpi_operating_model( + snapshot: DataEvidenceSnapshotResponse, +) -> DataCommercialCloseKpiOperatingModel: + scorecard = snapshot.commercial_close_readiness_scorecard + execution_plan = snapshot.commercial_close_execution_plan + release_summary = snapshot.data_room_release_summary + acceptance_summary = snapshot.diligence_close_acceptance_summary + acquisition_gate = snapshot.acquisition_readiness_gate + target_label = scorecard.target_contract_label + provider_write_count = sum( + int(write_executed) + for write_executed in ( + scorecard.provider_write_executed, + execution_plan.provider_write_executed, + release_summary.provider_write_executed, + acceptance_summary.provider_write_executed, + snapshot.verification_handoff.provider_write_executed, + ) + ) + + def status_for( + current_value: int, + target_value: int, + *, + maximum_guardrail: bool = False, + ) -> CommercialCloseKpiMetricStatus: + if maximum_guardrail: + return "target_met" if current_value <= target_value else "needs_attention" + return "target_met" if current_value >= target_value else "needs_attention" + + def metric( + *, + metric_key: str, + display_name: str, + metric_kind: CommercialCloseKpiMetricKind, + current_value: int, + target_value: int, + unit_label: str, + source_field: str, + owner_area: str, + buyer_implication: str, + next_action_text: str, + maximum_guardrail: bool = False, + ) -> DataCommercialCloseKpiOperatingMetric: + return DataCommercialCloseKpiOperatingMetric( + metric_key=metric_key, + display_name=display_name, + metric_kind=metric_kind, + status_code=status_for( + current_value, + target_value, + maximum_guardrail=maximum_guardrail, + ), + current_value=current_value, + target_value=target_value, + unit_label=unit_label, + source_field=source_field, + owner_area=owner_area, + buyer_implication=buyer_implication, + next_action_text=next_action_text, + provider_write_executed=False, + ) + + metrics = [ + metric( + metric_key="commercial_close_readiness_score", + display_name="Commercial close readiness score", + metric_kind="primary", + current_value=scorecard.total_score, + target_value=scorecard.max_score, + unit_label="score", + source_field="commercial_close_readiness_scorecard.total_score", + owner_area="commercial_diligence", + buyer_implication=( + f"{target_label} review remains blocked until the readiness " + "score reaches 100 and blockers clear." + ), + next_action_text=scorecard.next_action_text, + ), + metric( + metric_key="execution_lane_clearance", + display_name="Execution lane clearance", + metric_kind="driver", + current_value=execution_plan.ready_lane_count, + target_value=execution_plan.total_lane_count, + unit_label="lane", + source_field="commercial_close_execution_plan.ready_lane_count", + owner_area="program_management", + buyer_implication=( + "Buyer review needs every commercial close execution lane cleared." + ), + next_action_text=execution_plan.next_action_text, + ), + metric( + metric_key="data_room_artifact_readiness", + display_name="Data-room artifact readiness", + metric_kind="driver", + current_value=release_summary.ready_artifact_count, + target_value=release_summary.total_artifact_count, + unit_label="artifact", + source_field="data_room_release_summary.ready_artifact_count", + owner_area="data_room_ops", + buyer_implication=( + "All required data-room artifacts must be ready before buyer release." + ), + next_action_text=release_summary.next_action_text, + ), + metric( + metric_key="buyer_acceptance_clearance", + display_name="Buyer acceptance clearance", + metric_kind="driver", + current_value=acceptance_summary.ready_acceptance_count, + target_value=acceptance_summary.total_acceptance_count, + unit_label="acceptance", + source_field="diligence_close_acceptance_summary.ready_acceptance_count", + owner_area="buyer_diligence", + buyer_implication=( + "Buyer acceptance cannot close while acceptance items remain blocked." + ), + next_action_text=acceptance_summary.next_action_text, + ), + metric( + metric_key="product_kpi_attainment", + display_name="Product KPI attainment", + metric_kind="driver", + current_value=sum(1 for kpi in acquisition_gate.kpis if kpi.target_met), + target_value=len(acquisition_gate.kpis), + unit_label="kpi", + source_field="acquisition_readiness_gate.kpis", + owner_area="data_quality", + buyer_implication=( + "Product evidence KPIs must meet target before close readiness " + "can be claimed." + ), + next_action_text=acquisition_gate.decision_summary.next_step_text, + ), + metric( + metric_key="privacy_exposure_control", + display_name="Privacy exposure control", + metric_kind="guardrail", + current_value=release_summary.privacy_exposure_count, + target_value=0, + unit_label="exposure", + source_field="data_room_release_summary.privacy_exposure_count", + owner_area="privacy_security", + buyer_implication=( + "Buyer package must keep raw content, stable IDs, and credentials out." + ), + next_action_text="Keep the redaction policy enforced for every snapshot.", + maximum_guardrail=True, + ), + metric( + metric_key="offline_verifier_contract", + display_name="Offline verifier contract", + metric_kind="guardrail", + current_value=1 if scorecard.verifier_ready else 0, + target_value=1, + unit_label="contract", + source_field="verification_handoff.verifier_command", + owner_area="verification", + buyer_implication=( + "Buyer reviewers need a repeatable offline verifier for copied JSON." + ), + next_action_text=snapshot.verification_handoff.handoff_text, + ), + metric( + metric_key="provider_write_boundary", + display_name="Provider write boundary", + metric_kind="guardrail", + current_value=provider_write_count, + target_value=0, + unit_label="write", + source_field="provider_write_executed", + owner_area="security_governance", + buyer_implication=( + "Diligence evidence must remain read-only until explicit provider " + "write approval." + ), + next_action_text="Keep buyer evidence generation read-only.", + maximum_guardrail=True, + ), + ] + target_met_metric_count = sum( + 1 for item in metrics if item.status_code == "target_met" + ) + needs_attention_metric_count = len(metrics) - target_met_metric_count + blocked_metric_keys = [ + item.metric_key for item in metrics if item.status_code != "target_met" + ] + guardrail_breach_count = sum( + 1 + for item in metrics + if item.metric_kind == "guardrail" and item.status_code != "target_met" + ) + status_code: CommercialCloseKpiOperatingStatus = ( + "operating_ready" + if needs_attention_metric_count == 0 and guardrail_breach_count == 0 + else "operating_blocked" + ) + if status_code == "operating_ready": + buyer_summary_text = ( + f"Commercial close KPI operating model is ready for {target_label} " + "target review." + ) + next_action_text = ( + "Share the KPI operating model with buyer reviewers alongside the " + "verified data-room bundle." + ) + else: + buyer_summary_text = ( + "Commercial close KPI operating model remains blocked for " + f"{target_label} target review: {needs_attention_metric_count} of " + f"{len(metrics)} metric(s) need attention and {guardrail_breach_count} " + "guardrail breach(es) remain." + ) + next_action_text = ( + "Use the blocked KPI list to sequence execution lanes, regenerate " + "artifacts, rerun verification, and reissue the buyer scorecard." + ) + + return DataCommercialCloseKpiOperatingModel( + model_key="commercial_close_kpi_operating_model", + target_contract_value_krw=scorecard.target_contract_value_krw, + target_contract_label=target_label, + status_code=status_code, + primary_metric_key="commercial_close_readiness_score", + total_metric_count=len(metrics), + target_met_metric_count=target_met_metric_count, + needs_attention_metric_count=needs_attention_metric_count, + primary_metric_count=sum(1 for item in metrics if item.metric_kind == "primary"), + driver_metric_count=sum(1 for item in metrics if item.metric_kind == "driver"), + guardrail_metric_count=sum( + 1 for item in metrics if item.metric_kind == "guardrail" + ), + blocked_metric_keys=blocked_metric_keys, + guardrail_breach_count=guardrail_breach_count, + buyer_summary_text=buyer_summary_text, + next_action_text=next_action_text, + metrics=metrics, + provider_write_executed=False, + ) + + +def _commercial_close_buyer_brief( + snapshot: DataEvidenceSnapshotResponse, +) -> DataCommercialCloseBuyerBrief: + decision_summary = snapshot.diligence_close_decision_summary + acquisition_gate = snapshot.acquisition_readiness_gate + release_summary = snapshot.data_room_release_summary + acceptance_summary = snapshot.diligence_close_acceptance_summary + scorecard = snapshot.commercial_close_readiness_scorecard + execution_plan = snapshot.commercial_close_execution_plan + kpi_model = snapshot.commercial_close_kpi_operating_model + verification_handoff = snapshot.verification_handoff + privacy_policy = snapshot.privacy_redaction_policy + target_label = scorecard.target_contract_label + provider_write_count = sum( + int(write_executed) + for write_executed in ( + decision_summary.provider_write_executed, + acquisition_gate.provider_write_executed, + release_summary.provider_write_executed, + acceptance_summary.provider_write_executed, + scorecard.provider_write_executed, + execution_plan.provider_write_executed, + kpi_model.provider_write_executed, + verification_handoff.provider_write_executed, + ) + ) + + def yes_no(value: bool) -> str: + return "yes" if value else "no" + + def bullet( + *, + bullet_key: str, + display_name: str, + source_field: str, + detail_text: str, + ) -> DataCommercialCloseBuyerBriefBullet: + return DataCommercialCloseBuyerBriefBullet( + bullet_key=bullet_key, + display_name=display_name, + source_field=source_field, + detail_text=detail_text, + provider_write_executed=False, + ) + + evidence_basis_bullets = [ + bullet( + bullet_key="buyer_brief_readiness_score", + display_name="Commercial readiness score", + source_field="commercial_close_readiness_scorecard.total_score", + detail_text=( + f"Commercial readiness is {scorecard.total_score}/" + f"{scorecard.max_score} for {target_label} target review; " + f"status is {scorecard.status_code}." + ), + ), + bullet( + bullet_key="buyer_brief_data_room_release", + display_name="Data-room release", + source_field="data_room_release_summary.ready_artifact_count", + detail_text=( + f"Data-room release has {release_summary.ready_artifact_count}/" + f"{release_summary.total_artifact_count} artifact(s) ready and " + f"{release_summary.needs_attention_artifact_count} blocked artifact(s)." + ), + ), + bullet( + bullet_key="buyer_brief_acceptance_clearance", + display_name="Buyer acceptance clearance", + source_field="diligence_close_acceptance_summary.ready_acceptance_count", + detail_text=( + f"Buyer acceptance has {acceptance_summary.ready_acceptance_count}/" + f"{acceptance_summary.total_acceptance_count} acceptance item(s) " + f"ready with {acceptance_summary.blocker_count} blocker key(s)." + ), + ), + bullet( + bullet_key="buyer_brief_kpi_operating_model", + display_name="KPI operating model", + source_field="commercial_close_kpi_operating_model.target_met_metric_count", + detail_text=( + f"KPI operating model has {kpi_model.target_met_metric_count}/" + f"{kpi_model.total_metric_count} metric(s) at target and " + f"{kpi_model.guardrail_breach_count} guardrail breach(es)." + ), + ), + bullet( + bullet_key="buyer_brief_offline_verifier", + display_name="Offline verifier", + source_field="verification_handoff.verifier_command", + detail_text=( + "Copied snapshot JSON can be verified with " + f"{verification_handoff.verifier_command}." + ), + ), + ] + blocker_bullets = [ + bullet( + bullet_key=f"buyer_brief_blocker_{entry.exception_key}", + display_name=entry.display_name, + source_field=entry.source_field, + detail_text=( + f"{entry.severity_code} blocker owned by {entry.owner_area} for " + f"{entry.related_artifact}: {entry.next_action}" + ), + ) + for entry in snapshot.diligence_exception_register[:5] + ] + guardrail_bullets = [ + bullet( + bullet_key="buyer_brief_privacy_redaction", + display_name="Privacy redaction", + source_field="privacy_redaction_policy", + detail_text=( + "Privacy policy exposes raw content: " + f"{yes_no(privacy_policy.raw_content_exposed)}, stable IDs: " + f"{yes_no(privacy_policy.stable_identifiers_exposed)}, provider " + f"credentials: {yes_no(privacy_policy.provider_credentials_exposed)}." + ), + ), + bullet( + bullet_key="buyer_brief_data_room_exposure", + display_name="Data-room exposure controls", + source_field="data_room_release_summary.privacy_exposure_count", + detail_text=( + f"Data-room summary reports {release_summary.privacy_exposure_count} " + f"privacy exposure(s), {release_summary.raw_content_exposure_count} " + "raw content exposure(s), " + f"{release_summary.stable_identifier_exposure_count} stable ID " + f"exposure(s), and {release_summary.provider_credential_exposure_count} " + "credential exposure(s)." + ), + ), + bullet( + bullet_key="buyer_brief_provider_write_boundary", + display_name="Provider write boundary", + source_field="provider_write_executed", + detail_text=( + f"Provider write execution count is {provider_write_count}; buyer " + "evidence generation remains read-only." + ), + ), + bullet( + bullet_key="buyer_brief_snapshot_verifier", + display_name="Snapshot verifier", + source_field="verification_handoff", + detail_text=( + "Snapshot verification is required: " + f"{yes_no(release_summary.snapshot_verification_required)}; " + f"command {verification_handoff.verifier_command}." + ), + ), + ] + status_code: CommercialCloseBuyerBriefStatus = ( + "brief_ready" + if ( + decision_summary.decision_code == "ready_to_close" + and acquisition_gate.state_code == "ready" + and release_summary.release_status == "release_ready" + and acceptance_summary.decision_code == "ready_to_close" + and scorecard.status_code == "commercially_ready" + and execution_plan.status_code == "execution_ready" + and kpi_model.status_code == "operating_ready" + and provider_write_count == 0 + ) + else "brief_blocked" + ) + readiness_headline_text = ( + "Commercial close remains blocked: readiness score " + f"{scorecard.total_score}/{scorecard.max_score}, " + f"{kpi_model.needs_attention_metric_count} KPI operating metric(s), " + f"{execution_plan.blocked_lane_count} execution lane(s), and " + f"{len(snapshot.diligence_exception_register)} exception(s) require attention." + if status_code == "brief_blocked" + else ( + f"Commercial close buyer brief is ready for {target_label} target review." + ) + ) + proof_thesis_text = ( + "Naruon can package redacted DOM, paragraph, knowledge-graph, semantic " + "relation, data-room, KPI, and offline verifier evidence for buyer review " + "without exposing raw content, stable IDs, provider credentials, or provider " + "writes." + ) + reviewer_handoff_text = ( + "Buyer reviewers should start from commercial_close_buyer_brief, verify " + f"copied JSON with {verification_handoff.verifier_command}, then review " + f"{len(blocker_bullets)} blocker bullet(s) before release." + ) + next_action_text = ( + "Resolve top blocker bullets, rerun parser and graph remediation, regenerate " + "the snapshot, rerun the offline verifier, and reissue the buyer brief." + if status_code == "brief_blocked" + else "Share the verified buyer brief with commercial diligence reviewers." + ) + return DataCommercialCloseBuyerBrief( + brief_key="commercial_close_buyer_brief", + target_contract_value_krw=scorecard.target_contract_value_krw, + target_contract_label=target_label, + status_code=status_code, + readiness_headline_text=readiness_headline_text, + proof_thesis_text=proof_thesis_text, + evidence_basis_bullets=evidence_basis_bullets, + blocker_bullets=blocker_bullets, + guardrail_bullets=guardrail_bullets, + reviewer_handoff_text=reviewer_handoff_text, + next_action_text=next_action_text, + provider_write_executed=False, + ) + + +def _commercial_close_signoff_matrix( + snapshot: DataEvidenceSnapshotResponse, +) -> DataCommercialCloseSignoffMatrix: + buyer_brief = snapshot.commercial_close_buyer_brief + scorecard = snapshot.commercial_close_readiness_scorecard + execution_plan = snapshot.commercial_close_execution_plan + kpi_model = snapshot.commercial_close_kpi_operating_model + release_summary = snapshot.data_room_release_summary + acceptance_summary = snapshot.diligence_close_acceptance_summary + verification_handoff = snapshot.verification_handoff + privacy_policy = snapshot.privacy_redaction_policy + provider_write_count = sum( + int(write_executed) + for write_executed in ( + buyer_brief.provider_write_executed, + scorecard.provider_write_executed, + execution_plan.provider_write_executed, + kpi_model.provider_write_executed, + release_summary.provider_write_executed, + acceptance_summary.provider_write_executed, + verification_handoff.provider_write_executed, + ) + ) + + def row( + *, + signoff_key: str, + reviewer_role: str, + owner_area: str, + blocked: bool, + source_field: str, + required_artifact: str, + blocker_keys: list[str], + acceptance_text: str, + next_action_text: str, + ) -> DataCommercialCloseSignoffRow: + return DataCommercialCloseSignoffRow( + signoff_key=signoff_key, + reviewer_role=reviewer_role, + owner_area=owner_area, + status_code="blocked" if blocked else "signed_off", + source_field=source_field, + required_artifact=required_artifact, + blocker_keys=blocker_keys if blocked else [], + acceptance_text=acceptance_text, + next_action_text=next_action_text, + provider_write_executed=False, + ) + + privacy_signed_off = ( + not privacy_policy.raw_content_exposed + and not privacy_policy.stable_identifiers_exposed + and not privacy_policy.provider_credentials_exposed + and release_summary.privacy_exposure_count == 0 + ) + verifier_signed_off = ( + scorecard.verifier_ready + and release_summary.snapshot_verification_required + and bool(verification_handoff.verifier_command) + ) + signoffs = [ + row( + signoff_key="signoff_commercial_diligence", + reviewer_role="commercial diligence reviewer", + owner_area="commercial_diligence", + blocked=buyer_brief.status_code != "brief_ready", + source_field="commercial_close_buyer_brief.status_code", + required_artifact="commercial-close-buyer-brief.json", + blocker_keys=[ + bullet.bullet_key for bullet in buyer_brief.blocker_bullets[:5] + ], + acceptance_text=( + "Buyer brief is accepted when status is brief_ready and top " + "blocker bullets are cleared." + ), + next_action_text=buyer_brief.next_action_text, + ), + row( + signoff_key="signoff_program_management", + reviewer_role="program manager", + owner_area="program_management", + blocked=execution_plan.status_code != "execution_ready", + source_field="commercial_close_execution_plan.status_code", + required_artifact="commercial-close-execution-plan.json", + blocker_keys=[ + lane.lane_key + for lane in execution_plan.lanes + if lane.status_code != "ready" + ][:5], + acceptance_text=( + "Execution plan is accepted when every lane is ready and the " + "plan status is execution_ready." + ), + next_action_text=execution_plan.next_action_text, + ), + row( + signoff_key="signoff_data_room_ops", + reviewer_role="data-room operations reviewer", + owner_area="data_room_ops", + blocked=release_summary.release_status != "release_ready", + source_field="data_room_release_summary.release_status", + required_artifact="buyer-data-room-release.json", + blocker_keys=release_summary.blocked_artifact_files[:5], + acceptance_text=( + "Data-room release is accepted when release_status is " + "release_ready and all required artifacts are ready." + ), + next_action_text=release_summary.next_action_text, + ), + row( + signoff_key="signoff_buyer_diligence", + reviewer_role="buyer diligence reviewer", + owner_area="buyer_diligence", + blocked=acceptance_summary.decision_code != "ready_to_close", + source_field="diligence_close_acceptance_summary.decision_code", + required_artifact="buyer-acceptance-checklist.json", + blocker_keys=acceptance_summary.blocker_keys[:5], + acceptance_text=( + "Buyer diligence is accepted when decision_code is " + "ready_to_close and no acceptance blocker keys remain." + ), + next_action_text=acceptance_summary.next_action_text, + ), + row( + signoff_key="signoff_privacy_security", + reviewer_role="privacy/security reviewer", + owner_area="privacy_security", + blocked=not privacy_signed_off, + source_field="privacy_redaction_policy", + required_artifact="redacted-snapshot-policy.json", + blocker_keys=[ + key + for key, blocked in ( + ("raw_content_exposed", privacy_policy.raw_content_exposed), + ( + "stable_identifiers_exposed", + privacy_policy.stable_identifiers_exposed, + ), + ( + "provider_credentials_exposed", + privacy_policy.provider_credentials_exposed, + ), + ( + "data_room_privacy_exposure", + release_summary.privacy_exposure_count > 0, + ), + ) + if blocked + ], + acceptance_text=( + "Privacy guardrail is accepted when raw content, stable IDs, " + "credentials, and data-room privacy exposures are zero." + ), + next_action_text=( + "Keep redaction guardrails enforced before buyer release." + ), + ), + row( + signoff_key="signoff_verification", + reviewer_role="verification reviewer", + owner_area="verification", + blocked=not verifier_signed_off, + source_field="verification_handoff.verifier_command", + required_artifact="verify-evidence-snapshot.py", + blocker_keys=[] if verifier_signed_off else ["offline_verifier_contract"], + acceptance_text=( + "Verification is accepted when the offline verifier command and " + "snapshot verification requirement are present." + ), + next_action_text=( + "Save copied snapshot JSON and run " + f"{verification_handoff.verifier_command}." + ), + ), + row( + signoff_key="signoff_security_governance", + reviewer_role="security governance reviewer", + owner_area="security_governance", + blocked=provider_write_count != 0, + source_field="provider_write_executed", + required_artifact="read-only-evidence-boundary", + blocker_keys=[] if provider_write_count == 0 else ["provider_write_executed"], + acceptance_text=( + "Security governance is accepted when provider_write_executed is " + "false across the buyer evidence snapshot." + ), + next_action_text=( + "Keep provider write execution disabled until explicit approval." + ), + ), + ] + blocked_signoffs = [item for item in signoffs if item.status_code == "blocked"] + signed_off_count = len(signoffs) - len(blocked_signoffs) + blocker_keys = list( + dict.fromkeys( + key for signoff in blocked_signoffs for key in signoff.blocker_keys + ) + ) + status_code: CommercialCloseSignoffMatrixStatus = ( + "signoff_ready" if not blocked_signoffs else "signoff_blocked" + ) + if blocked_signoffs: + guardrail_summary_text = ( + "Privacy, offline verification, and provider write guardrails are " + f"signed off; {len(blocked_signoffs)} role signoff(s) remain blocked." + ) + reviewer_handoff_text = ( + "Route blocked signoffs to " + f"{', '.join(item.reviewer_role for item in blocked_signoffs)} before " + "buyer release." + ) + next_action_text = ( + "Resolve blocked signoff rows, regenerate the evidence snapshot, rerun " + "the offline verifier, and reissue the signoff matrix." + ) + else: + guardrail_summary_text = ( + "Privacy, offline verification, and provider write guardrails are " + "signed off." + ) + reviewer_handoff_text = ( + "All commercial close signoff reviewers can proceed with buyer release." + ) + next_action_text = ( + "Share the verified signoff matrix with commercial diligence reviewers." + ) + + return DataCommercialCloseSignoffMatrix( + matrix_key="commercial_close_signoff_matrix", + target_contract_value_krw=buyer_brief.target_contract_value_krw, + target_contract_label=buyer_brief.target_contract_label, + status_code=status_code, + required_signoff_count=len(signoffs), + signed_off_count=signed_off_count, + blocked_signoff_count=len(blocked_signoffs), + blocker_key_count=len(blocker_keys), + blocker_keys=blocker_keys[:8], + guardrail_summary_text=guardrail_summary_text, + reviewer_handoff_text=reviewer_handoff_text, + next_action_text=next_action_text, + signoffs=signoffs, + provider_write_executed=False, + ) + + +def _commercial_close_release_package( + snapshot: DataEvidenceSnapshotResponse, +) -> DataCommercialCloseReleasePackage: + release_summary = snapshot.data_room_release_summary + acceptance_summary = snapshot.diligence_close_acceptance_summary + scorecard = snapshot.commercial_close_readiness_scorecard + execution_plan = snapshot.commercial_close_execution_plan + kpi_model = snapshot.commercial_close_kpi_operating_model + buyer_brief = snapshot.commercial_close_buyer_brief + signoff_matrix = snapshot.commercial_close_signoff_matrix + privacy_policy = snapshot.privacy_redaction_policy + verification_handoff = snapshot.verification_handoff + target_label = buyer_brief.target_contract_label + privacy_ready = ( + not privacy_policy.raw_content_exposed + and not privacy_policy.stable_identifiers_exposed + and not privacy_policy.provider_credentials_exposed + and release_summary.privacy_exposure_count == 0 + ) + verifier_ready = ( + scorecard.verifier_ready + and bool(verification_handoff.verifier_command) + and verification_handoff.success_exit_code == 0 + ) + + def artifact( + *, + artifact_key: str, + release_order: int, + file_name: str, + display_name: str, + artifact_group: CommercialCloseReleaseArtifactGroup, + ready: bool, + source_field: str, + required_artifact: str, + reviewer_role: str, + blocker_keys: list[str], + release_instruction_text: str, + ) -> DataCommercialCloseReleaseArtifact: + return DataCommercialCloseReleaseArtifact( + artifact_key=artifact_key, + release_order=release_order, + file_name=file_name, + display_name=display_name, + artifact_group=artifact_group, + status_code="ready" if ready else "blocked", + source_field=source_field, + required_artifact=required_artifact, + reviewer_role=reviewer_role, + blocker_keys=[] if ready else blocker_keys, + release_instruction_text=release_instruction_text, + contains_raw_content=False, + contains_stable_identifiers=False, + contains_provider_credentials=False, + provider_write_executed=False, + ) + + artifacts = [ + artifact( + artifact_key="release_evidence_snapshot", + release_order=1, + file_name="naruon-evidence-snapshot.json", + display_name="Canonical evidence snapshot", + artifact_group="core_evidence", + ready=( + snapshot.snapshot_version == SNAPSHOT_VERSION + and snapshot.digest_algorithm == "sha256" + ), + source_field="snapshot_version,snapshot_digest,canonical_payload_fields", + required_artifact="naruon-evidence-snapshot.json", + reviewer_role="buyer diligence reviewer", + blocker_keys=[], + release_instruction_text=( + "Start buyer review from the canonical redacted snapshot JSON." + ), + ), + artifact( + artifact_key="release_privacy_policy", + release_order=2, + file_name="privacy-redaction-policy.json", + display_name="Privacy redaction policy", + artifact_group="guardrail", + ready=privacy_ready, + source_field="privacy_redaction_policy", + required_artifact="privacy-redaction-policy.json", + reviewer_role="privacy/security reviewer", + blocker_keys=[ + key + for key, blocked in ( + ("raw_content_exposed", privacy_policy.raw_content_exposed), + ( + "stable_identifiers_exposed", + privacy_policy.stable_identifiers_exposed, + ), + ( + "provider_credentials_exposed", + privacy_policy.provider_credentials_exposed, + ), + ( + "data_room_privacy_exposure", + release_summary.privacy_exposure_count > 0, + ), + ) + if blocked + ], + release_instruction_text=( + "Confirm raw content, stable identifiers, and credentials are absent." + ), + ), + artifact( + artifact_key="release_offline_verifier", + release_order=3, + file_name="verify-evidence-snapshot.py", + display_name="Offline evidence verifier", + artifact_group="guardrail", + ready=verifier_ready, + source_field="verification_handoff.verifier_command", + required_artifact="verify-evidence-snapshot.py", + reviewer_role="verification reviewer", + blocker_keys=[] if verifier_ready else ["offline_verifier_contract"], + release_instruction_text=( + "Run the verifier against copied snapshot JSON before sharing." + ), + ), + artifact( + artifact_key="release_data_room_summary", + release_order=4, + file_name="buyer-data-room-release.json", + display_name="Buyer data-room release summary", + artifact_group="buyer_diligence", + ready=release_summary.release_status == "release_ready", + source_field="data_room_release_summary.release_status", + required_artifact="buyer-data-room-release.json", + reviewer_role="data-room operations reviewer", + blocker_keys=release_summary.blocked_artifact_files[:5], + release_instruction_text=( + "Confirm all buyer data-room artifacts are ready for close." + ), + ), + artifact( + artifact_key="release_acceptance_checklist", + release_order=5, + file_name="buyer-acceptance-checklist.json", + display_name="Buyer acceptance checklist", + artifact_group="buyer_diligence", + ready=acceptance_summary.decision_code == "ready_to_close", + source_field="diligence_close_acceptance_summary.decision_code", + required_artifact="buyer-acceptance-checklist.json", + reviewer_role="buyer diligence reviewer", + blocker_keys=acceptance_summary.blocker_keys[:5], + release_instruction_text=( + "Resolve acceptance blockers before buyer close acceptance." + ), + ), + artifact( + artifact_key="release_readiness_scorecard", + release_order=6, + file_name="commercial-close-readiness-scorecard.json", + display_name="Commercial close readiness scorecard", + artifact_group="commercial_close", + ready=scorecard.status_code == "commercially_ready", + source_field="commercial_close_readiness_scorecard.status_code", + required_artifact="commercial-close-readiness-scorecard.json", + reviewer_role="commercial diligence reviewer", + blocker_keys=( + scorecard.kpi_gap_keys + + scorecard.acceptance_blocker_keys + + scorecard.blocked_artifact_files + )[:5], + release_instruction_text=( + "Review readiness score and blocker clearance for target review." + ), + ), + artifact( + artifact_key="release_execution_plan", + release_order=7, + file_name="commercial-close-execution-plan.json", + display_name="Commercial close execution plan", + artifact_group="commercial_close", + ready=execution_plan.status_code == "execution_ready", + source_field="commercial_close_execution_plan.status_code", + required_artifact="commercial-close-execution-plan.json", + reviewer_role="program manager", + blocker_keys=[ + lane.lane_key + for lane in execution_plan.lanes + if lane.status_code != "ready" + ][:5], + release_instruction_text=( + "Execute blocked lanes before reissuing the commercial package." + ), + ), + artifact( + artifact_key="release_kpi_operating_model", + release_order=8, + file_name="commercial-close-kpi-operating-model.json", + display_name="Commercial close KPI operating model", + artifact_group="commercial_close", + ready=kpi_model.status_code == "operating_ready", + source_field="commercial_close_kpi_operating_model.status_code", + required_artifact="commercial-close-kpi-operating-model.json", + reviewer_role="commercial diligence reviewer", + blocker_keys=kpi_model.blocked_metric_keys[:5], + release_instruction_text=( + "Verify all operating KPIs hit target before buyer package release." + ), + ), + artifact( + artifact_key="release_buyer_brief", + release_order=9, + file_name="commercial-close-buyer-brief.json", + display_name="Commercial close buyer brief", + artifact_group="commercial_close", + ready=buyer_brief.status_code == "brief_ready", + source_field="commercial_close_buyer_brief.status_code", + required_artifact="commercial-close-buyer-brief.json", + reviewer_role="commercial diligence reviewer", + blocker_keys=[ + bullet.bullet_key for bullet in buyer_brief.blocker_bullets[:5] + ], + release_instruction_text=( + "Use the buyer brief as the narrative index for close reviewers." + ), + ), + artifact( + artifact_key="release_signoff_matrix", + release_order=10, + file_name="commercial-close-signoff-matrix.json", + display_name="Commercial close signoff matrix", + artifact_group="commercial_close", + ready=signoff_matrix.status_code == "signoff_ready", + source_field="commercial_close_signoff_matrix.status_code", + required_artifact="commercial-close-signoff-matrix.json", + reviewer_role="commercial diligence reviewer", + blocker_keys=signoff_matrix.blocker_keys[:5], + release_instruction_text=( + "Confirm role signoffs before issuing the buyer release package." + ), + ), + ] + blocked_artifacts = [item for item in artifacts if item.status_code == "blocked"] + blocker_keys = list( + dict.fromkeys( + key for artifact_item in blocked_artifacts for key in artifact_item.blocker_keys + ) + ) + status_code: CommercialCloseReleasePackageStatus = ( + "release_ready" if not blocked_artifacts else "release_blocked" + ) + if blocked_artifacts: + buyer_handoff_text = ( + f"Commercial close release package remains blocked for {target_label} " + f"target review: {len(blocked_artifacts)} artifact(s) need remediation." + ) + next_action_text = ( + "Resolve blocked release artifacts, regenerate the evidence snapshot, " + "rerun the offline verifier, and reissue the release package." + ) + else: + buyer_handoff_text = ( + f"Commercial close release package is ready for {target_label} buyer " + "handoff." + ) + next_action_text = ( + "Share the verified release package with buyer diligence reviewers." + ) + + return DataCommercialCloseReleasePackage( + package_key="commercial_close_release_package", + target_contract_value_krw=buyer_brief.target_contract_value_krw, + target_contract_label=target_label, + status_code=status_code, + total_artifact_count=len(artifacts), + ready_artifact_count=len(artifacts) - len(blocked_artifacts), + blocked_artifact_count=len(blocked_artifacts), + signed_off_count=signoff_matrix.signed_off_count, + blocked_signoff_count=signoff_matrix.blocked_signoff_count, + blocker_key_count=len(blocker_keys), + blocked_artifact_files=[item.file_name for item in blocked_artifacts], + blocker_keys=blocker_keys[:10], + first_release_file_name=artifacts[0].file_name, + verification_command=verification_handoff.verifier_command, + buyer_handoff_text=buyer_handoff_text, + next_action_text=next_action_text, + artifacts=artifacts, + provider_write_executed=False, + ) + + +def _commercial_close_buyer_review_runbook( + snapshot: DataEvidenceSnapshotResponse, +) -> DataCommercialCloseBuyerReviewRunbook: + release_package = snapshot.commercial_close_release_package + artifact_by_key = { + artifact.artifact_key: artifact for artifact in release_package.artifacts + } + + def artifact_step( + *, + step_key: str, + review_order: int, + lane: CommercialCloseBuyerReviewStepLane, + artifact_key: str, + source_field: str, + reviewer_role: str, + owner_area: str, + sla_hours: int, + review_day: int, + entry_criteria_text: str, + exit_criteria_text: str, + ) -> DataCommercialCloseBuyerReviewRunbookStep: + artifact = artifact_by_key.get(artifact_key) + ready = artifact is not None and artifact.status_code == "ready" + if artifact is None: + evidence_file_name = "" + blocker_keys = [f"{artifact_key}_missing"] + else: + evidence_file_name = artifact.file_name + blocker_keys = artifact.blocker_keys + return DataCommercialCloseBuyerReviewRunbookStep( + step_key=step_key, + review_order=review_order, + lane=lane, + status_code="ready" if ready else "blocked", + evidence_file_name=evidence_file_name, + source_field=source_field, + reviewer_role=reviewer_role, + owner_area=owner_area, + sla_hours=sla_hours, + review_day=review_day, + entry_criteria_text=entry_criteria_text, + exit_criteria_text=exit_criteria_text, + blocker_keys=[] if ready else blocker_keys, + contains_raw_content=False, + contains_stable_identifiers=False, + contains_provider_credentials=False, + provider_write_executed=False, + ) + + steps = [ + DataCommercialCloseBuyerReviewRunbookStep( + step_key="buyer_review_intake", + review_order=1, + lane="intake", + status_code=( + "ready" + if release_package.total_artifact_count > 0 + and bool(release_package.first_release_file_name) + else "blocked" + ), + evidence_file_name=release_package.first_release_file_name, + source_field="commercial_close_release_package.first_release_file_name", + reviewer_role="buyer diligence lead", + owner_area="data_room_ops", + sla_hours=4, + review_day=1, + entry_criteria_text=( + "Open the verified release package and confirm buyer review scope." + ), + exit_criteria_text=( + "Buyer review starts from the canonical evidence snapshot file." + ), + blocker_keys=( + [] + if release_package.total_artifact_count > 0 + and bool(release_package.first_release_file_name) + else ["release_package_missing"] + ), + contains_raw_content=False, + contains_stable_identifiers=False, + contains_provider_credentials=False, + provider_write_executed=False, + ), + artifact_step( + step_key="buyer_review_snapshot_verification", + review_order=2, + lane="verification", + artifact_key="release_offline_verifier", + source_field="commercial_close_release_package.artifacts.release_offline_verifier", + reviewer_role="verification reviewer", + owner_area="verification", + sla_hours=4, + review_day=1, + entry_criteria_text="Run the offline verifier against copied snapshot JSON.", + exit_criteria_text="Verifier exits successfully before evidence review starts.", + ), + artifact_step( + step_key="buyer_review_privacy_redaction", + review_order=3, + lane="privacy", + artifact_key="release_privacy_policy", + source_field="commercial_close_release_package.artifacts.release_privacy_policy", + reviewer_role="privacy/security reviewer", + owner_area="security_governance", + sla_hours=8, + review_day=1, + entry_criteria_text="Inspect redaction policy before opening data-room files.", + exit_criteria_text="Raw content, stable identifiers, and credentials are absent.", + ), + artifact_step( + step_key="buyer_review_data_room_release", + review_order=4, + lane="data_room", + artifact_key="release_data_room_summary", + source_field="data_room_release_summary.release_status", + reviewer_role="data-room operations reviewer", + owner_area="data_room_ops", + sla_hours=8, + review_day=1, + entry_criteria_text="Confirm buyer data-room artifact readiness.", + exit_criteria_text="All data-room artifacts required for close are ready.", + ), + artifact_step( + step_key="buyer_review_acceptance_checklist", + review_order=5, + lane="data_room", + artifact_key="release_acceptance_checklist", + source_field="diligence_close_acceptance_summary.decision_code", + reviewer_role="buyer diligence reviewer", + owner_area="buyer_diligence", + sla_hours=8, + review_day=2, + entry_criteria_text="Review acceptance checklist against traceability map.", + exit_criteria_text="All close acceptance rows are ready for buyer signoff.", + ), + artifact_step( + step_key="buyer_review_readiness_scorecard", + review_order=6, + lane="commercial", + artifact_key="release_readiness_scorecard", + source_field="commercial_close_readiness_scorecard.status_code", + reviewer_role="commercial diligence reviewer", + owner_area="commercial_diligence", + sla_hours=8, + review_day=2, + entry_criteria_text="Review commercial readiness score and component blockers.", + exit_criteria_text="Commercial readiness scorecard is commercially ready.", + ), + artifact_step( + step_key="buyer_review_execution_plan", + review_order=7, + lane="commercial", + artifact_key="release_execution_plan", + source_field="commercial_close_execution_plan.status_code", + reviewer_role="program manager", + owner_area="program_management", + sla_hours=8, + review_day=2, + entry_criteria_text="Review blocked execution lanes and owner actions.", + exit_criteria_text="Execution plan lanes required for close are ready.", + ), + artifact_step( + step_key="buyer_review_kpi_operating_model", + review_order=8, + lane="commercial", + artifact_key="release_kpi_operating_model", + source_field="commercial_close_kpi_operating_model.status_code", + reviewer_role="commercial diligence reviewer", + owner_area="commercial_diligence", + sla_hours=8, + review_day=2, + entry_criteria_text="Review KPI target coverage and guardrail breaches.", + exit_criteria_text="Operating KPIs meet target review thresholds.", + ), + artifact_step( + step_key="buyer_review_buyer_brief", + review_order=9, + lane="commercial", + artifact_key="release_buyer_brief", + source_field="commercial_close_buyer_brief.status_code", + reviewer_role="commercial diligence reviewer", + owner_area="commercial_diligence", + sla_hours=4, + review_day=3, + entry_criteria_text="Review buyer narrative against evidence basis bullets.", + exit_criteria_text="Buyer brief is ready as the narrative review index.", + ), + artifact_step( + step_key="buyer_review_signoff_matrix", + review_order=10, + lane="signoff", + artifact_key="release_signoff_matrix", + source_field="commercial_close_signoff_matrix.status_code", + reviewer_role="commercial diligence reviewer", + owner_area="commercial_diligence", + sla_hours=4, + review_day=3, + entry_criteria_text="Confirm every required role signoff is ready.", + exit_criteria_text="Commercial close signoff matrix is ready.", + ), + ] + previous_blockers = list( + dict.fromkeys(key for step in steps for key in step.blocker_keys) + ) + release_ready = ( + release_package.status_code == "release_ready" and not previous_blockers + ) + steps.append( + DataCommercialCloseBuyerReviewRunbookStep( + step_key="buyer_review_release_decision", + review_order=11, + lane="release", + status_code="ready" if release_ready else "blocked", + evidence_file_name="commercial-close-release-package.json", + source_field="commercial_close_release_package.status_code", + reviewer_role="buyer diligence lead", + owner_area="buyer_diligence", + sla_hours=4, + review_day=3, + entry_criteria_text="Confirm every buyer review step is ready.", + exit_criteria_text="Approve the release package for buyer handoff.", + blocker_keys=[] if release_ready else previous_blockers[:10], + contains_raw_content=False, + contains_stable_identifiers=False, + contains_provider_credentials=False, + provider_write_executed=False, + ) + ) + blocked_steps = [step for step in steps if step.status_code == "blocked"] + blocker_keys = list( + dict.fromkeys(key for step in blocked_steps for key in step.blocker_keys) + ) + status_code: CommercialCloseBuyerReviewRunbookStatus = ( + "review_ready" if not blocked_steps else "review_blocked" + ) + if blocked_steps: + buyer_handoff_text = ( + f"Buyer review runbook remains blocked for " + f"{release_package.target_contract_label} target review: " + f"{len(blocked_steps)} step(s) need remediation." + ) + next_action_text = ( + "Resolve blocked buyer review steps, regenerate the evidence snapshot, " + "rerun the offline verifier, and reissue the runbook." + ) + else: + buyer_handoff_text = ( + f"Buyer review runbook is ready for " + f"{release_package.target_contract_label} diligence handoff." + ) + next_action_text = ( + "Share the verified runbook with buyer diligence reviewers." + ) + + return DataCommercialCloseBuyerReviewRunbook( + runbook_key="commercial_close_buyer_review_runbook", + target_contract_value_krw=release_package.target_contract_value_krw, + target_contract_label=release_package.target_contract_label, + status_code=status_code, + total_step_count=len(steps), + ready_step_count=len(steps) - len(blocked_steps), + blocked_step_count=len(blocked_steps), + blocker_key_count=len(blocker_keys), + blocked_step_keys=[step.step_key for step in blocked_steps], + blocker_keys=blocker_keys[:10], + first_step_key=steps[0].step_key, + final_decision_step_key=steps[-1].step_key, + verification_command=release_package.verification_command, + buyer_handoff_text=buyer_handoff_text, + next_action_text=next_action_text, + steps=steps, + provider_write_executed=False, + ) + + +def _acquisition_remediation_actions( + quality_checks: list[DataQualityCheck], +) -> list[DataAcquisitionRemediationAction]: + actions: list[DataAcquisitionRemediationAction] = [] + for check in quality_checks: + if check.status_code == "pass" and check.issue_count <= 0: + continue + action = _REMEDIATION_ACTIONS_BY_CHECK_KEY.get(check.check_key) + if action is None: + continue + actions.append( + DataAcquisitionRemediationAction( + blocking_check_key=check.check_key, + provider_write_executed=False, + **action, + ) + ) + return sorted(actions, key=lambda action: action.priority_rank) + + +def _quality_check_completion_percent(check: DataQualityCheck) -> int: + if check.total_count <= 0: + return 0 + passed_count = max(check.total_count - check.issue_count, 0) + return round((passed_count / check.total_count) * 100) + + +def _acquisition_readiness_kpis( + quality_checks: list[DataQualityCheck], +) -> list[DataAcquisitionReadinessKpi]: + kpis: list[DataAcquisitionReadinessKpi] = [] + for check in quality_checks: + target = _ACQUISITION_KPI_TARGETS_BY_CHECK_KEY.get(check.check_key) + if target is None: + continue + current_percent = _quality_check_completion_percent(check) + target_percent = int(target["target_percent"]) + kpis.append( + DataAcquisitionReadinessKpi( + source_check_key=check.check_key, + current_percent=current_percent, + target_met=( + check.status_code == "pass" and current_percent >= target_percent + ), + status_code=check.status_code, + provider_write_executed=False, + **target, + ) + ) + return sorted(kpis, key=lambda kpi: kpi.priority_rank) + + +def _acquisition_decision_summary( + *, + kpis: list[DataAcquisitionReadinessKpi], + remediation_actions: list[DataAcquisitionRemediationAction], + evidence_packet_ready: bool, + snapshot_verification_ready: bool, +) -> DataAcquisitionDecisionSummary: + target_gap_count = sum(1 for kpi in kpis if not kpi.target_met) + critical_action_count = sum( + 1 for action in remediation_actions if action.priority_code == "critical" + ) + high_action_count = sum( + 1 for action in remediation_actions if action.priority_code == "high" + ) + medium_action_count = sum( + 1 for action in remediation_actions if action.priority_code == "medium" + ) + if not evidence_packet_ready or not snapshot_verification_ready: + recommendation_code: DiligenceRecommendation = "insufficient_evidence" risk_level: DiligenceRiskLevel = "high" headline_text = "Evidence is insufficient for buyer diligence." next_step_text = ( @@ -2275,6 +4626,70 @@ def _evidence_snapshot_from_surface( ) } ) + snapshot = snapshot.model_copy( + update={ + "diligence_close_acceptance_checklist": ( + _diligence_close_acceptance_checklist(snapshot) + ) + } + ) + snapshot = snapshot.model_copy( + update={ + "diligence_close_acceptance_summary": ( + _diligence_close_acceptance_summary(snapshot) + ) + } + ) + snapshot = snapshot.model_copy( + update={"data_room_release_summary": _data_room_release_summary(snapshot)} + ) + snapshot = snapshot.model_copy( + update={ + "commercial_close_readiness_scorecard": ( + _commercial_close_readiness_scorecard(snapshot) + ) + } + ) + snapshot = snapshot.model_copy( + update={ + "commercial_close_execution_plan": _commercial_close_execution_plan( + snapshot + ) + } + ) + snapshot = snapshot.model_copy( + update={ + "commercial_close_kpi_operating_model": ( + _commercial_close_kpi_operating_model(snapshot) + ) + } + ) + snapshot = snapshot.model_copy( + update={ + "commercial_close_buyer_brief": _commercial_close_buyer_brief(snapshot) + } + ) + snapshot = snapshot.model_copy( + update={ + "commercial_close_signoff_matrix": ( + _commercial_close_signoff_matrix(snapshot) + ) + } + ) + snapshot = snapshot.model_copy( + update={ + "commercial_close_release_package": ( + _commercial_close_release_package(snapshot) + ) + } + ) + snapshot = snapshot.model_copy( + update={ + "commercial_close_buyer_review_runbook": ( + _commercial_close_buyer_review_runbook(snapshot) + ) + } + ) digest_payload = _snapshot_digest_payload(snapshot) return snapshot.model_copy( update={ diff --git a/backend/tests/test_data_api.py b/backend/tests/test_data_api.py index 2315ac4fd..2b79fde70 100644 --- a/backend/tests/test_data_api.py +++ b/backend/tests/test_data_api.py @@ -1385,6 +1385,1538 @@ def _expected_diligence_close_traceability_map(): return entries +def _expected_diligence_close_acceptance_checklist(): + return [ + { + "acceptance_key": f"accept_{trace['trace_key'].removeprefix('trace_')}", + "trace_key": trace["trace_key"], + "data_room_artifact": trace["data_room_artifact"], + "source_field": trace["source_field"], + "owner_area": trace["owner_area"], + "reviewer_roles": trace["buyer_review_roles"], + "acceptance_status": ( + "blocked" + if trace["close_gate_status"] == "blocked" + else "ready_for_acceptance" + ), + "close_gate_status": trace["close_gate_status"], + "blocker_keys": ( + trace["exception_keys"] + if trace["close_gate_status"] == "blocked" + else [] + ), + "acceptance_criteria": ( + f"Resolve {trace['exception_count']} exception(s), regenerate " + f"{trace['data_room_artifact']} from {trace['source_field']}, and " + "verify the copied snapshot digest before buyer acceptance." + ), + "verification_command": ( + "python scripts/verify_evidence_snapshot.py " + ), + "reviewer_evidence_summary": ( + f"{', '.join(trace['buyer_review_roles'])} review " + f"{trace['data_room_artifact']} for {trace['owner_area']}; " + f"{trace['trace_key']} covers {trace['exception_count']} exception(s)." + ), + "next_action": trace["next_action"], + "snapshot_verification_required": trace["snapshot_verification_required"], + "provider_write_executed": False, + } + for trace in _expected_diligence_close_traceability_map() + ] + + +def _expected_diligence_close_acceptance_summary(): + checklist = _expected_diligence_close_acceptance_checklist() + blocked = [item for item in checklist if item["acceptance_status"] == "blocked"] + ready = [ + item for item in checklist if item["acceptance_status"] == "ready_for_acceptance" + ] + reviewer_roles = sorted( + {role for item in checklist for role in item["reviewer_roles"]} + ) + required_artifacts = sorted({item["data_room_artifact"] for item in checklist}) + blocker_keys = sorted({key for item in blocked for key in item["blocker_keys"]}) + return { + "summary_key": "buyer_close_acceptance", + "decision_code": "close_blocked" if blocked else "ready_to_close", + "total_acceptance_count": len(checklist), + "blocked_acceptance_count": len(blocked), + "ready_acceptance_count": len(ready), + "reviewer_role_count": len(reviewer_roles), + "reviewer_roles": reviewer_roles, + "required_artifact_count": len(required_artifacts), + "required_artifacts": required_artifacts, + "blocker_count": len(blocker_keys), + "blocker_keys": blocker_keys, + "close_gate_status": "blocked" if blocked else "ready", + "snapshot_verification_required": any( + item["snapshot_verification_required"] for item in checklist + ), + "buyer_summary_text": ( + f"Buyer acceptance remains blocked by {len(blocked)} item(s) " + f"across {len(required_artifacts)} artifact(s) and " + f"{len(blocker_keys)} blocker key(s)." + ) + if blocked + else ( + f"Buyer acceptance is ready for {len(ready)} item(s) across " + f"{len(required_artifacts)} artifact(s)." + ), + "next_action_text": ( + "Resolve blocker keys, regenerate the evidence snapshot, run the " + "offline verifier, and reissue the acceptance checklist." + ) + if blocked + else ( + "Share the verified snapshot and acceptance checklist with buyer " + "reviewers." + ), + "provider_write_executed": False, + } + + +def _expected_data_room_release_summary(): + manifest = _expected_data_room_package_manifest() + acceptance_summary = _expected_diligence_close_acceptance_summary() + blocked_artifact_files = sorted( + item["file_name"] for item in manifest if item["state_code"] != "ready" + ) + return { + "release_key": "buyer_data_room_release", + "release_status": "release_blocked", + "total_artifact_count": len(manifest), + "ready_artifact_count": sum( + 1 for item in manifest if item["state_code"] == "ready" + ), + "needs_attention_artifact_count": len(blocked_artifact_files), + "required_for_close_count": sum( + 1 for item in manifest if item["required_for_close"] + ), + "blocked_artifact_files": blocked_artifact_files, + "privacy_exposure_count": 0, + "raw_content_exposure_count": 0, + "stable_identifier_exposure_count": 0, + "provider_credential_exposure_count": 0, + "snapshot_verification_required": True, + "verification_command": ( + "python scripts/verify_evidence_snapshot.py " + ), + "acceptance_blocker_count": acceptance_summary["blocker_count"], + "acceptance_blocker_keys": acceptance_summary["blocker_keys"], + "buyer_summary_text": ( + "Data-room release remains blocked by 3 artifact(s), 9 blocker key(s), " + "and 0 privacy exposure(s)." + ), + "next_action_text": ( + "Resolve blocked artifact states, clear acceptance blockers, run the " + "offline verifier, and reissue the release bundle." + ), + "provider_write_executed": False, + } + + +def _expected_commercial_close_readiness_scorecard(): + release_summary = _expected_data_room_release_summary() + acceptance_summary = _expected_diligence_close_acceptance_summary() + kpi_gap_keys = sorted( + kpi["source_check_key"] + for kpi in _expected_acquisition_readiness_kpis() + if not kpi["target_met"] + ) + category_scores = [ + { + "category_key": "evidence_packet_integrity", + "display_name": "Evidence packet integrity", + "status_code": "needs_attention", + "score": 14, + "max_score": 15, + "detail_text": "9 of 10 evidence packet checks are ready.", + }, + { + "category_key": "data_room_release_integrity", + "display_name": "Data room release integrity", + "status_code": "needs_attention", + "score": 14, + "max_score": 20, + "detail_text": "7 of 10 data-room artifacts are ready.", + }, + { + "category_key": "buyer_acceptance_clearance", + "display_name": "Buyer acceptance clearance", + "status_code": "needs_attention", + "score": 0, + "max_score": 20, + "detail_text": "9 acceptance blocker key(s) remain.", + }, + { + "category_key": "privacy_boundary", + "display_name": "Privacy boundary", + "status_code": "ready", + "score": 20, + "max_score": 20, + "detail_text": "0 privacy exposure(s) remain.", + }, + { + "category_key": "offline_verification", + "display_name": "Offline verification", + "status_code": "ready", + "score": 10, + "max_score": 10, + "detail_text": "Offline verifier contract is ready.", + }, + { + "category_key": "product_kpi_attainment", + "display_name": "Product KPI attainment", + "status_code": "needs_attention", + "score": 4, + "max_score": 15, + "detail_text": "9 KPI target gap(s) remain for buyer review.", + }, + ] + return { + "scorecard_key": "commercial_close_readiness", + "target_contract_value_krw": 2_000_000_000, + "target_contract_label": "2,000,000,000 KRW", + "status_code": "commercially_blocked", + "total_score": 62, + "max_score": 100, + "category_scores": category_scores, + "blocked_artifact_count": release_summary["needs_attention_artifact_count"], + "blocked_artifact_files": release_summary["blocked_artifact_files"], + "acceptance_blocker_count": acceptance_summary["blocker_count"], + "acceptance_blocker_keys": acceptance_summary["blocker_keys"], + "kpi_gap_count": len(kpi_gap_keys), + "kpi_gap_keys": kpi_gap_keys, + "privacy_exposure_count": 0, + "verifier_ready": True, + "release_status": "release_blocked", + "close_gate_status": "blocked", + "buyer_summary_text": ( + "Commercial close remains blocked for 2,000,000,000 KRW target " + "review: score 62/100 with 9 KPI gap(s), 9 acceptance blocker " + "key(s), and 3 blocked data-room artifact(s)." + ), + "next_action_text": ( + "Resolve KPI gaps and acceptance blockers, regenerate the data-room " + "bundle, run the offline verifier, and reissue the buyer scorecard." + ), + "provider_write_executed": False, + } + + +def _expected_commercial_close_execution_plan(): + verification_command = "python scripts/verify_evidence_snapshot.py " + lanes = [ + { + "lane_key": "lane_critical_email_ingestion_acquisition_readiness_summary_json", + "execution_order": 1, + "display_name": ( + "Critical email_ingestion execution for " + "acquisition-readiness-summary.json" + ), + "owner_area": "email_ingestion", + "priority_code": "critical", + "status_code": "blocked", + "related_artifact": "acquisition-readiness-summary.json", + "artifact_ready": False, + "action_count": 2, + "action_keys": [ + "repair_thread_id_integrity", + "backfill_dedupe_fingerprints", + ], + "blocking_check_keys": [ + "thread_id_integrity", + "dedupe_fingerprint", + ], + "acceptance_blocker_keys": [ + "exception_repair_thread_id_integrity", + "exception_backfill_dedupe_fingerprints", + ], + "kpi_gap_keys": [ + "thread_id_integrity", + "dedupe_fingerprint", + ], + "acceptance_criteria": ( + "Resolve 2 action(s), regenerate " + "acquisition-readiness-summary.json, run " + "python scripts/verify_evidence_snapshot.py , and " + "reissue the buyer scorecard." + ), + "verification_command": verification_command, + "next_action_text": ( + "Run canonical threading repair for affected scoped emails. " + "Backfill duplicate-detection fingerprints for scoped email records." + ), + "provider_write_executed": False, + }, + { + "lane_key": "lane_high_attachment_parsing_remediation_actions_json", + "execution_order": 2, + "display_name": ( + "High attachment_parsing execution for remediation-actions.json" + ), + "owner_area": "attachment_parsing", + "priority_code": "high", + "status_code": "blocked", + "related_artifact": "remediation-actions.json", + "artifact_ready": False, + "action_count": 1, + "action_keys": ["recover_attachment_content"], + "blocking_check_keys": ["attachment_content"], + "acceptance_blocker_keys": ["exception_recover_attachment_content"], + "kpi_gap_keys": ["attachment_content"], + "acceptance_criteria": ( + "Resolve 1 action(s), regenerate remediation-actions.json, run " + "python scripts/verify_evidence_snapshot.py , and " + "reissue the buyer scorecard." + ), + "verification_command": verification_command, + "next_action_text": ( + "Re-run attachment extraction for scoped attachments with blank safe " + "content." + ), + "provider_write_executed": False, + }, + { + "lane_key": "lane_high_content_graph_dom_paragraph_evidence_samples_json", + "execution_order": 3, + "display_name": ( + "High content_graph execution for " + "dom-paragraph-evidence-samples.json" + ), + "owner_area": "content_graph", + "priority_code": "high", + "status_code": "blocked", + "related_artifact": "dom-paragraph-evidence-samples.json", + "artifact_ready": True, + "action_count": 2, + "action_keys": [ + "backfill_content_graph_coverage", + "repair_segment_text_readiness", + ], + "blocking_check_keys": [ + "content_graph_coverage", + "content_segment_text_readiness", + ], + "acceptance_blocker_keys": [ + "exception_backfill_content_graph_coverage", + "exception_repair_segment_text_readiness", + ], + "kpi_gap_keys": [ + "content_graph_coverage", + "content_segment_text_readiness", + ], + "acceptance_criteria": ( + "Resolve 2 action(s), regenerate " + "dom-paragraph-evidence-samples.json, run " + "python scripts/verify_evidence_snapshot.py , and " + "reissue the buyer scorecard." + ), + "verification_command": verification_command, + "next_action_text": ( + "Backfill DOM paragraph segmentation for unsegmented scoped emails. " + "Rebuild affected content segments with safe text and word-count " + "evidence." + ), + "provider_write_executed": False, + }, + { + "lane_key": "lane_high_knowledge_graph_knowledge_graph_evidence_samples_json", + "execution_order": 4, + "display_name": ( + "High knowledge_graph execution for " + "knowledge-graph-evidence-samples.json" + ), + "owner_area": "knowledge_graph", + "priority_code": "high", + "status_code": "blocked", + "related_artifact": "knowledge-graph-evidence-samples.json", + "artifact_ready": True, + "action_count": 2, + "action_keys": [ + "backfill_knowledge_graph_coverage", + "attach_kg_evidence_endpoints", + ], + "blocking_check_keys": [ + "knowledge_graph_coverage", + "knowledge_graph_evidence_endpoint_readiness", + ], + "acceptance_blocker_keys": [ + "exception_backfill_knowledge_graph_coverage", + "exception_attach_kg_evidence_endpoints", + ], + "kpi_gap_keys": [ + "knowledge_graph_coverage", + "knowledge_graph_evidence_endpoint_readiness", + ], + "acceptance_criteria": ( + "Resolve 2 action(s), regenerate " + "knowledge-graph-evidence-samples.json, run " + "python scripts/verify_evidence_snapshot.py , and " + "reissue the buyer scorecard." + ), + "verification_command": verification_command, + "next_action_text": ( + "Persist deterministic knowledge graph edges for emails missing graph " + "coverage. Attach source or target paragraph segment endpoints to " + "affected KG edges." + ), + "provider_write_executed": False, + }, + { + "lane_key": "lane_high_semantic_kg_semantic_relation_evidence_samples_json", + "execution_order": 5, + "display_name": ( + "High semantic_kg execution for " + "semantic-relation-evidence-samples.json" + ), + "owner_area": "semantic_kg", + "priority_code": "high", + "status_code": "blocked", + "related_artifact": "semantic-relation-evidence-samples.json", + "artifact_ready": True, + "action_count": 1, + "action_keys": ["backfill_semantic_relation_sources"], + "blocking_check_keys": ["semantic_relation_source_backing"], + "acceptance_blocker_keys": [ + "exception_backfill_semantic_relation_sources" + ], + "kpi_gap_keys": ["semantic_relation_source_backing"], + "acceptance_criteria": ( + "Resolve 1 action(s), regenerate " + "semantic-relation-evidence-samples.json, run " + "python scripts/verify_evidence_snapshot.py , and " + "reissue the buyer scorecard." + ), + "verification_command": verification_command, + "next_action_text": ( + "Backfill source message or thread links for semantic relation records." + ), + "provider_write_executed": False, + }, + { + "lane_key": "lane_medium_attachment_parsing_remediation_actions_json", + "execution_order": 6, + "display_name": ( + "Medium attachment_parsing execution for remediation-actions.json" + ), + "owner_area": "attachment_parsing", + "priority_code": "medium", + "status_code": "blocked", + "related_artifact": "remediation-actions.json", + "artifact_ready": False, + "action_count": 1, + "action_keys": ["expand_attachment_parse_coverage"], + "blocking_check_keys": ["attachment_parse_coverage"], + "acceptance_blocker_keys": ["exception_expand_attachment_parse_coverage"], + "kpi_gap_keys": ["attachment_parse_coverage"], + "acceptance_criteria": ( + "Resolve 1 action(s), regenerate remediation-actions.json, run " + "python scripts/verify_evidence_snapshot.py , and " + "reissue the buyer scorecard." + ), + "verification_command": verification_command, + "next_action_text": ( + "Add parser coverage or metadata-only exception evidence for " + "unsupported attachment types." + ), + "provider_write_executed": False, + }, + ] + return { + "plan_key": "commercial_close_execution_plan", + "target_contract_value_krw": 2_000_000_000, + "target_contract_label": "2,000,000,000 KRW", + "status_code": "execution_blocked", + "total_lane_count": 6, + "blocked_lane_count": 6, + "ready_lane_count": 0, + "critical_lane_count": 1, + "high_lane_count": 4, + "medium_lane_count": 1, + "related_artifact_count": 5, + "related_artifacts": [ + "acquisition-readiness-summary.json", + "dom-paragraph-evidence-samples.json", + "knowledge-graph-evidence-samples.json", + "remediation-actions.json", + "semantic-relation-evidence-samples.json", + ], + "total_action_count": 9, + "kpi_gap_count": 9, + "acceptance_blocker_count": 9, + "verification_command": verification_command, + "buyer_summary_text": ( + "Commercial close execution remains blocked for 2,000,000,000 KRW " + "target review: 6 lane(s), 9 action(s), and 5 artifact(s) require " + "remediation." + ), + "next_action_text": ( + "Execute lanes in priority order, regenerate affected artifacts, run " + "the offline verifier, and reissue the buyer scorecard." + ), + "lanes": lanes, + "provider_write_executed": False, + } + + +def _expected_commercial_close_kpi_operating_model(): + metrics = [ + { + "metric_key": "commercial_close_readiness_score", + "display_name": "Commercial close readiness score", + "metric_kind": "primary", + "status_code": "needs_attention", + "current_value": 62, + "target_value": 100, + "unit_label": "score", + "source_field": "commercial_close_readiness_scorecard.total_score", + "owner_area": "commercial_diligence", + "buyer_implication": ( + "2,000,000,000 KRW review remains blocked until the readiness " + "score reaches 100 and blockers clear." + ), + "next_action_text": ( + "Resolve KPI gaps and acceptance blockers, regenerate the data-room " + "bundle, run the offline verifier, and reissue the buyer scorecard." + ), + "provider_write_executed": False, + }, + { + "metric_key": "execution_lane_clearance", + "display_name": "Execution lane clearance", + "metric_kind": "driver", + "status_code": "needs_attention", + "current_value": 0, + "target_value": 6, + "unit_label": "lane", + "source_field": "commercial_close_execution_plan.ready_lane_count", + "owner_area": "program_management", + "buyer_implication": ( + "Buyer review needs every commercial close execution lane cleared." + ), + "next_action_text": ( + "Execute lanes in priority order, regenerate affected artifacts, run " + "the offline verifier, and reissue the buyer scorecard." + ), + "provider_write_executed": False, + }, + { + "metric_key": "data_room_artifact_readiness", + "display_name": "Data-room artifact readiness", + "metric_kind": "driver", + "status_code": "needs_attention", + "current_value": 7, + "target_value": 10, + "unit_label": "artifact", + "source_field": "data_room_release_summary.ready_artifact_count", + "owner_area": "data_room_ops", + "buyer_implication": ( + "All required data-room artifacts must be ready before buyer release." + ), + "next_action_text": ( + "Resolve blocked artifact states, clear acceptance blockers, run the " + "offline verifier, and reissue the release bundle." + ), + "provider_write_executed": False, + }, + { + "metric_key": "buyer_acceptance_clearance", + "display_name": "Buyer acceptance clearance", + "metric_kind": "driver", + "status_code": "needs_attention", + "current_value": 0, + "target_value": 6, + "unit_label": "acceptance", + "source_field": ( + "diligence_close_acceptance_summary.ready_acceptance_count" + ), + "owner_area": "buyer_diligence", + "buyer_implication": ( + "Buyer acceptance cannot close while acceptance items remain blocked." + ), + "next_action_text": ( + "Resolve blocker keys, regenerate the evidence snapshot, run the " + "offline verifier, and reissue the acceptance checklist." + ), + "provider_write_executed": False, + }, + { + "metric_key": "product_kpi_attainment", + "display_name": "Product KPI attainment", + "metric_kind": "driver", + "status_code": "needs_attention", + "current_value": 3, + "target_value": 12, + "unit_label": "kpi", + "source_field": "acquisition_readiness_gate.kpis", + "owner_area": "data_quality", + "buyer_implication": ( + "Product evidence KPIs must meet target before close readiness " + "can be claimed." + ), + "next_action_text": ( + "Resolve critical and high remediation actions, then regenerate the " + "diligence evidence snapshot." + ), + "provider_write_executed": False, + }, + { + "metric_key": "privacy_exposure_control", + "display_name": "Privacy exposure control", + "metric_kind": "guardrail", + "status_code": "target_met", + "current_value": 0, + "target_value": 0, + "unit_label": "exposure", + "source_field": "data_room_release_summary.privacy_exposure_count", + "owner_area": "privacy_security", + "buyer_implication": ( + "Buyer package must keep raw content, stable IDs, and credentials out." + ), + "next_action_text": "Keep the redaction policy enforced for every snapshot.", + "provider_write_executed": False, + }, + { + "metric_key": "offline_verifier_contract", + "display_name": "Offline verifier contract", + "metric_kind": "guardrail", + "status_code": "target_met", + "current_value": 1, + "target_value": 1, + "unit_label": "contract", + "source_field": "verification_handoff.verifier_command", + "owner_area": "verification", + "buyer_implication": ( + "Buyer reviewers need a repeatable offline verifier for copied JSON." + ), + "next_action_text": ( + "Save the copied evidence snapshot JSON and verify it with the " + "offline verifier before sharing diligence materials." + ), + "provider_write_executed": False, + }, + { + "metric_key": "provider_write_boundary", + "display_name": "Provider write boundary", + "metric_kind": "guardrail", + "status_code": "target_met", + "current_value": 0, + "target_value": 0, + "unit_label": "write", + "source_field": "provider_write_executed", + "owner_area": "security_governance", + "buyer_implication": ( + "Diligence evidence must remain read-only until explicit provider " + "write approval." + ), + "next_action_text": "Keep buyer evidence generation read-only.", + "provider_write_executed": False, + }, + ] + return { + "model_key": "commercial_close_kpi_operating_model", + "target_contract_value_krw": 2_000_000_000, + "target_contract_label": "2,000,000,000 KRW", + "status_code": "operating_blocked", + "primary_metric_key": "commercial_close_readiness_score", + "total_metric_count": 8, + "target_met_metric_count": 3, + "needs_attention_metric_count": 5, + "primary_metric_count": 1, + "driver_metric_count": 4, + "guardrail_metric_count": 3, + "blocked_metric_keys": [ + "commercial_close_readiness_score", + "execution_lane_clearance", + "data_room_artifact_readiness", + "buyer_acceptance_clearance", + "product_kpi_attainment", + ], + "guardrail_breach_count": 0, + "buyer_summary_text": ( + "Commercial close KPI operating model remains blocked for " + "2,000,000,000 KRW target review: 5 of 8 metric(s) need attention " + "and 0 guardrail breach(es) remain." + ), + "next_action_text": ( + "Use the blocked KPI list to sequence execution lanes, regenerate " + "artifacts, rerun verification, and reissue the buyer scorecard." + ), + "metrics": metrics, + "provider_write_executed": False, + } + + +def _expected_commercial_close_buyer_brief(): + return { + "brief_key": "commercial_close_buyer_brief", + "target_contract_value_krw": 2_000_000_000, + "target_contract_label": "2,000,000,000 KRW", + "status_code": "brief_blocked", + "readiness_headline_text": ( + "Commercial close remains blocked: readiness score 62/100, 5 KPI " + "operating metric(s), 6 execution lane(s), and 9 exception(s) require " + "attention." + ), + "proof_thesis_text": ( + "Naruon can package redacted DOM, paragraph, knowledge-graph, semantic " + "relation, data-room, KPI, and offline verifier evidence for buyer review " + "without exposing raw content, stable IDs, provider credentials, or " + "provider writes." + ), + "evidence_basis_bullets": [ + { + "bullet_key": "buyer_brief_readiness_score", + "display_name": "Commercial readiness score", + "source_field": "commercial_close_readiness_scorecard.total_score", + "detail_text": ( + "Commercial readiness is 62/100 for 2,000,000,000 KRW target " + "review; status is commercially_blocked." + ), + "provider_write_executed": False, + }, + { + "bullet_key": "buyer_brief_data_room_release", + "display_name": "Data-room release", + "source_field": "data_room_release_summary.ready_artifact_count", + "detail_text": ( + "Data-room release has 7/10 artifact(s) ready and 3 blocked " + "artifact(s)." + ), + "provider_write_executed": False, + }, + { + "bullet_key": "buyer_brief_acceptance_clearance", + "display_name": "Buyer acceptance clearance", + "source_field": ( + "diligence_close_acceptance_summary.ready_acceptance_count" + ), + "detail_text": ( + "Buyer acceptance has 0/6 acceptance item(s) ready with 9 " + "blocker key(s)." + ), + "provider_write_executed": False, + }, + { + "bullet_key": "buyer_brief_kpi_operating_model", + "display_name": "KPI operating model", + "source_field": ( + "commercial_close_kpi_operating_model.target_met_metric_count" + ), + "detail_text": ( + "KPI operating model has 3/8 metric(s) at target and 0 " + "guardrail breach(es)." + ), + "provider_write_executed": False, + }, + { + "bullet_key": "buyer_brief_offline_verifier", + "display_name": "Offline verifier", + "source_field": "verification_handoff.verifier_command", + "detail_text": ( + "Copied snapshot JSON can be verified with python " + "scripts/verify_evidence_snapshot.py ." + ), + "provider_write_executed": False, + }, + ], + "blocker_bullets": [ + { + "bullet_key": "buyer_brief_blocker_exception_repair_thread_id_integrity", + "display_name": "Canonical thread repair", + "source_field": "quality_checks.thread_id_integrity", + "detail_text": ( + "critical blocker owned by email_ingestion for " + "acquisition-readiness-summary.json: Run canonical threading " + "repair for affected scoped emails." + ), + "provider_write_executed": False, + }, + { + "bullet_key": ( + "buyer_brief_blocker_exception_backfill_dedupe_fingerprints" + ), + "display_name": "Duplicate fingerprint backfill", + "source_field": "quality_checks.dedupe_fingerprint", + "detail_text": ( + "critical blocker owned by email_ingestion for " + "acquisition-readiness-summary.json: Backfill " + "duplicate-detection fingerprints for scoped email records." + ), + "provider_write_executed": False, + }, + { + "bullet_key": "buyer_brief_blocker_exception_recover_attachment_content", + "display_name": "Attachment content extraction", + "source_field": "quality_checks.attachment_content", + "detail_text": ( + "high blocker owned by attachment_parsing for " + "remediation-actions.json: Re-run attachment extraction for scoped " + "attachments with blank safe content." + ), + "provider_write_executed": False, + }, + { + "bullet_key": ( + "buyer_brief_blocker_exception_backfill_content_graph_coverage" + ), + "display_name": "DOM paragraph segmentation backfill", + "source_field": "quality_checks.content_graph_coverage", + "detail_text": ( + "high blocker owned by content_graph for " + "dom-paragraph-evidence-samples.json: Backfill DOM paragraph " + "segmentation for unsegmented scoped emails." + ), + "provider_write_executed": False, + }, + { + "bullet_key": ( + "buyer_brief_blocker_exception_backfill_knowledge_graph_coverage" + ), + "display_name": "Knowledge graph edge persistence", + "source_field": "quality_checks.knowledge_graph_coverage", + "detail_text": ( + "high blocker owned by knowledge_graph for " + "knowledge-graph-evidence-samples.json: Persist deterministic " + "knowledge graph edges for emails missing graph coverage." + ), + "provider_write_executed": False, + }, + ], + "guardrail_bullets": [ + { + "bullet_key": "buyer_brief_privacy_redaction", + "display_name": "Privacy redaction", + "source_field": "privacy_redaction_policy", + "detail_text": ( + "Privacy policy exposes raw content: no, stable IDs: no, " + "provider credentials: no." + ), + "provider_write_executed": False, + }, + { + "bullet_key": "buyer_brief_data_room_exposure", + "display_name": "Data-room exposure controls", + "source_field": "data_room_release_summary.privacy_exposure_count", + "detail_text": ( + "Data-room summary reports 0 privacy exposure(s), 0 raw content " + "exposure(s), 0 stable ID exposure(s), and 0 credential " + "exposure(s)." + ), + "provider_write_executed": False, + }, + { + "bullet_key": "buyer_brief_provider_write_boundary", + "display_name": "Provider write boundary", + "source_field": "provider_write_executed", + "detail_text": ( + "Provider write execution count is 0; buyer evidence generation " + "remains read-only." + ), + "provider_write_executed": False, + }, + { + "bullet_key": "buyer_brief_snapshot_verifier", + "display_name": "Snapshot verifier", + "source_field": "verification_handoff", + "detail_text": ( + "Snapshot verification is required: yes; command python " + "scripts/verify_evidence_snapshot.py ." + ), + "provider_write_executed": False, + }, + ], + "reviewer_handoff_text": ( + "Buyer reviewers should start from commercial_close_buyer_brief, verify " + "copied JSON with python scripts/verify_evidence_snapshot.py " + ", then review 5 blocker bullet(s) before release." + ), + "next_action_text": ( + "Resolve top blocker bullets, rerun parser and graph remediation, " + "regenerate the snapshot, rerun the offline verifier, and reissue the " + "buyer brief." + ), + "provider_write_executed": False, + } + + +def _expected_commercial_close_signoff_matrix(): + buyer_brief = _expected_commercial_close_buyer_brief() + scorecard = _expected_commercial_close_readiness_scorecard() + execution_plan = _expected_commercial_close_execution_plan() + release_summary = _expected_data_room_release_summary() + acceptance_summary = _expected_diligence_close_acceptance_summary() + verifier_command = "python scripts/verify_evidence_snapshot.py " + signoffs = [ + { + "signoff_key": "signoff_commercial_diligence", + "reviewer_role": "commercial diligence reviewer", + "owner_area": "commercial_diligence", + "status_code": "blocked", + "source_field": "commercial_close_buyer_brief.status_code", + "required_artifact": "commercial-close-buyer-brief.json", + "blocker_keys": [ + bullet["bullet_key"] for bullet in buyer_brief["blocker_bullets"][:5] + ], + "acceptance_text": ( + "Buyer brief is accepted when status is brief_ready and top " + "blocker bullets are cleared." + ), + "next_action_text": buyer_brief["next_action_text"], + "provider_write_executed": False, + }, + { + "signoff_key": "signoff_program_management", + "reviewer_role": "program manager", + "owner_area": "program_management", + "status_code": "blocked", + "source_field": "commercial_close_execution_plan.status_code", + "required_artifact": "commercial-close-execution-plan.json", + "blocker_keys": [ + lane["lane_key"] + for lane in execution_plan["lanes"] + if lane["status_code"] != "ready" + ][:5], + "acceptance_text": ( + "Execution plan is accepted when every lane is ready and the " + "plan status is execution_ready." + ), + "next_action_text": execution_plan["next_action_text"], + "provider_write_executed": False, + }, + { + "signoff_key": "signoff_data_room_ops", + "reviewer_role": "data-room operations reviewer", + "owner_area": "data_room_ops", + "status_code": "blocked", + "source_field": "data_room_release_summary.release_status", + "required_artifact": "buyer-data-room-release.json", + "blocker_keys": release_summary["blocked_artifact_files"][:5], + "acceptance_text": ( + "Data-room release is accepted when release_status is " + "release_ready and all required artifacts are ready." + ), + "next_action_text": release_summary["next_action_text"], + "provider_write_executed": False, + }, + { + "signoff_key": "signoff_buyer_diligence", + "reviewer_role": "buyer diligence reviewer", + "owner_area": "buyer_diligence", + "status_code": "blocked", + "source_field": "diligence_close_acceptance_summary.decision_code", + "required_artifact": "buyer-acceptance-checklist.json", + "blocker_keys": acceptance_summary["blocker_keys"][:5], + "acceptance_text": ( + "Buyer diligence is accepted when decision_code is ready_to_close " + "and no acceptance blocker keys remain." + ), + "next_action_text": acceptance_summary["next_action_text"], + "provider_write_executed": False, + }, + { + "signoff_key": "signoff_privacy_security", + "reviewer_role": "privacy/security reviewer", + "owner_area": "privacy_security", + "status_code": "signed_off", + "source_field": "privacy_redaction_policy", + "required_artifact": "redacted-snapshot-policy.json", + "blocker_keys": [], + "acceptance_text": ( + "Privacy guardrail is accepted when raw content, stable IDs, " + "credentials, and data-room privacy exposures are zero." + ), + "next_action_text": ( + "Keep redaction guardrails enforced before buyer release." + ), + "provider_write_executed": False, + }, + { + "signoff_key": "signoff_verification", + "reviewer_role": "verification reviewer", + "owner_area": "verification", + "status_code": "signed_off", + "source_field": "verification_handoff.verifier_command", + "required_artifact": "verify-evidence-snapshot.py", + "blocker_keys": [], + "acceptance_text": ( + "Verification is accepted when the offline verifier command and " + "snapshot verification requirement are present." + ), + "next_action_text": f"Save copied snapshot JSON and run {verifier_command}.", + "provider_write_executed": False, + }, + { + "signoff_key": "signoff_security_governance", + "reviewer_role": "security governance reviewer", + "owner_area": "security_governance", + "status_code": "signed_off", + "source_field": "provider_write_executed", + "required_artifact": "read-only-evidence-boundary", + "blocker_keys": [], + "acceptance_text": ( + "Security governance is accepted when provider_write_executed is " + "false across the buyer evidence snapshot." + ), + "next_action_text": ( + "Keep provider write execution disabled until explicit approval." + ), + "provider_write_executed": False, + }, + ] + blocked = [item for item in signoffs if item["status_code"] == "blocked"] + blocker_keys = list( + dict.fromkeys(key for item in blocked for key in item["blocker_keys"]) + ) + return { + "matrix_key": "commercial_close_signoff_matrix", + "target_contract_value_krw": scorecard["target_contract_value_krw"], + "target_contract_label": scorecard["target_contract_label"], + "status_code": "signoff_blocked", + "required_signoff_count": 7, + "signed_off_count": 3, + "blocked_signoff_count": 4, + "blocker_key_count": len(blocker_keys), + "blocker_keys": blocker_keys[:8], + "guardrail_summary_text": ( + "Privacy, offline verification, and provider write guardrails are " + "signed off; 4 role signoff(s) remain blocked." + ), + "reviewer_handoff_text": ( + "Route blocked signoffs to commercial diligence reviewer, program " + "manager, data-room operations reviewer, buyer diligence reviewer " + "before buyer release." + ), + "next_action_text": ( + "Resolve blocked signoff rows, regenerate the evidence snapshot, rerun " + "the offline verifier, and reissue the signoff matrix." + ), + "signoffs": signoffs, + "provider_write_executed": False, + } + + +def _expected_commercial_close_release_package(): + release_summary = _expected_data_room_release_summary() + acceptance_summary = _expected_diligence_close_acceptance_summary() + scorecard = _expected_commercial_close_readiness_scorecard() + execution_plan = _expected_commercial_close_execution_plan() + kpi_model = _expected_commercial_close_kpi_operating_model() + buyer_brief = _expected_commercial_close_buyer_brief() + signoff_matrix = _expected_commercial_close_signoff_matrix() + verifier_command = "python scripts/verify_evidence_snapshot.py " + artifacts = [ + { + "artifact_key": "release_evidence_snapshot", + "release_order": 1, + "file_name": "naruon-evidence-snapshot.json", + "display_name": "Canonical evidence snapshot", + "artifact_group": "core_evidence", + "status_code": "ready", + "source_field": "snapshot_version,snapshot_digest,canonical_payload_fields", + "required_artifact": "naruon-evidence-snapshot.json", + "reviewer_role": "buyer diligence reviewer", + "blocker_keys": [], + "release_instruction_text": ( + "Start buyer review from the canonical redacted snapshot JSON." + ), + "contains_raw_content": False, + "contains_stable_identifiers": False, + "contains_provider_credentials": False, + "provider_write_executed": False, + }, + { + "artifact_key": "release_privacy_policy", + "release_order": 2, + "file_name": "privacy-redaction-policy.json", + "display_name": "Privacy redaction policy", + "artifact_group": "guardrail", + "status_code": "ready", + "source_field": "privacy_redaction_policy", + "required_artifact": "privacy-redaction-policy.json", + "reviewer_role": "privacy/security reviewer", + "blocker_keys": [], + "release_instruction_text": ( + "Confirm raw content, stable identifiers, and credentials are absent." + ), + "contains_raw_content": False, + "contains_stable_identifiers": False, + "contains_provider_credentials": False, + "provider_write_executed": False, + }, + { + "artifact_key": "release_offline_verifier", + "release_order": 3, + "file_name": "verify-evidence-snapshot.py", + "display_name": "Offline evidence verifier", + "artifact_group": "guardrail", + "status_code": "ready", + "source_field": "verification_handoff.verifier_command", + "required_artifact": "verify-evidence-snapshot.py", + "reviewer_role": "verification reviewer", + "blocker_keys": [], + "release_instruction_text": ( + "Run the verifier against copied snapshot JSON before sharing." + ), + "contains_raw_content": False, + "contains_stable_identifiers": False, + "contains_provider_credentials": False, + "provider_write_executed": False, + }, + { + "artifact_key": "release_data_room_summary", + "release_order": 4, + "file_name": "buyer-data-room-release.json", + "display_name": "Buyer data-room release summary", + "artifact_group": "buyer_diligence", + "status_code": "blocked", + "source_field": "data_room_release_summary.release_status", + "required_artifact": "buyer-data-room-release.json", + "reviewer_role": "data-room operations reviewer", + "blocker_keys": release_summary["blocked_artifact_files"][:5], + "release_instruction_text": ( + "Confirm all buyer data-room artifacts are ready for close." + ), + "contains_raw_content": False, + "contains_stable_identifiers": False, + "contains_provider_credentials": False, + "provider_write_executed": False, + }, + { + "artifact_key": "release_acceptance_checklist", + "release_order": 5, + "file_name": "buyer-acceptance-checklist.json", + "display_name": "Buyer acceptance checklist", + "artifact_group": "buyer_diligence", + "status_code": "blocked", + "source_field": "diligence_close_acceptance_summary.decision_code", + "required_artifact": "buyer-acceptance-checklist.json", + "reviewer_role": "buyer diligence reviewer", + "blocker_keys": acceptance_summary["blocker_keys"][:5], + "release_instruction_text": ( + "Resolve acceptance blockers before buyer close acceptance." + ), + "contains_raw_content": False, + "contains_stable_identifiers": False, + "contains_provider_credentials": False, + "provider_write_executed": False, + }, + { + "artifact_key": "release_readiness_scorecard", + "release_order": 6, + "file_name": "commercial-close-readiness-scorecard.json", + "display_name": "Commercial close readiness scorecard", + "artifact_group": "commercial_close", + "status_code": "blocked", + "source_field": "commercial_close_readiness_scorecard.status_code", + "required_artifact": "commercial-close-readiness-scorecard.json", + "reviewer_role": "commercial diligence reviewer", + "blocker_keys": ( + scorecard["kpi_gap_keys"] + + scorecard["acceptance_blocker_keys"] + + scorecard["blocked_artifact_files"] + )[:5], + "release_instruction_text": ( + "Review readiness score and blocker clearance for target review." + ), + "contains_raw_content": False, + "contains_stable_identifiers": False, + "contains_provider_credentials": False, + "provider_write_executed": False, + }, + { + "artifact_key": "release_execution_plan", + "release_order": 7, + "file_name": "commercial-close-execution-plan.json", + "display_name": "Commercial close execution plan", + "artifact_group": "commercial_close", + "status_code": "blocked", + "source_field": "commercial_close_execution_plan.status_code", + "required_artifact": "commercial-close-execution-plan.json", + "reviewer_role": "program manager", + "blocker_keys": [ + lane["lane_key"] + for lane in execution_plan["lanes"] + if lane["status_code"] != "ready" + ][:5], + "release_instruction_text": ( + "Execute blocked lanes before reissuing the commercial package." + ), + "contains_raw_content": False, + "contains_stable_identifiers": False, + "contains_provider_credentials": False, + "provider_write_executed": False, + }, + { + "artifact_key": "release_kpi_operating_model", + "release_order": 8, + "file_name": "commercial-close-kpi-operating-model.json", + "display_name": "Commercial close KPI operating model", + "artifact_group": "commercial_close", + "status_code": "blocked", + "source_field": "commercial_close_kpi_operating_model.status_code", + "required_artifact": "commercial-close-kpi-operating-model.json", + "reviewer_role": "commercial diligence reviewer", + "blocker_keys": kpi_model["blocked_metric_keys"][:5], + "release_instruction_text": ( + "Verify all operating KPIs hit target before buyer package release." + ), + "contains_raw_content": False, + "contains_stable_identifiers": False, + "contains_provider_credentials": False, + "provider_write_executed": False, + }, + { + "artifact_key": "release_buyer_brief", + "release_order": 9, + "file_name": "commercial-close-buyer-brief.json", + "display_name": "Commercial close buyer brief", + "artifact_group": "commercial_close", + "status_code": "blocked", + "source_field": "commercial_close_buyer_brief.status_code", + "required_artifact": "commercial-close-buyer-brief.json", + "reviewer_role": "commercial diligence reviewer", + "blocker_keys": [ + bullet["bullet_key"] for bullet in buyer_brief["blocker_bullets"][:5] + ], + "release_instruction_text": ( + "Use the buyer brief as the narrative index for close reviewers." + ), + "contains_raw_content": False, + "contains_stable_identifiers": False, + "contains_provider_credentials": False, + "provider_write_executed": False, + }, + { + "artifact_key": "release_signoff_matrix", + "release_order": 10, + "file_name": "commercial-close-signoff-matrix.json", + "display_name": "Commercial close signoff matrix", + "artifact_group": "commercial_close", + "status_code": "blocked", + "source_field": "commercial_close_signoff_matrix.status_code", + "required_artifact": "commercial-close-signoff-matrix.json", + "reviewer_role": "commercial diligence reviewer", + "blocker_keys": signoff_matrix["blocker_keys"][:5], + "release_instruction_text": ( + "Confirm role signoffs before issuing the buyer release package." + ), + "contains_raw_content": False, + "contains_stable_identifiers": False, + "contains_provider_credentials": False, + "provider_write_executed": False, + }, + ] + blocked = [item for item in artifacts if item["status_code"] == "blocked"] + blocker_keys = list( + dict.fromkeys(key for item in blocked for key in item["blocker_keys"]) + ) + return { + "package_key": "commercial_close_release_package", + "target_contract_value_krw": 2_000_000_000, + "target_contract_label": "2,000,000,000 KRW", + "status_code": "release_blocked", + "total_artifact_count": 10, + "ready_artifact_count": 3, + "blocked_artifact_count": 7, + "signed_off_count": signoff_matrix["signed_off_count"], + "blocked_signoff_count": signoff_matrix["blocked_signoff_count"], + "blocker_key_count": len(blocker_keys), + "blocked_artifact_files": [item["file_name"] for item in blocked], + "blocker_keys": blocker_keys[:10], + "first_release_file_name": "naruon-evidence-snapshot.json", + "verification_command": verifier_command, + "buyer_handoff_text": ( + "Commercial close release package remains blocked for 2,000,000,000 " + "KRW target review: 7 artifact(s) need remediation." + ), + "next_action_text": ( + "Resolve blocked release artifacts, regenerate the evidence snapshot, " + "rerun the offline verifier, and reissue the release package." + ), + "artifacts": artifacts, + "provider_write_executed": False, + } + + +def _expected_commercial_close_buyer_review_runbook(): + release_package = _expected_commercial_close_release_package() + artifact_by_key = { + artifact["artifact_key"]: artifact for artifact in release_package["artifacts"] + } + + def artifact_step( + *, + step_key, + review_order, + lane, + artifact_key, + source_field, + reviewer_role, + owner_area, + sla_hours, + review_day, + entry_criteria_text, + exit_criteria_text, + ): + artifact = artifact_by_key.get(artifact_key) + ready = artifact is not None and artifact["status_code"] == "ready" + if artifact is None: + evidence_file_name = "" + blocker_keys = [f"{artifact_key}_missing"] + else: + evidence_file_name = artifact["file_name"] + blocker_keys = artifact["blocker_keys"] + return { + "step_key": step_key, + "review_order": review_order, + "lane": lane, + "status_code": "ready" if ready else "blocked", + "evidence_file_name": evidence_file_name, + "source_field": source_field, + "reviewer_role": reviewer_role, + "owner_area": owner_area, + "sla_hours": sla_hours, + "review_day": review_day, + "entry_criteria_text": entry_criteria_text, + "exit_criteria_text": exit_criteria_text, + "blocker_keys": [] if ready else blocker_keys, + "contains_raw_content": False, + "contains_stable_identifiers": False, + "contains_provider_credentials": False, + "provider_write_executed": False, + } + + intake_ready = ( + release_package["total_artifact_count"] > 0 + and bool(release_package["first_release_file_name"]) + ) + steps = [ + { + "step_key": "buyer_review_intake", + "review_order": 1, + "lane": "intake", + "status_code": "ready" if intake_ready else "blocked", + "evidence_file_name": release_package["first_release_file_name"], + "source_field": "commercial_close_release_package.first_release_file_name", + "reviewer_role": "buyer diligence lead", + "owner_area": "data_room_ops", + "sla_hours": 4, + "review_day": 1, + "entry_criteria_text": ( + "Open the verified release package and confirm buyer review scope." + ), + "exit_criteria_text": ( + "Buyer review starts from the canonical evidence snapshot file." + ), + "blocker_keys": [] if intake_ready else ["release_package_missing"], + "contains_raw_content": False, + "contains_stable_identifiers": False, + "contains_provider_credentials": False, + "provider_write_executed": False, + }, + artifact_step( + step_key="buyer_review_snapshot_verification", + review_order=2, + lane="verification", + artifact_key="release_offline_verifier", + source_field=( + "commercial_close_release_package.artifacts.release_offline_verifier" + ), + reviewer_role="verification reviewer", + owner_area="verification", + sla_hours=4, + review_day=1, + entry_criteria_text=( + "Run the offline verifier against copied snapshot JSON." + ), + exit_criteria_text=( + "Verifier exits successfully before evidence review starts." + ), + ), + artifact_step( + step_key="buyer_review_privacy_redaction", + review_order=3, + lane="privacy", + artifact_key="release_privacy_policy", + source_field=( + "commercial_close_release_package.artifacts.release_privacy_policy" + ), + reviewer_role="privacy/security reviewer", + owner_area="security_governance", + sla_hours=8, + review_day=1, + entry_criteria_text=( + "Inspect redaction policy before opening data-room files." + ), + exit_criteria_text=( + "Raw content, stable identifiers, and credentials are absent." + ), + ), + artifact_step( + step_key="buyer_review_data_room_release", + review_order=4, + lane="data_room", + artifact_key="release_data_room_summary", + source_field="data_room_release_summary.release_status", + reviewer_role="data-room operations reviewer", + owner_area="data_room_ops", + sla_hours=8, + review_day=1, + entry_criteria_text="Confirm buyer data-room artifact readiness.", + exit_criteria_text=( + "All data-room artifacts required for close are ready." + ), + ), + artifact_step( + step_key="buyer_review_acceptance_checklist", + review_order=5, + lane="data_room", + artifact_key="release_acceptance_checklist", + source_field="diligence_close_acceptance_summary.decision_code", + reviewer_role="buyer diligence reviewer", + owner_area="buyer_diligence", + sla_hours=8, + review_day=2, + entry_criteria_text="Review acceptance checklist against traceability map.", + exit_criteria_text=( + "All close acceptance rows are ready for buyer signoff." + ), + ), + artifact_step( + step_key="buyer_review_readiness_scorecard", + review_order=6, + lane="commercial", + artifact_key="release_readiness_scorecard", + source_field="commercial_close_readiness_scorecard.status_code", + reviewer_role="commercial diligence reviewer", + owner_area="commercial_diligence", + sla_hours=8, + review_day=2, + entry_criteria_text=( + "Review commercial readiness score and component blockers." + ), + exit_criteria_text=( + "Commercial readiness scorecard is commercially ready." + ), + ), + artifact_step( + step_key="buyer_review_execution_plan", + review_order=7, + lane="commercial", + artifact_key="release_execution_plan", + source_field="commercial_close_execution_plan.status_code", + reviewer_role="program manager", + owner_area="program_management", + sla_hours=8, + review_day=2, + entry_criteria_text="Review blocked execution lanes and owner actions.", + exit_criteria_text="Execution plan lanes required for close are ready.", + ), + artifact_step( + step_key="buyer_review_kpi_operating_model", + review_order=8, + lane="commercial", + artifact_key="release_kpi_operating_model", + source_field="commercial_close_kpi_operating_model.status_code", + reviewer_role="commercial diligence reviewer", + owner_area="commercial_diligence", + sla_hours=8, + review_day=2, + entry_criteria_text="Review KPI target coverage and guardrail breaches.", + exit_criteria_text="Operating KPIs meet target review thresholds.", + ), + artifact_step( + step_key="buyer_review_buyer_brief", + review_order=9, + lane="commercial", + artifact_key="release_buyer_brief", + source_field="commercial_close_buyer_brief.status_code", + reviewer_role="commercial diligence reviewer", + owner_area="commercial_diligence", + sla_hours=4, + review_day=3, + entry_criteria_text=( + "Review buyer narrative against evidence basis bullets." + ), + exit_criteria_text=( + "Buyer brief is ready as the narrative review index." + ), + ), + artifact_step( + step_key="buyer_review_signoff_matrix", + review_order=10, + lane="signoff", + artifact_key="release_signoff_matrix", + source_field="commercial_close_signoff_matrix.status_code", + reviewer_role="commercial diligence reviewer", + owner_area="commercial_diligence", + sla_hours=4, + review_day=3, + entry_criteria_text="Confirm every required role signoff is ready.", + exit_criteria_text="Commercial close signoff matrix is ready.", + ), + ] + previous_blockers = list( + dict.fromkeys(key for step in steps for key in step["blocker_keys"]) + ) + release_ready = ( + release_package["status_code"] == "release_ready" and not previous_blockers + ) + steps.append( + { + "step_key": "buyer_review_release_decision", + "review_order": 11, + "lane": "release", + "status_code": "ready" if release_ready else "blocked", + "evidence_file_name": "commercial-close-release-package.json", + "source_field": "commercial_close_release_package.status_code", + "reviewer_role": "buyer diligence lead", + "owner_area": "buyer_diligence", + "sla_hours": 4, + "review_day": 3, + "entry_criteria_text": "Confirm every buyer review step is ready.", + "exit_criteria_text": "Approve the release package for buyer handoff.", + "blocker_keys": [] if release_ready else previous_blockers[:10], + "contains_raw_content": False, + "contains_stable_identifiers": False, + "contains_provider_credentials": False, + "provider_write_executed": False, + } + ) + blocked = [item for item in steps if item["status_code"] == "blocked"] + blocker_keys = list( + dict.fromkeys(key for item in blocked for key in item["blocker_keys"]) + ) + return { + "runbook_key": "commercial_close_buyer_review_runbook", + "target_contract_value_krw": 2_000_000_000, + "target_contract_label": "2,000,000,000 KRW", + "status_code": "review_blocked", + "total_step_count": 11, + "ready_step_count": 3, + "blocked_step_count": 8, + "blocker_key_count": len(blocker_keys), + "blocked_step_keys": [item["step_key"] for item in blocked], + "blocker_keys": blocker_keys[:10], + "first_step_key": "buyer_review_intake", + "final_decision_step_key": "buyer_review_release_decision", + "verification_command": release_package["verification_command"], + "buyer_handoff_text": ( + "Buyer review runbook remains blocked for 2,000,000,000 KRW target " + "review: 8 step(s) need remediation." + ), + "next_action_text": ( + "Resolve blocked buyer review steps, regenerate the evidence snapshot, " + "rerun the offline verifier, and reissue the runbook." + ), + "steps": steps, + "provider_write_executed": False, + } + + def _expected_acquisition_remediation_actions(): return [ { @@ -1943,6 +3475,48 @@ def test_data_quality_evidence_snapshot_returns_shareable_redacted_surface(mock_ assert snapshot["evidence_packet_checklist"] == _expected_evidence_packet_checklist() assert "data_room_package_manifest" in snapshot["canonical_payload_fields"] assert snapshot["data_room_package_manifest"] == _expected_data_room_package_manifest() + assert "data_room_release_summary" in snapshot["canonical_payload_fields"] + assert snapshot["data_room_release_summary"] == _expected_data_room_release_summary() + assert "commercial_close_readiness_scorecard" in ( + snapshot["canonical_payload_fields"] + ) + assert ( + snapshot["commercial_close_readiness_scorecard"] + == _expected_commercial_close_readiness_scorecard() + ) + assert "commercial_close_execution_plan" in snapshot["canonical_payload_fields"] + assert ( + snapshot["commercial_close_execution_plan"] + == _expected_commercial_close_execution_plan() + ) + assert "commercial_close_kpi_operating_model" in snapshot["canonical_payload_fields"] + assert ( + snapshot["commercial_close_kpi_operating_model"] + == _expected_commercial_close_kpi_operating_model() + ) + assert "commercial_close_buyer_brief" in snapshot["canonical_payload_fields"] + assert ( + snapshot["commercial_close_buyer_brief"] + == _expected_commercial_close_buyer_brief() + ) + assert "commercial_close_signoff_matrix" in snapshot["canonical_payload_fields"] + assert ( + snapshot["commercial_close_signoff_matrix"] + == _expected_commercial_close_signoff_matrix() + ) + assert "commercial_close_release_package" in snapshot["canonical_payload_fields"] + assert ( + snapshot["commercial_close_release_package"] + == _expected_commercial_close_release_package() + ) + assert ( + "commercial_close_buyer_review_runbook" + in snapshot["canonical_payload_fields"] + ) + assert ( + snapshot["commercial_close_buyer_review_runbook"] + == _expected_commercial_close_buyer_review_runbook() + ) assert "diligence_exception_register" in snapshot["canonical_payload_fields"] assert ( snapshot["diligence_exception_register"] @@ -1981,6 +3555,20 @@ def test_data_quality_evidence_snapshot_returns_shareable_redacted_surface(mock_ snapshot["diligence_close_traceability_map"] == _expected_diligence_close_traceability_map() ) + assert "diligence_close_acceptance_checklist" in ( + snapshot["canonical_payload_fields"] + ) + assert ( + snapshot["diligence_close_acceptance_checklist"] + == _expected_diligence_close_acceptance_checklist() + ) + assert "diligence_close_acceptance_summary" in ( + snapshot["canonical_payload_fields"] + ) + assert ( + snapshot["diligence_close_acceptance_summary"] + == _expected_diligence_close_acceptance_summary() + ) for forbidden_field in ( "snapshot_digest", "digest_algorithm", @@ -2318,6 +3906,142 @@ def test_data_quality_evidence_snapshot_returns_shareable_redacted_surface(mock_ assert all( item["provider_write_executed"] is False for item in traceability_map ) + acceptance_checklist = snapshot["diligence_close_acceptance_checklist"] + assert len(acceptance_checklist) == 6 + assert acceptance_checklist[0] == { + "acceptance_key": "accept_risk_critical_email_ingestion_acquisition_readiness_summary_json", + "trace_key": "trace_risk_critical_email_ingestion_acquisition_readiness_summary_json", + "data_room_artifact": "acquisition-readiness-summary.json", + "source_field": "acquisition_readiness_gate", + "owner_area": "email_ingestion", + "reviewer_roles": ["executive diligence reviewer"], + "acceptance_status": "blocked", + "close_gate_status": "blocked", + "blocker_keys": [ + "exception_repair_thread_id_integrity", + "exception_backfill_dedupe_fingerprints", + ], + "acceptance_criteria": ( + "Resolve 2 exception(s), regenerate " + "acquisition-readiness-summary.json from acquisition_readiness_gate, " + "and verify the copied snapshot digest before buyer acceptance." + ), + "verification_command": ( + "python scripts/verify_evidence_snapshot.py " + ), + "reviewer_evidence_summary": ( + "executive diligence reviewer review " + "acquisition-readiness-summary.json for email_ingestion; " + "trace_risk_critical_email_ingestion_acquisition_readiness_summary_json " + "covers 2 exception(s)." + ), + "next_action": ( + "Resolve exception_repair_thread_id_integrity, " + "exception_backfill_dedupe_fingerprints, then regenerate the " + "evidence snapshot." + ), + "snapshot_verification_required": True, + "provider_write_executed": False, + } + assert acceptance_checklist[2]["source_field"] == "content_graph_evidence_samples" + assert acceptance_checklist[2]["reviewer_roles"] == ["data quality reviewer"] + assert acceptance_checklist[3]["data_room_artifact"] == ( + "knowledge-graph-evidence-samples.json" + ) + assert acceptance_checklist[-1]["blocker_keys"] == [ + "exception_expand_attachment_parse_coverage" + ] + assert all( + item["provider_write_executed"] is False for item in acceptance_checklist + ) + acceptance_summary = snapshot["diligence_close_acceptance_summary"] + assert acceptance_summary == { + "summary_key": "buyer_close_acceptance", + "decision_code": "close_blocked", + "total_acceptance_count": 6, + "blocked_acceptance_count": 6, + "ready_acceptance_count": 0, + "reviewer_role_count": 3, + "reviewer_roles": [ + "coverage reviewer", + "data quality reviewer", + "executive diligence reviewer", + ], + "required_artifact_count": 5, + "required_artifacts": [ + "acquisition-readiness-summary.json", + "dom-paragraph-evidence-samples.json", + "knowledge-graph-evidence-samples.json", + "remediation-actions.json", + "semantic-relation-evidence-samples.json", + ], + "blocker_count": 9, + "blocker_keys": [ + "exception_attach_kg_evidence_endpoints", + "exception_backfill_content_graph_coverage", + "exception_backfill_dedupe_fingerprints", + "exception_backfill_knowledge_graph_coverage", + "exception_backfill_semantic_relation_sources", + "exception_expand_attachment_parse_coverage", + "exception_recover_attachment_content", + "exception_repair_segment_text_readiness", + "exception_repair_thread_id_integrity", + ], + "close_gate_status": "blocked", + "snapshot_verification_required": True, + "buyer_summary_text": ( + "Buyer acceptance remains blocked by 6 item(s) across 5 artifact(s) " + "and 9 blocker key(s)." + ), + "next_action_text": ( + "Resolve blocker keys, regenerate the evidence snapshot, run the " + "offline verifier, and reissue the acceptance checklist." + ), + "provider_write_executed": False, + } + release_summary = snapshot["data_room_release_summary"] + assert release_summary == { + "release_key": "buyer_data_room_release", + "release_status": "release_blocked", + "total_artifact_count": 10, + "ready_artifact_count": 7, + "needs_attention_artifact_count": 3, + "required_for_close_count": 10, + "blocked_artifact_files": [ + "acquisition-readiness-summary.json", + "buyer-evidence-packet-checklist.json", + "remediation-actions.json", + ], + "privacy_exposure_count": 0, + "raw_content_exposure_count": 0, + "stable_identifier_exposure_count": 0, + "provider_credential_exposure_count": 0, + "snapshot_verification_required": True, + "verification_command": ( + "python scripts/verify_evidence_snapshot.py " + ), + "acceptance_blocker_count": 9, + "acceptance_blocker_keys": [ + "exception_attach_kg_evidence_endpoints", + "exception_backfill_content_graph_coverage", + "exception_backfill_dedupe_fingerprints", + "exception_backfill_knowledge_graph_coverage", + "exception_backfill_semantic_relation_sources", + "exception_expand_attachment_parse_coverage", + "exception_recover_attachment_content", + "exception_repair_segment_text_readiness", + "exception_repair_thread_id_integrity", + ], + "buyer_summary_text": ( + "Data-room release remains blocked by 3 artifact(s), 9 blocker key(s), " + "and 0 privacy exposure(s)." + ), + "next_action_text": ( + "Resolve blocked artifact states, clear acceptance blockers, run the " + "offline verifier, and reissue the release bundle." + ), + "provider_write_executed": False, + } assert "semantic_extraction_manifest" in snapshot["canonical_payload_fields"] assert "semantic_relation_evidence_samples" in snapshot["canonical_payload_fields"] assert snapshot["parser_manifest_summary"][0] == { diff --git a/docs/superpowers/plans/2026-07-02-commercial-close-buyer-brief.md b/docs/superpowers/plans/2026-07-02-commercial-close-buyer-brief.md new file mode 100644 index 000000000..ef30e7c05 --- /dev/null +++ b/docs/superpowers/plans/2026-07-02-commercial-close-buyer-brief.md @@ -0,0 +1,111 @@ +# Commercial Close Buyer Brief Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Add a deterministic buyer brief to the redacted DOM-paragraph knowledge-graph evidence snapshot so a 2,000,000,000 KRW target buyer review can read the close status, proof thesis, blocker summary, guardrails, and handoff without inspecting raw emails or attachments. + +**Architecture:** Keep the buyer brief inside `DataEvidenceSnapshotResponse` and derive it only from existing redacted snapshot fields. Do not add a new library, submodule, package split, route, dependency, or Figma Code Connect artifact in this phase; the sale-readiness value comes from a stable API contract, digest inclusion, visible UI, and regression evidence. + +**Tech Stack:** FastAPI/Pydantic backend, existing Data API snapshot contract, React/TypeScript Data Quality UI, Vitest, Pytest, Ruff, FigJam diagram generation. + +## Global Constraints + +- Figma Code Connect is not used. +- `target_contract_value_krw` is buyer-review operating metadata, not a valuation claim. +- The buyer brief must not expose raw email bodies, raw HTML, attachment bytes, message IDs, attachment IDs, stable database IDs, provider credentials, or DB evidence column strings. +- The buyer brief must be deterministic for the same snapshot inputs and included in `canonical_payload_fields`. +- Brief bullets must come from already-redacted snapshot fields and existing diligence contracts, not new data sources. +- Review process and queued GitHub checks are not blockers, but live PR head, unresolved review-thread count, and check state must be re-verified before completion. +- Preserve unrelated `.Jules/palette.md` and `.Jules/sentinel.md` edits. + +--- + +### Task 1: Backend Buyer Brief Contract + +**Files:** +- Modify: `backend/api/data.py` +- Modify: `backend/tests/test_data_api.py` + +**Interfaces:** +- Consumes: `diligence_close_decision_summary`, `acquisition_readiness_gate`, `data_room_release_summary`, `commercial_close_readiness_scorecard`, `commercial_close_execution_plan`, `commercial_close_kpi_operating_model`, `diligence_exception_register`, `privacy_redaction_policy`, and `verification_handoff` +- Produces: `commercial_close_buyer_brief: DataCommercialCloseBuyerBrief` + +- [x] Add `CommercialCloseBuyerBriefStatus = Literal["brief_ready", "brief_blocked"]`. +- [x] Add `DataCommercialCloseBuyerBriefBullet` with bullet key, display label, source field, detail text, and provider write boundary. +- [x] Add `DataCommercialCloseBuyerBrief` with target review metadata, status, readiness headline, proof thesis, evidence basis bullets, blocker bullets, guardrail bullets, reviewer handoff text, next action, and write boundary. +- [x] Add `_default_commercial_close_buyer_brief()`. +- [x] Add `_commercial_close_buyer_brief(snapshot)` after `_commercial_close_kpi_operating_model(snapshot)`. +- [x] Populate `commercial_close_buyer_brief` before `_snapshot_digest_payload(snapshot)`. +- [x] Add `_expected_commercial_close_buyer_brief()` and assert the exact object in `test_data_quality_evidence_snapshot_returns_shareable_redacted_surface`. +- [x] Assert `commercial_close_buyer_brief` is present in `canonical_payload_fields`. + +Expected current fixture: +- status: `brief_blocked` +- target review value: `2,000,000,000 KRW` +- readiness headline includes readiness score `62/100` +- proof thesis references redacted DOM/paragraph/KG evidence, data-room readiness, buyer acceptance, KPI operating status, and offline verification +- top blocker bullets: 5 +- guardrail bullets: 4 +- provider write boundary: false + +### Task 2: Frontend Type And Buyer Brief Card + +**Files:** +- Modify: `frontend/src/components/data-layout/types.ts` +- Modify: `frontend/src/components/data-layout/QualityCheckTab.tsx` +- Modify: `frontend/src/app/data/page.test.tsx` + +**Interfaces:** +- Consumes: `dataEvidenceSnapshot.commercial_close_buyer_brief` +- Produces: an existing-style snapshot card titled `Commercial close buyer brief` + +- [x] Add TypeScript types mirroring the backend buyer brief contract. +- [x] Add a fixture `commercialCloseBuyerBrief` with the backend expected values. +- [x] Add the brief to `canonical_payload_fields` and `dataEvidenceSnapshot`. +- [x] Render the brief near the commercial close KPI operating model using existing border/list/chip patterns. +- [x] Show status, target review value, readiness headline, proof thesis, reviewer handoff, next action, evidence basis bullets, blocker bullets, guardrail bullets, and write boundary. +- [x] Assert visible text includes `Commercial close buyer brief`, `brief_blocked`, `buyer_brief_readiness_score`, `buyer_brief_kpi_operating_model`, `buyer_brief_privacy_redaction`, and `buyer_brief_offline_verifier`. +- [x] Assert copied JSON includes `commercial_close_buyer_brief` exactly. + +### Task 3: FigJam Planning Update + +**Files:** +- Modify: this plan's evidence section after generation + +**Interfaces:** +- Consumes: current FigJam board `mjH0tpDIvz5kj44kL6354R` +- Produces: a new editable FigJam diagram for Phase 36 + +- [x] Generate a FigJam flowchart, not a Code Connect artifact. +- [x] Diagram: decision summary, readiness gate, release summary, scorecard, execution plan, KPI model, exception register, privacy policy, and verifier feed the buyer brief. +- [x] Record the FigJam URL in this plan. + +### Task 4: Verification, Ponytail Review, Push + +**Files:** +- Modify: this plan's evidence section + +**Interfaces:** +- Consumes: local tests, lint, git diff, PR #901 state +- Produces: pushed commit on `plan/email-dom-paragraph-kg-2026-07-02` + +- [x] Run `python3 -m pytest backend/tests/test_data_api.py -q`. +- [x] Run `python3 -m ruff check backend/api/data.py backend/tests/test_data_api.py`. +- [x] Run `PATH=/opt/homebrew/opt/node@24/bin:$PATH /opt/homebrew/opt/node@24/bin/npm test -- src/app/data/page.test.tsx` from `frontend/`. +- [x] Run `PATH=/opt/homebrew/opt/node@24/bin:$PATH /opt/homebrew/opt/node@24/bin/npm run lint -- src/components/data-layout/QualityCheckTab.tsx src/components/data-layout/types.ts src/app/data/page.test.tsx` from `frontend/`. +- [x] Run `git diff --check`. +- [x] Run Ponytail review on the diff and record complexity verdict. +- [x] Commit only intended files. +- [x] Push to `origin HEAD:refs/heads/plan/email-dom-paragraph-kg-2026-07-02`. +- [x] Re-verify live PR #901 `headRefOid`, merge state, unresolved review thread count, and check state. + +## Evidence + +- FigJam: `https://www.figma.com/board/mjH0tpDIvz5kj44kL6354R`. +- Backend tests: `python3 -m pytest backend/tests/test_data_api.py -q` -> 9 passed, 1 skipped. +- Backend ruff: `python3 -m ruff check backend/api/data.py backend/tests/test_data_api.py` -> All checks passed. +- Frontend tests: `PATH=/opt/homebrew/opt/node@24/bin:$PATH /opt/homebrew/opt/node@24/bin/npm test -- src/app/data/page.test.tsx` -> 13 passed. +- Frontend lint: `PATH=/opt/homebrew/opt/node@24/bin:$PATH /opt/homebrew/opt/node@24/bin/npm run lint -- src/components/data-layout/QualityCheckTab.tsx src/components/data-layout/types.ts src/app/data/page.test.tsx` -> passed with exit code 0. +- Diff check: `git diff --check` -> clean. +- Ponytail: `Lean already. Ship.` +- PR #901 live state after implementation push: `headRefOid=64b782e8d64b3d91e9e0e1701e4ea48953f0b024`, `mergeable=MERGEABLE`, `mergeStateStatus=BLOCKED`, current unresolved review threads `0`, outdated unresolved review threads `4`, checks queued/pending. diff --git a/docs/superpowers/plans/2026-07-02-commercial-close-buyer-review-runbook.md b/docs/superpowers/plans/2026-07-02-commercial-close-buyer-review-runbook.md new file mode 100644 index 000000000..68d32f2c0 --- /dev/null +++ b/docs/superpowers/plans/2026-07-02-commercial-close-buyer-review-runbook.md @@ -0,0 +1,114 @@ +# Commercial Close Buyer Review Runbook Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Add a deterministic buyer review runbook to the redacted DOM-paragraph knowledge-graph evidence snapshot so a 2,000,000,000 KRW target review can see the exact review sequence, evidence files, blockers, verifier command, SLA cadence, and privacy/write guardrails. + +**Architecture:** Keep the runbook inside `DataEvidenceSnapshotResponse` and derive it only from already-redacted snapshot fields, especially `commercial_close_release_package`. Do not add a new library, submodule, package split, route, dependency, or Figma Code Connect artifact in this phase; the contract still changes every phase, so extraction into a separate evidence-package library remains a follow-up after the snapshot surface stabilizes. + +**Tech Stack:** FastAPI/Pydantic backend, existing Data API snapshot contract, React/TypeScript Data Quality UI, Vitest, Pytest, Ruff, FigJam diagram generation. + +## Global Constraints + +- Figma Code Connect is not used. +- `target_contract_value_krw` is buyer-review operating metadata, not a valuation claim. +- The runbook must not expose raw email bodies, raw HTML, attachment bytes, message IDs, attachment IDs, stable database IDs, provider credentials, or DB evidence column strings. +- The runbook must be deterministic for the same snapshot inputs and included in `canonical_payload_fields`. +- Review steps must come from already-redacted snapshot fields and existing diligence/commercial-close contracts, not new data sources. +- Review process and queued GitHub checks are not blockers, but live PR head, unresolved review-thread count, and check state must be re-verified before completion. +- Preserve unrelated `.Jules/palette.md` and `.Jules/sentinel.md` edits. + +--- + +### Task 1: Backend Buyer Review Runbook Contract + +**Files:** +- Modify: `backend/api/data.py` +- Modify: `backend/tests/test_data_api.py` + +**Interfaces:** +- Consumes: `commercial_close_release_package`, `privacy_redaction_policy`, `verification_handoff`, `data_room_release_summary`, `diligence_close_acceptance_summary`, `commercial_close_readiness_scorecard`, `commercial_close_execution_plan`, `commercial_close_kpi_operating_model`, `commercial_close_buyer_brief`, and `commercial_close_signoff_matrix` +- Produces: `commercial_close_buyer_review_runbook: DataCommercialCloseBuyerReviewRunbook` + +- [x] Add `CommercialCloseBuyerReviewRunbookStatus = Literal["review_ready", "review_blocked"]`. +- [x] Add `CommercialCloseBuyerReviewStepStatus = Literal["ready", "blocked"]`. +- [x] Add `CommercialCloseBuyerReviewStepLane = Literal["intake", "verification", "privacy", "data_room", "commercial", "signoff", "release"]`. +- [x] Add `DataCommercialCloseBuyerReviewRunbookStep` with step key, review order, lane, status, evidence file, source field, reviewer role, owner area, SLA hours, review day, entry criteria, exit criteria, blocker keys, and privacy/write guardrails. +- [x] Add `DataCommercialCloseBuyerReviewRunbook` with target review metadata, status, step counts, blocked step keys, blocker keys, verifier command, buyer handoff, next action, first step, final decision step, steps, and write boundary. +- [x] Add `_default_commercial_close_buyer_review_runbook()`. +- [x] Add `_commercial_close_buyer_review_runbook(snapshot)` after `_commercial_close_release_package(snapshot)`. +- [x] Populate `commercial_close_buyer_review_runbook` before `_snapshot_digest_payload(snapshot)`. +- [x] Add `_expected_commercial_close_buyer_review_runbook()` and assert exact object equality in `test_data_quality_evidence_snapshot_returns_shareable_redacted_surface`. +- [x] Assert `commercial_close_buyer_review_runbook` is present in `canonical_payload_fields`. + +Expected current fixture: +- status: `review_blocked` +- target review value: `2,000,000,000 KRW` +- steps: 11 review rows +- ready steps: 3 +- blocked steps: 8 +- first step: `buyer_review_intake` +- final decision step: `buyer_review_release_decision` +- provider write boundary: false + +### Task 2: Frontend Type And Buyer Review Runbook Card + +**Files:** +- Modify: `frontend/src/components/data-layout/types.ts` +- Modify: `frontend/src/components/data-layout/QualityCheckTab.tsx` +- Modify: `frontend/src/app/data/page.test.tsx` + +**Interfaces:** +- Consumes: `dataEvidenceSnapshot.commercial_close_buyer_review_runbook` +- Produces: an existing-style snapshot card titled `Commercial close buyer review runbook` + +- [x] Add TypeScript types mirroring the backend runbook contract. +- [x] Add a fixture `commercialCloseBuyerReviewRunbook` with the backend expected values. +- [x] Add the runbook to `canonical_payload_fields` and `dataEvidenceSnapshot`. +- [x] Render the runbook after the release package using existing border/list/chip patterns. +- [x] Show status, target review value, step counts, first/final steps, blocked steps, blocker keys, verifier command, buyer handoff, next action, review order, lane, evidence file, source field, reviewer role, owner area, SLA hours, review day, entry/exit criteria, privacy flags, and write boundary. +- [x] Assert visible text includes `Commercial close buyer review runbook`, `buyer_review_intake`, `buyer_review_release_decision`, `review_blocked`, `blocked steps 8`, `commercial-close-signoff-matrix.json`, and `python scripts/verify_evidence_snapshot.py `. +- [x] Assert copied JSON includes `commercial_close_buyer_review_runbook` exactly. + +### Task 3: FigJam Planning Update + +**Files:** +- Modify: this plan's evidence section after generation + +**Interfaces:** +- Consumes: current FigJam board `mjH0tpDIvz5kj44kL6354R` +- Produces: a new editable FigJam diagram for Phase 39 + +- [x] Generate a FigJam flowchart, not a Code Connect artifact. +- [x] Diagram: release package, privacy policy, verifier, buyer review lanes, blocked/ready steps, and final release decision. +- [x] Record the FigJam URL in this plan. + +### Task 4: Verification, Ponytail Review, Push + +**Files:** +- Modify: this plan's evidence section + +**Interfaces:** +- Consumes: local tests, lint, git diff, PR #901 state +- Produces: pushed commit on `plan/email-dom-paragraph-kg-2026-07-02` + +- [x] Run `.venv/bin/python -m pytest backend/tests/test_data_api.py -q`. +- [x] Run `.venv/bin/python -m ruff check backend/api/data.py backend/tests/test_data_api.py`. +- [x] Run `PATH=/opt/homebrew/opt/node@24/bin:$PATH /opt/homebrew/opt/node@24/bin/npm test -- src/app/data/page.test.tsx` from `frontend/`. +- [x] Run `PATH=/opt/homebrew/opt/node@24/bin:$PATH /opt/homebrew/opt/node@24/bin/npm run lint -- src/components/data-layout/QualityCheckTab.tsx src/components/data-layout/types.ts src/app/data/page.test.tsx` from `frontend/`. +- [x] Run `git diff --check`. +- [x] Run Ponytail review on the diff and record complexity verdict. +- [x] Commit only intended files. +- [x] Push to `origin HEAD:refs/heads/plan/email-dom-paragraph-kg-2026-07-02`. +- [x] Re-verify live PR #901 `headRefOid`, merge state, unresolved review thread count, and check state. + +## Evidence + +- FigJam: [Phase 39 Commercial Close Buyer Review Runbook](https://www.figma.com/board/mjH0tpDIvz5kj44kL6354R) generated without Figma Code Connect. +- Backend tests: `.venv/bin/python -m pytest backend/tests/test_data_api.py -q` passed with 9 passed, 1 skipped. +- Backend ruff: `.venv/bin/python -m ruff check backend/api/data.py backend/tests/test_data_api.py` passed. +- Frontend tests: `PATH=/opt/homebrew/opt/node@24/bin:$PATH /opt/homebrew/opt/node@24/bin/npm test -- src/app/data/page.test.tsx` passed with 1 file and 13 tests. +- Frontend lint: `PATH=/opt/homebrew/opt/node@24/bin:$PATH /opt/homebrew/opt/node@24/bin/npm run lint -- src/components/data-layout/QualityCheckTab.tsx src/components/data-layout/types.ts src/app/data/page.test.tsx` passed. +- Diff check: `git diff --check` passed. +- Ponytail: Lean already. Ship. The buyer review runbook stays in the existing snapshot contract, adds no dependency, and avoids a premature library/submodule split. +- PR #901 live state after feature push: head `55774203da8480d2145d4b3f7da27f0612d31216`, mergeable `MERGEABLE`, merge state `BLOCKED`, current unresolved review threads 0, outdated unresolved review threads 4, checks queued/pending and not treated as blockers for this phase. diff --git a/docs/superpowers/plans/2026-07-02-commercial-close-execution-plan.md b/docs/superpowers/plans/2026-07-02-commercial-close-execution-plan.md new file mode 100644 index 000000000..011754237 --- /dev/null +++ b/docs/superpowers/plans/2026-07-02-commercial-close-execution-plan.md @@ -0,0 +1,115 @@ +# Commercial Close Execution Plan Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Add a deterministic commercial close execution plan to the redacted DOM-paragraph knowledge-graph evidence snapshot so a 2,000,000,000 KRW target buyer review can see exactly which owner lanes, artifacts, blockers, and verification steps remain before close. + +**Architecture:** Keep this as a first-party `DataEvidenceSnapshotResponse` contract derived from already-redacted snapshot fields. Do not add a separate library, submodule, package split, or Figma Code Connect artifact in this phase; the value is in a stable buyer-facing API contract, digest inclusion, visible UI, and regression evidence. + +**Tech Stack:** FastAPI/Pydantic backend, existing Data API snapshot contract, React/TypeScript Data Quality UI, Vitest, Pytest, Ruff, FigJam diagram generation. + +## Global Constraints + +- Figma Code Connect is not used. +- `target_contract_value_krw` is operational sale-readiness metadata, not a valuation claim. +- The plan must not expose raw email bodies, raw HTML, attachment bytes, message IDs, attachment IDs, stable database IDs, provider credentials, or DB evidence column strings. +- The plan must be deterministic for the same snapshot inputs and included in `canonical_payload_fields`. +- Execution lanes must be grouped from existing remediation actions and data-room artifacts, not hand-authored duplicate business logic. +- Review process and queued GitHub checks are not blockers, but live PR head, unresolved review-thread count, and check state must be re-verified before completion. +- Preserve unrelated `.Jules/palette.md` and `.Jules/sentinel.md` edits. + +--- + +### Task 1: Backend Execution Plan Contract + +**Files:** +- Modify: `backend/api/data.py` +- Modify: `backend/tests/test_data_api.py` + +**Interfaces:** +- Consumes: `commercial_close_readiness_scorecard`, `acquisition_readiness_gate.remediation_actions`, `data_room_package_manifest`, `diligence_close_acceptance_summary`, and `verification_handoff` +- Produces: `commercial_close_execution_plan: DataCommercialCloseExecutionPlan` + +- [x] Add `CommercialCloseExecutionStatus = Literal["execution_ready", "execution_blocked"]`. +- [x] Add `CommercialCloseExecutionLaneStatus = Literal["ready", "blocked"]`. +- [x] Add `DataCommercialCloseExecutionLane` with execution order, owner area, priority, related artifact, action keys, blocker keys, acceptance criteria, verification command, and write boundary. +- [x] Add `DataCommercialCloseExecutionPlan` with target review metadata, lane/action counts, artifact list, KPI/blocker counts, buyer summary, next action, and lanes. +- [x] Add `_default_commercial_close_execution_plan()`. +- [x] Add `_commercial_close_execution_plan(snapshot)` after `_commercial_close_readiness_scorecard(snapshot)`. +- [x] Populate `commercial_close_execution_plan` before `_snapshot_digest_payload(snapshot)`. +- [x] Add `_expected_commercial_close_execution_plan()` and assert the exact object in `test_data_evidence_snapshot_returns_redacted_buyer_packet`. +- [x] Assert `commercial_close_execution_plan` is present in `canonical_payload_fields`. + +Expected current fixture: +- status: `execution_blocked` +- total lanes: 6 +- blocked lanes: 6 +- critical lanes: 1 +- high lanes: 4 +- medium lanes: 1 +- total actions: 9 +- related artifacts: 5 +- KPI gaps: 9 +- acceptance blockers: 9 + +### Task 2: Frontend Type And Execution Card + +**Files:** +- Modify: `frontend/src/components/data-layout/types.ts` +- Modify: `frontend/src/components/data-layout/QualityCheckTab.tsx` +- Modify: `frontend/src/app/data/page.test.tsx` + +**Interfaces:** +- Consumes: `dataEvidenceSnapshot.commercial_close_execution_plan` +- Produces: an existing-style snapshot card titled `Commercial close execution plan` + +- [x] Add TypeScript types mirroring the backend execution-plan contract. +- [x] Add a fixture `commercialCloseExecutionPlan` with the backend expected values. +- [x] Add the plan to `canonical_payload_fields` and `dataEvidenceSnapshot`. +- [x] Render the plan near the commercial close readiness scorecard using existing border/list/chip patterns. +- [x] Show status, target review value, lane counts, action counts, artifact counts, KPI gaps, blocker counts, verifier command, buyer summary, next action, lane ownership, artifact readiness, acceptance criteria, blocking check keys, acceptance blocker keys, action keys, and write boundary. +- [x] Assert visible text includes `Commercial close execution plan`, `execution_blocked`, `6 lane(s)`, `email_ingestion`, `acquisition-readiness-summary.json`, `thread_id_integrity`, and `exception_repair_thread_id_integrity`. +- [x] Assert copied JSON includes `commercial_close_execution_plan` exactly. + +### Task 3: FigJam Planning Update + +**Files:** +- Modify: this plan's evidence section after generation + +**Interfaces:** +- Consumes: current FigJam board `mjH0tpDIvz5kj44kL6354R` +- Produces: a new editable FigJam diagram for Phase 34 + +- [x] Generate a FigJam flowchart, not a Code Connect artifact. +- [x] Diagram: readiness scorecard, remediation actions, data-room manifest, acceptance summary, and verifier handoff feed execution lanes, then buyer review reissue. +- [x] Record the FigJam URL in this plan. + +### Task 4: Verification, Ponytail Review, Push + +**Files:** +- Modify: this plan's evidence section + +**Interfaces:** +- Consumes: local tests, lint, git diff, PR #901 state +- Produces: pushed commit on `plan/email-dom-paragraph-kg-2026-07-02` + +- [x] Run `python3 -m pytest backend/tests/test_data_api.py -q`. +- [x] Run `python3 -m ruff check backend/api/data.py backend/tests/test_data_api.py`. +- [x] Run `npm test -- src/app/data/page.test.tsx`. +- [x] Run `npm run lint -- src/components/data-layout/QualityCheckTab.tsx src/components/data-layout/types.ts src/app/data/page.test.tsx`. +- [x] Run `git diff --check`. +- [x] Run Ponytail review on the diff and record complexity verdict. +- [x] Commit only intended files. +- [x] Push to `origin HEAD:refs/heads/plan/email-dom-paragraph-kg-2026-07-02`. +- [x] Re-verify live PR #901 `headRefOid`, merge state, unresolved review thread count, and check state. + +## Evidence + +- FigJam: `https://www.figma.com/board/mjH0tpDIvz5kj44kL6354R`. +- Backend tests: `python3 -m pytest backend/tests/test_data_api.py -q` -> 9 passed, 1 skipped. +- Backend ruff: `python3 -m ruff check backend/api/data.py backend/tests/test_data_api.py` -> All checks passed. +- Frontend tests: `PATH=/opt/homebrew/opt/node@24/bin:$PATH /opt/homebrew/opt/node@24/bin/npm test -- src/app/data/page.test.tsx` from `frontend/` -> 13 passed. +- Frontend lint: `PATH=/opt/homebrew/opt/node@24/bin:$PATH /opt/homebrew/opt/node@24/bin/npm run lint -- src/components/data-layout/QualityCheckTab.tsx src/components/data-layout/types.ts src/app/data/page.test.tsx` from `frontend/` -> passed. +- Diff check: `git diff --check` -> clean. +- Ponytail: `Lean already. Ship.` +- PR #901 live state: branch head re-verified after push, review threads 5 unresolved total with 1 current and 4 outdated, GitHub checks pending/queued and not treated as blockers. diff --git a/docs/superpowers/plans/2026-07-02-commercial-close-kpi-operating-model.md b/docs/superpowers/plans/2026-07-02-commercial-close-kpi-operating-model.md new file mode 100644 index 000000000..c1e8195a1 --- /dev/null +++ b/docs/superpowers/plans/2026-07-02-commercial-close-kpi-operating-model.md @@ -0,0 +1,114 @@ +# Commercial Close KPI Operating Model Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Add a deterministic commercial close KPI operating model to the redacted DOM-paragraph knowledge-graph evidence snapshot so a 2,000,000,000 KRW target buyer review can see the primary KPI, driver metrics, guardrails, owners, source fields, and next actions that govern close readiness. + +**Architecture:** Keep the KPI model inside `DataEvidenceSnapshotResponse` and derive it only from existing redacted snapshot fields. Do not add a new library, submodule, package split, route, dependency, or Figma Code Connect artifact in this phase; the sale-readiness value comes from a stable API contract, digest inclusion, visible UI, and regression evidence. + +**Tech Stack:** FastAPI/Pydantic backend, existing Data API snapshot contract, React/TypeScript Data Quality UI, Vitest, Pytest, Ruff, FigJam diagram generation. + +## Global Constraints + +- Figma Code Connect is not used. +- `target_contract_value_krw` is operational KPI review metadata, not a valuation claim. +- The KPI model must not expose raw email bodies, raw HTML, attachment bytes, message IDs, attachment IDs, stable database IDs, provider credentials, or DB evidence column strings. +- The KPI model must be deterministic for the same snapshot inputs and included in `canonical_payload_fields`. +- Metrics must come from already-redacted snapshot fields and existing buyer diligence contracts, not new data sources. +- Review process and queued GitHub checks are not blockers, but live PR head, unresolved review-thread count, and check state must be re-verified before completion. +- Preserve unrelated `.Jules/palette.md` and `.Jules/sentinel.md` edits. + +--- + +### Task 1: Backend KPI Operating Contract + +**Files:** +- Modify: `backend/api/data.py` +- Modify: `backend/tests/test_data_api.py` + +**Interfaces:** +- Consumes: `commercial_close_readiness_scorecard`, `commercial_close_execution_plan`, `data_room_release_summary`, `diligence_close_acceptance_summary`, `verification_handoff`, `privacy_redaction_policy`, and `acquisition_readiness_gate.kpis` +- Produces: `commercial_close_kpi_operating_model: DataCommercialCloseKpiOperatingModel` + +- [x] Add `CommercialCloseKpiMetricKind = Literal["primary", "driver", "guardrail"]`. +- [x] Add `CommercialCloseKpiMetricStatus = Literal["target_met", "needs_attention"]`. +- [x] Add `CommercialCloseKpiOperatingStatus = Literal["operating_ready", "operating_blocked"]`. +- [x] Add `DataCommercialCloseKpiOperatingMetric` with metric key, kind, status, current/target values, unit, owner area, source field, buyer implication, next action, and write boundary. +- [x] Add `DataCommercialCloseKpiOperatingModel` with target review metadata, metric counts, blocker keys, buyer summary, next action, metrics, and write boundary. +- [x] Add `_default_commercial_close_kpi_operating_model()`. +- [x] Add `_commercial_close_kpi_operating_model(snapshot)` after `_commercial_close_execution_plan(snapshot)`. +- [x] Populate `commercial_close_kpi_operating_model` before `_snapshot_digest_payload(snapshot)`. +- [x] Add `_expected_commercial_close_kpi_operating_model()` and assert the exact object in `test_data_evidence_snapshot_returns_redacted_buyer_packet`. +- [x] Assert `commercial_close_kpi_operating_model` is present in `canonical_payload_fields`. + +Expected current fixture: +- status: `operating_blocked` +- total metrics: 8 +- target met: 3 +- needs attention: 5 +- primary metrics: 1 +- driver metrics: 4 +- guardrail metrics: 3 +- primary score: 62 of 100 + +### Task 2: Frontend Type And KPI Card + +**Files:** +- Modify: `frontend/src/components/data-layout/types.ts` +- Modify: `frontend/src/components/data-layout/QualityCheckTab.tsx` +- Modify: `frontend/src/app/data/page.test.tsx` + +**Interfaces:** +- Consumes: `dataEvidenceSnapshot.commercial_close_kpi_operating_model` +- Produces: an existing-style snapshot card titled `Commercial close KPI operating model` + +- [x] Add TypeScript types mirroring the backend KPI operating contract. +- [x] Add a fixture `commercialCloseKpiOperatingModel` with the backend expected values. +- [x] Add the model to `canonical_payload_fields` and `dataEvidenceSnapshot`. +- [x] Render the model near the commercial close execution plan using existing border/list/chip patterns. +- [x] Show status, target review value, metric counts, target-met count, needs-attention count, driver/guardrail counts, buyer summary, next action, metric ownership, source fields, current/target values, buyer implications, and write boundary. +- [x] Assert visible text includes `Commercial close KPI operating model`, `operating_blocked`, `commercial_close_readiness_score`, `execution_lane_clearance`, `privacy_exposure_control`, and `provider_write_boundary`. +- [x] Assert copied JSON includes `commercial_close_kpi_operating_model` exactly. + +### Task 3: FigJam Planning Update + +**Files:** +- Modify: this plan's evidence section after generation + +**Interfaces:** +- Consumes: current FigJam board `mjH0tpDIvz5kj44kL6354R` +- Produces: a new editable FigJam diagram for Phase 35 + +- [x] Generate a FigJam flowchart, not a Code Connect artifact. +- [x] Diagram: readiness scorecard, execution plan, release summary, acceptance summary, acquisition KPIs, and guardrails feed the KPI operating model. +- [x] Record the FigJam URL in this plan. + +### Task 4: Verification, Ponytail Review, Push + +**Files:** +- Modify: this plan's evidence section + +**Interfaces:** +- Consumes: local tests, lint, git diff, PR #901 state +- Produces: pushed commit on `plan/email-dom-paragraph-kg-2026-07-02` + +- [x] Run `python3 -m pytest backend/tests/test_data_api.py -q`. +- [x] Run `python3 -m ruff check backend/api/data.py backend/tests/test_data_api.py`. +- [x] Run `PATH=/opt/homebrew/opt/node@24/bin:$PATH /opt/homebrew/opt/node@24/bin/npm test -- src/app/data/page.test.tsx` from `frontend/`. +- [x] Run `PATH=/opt/homebrew/opt/node@24/bin:$PATH /opt/homebrew/opt/node@24/bin/npm run lint -- src/components/data-layout/QualityCheckTab.tsx src/components/data-layout/types.ts src/app/data/page.test.tsx` from `frontend/`. +- [x] Run `git diff --check`. +- [x] Run Ponytail review on the diff and record complexity verdict. +- [ ] Commit only intended files. +- [ ] Push to `origin HEAD:refs/heads/plan/email-dom-paragraph-kg-2026-07-02`. +- [ ] Re-verify live PR #901 `headRefOid`, merge state, unresolved review thread count, and check state. + +## Evidence + +- FigJam: `https://www.figma.com/board/mjH0tpDIvz5kj44kL6354R`. +- Backend tests: `python3 -m pytest backend/tests/test_data_api.py -q` -> 9 passed, 1 skipped. +- Backend ruff: `python3 -m ruff check backend/api/data.py backend/tests/test_data_api.py` -> All checks passed. +- Frontend tests: `PATH=/opt/homebrew/opt/node@24/bin:$PATH /opt/homebrew/opt/node@24/bin/npm test -- src/app/data/page.test.tsx` -> 13 passed. +- Frontend lint: `PATH=/opt/homebrew/opt/node@24/bin:$PATH /opt/homebrew/opt/node@24/bin/npm run lint -- src/components/data-layout/QualityCheckTab.tsx src/components/data-layout/types.ts src/app/data/page.test.tsx` -> passed with exit code 0. +- Diff check: `git diff --check` -> clean. +- Ponytail: `Lean already. Ship.` +- PR #901 live state: pending. diff --git a/docs/superpowers/plans/2026-07-02-commercial-close-readiness-scorecard.md b/docs/superpowers/plans/2026-07-02-commercial-close-readiness-scorecard.md new file mode 100644 index 000000000..a3aad03f5 --- /dev/null +++ b/docs/superpowers/plans/2026-07-02-commercial-close-readiness-scorecard.md @@ -0,0 +1,112 @@ +# Commercial Close Readiness Scorecard Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Add a buyer-facing commercial close readiness scorecard to the redacted DOM-paragraph knowledge-graph evidence snapshot for a 2,000,000,000 KRW target review. + +**Architecture:** Keep the scorecard inside `DataEvidenceSnapshotResponse` and derive it only from already-redacted snapshot fields. Do not add a library, package, or submodule in this phase; the current repo already has the parser, evidence snapshot, release summary, and UI surfaces needed for the next buyer-diligence increment. + +**Tech Stack:** FastAPI/Pydantic backend, existing Data API snapshot contract, React/TypeScript Data Quality UI, Vitest, Pytest, Ruff, FigJam diagram generation. + +## Global Constraints + +- Figma Code Connect is not used. +- `target_contract_value_krw` is metadata for readiness framing, not a valuation claim. +- The scorecard must not expose raw email bodies, raw HTML, attachment bytes, message IDs, attachment IDs, stable database IDs, provider credentials, or DB evidence column strings. +- The scorecard must be deterministic for the same snapshot inputs and included in `canonical_payload_fields`. +- Review process and queued GitHub checks are not blockers, but live PR head and thread/check state must be re-verified before completion. +- Preserve unrelated `.Jules/palette.md` and `.Jules/sentinel.md` edits. + +--- + +### Task 1: Backend Scorecard Contract + +**Files:** +- Modify: `backend/api/data.py` +- Modify: `backend/tests/test_data_api.py` + +**Interfaces:** +- Consumes: `DataEvidenceSnapshotResponse.acquisition_readiness_gate`, `evidence_packet_checklist`, `data_room_release_summary`, `diligence_close_acceptance_summary`, `verification_handoff`, `privacy_redaction_policy` +- Produces: `commercial_close_readiness_scorecard: DataCommercialCloseReadinessScorecard` + +- [ ] Add `CommercialCloseReadinessStatus = Literal["commercially_ready", "commercially_blocked"]`. +- [ ] Add `CommercialCloseReadinessCategoryStatus = Literal["ready", "needs_attention"]`. +- [ ] Add `DataCommercialCloseReadinessCategoryScore` with `category_key`, `display_name`, `status_code`, `score`, `max_score`, and `detail_text`. +- [ ] Add `DataCommercialCloseReadinessScorecard` with target value, total score, category scores, blocker lists, buyer summary, next action, and `provider_write_executed`. +- [ ] Add `_default_commercial_close_readiness_scorecard()`. +- [ ] Add `_commercial_close_readiness_scorecard(snapshot)` after `_data_room_release_summary(snapshot)` is available. +- [ ] Populate `commercial_close_readiness_scorecard` before `_snapshot_digest_payload(snapshot)`. +- [ ] Add `_expected_commercial_close_readiness_scorecard()` and assert the exact object in `test_data_evidence_snapshot_returns_redacted_buyer_packet`. +- [ ] Assert `commercial_close_readiness_scorecard` is present in `canonical_payload_fields`. + +Expected current fixture score: +- evidence packet integrity: 14 of 15 +- data room release integrity: 14 of 20 +- buyer acceptance clearance: 0 of 20 +- privacy boundary: 20 of 20 +- offline verification: 10 of 10 +- product KPI attainment: 4 of 15 +- total: 62 of 100 +- status: `commercially_blocked` + +### Task 2: Frontend Type And Card + +**Files:** +- Modify: `frontend/src/components/data-layout/types.ts` +- Modify: `frontend/src/components/data-layout/QualityCheckTab.tsx` +- Modify: `frontend/src/app/data/page.test.tsx` + +**Interfaces:** +- Consumes: `dataEvidenceSnapshot.commercial_close_readiness_scorecard` +- Produces: an existing-style snapshot card titled `Commercial close readiness` + +- [ ] Add TypeScript types mirroring the backend scorecard contract. +- [ ] Add a fixture `commercialCloseReadinessScorecard` with the backend expected values. +- [ ] Add the scorecard to `canonical_payload_fields` and `dataEvidenceSnapshot`. +- [ ] Render the scorecard near the release summary using existing border/card/list/chip patterns. +- [ ] Show status, target value, score, buyer summary, next action, gap counts, privacy exposure count, verifier readiness, blocked artifacts, acceptance blocker keys, KPI gap keys, category scores, and write boundary. +- [ ] Assert visible text includes `Commercial close readiness`, `commercially_blocked`, `2,000,000,000 KRW`, `score 62 / 100`, `Product KPI attainment`, `exception_attach_kg_evidence_endpoints`, and `knowledge_graph_coverage`. +- [ ] Assert copied JSON includes `commercial_close_readiness_scorecard` exactly. + +### Task 3: FigJam Planning Update + +**Files:** +- Modify: this plan's evidence section after generation + +**Interfaces:** +- Consumes: current FigJam board `mjH0tpDIvz5kj44kL6354R` +- Produces: a new editable FigJam diagram for Phase 33 + +- [ ] Generate a FigJam flowchart, not a Code Connect artifact. +- [ ] Diagram: acquisition gate, evidence packet, data-room release, acceptance summary, privacy policy, verifier handoff, and KPI targets feed the commercial close readiness scorecard. +- [ ] Record the FigJam URL in this plan. + +### Task 4: Verification, Review, Push + +**Files:** +- Modify: this plan's evidence section + +**Interfaces:** +- Consumes: local tests, lint, git diff, PR #901 state +- Produces: pushed commit on `plan/email-dom-paragraph-kg-2026-07-02` + +- [ ] Run `python3 -m pytest backend/tests/test_data_api.py -q`. +- [ ] Run `python3 -m ruff check backend/api/data.py backend/tests/test_data_api.py`. +- [ ] Run `npm test -- src/app/data/page.test.tsx`. +- [ ] Run `npm run lint -- src/components/data-layout/QualityCheckTab.tsx src/components/data-layout/types.ts src/app/data/page.test.tsx`. +- [ ] Run `git diff --check`. +- [ ] Run Ponytail review on the diff and record complexity verdict. +- [ ] Commit only intended files. +- [ ] Push to `origin HEAD:refs/heads/plan/email-dom-paragraph-kg-2026-07-02`. +- [ ] Re-verify live PR #901 `headRefOid`, merge state, unresolved review thread count, and check state. + +## Evidence + +- FigJam: `https://www.figma.com/board/mjH0tpDIvz5kj44kL6354R`. +- Backend tests: `python3 -m pytest backend/tests/test_data_api.py -q` -> 9 passed, 1 skipped. +- Backend ruff: `python3 -m ruff check backend/api/data.py backend/tests/test_data_api.py` -> All checks passed. +- Frontend tests: `npm test -- src/app/data/page.test.tsx` -> 13 passed. +- Frontend lint: `npm run lint -- src/components/data-layout/QualityCheckTab.tsx src/components/data-layout/types.ts src/app/data/page.test.tsx` -> passed. +- Diff check: `git diff --check` -> clean. +- Ponytail: `Lean already. Ship.` +- PR #901 live state: pending. diff --git a/docs/superpowers/plans/2026-07-02-commercial-close-release-package.md b/docs/superpowers/plans/2026-07-02-commercial-close-release-package.md new file mode 100644 index 000000000..05b468244 --- /dev/null +++ b/docs/superpowers/plans/2026-07-02-commercial-close-release-package.md @@ -0,0 +1,113 @@ +# Commercial Close Release Package Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Add a deterministic buyer data-room commercial close release package to the redacted DOM-paragraph knowledge-graph evidence snapshot so a 2,000,000,000 KRW target review can see the exact close artifacts, release order, blockers, verifier command, and guardrails. + +**Architecture:** Keep the release package inside `DataEvidenceSnapshotResponse` and derive it only from existing redacted snapshot fields. Do not add a new library, submodule, package split, route, dependency, or Figma Code Connect artifact in this phase; this is a narrow canonical snapshot extension, while extraction into a dedicated evidence-package library is a later refactor once the contract stabilizes. + +**Tech Stack:** FastAPI/Pydantic backend, existing Data API snapshot contract, React/TypeScript Data Quality UI, Vitest, Pytest, Ruff, FigJam diagram generation. + +## Global Constraints + +- Figma Code Connect is not used. +- `target_contract_value_krw` is release-review operating metadata, not a valuation claim. +- The release package must not expose raw email bodies, raw HTML, attachment bytes, message IDs, attachment IDs, stable database IDs, provider credentials, or DB evidence column strings. +- The release package must be deterministic for the same snapshot inputs and included in `canonical_payload_fields`. +- Release artifact rows must come from already-redacted snapshot fields and existing diligence/commercial-close contracts, not new data sources. +- Review process and queued GitHub checks are not blockers, but live PR head, unresolved review-thread count, and check state must be re-verified before completion. +- Preserve unrelated `.Jules/palette.md` and `.Jules/sentinel.md` edits. + +--- + +### Task 1: Backend Release Package Contract + +**Files:** +- Modify: `backend/api/data.py` +- Modify: `backend/tests/test_data_api.py` + +**Interfaces:** +- Consumes: `data_room_package_manifest`, `data_room_release_summary`, `diligence_close_acceptance_summary`, `commercial_close_readiness_scorecard`, `commercial_close_execution_plan`, `commercial_close_kpi_operating_model`, `commercial_close_buyer_brief`, `commercial_close_signoff_matrix`, `privacy_redaction_policy`, and `verification_handoff` +- Produces: `commercial_close_release_package: DataCommercialCloseReleasePackage` + +- [x] Add `CommercialCloseReleaseArtifactStatus = Literal["ready", "blocked"]`. +- [x] Add `CommercialCloseReleasePackageStatus = Literal["release_ready", "release_blocked"]`. +- [x] Add `CommercialCloseReleaseArtifactGroup = Literal["core_evidence", "commercial_close", "buyer_diligence", "guardrail"]`. +- [x] Add `DataCommercialCloseReleaseArtifact` with artifact key, release order, file name, display name, artifact group, status, source field, required artifact, reviewer role, blocker keys, release instruction text, raw/stable exposure booleans, and write boundary. +- [x] Add `DataCommercialCloseReleasePackage` with target review metadata, release status, artifact counts, signoff counts, blocked artifact files, blocker keys, verifier command, buyer handoff, next action, artifacts, and write boundary. +- [x] Add `_default_commercial_close_release_package()`. +- [x] Add `_commercial_close_release_package(snapshot)` after `_commercial_close_signoff_matrix(snapshot)`. +- [x] Populate `commercial_close_release_package` before `_snapshot_digest_payload(snapshot)`. +- [x] Add `_expected_commercial_close_release_package()` and assert the exact object in `test_data_quality_evidence_snapshot_returns_shareable_redacted_surface`. +- [x] Assert `commercial_close_release_package` is present in `canonical_payload_fields`. + +Expected current fixture: +- status: `release_blocked` +- target review value: `2,000,000,000 KRW` +- artifacts: 10 release rows +- ready artifacts: 3 +- blocked artifacts: 7 +- signoffs: 3 signed off, 4 blocked +- provider write boundary: false + +### Task 2: Frontend Type And Release Package Card + +**Files:** +- Modify: `frontend/src/components/data-layout/types.ts` +- Modify: `frontend/src/components/data-layout/QualityCheckTab.tsx` +- Modify: `frontend/src/app/data/page.test.tsx` + +**Interfaces:** +- Consumes: `dataEvidenceSnapshot.commercial_close_release_package` +- Produces: an existing-style snapshot card titled `Commercial close release package` + +- [x] Add TypeScript types mirroring the backend release package contract. +- [x] Add a fixture `commercialCloseReleasePackage` with the backend expected values. +- [x] Add the package to `canonical_payload_fields` and `dataEvidenceSnapshot`. +- [x] Render the package after the signoff matrix using existing border/list/chip patterns. +- [x] Show status, target review value, artifact counts, signoff counts, blocked files, blocker keys, verifier command, buyer handoff, next action, row order, row files, source fields, reviewer roles, release instructions, privacy flags, and write boundary. +- [x] Assert visible text includes `Commercial close release package`, `commercial-close-signoff-matrix.json`, `commercial-close-buyer-brief.json`, `release_blocked`, `blocked artifacts`, and `python scripts/verify_evidence_snapshot.py `. +- [x] Assert copied JSON includes `commercial_close_release_package` exactly. + +### Task 3: FigJam Planning Update + +**Files:** +- Modify: this plan's evidence section after generation + +**Interfaces:** +- Consumes: current FigJam board `mjH0tpDIvz5kj44kL6354R` +- Produces: a new editable FigJam diagram for Phase 38 + +- [x] Generate a FigJam flowchart, not a Code Connect artifact. +- [x] Diagram: redacted evidence, diligence summaries, commercial-close scorecard/plan/KPI/brief/signoff, verifier, and buyer data-room release package. +- [x] Record the FigJam URL in this plan. + +### Task 4: Verification, Ponytail Review, Push + +**Files:** +- Modify: this plan's evidence section + +**Interfaces:** +- Consumes: local tests, lint, git diff, PR #901 state +- Produces: pushed commit on `plan/email-dom-paragraph-kg-2026-07-02` + +- [x] Run `python3 -m pytest backend/tests/test_data_api.py -q`. +- [x] Run `python3 -m ruff check backend/api/data.py backend/tests/test_data_api.py`. +- [x] Run `PATH=/opt/homebrew/opt/node@24/bin:$PATH /opt/homebrew/opt/node@24/bin/npm test -- src/app/data/page.test.tsx` from `frontend/`. +- [x] Run `PATH=/opt/homebrew/opt/node@24/bin:$PATH /opt/homebrew/opt/node@24/bin/npm run lint -- src/components/data-layout/QualityCheckTab.tsx src/components/data-layout/types.ts src/app/data/page.test.tsx` from `frontend/`. +- [x] Run `git diff --check`. +- [x] Run Ponytail review on the diff and record complexity verdict. +- [x] Commit only intended files. +- [x] Push to `origin HEAD:refs/heads/plan/email-dom-paragraph-kg-2026-07-02`. +- [x] Re-verify live PR #901 `headRefOid`, merge state, unresolved review thread count, and check state. + +## Evidence + +- FigJam: [Phase 38 Commercial Close Release Package](https://www.figma.com/board/mjH0tpDIvz5kj44kL6354R) generated without Figma Code Connect. +- Backend tests: `python3 -m pytest backend/tests/test_data_api.py -q` passed with 9 passed, 1 skipped. +- Backend ruff: `python3 -m ruff check backend/api/data.py backend/tests/test_data_api.py` passed. +- Frontend tests: `PATH=/opt/homebrew/opt/node@24/bin:$PATH /opt/homebrew/opt/node@24/bin/npm test -- src/app/data/page.test.tsx` passed with 1 file and 13 tests. +- Frontend lint: `PATH=/opt/homebrew/opt/node@24/bin:$PATH /opt/homebrew/opt/node@24/bin/npm run lint -- src/components/data-layout/QualityCheckTab.tsx src/components/data-layout/types.ts src/app/data/page.test.tsx` passed. +- Diff check: `git diff --check` passed. +- Ponytail: Lean already. Ship. The release package stays in the existing snapshot contract, adds no dependency, and avoids a premature library/submodule split. +- PR #901 live state after feature push: head `ba51e69cd37fc8284e6328db75c1b80869e8a778`, mergeable `MERGEABLE`, merge state `BLOCKED`, current unresolved review threads 0, outdated unresolved review threads 4, checks queued/pending and not treated as blockers for this phase. diff --git a/docs/superpowers/plans/2026-07-02-commercial-close-signoff-matrix.md b/docs/superpowers/plans/2026-07-02-commercial-close-signoff-matrix.md new file mode 100644 index 000000000..ed9dfc5af --- /dev/null +++ b/docs/superpowers/plans/2026-07-02-commercial-close-signoff-matrix.md @@ -0,0 +1,112 @@ +# Commercial Close Signoff Matrix Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Add a deterministic role-by-role commercial close signoff matrix to the redacted DOM-paragraph knowledge-graph evidence snapshot so a 2,000,000,000 KRW target buyer review can see which operating roles can sign off and which blockers prevent close. + +**Architecture:** Keep the signoff matrix inside `DataEvidenceSnapshotResponse` and derive it only from existing redacted snapshot fields. Do not add a new library, submodule, package split, route, dependency, or Figma Code Connect artifact in this phase; `backend/api/data.py` is large enough to justify a later internal split, but adding that split in the same PR would broaden the risk beyond this buyer-close artifact. + +**Tech Stack:** FastAPI/Pydantic backend, existing Data API snapshot contract, React/TypeScript Data Quality UI, Vitest, Pytest, Ruff, FigJam diagram generation. + +## Global Constraints + +- Figma Code Connect is not used. +- `target_contract_value_krw` is role signoff review metadata, not a valuation claim. +- The signoff matrix must not expose raw email bodies, raw HTML, attachment bytes, message IDs, attachment IDs, stable database IDs, provider credentials, or DB evidence column strings. +- The signoff matrix must be deterministic for the same snapshot inputs and included in `canonical_payload_fields`. +- Signoff rows must come from already-redacted snapshot fields and existing diligence contracts, not new data sources. +- Review process and queued GitHub checks are not blockers, but live PR head, unresolved review-thread count, and check state must be re-verified before completion. +- Preserve unrelated `.Jules/palette.md` and `.Jules/sentinel.md` edits. + +--- + +### Task 1: Backend Signoff Matrix Contract + +**Files:** +- Modify: `backend/api/data.py` +- Modify: `backend/tests/test_data_api.py` + +**Interfaces:** +- Consumes: `commercial_close_buyer_brief`, `commercial_close_kpi_operating_model`, `commercial_close_execution_plan`, `commercial_close_readiness_scorecard`, `data_room_release_summary`, `diligence_close_acceptance_summary`, `privacy_redaction_policy`, and `verification_handoff` +- Produces: `commercial_close_signoff_matrix: DataCommercialCloseSignoffMatrix` + +- [x] Add `CommercialCloseSignoffStatus = Literal["signed_off", "blocked"]`. +- [x] Add `CommercialCloseSignoffMatrixStatus = Literal["signoff_ready", "signoff_blocked"]`. +- [x] Add `DataCommercialCloseSignoffRow` with signoff key, reviewer role, owner area, status, source field, required artifact, blocker keys, acceptance text, next action, and write boundary. +- [x] Add `DataCommercialCloseSignoffMatrix` with target review metadata, matrix status, signoff counts, blocker keys, guardrail summary, reviewer handoff, next action, rows, and write boundary. +- [x] Add `_default_commercial_close_signoff_matrix()`. +- [x] Add `_commercial_close_signoff_matrix(snapshot)` after `_commercial_close_buyer_brief(snapshot)`. +- [x] Populate `commercial_close_signoff_matrix` before `_snapshot_digest_payload(snapshot)`. +- [x] Add `_expected_commercial_close_signoff_matrix()` and assert the exact object in `test_data_quality_evidence_snapshot_returns_shareable_redacted_surface`. +- [x] Assert `commercial_close_signoff_matrix` is present in `canonical_payload_fields`. + +Expected current fixture: +- status: `signoff_blocked` +- target review value: `2,000,000,000 KRW` +- required signoffs: 7 +- signed off: 3 +- blocked: 4 +- rows cover commercial diligence, program management, data-room operations, buyer diligence, privacy/security, verification, and security governance +- provider write boundary: false + +### Task 2: Frontend Type And Signoff Card + +**Files:** +- Modify: `frontend/src/components/data-layout/types.ts` +- Modify: `frontend/src/components/data-layout/QualityCheckTab.tsx` +- Modify: `frontend/src/app/data/page.test.tsx` + +**Interfaces:** +- Consumes: `dataEvidenceSnapshot.commercial_close_signoff_matrix` +- Produces: an existing-style snapshot card titled `Commercial close signoff matrix` + +- [x] Add TypeScript types mirroring the backend signoff matrix contract. +- [x] Add a fixture `commercialCloseSignoffMatrix` with the backend expected values. +- [x] Add the matrix to `canonical_payload_fields` and `dataEvidenceSnapshot`. +- [x] Render the matrix after the buyer brief using existing border/list/chip patterns. +- [x] Show status, target review value, signoff counts, blocker keys, guardrail summary, reviewer handoff, next action, row owners, source fields, artifacts, blocker keys, acceptance text, and write boundary. +- [x] Assert visible text includes `Commercial close signoff matrix`, `signoff_blocked`, `signoff_commercial_diligence`, `signoff_privacy_security`, `signoff_verification`, and `signoff_security_governance`. +- [x] Assert copied JSON includes `commercial_close_signoff_matrix` exactly. + +### Task 3: FigJam Planning Update + +**Files:** +- Modify: this plan's evidence section after generation + +**Interfaces:** +- Consumes: current FigJam board `mjH0tpDIvz5kj44kL6354R` +- Produces: a new editable FigJam diagram for Phase 37 + +- [x] Generate a FigJam flowchart, not a Code Connect artifact. +- [x] Diagram: buyer brief, KPI model, execution plan, scorecard, release summary, acceptance summary, privacy policy, and verifier feed the signoff matrix. +- [x] Record the FigJam URL in this plan. + +### Task 4: Verification, Ponytail Review, Push + +**Files:** +- Modify: this plan's evidence section + +**Interfaces:** +- Consumes: local tests, lint, git diff, PR #901 state +- Produces: pushed commit on `plan/email-dom-paragraph-kg-2026-07-02` + +- [x] Run `python3 -m pytest backend/tests/test_data_api.py -q`. +- [x] Run `python3 -m ruff check backend/api/data.py backend/tests/test_data_api.py`. +- [x] Run `PATH=/opt/homebrew/opt/node@24/bin:$PATH /opt/homebrew/opt/node@24/bin/npm test -- src/app/data/page.test.tsx` from `frontend/`. +- [x] Run `PATH=/opt/homebrew/opt/node@24/bin:$PATH /opt/homebrew/opt/node@24/bin/npm run lint -- src/components/data-layout/QualityCheckTab.tsx src/components/data-layout/types.ts src/app/data/page.test.tsx` from `frontend/`. +- [x] Run `git diff --check`. +- [x] Run Ponytail review on the diff and record complexity verdict. +- [x] Commit only intended files. +- [x] Push to `origin HEAD:refs/heads/plan/email-dom-paragraph-kg-2026-07-02`. +- [x] Re-verify live PR #901 `headRefOid`, merge state, unresolved review thread count, and check state. + +## Evidence + +- FigJam: [Phase 37 Commercial Close Signoff Matrix](https://www.figma.com/board/mjH0tpDIvz5kj44kL6354R) generated without Figma Code Connect. +- Backend tests: `python3 -m pytest backend/tests/test_data_api.py -q` -> 9 passed, 1 skipped. +- Backend ruff: `python3 -m ruff check backend/api/data.py backend/tests/test_data_api.py` -> all checks passed. +- Frontend tests: `PATH=/opt/homebrew/opt/node@24/bin:$PATH /opt/homebrew/opt/node@24/bin/npm test -- src/app/data/page.test.tsx` -> 1 file passed, 13 tests passed. +- Frontend lint: `PATH=/opt/homebrew/opt/node@24/bin:$PATH /opt/homebrew/opt/node@24/bin/npm run lint -- src/components/data-layout/QualityCheckTab.tsx src/components/data-layout/types.ts src/app/data/page.test.tsx` -> clean. +- Diff check: `git diff --check` -> clean. +- Ponytail: `Lean already. Ship.` +- PR #901 live state after push: open, `MERGEABLE`, `BLOCKED` by queued/pending checks; current unresolved review threads 0, outdated unresolved review threads 4. Queued GitHub checks are not treated as blockers per user instruction. diff --git a/docs/superpowers/plans/2026-07-02-data-room-release-summary.md b/docs/superpowers/plans/2026-07-02-data-room-release-summary.md new file mode 100644 index 000000000..8d5620030 --- /dev/null +++ b/docs/superpowers/plans/2026-07-02-data-room-release-summary.md @@ -0,0 +1,153 @@ +# Data Room Release Summary Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [x]`) syntax for tracking. + +**Goal:** Add a buyer data-room release summary to the redacted evidence snapshot so diligence reviewers can see whether the release bundle is safe to share and what still blocks close. + +**Architecture:** Derive the release summary from already-redacted snapshot fields: `data_room_package_manifest`, `privacy_redaction_policy`, `verification_handoff`, and `diligence_close_acceptance_summary`. Keep it inside `DataEvidenceSnapshotResponse`, include it in the tamper-evident digest, and render it in the existing Data Quality snapshot card before detailed manifest entries. + +**Tech Stack:** FastAPI, Pydantic, pytest, React, TypeScript, Vitest, existing DataLayout styles, FigJam. + +## Global Constraints + +- Do not use Figma Code Connect. +- Do not add dependencies, package splits, git submodules, provider writes, raw-content export, raw email bodies, raw HTML, attachment bytes, stable provider IDs, database IDs, credentials, or database evidence column strings. +- Preserve unrelated `.Jules/palette.md` and `.Jules/sentinel.md` worktree changes. +- Review process and queued GitHub checks are not blockers; failed local validation or failed live checks are actionable. +- Keep the summary deterministic and derived only from existing safe snapshot fields. + +--- + +### Task 1: Backend Release Summary Contract + +**Files:** +- Modify: `backend/api/data.py` +- Modify: `backend/tests/test_data_api.py` + +**Interfaces:** +- Produces `DataRoomReleaseSummary` +- Produces `data_room_release_summary: DataRoomReleaseSummary` on `DataEvidenceSnapshotResponse` +- Produces `_data_room_release_summary(snapshot: DataEvidenceSnapshotResponse) -> DataRoomReleaseSummary` + +- [x] **Step 1: Add expected backend fixture** + +Add `_expected_data_room_release_summary()` to `backend/tests/test_data_api.py` and assert: + +```python +{ + "release_key": "buyer_data_room_release", + "release_status": "release_blocked", + "total_artifact_count": 10, + "ready_artifact_count": 7, + "needs_attention_artifact_count": 3, + "required_for_close_count": 10, + "blocked_artifact_files": [ + "acquisition-readiness-summary.json", + "buyer-evidence-packet-checklist.json", + "remediation-actions.json", + ], + "privacy_exposure_count": 0, + "raw_content_exposure_count": 0, + "stable_identifier_exposure_count": 0, + "provider_credential_exposure_count": 0, + "snapshot_verification_required": True, + "verification_command": "python scripts/verify_evidence_snapshot.py ", + "acceptance_blocker_count": 9, + "acceptance_blocker_keys": [ + "exception_attach_kg_evidence_endpoints", + "exception_backfill_content_graph_coverage", + "exception_backfill_dedupe_fingerprints", + "exception_backfill_knowledge_graph_coverage", + "exception_backfill_semantic_relation_sources", + "exception_expand_attachment_parse_coverage", + "exception_recover_attachment_content", + "exception_repair_segment_text_readiness", + "exception_repair_thread_id_integrity", + ], + "buyer_summary_text": ( + "Data-room release remains blocked by 3 artifact(s), 9 blocker key(s), " + "and 0 privacy exposure(s)." + ), + "next_action_text": ( + "Resolve blocked artifact states, clear acceptance blockers, run the " + "offline verifier, and reissue the release bundle." + ), + "provider_write_executed": False, +} +``` + +- [x] **Step 2: Add backend model and helper** + +Add `DataRoomReleaseStatus = Literal["release_ready", "release_blocked"]`, `DataRoomReleaseSummary`, `_default_data_room_release_summary()`, and `_data_room_release_summary(snapshot)`. + +- [x] **Step 3: Include summary in digest** + +Populate `data_room_release_summary` after `diligence_close_acceptance_summary` and before `_snapshot_digest_payload(snapshot)`. + +- [x] **Step 4: Run backend validation** + +Run: + +```bash +python3 -m pytest backend/tests/test_data_api.py -q +python3 -m ruff check backend/api/data.py backend/tests/test_data_api.py +``` + +### Task 2: Frontend Release Summary Surface + +**Files:** +- Modify: `frontend/src/components/data-layout/types.ts` +- Modify: `frontend/src/components/data-layout/QualityCheckTab.tsx` +- Modify: `frontend/src/app/data/page.test.tsx` + +**Interfaces:** +- Consumes `dataEvidenceSnapshot.data_room_release_summary` +- Renders an existing-style snapshot card section titled `Data room release summary` + +- [x] **Step 1: Add TypeScript type and fixture** + +Mirror the backend fixture in `frontend/src/app/data/page.test.tsx` and add the response type in `frontend/src/components/data-layout/types.ts`. + +- [x] **Step 2: Render release summary** + +Show release status, buyer summary, next action, artifact readiness counts, privacy exposure counts, verification command, acceptance blocker count, blocked artifact chips, acceptance blocker chips, and write boundary. + +- [x] **Step 3: Assert UI and copied JSON** + +Assert visible text includes `Data room release summary`, `release_blocked`, `Data-room release remains blocked`, `blocked 3`, `privacy exposures 0`, `verify-evidence-snapshot.py`, `buyer-evidence-packet-checklist.json`, and `exception_attach_kg_evidence_endpoints`. Assert copied JSON includes `data_room_release_summary` exactly. + +- [x] **Step 4: Run frontend validation** + +Run: + +```bash +cd frontend && npm test -- src/app/data/page.test.tsx +cd frontend && npm run lint -- src/components/data-layout/QualityCheckTab.tsx src/components/data-layout/types.ts src/app/data/page.test.tsx +``` + +### Task 3: FigJam, Ponytail, PR Update + +**Files:** +- Modify: `docs/superpowers/plans/2026-07-02-data-room-release-summary.md` + +- [x] **Step 1: Generate FigJam flowchart** + +Add a Phase 32 flowchart to the existing FigJam board showing manifest, privacy policy, verifier, and acceptance summary rolling into release blocked or release ready. + +- [x] **Step 2: Run Ponytail diff review** + +Confirm the diff does not add dependencies, speculative package boundaries, or a separate library/submodule for one derived snapshot projection. + +- [x] **Step 3: Push and verify PR** + +Commit, push to `plan/email-dom-paragraph-kg-2026-07-02`, and verify live PR #901 head, unresolved review thread count, and check state. + +## Evidence + +- Backend validation: `python3 -m pytest backend/tests/test_data_api.py -q` passed with 9 passed and 1 skipped. +- Backend lint: `python3 -m ruff check backend/api/data.py backend/tests/test_data_api.py` passed. +- Frontend coverage: `npm test -- src/app/data/page.test.tsx` passed with 13 tests. +- Frontend lint: `npm run lint -- src/components/data-layout/QualityCheckTab.tsx src/components/data-layout/types.ts src/app/data/page.test.tsx` passed. +- FigJam: https://www.figma.com/board/mjH0tpDIvz5kj44kL6354R +- Ponytail complexity review: Lean already. Ship. +- Product/design decision: no separate library or submodule is warranted yet because this is a deterministic buyer handoff summary over existing safe snapshot fields. diff --git a/docs/superpowers/plans/2026-07-02-diligence-close-acceptance-checklist.md b/docs/superpowers/plans/2026-07-02-diligence-close-acceptance-checklist.md new file mode 100644 index 000000000..30dcd67fd --- /dev/null +++ b/docs/superpowers/plans/2026-07-02-diligence-close-acceptance-checklist.md @@ -0,0 +1,45 @@ +# Diligence Close Acceptance Checklist + +## Goal + +Add a deterministic buyer-close acceptance checklist to the redacted evidence snapshot so diligence reviewers can approve each safe DOM/paragraph, attachment, and knowledge-graph evidence artifact from the traceability map without receiving raw email bodies, raw attachment bytes, stable identifiers, provider credentials, or database evidence strings. + +## Scope + +- Keep the work inside the existing `backend/api/data.py` evidence snapshot contract and `frontend/src/components/data-layout` Data Quality UI. +- Do not create a separate library, package, git submodule, or Figma Code Connect integration for this phase; the checklist is a deterministic view over the existing traceability map and verifier handoff. +- Preserve unrelated `.Jules` working tree changes. +- Treat review process and queued GitHub checks as non-blocking per operator instruction. + +## Implementation Plan + +- [x] Add `diligence_close_acceptance_checklist` to the evidence snapshot response. +- [x] Derive acceptance entries from `diligence_close_traceability_map` plus `verification_handoff.verifier_command`. +- [x] Include acceptance key, trace key, data-room artifact, source field, owner area, reviewer roles, acceptance status, close gate status, blocker keys, acceptance criteria, verifier command, reviewer summary, next action, snapshot verification requirement, and write boundary. +- [x] Include the field in the canonical digest payload and backend fixture assertions. +- [x] Add a UI section after the traceability map and before the detailed proof plan. +- [x] Add frontend fixture, copied JSON, and visible rendering coverage. +- [x] Add the Phase 30 FigJam flow without Figma Code Connect. +- [x] Run backend tests, ruff, frontend tests, and frontend lint. + +## Acceptance Criteria + +- The first acceptance item links `trace_risk_critical_email_ingestion_acquisition_readiness_summary_json` to `acquisition-readiness-summary.json`, `acquisition_readiness_gate`, `email_ingestion`, and `executive diligence reviewer`. +- DOM paragraph acceptance is represented by `content_graph_evidence_samples` feeding `dom-paragraph-evidence-samples.json`. +- Knowledge graph acceptance is represented by `knowledge_graph_evidence_samples` feeding `knowledge-graph-evidence-samples.json`. +- Attachment remediation acceptance keeps `exception_expand_attachment_parse_coverage` visible as a blocker key. +- Every checklist entry has `provider_write_executed: false`. +- `canonical_payload_fields` includes `diligence_close_acceptance_checklist`. +- The copied evidence snapshot JSON includes the new acceptance checklist. +- The UI renders acceptance criteria, verifier command, close gate, blocker keys, reviewer roles, next action, snapshot verification, and write boundary. +- Local backend and frontend validations pass. + +## Evidence + +- Backend model/API: `diligence_close_acceptance_checklist` is derived deterministically from the traceability map before canonical digest generation. +- Backend coverage: `python3 -m pytest backend/tests/test_data_api.py -q` passed with 9 passed and 1 skipped. +- Backend lint: `ruff check backend/api/data.py backend/tests/test_data_api.py` passed. +- Frontend coverage: `npm test -- src/app/data/page.test.tsx` passed with 12 tests. +- Frontend lint: `npm run lint -- src/components/data-layout/QualityCheckTab.tsx src/components/data-layout/types.ts src/app/data/page.test.tsx` passed. +- FigJam: https://www.figma.com/board/mjH0tpDIvz5kj44kL6354R +- Product/design decision: no separate library or submodule is warranted yet because the acceptance checklist is a narrow deterministic projection of the existing snapshot contract and UI surface. diff --git a/docs/superpowers/plans/2026-07-02-diligence-close-acceptance-summary.md b/docs/superpowers/plans/2026-07-02-diligence-close-acceptance-summary.md new file mode 100644 index 000000000..0acd5518b --- /dev/null +++ b/docs/superpowers/plans/2026-07-02-diligence-close-acceptance-summary.md @@ -0,0 +1,47 @@ +# Diligence Close Acceptance Summary + +## Goal + +Add a deterministic buyer-close acceptance summary to the redacted evidence snapshot so acquisition reviewers can see the acceptance decision, required reviewer roles, data-room artifacts, blocker keys, verifier action, and write boundary without opening every checklist item. + +## Scope + +- Keep the work inside the existing `backend/api/data.py` evidence snapshot contract and `frontend/src/components/data-layout` Data Quality UI. +- Do not create a separate library, package, git submodule, or Figma Code Connect integration for this phase; the summary is a deterministic rollup over the existing acceptance checklist. +- Preserve unrelated `.Jules` working tree changes. +- Treat review process and queued GitHub checks as non-blocking per operator instruction. + +## Implementation Plan + +- [x] Add `DataDiligenceCloseAcceptanceSummary` to the evidence snapshot response. +- [x] Derive the summary from `diligence_close_acceptance_checklist` after the checklist is populated. +- [x] Include decision code, total/blocked/ready acceptance counts, reviewer roles, required artifacts, blocker keys, close gate, snapshot verification requirement, buyer summary, next action, and write boundary. +- [x] Include `diligence_close_acceptance_summary` in canonical payload fields and backend fixture assertions. +- [x] Add frontend TypeScript coverage and a Data Quality summary card before the detailed acceptance checklist. +- [x] Render reviewer role, required artifact, and blocker key chips using existing Data Quality card styles. +- [x] Extend frontend fixture, visible rendering assertions, and copied snapshot JSON assertions. +- [x] Add the Phase 31 FigJam flow without Figma Code Connect. +- [x] Run backend tests, ruff, frontend tests, frontend lint, and `git diff --check`. + +## Acceptance Criteria + +- The summary key is `buyer_close_acceptance`. +- `decision_code` is `close_blocked` when any acceptance checklist item is blocked; otherwise it is `ready_to_close`. +- `close_gate_status` mirrors the blocked/ready decision. +- The current evidence snapshot reports 6 total acceptance items, 6 blocked items, 0 ready items, 3 reviewer roles, 5 required artifacts, and 9 blocker keys. +- Required artifacts include `acquisition-readiness-summary.json`, `dom-paragraph-evidence-samples.json`, `knowledge-graph-evidence-samples.json`, `remediation-actions.json`, and `semantic-relation-evidence-samples.json`. +- Blocker keys include `exception_attach_kg_evidence_endpoints` and `exception_expand_attachment_parse_coverage`. +- `snapshot_verification_required` is true when any checklist item requires copied snapshot verification. +- `provider_write_executed` remains false. +- The UI renders the acceptance summary, buyer summary, verifier next action, counts, reviewer role chips, required artifact chips, blocker key chips, and write boundary. +- The copied evidence snapshot JSON includes the exact summary shape. + +## Evidence + +- Backend validation: `python3 -m pytest backend/tests/test_data_api.py -q` passed with 9 passed and 1 skipped. +- Backend lint: `python3 -m ruff check backend/api/data.py backend/tests/test_data_api.py` passed. +- Frontend coverage: `npm test -- src/app/data/page.test.tsx` passed with 12 tests. +- Frontend lint: `npm run lint -- src/components/data-layout/QualityCheckTab.tsx src/components/data-layout/types.ts src/app/data/page.test.tsx` passed. +- FigJam: https://www.figma.com/board/mjH0tpDIvz5kj44kL6354R +- Ponytail complexity review: no new dependency, package split, submodule, or speculative abstraction is warranted for this deterministic snapshot projection. +- Product/design decision: no separate library or submodule is warranted yet because the summary is a narrow deterministic projection of the existing snapshot contract and UI surface. diff --git a/frontend/src/app/data/page.test.tsx b/frontend/src/app/data/page.test.tsx index 49fe17a39..18d8da967 100644 --- a/frontend/src/app/data/page.test.tsx +++ b/frontend/src/app/data/page.test.tsx @@ -1013,6 +1013,1181 @@ const diligenceCloseTraceabilityMap = [ }, ]; +const diligenceCloseAcceptanceChecklist = diligenceCloseTraceabilityMap.map((item) => ({ + acceptance_key: `accept_${item.trace_key.replace(/^trace_/, "")}`, + trace_key: item.trace_key, + data_room_artifact: item.data_room_artifact, + source_field: item.source_field, + owner_area: item.owner_area, + reviewer_roles: item.buyer_review_roles, + acceptance_status: item.close_gate_status === "blocked" ? "blocked" : "ready_for_acceptance", + close_gate_status: item.close_gate_status, + blocker_keys: item.close_gate_status === "blocked" ? item.exception_keys : [], + acceptance_criteria: `Resolve ${item.exception_count} exception(s), regenerate ${item.data_room_artifact} from ${item.source_field}, and verify the copied snapshot digest before buyer acceptance.`, + verification_command: "python scripts/verify_evidence_snapshot.py ", + reviewer_evidence_summary: `${item.buyer_review_roles.join(", ")} review ${item.data_room_artifact} for ${item.owner_area}; ${item.trace_key} covers ${item.exception_count} exception(s).`, + next_action: item.next_action, + snapshot_verification_required: item.snapshot_verification_required, + provider_write_executed: false, +})); + +const diligenceCloseAcceptanceSummary = { + summary_key: "buyer_close_acceptance", + decision_code: "close_blocked", + total_acceptance_count: diligenceCloseAcceptanceChecklist.length, + blocked_acceptance_count: diligenceCloseAcceptanceChecklist.length, + ready_acceptance_count: 0, + reviewer_role_count: 3, + reviewer_roles: [ + "coverage reviewer", + "data quality reviewer", + "executive diligence reviewer", + ], + required_artifact_count: 5, + required_artifacts: [ + "acquisition-readiness-summary.json", + "dom-paragraph-evidence-samples.json", + "knowledge-graph-evidence-samples.json", + "remediation-actions.json", + "semantic-relation-evidence-samples.json", + ], + blocker_count: 9, + blocker_keys: [ + "exception_attach_kg_evidence_endpoints", + "exception_backfill_content_graph_coverage", + "exception_backfill_dedupe_fingerprints", + "exception_backfill_knowledge_graph_coverage", + "exception_backfill_semantic_relation_sources", + "exception_expand_attachment_parse_coverage", + "exception_recover_attachment_content", + "exception_repair_segment_text_readiness", + "exception_repair_thread_id_integrity", + ], + close_gate_status: "blocked", + snapshot_verification_required: true, + buyer_summary_text: "Buyer acceptance remains blocked by 6 item(s) across 5 artifact(s) and 9 blocker key(s).", + next_action_text: "Resolve blocker keys, regenerate the evidence snapshot, run the offline verifier, and reissue the acceptance checklist.", + provider_write_executed: false, +}; + +const dataRoomReleaseSummary = { + release_key: "buyer_data_room_release", + release_status: "release_blocked", + total_artifact_count: dataRoomPackageManifest.length, + ready_artifact_count: dataRoomPackageManifest.filter((item) => item.state_code === "ready").length, + needs_attention_artifact_count: dataRoomPackageManifest.filter((item) => item.state_code !== "ready").length, + required_for_close_count: dataRoomPackageManifest.filter((item) => item.required_for_close).length, + blocked_artifact_files: [ + "acquisition-readiness-summary.json", + "buyer-evidence-packet-checklist.json", + "remediation-actions.json", + ], + privacy_exposure_count: 0, + raw_content_exposure_count: 0, + stable_identifier_exposure_count: 0, + provider_credential_exposure_count: 0, + snapshot_verification_required: true, + verification_command: "python scripts/verify_evidence_snapshot.py ", + acceptance_blocker_count: diligenceCloseAcceptanceSummary.blocker_count, + acceptance_blocker_keys: diligenceCloseAcceptanceSummary.blocker_keys, + buyer_summary_text: "Data-room release remains blocked by 3 artifact(s), 9 blocker key(s), and 0 privacy exposure(s).", + next_action_text: "Resolve blocked artifact states, clear acceptance blockers, run the offline verifier, and reissue the release bundle.", + provider_write_executed: false, +}; + +const commercialCloseReadinessScorecard = { + scorecard_key: "commercial_close_readiness", + target_contract_value_krw: 2_000_000_000, + target_contract_label: "2,000,000,000 KRW", + status_code: "commercially_blocked", + total_score: 62, + max_score: 100, + category_scores: [ + { + category_key: "evidence_packet_integrity", + display_name: "Evidence packet integrity", + status_code: "needs_attention", + score: 14, + max_score: 15, + detail_text: "9 of 10 evidence packet checks are ready.", + }, + { + category_key: "data_room_release_integrity", + display_name: "Data room release integrity", + status_code: "needs_attention", + score: 14, + max_score: 20, + detail_text: "7 of 10 data-room artifacts are ready.", + }, + { + category_key: "buyer_acceptance_clearance", + display_name: "Buyer acceptance clearance", + status_code: "needs_attention", + score: 0, + max_score: 20, + detail_text: "9 acceptance blocker key(s) remain.", + }, + { + category_key: "privacy_boundary", + display_name: "Privacy boundary", + status_code: "ready", + score: 20, + max_score: 20, + detail_text: "0 privacy exposure(s) remain.", + }, + { + category_key: "offline_verification", + display_name: "Offline verification", + status_code: "ready", + score: 10, + max_score: 10, + detail_text: "Offline verifier contract is ready.", + }, + { + category_key: "product_kpi_attainment", + display_name: "Product KPI attainment", + status_code: "needs_attention", + score: 4, + max_score: 15, + detail_text: "9 KPI target gap(s) remain for buyer review.", + }, + ], + blocked_artifact_count: dataRoomReleaseSummary.needs_attention_artifact_count, + blocked_artifact_files: dataRoomReleaseSummary.blocked_artifact_files, + acceptance_blocker_count: diligenceCloseAcceptanceSummary.blocker_count, + acceptance_blocker_keys: diligenceCloseAcceptanceSummary.blocker_keys, + kpi_gap_count: 9, + kpi_gap_keys: [ + "attachment_content", + "attachment_parse_coverage", + "content_graph_coverage", + "content_segment_text_readiness", + "dedupe_fingerprint", + "knowledge_graph_coverage", + "knowledge_graph_evidence_endpoint_readiness", + "semantic_relation_source_backing", + "thread_id_integrity", + ], + privacy_exposure_count: 0, + verifier_ready: true, + release_status: "release_blocked", + close_gate_status: "blocked", + buyer_summary_text: "Commercial close remains blocked for 2,000,000,000 KRW target review: score 62/100 with 9 KPI gap(s), 9 acceptance blocker key(s), and 3 blocked data-room artifact(s).", + next_action_text: "Resolve KPI gaps and acceptance blockers, regenerate the data-room bundle, run the offline verifier, and reissue the buyer scorecard.", + provider_write_executed: false, +}; + +const commercialCloseExecutionPlan = { + plan_key: "commercial_close_execution_plan", + target_contract_value_krw: 2_000_000_000, + target_contract_label: "2,000,000,000 KRW", + status_code: "execution_blocked", + total_lane_count: 6, + blocked_lane_count: 6, + ready_lane_count: 0, + critical_lane_count: 1, + high_lane_count: 4, + medium_lane_count: 1, + related_artifact_count: 5, + related_artifacts: [ + "acquisition-readiness-summary.json", + "dom-paragraph-evidence-samples.json", + "knowledge-graph-evidence-samples.json", + "remediation-actions.json", + "semantic-relation-evidence-samples.json", + ], + total_action_count: 9, + kpi_gap_count: 9, + acceptance_blocker_count: 9, + verification_command: "python scripts/verify_evidence_snapshot.py ", + buyer_summary_text: "Commercial close execution remains blocked for 2,000,000,000 KRW target review: 6 lane(s), 9 action(s), and 5 artifact(s) require remediation.", + next_action_text: "Execute lanes in priority order, regenerate affected artifacts, run the offline verifier, and reissue the buyer scorecard.", + lanes: [ + { + lane_key: "lane_critical_email_ingestion_acquisition_readiness_summary_json", + execution_order: 1, + display_name: "Critical email_ingestion execution for acquisition-readiness-summary.json", + owner_area: "email_ingestion", + priority_code: "critical", + status_code: "blocked", + related_artifact: "acquisition-readiness-summary.json", + artifact_ready: false, + action_count: 2, + action_keys: [ + "repair_thread_id_integrity", + "backfill_dedupe_fingerprints", + ], + blocking_check_keys: [ + "thread_id_integrity", + "dedupe_fingerprint", + ], + acceptance_blocker_keys: [ + "exception_repair_thread_id_integrity", + "exception_backfill_dedupe_fingerprints", + ], + kpi_gap_keys: [ + "thread_id_integrity", + "dedupe_fingerprint", + ], + acceptance_criteria: "Resolve 2 action(s), regenerate acquisition-readiness-summary.json, run python scripts/verify_evidence_snapshot.py , and reissue the buyer scorecard.", + verification_command: "python scripts/verify_evidence_snapshot.py ", + next_action_text: "Run canonical threading repair for affected scoped emails. Backfill duplicate-detection fingerprints for scoped email records.", + provider_write_executed: false, + }, + { + lane_key: "lane_high_attachment_parsing_remediation_actions_json", + execution_order: 2, + display_name: "High attachment_parsing execution for remediation-actions.json", + owner_area: "attachment_parsing", + priority_code: "high", + status_code: "blocked", + related_artifact: "remediation-actions.json", + artifact_ready: false, + action_count: 1, + action_keys: ["recover_attachment_content"], + blocking_check_keys: ["attachment_content"], + acceptance_blocker_keys: ["exception_recover_attachment_content"], + kpi_gap_keys: ["attachment_content"], + acceptance_criteria: "Resolve 1 action(s), regenerate remediation-actions.json, run python scripts/verify_evidence_snapshot.py , and reissue the buyer scorecard.", + verification_command: "python scripts/verify_evidence_snapshot.py ", + next_action_text: "Re-run attachment extraction for scoped attachments with blank safe content.", + provider_write_executed: false, + }, + { + lane_key: "lane_high_content_graph_dom_paragraph_evidence_samples_json", + execution_order: 3, + display_name: "High content_graph execution for dom-paragraph-evidence-samples.json", + owner_area: "content_graph", + priority_code: "high", + status_code: "blocked", + related_artifact: "dom-paragraph-evidence-samples.json", + artifact_ready: true, + action_count: 2, + action_keys: [ + "backfill_content_graph_coverage", + "repair_segment_text_readiness", + ], + blocking_check_keys: [ + "content_graph_coverage", + "content_segment_text_readiness", + ], + acceptance_blocker_keys: [ + "exception_backfill_content_graph_coverage", + "exception_repair_segment_text_readiness", + ], + kpi_gap_keys: [ + "content_graph_coverage", + "content_segment_text_readiness", + ], + acceptance_criteria: "Resolve 2 action(s), regenerate dom-paragraph-evidence-samples.json, run python scripts/verify_evidence_snapshot.py , and reissue the buyer scorecard.", + verification_command: "python scripts/verify_evidence_snapshot.py ", + next_action_text: "Backfill DOM paragraph segmentation for unsegmented scoped emails. Rebuild affected content segments with safe text and word-count evidence.", + provider_write_executed: false, + }, + { + lane_key: "lane_high_knowledge_graph_knowledge_graph_evidence_samples_json", + execution_order: 4, + display_name: "High knowledge_graph execution for knowledge-graph-evidence-samples.json", + owner_area: "knowledge_graph", + priority_code: "high", + status_code: "blocked", + related_artifact: "knowledge-graph-evidence-samples.json", + artifact_ready: true, + action_count: 2, + action_keys: [ + "backfill_knowledge_graph_coverage", + "attach_kg_evidence_endpoints", + ], + blocking_check_keys: [ + "knowledge_graph_coverage", + "knowledge_graph_evidence_endpoint_readiness", + ], + acceptance_blocker_keys: [ + "exception_backfill_knowledge_graph_coverage", + "exception_attach_kg_evidence_endpoints", + ], + kpi_gap_keys: [ + "knowledge_graph_coverage", + "knowledge_graph_evidence_endpoint_readiness", + ], + acceptance_criteria: "Resolve 2 action(s), regenerate knowledge-graph-evidence-samples.json, run python scripts/verify_evidence_snapshot.py , and reissue the buyer scorecard.", + verification_command: "python scripts/verify_evidence_snapshot.py ", + next_action_text: "Persist deterministic knowledge graph edges for emails missing graph coverage. Attach source or target paragraph segment endpoints to affected KG edges.", + provider_write_executed: false, + }, + { + lane_key: "lane_high_semantic_kg_semantic_relation_evidence_samples_json", + execution_order: 5, + display_name: "High semantic_kg execution for semantic-relation-evidence-samples.json", + owner_area: "semantic_kg", + priority_code: "high", + status_code: "blocked", + related_artifact: "semantic-relation-evidence-samples.json", + artifact_ready: true, + action_count: 1, + action_keys: ["backfill_semantic_relation_sources"], + blocking_check_keys: ["semantic_relation_source_backing"], + acceptance_blocker_keys: ["exception_backfill_semantic_relation_sources"], + kpi_gap_keys: ["semantic_relation_source_backing"], + acceptance_criteria: "Resolve 1 action(s), regenerate semantic-relation-evidence-samples.json, run python scripts/verify_evidence_snapshot.py , and reissue the buyer scorecard.", + verification_command: "python scripts/verify_evidence_snapshot.py ", + next_action_text: "Backfill source message or thread links for semantic relation records.", + provider_write_executed: false, + }, + { + lane_key: "lane_medium_attachment_parsing_remediation_actions_json", + execution_order: 6, + display_name: "Medium attachment_parsing execution for remediation-actions.json", + owner_area: "attachment_parsing", + priority_code: "medium", + status_code: "blocked", + related_artifact: "remediation-actions.json", + artifact_ready: false, + action_count: 1, + action_keys: ["expand_attachment_parse_coverage"], + blocking_check_keys: ["attachment_parse_coverage"], + acceptance_blocker_keys: ["exception_expand_attachment_parse_coverage"], + kpi_gap_keys: ["attachment_parse_coverage"], + acceptance_criteria: "Resolve 1 action(s), regenerate remediation-actions.json, run python scripts/verify_evidence_snapshot.py , and reissue the buyer scorecard.", + verification_command: "python scripts/verify_evidence_snapshot.py ", + next_action_text: "Add parser coverage or metadata-only exception evidence for unsupported attachment types.", + provider_write_executed: false, + }, + ], + provider_write_executed: false, +}; + +const commercialCloseKpiOperatingModel = { + model_key: "commercial_close_kpi_operating_model", + target_contract_value_krw: 2_000_000_000, + target_contract_label: "2,000,000,000 KRW", + status_code: "operating_blocked", + primary_metric_key: "commercial_close_readiness_score", + total_metric_count: 8, + target_met_metric_count: 3, + needs_attention_metric_count: 5, + primary_metric_count: 1, + driver_metric_count: 4, + guardrail_metric_count: 3, + blocked_metric_keys: [ + "commercial_close_readiness_score", + "execution_lane_clearance", + "data_room_artifact_readiness", + "buyer_acceptance_clearance", + "product_kpi_attainment", + ], + guardrail_breach_count: 0, + buyer_summary_text: "Commercial close KPI operating model remains blocked for 2,000,000,000 KRW target review: 5 of 8 metric(s) need attention and 0 guardrail breach(es) remain.", + next_action_text: "Use the blocked KPI list to sequence execution lanes, regenerate artifacts, rerun verification, and reissue the buyer scorecard.", + metrics: [ + { + metric_key: "commercial_close_readiness_score", + display_name: "Commercial close readiness score", + metric_kind: "primary", + status_code: "needs_attention", + current_value: 62, + target_value: 100, + unit_label: "score", + source_field: "commercial_close_readiness_scorecard.total_score", + owner_area: "commercial_diligence", + buyer_implication: "2,000,000,000 KRW review remains blocked until the readiness score reaches 100 and blockers clear.", + next_action_text: "Resolve KPI gaps and acceptance blockers, regenerate the data-room bundle, run the offline verifier, and reissue the buyer scorecard.", + provider_write_executed: false, + }, + { + metric_key: "execution_lane_clearance", + display_name: "Execution lane clearance", + metric_kind: "driver", + status_code: "needs_attention", + current_value: 0, + target_value: 6, + unit_label: "lane", + source_field: "commercial_close_execution_plan.ready_lane_count", + owner_area: "program_management", + buyer_implication: "Buyer review needs every commercial close execution lane cleared.", + next_action_text: "Execute lanes in priority order, regenerate affected artifacts, run the offline verifier, and reissue the buyer scorecard.", + provider_write_executed: false, + }, + { + metric_key: "data_room_artifact_readiness", + display_name: "Data-room artifact readiness", + metric_kind: "driver", + status_code: "needs_attention", + current_value: 7, + target_value: 10, + unit_label: "artifact", + source_field: "data_room_release_summary.ready_artifact_count", + owner_area: "data_room_ops", + buyer_implication: "All required data-room artifacts must be ready before buyer release.", + next_action_text: "Resolve blocked artifact states, clear acceptance blockers, run the offline verifier, and reissue the release bundle.", + provider_write_executed: false, + }, + { + metric_key: "buyer_acceptance_clearance", + display_name: "Buyer acceptance clearance", + metric_kind: "driver", + status_code: "needs_attention", + current_value: 0, + target_value: 6, + unit_label: "acceptance", + source_field: "diligence_close_acceptance_summary.ready_acceptance_count", + owner_area: "buyer_diligence", + buyer_implication: "Buyer acceptance cannot close while acceptance items remain blocked.", + next_action_text: "Resolve blocker keys, regenerate the evidence snapshot, run the offline verifier, and reissue the acceptance checklist.", + provider_write_executed: false, + }, + { + metric_key: "product_kpi_attainment", + display_name: "Product KPI attainment", + metric_kind: "driver", + status_code: "needs_attention", + current_value: 3, + target_value: 12, + unit_label: "kpi", + source_field: "acquisition_readiness_gate.kpis", + owner_area: "data_quality", + buyer_implication: "Product evidence KPIs must meet target before close readiness can be claimed.", + next_action_text: "Resolve critical and high remediation actions, then regenerate the diligence evidence snapshot.", + provider_write_executed: false, + }, + { + metric_key: "privacy_exposure_control", + display_name: "Privacy exposure control", + metric_kind: "guardrail", + status_code: "target_met", + current_value: 0, + target_value: 0, + unit_label: "exposure", + source_field: "data_room_release_summary.privacy_exposure_count", + owner_area: "privacy_security", + buyer_implication: "Buyer package must keep raw content, stable IDs, and credentials out.", + next_action_text: "Keep the redaction policy enforced for every snapshot.", + provider_write_executed: false, + }, + { + metric_key: "offline_verifier_contract", + display_name: "Offline verifier contract", + metric_kind: "guardrail", + status_code: "target_met", + current_value: 1, + target_value: 1, + unit_label: "contract", + source_field: "verification_handoff.verifier_command", + owner_area: "verification", + buyer_implication: "Buyer reviewers need a repeatable offline verifier for copied JSON.", + next_action_text: "Save the copied evidence snapshot JSON and verify it with the offline verifier before sharing diligence materials.", + provider_write_executed: false, + }, + { + metric_key: "provider_write_boundary", + display_name: "Provider write boundary", + metric_kind: "guardrail", + status_code: "target_met", + current_value: 0, + target_value: 0, + unit_label: "write", + source_field: "provider_write_executed", + owner_area: "security_governance", + buyer_implication: "Diligence evidence must remain read-only until explicit provider write approval.", + next_action_text: "Keep buyer evidence generation read-only.", + provider_write_executed: false, + }, + ], + provider_write_executed: false, +}; + +const commercialCloseBuyerBrief = { + brief_key: "commercial_close_buyer_brief", + target_contract_value_krw: 2_000_000_000, + target_contract_label: "2,000,000,000 KRW", + status_code: "brief_blocked", + readiness_headline_text: "Commercial close remains blocked: readiness score 62/100, 5 KPI operating metric(s), 6 execution lane(s), and 9 exception(s) require attention.", + proof_thesis_text: "Naruon can package redacted DOM, paragraph, knowledge-graph, semantic relation, data-room, KPI, and offline verifier evidence for buyer review without exposing raw content, stable IDs, provider credentials, or provider writes.", + evidence_basis_bullets: [ + { + bullet_key: "buyer_brief_readiness_score", + display_name: "Commercial readiness score", + source_field: "commercial_close_readiness_scorecard.total_score", + detail_text: "Commercial readiness is 62/100 for 2,000,000,000 KRW target review; status is commercially_blocked.", + provider_write_executed: false, + }, + { + bullet_key: "buyer_brief_data_room_release", + display_name: "Data-room release", + source_field: "data_room_release_summary.ready_artifact_count", + detail_text: "Data-room release has 7/10 artifact(s) ready and 3 blocked artifact(s).", + provider_write_executed: false, + }, + { + bullet_key: "buyer_brief_acceptance_clearance", + display_name: "Buyer acceptance clearance", + source_field: "diligence_close_acceptance_summary.ready_acceptance_count", + detail_text: "Buyer acceptance has 0/6 acceptance item(s) ready with 9 blocker key(s).", + provider_write_executed: false, + }, + { + bullet_key: "buyer_brief_kpi_operating_model", + display_name: "KPI operating model", + source_field: "commercial_close_kpi_operating_model.target_met_metric_count", + detail_text: "KPI operating model has 3/8 metric(s) at target and 0 guardrail breach(es).", + provider_write_executed: false, + }, + { + bullet_key: "buyer_brief_offline_verifier", + display_name: "Offline verifier", + source_field: "verification_handoff.verifier_command", + detail_text: "Copied snapshot JSON can be verified with python scripts/verify_evidence_snapshot.py .", + provider_write_executed: false, + }, + ], + blocker_bullets: [ + { + bullet_key: "buyer_brief_blocker_exception_repair_thread_id_integrity", + display_name: "Canonical thread repair", + source_field: "quality_checks.thread_id_integrity", + detail_text: "critical blocker owned by email_ingestion for acquisition-readiness-summary.json: Run canonical threading repair for affected scoped emails.", + provider_write_executed: false, + }, + { + bullet_key: "buyer_brief_blocker_exception_backfill_dedupe_fingerprints", + display_name: "Duplicate fingerprint backfill", + source_field: "quality_checks.dedupe_fingerprint", + detail_text: "critical blocker owned by email_ingestion for acquisition-readiness-summary.json: Backfill duplicate-detection fingerprints for scoped email records.", + provider_write_executed: false, + }, + { + bullet_key: "buyer_brief_blocker_exception_recover_attachment_content", + display_name: "Attachment content extraction", + source_field: "quality_checks.attachment_content", + detail_text: "high blocker owned by attachment_parsing for remediation-actions.json: Re-run attachment extraction for scoped attachments with blank safe content.", + provider_write_executed: false, + }, + { + bullet_key: "buyer_brief_blocker_exception_backfill_content_graph_coverage", + display_name: "DOM paragraph segmentation backfill", + source_field: "quality_checks.content_graph_coverage", + detail_text: "high blocker owned by content_graph for dom-paragraph-evidence-samples.json: Backfill DOM paragraph segmentation for unsegmented scoped emails.", + provider_write_executed: false, + }, + { + bullet_key: "buyer_brief_blocker_exception_backfill_knowledge_graph_coverage", + display_name: "Knowledge graph edge persistence", + source_field: "quality_checks.knowledge_graph_coverage", + detail_text: "high blocker owned by knowledge_graph for knowledge-graph-evidence-samples.json: Persist deterministic knowledge graph edges for emails missing graph coverage.", + provider_write_executed: false, + }, + ], + guardrail_bullets: [ + { + bullet_key: "buyer_brief_privacy_redaction", + display_name: "Privacy redaction", + source_field: "privacy_redaction_policy", + detail_text: "Privacy policy exposes raw content: no, stable IDs: no, provider credentials: no.", + provider_write_executed: false, + }, + { + bullet_key: "buyer_brief_data_room_exposure", + display_name: "Data-room exposure controls", + source_field: "data_room_release_summary.privacy_exposure_count", + detail_text: "Data-room summary reports 0 privacy exposure(s), 0 raw content exposure(s), 0 stable ID exposure(s), and 0 credential exposure(s).", + provider_write_executed: false, + }, + { + bullet_key: "buyer_brief_provider_write_boundary", + display_name: "Provider write boundary", + source_field: "provider_write_executed", + detail_text: "Provider write execution count is 0; buyer evidence generation remains read-only.", + provider_write_executed: false, + }, + { + bullet_key: "buyer_brief_snapshot_verifier", + display_name: "Snapshot verifier", + source_field: "verification_handoff", + detail_text: "Snapshot verification is required: yes; command python scripts/verify_evidence_snapshot.py .", + provider_write_executed: false, + }, + ], + reviewer_handoff_text: "Buyer reviewers should start from commercial_close_buyer_brief, verify copied JSON with python scripts/verify_evidence_snapshot.py , then review 5 blocker bullet(s) before release.", + next_action_text: "Resolve top blocker bullets, rerun parser and graph remediation, regenerate the snapshot, rerun the offline verifier, and reissue the buyer brief.", + provider_write_executed: false, +}; + +const commercialCloseSignoffRows = [ + { + signoff_key: "signoff_commercial_diligence", + reviewer_role: "commercial diligence reviewer", + owner_area: "commercial_diligence", + status_code: "blocked", + source_field: "commercial_close_buyer_brief.status_code", + required_artifact: "commercial-close-buyer-brief.json", + blocker_keys: commercialCloseBuyerBrief.blocker_bullets.map((bullet) => bullet.bullet_key), + acceptance_text: "Buyer brief is accepted when status is brief_ready and top blocker bullets are cleared.", + next_action_text: commercialCloseBuyerBrief.next_action_text, + provider_write_executed: false, + }, + { + signoff_key: "signoff_program_management", + reviewer_role: "program manager", + owner_area: "program_management", + status_code: "blocked", + source_field: "commercial_close_execution_plan.status_code", + required_artifact: "commercial-close-execution-plan.json", + blocker_keys: commercialCloseExecutionPlan.lanes + .filter((lane) => lane.status_code !== "ready") + .slice(0, 5) + .map((lane) => lane.lane_key), + acceptance_text: "Execution plan is accepted when every lane is ready and the plan status is execution_ready.", + next_action_text: commercialCloseExecutionPlan.next_action_text, + provider_write_executed: false, + }, + { + signoff_key: "signoff_data_room_ops", + reviewer_role: "data-room operations reviewer", + owner_area: "data_room_ops", + status_code: "blocked", + source_field: "data_room_release_summary.release_status", + required_artifact: "buyer-data-room-release.json", + blocker_keys: dataRoomReleaseSummary.blocked_artifact_files.slice(0, 5), + acceptance_text: "Data-room release is accepted when release_status is release_ready and all required artifacts are ready.", + next_action_text: dataRoomReleaseSummary.next_action_text, + provider_write_executed: false, + }, + { + signoff_key: "signoff_buyer_diligence", + reviewer_role: "buyer diligence reviewer", + owner_area: "buyer_diligence", + status_code: "blocked", + source_field: "diligence_close_acceptance_summary.decision_code", + required_artifact: "buyer-acceptance-checklist.json", + blocker_keys: diligenceCloseAcceptanceSummary.blocker_keys.slice(0, 5), + acceptance_text: "Buyer diligence is accepted when decision_code is ready_to_close and no acceptance blocker keys remain.", + next_action_text: diligenceCloseAcceptanceSummary.next_action_text, + provider_write_executed: false, + }, + { + signoff_key: "signoff_privacy_security", + reviewer_role: "privacy/security reviewer", + owner_area: "privacy_security", + status_code: "signed_off", + source_field: "privacy_redaction_policy", + required_artifact: "redacted-snapshot-policy.json", + blocker_keys: [], + acceptance_text: "Privacy guardrail is accepted when raw content, stable IDs, credentials, and data-room privacy exposures are zero.", + next_action_text: "Keep redaction guardrails enforced before buyer release.", + provider_write_executed: false, + }, + { + signoff_key: "signoff_verification", + reviewer_role: "verification reviewer", + owner_area: "verification", + status_code: "signed_off", + source_field: "verification_handoff.verifier_command", + required_artifact: "verify-evidence-snapshot.py", + blocker_keys: [], + acceptance_text: "Verification is accepted when the offline verifier command and snapshot verification requirement are present.", + next_action_text: "Save copied snapshot JSON and run python scripts/verify_evidence_snapshot.py .", + provider_write_executed: false, + }, + { + signoff_key: "signoff_security_governance", + reviewer_role: "security governance reviewer", + owner_area: "security_governance", + status_code: "signed_off", + source_field: "provider_write_executed", + required_artifact: "read-only-evidence-boundary", + blocker_keys: [], + acceptance_text: "Security governance is accepted when provider_write_executed is false across the buyer evidence snapshot.", + next_action_text: "Keep provider write execution disabled until explicit approval.", + provider_write_executed: false, + }, +]; + +const commercialCloseSignoffBlockerKeys = Array.from( + new Set( + commercialCloseSignoffRows + .filter((signoff) => signoff.status_code === "blocked") + .flatMap((signoff) => signoff.blocker_keys), + ), +); + +const commercialCloseSignoffMatrix = { + matrix_key: "commercial_close_signoff_matrix", + target_contract_value_krw: 2_000_000_000, + target_contract_label: "2,000,000,000 KRW", + status_code: "signoff_blocked", + required_signoff_count: 7, + signed_off_count: 3, + blocked_signoff_count: 4, + blocker_key_count: commercialCloseSignoffBlockerKeys.length, + blocker_keys: commercialCloseSignoffBlockerKeys.slice(0, 8), + guardrail_summary_text: "Privacy, offline verification, and provider write guardrails are signed off; 4 role signoff(s) remain blocked.", + reviewer_handoff_text: "Route blocked signoffs to commercial diligence reviewer, program manager, data-room operations reviewer, buyer diligence reviewer before buyer release.", + next_action_text: "Resolve blocked signoff rows, regenerate the evidence snapshot, rerun the offline verifier, and reissue the signoff matrix.", + signoffs: commercialCloseSignoffRows, + provider_write_executed: false, +}; + +const commercialCloseReleaseArtifacts = [ + { + artifact_key: "release_evidence_snapshot", + release_order: 1, + file_name: "naruon-evidence-snapshot.json", + display_name: "Canonical evidence snapshot", + artifact_group: "core_evidence", + status_code: "ready", + source_field: "snapshot_version,snapshot_digest,canonical_payload_fields", + required_artifact: "naruon-evidence-snapshot.json", + reviewer_role: "buyer diligence reviewer", + blocker_keys: [], + release_instruction_text: "Start buyer review from the canonical redacted snapshot JSON.", + contains_raw_content: false, + contains_stable_identifiers: false, + contains_provider_credentials: false, + provider_write_executed: false, + }, + { + artifact_key: "release_privacy_policy", + release_order: 2, + file_name: "privacy-redaction-policy.json", + display_name: "Privacy redaction policy", + artifact_group: "guardrail", + status_code: "ready", + source_field: "privacy_redaction_policy", + required_artifact: "privacy-redaction-policy.json", + reviewer_role: "privacy/security reviewer", + blocker_keys: [], + release_instruction_text: "Confirm raw content, stable identifiers, and credentials are absent.", + contains_raw_content: false, + contains_stable_identifiers: false, + contains_provider_credentials: false, + provider_write_executed: false, + }, + { + artifact_key: "release_offline_verifier", + release_order: 3, + file_name: "verify-evidence-snapshot.py", + display_name: "Offline evidence verifier", + artifact_group: "guardrail", + status_code: "ready", + source_field: "verification_handoff.verifier_command", + required_artifact: "verify-evidence-snapshot.py", + reviewer_role: "verification reviewer", + blocker_keys: [], + release_instruction_text: "Run the verifier against copied snapshot JSON before sharing.", + contains_raw_content: false, + contains_stable_identifiers: false, + contains_provider_credentials: false, + provider_write_executed: false, + }, + { + artifact_key: "release_data_room_summary", + release_order: 4, + file_name: "buyer-data-room-release.json", + display_name: "Buyer data-room release summary", + artifact_group: "buyer_diligence", + status_code: "blocked", + source_field: "data_room_release_summary.release_status", + required_artifact: "buyer-data-room-release.json", + reviewer_role: "data-room operations reviewer", + blocker_keys: dataRoomReleaseSummary.blocked_artifact_files.slice(0, 5), + release_instruction_text: "Confirm all buyer data-room artifacts are ready for close.", + contains_raw_content: false, + contains_stable_identifiers: false, + contains_provider_credentials: false, + provider_write_executed: false, + }, + { + artifact_key: "release_acceptance_checklist", + release_order: 5, + file_name: "buyer-acceptance-checklist.json", + display_name: "Buyer acceptance checklist", + artifact_group: "buyer_diligence", + status_code: "blocked", + source_field: "diligence_close_acceptance_summary.decision_code", + required_artifact: "buyer-acceptance-checklist.json", + reviewer_role: "buyer diligence reviewer", + blocker_keys: diligenceCloseAcceptanceSummary.blocker_keys.slice(0, 5), + release_instruction_text: "Resolve acceptance blockers before buyer close acceptance.", + contains_raw_content: false, + contains_stable_identifiers: false, + contains_provider_credentials: false, + provider_write_executed: false, + }, + { + artifact_key: "release_readiness_scorecard", + release_order: 6, + file_name: "commercial-close-readiness-scorecard.json", + display_name: "Commercial close readiness scorecard", + artifact_group: "commercial_close", + status_code: "blocked", + source_field: "commercial_close_readiness_scorecard.status_code", + required_artifact: "commercial-close-readiness-scorecard.json", + reviewer_role: "commercial diligence reviewer", + blocker_keys: [ + ...commercialCloseReadinessScorecard.kpi_gap_keys, + ...commercialCloseReadinessScorecard.acceptance_blocker_keys, + ...commercialCloseReadinessScorecard.blocked_artifact_files, + ].slice(0, 5), + release_instruction_text: "Review readiness score and blocker clearance for target review.", + contains_raw_content: false, + contains_stable_identifiers: false, + contains_provider_credentials: false, + provider_write_executed: false, + }, + { + artifact_key: "release_execution_plan", + release_order: 7, + file_name: "commercial-close-execution-plan.json", + display_name: "Commercial close execution plan", + artifact_group: "commercial_close", + status_code: "blocked", + source_field: "commercial_close_execution_plan.status_code", + required_artifact: "commercial-close-execution-plan.json", + reviewer_role: "program manager", + blocker_keys: commercialCloseExecutionPlan.lanes + .filter((lane) => lane.status_code !== "ready") + .slice(0, 5) + .map((lane) => lane.lane_key), + release_instruction_text: "Execute blocked lanes before reissuing the commercial package.", + contains_raw_content: false, + contains_stable_identifiers: false, + contains_provider_credentials: false, + provider_write_executed: false, + }, + { + artifact_key: "release_kpi_operating_model", + release_order: 8, + file_name: "commercial-close-kpi-operating-model.json", + display_name: "Commercial close KPI operating model", + artifact_group: "commercial_close", + status_code: "blocked", + source_field: "commercial_close_kpi_operating_model.status_code", + required_artifact: "commercial-close-kpi-operating-model.json", + reviewer_role: "commercial diligence reviewer", + blocker_keys: commercialCloseKpiOperatingModel.blocked_metric_keys.slice(0, 5), + release_instruction_text: "Verify all operating KPIs hit target before buyer package release.", + contains_raw_content: false, + contains_stable_identifiers: false, + contains_provider_credentials: false, + provider_write_executed: false, + }, + { + artifact_key: "release_buyer_brief", + release_order: 9, + file_name: "commercial-close-buyer-brief.json", + display_name: "Commercial close buyer brief", + artifact_group: "commercial_close", + status_code: "blocked", + source_field: "commercial_close_buyer_brief.status_code", + required_artifact: "commercial-close-buyer-brief.json", + reviewer_role: "commercial diligence reviewer", + blocker_keys: commercialCloseBuyerBrief.blocker_bullets.map((bullet) => bullet.bullet_key), + release_instruction_text: "Use the buyer brief as the narrative index for close reviewers.", + contains_raw_content: false, + contains_stable_identifiers: false, + contains_provider_credentials: false, + provider_write_executed: false, + }, + { + artifact_key: "release_signoff_matrix", + release_order: 10, + file_name: "commercial-close-signoff-matrix.json", + display_name: "Commercial close signoff matrix", + artifact_group: "commercial_close", + status_code: "blocked", + source_field: "commercial_close_signoff_matrix.status_code", + required_artifact: "commercial-close-signoff-matrix.json", + reviewer_role: "commercial diligence reviewer", + blocker_keys: commercialCloseSignoffMatrix.blocker_keys.slice(0, 5), + release_instruction_text: "Confirm role signoffs before issuing the buyer release package.", + contains_raw_content: false, + contains_stable_identifiers: false, + contains_provider_credentials: false, + provider_write_executed: false, + }, +]; + +const commercialCloseReleaseBlockedArtifacts = commercialCloseReleaseArtifacts.filter( + (artifact) => artifact.status_code === "blocked", +); + +const commercialCloseReleaseBlockerKeys = Array.from( + new Set(commercialCloseReleaseBlockedArtifacts.flatMap((artifact) => artifact.blocker_keys)), +); + +const commercialCloseReleasePackage = { + package_key: "commercial_close_release_package", + target_contract_value_krw: 2_000_000_000, + target_contract_label: "2,000,000,000 KRW", + status_code: "release_blocked", + total_artifact_count: commercialCloseReleaseArtifacts.length, + ready_artifact_count: commercialCloseReleaseArtifacts.length - commercialCloseReleaseBlockedArtifacts.length, + blocked_artifact_count: commercialCloseReleaseBlockedArtifacts.length, + signed_off_count: commercialCloseSignoffMatrix.signed_off_count, + blocked_signoff_count: commercialCloseSignoffMatrix.blocked_signoff_count, + blocker_key_count: commercialCloseReleaseBlockerKeys.length, + blocked_artifact_files: commercialCloseReleaseBlockedArtifacts.map((artifact) => artifact.file_name), + blocker_keys: commercialCloseReleaseBlockerKeys.slice(0, 10), + first_release_file_name: "naruon-evidence-snapshot.json", + verification_command: "python scripts/verify_evidence_snapshot.py ", + buyer_handoff_text: "Commercial close release package remains blocked for 2,000,000,000 KRW target review: 7 artifact(s) need remediation.", + next_action_text: "Resolve blocked release artifacts, regenerate the evidence snapshot, rerun the offline verifier, and reissue the release package.", + artifacts: commercialCloseReleaseArtifacts, + provider_write_executed: false, +}; + +const commercialCloseReleaseArtifactByKey = Object.fromEntries( + commercialCloseReleaseArtifacts.map((artifact) => [artifact.artifact_key, artifact]), +); + +const makeCommercialCloseBuyerReviewStep = ({ + step_key, + review_order, + lane, + artifact_key, + source_field, + reviewer_role, + owner_area, + sla_hours, + review_day, + entry_criteria_text, + exit_criteria_text, +}: { + step_key: string; + review_order: number; + lane: string; + artifact_key: string; + source_field: string; + reviewer_role: string; + owner_area: string; + sla_hours: number; + review_day: number; + entry_criteria_text: string; + exit_criteria_text: string; +}) => { + const artifact = commercialCloseReleaseArtifactByKey[artifact_key]; + const ready = artifact?.status_code === "ready"; + return { + step_key, + review_order, + lane, + status_code: ready ? "ready" : "blocked", + evidence_file_name: artifact?.file_name ?? "", + source_field, + reviewer_role, + owner_area, + sla_hours, + review_day, + entry_criteria_text, + exit_criteria_text, + blocker_keys: ready ? [] : (artifact?.blocker_keys ?? [`${artifact_key}_missing`]), + contains_raw_content: false, + contains_stable_identifiers: false, + contains_provider_credentials: false, + provider_write_executed: false, + }; +}; + +const commercialCloseBuyerReviewBaseSteps = [ + { + step_key: "buyer_review_intake", + review_order: 1, + lane: "intake", + status_code: "ready", + evidence_file_name: commercialCloseReleasePackage.first_release_file_name, + source_field: "commercial_close_release_package.first_release_file_name", + reviewer_role: "buyer diligence lead", + owner_area: "data_room_ops", + sla_hours: 4, + review_day: 1, + entry_criteria_text: "Open the verified release package and confirm buyer review scope.", + exit_criteria_text: "Buyer review starts from the canonical evidence snapshot file.", + blocker_keys: [], + contains_raw_content: false, + contains_stable_identifiers: false, + contains_provider_credentials: false, + provider_write_executed: false, + }, + makeCommercialCloseBuyerReviewStep({ + step_key: "buyer_review_snapshot_verification", + review_order: 2, + lane: "verification", + artifact_key: "release_offline_verifier", + source_field: "commercial_close_release_package.artifacts.release_offline_verifier", + reviewer_role: "verification reviewer", + owner_area: "verification", + sla_hours: 4, + review_day: 1, + entry_criteria_text: "Run the offline verifier against copied snapshot JSON.", + exit_criteria_text: "Verifier exits successfully before evidence review starts.", + }), + makeCommercialCloseBuyerReviewStep({ + step_key: "buyer_review_privacy_redaction", + review_order: 3, + lane: "privacy", + artifact_key: "release_privacy_policy", + source_field: "commercial_close_release_package.artifacts.release_privacy_policy", + reviewer_role: "privacy/security reviewer", + owner_area: "security_governance", + sla_hours: 8, + review_day: 1, + entry_criteria_text: "Inspect redaction policy before opening data-room files.", + exit_criteria_text: "Raw content, stable identifiers, and credentials are absent.", + }), + makeCommercialCloseBuyerReviewStep({ + step_key: "buyer_review_data_room_release", + review_order: 4, + lane: "data_room", + artifact_key: "release_data_room_summary", + source_field: "data_room_release_summary.release_status", + reviewer_role: "data-room operations reviewer", + owner_area: "data_room_ops", + sla_hours: 8, + review_day: 1, + entry_criteria_text: "Confirm buyer data-room artifact readiness.", + exit_criteria_text: "All data-room artifacts required for close are ready.", + }), + makeCommercialCloseBuyerReviewStep({ + step_key: "buyer_review_acceptance_checklist", + review_order: 5, + lane: "data_room", + artifact_key: "release_acceptance_checklist", + source_field: "diligence_close_acceptance_summary.decision_code", + reviewer_role: "buyer diligence reviewer", + owner_area: "buyer_diligence", + sla_hours: 8, + review_day: 2, + entry_criteria_text: "Review acceptance checklist against traceability map.", + exit_criteria_text: "All close acceptance rows are ready for buyer signoff.", + }), + makeCommercialCloseBuyerReviewStep({ + step_key: "buyer_review_readiness_scorecard", + review_order: 6, + lane: "commercial", + artifact_key: "release_readiness_scorecard", + source_field: "commercial_close_readiness_scorecard.status_code", + reviewer_role: "commercial diligence reviewer", + owner_area: "commercial_diligence", + sla_hours: 8, + review_day: 2, + entry_criteria_text: "Review commercial readiness score and component blockers.", + exit_criteria_text: "Commercial readiness scorecard is commercially ready.", + }), + makeCommercialCloseBuyerReviewStep({ + step_key: "buyer_review_execution_plan", + review_order: 7, + lane: "commercial", + artifact_key: "release_execution_plan", + source_field: "commercial_close_execution_plan.status_code", + reviewer_role: "program manager", + owner_area: "program_management", + sla_hours: 8, + review_day: 2, + entry_criteria_text: "Review blocked execution lanes and owner actions.", + exit_criteria_text: "Execution plan lanes required for close are ready.", + }), + makeCommercialCloseBuyerReviewStep({ + step_key: "buyer_review_kpi_operating_model", + review_order: 8, + lane: "commercial", + artifact_key: "release_kpi_operating_model", + source_field: "commercial_close_kpi_operating_model.status_code", + reviewer_role: "commercial diligence reviewer", + owner_area: "commercial_diligence", + sla_hours: 8, + review_day: 2, + entry_criteria_text: "Review KPI target coverage and guardrail breaches.", + exit_criteria_text: "Operating KPIs meet target review thresholds.", + }), + makeCommercialCloseBuyerReviewStep({ + step_key: "buyer_review_buyer_brief", + review_order: 9, + lane: "commercial", + artifact_key: "release_buyer_brief", + source_field: "commercial_close_buyer_brief.status_code", + reviewer_role: "commercial diligence reviewer", + owner_area: "commercial_diligence", + sla_hours: 4, + review_day: 3, + entry_criteria_text: "Review buyer narrative against evidence basis bullets.", + exit_criteria_text: "Buyer brief is ready as the narrative review index.", + }), + makeCommercialCloseBuyerReviewStep({ + step_key: "buyer_review_signoff_matrix", + review_order: 10, + lane: "signoff", + artifact_key: "release_signoff_matrix", + source_field: "commercial_close_signoff_matrix.status_code", + reviewer_role: "commercial diligence reviewer", + owner_area: "commercial_diligence", + sla_hours: 4, + review_day: 3, + entry_criteria_text: "Confirm every required role signoff is ready.", + exit_criteria_text: "Commercial close signoff matrix is ready.", + }), +]; + +const commercialCloseBuyerReviewPreviousBlockers = Array.from( + new Set(commercialCloseBuyerReviewBaseSteps.flatMap((step) => step.blocker_keys)), +); + +const commercialCloseBuyerReviewReleaseReady = + commercialCloseReleasePackage.status_code === "release_ready" && + commercialCloseBuyerReviewPreviousBlockers.length === 0; + +const commercialCloseBuyerReviewSteps = [ + ...commercialCloseBuyerReviewBaseSteps, + { + step_key: "buyer_review_release_decision", + review_order: 11, + lane: "release", + status_code: commercialCloseBuyerReviewReleaseReady ? "ready" : "blocked", + evidence_file_name: "commercial-close-release-package.json", + source_field: "commercial_close_release_package.status_code", + reviewer_role: "buyer diligence lead", + owner_area: "buyer_diligence", + sla_hours: 4, + review_day: 3, + entry_criteria_text: "Confirm every buyer review step is ready.", + exit_criteria_text: "Approve the release package for buyer handoff.", + blocker_keys: commercialCloseBuyerReviewReleaseReady + ? [] + : commercialCloseBuyerReviewPreviousBlockers.slice(0, 10), + contains_raw_content: false, + contains_stable_identifiers: false, + contains_provider_credentials: false, + provider_write_executed: false, + }, +]; + +const commercialCloseBuyerReviewBlockedSteps = commercialCloseBuyerReviewSteps.filter( + (step) => step.status_code === "blocked", +); + +const commercialCloseBuyerReviewBlockerKeys = Array.from( + new Set(commercialCloseBuyerReviewBlockedSteps.flatMap((step) => step.blocker_keys)), +); + +const commercialCloseBuyerReviewRunbook = { + runbook_key: "commercial_close_buyer_review_runbook", + target_contract_value_krw: 2_000_000_000, + target_contract_label: "2,000,000,000 KRW", + status_code: "review_blocked", + total_step_count: commercialCloseBuyerReviewSteps.length, + ready_step_count: commercialCloseBuyerReviewSteps.length - commercialCloseBuyerReviewBlockedSteps.length, + blocked_step_count: commercialCloseBuyerReviewBlockedSteps.length, + blocker_key_count: commercialCloseBuyerReviewBlockerKeys.length, + blocked_step_keys: commercialCloseBuyerReviewBlockedSteps.map((step) => step.step_key), + blocker_keys: commercialCloseBuyerReviewBlockerKeys.slice(0, 10), + first_step_key: "buyer_review_intake", + final_decision_step_key: "buyer_review_release_decision", + verification_command: commercialCloseReleasePackage.verification_command, + buyer_handoff_text: "Buyer review runbook remains blocked for 2,000,000,000 KRW target review: 8 step(s) need remediation.", + next_action_text: "Resolve blocked buyer review steps, regenerate the evidence snapshot, rerun the offline verifier, and reissue the runbook.", + steps: commercialCloseBuyerReviewSteps, + provider_write_executed: false, +}; + const dataQualitySurface = { workspace_id: "workspace-org-acme", organization_id: "org-acme", @@ -1378,7 +2553,17 @@ const dataEvidenceSnapshot = { "audit_event", "content_graph_evidence_samples", "content_graph_topology_counts", + "commercial_close_buyer_brief", + "commercial_close_execution_plan", + "commercial_close_kpi_operating_model", + "commercial_close_readiness_scorecard", + "commercial_close_buyer_review_runbook", + "commercial_close_release_package", + "commercial_close_signoff_matrix", "data_room_package_manifest", + "data_room_release_summary", + "diligence_close_acceptance_checklist", + "diligence_close_acceptance_summary", "diligence_exception_register", "diligence_close_artifact_review_queue", "diligence_close_owner_handoff_queue", @@ -1472,10 +2657,20 @@ const dataEvidenceSnapshot = { verification_handoff: snapshotVerificationHandoff, evidence_packet_checklist: evidencePacketChecklist, data_room_package_manifest: dataRoomPackageManifest, + data_room_release_summary: dataRoomReleaseSummary, + commercial_close_readiness_scorecard: commercialCloseReadinessScorecard, + commercial_close_execution_plan: commercialCloseExecutionPlan, + commercial_close_kpi_operating_model: commercialCloseKpiOperatingModel, + commercial_close_buyer_brief: commercialCloseBuyerBrief, + commercial_close_signoff_matrix: commercialCloseSignoffMatrix, + commercial_close_release_package: commercialCloseReleasePackage, + commercial_close_buyer_review_runbook: commercialCloseBuyerReviewRunbook, diligence_exception_register: diligenceExceptionRegister, diligence_close_artifact_review_queue: diligenceCloseArtifactReviewQueue, diligence_close_owner_handoff_queue: diligenceCloseOwnerHandoffQueue, diligence_close_traceability_map: diligenceCloseTraceabilityMap, + diligence_close_acceptance_checklist: diligenceCloseAcceptanceChecklist, + diligence_close_acceptance_summary: diligenceCloseAcceptanceSummary, diligence_close_decision_summary: diligenceCloseDecisionSummary, diligence_close_proof_plan: diligenceCloseProofPlan, diligence_risk_matrix: diligenceRiskMatrix, @@ -2097,6 +3292,66 @@ describe("DataPage", () => { expect(container.textContent).toContain("Offline snapshot verification"); expect(container.textContent).toContain("redacted_snapshot_policy"); expect(container.textContent).toContain("buyer_evidence_readiness_gate"); + expect(container.textContent).toContain("Commercial close readiness"); + expect(container.textContent).toContain("commercially_blocked"); + expect(container.textContent).toContain("2,000,000,000 KRW"); + expect(container.textContent).toContain("score 62 / 100"); + expect(container.textContent).toContain("Product KPI attainment"); + expect(container.textContent).toContain("knowledge_graph_coverage"); + expect(container.textContent).toContain("Commercial close execution plan"); + expect(container.textContent).toContain("execution_blocked"); + expect(container.textContent).toContain("6 lane(s)"); + expect(container.textContent).toContain("email_ingestion"); + expect(container.textContent).toContain("acquisition-readiness-summary.json"); + expect(container.textContent).toContain("thread_id_integrity"); + expect(container.textContent).toContain("exception_repair_thread_id_integrity"); + expect(container.textContent).toContain("Artifact ready"); + expect(container.textContent).toContain("Commercial close KPI operating model"); + expect(container.textContent).toContain("operating_blocked"); + expect(container.textContent).toContain("commercial_close_readiness_score"); + expect(container.textContent).toContain("execution_lane_clearance"); + expect(container.textContent).toContain("privacy_exposure_control"); + expect(container.textContent).toContain("provider_write_boundary"); + expect(container.textContent).toContain("Commercial close buyer brief"); + expect(container.textContent).toContain("brief_blocked"); + expect(container.textContent).toContain("buyer_brief_readiness_score"); + expect(container.textContent).toContain("buyer_brief_kpi_operating_model"); + expect(container.textContent).toContain("buyer_brief_privacy_redaction"); + expect(container.textContent).toContain("buyer_brief_offline_verifier"); + expect(container.textContent).toContain("Commercial close signoff matrix"); + expect(container.textContent).toContain("signoff_blocked"); + expect(container.textContent).toContain("signoff_commercial_diligence"); + expect(container.textContent).toContain("signoff_program_management"); + expect(container.textContent).toContain("signoff_data_room_ops"); + expect(container.textContent).toContain("signoff_buyer_diligence"); + expect(container.textContent).toContain("signoff_privacy_security"); + expect(container.textContent).toContain("signoff_verification"); + expect(container.textContent).toContain("signoff_security_governance"); + expect(container.textContent).toContain("read-only-evidence-boundary"); + expect(container.textContent).toContain("Commercial close release package"); + expect(container.textContent).toContain("commercial_close_release_package"); + expect(container.textContent).toContain("release_blocked"); + expect(container.textContent).toContain("blocked artifacts 7"); + expect(container.textContent).toContain("commercial-close-buyer-brief.json"); + expect(container.textContent).toContain("commercial-close-signoff-matrix.json"); + expect(container.textContent).toContain("buyer-data-room-release.json"); + expect(container.textContent).toContain("naruon-evidence-snapshot.json"); + expect(container.textContent).toContain("credentials: no"); + expect(container.textContent).toContain("Commercial close buyer review runbook"); + expect(container.textContent).toContain("commercial_close_buyer_review_runbook"); + expect(container.textContent).toContain("buyer_review_intake"); + expect(container.textContent).toContain("buyer_review_release_decision"); + expect(container.textContent).toContain("review_blocked"); + expect(container.textContent).toContain("blocked steps 8"); + expect(container.textContent).toContain("commercial-close-signoff-matrix.json"); + expect(container.textContent).toContain("python scripts/verify_evidence_snapshot.py "); + expect(container.textContent).toContain("Data room release summary"); + expect(container.textContent).toContain("release_blocked"); + expect(container.textContent).toContain("Data-room release remains blocked"); + expect(container.textContent).toContain("blocked 3"); + expect(container.textContent).toContain("privacy exposures 0"); + expect(container.textContent).toContain("buyer-evidence-packet-checklist.json"); + expect(container.textContent).toContain("exception_attach_kg_evidence_endpoints"); expect(container.textContent).toContain("Data room package manifest"); expect(container.textContent).toContain("naruon-evidence-snapshot.json"); expect(container.textContent).toContain("verify-evidence-snapshot.py"); @@ -2140,6 +3395,21 @@ describe("DataPage", () => { expect(container.textContent).toContain("review_acquisition_readiness_summary_json"); expect(container.textContent).toContain("handoff_email_ingestion"); expect(container.textContent).toContain("close proof traceability"); + expect(container.textContent).toContain("Diligence close acceptance summary"); + expect(container.textContent).toContain("Buyer acceptance remains blocked"); + expect(container.textContent).toContain("Acceptance items"); + expect(container.textContent).toContain("total 6"); + expect(container.textContent).toContain("ready 0"); + expect(container.textContent).toContain("Reviewer roles"); + expect(container.textContent).toContain("Required artifacts"); + expect(container.textContent).toContain("Blocker keys"); + expect(container.textContent).toContain("exception_attach_kg_evidence_endpoints"); + expect(container.textContent).toContain("offline verifier"); + expect(container.textContent).toContain("Diligence close acceptance checklist"); + expect(container.textContent).toContain("verify the copied snapshot digest"); + expect(container.textContent).toContain("Verification command"); + expect(container.textContent).toContain("Close gate"); + expect(container.textContent).toContain("buyer acceptance"); expect(container.textContent).toContain("Diligence close proof plan"); expect(container.textContent).toContain("critical evidence gate"); expect(container.textContent).toContain("blocked"); @@ -2229,6 +3499,14 @@ describe("DataPage", () => { expect(copiedSnapshot.canonical_payload_fields).toContain("diligence_close_artifact_review_queue"); expect(copiedSnapshot.canonical_payload_fields).toContain("diligence_close_owner_handoff_queue"); expect(copiedSnapshot.canonical_payload_fields).toContain("diligence_close_traceability_map"); + expect(copiedSnapshot.canonical_payload_fields).toContain("data_room_release_summary"); + expect(copiedSnapshot.canonical_payload_fields).toContain("commercial_close_readiness_scorecard"); + expect(copiedSnapshot.canonical_payload_fields).toContain("commercial_close_execution_plan"); + expect(copiedSnapshot.canonical_payload_fields).toContain("commercial_close_kpi_operating_model"); + expect(copiedSnapshot.canonical_payload_fields).toContain("commercial_close_buyer_brief"); + expect(copiedSnapshot.canonical_payload_fields).toContain("commercial_close_signoff_matrix"); + expect(copiedSnapshot.canonical_payload_fields).toContain("commercial_close_release_package"); + expect(copiedSnapshot.canonical_payload_fields).toContain("commercial_close_buyer_review_runbook"); expect(copiedSnapshot.verification_handoff.verifier_key).toBe("offline_evidence_snapshot_verifier"); expect(copiedSnapshot.verification_handoff.failure_exit_codes.digest_mismatch).toBe(4); expect(copiedSnapshot.evidence_packet_checklist).toHaveLength(10); @@ -2238,6 +3516,14 @@ describe("DataPage", () => { expect(copiedSnapshot.data_room_package_manifest[0].file_name).toBe("naruon-evidence-snapshot.json"); expect(copiedSnapshot.data_room_package_manifest[8].state_code).toBe("needs_attention"); expect(copiedSnapshot.data_room_package_manifest.every((item: { contains_raw_content: boolean }) => !item.contains_raw_content)).toBe(true); + expect(copiedSnapshot.data_room_release_summary).toEqual(dataRoomReleaseSummary); + expect(copiedSnapshot.commercial_close_readiness_scorecard).toEqual(commercialCloseReadinessScorecard); + expect(copiedSnapshot.commercial_close_execution_plan).toEqual(commercialCloseExecutionPlan); + expect(copiedSnapshot.commercial_close_kpi_operating_model).toEqual(commercialCloseKpiOperatingModel); + expect(copiedSnapshot.commercial_close_buyer_brief).toEqual(commercialCloseBuyerBrief); + expect(copiedSnapshot.commercial_close_signoff_matrix).toEqual(commercialCloseSignoffMatrix); + expect(copiedSnapshot.commercial_close_release_package).toEqual(commercialCloseReleasePackage); + expect(copiedSnapshot.commercial_close_buyer_review_runbook).toEqual(commercialCloseBuyerReviewRunbook); expect(copiedSnapshot.diligence_exception_register).toHaveLength(9); expect(copiedSnapshot.diligence_exception_register[0]).toEqual({ exception_key: "exception_repair_thread_id_integrity", @@ -2381,6 +3667,31 @@ describe("DataPage", () => { expect(copiedSnapshot.diligence_close_traceability_map[3].data_room_artifact).toBe("knowledge-graph-evidence-samples.json"); expect(copiedSnapshot.diligence_close_traceability_map[5].source_field).toBe("acquisition_readiness_gate.remediation_actions"); expect(copiedSnapshot.diligence_close_traceability_map[5].owner_handoff_key).toBe("handoff_attachment_parsing"); + expect(copiedSnapshot.diligence_close_acceptance_checklist).toHaveLength(6); + expect(copiedSnapshot.diligence_close_acceptance_checklist[0]).toEqual({ + acceptance_key: "accept_risk_critical_email_ingestion_acquisition_readiness_summary_json", + trace_key: "trace_risk_critical_email_ingestion_acquisition_readiness_summary_json", + data_room_artifact: "acquisition-readiness-summary.json", + source_field: "acquisition_readiness_gate", + owner_area: "email_ingestion", + reviewer_roles: ["executive diligence reviewer"], + acceptance_status: "blocked", + close_gate_status: "blocked", + blocker_keys: [ + "exception_repair_thread_id_integrity", + "exception_backfill_dedupe_fingerprints", + ], + acceptance_criteria: "Resolve 2 exception(s), regenerate acquisition-readiness-summary.json from acquisition_readiness_gate, and verify the copied snapshot digest before buyer acceptance.", + verification_command: "python scripts/verify_evidence_snapshot.py ", + reviewer_evidence_summary: "executive diligence reviewer review acquisition-readiness-summary.json for email_ingestion; trace_risk_critical_email_ingestion_acquisition_readiness_summary_json covers 2 exception(s).", + next_action: "Resolve exception_repair_thread_id_integrity, exception_backfill_dedupe_fingerprints, then regenerate the evidence snapshot.", + snapshot_verification_required: true, + provider_write_executed: false, + }); + expect(copiedSnapshot.diligence_close_acceptance_checklist[2].source_field).toBe("content_graph_evidence_samples"); + expect(copiedSnapshot.diligence_close_acceptance_checklist[3].data_room_artifact).toBe("knowledge-graph-evidence-samples.json"); + expect(copiedSnapshot.diligence_close_acceptance_checklist[5].blocker_keys).toEqual(["exception_expand_attachment_parse_coverage"]); + expect(copiedSnapshot.diligence_close_acceptance_summary).toEqual(diligenceCloseAcceptanceSummary); expect(copiedSnapshot.parser_manifest_summary[0].parser_key).toBe("plain_text"); expect(copiedSnapshot.privacy_redaction_policy.allowed_sample_fields).toEqual([ "sample_key", @@ -2416,6 +3727,58 @@ describe("DataPage", () => { expect(copiedSnapshot.acquisition_readiness_gate.remediation_actions[0].action_key).toBe("repair_thread_id_integrity"); }); + it("renders acceptance summary when the checklist has no rows", async () => { + const summaryOnlySnapshot = { + ...dataEvidenceSnapshot, + diligence_close_acceptance_checklist: [], + diligence_close_acceptance_summary: { + ...diligenceCloseAcceptanceSummary, + decision_code: "ready_to_close", + total_acceptance_count: 0, + blocked_acceptance_count: 0, + ready_acceptance_count: 0, + reviewer_role_count: 0, + reviewer_roles: [], + required_artifact_count: 0, + required_artifacts: [], + blocker_count: 0, + blocker_keys: [], + close_gate_status: "ready", + snapshot_verification_required: false, + buyer_summary_text: "No buyer acceptance requirements are present.", + next_action_text: "Generate the evidence snapshot before buyer acceptance.", + }, + }; + const baseFetch = mockWebdavFetch(); + const fetchMock = vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => { + const path = String(input); + if (path === "/api/data/quality-surface/evidence-snapshot") { + void init; + return jsonResponse(summaryOnlySnapshot); + } + return baseFetch(input, init); + }); + vi.stubGlobal("fetch", fetchMock); + container = document.createElement("div"); + document.body.appendChild(container); + root = createRoot(container); + + await act(async () => { + root?.render(); + }); + + const qualityTab = Array.from(container.querySelectorAll("button")).find((candidate) => + candidate.textContent?.includes("품질 점검"), + ); + await act(async () => { + qualityTab?.dispatchEvent(new MouseEvent("click", { bubbles: true })); + }); + + expect(container.textContent).toContain("Diligence close acceptance summary"); + expect(container.textContent).toContain("No buyer acceptance requirements are present."); + expect(container.textContent).not.toContain("Diligence close acceptance checklist"); + }); + it("keeps quality checks usable when evidence snapshot fetch fails", async () => { const consoleError = vi.spyOn(console, "error").mockImplementation(() => undefined); const fetchMock = vi.fn(async (input: RequestInfo | URL) => { diff --git a/frontend/src/components/data-layout/QualityCheckTab.tsx b/frontend/src/components/data-layout/QualityCheckTab.tsx index 5ff9c4c6b..e2593da12 100644 --- a/frontend/src/components/data-layout/QualityCheckTab.tsx +++ b/frontend/src/components/data-layout/QualityCheckTab.tsx @@ -40,9 +40,26 @@ export function QualityCheckTab({ const acquisitionReadinessGate = dataQualitySurface?.acquisition_readiness_gate; const evidenceSnapshot = dataEvidenceSnapshot; const closeDecisionSummary = evidenceSnapshot?.diligence_close_decision_summary; + const releaseSummary = evidenceSnapshot?.data_room_release_summary; + const commercialCloseScorecard = evidenceSnapshot?.commercial_close_readiness_scorecard; + const commercialCloseExecutionPlan = evidenceSnapshot?.commercial_close_execution_plan; + const commercialCloseKpiOperatingModel = evidenceSnapshot?.commercial_close_kpi_operating_model; + const commercialCloseBuyerBrief = evidenceSnapshot?.commercial_close_buyer_brief; + const commercialCloseSignoffMatrix = evidenceSnapshot?.commercial_close_signoff_matrix; + const commercialCloseReleasePackage = evidenceSnapshot?.commercial_close_release_package; + const commercialCloseBuyerReviewRunbook = evidenceSnapshot?.commercial_close_buyer_review_runbook; const artifactReviewQueue = evidenceSnapshot?.diligence_close_artifact_review_queue ?? []; const ownerHandoffQueue = evidenceSnapshot?.diligence_close_owner_handoff_queue ?? []; const traceabilityMap = evidenceSnapshot?.diligence_close_traceability_map ?? []; + const acceptanceChecklist = evidenceSnapshot?.diligence_close_acceptance_checklist ?? []; + const acceptanceSummary = evidenceSnapshot?.diligence_close_acceptance_summary; + const commercialCloseBuyerBriefSections = commercialCloseBuyerBrief + ? [ + { title: 'Evidence basis', bullets: commercialCloseBuyerBrief.evidence_basis_bullets }, + { title: 'Top blocker bullets', bullets: commercialCloseBuyerBrief.blocker_bullets }, + { title: 'Guardrail bullets', bullets: commercialCloseBuyerBrief.guardrail_bullets }, + ] + : []; const copyEvidenceSnapshot = React.useCallback(async () => { if (!evidenceSnapshot) return; try { @@ -124,7 +141,7 @@ export function QualityCheckTab({
-
쓰기 경계
+
Write boundary
{getWriteBoundaryLabel(evidenceSnapshot.verification_handoff.provider_write_executed)}
@@ -154,7 +171,7 @@ export function QualityCheckTab({
{toSafeReactText(item.source_field)}
-
쓰기 경계
+
Write boundary
{getWriteBoundaryLabel(item.provider_write_executed)}
@@ -163,6 +180,844 @@ export function QualityCheckTab({ )} + {commercialCloseScorecard && ( +
+

Commercial close readiness

+
+
+
+

{toSafeReactText(commercialCloseScorecard.status_code)}

+

{toSafeReactText(commercialCloseScorecard.buyer_summary_text)}

+

{toSafeReactText(commercialCloseScorecard.next_action_text)}

+
+ + {toSafeReactText(commercialCloseScorecard.scorecard_key)} + +
+
+
+
Target review value
+
{toSafeReactText(commercialCloseScorecard.target_contract_label)}
+
+
+
Score
+
score {formatCount(commercialCloseScorecard.total_score)} / {formatCount(commercialCloseScorecard.max_score)}
+
+
+
KPI gaps
+
{formatCount(commercialCloseScorecard.kpi_gap_count)}
+
+
+
Acceptance blockers
+
{formatCount(commercialCloseScorecard.acceptance_blocker_count)}
+
+
+
Data-room blockers
+
{formatCount(commercialCloseScorecard.blocked_artifact_count)}
+
+
+
Privacy exposures
+
{formatCount(commercialCloseScorecard.privacy_exposure_count)}
+
+
+
Offline verifier
+
{commercialCloseScorecard.verifier_ready ? 'ready' : 'needs attention'}
+
+
+
Write boundary
+
{getWriteBoundaryLabel(commercialCloseScorecard.provider_write_executed)}
+
+
+
+ {commercialCloseScorecard.category_scores.map((category) => ( +
+
+
+

{toSafeReactText(category.display_name)}

+

{toSafeReactText(category.detail_text)}

+
+ + {formatCount(category.score)} / {formatCount(category.max_score)} + +
+
+ ))} +
+
+ {commercialCloseScorecard.blocked_artifact_files.map((fileName) => ( + + {toSafeReactText(fileName)} + + ))} +
+
+ {commercialCloseScorecard.acceptance_blocker_keys.map((blockerKey) => ( + + {toSafeReactText(blockerKey)} + + ))} +
+
+ {commercialCloseScorecard.kpi_gap_keys.map((gapKey) => ( + + {toSafeReactText(gapKey)} + + ))} +
+
+
+ )} + {commercialCloseExecutionPlan && ( +
+

Commercial close execution plan

+
+
+
+

{toSafeReactText(commercialCloseExecutionPlan.status_code)}

+

{toSafeReactText(commercialCloseExecutionPlan.buyer_summary_text)}

+

{toSafeReactText(commercialCloseExecutionPlan.next_action_text)}

+
+ + {toSafeReactText(commercialCloseExecutionPlan.plan_key)} + +
+
+
+
Target review value
+
{toSafeReactText(commercialCloseExecutionPlan.target_contract_label)}
+
+
+
Execution lanes
+
{formatCount(commercialCloseExecutionPlan.total_lane_count)} lane(s)
+
+
+
Blocked lanes
+
{formatCount(commercialCloseExecutionPlan.blocked_lane_count)}
+
+
+
Ready lanes
+
{formatCount(commercialCloseExecutionPlan.ready_lane_count)}
+
+
+
Priority lanes
+
+ critical {formatCount(commercialCloseExecutionPlan.critical_lane_count)} · high {formatCount(commercialCloseExecutionPlan.high_lane_count)} · medium {formatCount(commercialCloseExecutionPlan.medium_lane_count)} +
+
+
+
Actions
+
{formatCount(commercialCloseExecutionPlan.total_action_count)}
+
+
+
Artifacts
+
{formatCount(commercialCloseExecutionPlan.related_artifact_count)}
+
+
+
KPI gaps
+
{formatCount(commercialCloseExecutionPlan.kpi_gap_count)}
+
+
+
Acceptance blockers
+
{formatCount(commercialCloseExecutionPlan.acceptance_blocker_count)}
+
+
+
Verifier command
+
{toSafeReactText(commercialCloseExecutionPlan.verification_command)}
+
+
+
Write boundary
+
{getWriteBoundaryLabel(commercialCloseExecutionPlan.provider_write_executed)}
+
+
+
+ {commercialCloseExecutionPlan.related_artifacts.map((artifact) => ( + + {toSafeReactText(artifact)} + + ))} +
+
+ {commercialCloseExecutionPlan.lanes.map((lane) => ( +
+
+
+

+ {formatCount(lane.execution_order)}. {toSafeReactText(lane.display_name)} +

+

{toSafeReactText(lane.acceptance_criteria)}

+

{toSafeReactText(lane.next_action_text)}

+
+ + {toSafeReactText(lane.status_code)} + +
+
+
+
Owner
+
{toSafeReactText(lane.owner_area)}
+
+
+
Priority
+
{toSafeReactText(lane.priority_code)}
+
+
+
Artifact ready
+
{lane.artifact_ready ? 'yes' : 'no'}
+
+
+
Action count
+
{formatCount(lane.action_count)}
+
+
+
Related artifact
+
{toSafeReactText(lane.related_artifact)}
+
+
+
+ {lane.action_keys.map((actionKey) => ( + + {toSafeReactText(actionKey)} + + ))} +
+
+ {lane.blocking_check_keys.map((checkKey) => ( + + {toSafeReactText(checkKey)} + + ))} +
+
+ {lane.acceptance_blocker_keys.map((blockerKey) => ( + + {toSafeReactText(blockerKey)} + + ))} +
+
+ {lane.kpi_gap_keys.map((gapKey) => ( + + {toSafeReactText(gapKey)} + + ))} +
+
+
+
Lane verifier
+
{toSafeReactText(lane.verification_command)}
+
+
+
Write boundary
+
{getWriteBoundaryLabel(lane.provider_write_executed)}
+
+
+
+ ))} +
+
+
+ )} + {commercialCloseKpiOperatingModel && ( +
+

Commercial close KPI operating model

+
+
+
+

{toSafeReactText(commercialCloseKpiOperatingModel.status_code)}

+

{toSafeReactText(commercialCloseKpiOperatingModel.buyer_summary_text)}

+

{toSafeReactText(commercialCloseKpiOperatingModel.next_action_text)}

+
+ + {toSafeReactText(commercialCloseKpiOperatingModel.model_key)} + +
+
+
+
Target review value
+
{toSafeReactText(commercialCloseKpiOperatingModel.target_contract_label)}
+
+
+
Primary KPI
+
{toSafeReactText(commercialCloseKpiOperatingModel.primary_metric_key)}
+
+
+
Metrics
+
{formatCount(commercialCloseKpiOperatingModel.total_metric_count)}
+
+
+
Target met
+
{formatCount(commercialCloseKpiOperatingModel.target_met_metric_count)}
+
+
+
Needs attention
+
{formatCount(commercialCloseKpiOperatingModel.needs_attention_metric_count)}
+
+
+
Driver metrics
+
{formatCount(commercialCloseKpiOperatingModel.driver_metric_count)}
+
+
+
Guardrails
+
{formatCount(commercialCloseKpiOperatingModel.guardrail_metric_count)}
+
+
+
Guardrail breaches
+
{formatCount(commercialCloseKpiOperatingModel.guardrail_breach_count)}
+
+
+
Write boundary
+
{getWriteBoundaryLabel(commercialCloseKpiOperatingModel.provider_write_executed)}
+
+
+
+ {commercialCloseKpiOperatingModel.blocked_metric_keys.map((metricKey) => ( + + {toSafeReactText(metricKey)} + + ))} +
+
+ {commercialCloseKpiOperatingModel.metrics.map((metric) => ( +
+
+
+

{toSafeReactText(metric.display_name)}

+

{toSafeReactText(metric.buyer_implication)}

+

{toSafeReactText(metric.next_action_text)}

+
+ + {toSafeReactText(metric.status_code)} + +
+
+
+
Metric key
+
{toSafeReactText(metric.metric_key)}
+
+
+
Kind
+
{toSafeReactText(metric.metric_kind)}
+
+
+
Owner
+
{toSafeReactText(metric.owner_area)}
+
+
+
Value
+
{formatCount(metric.current_value)} / {formatCount(metric.target_value)} {toSafeReactText(metric.unit_label)}
+
+
+
Source field
+
{toSafeReactText(metric.source_field)}
+
+
+
Write boundary
+
{getWriteBoundaryLabel(metric.provider_write_executed)}
+
+
+
+ ))} +
+
+
+ )} + {commercialCloseBuyerBrief && ( +
+

Commercial close buyer brief

+
+
+
+

{toSafeReactText(commercialCloseBuyerBrief.status_code)}

+

{toSafeReactText(commercialCloseBuyerBrief.readiness_headline_text)}

+

{toSafeReactText(commercialCloseBuyerBrief.proof_thesis_text)}

+
+ + {toSafeReactText(commercialCloseBuyerBrief.brief_key)} + +
+
+
+
Target review value
+
{toSafeReactText(commercialCloseBuyerBrief.target_contract_label)}
+
+
+
Evidence basis
+
{formatCount(commercialCloseBuyerBrief.evidence_basis_bullets.length)}
+
+
+
Top blockers
+
{formatCount(commercialCloseBuyerBrief.blocker_bullets.length)}
+
+
+
Guardrails
+
{formatCount(commercialCloseBuyerBrief.guardrail_bullets.length)}
+
+
+
Write boundary
+
{getWriteBoundaryLabel(commercialCloseBuyerBrief.provider_write_executed)}
+
+
+
+ {commercialCloseBuyerBriefSections.map((section) => ( +
+

{section.title}

+
+ {section.bullets.map((bullet) => ( +
+

{toSafeReactText(bullet.display_name)}

+

{toSafeReactText(bullet.detail_text)}

+

{toSafeReactText(bullet.bullet_key)} · {toSafeReactText(bullet.source_field)}

+
+ ))} +
+
+ ))} +
+
+

{toSafeReactText(commercialCloseBuyerBrief.reviewer_handoff_text)}

+

{toSafeReactText(commercialCloseBuyerBrief.next_action_text)}

+
+
+
+ )} + {commercialCloseSignoffMatrix && ( +
+

Commercial close signoff matrix

+
+
+
+

{toSafeReactText(commercialCloseSignoffMatrix.status_code)}

+

{toSafeReactText(commercialCloseSignoffMatrix.guardrail_summary_text)}

+

{toSafeReactText(commercialCloseSignoffMatrix.reviewer_handoff_text)}

+

{toSafeReactText(commercialCloseSignoffMatrix.next_action_text)}

+
+ + {toSafeReactText(commercialCloseSignoffMatrix.matrix_key)} + +
+
+
+
Target review value
+
{toSafeReactText(commercialCloseSignoffMatrix.target_contract_label)}
+
+
+
Required signoffs
+
{formatCount(commercialCloseSignoffMatrix.required_signoff_count)}
+
+
+
Signed off
+
{formatCount(commercialCloseSignoffMatrix.signed_off_count)}
+
+
+
Blocked signoffs
+
{formatCount(commercialCloseSignoffMatrix.blocked_signoff_count)}
+
+
+
Blocker keys
+
{formatCount(commercialCloseSignoffMatrix.blocker_key_count)}
+
+
+
Write boundary
+
{getWriteBoundaryLabel(commercialCloseSignoffMatrix.provider_write_executed)}
+
+
+
+ {commercialCloseSignoffMatrix.blocker_keys.map((blockerKey) => ( + + {toSafeReactText(blockerKey)} + + ))} +
+
+ {commercialCloseSignoffMatrix.signoffs.map((signoff) => ( +
+
+
+

{toSafeReactText(signoff.reviewer_role)}

+

{toSafeReactText(signoff.acceptance_text)}

+

{toSafeReactText(signoff.next_action_text)}

+
+ + {toSafeReactText(signoff.status_code)} + +
+
+
+
Signoff key
+
{toSafeReactText(signoff.signoff_key)}
+
+
+
Owner
+
{toSafeReactText(signoff.owner_area)}
+
+
+
Required artifact
+
{toSafeReactText(signoff.required_artifact)}
+
+
+
Write boundary
+
{getWriteBoundaryLabel(signoff.provider_write_executed)}
+
+
+
Source field
+
{toSafeReactText(signoff.source_field)}
+
+
+
+ {signoff.blocker_keys.map((blockerKey) => ( + + {toSafeReactText(blockerKey)} + + ))} +
+
+ ))} +
+
+
+ )} + {commercialCloseReleasePackage && ( +
+

Commercial close release package

+
+
+
+

{toSafeReactText(commercialCloseReleasePackage.status_code)}

+

{toSafeReactText(commercialCloseReleasePackage.buyer_handoff_text)}

+

{toSafeReactText(commercialCloseReleasePackage.next_action_text)}

+
+ + {toSafeReactText(commercialCloseReleasePackage.package_key)} + +
+
+
+
Target review value
+
{toSafeReactText(commercialCloseReleasePackage.target_contract_label)}
+
+
+
Release artifacts
+
{formatCount(commercialCloseReleasePackage.total_artifact_count)}
+
+
+
Ready artifacts
+
{formatCount(commercialCloseReleasePackage.ready_artifact_count)}
+
+
+
Blocked artifacts
+
blocked artifacts {formatCount(commercialCloseReleasePackage.blocked_artifact_count)}
+
+
+
Signed off
+
{formatCount(commercialCloseReleasePackage.signed_off_count)}
+
+
+
Blocked signoffs
+
{formatCount(commercialCloseReleasePackage.blocked_signoff_count)}
+
+
+
Blocker keys
+
{formatCount(commercialCloseReleasePackage.blocker_key_count)}
+
+
+
First release file
+
{toSafeReactText(commercialCloseReleasePackage.first_release_file_name)}
+
+
+
Verifier command
+
{toSafeReactText(commercialCloseReleasePackage.verification_command)}
+
+
+
Write boundary
+
{getWriteBoundaryLabel(commercialCloseReleasePackage.provider_write_executed)}
+
+
+
+ {commercialCloseReleasePackage.blocked_artifact_files.map((fileName) => ( + + {toSafeReactText(fileName)} + + ))} +
+
+ {commercialCloseReleasePackage.blocker_keys.map((blockerKey) => ( + + {toSafeReactText(blockerKey)} + + ))} +
+
+ {commercialCloseReleasePackage.artifacts.map((artifact) => ( +
+
+
+

+ {formatCount(artifact.release_order)}. {toSafeReactText(artifact.file_name)} +

+

{toSafeReactText(artifact.display_name)}

+

{toSafeReactText(artifact.release_instruction_text)}

+
+ + {toSafeReactText(artifact.status_code)} + +
+
+
+
Artifact key
+
{toSafeReactText(artifact.artifact_key)}
+
+
+
Group
+
{toSafeReactText(artifact.artifact_group)}
+
+
+
Reviewer role
+
{toSafeReactText(artifact.reviewer_role)}
+
+
+
Required artifact
+
{toSafeReactText(artifact.required_artifact)}
+
+
+
Source field
+
{toSafeReactText(artifact.source_field)}
+
+
+
Raw content
+
raw content: {artifact.contains_raw_content ? 'yes' : 'no'}
+
+
+
Stable IDs
+
stable IDs: {artifact.contains_stable_identifiers ? 'yes' : 'no'}
+
+
+
Credentials
+
credentials: {artifact.contains_provider_credentials ? 'yes' : 'no'}
+
+
+
Write boundary
+
{getWriteBoundaryLabel(artifact.provider_write_executed)}
+
+
+
+ {artifact.blocker_keys.map((blockerKey) => ( + + {toSafeReactText(blockerKey)} + + ))} +
+
+ ))} +
+
+
+ )} + {commercialCloseBuyerReviewRunbook && ( +
+

Commercial close buyer review runbook

+
+
+
+

{toSafeReactText(commercialCloseBuyerReviewRunbook.status_code)}

+

{toSafeReactText(commercialCloseBuyerReviewRunbook.buyer_handoff_text)}

+

{toSafeReactText(commercialCloseBuyerReviewRunbook.next_action_text)}

+
+ + {toSafeReactText(commercialCloseBuyerReviewRunbook.runbook_key)} + +
+
+
+
Target review value
+
{toSafeReactText(commercialCloseBuyerReviewRunbook.target_contract_label)}
+
+
+
Review steps
+
{formatCount(commercialCloseBuyerReviewRunbook.total_step_count)}
+
+
+
Ready steps
+
{formatCount(commercialCloseBuyerReviewRunbook.ready_step_count)}
+
+
+
Blocked steps
+
blocked steps {formatCount(commercialCloseBuyerReviewRunbook.blocked_step_count)}
+
+
+
Blocker keys
+
{formatCount(commercialCloseBuyerReviewRunbook.blocker_key_count)}
+
+
+
First step
+
{toSafeReactText(commercialCloseBuyerReviewRunbook.first_step_key)}
+
+
+
Final decision
+
{toSafeReactText(commercialCloseBuyerReviewRunbook.final_decision_step_key)}
+
+
+
Write boundary
+
{getWriteBoundaryLabel(commercialCloseBuyerReviewRunbook.provider_write_executed)}
+
+
+
Verifier command
+
{toSafeReactText(commercialCloseBuyerReviewRunbook.verification_command)}
+
+
+
+ {commercialCloseBuyerReviewRunbook.blocked_step_keys.map((stepKey) => ( + + {toSafeReactText(stepKey)} + + ))} +
+
+ {commercialCloseBuyerReviewRunbook.blocker_keys.map((blockerKey) => ( + + {toSafeReactText(blockerKey)} + + ))} +
+
+ {commercialCloseBuyerReviewRunbook.steps.map((step) => ( +
+
+
+

+ {formatCount(step.review_order)}. {toSafeReactText(step.step_key)} +

+

{toSafeReactText(step.evidence_file_name)}

+

{toSafeReactText(step.entry_criteria_text)}

+

{toSafeReactText(step.exit_criteria_text)}

+
+ + {toSafeReactText(step.status_code)} + +
+
+
+
Lane
+
{toSafeReactText(step.lane)}
+
+
+
Reviewer role
+
{toSafeReactText(step.reviewer_role)}
+
+
+
Owner
+
{toSafeReactText(step.owner_area)}
+
+
+
Review day
+
day {formatCount(step.review_day)}
+
+
+
SLA hours
+
{formatCount(step.sla_hours)}
+
+
+
Source field
+
{toSafeReactText(step.source_field)}
+
+
+
Raw content
+
raw content: {step.contains_raw_content ? 'yes' : 'no'}
+
+
+
Stable IDs
+
stable IDs: {step.contains_stable_identifiers ? 'yes' : 'no'}
+
+
+
Credentials
+
credentials: {step.contains_provider_credentials ? 'yes' : 'no'}
+
+
+
Write boundary
+
{getWriteBoundaryLabel(step.provider_write_executed)}
+
+
+
+ {step.blocker_keys.map((blockerKey) => ( + + {toSafeReactText(blockerKey)} + + ))} +
+
+ ))} +
+
+
+ )} + {releaseSummary && ( +
+

Data room release summary

+
+
+
+

{toSafeReactText(releaseSummary.release_status)}

+

{toSafeReactText(releaseSummary.buyer_summary_text)}

+

{toSafeReactText(releaseSummary.next_action_text)}

+
+ + {toSafeReactText(releaseSummary.release_key)} + +
+
+
+
Artifacts
+
+ total {formatCount(releaseSummary.total_artifact_count)} · ready {formatCount(releaseSummary.ready_artifact_count)} · blocked {formatCount(releaseSummary.needs_attention_artifact_count)} +
+
+
+
Required for close
+
{formatCount(releaseSummary.required_for_close_count)}
+
+
+
Privacy exposures
+
privacy exposures {formatCount(releaseSummary.privacy_exposure_count)}
+
+
+
Raw / stable / credential
+
+ {formatCount(releaseSummary.raw_content_exposure_count)} / {formatCount(releaseSummary.stable_identifier_exposure_count)} / {formatCount(releaseSummary.provider_credential_exposure_count)} +
+
+
+
Acceptance blockers
+
{formatCount(releaseSummary.acceptance_blocker_count)}
+
+
+
Snapshot verification
+
{releaseSummary.snapshot_verification_required ? 'required' : 'not required'}
+
+
+
Verification command
+
{toSafeReactText(releaseSummary.verification_command)}
+
+
+
Write boundary
+
{getWriteBoundaryLabel(releaseSummary.provider_write_executed)}
+
+
+
+ {releaseSummary.blocked_artifact_files.map((fileName) => ( + + {toSafeReactText(fileName)} + + ))} +
+
+ {releaseSummary.acceptance_blocker_keys.map((blockerKey) => ( + + {toSafeReactText(blockerKey)} + + ))} +
+
+
+ )} {evidenceSnapshot.data_room_package_manifest.length > 0 && (

Data room package manifest

@@ -201,7 +1056,7 @@ export function QualityCheckTab({
stable IDs: {item.contains_stable_identifiers ? 'yes' : 'no'}
-
쓰기 경계
+
Write boundary
{getWriteBoundaryLabel(item.provider_write_executed)}
@@ -248,7 +1103,7 @@ export function QualityCheckTab({
blocks close: {item.blocks_close ? 'yes' : 'no'}
-
쓰기 경계
+
Write boundary
{getWriteBoundaryLabel(item.provider_write_executed)}
@@ -291,7 +1146,7 @@ export function QualityCheckTab({
blocks close: {item.blocks_close ? 'yes' : 'no'}
-
쓰기 경계
+
Write boundary
{getWriteBoundaryLabel(item.provider_write_executed)}
@@ -359,7 +1214,7 @@ export function QualityCheckTab({
-
쓰기 경계
+
Write boundary
{getWriteBoundaryLabel(closeDecisionSummary.provider_write_executed)}
@@ -416,7 +1271,7 @@ export function QualityCheckTab({
{item.snapshot_verification_required ? 'required' : 'not required'}
-
쓰기 경계
+
Write boundary
{getWriteBoundaryLabel(item.provider_write_executed)}
@@ -473,7 +1328,7 @@ export function QualityCheckTab({
{item.snapshot_verification_required ? 'required' : 'not required'}
-
쓰기 경계
+
Write boundary
{getWriteBoundaryLabel(item.provider_write_executed)}
@@ -548,7 +1403,7 @@ export function QualityCheckTab({
{toSafeReactText(item.severity_code)}
-
쓰기 경계
+
Write boundary
{getWriteBoundaryLabel(item.provider_write_executed)}
@@ -564,6 +1419,134 @@ export function QualityCheckTab({ )} + {(acceptanceSummary || acceptanceChecklist.length > 0) && ( +
+ {acceptanceSummary && ( +
+
+
+

Diligence close acceptance summary

+

{toSafeReactText(acceptanceSummary.decision_code)}

+

{toSafeReactText(acceptanceSummary.buyer_summary_text)}

+

{toSafeReactText(acceptanceSummary.next_action_text)}

+
+ + {toSafeReactText(acceptanceSummary.close_gate_status)} + +
+
+
+
Acceptance items
+
+ total {formatCount(acceptanceSummary.total_acceptance_count)} · blocked {formatCount(acceptanceSummary.blocked_acceptance_count)} · ready {formatCount(acceptanceSummary.ready_acceptance_count)} +
+
+
+
Reviewer roles
+
{formatCount(acceptanceSummary.reviewer_role_count)}
+
+
+
Required artifacts
+
{formatCount(acceptanceSummary.required_artifact_count)}
+
+
+
Blocker keys
+
{formatCount(acceptanceSummary.blocker_count)}
+
+
+
Snapshot verification
+
{acceptanceSummary.snapshot_verification_required ? 'required' : 'not required'}
+
+
+
Write boundary
+
{getWriteBoundaryLabel(acceptanceSummary.provider_write_executed)}
+
+
+
+ {acceptanceSummary.reviewer_roles.map((role) => ( + + {toSafeReactText(role)} + + ))} +
+
+ {acceptanceSummary.required_artifacts.map((artifact) => ( + + {toSafeReactText(artifact)} + + ))} +
+
+ {acceptanceSummary.blocker_keys.map((blockerKey) => ( + + {toSafeReactText(blockerKey)} + + ))} +
+
+ )} + {acceptanceChecklist.length > 0 && ( + <> +

Diligence close acceptance checklist

+
+ {acceptanceChecklist.map((item) => ( +
+
+
+

{toSafeReactText(item.data_room_artifact)}

+

{toSafeReactText(item.reviewer_roles.join(', '))}

+

{toSafeReactText(item.acceptance_criteria)}

+

{toSafeReactText(item.reviewer_evidence_summary)}

+

{toSafeReactText(item.next_action)}

+
+ + {toSafeReactText(item.acceptance_status)} + +
+
+
+
Trace key
+
{toSafeReactText(item.trace_key)}
+
+
+
Source field
+
{toSafeReactText(item.source_field)}
+
+
+
Owner area
+
{toSafeReactText(item.owner_area)}
+
+
+
Verification command
+
{toSafeReactText(item.verification_command)}
+
+
+
Close gate
+
{toSafeReactText(item.close_gate_status)}
+
+
+
Snapshot verification
+
{item.snapshot_verification_required ? 'required' : 'not required'}
+
+
+
Write boundary
+
{getWriteBoundaryLabel(item.provider_write_executed)}
+
+
+
+ {item.blocker_keys.map((blockerKey) => ( + + {toSafeReactText(blockerKey)} + + ))} +
+
+ ))} +
+ + )} +
+ )} {evidenceSnapshot.diligence_close_proof_plan.length > 0 && (

Diligence close proof plan

@@ -603,7 +1586,7 @@ export function QualityCheckTab({
{toSafeReactText(item.severity_code)}
-
쓰기 경계
+
Write boundary
{getWriteBoundaryLabel(item.provider_write_executed)}
@@ -652,7 +1635,7 @@ export function QualityCheckTab({
{acquisitionReadinessGate.snapshot_verification_ready ? 'Snapshot verification ready' : 'Snapshot verification pending'}
-
쓰기 경계
+
Write boundary
{getWriteBoundaryLabel(acquisitionReadinessGate.provider_write_executed)}
@@ -684,7 +1667,7 @@ export function QualityCheckTab({
{toSafeReactText(acquisitionReadinessGate.decision_summary.summary_key)}
-
쓰기 경계
+
Write boundary
{getWriteBoundaryLabel(acquisitionReadinessGate.decision_summary.provider_write_executed)}
@@ -727,7 +1710,7 @@ export function QualityCheckTab({
{toSafeReactText(kpi.owner_area)}
-
쓰기 경계
+
Write boundary
{getWriteBoundaryLabel(kpi.provider_write_executed)}
@@ -765,7 +1748,7 @@ export function QualityCheckTab({
{toSafeReactText(action.blocking_check_key)}
-
쓰기 경계
+
Write boundary
{getWriteBoundaryLabel(action.provider_write_executed)}
@@ -834,7 +1817,7 @@ export function QualityCheckTab({
{formatCount(check.total_count)}
-
쓰기 경계
+
Write boundary
{getWriteBoundaryLabel(check.provider_write_executed)}
@@ -865,7 +1848,7 @@ export function QualityCheckTab({
{formatCount(item.object_count)}
-
쓰기 경계
+
Write boundary
{getWriteBoundaryLabel(item.provider_write_executed)}
@@ -897,7 +1880,7 @@ export function QualityCheckTab({
{formatCount(item.object_count)}
-
쓰기 경계
+
Write boundary
{getWriteBoundaryLabel(item.provider_write_executed)}
@@ -998,7 +1981,7 @@ export function QualityCheckTab({
{formatCount(item.source_backed_relation_count)}
-
쓰기 경계
+
Write boundary
{getWriteBoundaryLabel(item.provider_write_executed)}
@@ -1036,7 +2019,7 @@ export function QualityCheckTab({
{toSafeReactText(item.source_scope)}
-
쓰기 경계
+
Write boundary
{getWriteBoundaryLabel(false)}
@@ -1075,7 +2058,7 @@ export function QualityCheckTab({
{toSafeReactText(item.parser_key)}
-
쓰기 경계
+
Write boundary
{getWriteBoundaryLabel(item.provider_write_executed)}
diff --git a/frontend/src/components/data-layout/types.ts b/frontend/src/components/data-layout/types.ts index 0aada1b80..f14b1cc45 100644 --- a/frontend/src/components/data-layout/types.ts +++ b/frontend/src/components/data-layout/types.ts @@ -50,11 +50,29 @@ export type SurfaceStatusCode = 'ready' | 'running' | 'needs_attention' | 'pendi export type QualityStatusCode = 'pass' | 'needs_attention' | 'pending'; export type AcquisitionReadinessState = 'ready' | 'needs_attention' | 'pending'; export type RemediationPriority = 'critical' | 'high' | 'medium'; +export type DataRoomReleaseStatus = 'release_ready' | 'release_blocked'; +export type CommercialCloseReadinessStatus = 'commercially_ready' | 'commercially_blocked'; +export type CommercialCloseReadinessCategoryStatus = 'ready' | 'needs_attention'; +export type CommercialCloseExecutionStatus = 'execution_ready' | 'execution_blocked'; +export type CommercialCloseExecutionLaneStatus = 'ready' | 'blocked'; +export type CommercialCloseKpiMetricKind = 'primary' | 'driver' | 'guardrail'; +export type CommercialCloseKpiMetricStatus = 'target_met' | 'needs_attention'; +export type CommercialCloseKpiOperatingStatus = 'operating_ready' | 'operating_blocked'; +export type CommercialCloseBuyerBriefStatus = 'brief_ready' | 'brief_blocked'; +export type CommercialCloseSignoffStatus = 'signed_off' | 'blocked'; +export type CommercialCloseSignoffMatrixStatus = 'signoff_ready' | 'signoff_blocked'; +export type CommercialCloseReleaseArtifactStatus = 'ready' | 'blocked'; +export type CommercialCloseReleasePackageStatus = 'release_ready' | 'release_blocked'; +export type CommercialCloseReleaseArtifactGroup = 'core_evidence' | 'commercial_close' | 'buyer_diligence' | 'guardrail'; +export type CommercialCloseBuyerReviewRunbookStatus = 'review_ready' | 'review_blocked'; +export type CommercialCloseBuyerReviewStepStatus = 'ready' | 'blocked'; +export type CommercialCloseBuyerReviewStepLane = 'intake' | 'verification' | 'privacy' | 'data_room' | 'commercial' | 'signoff' | 'release'; export type CloseGateStatus = 'blocked' | 'ready'; export type DiligenceCloseDecision = 'ready_to_close' | 'close_blocked'; export type DiligenceCloseSeverity = RemediationPriority | 'none'; export type DiligenceArtifactReviewStatus = 'blocked' | 'ready_for_review'; export type DiligenceOwnerHandoffStatus = 'blocked' | 'ready_for_handoff'; +export type DiligenceAcceptanceStatus = 'blocked' | 'ready_for_acceptance'; export type DiligenceRecommendation = 'ready_for_diligence' | 'remediate_before_close' | 'insufficient_evidence'; export type DiligenceRiskLevel = 'low' | 'medium' | 'high'; export type RepositoryAssetState = 'ready' | 'needs_attention'; @@ -295,6 +313,259 @@ export type DataEvidenceSnapshotResponse = { detail_text: string; provider_write_executed: boolean; }>; + data_room_release_summary: { + release_key: string; + release_status: DataRoomReleaseStatus; + total_artifact_count: number; + ready_artifact_count: number; + needs_attention_artifact_count: number; + required_for_close_count: number; + blocked_artifact_files: string[]; + privacy_exposure_count: number; + raw_content_exposure_count: number; + stable_identifier_exposure_count: number; + provider_credential_exposure_count: number; + snapshot_verification_required: boolean; + verification_command: string; + acceptance_blocker_count: number; + acceptance_blocker_keys: string[]; + buyer_summary_text: string; + next_action_text: string; + provider_write_executed: boolean; + }; + commercial_close_readiness_scorecard: { + scorecard_key: string; + target_contract_value_krw: number; + target_contract_label: string; + status_code: CommercialCloseReadinessStatus; + total_score: number; + max_score: number; + category_scores: Array<{ + category_key: string; + display_name: string; + status_code: CommercialCloseReadinessCategoryStatus; + score: number; + max_score: number; + detail_text: string; + }>; + blocked_artifact_count: number; + blocked_artifact_files: string[]; + acceptance_blocker_count: number; + acceptance_blocker_keys: string[]; + kpi_gap_count: number; + kpi_gap_keys: string[]; + privacy_exposure_count: number; + verifier_ready: boolean; + release_status: DataRoomReleaseStatus; + close_gate_status: CloseGateStatus; + buyer_summary_text: string; + next_action_text: string; + provider_write_executed: boolean; + }; + commercial_close_execution_plan: { + plan_key: string; + target_contract_value_krw: number; + target_contract_label: string; + status_code: CommercialCloseExecutionStatus; + total_lane_count: number; + blocked_lane_count: number; + ready_lane_count: number; + critical_lane_count: number; + high_lane_count: number; + medium_lane_count: number; + related_artifact_count: number; + related_artifacts: string[]; + total_action_count: number; + kpi_gap_count: number; + acceptance_blocker_count: number; + verification_command: string; + buyer_summary_text: string; + next_action_text: string; + lanes: Array<{ + lane_key: string; + execution_order: number; + display_name: string; + owner_area: string; + priority_code: RemediationPriority; + status_code: CommercialCloseExecutionLaneStatus; + related_artifact: string; + artifact_ready: boolean; + action_count: number; + action_keys: string[]; + blocking_check_keys: string[]; + acceptance_blocker_keys: string[]; + kpi_gap_keys: string[]; + acceptance_criteria: string; + verification_command: string; + next_action_text: string; + provider_write_executed: boolean; + }>; + provider_write_executed: boolean; + }; + commercial_close_kpi_operating_model: { + model_key: string; + target_contract_value_krw: number; + target_contract_label: string; + status_code: CommercialCloseKpiOperatingStatus; + primary_metric_key: string; + total_metric_count: number; + target_met_metric_count: number; + needs_attention_metric_count: number; + primary_metric_count: number; + driver_metric_count: number; + guardrail_metric_count: number; + blocked_metric_keys: string[]; + guardrail_breach_count: number; + buyer_summary_text: string; + next_action_text: string; + metrics: Array<{ + metric_key: string; + display_name: string; + metric_kind: CommercialCloseKpiMetricKind; + status_code: CommercialCloseKpiMetricStatus; + current_value: number; + target_value: number; + unit_label: string; + source_field: string; + owner_area: string; + buyer_implication: string; + next_action_text: string; + provider_write_executed: boolean; + }>; + provider_write_executed: boolean; + }; + commercial_close_buyer_brief: { + brief_key: string; + target_contract_value_krw: number; + target_contract_label: string; + status_code: CommercialCloseBuyerBriefStatus; + readiness_headline_text: string; + proof_thesis_text: string; + evidence_basis_bullets: Array<{ + bullet_key: string; + display_name: string; + source_field: string; + detail_text: string; + provider_write_executed: boolean; + }>; + blocker_bullets: Array<{ + bullet_key: string; + display_name: string; + source_field: string; + detail_text: string; + provider_write_executed: boolean; + }>; + guardrail_bullets: Array<{ + bullet_key: string; + display_name: string; + source_field: string; + detail_text: string; + provider_write_executed: boolean; + }>; + reviewer_handoff_text: string; + next_action_text: string; + provider_write_executed: boolean; + }; + commercial_close_signoff_matrix: { + matrix_key: string; + target_contract_value_krw: number; + target_contract_label: string; + status_code: CommercialCloseSignoffMatrixStatus; + required_signoff_count: number; + signed_off_count: number; + blocked_signoff_count: number; + blocker_key_count: number; + blocker_keys: string[]; + guardrail_summary_text: string; + reviewer_handoff_text: string; + next_action_text: string; + signoffs: Array<{ + signoff_key: string; + reviewer_role: string; + owner_area: string; + status_code: CommercialCloseSignoffStatus; + source_field: string; + required_artifact: string; + blocker_keys: string[]; + acceptance_text: string; + next_action_text: string; + provider_write_executed: boolean; + }>; + provider_write_executed: boolean; + }; + commercial_close_release_package: { + package_key: string; + target_contract_value_krw: number; + target_contract_label: string; + status_code: CommercialCloseReleasePackageStatus; + total_artifact_count: number; + ready_artifact_count: number; + blocked_artifact_count: number; + signed_off_count: number; + blocked_signoff_count: number; + blocker_key_count: number; + blocked_artifact_files: string[]; + blocker_keys: string[]; + first_release_file_name: string; + verification_command: string; + buyer_handoff_text: string; + next_action_text: string; + artifacts: Array<{ + artifact_key: string; + release_order: number; + file_name: string; + display_name: string; + artifact_group: CommercialCloseReleaseArtifactGroup; + status_code: CommercialCloseReleaseArtifactStatus; + source_field: string; + required_artifact: string; + reviewer_role: string; + blocker_keys: string[]; + release_instruction_text: string; + contains_raw_content: boolean; + contains_stable_identifiers: boolean; + contains_provider_credentials: boolean; + provider_write_executed: boolean; + }>; + provider_write_executed: boolean; + }; + commercial_close_buyer_review_runbook: { + runbook_key: string; + target_contract_value_krw: number; + target_contract_label: string; + status_code: CommercialCloseBuyerReviewRunbookStatus; + total_step_count: number; + ready_step_count: number; + blocked_step_count: number; + blocker_key_count: number; + blocked_step_keys: string[]; + blocker_keys: string[]; + first_step_key: string; + final_decision_step_key: string; + verification_command: string; + buyer_handoff_text: string; + next_action_text: string; + steps: Array<{ + step_key: string; + review_order: number; + lane: CommercialCloseBuyerReviewStepLane; + status_code: CommercialCloseBuyerReviewStepStatus; + evidence_file_name: string; + source_field: string; + reviewer_role: string; + owner_area: string; + sla_hours: number; + review_day: number; + entry_criteria_text: string; + exit_criteria_text: string; + blocker_keys: string[]; + contains_raw_content: boolean; + contains_stable_identifiers: boolean; + contains_provider_credentials: boolean; + provider_write_executed: boolean; + }>; + provider_write_executed: boolean; + }; diligence_exception_register: Array<{ exception_key: string; blocking_check_key: string; @@ -402,6 +673,41 @@ export type DataEvidenceSnapshotResponse = { snapshot_verification_required: boolean; provider_write_executed: boolean; }>; + diligence_close_acceptance_checklist: Array<{ + acceptance_key: string; + trace_key: string; + data_room_artifact: string; + source_field: string; + owner_area: string; + reviewer_roles: string[]; + acceptance_status: DiligenceAcceptanceStatus; + close_gate_status: CloseGateStatus; + blocker_keys: string[]; + acceptance_criteria: string; + verification_command: string; + reviewer_evidence_summary: string; + next_action: string; + snapshot_verification_required: boolean; + provider_write_executed: boolean; + }>; + diligence_close_acceptance_summary: { + summary_key: string; + decision_code: DiligenceCloseDecision; + total_acceptance_count: number; + blocked_acceptance_count: number; + ready_acceptance_count: number; + reviewer_role_count: number; + reviewer_roles: string[]; + required_artifact_count: number; + required_artifacts: string[]; + blocker_count: number; + blocker_keys: string[]; + close_gate_status: CloseGateStatus; + snapshot_verification_required: boolean; + buyer_summary_text: string; + next_action_text: string; + provider_write_executed: boolean; + }; parser_manifest_summary: Array<{ parser_key: string; display_name: string;