G2 Final Proof — SUA-RE Time Concept Baseline
G2 Final Proof — SUA-RE Time Concept Baseline
Ngày: 2026-07-07. Nhiệm vụ: G2-SEAL — seal baseline mới sau G2-1B′ APPLIED. Read-only PG (chỉ SELECT). 0 ghi PG, 0 DDL/DML, 0 append manifest, 0 chạy dot-pg-atomic-apply, 0 sửa SQL/UI/shadow, 0 dọn inert file. Chỉ tạo 2 file protection trong mcp-writes + báo cáo KB này.
Gate: GO_SEAL_G2_TIME_CONCEPT_BASELINE received — yes. Owner phát nguyên văn ở lượt riêng; lượt nhận task card đã HOLD 0 hành động — đúng kỷ luật xuyên suốt G1-2B → G2-1B′.
1. Verdict
SEALED
Toàn bộ verify read-only mục 5 PASS 100% (33/33 boolean check chạy thật trên PG đều true). Baseline JSON + readonly checklist đã tồn tại trên VPS, sha256 xác nhận 2 phía (local shasum + VPS sha256sum khớp).
2. Scope
G2-SEAL = read-only PG + protection artifacts + KB report. Không PG write. Bổ sung bắt buộc "tách snapshot và invariant" đã thực thi: baseline JSON có 2 khối top-level riêng (snapshot_at_seal / forward_invariants); checklist SQL chia 2 group rõ (snapshot theo id cụ thể / invariant không phụ thuộc id).
3. What G2 proved
- Sửa-rẻ concept-level đã dùng thật (không còn là lý thuyết): tách "tổng phút cộng dồn" khỏi "số phút task" bằng 1 golden SQL 4 câu + 1 dòng manifest.
- Thêm concept mới
field.tong_phut_congdon(id=14, active, aliases 5 mục). - Sửa ranh giới concept cũ
field.so_phut(id=5) — chỉ ranh_gioi, ten/mo_ta/status nguyên. - Remap usage bằng lịch sử (SR-SUA): id=13 thành history, id=32 thành current cùng slot qv-tot — không xóa gì.
- Current rows ổn định 30, mỗi slot đúng 1 current (DB-enforced).
- Không scan/re-scan; không UI patch; 29 slot khác không rung.
- Kỷ luật guardrail học được từ HOLD: golden SQL không chứa từ khóa cấm kể cả trong comment; đã render lại r2 sạch và apply thành công.
4. Completed G2 steps
| Bước | Report (knowledge/dev/laws-new/kestra/sua-re/nhap-ui/) | Result | DB write | Artifact chính / sha |
|---|---|---|---|---|
| G2-1A render | g2-1a-time-concept-ledger-delta-ready-for-audit-2026-07-07.md | READY_FOR_AUDIT | KHÔNG | old golden 23ced9a4… + change-scope b7133a7d… |
| G2-1B apply (old) | g2-1-time-concept-ledger-delta-applied-2026-07-07.md | HOLD_GUARDRAIL_REJECTED | KHÔNG (0 write, chặn trước psql) | apply file cũ + manifest dòng 9 → inert audit trail |
| G2-1A′ re-render r2 | g2-1a-r2-guardrail-safe-ready-for-audit-2026-07-07.md | READY_FOR_AUDIT | KHÔNG | r2 golden ef74898d…, executable body byte-identical old golden |
| G2-1B′ apply r2 | g2-1b-r2-time-concept-ledger-delta-applied-2026-07-07.md | APPLIED | CÓ — INSERT 0 1 / UPDATE 1 / UPDATE 1 / INSERT 0 1, COMMIT qua gateway |
apply r2 ef74898d…, manifest 9→10 |
| G2-SEAL | g2-final-proof-2026-07-07.md (báo cáo này) | SEALED | KHÔNG (SELECT only) | baseline JSON 182575c1… + checklist bd7841da… |
5. Final DB baseline at G2 seal
Verify read-only 2026-07-07 (MCP query_pg, READ ONLY transaction) — PASS toàn bộ; 33 check của checklist chạy thật đều true:
- concept count = 14; max concept id = 14 ✓
- usage total = 32; max usage id = 32 ✓; current = 30 ✓; current distinct slot_key = 30 ✓; total distinct slot_key = 30 ✓
- non-current = đúng 2 dòng: id 11 và id 13 (string_agg = '11,13') ✓
- current match_status: matched 27 / candidate 2 / review 1 / pending 0 ✓
field.so_phut: id=5, ten/kind/mo_ta/status nguyên, ranh_gioi mới khớp nguyên văn ✓ (boolean gộp toàn field = true)field.tong_phut_congdon: id=14, đủ ten/kind/mo_ta/ranh_gioi/aliases 5 mục/match_policy auto/active ✓ (boolean gộp = true)field.tong_thoigian_nhaptay: 0 row ✓- id=13: history, item_key
…::scan_0, đủ field nguyên, joined concept_key field.so_phut, matched ✓ - id=32: current, item_key
…::scan_g2_1_time_concept_001, dedupe_key field.tong_phut_congdon, concept_id=14, matched (GENERATED), owner_concept_id NULL, near_concepts[], 4 decision fields NULL ✓ - id=11 history G1 slot ✓; id=31 current task-minutes ✓; id=12 vẫn so_phut ✓; id 24/25/30 keep_pending decision_by='Owner', không dòng nào khác có owner_decision ✓
- Hạ tầng: đúng 2 bảng, 0 view, 0 trigger, 10 index (gồm unique concept_key, unique item_key,
ux_sruk_slot_currentUNIQUE(slot_key) WHERE is_current), match_status GENERATED ALWAYS + có generation_expression, không date_updated/backlog_note ✓ - Manifest không đổi trong G2-SEAL (10 dòng, dòng 9 inert + dòng 10 r2) ✓; toàn bộ sha golden/apply/change-scope/script không đổi ✓; UI/source/shadow không bị chạm ✓
6. Delta proof (before → after G2)
- concept 13 → 14 (thêm đúng 1: field.tong_phut_congdon)
- usage 31 → 32 (thêm đúng 1: id=32)
- current 30 giữ nguyên (id=13 rời current, id=32 vào current — cùng slot)
- id=13: current → history (không xóa)
- id=32: new current slot qv-tot, trỏ concept mới
- field.so_phut: boundary fixed (hết chặn "tổng phút cộng dồn thành concept riêng")
- field.tong_phut_congdon: created
- match_status distribution không đổi 27/2/1; 24/25/30 không đụng
7. Protected/sealed artifacts
Các file protection là vật liệu kiểm tra thủ công/agent, KHÔNG phải enforcement tự động.
/opt/incomex/docs/mcp-writes/sua-re/protection/g2-sealed-baseline-2026-07-07.json— sha256182575c1d71a5aeb56515657f9fcdf448bf91ce31b394e5f6158f354dcf8a2a6(8072 B; 2 khối snapshot_at_seal + forward_invariants, kèm snapshot_note + current_id_note nguyên văn theo yêu cầu bổ sung) — status: current_baseline/opt/incomex/docs/mcp-writes/sua-re/protection/g2-sealed-readonly-check-2026-07-07.sql— sha256bd7841da5e92bf7c6b967214b07c5c7d332483dfe50e3e26e40725466835208e(10846 B; SELECT-only, Group 1 snapshot / Group 2 invariant, qv-tot kiểm bằng slot_key+JOIN ở group invariant; comment sạch từ khóa; KHÔNG trong /opt/incomex/dot/sql, KHÔNG vào manifest) — status: current_checklist- sha256 xác nhận 2 phía: local shasum == VPS sha256sum, khớp 100%. Checklist đã chạy thử thật trên PG trước khi seal: 33/33 true.
- r2 golden/apply:
ef74898d…(golden mcp-writes + apply dot/sql, byte-identical) — status: applied - Old g2-1 golden/apply:
23ced9a4…— status: inert_guardrail_rejected (audit trail, không dùng lại) - Manifest: 10 dòng; dòng 9 = relpath cũ (inert), dòng 10 = relpath r2 (applied); không đổi trong G2-SEAL.
dot-pg-atomic-applysha256cf90611d…(ghi để đối chiếu).- g1-sealed-baseline-2026-07-07.json + g1-sealed-readonly-check-2026-07-07.sql — status: superseded_by_g2 (file vẫn nằm nguyên trên VPS làm lịch sử, không dùng làm current check).
8. Regression/integrity checklist
- G2 baseline là current baseline sau G2-SEAL — G1 baseline đã bị superseded bởi G2, không dùng G1 checklist làm current check nữa.
- G2 baseline là current cho đến khi có approved later delta. Khi có delta mới được approve + apply, phải tạo G3/G-next sealed baseline mới; không dùng checklist G1 hoặc G2 cũ để kết luận hồi quy sau khi đã có sealed baseline mới hơn.
- Agent sau phải đọc G2 final proof này (hoặc sealed baseline mới nhất) trước mọi write liên quan sua_re, chạy readonly checklist tương ứng, lệch không giải thích được → HOLD.
- Checklist G2 là manual/agent regression material, không phải automatic enforcement. Enforcement thật vẫn là: Owner gate (GO nguyên văn) + golden SQL + manifest allowlist + DOT guardrail + atomic transaction (psql -1) + verify read-only sau apply + KB report.
- Invariant bền (không phụ thuộc id): mỗi slot đúng 1 current; history không xóa; slot_key =
ui_id || '::' || location_anchor; item_key =slot_key || '::' || scan_id; match_status GENERATED không ghi tay; PG write chỉ qua DOT; delta approved sau này được phép supersede current rows.
9. Backlog
field.tong_thoigian_nhaptay— deferred (chưa có usage; cần delta riêng có Owner gate).- UI source thật chưa xử lý (G2 là ledger-only; dòng tổng phút trên UI không đổi gì).
- scan/re-scan pipeline chưa có (scan_id vẫn thủ công theo từng delta).
- SR-HARDEN-1 — biến bài học thành current-state/registry/preflight: (a) golden SQL không chứa từ khóa guardrail kể cả comment (preflight scan trước render); (b) hardcoded-id guard phải có pre-check id tương ứng; (c) chuỗi supersede baseline G1→G2→G-next thành registry đọc máy.
10. Caveat
- Old inert relpath cũ (
sua-re/concept-delta-time-values-g2-1.sql, manifest dòng 9) vẫn nằm trong manifest/filesystem — không dùng lại; guardrail sẽ tiếp tục chặn đúng file đó nếu chạy lại. - id=32 là current TẠI THỜI ĐIỂM G2 seal, không vĩnh viễn — approved SR-SUA delta sau này có thể đưa id=32 thành history và tạo current mới cùng slot; khi đó seal baseline mới.
- G2-SEAL không phải scanner tự động — chưa đăng ký measurement/scanner Điều 31; agent phải tự chạy checklist trước write.
- Nếu sau này có delta mới → phải seal baseline mới; checklist này chỉ đúng cho trạng thái G2 sealed.
- Protection files được đặt vào VPS qua kênh SSH với owner/perm khớp pattern G1 (10001:10001, 0664); sha 2 phía khớp nên nội dung đảm bảo nguyên văn.
11. Next gate
Đề xuất sau G2-SEAL (Owner chọn):
- SR-HARDEN-1 — đóng gói bài học thành preflight/registry (khuyến nghị trước khi làm delta kế tiếp); hoặc
- Dừng G2 tại đây — hệ ở trạng thái sạch: baseline current = G2, backlog ghi rõ, không có việc treo.
Agent sau không được tự suy GO cho bất kỳ bước nào.