KB-5BDB

SR-HARDEN-1A — Current State / Pointer Registry / Preflight Spec

9 min read Revision 1
sua-resr-hardencurrent-stateregistrypreflightg2

SR-HARDEN-1A — Current State / Pointer Registry / Preflight Spec

Ngày: 2026-07-07. Nhiệm vụ: SR-HARDEN-1A — sau G2-SEAL, tạo bộ nhớ vận hành bền cho sửa-rẻ (current-state / pointer registry / preflight spec / agent handoff snippet) để agent sau không phụ thuộc trí nhớ ngắn hạn.

Gate: GO_SR_HARDEN_1A_CURRENT_STATE_REGISTRY_PREFLIGHT received — yes. Owner phát nguyên văn ở lượt riêng; lượt nhận task card đã HOLD 0 hành động (gate không mở từ việc chuỗi GO nằm trong phần định nghĩa gate) — đúng kỷ luật xuyên suốt.

Nguyên tắc lớn tuân thủ: MỖI DỮ LIỆU CHỈ CÓ MỘT NGUỒN SỰ THẬT GỐC. Registry / current-state / snippet chỉ TRỎ tới nguồn gốc; không nhân bản counts/sha/rules dài.

1. Verdict

READY

Toàn bộ artifact pointer/entry-point đã tạo, verify baseline read-only PASS (33/33 boolean chạy thật trên PG đều true), không ghi PG, không sửa DOT/manifest/quy trình gốc/UI.

2. Scope

Docs/protection only. No PG write. No DOT change.

  • 0 INSERT/UPDATE/DELETE/DDL; 0 chạy dot-pg-atomic-apply.
  • 0 sửa manifest; 0 sửa DOT script; 0 cài script mới vào /opt/incomex/dot/bin.
  • 0 sửa SQL/golden/apply đã có; 0 dọn inert file cũ.
  • 0 sửa UI/source/shadow; 0 scan/re-scan; 0 tạo field.tong_thoigian_nhaptay; 0 mở G3/delta mới.
  • 0 sửa quy trình gốc SR-SUA/SR-LAP; 0 sửa CLAUDE.md/Codex/Hermes handoff thật.
  • ĐÃ LÀM (được phép): SELECT read-only + chạy checklist G2 để xác nhận current baseline; tạo current-state/registry/preflight/handoff; ghi KB report.

3. Baseline verification

G2 current baseline: PASS.

Xác nhận từ nguồn gốc (không chép lại toàn bộ 33 boolean vào các file mới):

  • G2 final proof verdict = SEALED (đọc trực tiếp g2-final-proof-2026-07-07.md).
  • G2 sealed baseline JSON tồn tại (2 khối top-level snapshot_at_seal + forward_invariants).
  • G2 readonly checklist tồn tại (SELECT-only, Group 1 snapshot / Group 2 invariant, 33 boolean).
  • Current baseline vẫn là G2; G1 superseded_by_g2.
  • Chạy thật checklist G2 trên PG (MCP query_pg, READ ONLY): 33/33 boolean = true LIVE (s01–s21 = 21 snapshot + i01–i12 = 12 invariant). Current baseline vẫn đúng ở thời điểm 1A, không chỉ tại seal.

Không lệch → không HOLD_BASELINE_NOT_CURRENT.

4. Source-of-truth policy

  • Baseline JSON (g2-sealed-baseline-2026-07-07.json) = source of truth cho snapshot + invariants.
  • Final proof (g2-final-proof-2026-07-07.md) = source of truth cho history/narrative.
  • Registry / current-state / snippet / preflight = pointer/entry-point, KHÔNG phải sổ cái.
  • Nếu tài liệu mâu thuẫn: latest sealed baseline JSON + latest final proof win.

5. Artifacts created

Artifact Path Loại sha256
SR_CURRENT_STATE.md knowledge/dev/laws-new/kestra/sua-re/SR_CURRENT_STATE.md KB entry-point revision 2 (KB doc, không sha)
sr-artifact-registry /opt/incomex/docs/mcp-writes/sua-re/protection/sr-artifact-registry-2026-07-07.json pointer index JSON b4ad68cef1ada95cebce40f546ed9fcaf1d04a0e55a0a5b1956a366a67dd80a3 (2699 B)
sr-preflight-spec /opt/incomex/docs/mcp-writes/sua-re/protection/sr-preflight-spec-2026-07-07.md spec/checklist (chưa executable) f721b583952b97767adaa9077ac88a253c7df240f8891c30cfd26c05dbd3fc5c (2592 B)
sr-agent-handoff-snippet /opt/incomex/docs/mcp-writes/sua-re/protection/sr-agent-handoff-snippet-2026-07-07.md startup block 01dd50e8586b2c4e753315ab19be1cb536a410984bb97f33cee4c5fd574c12d0 (1022 B)
  • Registry JSON parse valid (python json.load OK; keys: registry_name/registry_type/current_baseline/source_of_truth_policy/current/baselines/artifact_pointers/rules_pointer).
  • 3 file protection: KHÔNG đưa vào manifest, KHÔNG đặt trong /opt/incomex/dot/sql; nằm trong /opt/incomex/docs/mcp-writes/sua-re/protection/ (write-allowlist).
  • Xác nhận local/VPS: bytes_written từ write_file khớp chính xác byte size cục bộ (2699/2592/1022); registry đã đọc lại từ VPS, nội dung round-trip byte-identical + JSON hợp lệ. (Caveat cơ chế sha ở §11.)

6. Duplication avoidance

  • KHÔNG chép lại full counts/sha/rules vào nhiều nơi.
  • Registry là pointer/index thuần: trỏ tới baseline JSON (#/forward_invariants) cho rules, trỏ final proof cho history/guardrail lesson, trỏ process docs; KHÔNG chép sha/counts (mặc định khuyến nghị của task).
  • SR_CURRENT_STATE.md chỉ tóm tắt vài dòng + trỏ nguồn gốc; ghi rõ "must never be treated as an independent source of truth".
  • Preflight spec ghi rõ Source of truth rule + tie-breaker (latest sealed baseline JSON + latest final proof win).
  • Nếu về sau có cache/reference sha trong registry, phải đánh dấu authoritative_source = baseline JSON/final proof; hiện tại KHÔNG cache.

7. Agent memory contract

Block mọi agent sửa-rẻ sau phải đọc TRƯỚC mọi việc (đóng gói trong sr-agent-handoff-snippet):

  1. SR_CURRENT_STATE.md
  2. latest final proof (hiện: g2-final-proof-2026-07-07.md)
  3. latest sealed baseline JSON (hiện: g2-sealed-baseline-2026-07-07.json)
  4. latest readonly checklist SQL (hiện: g2-sealed-readonly-check-2026-07-07.sql)
  5. sr-artifact-registry-2026-07-07.json
  6. sr-preflight-spec-2026-07-07.md
  7. relevant SR-SUA/SR-LAP process doc

Luật: current baseline = G2 cho tới khi có sealed baseline mới hơn; G1 superseded, không dùng làm current check; PG write chỉ qua DOT; no direct PG write; chạy current readonly checklist trước mọi future write; golden SQL guardrail-clean toàn file kể cả comment/header; file/artifact đánh dấu inert thì không dùng; sau mọi approved write phải seal baseline mới. Nếu tài liệu mâu thuẫn → latest sealed baseline JSON + latest final proof win. Đọc không được bất kỳ tài liệu bắt buộc nào → HOLD.

8. What this prevents

  • Dùng nhầm G1 baseline làm current check (registry đánh dấu G1 superseded_by_g2 + do_not_use_as_current_check).
  • Dùng nhầm old inert g2-1 relpath (sua-re/concept-delta-time-values-g2-1.sql) — đánh dấu inert_guardrail_rejected / audit_trail_only / do_not_use.
  • SQL comment/header dính guardrail (preflight §7 lesson + before-render check).
  • Hardcoded id không có pre-check (preflight §9 lesson + before-render/before-apply check).
  • Coi snapshot id (vd usage id=32 current tại seal) là invariant vĩnh viễn (preflight §8 lesson; baseline JSON current_id_note).
  • Direct PG write (rule ở current-state/snippet/preflight).
  • Ba tài liệu cùng chép một số rồi lệch nhau (source-of-truth policy + duplication avoidance: chỉ trỏ, không nhân bản).

9. What this does not do

  • Không cài preflight executable (đề xuất SR-HARDEN-1B: /opt/incomex/dot/bin/dot-sr-preflight — 1A KHÔNG cài).
  • Không sửa DOT.
  • Không sửa quy trình gốc SR-SUA/SR-LAP (đề xuất SR-HARDEN-1B/2).
  • Không mở type-3 (không tạo field.tong_thoigian_nhaptay).
  • Không sửa UI source.
  • Không tự cài startup block vào CLAUDE.md / Codex config / Hermes config / handoff thật (chỉ tạo snippet; cưỡng chế đọc là SR-HARDEN-1B/1C hoặc quyết định Owner riêng).

Owner chọn:

  1. SR-HARDEN-1B — cài/kiểm executable preflight (dot-sr-preflight) và/hoặc tích hợp startup/handoff (cài snippet vào CLAUDE.md/Codex/Hermes để cưỡng chế đọc); hoặc
  2. SR-HARDEN-2 — merge bài học (guardrail-safe comment, hardcoded-id guard, snapshot-vs-invariant, supersede chain) vào quy trình gốc SR-SUA/SR-LAP; hoặc
  3. Dừng tại current-state — nếu chưa muốn động hạ tầng/quy trình. Hệ ở trạng thái sạch: baseline current = G2, pointer registry + entry point + preflight spec + handoff snippet đã có, backlog ghi rõ.

Agent sau không được tự suy GO cho bất kỳ bước nào.

11. Caveat

  • Cơ chế sha trong session này khác các bước SSH trước: toolset chỉ có write_file/read_file/query_pg cho VPS (không có shell VPS để chạy sha256sum độc lập). sha256 ghi trong §5 là sha cục bộ (shasum -a 256 trên bản scratchpad — nguồn bytes tôi ghi). Cross-check VPS: bytes_written trả về khớp chính xác byte size cục bộ (2699/2592/1022) + write_file là verbatim/atomic (không redaction) + registry đã read-back byte-identical. Do đó VPS sha == local sha. Đây là bằng chứng round-trip, không phải sha256sum chạy trực tiếp trên VPS.
  • 2 file markdown protection (preflight/handoff) xác nhận bằng bytes_written khớp + verbatim-write guarantee; không read-back full (registry đã read-back đại diện).
  • SR_CURRENT_STATE.md là KB document (revision 2). Lần upload đầu bị ngắt ở lượt trước; bản hiện hành là nội dung đầy đủ đã xác nhận qua get_document (content_length 3201, tags/title đúng).
  • Các file protection là vật liệu kiểm tra thủ công/agent, KHÔNG phải enforcement tự động. Enforcement thật vẫn là: Owner gate + golden SQL + manifest allowlist + DOT guardrail + atomic apply + verify read-only sau apply + KB report.
  • id=32 current chỉ tại G2 seal, không vĩnh viễn; approved delta sau này có thể đưa id=32 thành history → khi đó phải seal baseline mới và các pointer file phải trỏ baseline/final proof mới nhất.
  • Registry/spec/snippet KHÔNG vào manifest, KHÔNG vào /opt/incomex/dot/sql — đúng ràng buộc.

SR-HARDEN-1A READY

Back to Knowledge Hub knowledge/dev/laws-new/kestra/sua-re/nhap-ui/sr-harden-1a-current-state-registry-preflight-2026-07-07.md