feat(runtime): harden daily pipeline audit and verification

Tighten real-ingestion success rules, separate scheduled reports from historical rebuilds, and persist source-level runtime audit across daily pipeline runs.

Also add the Phase 5 CI workflow contract plus verification updates and supporting docs so the full uncommitted change set can be validated together.
This commit is contained in:
phamnazage-jpg
2026-05-14 16:17:39 +08:00
parent 618dff33da
commit a8999abcb0
17 changed files with 880 additions and 45 deletions

View File

@@ -55,7 +55,7 @@ archive_report_artifacts() {
}
track_report_state() {
local db_url report_date status model_count summary_md output_path error_message
local db_url report_date status model_count summary_md output_path error_message run_kind trigger_source is_official_daily
db_url="$1"
report_date="$2"
status="$3"
@@ -63,6 +63,9 @@ track_report_state() {
summary_md="${5:-}"
output_path="${6:-}"
error_message="${7:-}"
run_kind="${8:-manual}"
trigger_source="${9:-cli}"
is_official_daily="${10:-false}"
psql "$db_url" \
-v ON_ERROR_STOP=1 \
@@ -71,7 +74,10 @@ track_report_state() {
--set=model_count="$model_count" \
--set=summary_md="$summary_md" \
--set=output_path="$output_path" \
--set=error_message="$error_message" <<'SQL'
--set=error_message="$error_message" \
--set=run_kind="$run_kind" \
--set=trigger_source="$trigger_source" \
--set=is_official_daily="$is_official_daily" <<'SQL'
INSERT INTO daily_report (
report_date,
status,
@@ -79,6 +85,9 @@ INSERT INTO daily_report (
summary_md,
output_path,
error_message,
run_kind,
trigger_source,
is_official_daily,
created_at,
updated_at
)
@@ -89,6 +98,9 @@ VALUES (
NULLIF(:'summary_md', ''),
NULLIF(:'output_path', ''),
NULLIF(:'error_message', ''),
NULLIF(:'run_kind', ''),
NULLIF(:'trigger_source', ''),
NULLIF(:'is_official_daily', '')::BOOLEAN,
NOW(),
NOW()
)
@@ -98,6 +110,21 @@ ON CONFLICT (report_date) DO UPDATE SET
summary_md = COALESCE(EXCLUDED.summary_md, daily_report.summary_md),
output_path = COALESCE(EXCLUDED.output_path, daily_report.output_path),
error_message = EXCLUDED.error_message,
run_kind = CASE
WHEN EXCLUDED.is_official_daily THEN EXCLUDED.run_kind
WHEN daily_report.trigger_source = 'legacy_backfill' THEN EXCLUDED.run_kind
ELSE daily_report.run_kind
END,
trigger_source = CASE
WHEN EXCLUDED.is_official_daily THEN EXCLUDED.trigger_source
WHEN daily_report.trigger_source = 'legacy_backfill' THEN EXCLUDED.trigger_source
ELSE daily_report.trigger_source
END,
is_official_daily = CASE
WHEN EXCLUDED.is_official_daily THEN TRUE
WHEN daily_report.trigger_source = 'legacy_backfill' THEN EXCLUDED.is_official_daily
ELSE daily_report.is_official_daily
END,
updated_at = NOW();
INSERT INTO report_runs (
@@ -106,7 +133,10 @@ INSERT INTO report_runs (
status,
summary_md,
output_path,
error_message
error_message,
run_kind,
trigger_source,
is_official_daily
)
VALUES (
'pipeline',
@@ -114,7 +144,10 @@ VALUES (
:'status',
NULLIF(:'summary_md', ''),
NULLIF(:'output_path', ''),
NULLIF(:'error_message', '')
NULLIF(:'error_message', ''),
NULLIF(:'run_kind', ''),
NULLIF(:'trigger_source', ''),
NULLIF(:'is_official_daily', '')::BOOLEAN
);
SQL
}