8월 7일까지 워킹트리에만 남아 있던 미커밋 작업을 커밋한다. 여러 사본 폴더(worktree·clone)에 흩어져 있던 중간 스냅샷을 정리하기 전에 원본을 git 이력으로 고정하는 것이 목적이다. - contracts/routes/services: measurement, outcome_trajectory, rupture_repair, deliberate_practice, calibration_transfer, supervision_research, multimodal_alliance, continuous_improvement 계열 신규 모듈과 테스트 - infra/db/init: 07~16 마이그레이션(측정 기반~calibration transfer 실행) - apps/web: 세션 리뷰 카드·관리 화면·E2E 스펙 추가 - docs/ops: G0~G8 라이브 통합·배포·롤백 증거 문서와 evidence JSON/PNG - scripts: smoke·ledger·릴리스 에이전트·NAS 프리뷰 운영 스크립트 engine.public 로그 .bak과 apps/web/test-results 산출물은 커밋에서 제외했다.
342 lines
15 KiB
PL/PgSQL
342 lines
15 KiB
PL/PgSQL
\set ON_ERROR_STOP on
|
|
|
|
BEGIN;
|
|
|
|
INSERT INTO app.app_user (user_id, external_id, email, display_name, role, cohort)
|
|
VALUES
|
|
('12000000-0000-0000-0000-000000000001','g6-smoke-learner-a','g6-a@example.invalid','G6 A','learner','g6-smoke-a'),
|
|
('12000000-0000-0000-0000-000000000002','g6-smoke-learner-b','g6-b@example.invalid','G6 B','learner','g6-smoke-b'),
|
|
('12000000-0000-0000-0000-000000000003','g6-smoke-teacher','g6-t@example.invalid','G6 T','instructor','g6-smoke-a');
|
|
|
|
INSERT INTO app.sessions (id, learner_id, theory_mode)
|
|
VALUES ('12000000-0000-0000-0000-000000000011','12000000-0000-0000-0000-000000000001','integrative');
|
|
|
|
INSERT INTO app.measurement_instrument (
|
|
instrument_id, instrument_version, name_ko, instrument_kind, construct,
|
|
validation_basis, scoring_schema, metadata
|
|
) VALUES (
|
|
'g6-smoke-instrument','1','G6 smoke','runtime_metric','working_alliance',
|
|
'synthetic smoke only','{"min":0,"max":1}',
|
|
'{"clinical_claim_allowed":false}'
|
|
);
|
|
|
|
INSERT INTO app.measurement_event (
|
|
measurement_id, session_id, construct, dimension, perspective, source_kind,
|
|
instrument_id, instrument_version, value, scale_min, scale_max, status,
|
|
visible_to
|
|
) VALUES
|
|
('12000000-0000-0000-0000-000000000021','12000000-0000-0000-0000-000000000011',
|
|
'working_alliance','g6-smoke-a','runtime_observation','observed_runtime',
|
|
'g6-smoke-instrument','1',0.4,0,1,'ready','{evaluator,supervisor,research}'),
|
|
('12000000-0000-0000-0000-000000000022','12000000-0000-0000-0000-000000000011',
|
|
'working_alliance','g6-smoke-b','runtime_observation','observed_runtime',
|
|
'g6-smoke-instrument','1',0.6,0,1,'ready','{evaluator,supervisor,research}');
|
|
|
|
SET LOCAL ROLE vignette;
|
|
SELECT set_config('app.ai_context','1',true);
|
|
SELECT set_config('app.current_ai_view','supervisor',true);
|
|
|
|
INSERT INTO app.supervision_evidence_pointer (
|
|
pointer_id, learner_id, cohort_id, consumer_view, ledger, event_id,
|
|
session_id, route_hint, content_hash
|
|
) VALUES (
|
|
'12000000-0000-0000-0000-000000000031','12000000-0000-0000-0000-000000000001',
|
|
'g6-smoke-a','supervisor','measurement_event','12000000-0000-0000-0000-000000000021',
|
|
'12000000-0000-0000-0000-000000000011','/sessions/{session_id}/measurements',repeat('a',64)
|
|
);
|
|
|
|
DO $$
|
|
BEGIN
|
|
BEGIN
|
|
INSERT INTO app.supervision_evidence_pointer (
|
|
pointer_id, learner_id, cohort_id, consumer_view, ledger, event_id,
|
|
session_id, route_hint, content_hash
|
|
) VALUES (
|
|
'12000000-0000-0000-0000-000000000039','12000000-0000-0000-0000-000000000001',
|
|
'g6-smoke-a','supervisor','measurement_event','12000000-0000-0000-0000-000000000099',
|
|
'12000000-0000-0000-0000-000000000011','/sessions/{session_id}/measurements',repeat('0',64)
|
|
);
|
|
RAISE EXCEPTION 'missing ledger pointer unexpectedly succeeded';
|
|
EXCEPTION WHEN check_violation THEN NULL;
|
|
END;
|
|
END;
|
|
$$;
|
|
|
|
INSERT INTO app.supervision_attention_snapshot (
|
|
snapshot_id, submission_id, content_hash, cohort_id, item_count, source_pointer_ids
|
|
) VALUES (
|
|
'12000000-0000-0000-0000-000000000041','12000000-0000-0000-0000-000000000042',
|
|
repeat('b',64),'g6-smoke-a',1,'{12000000-0000-0000-0000-000000000031}'
|
|
);
|
|
INSERT INTO app.supervision_attention_item (
|
|
item_id, snapshot_id, learner_id, learner_ref, cohort_id, queue_position,
|
|
primary_signal, oldest_active_sequence, drilldown_routes, evidence_pointer_ids
|
|
) VALUES (
|
|
'12000000-0000-0000-0000-000000000043','12000000-0000-0000-0000-000000000041',
|
|
'12000000-0000-0000-0000-000000000001','learner-smoke-a','g6-smoke-a',1,
|
|
'deterioration',1,ARRAY['/sessions/{session_id}/measurements'],
|
|
'{12000000-0000-0000-0000-000000000031}'
|
|
);
|
|
INSERT INTO app.supervision_attention_reason (
|
|
reason_id, item_id, signal_id, signal_type, severity, uncertainty, evidence_pointer_ids
|
|
) VALUES (
|
|
'12000000-0000-0000-0000-000000000044','12000000-0000-0000-0000-000000000043',
|
|
'oas-g6-signal-smoke-a','deterioration','high',0.2,
|
|
'{12000000-0000-0000-0000-000000000031}'
|
|
);
|
|
INSERT INTO app.supervision_curriculum_gap_snapshot (
|
|
gap_snapshot_id, submission_id, content_hash, cohort_id, competency_id,
|
|
gap_kind, status, uncertainty, affected_learner_count, evidence_pointer_ids
|
|
) VALUES (
|
|
'12000000-0000-0000-0000-000000000045','12000000-0000-0000-0000-000000000046',
|
|
repeat('c',64),'g6-smoke-a','competency.rupture-repair','rupture_repair',
|
|
'observed',0.3,1,'{12000000-0000-0000-0000-000000000031}'
|
|
);
|
|
|
|
DO $$
|
|
BEGIN
|
|
IF (SELECT count(*) FROM app.supervision_attention_item) <> 1 THEN
|
|
RAISE EXCEPTION 'supervisor cannot read own attention queue';
|
|
END IF;
|
|
IF (SELECT count(*) FROM app.supervision_evaluation_batch) <> 0 THEN
|
|
RAISE EXCEPTION 'supervisor leaked research relations';
|
|
END IF;
|
|
END;
|
|
$$;
|
|
|
|
SELECT set_config('app.current_ai_view','research',true);
|
|
INSERT INTO app.supervision_evidence_pointer (
|
|
pointer_id, learner_id, cohort_id, consumer_view, ledger, event_id,
|
|
session_id, route_hint, content_hash
|
|
) VALUES
|
|
('12000000-0000-0000-0000-000000000051','12000000-0000-0000-0000-000000000001',
|
|
'g6-smoke-a','research','measurement_event','12000000-0000-0000-0000-000000000021',
|
|
'12000000-0000-0000-0000-000000000011','/sessions/{session_id}/measurements',repeat('d',64)),
|
|
('12000000-0000-0000-0000-000000000052','12000000-0000-0000-0000-000000000001',
|
|
'g6-smoke-a','research','measurement_event','12000000-0000-0000-0000-000000000022',
|
|
'12000000-0000-0000-0000-000000000011','/sessions/{session_id}/measurements',repeat('e',64));
|
|
|
|
INSERT INTO app.supervision_evaluation_batch (
|
|
batch_record_id, submission_id, content_hash, batch_id, cohort_id, model_name,
|
|
prompt_version, instrument_id, instrument_version, observation_count
|
|
) VALUES
|
|
('12000000-0000-0000-0000-000000000061','12000000-0000-0000-0000-000000000062',repeat('f',64),
|
|
'oas-g6-batch-smoke-baseline','g6-smoke-a','g6-model-a','p1','g6-smoke-instrument','1',1),
|
|
('12000000-0000-0000-0000-000000000063','12000000-0000-0000-0000-000000000064',repeat('1',64),
|
|
'oas-g6-batch-smoke-candidate','g6-smoke-a','g6-model-b','p2','g6-smoke-instrument','1',1);
|
|
DO $$
|
|
BEGIN
|
|
BEGIN
|
|
INSERT INTO app.supervision_evaluation_observation (
|
|
observation_record_id, batch_record_id, cohort_id, case_ref, competency_id,
|
|
synthetic_subgroup, gold_label, predicted_label, evidence_pointer_id
|
|
) VALUES (
|
|
'12000000-0000-0000-0000-000000000069','12000000-0000-0000-0000-000000000061',
|
|
'g6-smoke-a','case-cross-view','competency.rupture-repair','synthetic-smoke-a',
|
|
'pass','pass','12000000-0000-0000-0000-000000000031'
|
|
);
|
|
RAISE EXCEPTION 'research aggregate accepted supervisor pointer';
|
|
EXCEPTION WHEN check_violation THEN NULL;
|
|
END;
|
|
END;
|
|
$$;
|
|
INSERT INTO app.supervision_evaluation_observation (
|
|
observation_record_id, batch_record_id, cohort_id, case_ref, competency_id,
|
|
synthetic_subgroup, gold_label, predicted_label, evidence_pointer_id
|
|
) VALUES
|
|
('12000000-0000-0000-0000-000000000065','12000000-0000-0000-0000-000000000061',
|
|
'g6-smoke-a','case-smoke','competency.rupture-repair','synthetic-smoke-a','pass','pass',
|
|
'12000000-0000-0000-0000-000000000051'),
|
|
('12000000-0000-0000-0000-000000000066','12000000-0000-0000-0000-000000000063',
|
|
'g6-smoke-a','case-smoke','competency.rupture-repair','synthetic-smoke-a','pass','retry',
|
|
'12000000-0000-0000-0000-000000000052');
|
|
INSERT INTO app.supervision_drift_report (
|
|
drift_report_id, submission_id, content_hash, cohort_id,
|
|
baseline_batch_record_id, candidate_batch_record_id, matched_count, status,
|
|
evidence_pointer_ids
|
|
) VALUES (
|
|
'12000000-0000-0000-0000-000000000067','12000000-0000-0000-0000-000000000068',
|
|
repeat('2',64),'g6-smoke-a','12000000-0000-0000-0000-000000000061',
|
|
'12000000-0000-0000-0000-000000000063',1,'insufficient_evidence',
|
|
'{12000000-0000-0000-0000-000000000051,12000000-0000-0000-0000-000000000052}'
|
|
);
|
|
|
|
INSERT INTO app.supervision_phase3_manifest (
|
|
manifest_id, submission_id, content_hash, cohort_id, schema_version, artifact_count
|
|
) VALUES (
|
|
'12000000-0000-0000-0000-000000000071','12000000-0000-0000-0000-000000000072',
|
|
repeat('3',64),'g6-smoke-a','vignette.phase3-outcome-evidence-manifest.v1',4
|
|
);
|
|
INSERT INTO app.supervision_phase3_artifact (
|
|
artifact_record_id, manifest_id, cohort_id, domain, artifact_id, schema_version,
|
|
content_sha256, record_count, provenance_uri, source_pointer_id
|
|
) VALUES
|
|
('12000000-0000-0000-0000-000000000073','12000000-0000-0000-0000-000000000071','g6-smoke-a','alliance','a','v1',repeat('4',64),1,'db://app/measurement_event','12000000-0000-0000-0000-000000000051'),
|
|
('12000000-0000-0000-0000-000000000074','12000000-0000-0000-0000-000000000071','g6-smoke-a','rupture','r','v1',repeat('5',64),1,'db://app/measurement_event','12000000-0000-0000-0000-000000000051'),
|
|
('12000000-0000-0000-0000-000000000075','12000000-0000-0000-0000-000000000071','g6-smoke-a','transfer','t','v1',repeat('6',64),1,'db://app/measurement_event','12000000-0000-0000-0000-000000000052'),
|
|
('12000000-0000-0000-0000-000000000076','12000000-0000-0000-0000-000000000071','g6-smoke-a','calibration','c','v1',repeat('7',64),1,'audit://supervision/teacher','12000000-0000-0000-0000-000000000052');
|
|
|
|
DO $$
|
|
BEGIN
|
|
IF (SELECT count(*) FROM app.supervision_attention_item) <> 0 THEN
|
|
RAISE EXCEPTION 'research leaked supervisor queue';
|
|
END IF;
|
|
IF (SELECT count(*) FROM app.supervision_evaluation_batch) <> 2
|
|
OR (SELECT count(*) FROM app.supervision_phase3_artifact) <> 4 THEN
|
|
RAISE EXCEPTION 'research cannot read version/manifest ledger';
|
|
END IF;
|
|
IF EXISTS (SELECT 1 FROM app.supervision_drift_report
|
|
WHERE status = 'insufficient_evidence'
|
|
AND (baseline_accuracy IS NOT NULL OR candidate_accuracy IS NOT NULL OR accuracy_delta IS NOT NULL)) THEN
|
|
RAISE EXCEPTION 'underpowered drift report contains score';
|
|
END IF;
|
|
END;
|
|
$$;
|
|
|
|
SELECT set_config('app.ai_context','',true);
|
|
SELECT set_config('app.current_ai_view','',true);
|
|
SELECT set_config('app.current_role','instructor',true);
|
|
SELECT set_config('app.current_uid','12000000-0000-0000-0000-000000000003',true);
|
|
SELECT set_config('app.current_cohort','g6-smoke-a',true);
|
|
|
|
INSERT INTO app.supervision_teacher_ai_disagreement (
|
|
disagreement_record_id, submission_id, content_hash, disagreement_id,
|
|
learner_id, cohort_id, case_ref, competency_id, ai_label, teacher_label,
|
|
ai_model, prompt_version, instrument_id, instrument_version,
|
|
correction_reason_code, ai_evidence_pointer_ids, teacher_evidence_pointer_ids,
|
|
created_by_uid
|
|
) VALUES (
|
|
'12000000-0000-0000-0000-000000000081','12000000-0000-0000-0000-000000000082',
|
|
repeat('8',64),'oas-g6-disagreement-smoke','12000000-0000-0000-0000-000000000001',
|
|
'g6-smoke-a','case-smoke','competency.rupture-repair','pass','retry',
|
|
'g6-model-a','p1','g6-smoke-instrument','1','evidence-mismatch',
|
|
'{12000000-0000-0000-0000-000000000051}',
|
|
'{12000000-0000-0000-0000-000000000052}',
|
|
'12000000-0000-0000-0000-000000000003'
|
|
);
|
|
INSERT INTO app.supervision_calibration_dataset_row (
|
|
dataset_row_id, disagreement_record_id, learner_id, cohort_id, row_hash,
|
|
evidence_pointer_ids
|
|
) VALUES (
|
|
'12000000-0000-0000-0000-000000000083','12000000-0000-0000-0000-000000000081',
|
|
'12000000-0000-0000-0000-000000000001','g6-smoke-a',repeat('9',64),
|
|
'{12000000-0000-0000-0000-000000000051,12000000-0000-0000-0000-000000000052}'
|
|
);
|
|
INSERT INTO audit.supervision_teacher_event (
|
|
audit_event_id, disagreement_record_id, actor_uid, learner_id, cohort_id,
|
|
action, content_hash, evidence_pointer_ids
|
|
) VALUES (
|
|
'12000000-0000-0000-0000-000000000084','12000000-0000-0000-0000-000000000081',
|
|
'12000000-0000-0000-0000-000000000003','12000000-0000-0000-0000-000000000001',
|
|
'g6-smoke-a','teacher_ai_disagreement.corrected',repeat('8',64),
|
|
'{12000000-0000-0000-0000-000000000051,12000000-0000-0000-0000-000000000052}'
|
|
);
|
|
|
|
DO $$
|
|
BEGIN
|
|
IF (SELECT count(*) FROM app.supervision_attention_item) <> 1
|
|
OR (SELECT count(*) FROM app.supervision_teacher_ai_disagreement) <> 1
|
|
OR (SELECT count(*) FROM app.supervision_evaluation_batch) <> 2
|
|
OR (SELECT count(*) FROM audit.supervision_teacher_event) <> 1 THEN
|
|
RAISE EXCEPTION 'teacher same-cohort visibility failed';
|
|
END IF;
|
|
END;
|
|
$$;
|
|
|
|
SELECT set_config('app.current_cohort','g6-smoke-b',true);
|
|
DO $$
|
|
BEGIN
|
|
IF (SELECT count(*) FROM app.supervision_attention_item) <> 0
|
|
OR (SELECT count(*) FROM app.supervision_teacher_ai_disagreement) <> 0
|
|
OR (SELECT count(*) FROM app.supervision_evaluation_batch) <> 0
|
|
OR (SELECT count(*) FROM audit.supervision_teacher_event) <> 0 THEN
|
|
RAISE EXCEPTION 'teacher cross-cohort visibility leak';
|
|
END IF;
|
|
END;
|
|
$$;
|
|
|
|
SELECT set_config('app.current_role','learner',true);
|
|
SELECT set_config('app.current_uid','12000000-0000-0000-0000-000000000001',true);
|
|
SELECT set_config('app.current_cohort','g6-smoke-a',true);
|
|
DO $$
|
|
BEGIN
|
|
IF (SELECT count(*) FROM app.supervision_attention_snapshot) <> 0
|
|
OR (SELECT count(*) FROM app.supervision_attention_item) <> 1
|
|
OR (SELECT count(*) FROM app.supervision_teacher_ai_disagreement) <> 1
|
|
OR (SELECT count(*) FROM app.supervision_evaluation_batch) <> 0 THEN
|
|
RAISE EXCEPTION 'learner self visibility failed';
|
|
END IF;
|
|
END;
|
|
$$;
|
|
|
|
SELECT set_config('app.current_uid','12000000-0000-0000-0000-000000000002',true);
|
|
SELECT set_config('app.current_cohort','g6-smoke-b',true);
|
|
DO $$
|
|
BEGIN
|
|
IF (SELECT count(*) FROM app.supervision_attention_item) <> 0
|
|
OR (SELECT count(*) FROM app.supervision_teacher_ai_disagreement) <> 0 THEN
|
|
RAISE EXCEPTION 'learner cross-user visibility leak';
|
|
END IF;
|
|
END;
|
|
$$;
|
|
|
|
SELECT set_config('app.current_role','admin',true);
|
|
SELECT set_config('app.current_uid','12000000-0000-0000-0000-000000000003',true);
|
|
DO $$
|
|
BEGIN
|
|
IF (SELECT count(*) FROM app.supervision_attention_snapshot) <> 1
|
|
OR (SELECT count(*) FROM app.supervision_teacher_ai_disagreement) <> 1
|
|
OR (SELECT count(*) FROM app.supervision_phase3_manifest) <> 1 THEN
|
|
RAISE EXCEPTION 'admin visibility failed';
|
|
END IF;
|
|
END;
|
|
$$;
|
|
|
|
SELECT set_config('app.current_role','',true);
|
|
SELECT set_config('app.current_uid','',true);
|
|
SELECT set_config('app.current_cohort','',true);
|
|
DO $$
|
|
BEGIN
|
|
IF (SELECT count(*) FROM app.supervision_attention_item) <> 0
|
|
OR (SELECT count(*) FROM app.supervision_teacher_ai_disagreement) <> 0
|
|
OR (SELECT count(*) FROM app.supervision_evaluation_batch) <> 0 THEN
|
|
RAISE EXCEPTION 'public/missing GUC visibility leak';
|
|
END IF;
|
|
END;
|
|
$$;
|
|
|
|
RESET ROLE;
|
|
DO $$
|
|
BEGIN
|
|
BEGIN
|
|
UPDATE app.supervision_attention_snapshot SET item_count = 2
|
|
WHERE snapshot_id = '12000000-0000-0000-0000-000000000041';
|
|
RAISE EXCEPTION 'append-only update unexpectedly succeeded';
|
|
EXCEPTION WHEN object_not_in_prerequisite_state THEN
|
|
IF SQLERRM = 'append-only update unexpectedly succeeded' THEN RAISE; END IF;
|
|
END;
|
|
BEGIN
|
|
DELETE FROM audit.supervision_teacher_event
|
|
WHERE audit_event_id = '12000000-0000-0000-0000-000000000084';
|
|
RAISE EXCEPTION 'append-only delete unexpectedly succeeded';
|
|
EXCEPTION WHEN object_not_in_prerequisite_state THEN
|
|
IF SQLERRM = 'append-only delete unexpectedly succeeded' THEN RAISE; END IF;
|
|
END;
|
|
END;
|
|
$$;
|
|
|
|
ROLLBACK;
|
|
|
|
DO $$
|
|
BEGIN
|
|
IF EXISTS (SELECT 1 FROM app.app_user WHERE external_id LIKE 'g6-smoke-%')
|
|
OR EXISTS (SELECT 1 FROM app.supervision_attention_snapshot
|
|
WHERE snapshot_id = '12000000-0000-0000-0000-000000000041')
|
|
OR EXISTS (SELECT 1 FROM app.supervision_phase3_manifest
|
|
WHERE manifest_id = '12000000-0000-0000-0000-000000000071') THEN
|
|
RAISE EXCEPTION 'G6 smoke rollback left residue';
|
|
END IF;
|
|
END;
|
|
$$;
|
|
|
|
SELECT 'G6 supervision/research ledger smoke: PASS (rollback residue 0)' AS result;
|