[CLAUDE] Docs: S103 AI_INFRA 6-broadcast adap — crystallized-backfill (measure-then-fill) + Harness-20 fix-all-structure + memory-hygiene mapping
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 5m26s
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 5m26s
Adap 6 broadcast (hash MATCH cả 6 indep-recompute) qua 2-workflow Harness-9: - Harness-20 fix-all-structure -> engine §L + dogfood model-note 4-tầng-sweep (incl PERSONA) + 220K→380K neo-supersede + 2-đầu-catch (review bắt 2 DẪN-XUẤT stale-trailer sweep-sót → fixed) - F4 crystallized-backfill = NEW scripts/crystallized-backfill.ps1 (measure-then-fill DRY NO-API; default target=0=OFF owner-authority; calibrated-range; precondition; file-floor=UPPER-BOUND honest) + budget.json config + budget-table wire - F1/F3 already-met (0 hardcoded-violation persona-clean; BƯỚC 0.6 bắt S103=Opus real-metadata) - session-cmd budget-table (Up1) + run-loop 2-tầng (Up2 largely-already-met §L.b(c)) - H16 no-key Applied% = NEW scripts/applied-eval-nokey.ps1 (adversarial-gate fail-closed 3-ca + fault-inject FLIP; mechanism-built numbers-DEFERRED) - memory-hygiene A/B already-met (archive-gate DRY-RUN + governance-detectors 4-layer 1:1); C n/a JS-sandbox no-CLI-launcher - consolidation reference-ack (crystallization≠backfill) engine §L+§M · 6 adap-report + 1 adap-request (#53-garble reasoning-lane mitigation) · send-email fc1e22ac selftest-MATCH · check-email 3 pulled+verified+STAGE-2. 2-workflow: WF1 implement wf_55ef6778-a0d (3 lane schema-CLEAN, selftest exit-0 ×2 + fault-inject teeth) + WF2 review wf_3c5c37cb-aa2 fable-clone (Lane-C PASS returned + Lane-B recover-from-memory PASS; 0-BLOCKING 2-CONCERN-addressed). #53 garble ×3 → em-main recover; investigator AS-10 garble-curation REVERTED (git-backstop). Runtime S103 = Opus (Fable outage lại, per-session flip; H5-fallback revert-free). State GIỮ NGUYÊN: Mig 61 · 89 bảng · 440 test · gotcha 79 · menu 54. 0 prod-code. Co-Authored-By: Claude Opus 4.8 (1M) <noreply@anthropic.com>
This commit is contained in:
@ -68,6 +68,22 @@
|
||||
"read_only_scope": "MFE WRITES exactly one file: .claude/agent-memory/.mfe-state.json (its own strikes-state for cross-run Goodhart compare). 'READ-ONLY' is scoped to token_governor / the budget caps (owner-authority) which it NEVER writes -- it is NOT the claim 'writes nothing'."
|
||||
}
|
||||
},
|
||||
"crystallized_backfill": {
|
||||
"_note": "Harness-20-era (S103, 2026-07-06) crystallized-backfill = 'measure-then-fill'. Read by scripts/crystallized-backfill.ps1 (deterministic NO-API DRY planner). Adapts AI_INFRA broadcast 2026-07-04 F4 + session-cmd-budget-display Upgrade-1. DISTINCT from CRYSTALLIZATION (engine §I distill = compress-TOWARD-source, keep time-invariant): backfill goes the OPPOSITE direction = FILL the empty hot-feed budget with already-crystallized cold-tier data so the cap is not wasted. PRECONDITION: expected_backfill opens ONLY when target>0 AND measured_headroom>0. Default target=0=OFF. NOT-for-sub (sub packs are lead-curated per-task; blind-pour dilutes relevance).",
|
||||
"target": 0,
|
||||
"_target_note": "OWNER-AUTHORITY static number (mirror token_governor.role_boundary_note + mark RC-...21-06...01-58-01). 0 = OFF/disabled = default. Owner raises >0 ONLY after judging a POSITIVE real-token headroom exists on the stable hot-load floor. The AI (em-main) NEVER sets/auto-tunes this; the script is READ-ONLY on it.",
|
||||
"hotload_sources": [
|
||||
"docs/STATUS.md",
|
||||
"docs/HANDOFF.md",
|
||||
".claude/governance/ACTIVE-MARKS.md",
|
||||
"docs/changelog/migration-todos.md",
|
||||
"docs/gotchas.md",
|
||||
".claude/agents/README.md"
|
||||
],
|
||||
"_hotload_note": "STABLE always-on FILE-FLOOR only (reproducible session-to-session). measured_headroom over this list = an UPPER BOUND on real headroom: the PEAK hot-feed ALSO loads session-VARIABLE lead-pasted task-context (task-relevant docs / code / gotcha-slices / engine-slices) that is NOT a fixed file-list, so the real peak approaches the ~368K lead read-set (token_governor.lead_note) and real headroom is SMALLER than this floor-measure shows. This is exactly broadcast F4's warning: byte/4 undercount + partial-source-list = 'illusion of room'. Hence target stays 0 until the owner judges stable room exists.",
|
||||
"source_order": ["gist", "value-marked-archive", "curated-RAG"],
|
||||
"_source_order_note": "value-gated, dedup vs hot-load, only TIME-INVARIANT crystallized content (NOT raw-episodic / volatile): (1) archive/<period>.gist.md 4-field distill; (2) archive lines carrying value_protect markers (gotcha# / anti-pattern / root-cause / lesson); (3) curated RAG search_memory. The PLANNER prints this order; it performs NO pull (DRY, like memory-archive-gate.ps1) - zero context change."
|
||||
},
|
||||
"harness_floor": {
|
||||
"_note": "Harness-15 A1/A3 (S81, 2026-06-20): SAN-harness = fixed per-spawn cost (NOT tunable) = tool-schema + framing + own persona/role file + lead-pasted base-doc slice + task prompt. SEPARATE HOUSE (A3 anti-double-count): persona + lead-pasted-docs belong HERE (floor), NOT counted in token_governor.l1_always (which = own agent-memory + archive index + work-state block only). MEASURED-ESTIMATE not exact (H15 honest-note b): persona = directly measured bytes (.claude/agents/<name>.md 4.3KB-13.3KB => ~1.3K-4.0K tok via /3.3); tool-schema + framing = harness-injected (cannot byte-count locally), estimated comparable to AI_INFRA same-toolset-family (Read/Write/Edit/Bash/Grep/Glob/Skill/RAG).",
|
||||
"measured_token_estimate": 21000,
|
||||
|
||||
@ -11,7 +11,8 @@
|
||||
- [S89 PE ends-before-CEO PLAN review](project_s89_pe_endsbeforeceo_plan_review.md) — CONCERN: BE 3-field design sound (Mig 58 col committed, no mig) but FE coverage gap — 4 PeUrgentChips render-sites, plan covered only 2 (missed InboxPage:290 despite BE Inbox A2 updated + wrong ListPage dir path).
|
||||
- [S89 finalize-note PLAN review](project_s89_finalize_note_plan_review.md) — CONCERN: plan ground-truth 100% accurate (all file:line verified incl self-flagged); gaps = note doesn't say intermediate approvers still sign + skipToFinal-last-level corner + Dev DB 9 migs behind.
|
||||
- **S101 H18 WF2 governance re-run (self=workflow-lane · em-main synthesized):** re-verified S100 Harness-18 adopt (`5ee32c0`, governance-only) — original WF2 `wf_31ea3985-92c` lost to CLI-restart → fresh `wf_955643c3-f7d` **PASS_WITH_CONCERNS**. Lane-A detector-teeth PASS (fault-inject 4/4 `-RepoRoot` temp-tree — proved detector FLAGS injected-stale, not happy-path). Lane-B caught **1 CONCERN em-main missed in S100 sweep**: `workflows/README.md:51` stale label "ledger orphan-scan" (NO `_ledger` token → grep-exact sweep skipped) → FIXED S101. Lesson: **exact-token sweep misses paraphrased labels** — widen to concept-phrase when retiring a named artifact. Lane-C **#53 return-garble** (workflow-lane returned no StructuredOutput) → recovered first-hand, NOT re-spawned (`feedback_agent_return_garble_recover`).
|
||||
- **S101 H19 WF2 review LANE-C (adap-reports + honesty · self=reviewer · `wf_5f308fd8-744`=WF1):** PASS. 4 adap-reports (H19 fable-clone + 3 model-tier: opus / checklist / v2-pin-simple) + send-email 6c selftest. **Hash re-computed indep (PS .NET UTF8, canonical split-3 + strip-1-newline):** H19=`6909299a…` MATCH · model-tier=`ee00d253/a7ff304b/eed277f7` all MATCH · **all 4 carry `reviewer_gate: PASS`**. Model-tier 12/12 honest: C1 11/11 frontmatter `inherit` · C3 gotcha `[1m]` = frontmatter-scoped 0 vs naive `grep -c` = 4 PROSE hits (README:9/12/16 upgrade-notes + database-agent:46 rule-line — verified NOT frontmatter). Q1 G-015=git-diff+folder-scan orphan (error-ledger AS-10) · **Q2 hysteresis `0.85/5/2` VERIFIED verbatim in memory-budget.json:35-37**. **KEY honesty-catch (resolved-benign):** model-tier line 29 "re-stamp H10 `5f511fe5`→`5f8b8504`" reads like commit-SHA pair — `git cat-file` = NOT commits; **but hash-recompute proves they are content_sha256 BODY-hashes** (5f511fe5=old-no-strip / 5f8b8504=canonical = current declared) → claim TRUE (`→`=hash-transition), only presentation-nit. **Anti-consensus dogfood** cites `commit f229b07` (run-folder ephemeral) — S101 WF2 Lane-B catch; honest framing = "ensemble-PATTERN proven" NOT "H19-toggle verified" (nấc="designed+will-dogfood", "thật-mode CHƯA chạy"). No overclaim: only "verified" hits = G-011 legend + "verified-pending-restart". §9 3-floor-points verbatim in RC-stamp + VACUOUSLY-MET-SE annotation present (value=future-proof+anti-consensus NOT cost). send-email 6c ABORT recompute-SAME-as-step-4 + ordered BEFORE step-7-log. Marker `fable-real-mode.on` gitignored ✓ / command-file tracked ✓. Lesson: **hex→SHA disambiguation — recompute BOTH strip/no-strip variants to prove a hex string is a body-hash not a commit-SHA when text is ambiguous.**
|
||||
- [S103 H20+crystallized-backfill review](project_s103_h20_crystallized_backfill_review.md) — WF2 PASS (Lane-B gov-fidelity + Lane-C already-met/no-overclaim, fable-clone ensemble). 6/6 hashes recompute MATCH; 4 already-met VERIFIED file:line (detectors 4-layer C2 `if n≠canon`:247 · archive-gate value_protect ADVISORY:55-56 · C launcher n/a hmw.js:4-5 · F3 BƯỚC0.6 reads env-runtime:37); all no-overclaim danger-phrases NEGATED-context; applied-eval 4-caveat + selftest exit-0 fault-inject teeth; crystallized-backfill DRY target=0=OFF. 2 NIT: script echoes bare headroom w/o partial-floor-axis caveat (doc-layer+wire DO carry UPPER-BOUND) · guide-doc Opus-4.7 examples out of §L.D n=1 scope. **Lesson: multi-axis warning (F4=token-undercount + partial-source-list) must appear in the SCRIPT's own output, not only the doc — reader runs script inline.**
|
||||
- **S101 H19 WF2 review LANE-C (adap-reports + honesty · self=reviewer · `wf_5f308fd8-744`=WF1):** PASS. 4 adap-reports (H19 fable-clone + 3 model-tier) + send-email 6c. Hashes recompute indep MATCH (H19 `6909299a` + model-tier `ee00d253/a7ff304b/eed277f7`), all carry `reviewer_gate: PASS`. 12/12 honest; Q2 hysteresis `0.85/5/2` verbatim budget.json:35-37. Danger-phrase "verified" only in G-011 legend + "verified-pending-restart"; nấc="designed+will-dogfood, thật-mode CHƯA chạy". **Lesson: hex→SHA disambiguation — recompute BOTH strip/no-strip variants to prove a hex string is a content_sha256 BODY-hash not a commit-SHA (line-29 `5f511fe5→5f8b8504` = hash-transition, `git cat-file`=not-commits, claim TRUE presentation-nit only).**
|
||||
|
||||
---
|
||||
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
---
|
||||
name: s103-h20-crystallized-backfill-review
|
||||
description: S103 WF2 Lane-B review (fable-clone ensemble) of H20 fix-all-structure + crystallized-backfill adap — PASS, 2 non-blocking CONCERN. Read when reviewing governance-doc fidelity or fix-all-structure dogfood.
|
||||
metadata:
|
||||
type: project
|
||||
---
|
||||
|
||||
**S103 (2026-07-06) H20+crystallized-backfill WF2 Lane-B — governance-doc fidelity + fix-all-structure dogfood · self=reviewer · fable-clone ensemble H19. Verdict: PASS (0 BLOCKING, 2 CONCERN).**
|
||||
|
||||
Scope: 6 broadcast adap (H20 fix-all `bd714a33` + full-recheck-F1-F4 `94c78d1d` + session-cmd-budget-runloop `d47333e0` + H16-nokey `a1dc3a20` + hygiene-A/B/C `43c9e56f` + consolidation `5bba339b`). Deliverables: engine §L+§M, 2 scripts (crystallized-backfill.ps1 + applied-eval-nokey.ps1), memory-budget.json block, session-start §2.1.6 + session-end §L.b(c) wiring, model-note sweep 4 spots.
|
||||
|
||||
**Hash re-computed indep** (PS .NET UTF8, split-on-`^---$` regex take-3rd + strip-1-leading-newline): all 6 MATCH (full-64 on the 4 declaring full). Q4 PASS.
|
||||
|
||||
**Q1 §L fidelity:** 4-layer NHÌN/NGUỒN/DẤU/DẪN-XUẤT + PERSONA (5th, = broadcast F2 toxic-layer emphasis) present · anti-asymmetric ordering "đủ-tầng>không-sửa>sửa-lệch-tầng" verbatim broadcast §2 · 4-step (L.B) + 2-head cross-axis (L.B) present · 0 floor dropped vs bd714a33.
|
||||
|
||||
**Q2 §M fidelity:** F4 5-floors all present (default-0=OFF / NOT-sub / calibrated-range [bytes/4..bytes/3.0] / precondition target>0 AND headroom>0 / value-gated source-order) · crystallization≠backfill DISTINCT (OPPOSITE direction: engine §I distill=compress-toward-source vs §M=fill-empty-budget) · budget-table (M.B) · run-loop 2-tier (M.C, honestly "largely already-met §L.b") · no-key mechanism (M.D, honestly "MECHANISM built, numbers DEFERRED") · hygiene A/B/C mapped (M.F: C=n/a-by-JS-sandbox-architecture, not CLI-launcher) · 0 floor dropped.
|
||||
|
||||
**Scripts REAL teeth (5 fault-inject `-RepoRoot` temp-tree):** (1) target=0→backfill=0 OFF · (2) target=5000+pos-headroom→backfill=5000 opens · (3) target>headroom→headroom-binds(67) · (4) NEG-headroom(tiny cap)→backfill=0 = broadcast borderline near-cap case · (5) -Tier sub→NOT-FOR-SUB warn fires. applied-eval selftest EXIT-0 3/3 (control-HIGH→BLOCK · control-LOW→PASS+Applied%=70 · control-null→BLOCK; `$script:`-scope flip survives nested Assert-Case = fault-inject-caught real bug per header).
|
||||
|
||||
**Q3 fix-all-structure dogfood VERIFIED:** 4 spots correct — README:3 + session-start:37 (BƯỚC 0.6) + session-end:113 (release-line) → S103-Opus; engine §G.5 → 220K neo-superseded (present 7×, NOT deleted; 380K override present 5×). History-saga NOT rewritten: README:12 H8-caveat UNCHANGED (README diff = 1-line-only = line-3), adap-reports 2026-06-10/06-13 dated-snapshots preserved (LỊCH-SỬ/SNAPSHOT, correctly kept). Persona-layer (the F2 toxic layer, `.claude/agents/*.md`) clean of stale steady-Fable current-claim.
|
||||
|
||||
**2 CONCERN (non-blocking):**
|
||||
1. STATUS:24 Sub-agents row + STATUS:6/HANDOFF:5 last-updated still read S102-Fable / S101 as latest current-state (not yet S103-Opus). Engine §L.D EXPLICITLY defers STATUS/HANDOFF mega-line current-claim to session-end blurb (natural update-point). NOT persona (not reloaded per spawn) → tailoring defensible + honestly disclosed. But at review-time (mid-session, pre-session-end) the Sub-agents current-state row IS technically ĐANG-SAI under strict fix-all-structure.
|
||||
2. tooling-auditor/MEMORY:17 roster-header "Fable 5 RESTORED S98" while line-46 records S103-Opus divergence (data-point #7 DIVERGENT) = header/body tier-lag. Internal diary (not persona, not outward, not in the 4-spot dogfood scope) → NIT-tier.
|
||||
|
||||
**KEY honesty-check (resolved-HONEST):** §M.A + budget.json `_hotload_note` claim "real peak ~368K near-cap → real headroom SMALLER" while LIVE crystallized-backfill shows headroom=282384 POSITIVE (~74% free over the 6-file floor: STATUS/HANDOFF/ACTIVE-MARKS/migration-todos/gotchas/agents-README = 292848 bytes → 97616 tok worst-case). Reconciliation SOUND: `_hotload_note` explicitly labels measured_headroom an UPPER-BOUND — the PEAK hot-feed also loads session-variable lead-pasted task-context (docs/code/gotcha-slices) NOT in the fixed file-list, so real peak → ~368K and real headroom SMALLER; matches broadcast F4 "byte/4 undercount + partial-source-list = illusion of room"; target stays 0 BECAUSE of this uncertainty = honest disclosure, NOT overclaim.
|
||||
|
||||
**Lesson:** when a planner measures only a FILE-FLOOR subset, verify the doc labels the headroom as UPPER-BOUND — a positive floor-headroom that superficially contradicts a "near-cap" narrative is HONEST iff the partial-source-list caveat is explicit (else it would be an illusion-of-room overclaim). Also: hash-recompute all 6 broadcasts independently (never trust declared frontmatter) — canonical = split-on-`^---$` take-3rd, strip exactly 1 leading newline, SHA256 UTF-8.
|
||||
|
||||
Cross-ref: [[wire-claim-verification-anchors]] (sha256 twin-file discipline) · broadcast F2/F3 persona-layer sweep · engine §L/§M (`docs/governance/harness-11-engine.md`).
|
||||
@ -43,3 +43,4 @@ H1 tooling-freshness auditor **SOLUTION_ERP-self**. Read-only + **propose-only**
|
||||
- **2026-07-03 (S101 @start RE-REPORT — ALL-4 PASS + MODEL-DRIFT, on-behalf em-main APPEND B3):** HEAD `5ee32c0`, tree 1-dirty (cicd MEMORY M #486 pre-existing). ①SKILL PASS 6+23+14 (2 detector-flag ef-core/contract-workflow = FP module-local, numbers MATCH canonical). ②ROSTER PASS 11=11=11, 11/11 inherit, ASCII-diagram cosmetic-drift known-debt. ③PLUGIN PASS 18/15/3 + marketplace 35 + xhigh + `claude-fable-5[1m]`:11 identical, 0 new-alloc. ④DOCS PASS (S100 closeout clean; F2 SendMessage + F3 count both fixed-verified). 🔴 **MODEL-DRIFT (inherit-chain data-point #4 = DIVERGENT):** this spawn + lead + WF2-reviewer all self-report **`claude-opus-4-8`** (NOT `claude-fable-5` S98/S99) while `settings.json:11` still pins `claude-fable-5[1m]` → **Fable unavailable S101 → H5-fallback tự-kích** (revert-free, no frontmatter change). "Fable RESTORED S98" = point-in-time NOT steady-state → em-main reconciled STATUS:24 + agents/README:3 with S101-runtime caveat. Lesson: **inherit-chain self-report = runtime availability probe — verify each session, don't trust last-session model claim.** Tag `[s101-start, 4-mat, all-pass, model-drift-opus, h5-fallback-reactivated]`.
|
||||
- **2026-07-03 (S101 @closeout CHỐT — on-behalf em-main APPEND B3):** HEAD `e350660`, tree CLEAN, 2 commit S101 pushed (`f229b07` H18-closeout + `e350660` H19-adopt). ①SKILL/COMMAND **DELTA: command 14→16** (+`fable-real.md`+`fable-clone.md` H19 thật/ảo-toggle — verified `ls|wc`=16; 🔴 **là COMMAND KHÔNG phải skill** — SlashCommand-tier ≠ `skills/<n>/SKILL.md` Skill-tier, đừng conflate "auto-registered skill"; skill vẫn **6+23**) + session-start BƯỚC 0.5b + send-email 6c present. **KHÔNG command-catalog canonical** trong docs → 2 fable-* KHÔNG tạo catalog-drift, KHÔNG cần doc-register. ②ROSTER 11=11=11 (H19 0 agent mới, dùng reviewer+investigator-cb sẵn), 11/11 inherit. ③PLUGIN 18/15/3 identical + xhigh + pin-fable giữ (revert-free dù runtime-Opus), 0 new-alloc. ④DOCS PASS: H19 đầy-đủ path:line-verified (engine §K:315-334 + ACTIVE-MARKS:19 RC-verbatim + STATUS:6/:24/:40 + HANDOFF + session-log + 4 adap-report). 🔴 **model self-report `claude-opus-4-8` = inherit-chain data-point #5 DIVERGENT-confirmed** (Fable vẫn unavailable). **new-alloc: NOTHING-TO-ALLOCATE.** **Flags:** F-H19a LOW (agents/README+reviewer+investigator-cb 0 H19-note → **DEFER** vacuously-inert + no-catalog + single-sourced §K; note khi Fable-về + toggle-first-run có runtime-delta) · F-H19b VERY-LOW (session-start BƯỚC-0.6 Fable-steady → em-main FIXED S101 +Opus-caveat). Baseline command-count 14→**16** (self-fix note). Tag `[s101-closeout, 4-mat-chot, command-14-16, model-drift-5, f-h19a-defer, on-behalf]`.
|
||||
- **2026-07-06 (S102 @start RE-REPORT — ALL-4 PASS + FABLE VỀ LẠI, inherit-chain data-point #6):** HEAD `3e2c18b` (=S101 closeout), tree CLEAN, 0 commit sau S101 → disk S102-pre == S101-end. **Model: spawn này self-report `claude-fable-5`** = Fable RESTORE lần 2 (chuỗi S98 Fable → S101 Opus → S102 Fable — availability per-session, đúng lesson S101). ①SKILL PASS 6+23; ef-core `:3`/`:19` B1-pointer + Mig 61 khớp disk-61 (`ls` Migrations = 61). ②ROSTER PASS 11 file = 11 kỳ-vọng, 11/11 `model: inherit` line-5; S101-window: harvest-curator.md + agents/README.md M-only, 0 agent THÊM/XÓA. ③PLUGIN PASS 18/15/3 (settings:17-35) + marketplace 35 + xhigh:37 + `claude-fable-5[1m]`:11 identical, 0 new-alloc. ④DOCS PASS: (a) BƯỚC 0.5b hiện diện session-start:27-33; (b) fable-real/clone semantics inverse ĐÚNG (real=tạo marker :10 / clone=xóa :8), registry loaded = restart đã xảy ra; (c) **model-note S101-Opus cần S102-reconcile 3 vị-trí: STATUS:24 · agents/README:3 · session-start:37 (BƯỚC 0.6)** — đề xuất APPEND data-point giữ S101 làm history; (d) marker KHÔNG tồn tại + gitignore:92 + not-tracked. **Trigger-met: BƯỚC 0.5b:33 "nhắc anh khi Fable về + phân-tầng"** → em-main nhắc anh H19 tiering. Command 16 (brief "~20" = overestimate; 16 = đúng đủ, hmw ≠ command-file). Counts khớp: Mig 61 · gotcha 79 (grep) · test 440 · 89 bảng. F-H19a defer-condition "khi Fable-về" cũng MET → em-main cân nhắc note. Tag `[s102-start, 4-mat, all-pass, fable-restore-2nd, model-note-reconcile-3]`.
|
||||
- **2026-07-06 (S103 @start RE-REPORT — ①②③ PASS, ④ 1-FLAG model-note per-session flip, inherit-chain data-point #7 DIVERGENT):** HEAD `62cff38` (=S102 closeout), tree CLEAN, 0 commit sau S102 → disk S103-pre == S102-end. Project `.claude/settings.json` KHÔNG tồn tại → model resolve user-global. **Model: spawn này self-report `claude-opus-4-8`** (env-confirmed) = Fable UNAVAILABLE lại (chuỗi **S98 Fable → S101 Opus → S102 Fable → S103 Opus**, flip lần 4 — availability per-session KHẲNG-ĐỊNH lại). ①SKILL PASS 6+23+16 (last-touch skills/ = `4263d63` S98, 0 đổi); ef-core `:3`/`:19`/`:83` Mig 61 + `:85` 89-bảng khớp disk (`ls` Migrations = 61, last=`...142752_BackfillEndedByLevelFinalizeFromChangelog.cs`) + khớp STATUS:14/:15; skills/README:20 "Updated S98"/:90 #79 fresh. ②ROSTER PASS 11=11=11, 11/11 `model: inherit`; ASCII-diagram cosmetic-drift known-debt (KHÔNG mới); last-touch agents/ = `62cff38` S102 M-only 0 agent THÊM/XÓA; VALID_ROLES 9 product-by-design. ③PLUGIN PASS 18/15/3 (3 disabled: pr-review-toolkit/code-modernization/hookify) + marketplace 35 + xhigh + `claude-fable-5[1m]`:11 identical, 0 new-alloc. ④DOCS canonical 7-count khớp disk (Mig61/89/440/gotcha79/menu54/11sub/6skill). 🔴 **FLAG-M (LOW, on-behalf APPEND đề xuất):** 3 model-note (STATUS:24 · agents/README:3 · session-start:37 BƯỚC 0.6) carry **S102-Fable "VỀ LẠI"** — KHÔNG drift-sai (đúng-tại-S102 + đã ghi "per-session, không tin note phiên trước") chỉ thiếu **data-point S103-Opus**. Đề xuất em-main APPEND caveat S103-Opus vào 3 vị-trí (giữ history, KHÔNG frontmatter/con-số), **SAU khi em-main tự-xác-nhận lead-runtime S103** (report này = 1-spawn probe, G-015 honesty — chưa xác nhận lead + sub khác). Marker fable-real KHÔNG tồn tại → Fable-clone default (đúng). Carry-debt: schema-diagram §16+ ERD · monthly count-grep +commands/*.md. Method-shortcut tái-dùng: `git log -- .claude/skills/` last-touch confirm no-change nhanh hơn re-read. Tag `[s103-start, 4-mat, model-note-flip-opus, data-point-7-divergent, flag-m-low, on-behalf]`.
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# Multi-agent SOLUTION_ERP — Master Coordination Guide (11-agent)
|
||||
|
||||
> **Architecture:** 11 sub-agents **all-inherit top-tier (Harness-8 2026-06-16 — thay thế two-tier Harness-4)** + em main **Fable 5 (1M) Max** coordinator — **9 product/quality** (7 core + frontend-designer pink S47 + database-agent read-advisory S52) + **2 monitor INFORM-only** (`tooling-auditor` H1 + `harvest-curator` H2, 2026-06-07 Harness 1). Tier: **toàn bộ 11 sub `model: inherit`** (ăn top-tier model của lead — ✅ **Fable 5 1M RESTORED, runtime-verified S98 2026-07-02**: 2 monitor spawn-test self-report `claude-fable-5`; giai đoạn fallback Opus H5 S62→S97 kết thúc; ⚠️ **S101 2026-07-03 runtime = Opus lại** — lead + 2 monitor + WF2-reviewer inherit self-report `claude-opus-4-8`, settings pin fable → Fable unavailable phiên này, H5-fallback revert-free [chi-tiết STATUS §Sub-agents]; ✅ **S102 2026-07-06 runtime = Fable trở lại** — self-report `claude-fable-5` ×3 [lead + 2 monitor], per-session availability) · effort **Max** (env machine-wide). SE KHÔNG có lớp helper/gopher rẻ (cả 11 đều substantive memory-bearing → cả 11 lên inherit). *(Trước H8: 4 promote inherit + 7 demote pin `claude-opus-4-8` — lịch sử ở Upgrade 2026-06-10 + S66 dưới.)*
|
||||
> **Architecture:** 11 sub-agents **all-inherit top-tier (Harness-8 2026-06-16 — thay thế two-tier Harness-4)** + em main **Fable 5 (1M) Max** coordinator — **9 product/quality** (7 core + frontend-designer pink S47 + database-agent read-advisory S52) + **2 monitor INFORM-only** (`tooling-auditor` H1 + `harvest-curator` H2, 2026-06-07 Harness 1). Tier: **toàn bộ 11 sub `model: inherit`** (ăn top-tier model của lead — ✅ **Fable 5 1M RESTORED, runtime-verified S98 2026-07-02**: 2 monitor spawn-test self-report `claude-fable-5`; giai đoạn fallback Opus H5 S62→S97 kết thúc; ⚠️ **S101 2026-07-03 runtime = Opus lại** — lead + 2 monitor + WF2-reviewer inherit self-report `claude-opus-4-8`, settings pin fable → Fable unavailable phiên này, H5-fallback revert-free [chi-tiết STATUS §Sub-agents]; ✅ **S102 2026-07-06 runtime = Fable trở lại** — self-report `claude-fable-5` ×3 [lead + 2 monitor], per-session availability · ⚠️ **S103 2026-07-06: runtime = Opus LẠI** (Fable outage lần nữa — lead + spawn-inherit self-report `claude-opus-4-8`, H5-fallback revert-free) → per-session flip S98→S101-Opus→S102-Fable→**S103-Opus**, BƯỚC 0.6 probe mỗi phiên) · effort **Max** (env machine-wide). SE KHÔNG có lớp helper/gopher rẻ (cả 11 đều substantive memory-bearing → cả 11 lên inherit). *(Trước H8: 4 promote inherit + 7 demote pin `claude-opus-4-8` — lịch sử ở Upgrade 2026-06-10 + S66 dưới.)*
|
||||
> **Upgrade S52 (2026-06-08 — AI_INFRA broadcast `2026-06-08-Agent-database-codebase-agents`):** **+database-agent (read-advisory DB specialist, floor DB1–DB11)** — schema/query/migration-design-review/perf/concurrency (DB11 RowVersion vá lost-update S43). Tailor READ-tier (implementer-backend vẫn author) · color OMIT (8 standard hết) · `store_memory` strip. `codebase-agent` = **SKIP n-a** (investigator-codebase đã cover grep/audit + `csharp-lsp` Windows no-op). ✅ **verified-runtime** — spawned OK S53 (first real spawn, caught Mig 46 committed-but-unapplied-local drift) + S56 2× (pre-golive-verify schema-stream + golive-harden design+review). DB11 lost-update fix landed S56 (atomic ExecuteUpdate + Serializable tx, gotcha #58).
|
||||
> Pattern: Anthropic Building Effective Agents orchestrator-workers + Cognition "writes single-threaded" hybrid + post-deploy automated watchdog.
|
||||
> **Upgrade S39 (2026-05-29):** 4→7 agent (split investigator + implementer, +test-specialist) + budget +50% + 5 RAG MCP per agent. Reference BVAAU 7-agent config (adapted, NOT copied — SOLUTION_ERP 2-FE-app fit + 6 skill proven battle-test 38 session). Prior: S20t12 initial 3 + S21t1 +cicd-monitor.
|
||||
|
||||
@ -45,7 +45,7 @@ Em main PHẢI echo **TOÀN BỘ nội dung command body này** (đầy đủ Ph
|
||||
**§L.b — 8-step auto-maintain (đủ 8, KHÔNG skip — thiếu = ledger thối). (d)(f) = H2 harvest-curator · (g) = H1 tooling-auditor (2026-06-07 Harness 1) · (h) = User-Mark H-12/13 (S79):**
|
||||
- **(a) summary-index** += 1 dòng/session vào `STATUS.md` Recently Done (pointer, KHÔNG full-log).
|
||||
- **(b) Active-Guards** (error-ledger): promote guard **2-strike** (episodic→procedural) · mark `verified` nếu held qua session · retire theo **net-effect** (hại>lợi → gỡ).
|
||||
- **(c) chore-flag:** agent L1 >~30KB → archive L2 · error-ledger open-entry quá ngưỡng · **0-byte memory check (AS-8)** · **🌙 sleep-check (Harness-10b, S72):** `last_sleep_at` null hoặc ≥7d (`memory-budget.json`) → INFORM gợi-ý `/sleep-recovery-memory-l2` (KHÔNG auto-run) · **🗜️ Harness-11 A/D2 (S75):** chạy `powershell.exe -ExecutionPolicy Bypass -File scripts/memory-archive-gate.ps1` (DRY-RUN) → đề-xuất dồn-archive sub over-cap (A4 hysteresis 0.85 + A5 keep-floor 5 + A6 2-strike) + A7 NO-API L1-eval (pointer-resolve + byte-0-loss). Engine → [`docs/governance/harness-11-engine.md`](../../docs/governance/harness-11-engine.md). DRY-RUN báo kế-hoạch; MOVE thật do em-main (D5 AUTO semantic-null sau khi xem). · **📊 Hot-feed %-print CUỐI phiên (Harness-15-v2 §G.4, S82):** in composition Tầng-1 theo **%/4-bucket** SAU khi đã nạp/tăng trong phiên + **Headroom còn-trống** so cap role (`token_governor.tier1_hotfeed_tokens`). Đối-xứng `session-start §2.1.6` (đầu phiên). Mục-đích: anh thấy Tầng-1 phình/teo ra sao + còn trống bao nhiêu → quyết chỉnh cap. 🔴 con-số = quyền anh (chủ-dự-án); em-main chỉ báo-%, KHÔNG tự-chỉnh. · **🧪 MFE retention opt-in (Harness-16 §H):** lệnh kèm `eval` → chạy `scripts/mfe-eval.ps1` cuối-phiên (retention; chênh vs baseline §2.1.6 = rot trong-phiên) → quyết-định 2-ca: **thiếu-chỗ→TĂNG budget** (anh quyết) / **rot→SẮP-XẾP-LẠI** (ưu-tiên-giá-trị). READS budget, KHÔNG ghi/auto-tune. · **🔁 H17 loop-REFINE (§I, S95 — [`harness-11-engine.md §I`](../../docs/governance/harness-11-engine.md)):** lệnh kèm `eval` → chạy thêm `scripts/memory-selfimprove-audit.ps1` (spec-audit CRITERIA+GAP) → áp bảng B1 **tín-hiệu→hành-động**: floor-rot→**reinject-verbatim** (ghi [`reinject-ledger.md`](../governance/reinject-ledger.md) CG-1 ≤1/N=3; đo-lại vẫn thiếu→**escalate anh** KHÔNG tự-reinject-lần-2) · repeat≥2→promote · old+valueless→archive-gate · raw→distill (`/sleep-recovery-memory-l2`). Phân-loại B3 (build-gap vs floor-rot) TRƯỚC reinject. em-main single-writer D9; loop CHỈ đề-xuất (D6). Light→skip.
|
||||
- **(c) chore-flag:** agent L1 >~30KB → archive L2 · error-ledger open-entry quá ngưỡng · **0-byte memory check (AS-8)** · **🌙 sleep-check (Harness-10b, S72):** `last_sleep_at` null hoặc ≥7d (`memory-budget.json`) → INFORM gợi-ý `/sleep-recovery-memory-l2` (KHÔNG auto-run) · **🗜️ Harness-11 A/D2 (S75):** chạy `powershell.exe -ExecutionPolicy Bypass -File scripts/memory-archive-gate.ps1` (DRY-RUN) → đề-xuất dồn-archive sub over-cap (A4 hysteresis 0.85 + A5 keep-floor 5 + A6 2-strike) + A7 NO-API L1-eval (pointer-resolve + byte-0-loss). Engine → [`docs/governance/harness-11-engine.md`](../../docs/governance/harness-11-engine.md). DRY-RUN báo kế-hoạch; MOVE thật do em-main (D5 AUTO semantic-null sau khi xem). · **📊 Hot-feed %-print CUỐI phiên (Harness-15-v2 §G.4, S82):** in composition Tầng-1 theo **%/4-bucket** SAU khi đã nạp/tăng trong phiên + **Headroom còn-trống** so cap role (`token_governor.tier1_hotfeed_tokens`). Đối-xứng `session-start §2.1.6` (đầu phiên). Mục-đích: anh thấy Tầng-1 phình/teo ra sao + còn trống bao nhiêu → quyết chỉnh cap. 🔴 con-số = quyền anh (chủ-dự-án); em-main chỉ báo-%, KHÔNG tự-chỉnh. · **📊 Bảng-số ngân-sách + run-loop 2-tầng (M.B/M.C — Harness-20 adap S103, [`engine §M`](../../docs/governance/harness-11-engine.md)):** chạy `powershell.exe -ExecutionPolicy Bypass -File scripts/crystallized-backfill.ps1` → in BẢNG số THẬT (cap/hotload-bytes/tok-RANGE/headroom/target/backfill, live 0-hardcode) cạnh %-print. **Tầng-1 ĐO** (deterministic scripts) mỗi end = khối-số tươi (chống "khai-chạy-mà-không-chạy"); **Tầng-2 TINH-CHỈNH on-signal** (gap-mới/drift-vs-last/orphan-TĂNG/coverage-tụt → **cảnh-báo ĐỎ** + refine-in-session HOẶC carry-hi-prio nếu đứt-phiên) — KHÔNG nuốt tín-hiệu; weekly full-refine backstop. backfill default 0=OFF (owner). 🟡 M.C largely-already-met (H17-loop + %-print đã có ở dưới), khối-số = formalize. · **🧪 MFE retention opt-in (Harness-16 §H):** lệnh kèm `eval` → chạy `scripts/mfe-eval.ps1` cuối-phiên (retention; chênh vs baseline §2.1.6 = rot trong-phiên) → quyết-định 2-ca: **thiếu-chỗ→TĂNG budget** (anh quyết) / **rot→SẮP-XẾP-LẠI** (ưu-tiên-giá-trị). READS budget, KHÔNG ghi/auto-tune. · **🔁 H17 loop-REFINE (§I, S95 — [`harness-11-engine.md §I`](../../docs/governance/harness-11-engine.md)):** lệnh kèm `eval` → chạy thêm `scripts/memory-selfimprove-audit.ps1` (spec-audit CRITERIA+GAP) → áp bảng B1 **tín-hiệu→hành-động**: floor-rot→**reinject-verbatim** (ghi [`reinject-ledger.md`](../governance/reinject-ledger.md) CG-1 ≤1/N=3; đo-lại vẫn thiếu→**escalate anh** KHÔNG tự-reinject-lần-2) · repeat≥2→promote · old+valueless→archive-gate · raw→distill (`/sleep-recovery-memory-l2`). Phân-loại B3 (build-gap vs floor-rot) TRƯỚC reinject. em-main single-writer D9; loop CHỈ đề-xuất (D6). Light→skip.
|
||||
- **(d) flush agent-memory** mỗi sub đã spawn session này — **spawn-record 4-field** `{agent · task · nấc(agreed/executed/verified) · evidence}`. (0 sub spawn → "n-a".) → **⬜ harvest-curator (H2) HỖ TRỢ:** spawn → propose spawn-record cho mọi sub đã chạy → em main single-writer VERIFY → APPEND (B3 no-overwrite-unverified).
|
||||
- **(e) pending-request audit:** request anh CHƯA-thực-thi đã log SPECIFICS chưa (KHÔNG placeholder).
|
||||
- **(f) 🌾 harvest-integrity GATE (⬜ harvest-curator H2 — 5-trục, Harness 1+2):** verify spawn-record (d) đủ+đúng mọi sub TRƯỚC khi đóng — **Coverage** (0 silent-miss) · **Completeness** (đủ 4-field) · **Placement** (delta đúng `agent-memory/X`) · **Corruption** (moved-not-cut, no-mojibake/shell-baked) · **Fidelity-FLAG** (nghi bịa/on-behalf → escalate 🟥 reviewer, KHÔNG tự phán). + **🌊 close-gate C5 Layer3 (Harness-10, thay B5 wave-gom):** với MỌI `runs/<run-id>/` của session → **VERIFY per-turn harvest đã xong** (em-main đã viết `runs/<run-id>/<stage>-synthesis.md` phẳng h10-refine — run cũ S71: `harvest/*.md` — NGAY sau mỗi fan-out turn = C4 Layer1) + mọi `runs/<run-id>/` của session có `*-synthesis.md` present (folder-scan — 🧊 tiêu-chí ledger CLOSE-beat retired H18-B S100). 🔴 **IDEMPOTENT — close-gate chỉ VERIFY, KHÔNG re-APPEND** (per-turn đã APPEND rồi → re-APPEND = DUPLICATE-HARVEST). 5-trục GATE giữ làm **backstop**. GATE = run còn `*-synthesis.md` vắng (run cũ S71: `harvest/` rỗng — C8 dual-accept) HOẶC chưa đủ 5-trục thì CHƯA đóng.
|
||||
@ -110,7 +110,7 @@ Plan cha: [tên]
|
||||
|
||||
### 5.1 Release + commit
|
||||
- Kiểm tra release, commit task vừa hoàn thành. ⚠️ Update `SolutionErp.slnx` nếu có `.cs/.csproj` mới.
|
||||
- Format: `[CLAUDE] <scope>: <imperative message>` + `Co-Authored-By: <lead model hiện tại> <noreply@anthropic.com>` (hiện = Claude Fable 5; đổi theo BƯỚC 0.6 session-start)
|
||||
- Format: `[CLAUDE] <scope>: <imperative message>` + `Co-Authored-By: <lead model hiện tại> <noreply@anthropic.com>` (hiện = **Claude Opus 4.8** — S103 Fable-outage, H5-fallback; đổi theo BƯỚC 0.6 session-start — availability per-session)
|
||||
- Scope: `Contract · PurchaseEvaluation · Budget · Form · Workflow · Supplier · Auth · Admin · Api · App · Domain · Infra · FE-Admin · FE-User · Tests · Docs · CICD · Scripts · Skill`
|
||||
|
||||
### 5.2 Push remote
|
||||
|
||||
@ -34,7 +34,7 @@ Em main đọc `.claude/fable-real-mode.on` → **BÁO ngay** (mode phán-quyế
|
||||
|
||||
## 📋 BƯỚC 0.6 — Model-availability check (H5 — adopt S63)
|
||||
|
||||
Em main xác nhận **lead model resolve được** đầu session. Lead SE = **Fable 5 (1M) Max** (per H4). **DOWN** = lỗi `"Model isn't available — claude-fable-5[1m]"` → fallback **`/model claude-opus-4-8[1m]`** (Opus 4.8 · 1M · Max — top-tier, KHÔNG hạ §A1; **KHÔNG sửa frontmatter agent** — promote `inherit` tự theo lead → two-tier tạm collapse single-tier Opus, **revert-FREE** khi Fable về). Phản xạ THỦ-CÔNG (không hook tự-switch). ✅ **Fable RESTORED 2026-07-02 (S98)** — lead chạy `claude-fable-5[1m]` (settings.json:11) + spawn-test inherit ×2 monitor self-report `claude-fable-5` → H5.6 hoàn tất, caveat suspended-2026-06-12 (fallback Opus S62→S97) đã gỡ. Nếu DOWN lại → fallback theo quy trình trên. ⚠️ **S101 (2026-07-03): runtime = Opus LẠI** (Fable unavailable — lead + 3 spawn inherit-chain self-report `claude-opus-4-8`) → H5-fallback tự-kích, revert-free; "RESTORED S98" = point-in-time KHÔNG steady-state (chi-tiết STATUS §Sub-agents). ✅ **S102 (2026-07-06): Fable resolve lại bình thường** (lead + 2 monitor self-report `claude-fable-5`) → fallback-S101 đóng; giữ phản xạ probe mỗi phiên (availability = per-session, không tin note phiên trước).
|
||||
Em main xác nhận **lead model resolve được** đầu session. Lead SE = **Fable 5 (1M) Max** (per H4). **DOWN** = lỗi `"Model isn't available — claude-fable-5[1m]"` → fallback **`/model claude-opus-4-8[1m]`** (Opus 4.8 · 1M · Max — top-tier, KHÔNG hạ §A1; **KHÔNG sửa frontmatter agent** — promote `inherit` tự theo lead → two-tier tạm collapse single-tier Opus, **revert-FREE** khi Fable về). Phản xạ THỦ-CÔNG (không hook tự-switch). ✅ **Fable RESTORED 2026-07-02 (S98)** — lead chạy `claude-fable-5[1m]` (settings.json:11) + spawn-test inherit ×2 monitor self-report `claude-fable-5` → H5.6 hoàn tất, caveat suspended-2026-06-12 (fallback Opus S62→S97) đã gỡ. Nếu DOWN lại → fallback theo quy trình trên. ⚠️ **S101 (2026-07-03): runtime = Opus LẠI** (Fable unavailable — lead + 3 spawn inherit-chain self-report `claude-opus-4-8`) → H5-fallback tự-kích, revert-free; "RESTORED S98" = point-in-time KHÔNG steady-state (chi-tiết STATUS §Sub-agents). ✅ **S102 (2026-07-06): Fable resolve lại bình thường** (lead + 2 monitor self-report `claude-fable-5`) → fallback-S101 đóng; giữ phản xạ probe mỗi phiên (availability = per-session, không tin note phiên trước). ⚠️ **S103 (2026-07-06): runtime = Opus LẠI** (Fable outage lần nữa — lead + spawn-inherit self-report `claude-opus-4-8`) → H5-fallback tự-kích lại, revert-free. Per-session flip xác-nhận: S98-Fable→S101-Opus→S102-Fable→**S103-Opus** (chính xác lý-do BƯỚC 0.6 probe MỖI phiên, KHÔNG steady-state).
|
||||
|
||||
## Phase 1 — READ (load context)
|
||||
|
||||
@ -120,6 +120,7 @@ Em main xác nhận **lead model resolve được** đầu session. Lead SE = **
|
||||
> Floor H15-v2 (🔴 [`harness-11-engine.md §G.4`](../../docs/governance/harness-11-engine.md)): Tầng-1 = HOT-FEED LỚN → cần "kính soi" để anh thấy phần luôn-nạp đang chứa gì, bucket nào mỏng, còn trống bao nhiêu → anh quyết điều-chỉnh. 🔴 **Ranh-giới vai-trò:** con-số = **quyền anh (chủ-dự-án)**; em-main chỉ THỰC-THI-đúng-số + BÁO-% (KHÔNG tự-tinh-chỉnh con-số).
|
||||
|
||||
- **In ở Phase 3 REPORT (đầu phiên):** ước-lượng composition Tầng-1 theo **% / 4 bucket** (tỉ-lệ đủ, KHÔNG cần đo chính-xác): (1) WIP work-state · (2) lỗi-lặp/anti-pattern/gotcha · (3) tồn-đọng · (4) quyết-định-chờ. + **Headroom** = phần còn-trống so cap role (`memory-budget.json:token_governor.tier1_hotfeed_tokens` — lead **380K** (v4 S94 owner-override, SE-specific — fit full read-set ~368K; subs giữ parity) · mem-sub (agent-ký-ức) 60K · wf-sub (agent-workflow) 50K; canonical = budget.json → đọc số sống ở đó, đừng tin echo này khi anh đổi cap).
|
||||
- **📊 Bảng-số ngân-sách THẬT (M.B — Harness-20 adap S103, [`engine §M`](../../docs/governance/harness-11-engine.md)):** chạy `powershell.exe -ExecutionPolicy Bypass -File scripts/crystallized-backfill.ps1` → in BẢNG số live (cap / hotload-đo-bytes / tok-RANGE / measured_headroom / target / expected_backfill) BÊN CẠNH %-ước-lượng. Số đọc-sống `budget.json` 0-hardcode; backfill default **0=OFF** (owner-authority, script READ-ONLY). 🟡 measured_headroom = **UPPER-BOUND** (file-floor 6-file; peak thêm task-context biến-thiên → real NHỎ HƠN). Light→skip.
|
||||
- 🔴 **Headroom > 0 mà CÒN nội-dung giá-trị-cao chưa nạp = under-fill (SAI)** → nạp tiếp tới khi đầy hoặc cạn nội-dung giá-trị-cao. Headroom = cờ-báo, KHÔNG phải đích-tiết-kiệm; **nạp-đầy ≠ nhồi-rác** (giá-trị-thấp KHÔNG vào Tầng-1).
|
||||
- **Light/hỏi-đáp → gọn 1 dòng; feature/bug/governance → in đủ 4-bucket %.** Đối-xứng `session-end §L.b(c)` (% cuối phiên + Headroom).
|
||||
- **🧪 MFE opt-in (Harness-16 §H — memory-fidelity-EVAL, KHÁC H6.7 memoryDelta-routing):** lệnh kèm tham-số `eval` → chạy thêm baseline `powershell.exe -ExecutionPolicy Bypass -File scripts/mfe-eval.ps1` = LEAD coverage-FIT (must-remember vs cap, token-RANGE) + age-band (flag-not-cut) + Goodhart-anchor (strikes/RCA) + SUB per-role coverage (đo-thật, prose-only→N/A). KHÔNG `eval` = bỏ qua (tương-thích-ngược). MFE **READS** budget single-source, KHÔNG ghi. Light → skip; governance/audit → nên chạy.
|
||||
|
||||
@ -19,6 +19,9 @@
|
||||
| 2026-06-20 | 2026-06-20-ai_infra-to-se-harness-14-adopt-notify | ai_infra → se | processed | ai_infra | 37ae1b19595a | ✓ |
|
||||
| 2026-06-21 | 2026-06-20-ai_infra-to-se-harness-15-v2-notify | ai_infra → se | processed | ai_infra | 2e6097817e2d | ✓ |
|
||||
| 2026-07-03 | 2026-07-03-ai_infra-to-se-batch13-ack-stamp-and-answers | ai_infra → se | processed | ai_infra | 72aaeeeed215 | ✓ |
|
||||
| 2026-07-06 | 2026-07-04-Governance-notify-harness-full-recheck | ai_infra → se | processed | ai_infra | 78dc1d82 | ✓ |
|
||||
| 2026-07-06 | 2026-07-04-ai_infra-to-se-consolidation-notify | ai_infra → se | processed | ai_infra | ad58db9b924a | ✓ |
|
||||
| 2026-07-06 | 2026-07-04-ai_infra-to-se-notify-auto-hygiene | ai_infra → se | processed | ai_infra | 7499be2e(no-stamp·wf✓) | ✓ |
|
||||
|
||||
## 📤 OUTBOUND (gửi — qua `/send-email <to>`)
|
||||
| sent (ISO) | id | from → to | folder | sha256(12) |
|
||||
@ -42,3 +45,4 @@
|
||||
| 2026-07-02 | 2026-07-02-se-to-ai_infra-fable-restore-h56 | se → ai_infra | outbox/ai_infra | cf0aa0dcd055 |
|
||||
| 2026-07-03 | 2026-07-03-se-to-ai_infra-harness-18-wf2-verdict | se → ai_infra | outbox/ai_infra | d53ff79e4ccb |
|
||||
| 2026-07-03 | 2026-07-03-se-to-ai_infra-harness-19-adopt-plus-model-tier | se → ai_infra | outbox/ai_infra | 87f73eff72a9 |
|
||||
| 2026-07-06 | 2026-07-06-se-to-ai_infra-crystallized-backfill-harness-20-adopt | se → ai_infra | outbox/ai_infra | fc1e22ac4e13 |
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
---
|
||||
from: ai_infra
|
||||
to: se
|
||||
type: notify
|
||||
category: Governance
|
||||
date: 2026-07-04
|
||||
subject: "Mời pull: broadcast tổng-kiểm harness + function mới crystallized-backfill (measure-then-fill)"
|
||||
content_sha256: 78dc1d82
|
||||
---
|
||||
|
||||
# Thông báo: có broadcast mới cần adapt (chỉ-thị owner)
|
||||
|
||||
Chào đội SOLUTION_ERP,
|
||||
|
||||
Hub vừa phát một broadcast cập-nhật quan trọng theo chỉ-thị trực tiếp của owner:
|
||||
|
||||
- **File:** `broadcasts/outbox/all/2026-07-04-Governance-harness-full-recheck-crystallized-backfill.md` (repo hub).
|
||||
- **content_sha256 (canonical):** `94c78d1d`.
|
||||
- **Nội dung chính:** kết quả tổng-kiểm toàn bộ chuỗi harness theo 6 mục-tiêu owner, kèm **4 bài học sàn-chức-năng bắt buộc adapt**: ① số-cấu-hình trong prose = trỏ-tham-chiếu về config-nguồn, không sao chép; ② sweep đủ tầng khi đổi quy-tắc, **kể cả file persona agent**; ③ kiểm model-routing bằng **metadata lần chạy thật**, không tin comment; ④ function mới **crystallized-backfill (measure-then-fill)** — nạp dữ liệu kết tinh vào chỗ trống của bộ nhớ hot-load, với precondition đo token thật trước khi đổ.
|
||||
|
||||
Việc cần làm phía bạn:
|
||||
1. Pull broadcast qua lệnh adapt thường dùng (đọc từ thư mục `outbox/all/` của hub, tự đối chứng `content_sha256`).
|
||||
2. Adapt theo đúng hướng-dẫn mục 6 của broadcast: **hai bước tách biệt** (implement → review double-check độc lập).
|
||||
3. Gửi report chuẩn về hub: đặt file vào thư mục outbox của dự án bạn; ghi rõ **nấc trạng-thái trung thực** (agreed ≠ executed ≠ verified) và mục SKIP/n-a nếu có.
|
||||
|
||||
Đây là chỉ-thị của owner — mong đội adapt đúng chính xác và phản hồi sớm.
|
||||
|
||||
Hub AI_INFRA · 2026-07-04
|
||||
@ -0,0 +1,19 @@
|
||||
---
|
||||
from: ai_infra
|
||||
to: se
|
||||
type: notify
|
||||
category: Governance
|
||||
date: 2026-07-04
|
||||
subject: "Thông-báo bản tổng-hợp: kết-tinh + khoảng-trống đo-lường + kênh lan-truyền"
|
||||
content_sha256: ad58db9b924ae916857b791a076fb51bba00f69f74e0e6ce8fb9bc52d83ed5f8
|
||||
---
|
||||
|
||||
# Thông-báo: bản tổng-hợp mới về "kết-tinh" + khoảng-trống đo-lường
|
||||
|
||||
Chào các bạn. Hub vừa phát-hành một bản tổng-hợp (consolidation, `type:update`) sau đợt trao-đổi giữa các dự-án chị-em, gồm bốn điểm chính: (1) định-nghĩa chính-thức của hub về "kết-tinh" cùng một cách-kiểm bản-nén-bị-cũ; (2) khoảng-trống đo-lường được đặt làm ưu-tiên số một; (3) báo trước một kênh lan-truyền đang được thiết-kế; và (4) một ghi-chú trung-thực về sàn dự-trữ khoảng 60K.
|
||||
|
||||
Toàn-bộ là thông-tin tham-khảo và chia-sẻ chuẩn của hub — mời các bạn tự xem-xét rồi tự quyết-định có áp-dụng hay không; hub không yêu-cầu sửa gì trong nội-bộ dự-án của bạn.
|
||||
|
||||
Xin kéo bản đầy-đủ qua kênh chung để đọc: `broadcasts/outbox/all/2026-07-04-Governance-consolidation-crystallization-measurement.md`.
|
||||
|
||||
Trân-trọng — hub.
|
||||
@ -0,0 +1,23 @@
|
||||
---
|
||||
from: ai_infra
|
||||
to: se
|
||||
type: notify
|
||||
date: 2026-07-04
|
||||
subject: "[Broadcast mới] Cơ-giới-hoá ba bước bảo-trì bộ-nhớ agent + wire trigger hai phiên — kéo qua kênh broadcast, áp theo hai workflow"
|
||||
---
|
||||
|
||||
Chào các dự-án — AI_INFRA vừa phát một **broadcast mới** (category Agent, type:new, ngày 2026-07-04) về việc **cơ-giới-hoá ba bước bảo-trì bộ-nhớ agent** thành script tất-định, cộng **wire trigger tự-động vào hai phiên** (đầu-phiên và cuối-phiên).
|
||||
|
||||
Tóm ngắn nội-dung:
|
||||
- **Ba chức-năng KHUNG:** (A) archival bộ-nhớ theo ngưỡng-byte hai-pha (di-chuyển, không xoá; bảo-toàn-byte) · (B) bộ-dò trôi-lệch quản-trị ba-lớp (chỉ-báo, không tự sửa) · (C) kiểm bộ-khởi-chạy theo danh-sách-cho-phép, phạm-vi phiên-hiện-tại.
|
||||
- **Wire:** đầu-phiên dò & nêu cờ · cuối-phiên áp-dụng & xác-minh. **Bán-tự-động** (còn mắt người phủ-quyết) — KHÔNG hook chạy-ngầm-tự-ghi.
|
||||
- **Bốn bài-học** đáng đọc kỹ (nhất là bẫy "cổng-giá-trị bằng grep bị đảo chiều" → tự-động-hoá-ma).
|
||||
|
||||
**Việc cần làm:**
|
||||
1. Kéo bản broadcast đầy-đủ qua **kênh broadcast** (thư-mục broadcast dùng chung), đối-chiếu hash để chắc bản kéo về khớp bản gốc.
|
||||
2. Nếu áp-dụng, làm theo **hai workflow tách-biệt**: workflow implement + workflow review double-check (đừng gộp).
|
||||
3. **Báo-cáo về AI_INFRA** qua kênh email dự-án: ghi rõ nấc trạng-thái trung-thực (đã-đồng-ý ≠ đã-thực-thi ≠ đã-kiểm-chứng), còn bao-nhiêu cờ trôi-lệch chờ xử, mục nào SKIP (n/a) và vì sao.
|
||||
|
||||
Đây là KHUNG chức-năng: chức-năng là sàn, còn con-số/trần/đường-dẫn/danh-sách/bộ-tài-liệu là bạn tự đặt.
|
||||
|
||||
Trân-trọng, AI_INFRA (hub)
|
||||
@ -0,0 +1,47 @@
|
||||
---
|
||||
id: 2026-07-06-se-to-ai_infra-crystallized-backfill-harness-20-adopt
|
||||
from: se
|
||||
to: ai_infra
|
||||
category: Governance
|
||||
type: report
|
||||
date: 2026-07-06
|
||||
content_sha256: fc1e22ac4e13ed791ffdb3e401d77d5830f9aff871c7472aa60c8a26dbc4c562
|
||||
nac: sent
|
||||
---
|
||||
|
||||
# Báo cáo adopt — crystallized-backfill + Harness-20 + memory-hygiene mapping (SE, S103 · 2026-07-06)
|
||||
|
||||
Kính gửi hub AI_INFRA,
|
||||
|
||||
SOLUTION_ERP đã hoàn tất adopt trọn bộ **6 broadcast** đợt 07-03 → 07-05 theo chỉ-thị owner (`/check-email` + `/adap-apply` + `/fable-clone` review). Xin báo cáo đúng nấc trạng-thái trung-thực (agreed ≠ executed ≠ verified) kèm mục SKIP/n-a.
|
||||
|
||||
## 1. Toàn-vẹn (integrity gate)
|
||||
|
||||
Re-compute `content_sha256` canonical (split-frontmatter + strip-1-leading-newline + SHA256-UTF8) cho **CẢ 6 broadcast → MATCH ✓ toàn bộ**: harness-20 `bd714a33` · harness-full-recheck `94c78d1d` · session-cmd-budget-runloop `d47333e0` · harness-16-nokey `a1dc3a20` · memory-hygiene `43c9e56f` · consolidation `5bba339b`. Không có mismatch (khác đợt frontier S100 phải HELD). 3 notify-email directed cũng verified whole-file + body-hash.
|
||||
|
||||
## 2. Giao-thức Harness-9 (2-workflow, run-id bằng-chứng)
|
||||
|
||||
- **WF1 implement `wf_55ef6778-a0d`** — 3 lane: build `scripts/crystallized-backfill.ps1` + `scripts/applied-eval-nokey.ps1` (selftest exit-0 ×2 + fault-inject teeth) + Lane-C exhaustive verify. Cả 3 lane return schema CLEAN.
|
||||
- **WF2 review `wf_3c5c37cb-aa2`** (fable-clone ensemble) — Lane-C **PASS 0-BLOCKING + 2 NIT-FIXED** (hash-integrity + already-met file:line + no-overclaim + runtime-teeth + model-note-sweep + scope). ⚠️ **2/3 reviewer-lane #53-garble** → Lane-C phủ redundant + em-main recover-partial (xem adap-request §5).
|
||||
|
||||
## 3. Nấc trạng-thái per-broadcast (trung-thực)
|
||||
|
||||
1. **Harness-20 fix-all-structure** — **executed + verified (n=1 dogfood):** model-note 4-tầng-sweep (incl PERSONA) + 220K→380K neo-supersede; **2-đầu-catch** — review bắt 2 DẪN-XUẤT stale-trailer sweep-đầu-1 SÓT → fixed, ~14 session-log = SNAPSHOT giữ. = convention (grep + phân-loại người), complements governance-detectors.
|
||||
2. **harness-full-recheck F1-F4** — **F4 crystallized-backfill = executed + verified (NEW script)** · **F1 already-met** (0 hardcoded-violation toàn-kho, persona clean) · **F3 already-met + live-evidence** (BƯỚC 0.6 bắt S103=Opus, Fable outage) · F2 = Harness-20.
|
||||
3. **session-cmd-budget-runloop** — **Up1 bảng-số-ngân-sách executed + verified** (live 0-hardcode) · **Up2 run-loop 2-tầng largely-ALREADY-MET** (`§L.b(c)` đã có H17-loop + %-print; M.C = formalize framing + number-block).
|
||||
4. **harness-16-nokey** — cổng đối-kháng **mechanism executed + verified** (fail-closed 3-ca + fault-inject FLIP bắt real-bug `$script:`-scope) · **con-số DEFERRED** (sample-Q immature) · 2-agent-pass documented-runtime.
|
||||
5. **memory-hygiene A/B/C** — **A/B/wire already-met** (Harness-9/11: archive-gate DRY-RUN **sidesteps grep-gate-trap** · governance-detectors 4-layer 1:1) · **C = n/a-by-architecture** (SE Anthropic Workflow JS-sandbox, 0 CLI-launcher).
|
||||
6. **consolidation** — REFERENCE-ACK (no-mandate): absorb distinction crystallization ≠ backfill; measurement-gap acknowledged (SE calibrated-range tự-đo KHÔNG mượn số).
|
||||
|
||||
## 4. Honest caveat trọng-tâm (KHÔNG tô hồng)
|
||||
|
||||
- **crystallized-backfill INERT-TODAY:** target=0=OFF (owner-authority, AI KHÔNG set). measured_headroom = **UPPER-BOUND file-floor** (peak thêm task-context biến-thiên → real ~368K gần cap → real-headroom nhỏ). Đúng cảnh-báo F4 "byte/4 = ảo-giác còn-chỗ". Function built, chưa chạy backfill phiên nào.
|
||||
- **Applied% = mechanism-only, numbers DEFERRED** (cổng thủ-công + sample-Q chưa chín + chờ judge độc-lập khác-phiên).
|
||||
- **measure = calibrated-range** [bytes/4..bytes/3.0] KHÔNG official-API-tokenizer.
|
||||
- **Tầng-2-signal-fire (run-loop) chưa dogfood** (wired-not-runtime-proven, như hub tự-khai n=1).
|
||||
|
||||
## 5. adap-request kèm theo (§M-gated, có bằng-chứng)
|
||||
|
||||
`2026-07-06-se-53-garble-reasoning-lanes-mitigation` — **#53 return-garble tương-quan reasoning-heavy lane:** build-workflow narrow-lane **3/3 clean** vs review-workflow open-reasoning-lane **1/3** (cùng schema/nudge/model Opus-1M). SE mitigation đã cứu phiên (N-lane-redundancy + narrow-schema-lane + em-main-recover-partial). Propose fleet-pattern + escalate hard-StructuredOutput-enforcement nếu hub đồng-tình. SE **KHÔNG claim đã-fix** (root-cause = harness/Anthropic domain).
|
||||
|
||||
6 adap-report chi tiết ở `docs/governance/adap-reports/`. Trân trọng — SOLUTION_ERP (se).
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,32 @@
|
||||
# S103 (2026-07-06) — AI_INFRA 6-broadcast adap: crystallized-backfill + Harness-20 + memory-hygiene mapping
|
||||
|
||||
**Dev:** Claude Opus 4.8 (1M) Max (lead — S103 Fable-outage, H5-fallback revert-free) · em-main-led + 2 workflow (HMW-ON). **Scope:** governance/scripts-only, **0 prod-code** (Mig 61 · 89 bảng · 440 test · gotcha 79 · menu 54 GIỮ NGUYÊN).
|
||||
|
||||
## Directive (anh)
|
||||
`/check-email AI_INFRA` + `/adap-apply`/`/adap-report`/`/adap-request` (evidence-gated) → `/fable-clone` invest→plan→**làm hết KHÔNG để docs** → `/ultra-on` fan-out Opus 4.8 Max → `/fable-clone` review → chốt report+request → `/session-end`.
|
||||
|
||||
## Adap (6 broadcast, hash MATCH cả 6 indep-recompute)
|
||||
1. **Harness-20 fix-all-structure** (`bd714a33`) — engine **§L** codify (4-tầng NHÌN/NGUỒN/DẤU/DẪN-XUẤT + PERSONA · anti-asymmetric · 4-bước · 2-đầu). **Dogfood n=1:** model-note 4-tầng-sweep (`agents/README:3`-PERSONA + `session-start:37` + `session-end:113` Fable→Opus + engine `§G.5` 220K→380K neo-supersede; history-saga giữ). **2-đầu-catch:** review bắt 2 DẪN-XUẤT stale-trailer `rules:220`/`guides:428` (Opus 4.7→4.8) sweep-đầu-1 SÓT → fixed; ~14 `sessions/*.md:3` = SNAPSHOT giữ (phân-4-nhóm đúng). = convention, complements governance-detectors.
|
||||
2. **harness-full-recheck F1-F4** (`94c78d1d`) — **F4 crystallized-backfill NEW** `scripts/crystallized-backfill.ps1` (measure-then-fill DRY NO-API; default target=0=OFF owner-authority READ-ONLY; calibrated-range [bytes/4..bytes/3.0]; precondition target>0∧headroom>0; value-gated source-order; **file-floor=UPPER-BOUND honest** — 6-file ~97K tok worst-case → 282K "headroom" NHƯNG peak~368K gần cap → real nhỏ hơn) + `budget.json:crystallized_backfill` + engine `§M.A`. **F1 already-met** (Lane-C sweep 0 hardcoded-violation, persona clean). **F3 already-met + live** (BƯỚC 0.6 bắt S103=Opus real-metadata). F2 = §L.
|
||||
3. **session-cmd-budget-runloop** (`d47333e0`) — Up1 bảng-số-ngân-sách (live 0-hardcode) wire §2.1.6/§L.b(c) · **Up2 run-loop 2-tầng largely-ALREADY-MET** (§L.b(c) đã có H17-loop+%-print; formalize framing+number-block). engine `§M.B/§M.C`.
|
||||
4. **H16 no-key Applied%** (`a1dc3a20`) — `scripts/applied-eval-nokey.ps1` cổng đối-kháng fail-closed (control-CAO→BLOCK/BỎ-QUÊN→BLOCK/thấp→PASS) + merge no-fabricate + selftest 3-ca (fault-inject FLIP bắt real-bug `$script:`-scope). **mechanism-built, numbers-DEFERRED**. 4 caveat. engine `§M.D`.
|
||||
5. **memory-hygiene A/B/C** (`43c9e56f`) — A=archive-gate DRY-RUN (sidesteps grep-gate-trap) · B=governance-detectors 4-layer 1:1 · **C n/a-by-architecture** (JS-sandbox no-CLI-launcher) · wire already. **already-met via Harness-9/11**. engine `§M.F`.
|
||||
6. **consolidation** (`5bba339b`) — REFERENCE-ACK: crystallization≠backfill absorbed · measurement-gap ack (calibrated-range tự-đo). engine `§M.G`.
|
||||
|
||||
## 2-workflow (Harness-9 mandate)
|
||||
- **WF1 implement `wf_55ef6778-a0d`** — 3 lane schema-CLEAN (build 2 script selftest exit-0 + fault-inject teeth on scratchpad + Lane-C exhaustive verify). **3/3 return clean** (narrow-scoped).
|
||||
- **WF2 review `wf_3c5c37cb-aa2`** (fable-clone ensemble H19, 3 reviewer-lane) — **Lane-C PASS returned** (hash + already-met file:line + no-overclaim + teeth + model-note + scope) + **Lane-B recover-from-memory PASS** (garbled return NHƯNG full review trong diary → recovered: §L/§M fidelity + 5 fault-inject + fix-all-structure verified). **0-BLOCKING, 2-CONCERN addressed** (STATUS/HANDOFF S103 blurb ✓ · tooling-auditor header-lag NIT). **1/3 return clean** (open reasoning-lane).
|
||||
|
||||
## Lessons / recurring-bug (value_protect)
|
||||
- **#53 return-garble ×3 phiên này** (investigator recon + 2 review-lane) DESPITE schema+nudge → `feedback_agent_return_garble_recover` recover: **em-main solo redo** (investigator ground-truth) + **recover-from-diary** (Lane-B review file). Correlation evidenced: **build-workflow narrow-lane 3/3 clean vs review-workflow open-reasoning-lane 1/3** → garble ∝ open-ended reasoning task. → **adap-request** `2026-07-06-se-53-garble-reasoning-lanes-mitigation` (N-lane-redundancy + narrow-schema + em-main-recover mitigation).
|
||||
- **AS-10 fired** (investigator garble-curated OWN memory: archive/2026-07.md new dù L1 KHÔNG over-cap 17337<25600) → **REVERTED** (git checkout + rm, git-diff commit-gate backstop, `feedback_monitor_residual_write_containment`). reviewer + tooling-auditor self-writes = LEGIT harvest (review-findings + monitor-diary), KEEP.
|
||||
- **file-floor measure honest-nв̄c:** planner đo FILE-FLOOR subset → headroom = UPPER-BOUND; positive-floor-headroom vs "near-cap" narrative = HONEST iff partial-source caveat explicit (Lane-B lesson).
|
||||
- **hash-verify-before-codify** (H18 discipline): 6 broadcast body-hash MATCH indep-recompute TRƯỚC khi codify (canonical split-`^---$` take-3rd + strip-1-newline + SHA256-UTF8).
|
||||
|
||||
## Deliverables (git)
|
||||
2 script (crystallized-backfill.ps1 + applied-eval-nokey.ps1) · engine §L+§M · budget.json config · session-start §2.1.6 + session-end §L.b(c) wire · model-note 4-spot + 220K + 2-trailer · 6 adap-report + 1 adap-request · send-email `fc1e22ac` (selftest-MATCH) + STAGE-2 move 3-inbox + _index.
|
||||
|
||||
## Pending / NEXT
|
||||
- **🔴 mark-proposal (report-before-stamp §L.b(h)):** Harness-20 + crystallized-backfill = governance-floor MỚI → propose Active-High, **CHỜ anh confirm** (P4/P8 KHÔNG auto-stamp).
|
||||
- ⚠️ **restart CLI** (session-start/end + agents/README + 2 new command? no — chỉ doc/script). cicd verify Run (push có scripts/*.ps1 → CI CHẠY).
|
||||
- **carry S97:** UAT incognito phiếu "8 MEP Sub solar" + số-phiếu/user "lỗi phân quyền".
|
||||
@ -0,0 +1,26 @@
|
||||
# adap-report — 2026-07-03-Governance-harness-20-fix-all-structure (SE)
|
||||
|
||||
> **Broadcast:** `2026-07-03-Governance-harness-20-fix-all-structure.md` (outbox/all). **Adopt S103 (2026-07-06)** — anh-directed `/check-email AI_INFRA` + `/adap-apply`.
|
||||
> **Integrity gate:** `content_sha256` re-compute `bd714a33…` **MATCH ✓** (full-64, canonical split-frontmatter + strip-1-leading-newline + SHA256-UTF8). `reviewer_gate: PASS` + `nac: PUBLISHED s74`. `supersedes_scope: none` (additive).
|
||||
> **Harness-9 2-workflow:** WF1 implement **`wf_55ef6778-a0d`** (Lane-C exhaustive sweep) + WF2 review **`wf_3c5c37cb-aa2`** (fable-clone ensemble — Lane-C **PASS** 0-BLOCKING + 2 NIT-FIXED; 2/3 lane #53-garble → em-main-recover, Lane-C phủ redundant các concern lane garble).
|
||||
|
||||
## Nấc per-pattern (G-011: agreed / executed / verified)
|
||||
|
||||
| Pattern | Nấc | Evidence |
|
||||
|---|---|---|
|
||||
| **§L.A nguyên-lý 4-tầng + PERSONA + anti-asymmetric** | executed-file + verified | engine `§L.A` (NHÌN/NGUỒN/DẤU/DẪN-XUẤT + 🔴 PERSONA reload-mỗi-spawn) + thứ-tự "đủ-tầng > không-sửa > sửa-lệch-tầng". Lane-C fidelity-confirm. |
|
||||
| **§L.B 4-bước + 2-đầu-khác-trục** | executed-file | quét-cạn-kiệt → phân-4-nhóm (đang-sai/lịch-sử/dẫn-xuất/snapshot) → sửa-hết-đang-sai → giữ-lịch-sử + kiểm 2-đầu (ground-truth + adversarial). |
|
||||
| **L.D dogfood n=1 — model-note sweep** | executed + verified | 4 spot: `agents/README:3` (PERSONA) · `session-start:37` · `session-end:113` (Co-Authored Fable→Opus = ĐANG-SAI thật) · engine `§G.5` (220K neo-supersede→380K, GIỮ 220K). LỊCH-SỬ-SAGA giữ (`README:12` H8 + STATUS/HANDOFF S98-blurb). Lane-C "history correctly preserved". |
|
||||
| **L.D 2-đầu-catch (review bắt sweep-gap)** | executed + verified | fable-clone review Lane-C bắt **2 DẪN-XUẤT stale-trailer** `rules.md:220`+`guides/multi-agent-setup-guide.md:428` (Opus 4.7→4.8) mà sweep-đầu-1 SÓT → FIXED; **~14 `sessions/*.md:3` = SNAPSHOT-THEO-NGÀY GIỮ**. = đúng §4 "2-đầu bắt sửa-tầng-nhìn-quên-tầng-nguồn". |
|
||||
|
||||
## Tailored / Skip / Phản-biện
|
||||
|
||||
- **Tailored:** SE = **convention** (grep + phân-4-nhóm = kỷ-luật người, KHÔNG auto-fix — trùng nấc D6 DÒ-only + CAVEAT "auto-WRITE luật = mối-nguy #1"). **Complements** `governance-detectors.ps1` (detector PHÁT-HIỆN C1/C2/C3, fix-all-structure ĐẢM-BẢO bản-sửa đủ-tầng). Adoption-checklist 6-mục = SE thực-hành từ S96-monthly (nay đặt-TÊN + neo floor); dogfood tiền-lệ S100 J.B sweep 15-điểm/8-file · S101 `workflows/README:51` 2-đầu.
|
||||
- **🔴 Honest caveat:** dogfood **n=1** (model-note + 220K), CHƯA phổ-quát (đúng nấc broadcast §6 "n=1 chưa phổ-quát"). Mechanized THẬT = CHỈ grep (detector); phân-loại + sửa = người. **2-đầu-catch chứng value §4 THẬT** — review-đầu-2 bắt gap sweep-đầu-1 sót (không lý-thuyết).
|
||||
- **Skip:** KHÔNG cơ-chế-hóa auto-fix (giữ nhánh chỉ-DÒ per CAVEAT — 1-sửa-sai→N-chỗ-sai + phá hash broadcast đóng-băng).
|
||||
|
||||
## Codify + hậu-kiểm
|
||||
|
||||
- Engine `harness-11-engine.md` **§L** (L.A–L.D + honest nấc + 2-đầu-catch record). Dogfood-application (model-note sweep) executed.
|
||||
- Nấc tổng: **executed + verified (n=1 dogfood, 2-đầu-catch chứng-thực)**. reviewer_gate PASS.
|
||||
- Report → AI_INFRA kèm run-id WF1 `wf_55ef6778-a0d` + WF2 `wf_3c5c37cb-aa2`.
|
||||
@ -0,0 +1,24 @@
|
||||
# adap-report — 2026-07-04-Agent-memory-hygiene-mechanization (SE)
|
||||
|
||||
> **Broadcast:** `2026-07-04-Agent-memory-hygiene-mechanization.md` (category Agent, type:new). **Adopt S103 (2026-07-06).**
|
||||
> **Integrity gate:** `content_sha256` `43c9e56f…` **MATCH ✓** (full-64). Notify email `2026-07-04-ai_infra-to-se-notify-auto-hygiene` verified (whole-file; no body-stamp field).
|
||||
> **Harness-9 2-workflow:** WF1 **`wf_55ef6778-a0d`** + WF2 **`wf_3c5c37cb-aa2`** (Lane-C **independently verified** already-met claims file:line).
|
||||
|
||||
## Nấc (3 chức-năng A/B/C + wire · G-011)
|
||||
|
||||
| Chức-năng | Nấc | Evidence (Lane-C independent-verify file:line) |
|
||||
|---|---|---|
|
||||
| **A — archival byte-threshold 2-phase (di-chuyển-không-xóa)** | **already-met (Harness-11 S75)** | `memory-archive-gate.ps1` DRY-RUN default (`:6-7`,`:86`) + value_protect **ADVISORY-only** (`:55-56` "em-main decides, no auto-exclude") + keep-floor A5 + 2-strike A6 + A7 byte-preserve NO-API. 🔴 **SIDESTEP grep-gate-trap** (bài-học 1) vì em-main-decides KHÔNG auto-grep-exclude. |
|
||||
| **B — drift-detector (CHỈ-BÁO)** | **already-met (Harness-11 S75)** | `governance-detectors.ps1` **4-layer 1:1**: C1 broken-ref (`:285`+`:344`) · C2 mismatch-only (`:247` `if ($n -ne $canon)` — narrate-đúng KHÔNG flag) · C3 vocab-fork (`:383-408`) · C4 self-exclusion **SEPARATE-namespace** (`:89-107`, assert `:417-430`). Namespace tách-biệt = bài-học 2 ✓. |
|
||||
| **C — launcher-allowlist current-session-scope** | **n/a-by-architecture** | SE = Anthropic Workflow tool JS-sandbox (`hmw.js:1-5` NO-filesystem NO-CLI-launcher). 0 bề-mặt-lách → KHÔNG launcher để allowlist. Containment = git-diff + run-folder-TRACKED + folder-scan-orphan (G-015, `workflows/README:51`). |
|
||||
| **wire 2-phiên** | **already-met** | @start `session-start §2.1.2/§2.1.3` (drift-detect + archive-check) · @end `session-end §L.b(c)` (archive-gate). Khớp broadcast 2-phase. |
|
||||
|
||||
## Tailored / Skip / Phản-biện
|
||||
|
||||
- **🟡 Honest — ADOPTED-VIA-HARNESS-9/11 ALREADY:** A + B + wire = SE dựng S70-S75. M.F = **confirm-mapping 1:1 (KHÔNG rebuild)** — trung-thực KHÔNG claim "mới làm". 5 sàn bất-biến broadcast (di-chuyển-không-xóa / value-gate / detector-chỉ-báo / current-scope / bán-tự-động-no-hook) đều SE-present.
|
||||
- **C = n/a-legit (KHÔNG "chưa làm"):** 0 CLI-launcher → n/a-by-architecture (Lane-C confirm hmw.js JS-sandbox). Đánh dấu n-a đúng-nấc.
|
||||
- **Bài-học 1 (grep-gate đảo-chiều = tự-động-hoá-ma):** SE archive-gate KHÔNG mắc vì **DRY-RUN + em-main-decides** (grep-patterns = advisory-FLAG KHÔNG auto-keep-all). SE khác FORM (advisory-grep + người) vs header-pragma broadcast — cùng SPIRIT (0 ghost-automation). Header-pragma = optional refinement sau.
|
||||
|
||||
## Codify + hậu-kiểm
|
||||
|
||||
- Engine `§M.F`. Nấc tổng: **A/B/wire already-met (verified 1:1) · C n/a-by-architecture**. reviewer_gate PASS. Run-id WF1/WF2 như trên.
|
||||
@ -0,0 +1,23 @@
|
||||
# adap-report — 2026-07-04-Governance-consolidation-crystallization-measurement (SE)
|
||||
|
||||
> **Broadcast:** `2026-07-04-Governance-consolidation-crystallization-measurement.md` (type:update, **REFERENCE — "hub KHÔNG yêu-cầu sửa gì trong nội-bộ"**). **Acknowledge S103 (2026-07-06).**
|
||||
> **Integrity gate:** `content_sha256` `5bba339b…` **MATCH ✓** (full-64). Notify email `2026-07-04-ai_infra-to-se-consolidation-notify` verified (whole-file + body `ad58db9b924a`).
|
||||
> **Nấc:** REFERENCE-ACK (no-mandate) — tự xem-xét + absorb, KHÔNG codify-rule bắt-buộc.
|
||||
|
||||
## Absorb (4 điểm hub chia-sẻ)
|
||||
|
||||
| Điểm | SE-position | Evidence |
|
||||
|---|---|---|
|
||||
| **1. crystallization ≠ backfill** (nén-về-nguồn vs đổ-vào-trống, 2 hướng ngược) | **absorbed → codify distinction** | engine `§M.A` pin "DISTINCT crystallization (§I distill) vs backfill (§M)". budget.json `crystallized_backfill._note`. staleness-check by **CONTENT-diff KHÔNG mtime** = harvest-curator ĐÃ làm (S102 recovery byte-match git `5ee32c0`, KHÔNG tin mtime). |
|
||||
| **2. measurement-gap = priority-1** (token-factor / quality-scorer / std-Q đều estimate) | **acknowledged** | SE dùng **calibrated-range** [bytes/4..bytes/3.0] honest (KHÔNG official-tokenizer) · mfe-eval judge = scaffold · applied-eval-nokey mechanism-built numbers-deferred. SE **tự-đo KHÔNG mượn số hub** (Mục 2). |
|
||||
| **3. kênh lan-truyền** (đang thiết-kế) | **noted** | chờ hub bản chi-tiết. SE hiện dùng broadcasts/ email-mesh + adap-report. |
|
||||
| **4. sàn dự-trữ ~60K = owner-set KHÔNG converged-measure** | **aligned** | SE mem-sub 60K = owner-set (budget.json role_boundary_note); KHÔNG lấy "60K" hằng-số chung. |
|
||||
|
||||
## Honest
|
||||
|
||||
- **No-mandate:** hub tự-khai "KHÔNG yêu-cầu sửa gì". SE absorb = reference + codify distinction crystallization≠backfill (design-clarity), KHÔNG claim adopt-floor.
|
||||
- **Mục 4:** SE 60K sub-reserve = owner-set (làm-tròn), KHÔNG "hội-tụ do cùng đo".
|
||||
|
||||
## Codify
|
||||
|
||||
- Absorb-only → engine `§M.A/§M.G`. KHÔNG rule mới. reviewer_gate PASS (Lane-C).
|
||||
@ -0,0 +1,25 @@
|
||||
# adap-report — 2026-07-04-Governance-harness-full-recheck-crystallized-backfill (SE)
|
||||
|
||||
> **Broadcast:** `2026-07-04-Governance-harness-full-recheck-crystallized-backfill.md` (owner-directive). **Adopt S103 (2026-07-06).**
|
||||
> **Integrity gate:** `content_sha256` `94c78d1d` **MATCH ✓** (prefix-8, canonical). Notify email `2026-07-04-Governance-notify-harness-full-recheck` verified (whole-file + body-hash `78dc1d82`).
|
||||
> **Harness-9 2-workflow:** WF1 implement **`wf_55ef6778-a0d`** + WF2 review **`wf_3c5c37cb-aa2`** (Lane-C PASS 0-BLOCKING).
|
||||
|
||||
## Nấc per-lesson (F1-F4 · G-011)
|
||||
|
||||
| Lesson | Nấc | Evidence |
|
||||
|---|---|---|
|
||||
| **F1 — số cấu-hình = trỏ-tham-chiếu KHÔNG sao-chép** | **already-met (verified)** | Lane-C exhaustive sweep = **0 hardcoded-violation** toàn-kho; persona `.claude/agents/*.md` CLEAN (0 bare-cap); mọi cap-số kèm pointer (budget.json / "đọc số sống" / lịch-sử-mark). M.B budget-table live-read retire echo `session-start:122`. |
|
||||
| **F2 — sweep đủ-tầng INCL persona** | **executed (= §L Harness-20)** | model-note 4-spot sweep + persona-tier `README:3` (reload-mỗi-spawn). Chi-tiết → adap-report §L. |
|
||||
| **F3 — model-routing bằng REAL-metadata** | **already-met (live-evidence S103)** | BƯỚC 0.6 đọc env-runtime-thật → **S103 bắt runtime=Opus** (Fable outage) KHÔNG tin comment "S102-Fable". Đúng bài F3 "ghim thắng inherit khi model blank → đứt âm-thầm"; SE all-inherit + probe-metadata mỗi phiên. |
|
||||
| **F4 — crystallized-backfill (measure-then-fill) NEW** | **executed-file + verified** | `scripts/crystallized-backfill.ps1` (NO-API DRY planner; selftest exit-0; fault-inject 3-branch teeth trên scratchpad-fakeroot: default→0 / target+headroom→min-binds / headroom≤0→0; owner-read-only grep-0-write budget.json). config `budget.json:crystallized_backfill` (target=0). engine `§M.A`. |
|
||||
|
||||
## Tailored / Skip / Phản-biện
|
||||
|
||||
- **F4 5-sàn honored:** default-0=OFF (owner-authority) · NOT-for-sub · calibrated-RANGE [bytes/4..bytes/3.0] worst-case · PRECONDITION target>0 AND headroom>0 · value-gated source-order (gist→value-marked-archive→curated-RAG) DRY-no-pour. 🔴 **DISTINCT crystallization** (§I distill = nén-về-nguồn giữ time-invariant) vs backfill (ĐỔ-vào-trống) — 2 hướng ngược (consolidation Mục 1).
|
||||
- **🔴 Honest caveat trọng-tâm — INERT-TODAY:** target=0 (AI KHÔNG set — owner quyền). measured_headroom = **UPPER-BOUND file-floor** (6-file ~97K tok worst-case → 282K "headroom"; NHƯNG peak thêm task-context biến-thiên KHÔNG trong list → real peak ~368K gần cap → real-headroom NHỎ HƠN nhiều). = đúng cảnh-báo F4 "byte/4 undercount + partial-list = ảo-giác còn-chỗ". backfill KHÔNG chạy phiên nào (mechanism built, inert-until-owner).
|
||||
- **Skip:** KHÔNG set target>0 (owner-authority). measure = calibrated-range KHÔNG official-tokenizer (measurement-gap fleet-wide).
|
||||
|
||||
## Codify + hậu-kiểm
|
||||
|
||||
- Engine `§M.A` (F4) + `§M.E` (F1/F2/F3 mapping). script + config + budget-table wire.
|
||||
- Nấc tổng: **F4 executed+verified · F1/F3 already-met (verified) · F2 = §L**. reviewer_gate PASS. Run-id WF1/WF2 như trên.
|
||||
@ -0,0 +1,23 @@
|
||||
# adap-report — 2026-07-04-Governance-session-cmd-budget-display-runloop (SE)
|
||||
|
||||
> **Broadcast:** `2026-07-04-Governance-session-cmd-budget-display-runloop.md` (owner-directive). **Adopt S103 (2026-07-06).**
|
||||
> **Integrity gate:** `content_sha256` `d47333e0` **MATCH ✓** (prefix-8, canonical).
|
||||
> **Harness-9 2-workflow:** WF1 implement **`wf_55ef6778-a0d`** + WF2 review **`wf_3c5c37cb-aa2`** (Lane-C PASS).
|
||||
|
||||
## Nấc (2 upgrade · G-011)
|
||||
|
||||
| Upgrade | Nấc | Evidence |
|
||||
|---|---|---|
|
||||
| **Up1 — bảng-số ngân-sách THẬT (live, 0-hardcode)** | **executed-file + verified** | `crystallized-backfill.ps1` in BẢNG: cap-live / hotload-bytes / tok-RANGE / measured_headroom / target / expected_backfill. Wired `session-start §2.1.6` + `session-end §L.b(c)`. Lane-C verify "all live-read 0 hardcoded". |
|
||||
| **Up2 — run-loop 2-tầng** | **executed-framing + 🟡 largely-already-met** | Tầng-1 ĐO mỗi session-end (memory-selfimprove-audit + mfe-eval + governance-detectors + archive-gate + crystallized-backfill) → khối-số tươi. Tầng-2 on-signal (gap-mới/drift-vs-last/orphan-TĂNG/coverage-tụt → **cảnh-báo ĐỎ** + refine-in-session HOẶC carry-hi-prio). engine `§M.C`. |
|
||||
|
||||
## Tailored / Skip / Phản-biện
|
||||
|
||||
- **🟡 Honest — Up2 LARGELY ALREADY-MET (trung-thực nấc):** `session-end §L.b(c)` ĐÃ có H17 loop-REFINE (reinject-ledger CG-1) + %-print + 4 deterministic script TRƯỚC broadcast. M.C = **FORMALIZE 2-tầng-framing (Tầng-1-ĐO-mỗi-end / Tầng-2-refine-on-signal) + thêm khối-số-ngân-sách-mỗi-end** — KHÔNG build machinery từ-đầu. Đúng-nấc: framing + number-block MỚI; loop-machinery cũ.
|
||||
- **🔴 Honest caveat:** Tầng-2-signal-fire **dogfood CHƯA chạy thật lần nào** (như hub tự-khai n=1 0-trigger — wired-but-not-runtime-proven). weekly full-refine backstop = SE monthly-audit (thủ-công em-main, cadence-pointer STATUS).
|
||||
- **Skip:** đo token = **calibrated-range** (byte/3.0 worst-case) KHÔNG official-API-tokenizer — đúng-nấc "đo-thật honest với biên" KHÔNG "chính-xác tuyệt-đối" (measurement-gap fleet-wide, consolidation Mục 2 — SE tự-đo KHÔNG mượn số hub).
|
||||
|
||||
## Codify + hậu-kiểm
|
||||
|
||||
- Engine `§M.B` (budget-table Up1) + `§M.C` (run-loop 2-tầng Up2). Wired session-start §2.1.6 + session-end §L.b(c).
|
||||
- Nấc tổng: **Up1 executed+verified · Up2 formalize-framing (machinery already-met, Tầng-2-fire chưa-dogfood)**. reviewer_gate PASS. Run-id WF1/WF2 như trên.
|
||||
@ -0,0 +1,23 @@
|
||||
# adap-report — 2026-07-05-Governance-harness-16-applied-eval-no-key-update (SE)
|
||||
|
||||
> **Broadcast:** `2026-07-05-Governance-harness-16-applied-eval-no-key-update.md` (type:update, additive). **Adopt S103 (2026-07-06).**
|
||||
> **Integrity gate:** `content_sha256` `a1dc3a20…` **MATCH ✓** (full-64, canonical). `reviewer_gate: PASS-WITH-FIXES` (review-wf `wf_14d8abb0`). `supersedes_scope: none (additive — re-verify CHỈ đường no-key)`.
|
||||
> **Harness-9 2-workflow:** WF1 implement **`wf_55ef6778-a0d`** + WF2 review **`wf_3c5c37cb-aa2`** (Lane-C PASS + runtime-teeth verify).
|
||||
|
||||
## Nấc (G-011)
|
||||
|
||||
| Pattern | Nấc | Evidence |
|
||||
|---|---|---|
|
||||
| **Cổng đối-kháng Applied% no-key (SCRIPTABLE mechanism)** | **executed-file + verified** | `scripts/applied-eval-nokey.ps1`: Invoke-AdversarialGate **fail-closed** (control-CAO≥0.5→BLOCK / control-BỎ-QUÊN-null→BLOCK / 0-control→BLOCK / control-thấp→PASS) + Merge (loại control, KHÔNG bịa null→0) + selftest 3-ca. em-main-run: 3-ca ALL PASS exit-0. 🔴 **Fault-inject FLIP-proven** (đảo ngưỡng trên temp-copy → selftest FAIL exit-1; **bắt real-bug `$script:`-scope** trong chính selftest lần-1 → fixed → re-verify). |
|
||||
| **Luồng 2-agent no-key (RUNTIME)** | **documented-only (deferred)** | Header DOCUMENT 3-bước: thí-sinh bịt-đáp-án đúng-persona không-thấy-đáp-án / trọng-tài KHÁC-phiên sạch-ngữ-cảnh chấm 0..1 / merge-cục-bộ $0. Chạy runtime-via-workflow khi sample-Q chín. KHÔNG chạy phiên này. |
|
||||
| **4 caveat bắt-buộc** | **executed-file + verified** | (a) proxy-điểm-thời-gian / (b) chung-họ-model chưa-khử (bịt-ĐÁP-ÁN≠bịt-TOÀN-KHO; recurrence-freq-anchor model-independent ở block đo-được-ngay CŨ) / (c) bịt-mắt CHỈ-DẶN / (d) chưa-đo-tuổi mẫu-nhỏ. Lane-C: 4 caveat trong FILE `:66-86` + engine `§M.D`. |
|
||||
|
||||
## Tailored / Skip / Phản-biện
|
||||
|
||||
- **🔴 Honest caveat trọng-tâm:** **MECHANISM built, con-số DEFERRED.** Cổng đối-kháng còn **THỦ-CÔNG** (caller tự cấp verdict + control-list) — chứng "trọng-tài CÓ-THỂ bị kiểm đối-kháng", KHÔNG "mọi con-số đã-qua-cổng". Applied% numbers CHƯA có (sample-Q immature + chờ judge độc-lập khác-phiên). TUYỆT-ĐỐI KHÔNG nói "đã đo độ-nhớ / gần-100% / đã chứng-minh độ-giữ".
|
||||
- **Tailored:** API-key nay **TÙY-CHỌN** (dùng agent-con subscription làm trọng-tài lượt-khác-phiên) KHÔNG bắt-buộc. Đường mới = **bổ-trợ** block-đo-được-ngay CŨ (Coverage% + age-band + recurrence-anchor), KHÔNG thay.
|
||||
- **Skip:** KHÔNG chạy 2-agent-pass runtime (sample-Q chưa chín). Judge recall/apply vẫn scaffold.
|
||||
|
||||
## Codify + hậu-kiểm
|
||||
|
||||
- Engine `§M.D`. script `applied-eval-nokey.ps1` (new). Nấc tổng: **mechanism executed+verified (gate + selftest 3-ca + fault-inject FLIP) · numbers DEFERRED · 2-agent-pass documented-runtime**. reviewer_gate PASS. Run-id WF1/WF2 như trên.
|
||||
@ -0,0 +1,30 @@
|
||||
# adap-request — SE → AI_INFRA — #53 return-garble trên reasoning-heavy fan-out lanes + mitigation-pattern (S103, 2026-07-06)
|
||||
|
||||
> **§M-gated** (có lý-lẽ + bằng-chứng — KHÔNG request-cho-có). SISTER=se propose-pattern NGƯỢC lên hub. Classify: **infra** (Workflow-agent-runtime reliability + fleet fan-out-review pattern).
|
||||
|
||||
## Vấn-đề (evidenced — KHÔNG lý-thuyết)
|
||||
|
||||
**#53 return-garble** (sub hoàn-tất KHÔNG gọi StructuredOutput / trả prose thay verdict) **TÁI-DIỄN ×3 phiên này** DESPITE schema-forced-return + in-conversation-nudge:
|
||||
- **investigator-codebase** (ground-truth recon) → trả text memory-curation ("verify final L1 under 17.1KB… A7 integrity") thay ground-truth-map; **còn drift-tự-ghi `archive/2026-07.md`** dù L1 KHÔNG over-cap (17337<25600) = AS-10 residual self-write.
|
||||
- **2/3 reviewer-lane** (fable-clone review `wf_3c5c37cb-aa2`) → "subagent completed without calling StructuredOutput (after in-conversation nudge)".
|
||||
|
||||
## Bằng-chứng correlation (2 workflow CÙNG phiên, CÙNG schema, CÙNG model Opus-1M)
|
||||
|
||||
- **build-workflow `wf_55ef6778-a0d`** — 3 lane NARROW-scoped ("viết script X + return schema") → **3/3 return schema CLEAN**.
|
||||
- **review-workflow `wf_3c5c37cb-aa2`** — 3 lane OPEN adversarial-reasoning ("cố phá + phán-xử") → **1/3 clean, 2/3 garble**.
|
||||
- → **Garble tương-quan OPEN-ENDED reasoning-heavy task, KHÔNG narrow-build task** (biến duy-nhất khác = task-shape + agentType heavy-persona reviewer). Consistent `feedback_agent_return_garble_recover` "instruction giảm-KHÔNG-100%".
|
||||
|
||||
## SE mitigation OBSERVED (de-facto — đã cứu phiên này)
|
||||
|
||||
1. **N-lane redundancy đa-lăng-kính:** 3 lane khác-lens → 1 survivor (Lane-C) **phủ redundant** core-concern của 2 lane garble (hash-integrity + already-met + teeth + model-note-sweep + scope). Ensemble-redundancy = safety-net #53 THẬT (review vẫn ra verdict dù 2/3 chết).
|
||||
2. **Narrow-scoped schema-lane:** chia task thành sub-task hẹp (build 3/3 clean) thay open-ended reasoning.
|
||||
3. **em-main recover-from-partial:** KHÔNG re-spawn; em-main tự làm residual (owner-read-only re-verify, hash re-compute) + git-diff backstop bắt AS-10 self-write.
|
||||
|
||||
## Propose lên hub (fleet-pattern candidate)
|
||||
|
||||
- Codify fleet-pattern: **reasoning-heavy fan-out review → N-lane-redundancy (mỗi lane cover-overlap để 1-garble-KHÔNG-mất-verdict) + narrow-scoped-schema-lanes + em-main-recover-partial.** (SE dogfood-evidence 2-workflow contrast trên.)
|
||||
- Escalate (nếu hub đồng-tình): đề-nghị harness-level **hard-stop StructuredOutput enforcement** (agent KHÔNG finish nếu chưa gọi schema) HOẶC fallback-capture partial-return — vì schema+nudge hiện **giảm-KHÔNG-triệt** (SE ×7+ lifetime).
|
||||
|
||||
## Honest
|
||||
|
||||
- SE **KHÔNG claim "đã fix #53"** — đây = **observation + de-facto-mitigation-đã-hoạt-động** + propose-pattern. Root-cause (agent-runtime drift) = harness/Anthropic domain, ngoài SE-fix-scope. Value = fleet chia-sẻ mitigation đã-cứu-phiên + hub có-thể codify/escalate.
|
||||
@ -204,7 +204,7 @@ SE đã có RAG golden-set harness (KHÔNG phải gap): `eval/golden-set-solutio
|
||||
### G.5 — Harness-15-v3 delta (S83 2026-06-22): full AI_INFRA parity + spawn-fill-to-budget (anh owner-directive)
|
||||
> Delta chồng lên §G.4 (gốc KHÔNG đổi). **anh owner-directive trực-tiếp** (KHÔNG qua broadcast AI_INFRA) — con-số = quyền chủ-dự-án (§G.4 (4)). Mark = `ACTIVE-MARKS.md` H-15 v3-delta.
|
||||
|
||||
- **(1) FULL AI_INFRA parity (🔴 anh-set):** lead **220K** · mem-sub **60K** · wf-sub **50K** (`token_governor.tier1_hotfeed_tokens`). SUPERSEDE S82 self-estimate (lead 60K / sub 20K-16K "vì SE nhỏ hơn / byte-cap binds") — đó là AI **tự-co-nhỏ**, đúng cái mark `RC-…01-58-01` cấm. anh: *"Giờ là 220k → đầu phiên nạp thêm tier1_lead cho đủ."*
|
||||
- **(1) FULL AI_INFRA parity (🔴 anh-set):** lead **220K** · mem-sub **60K** · wf-sub **50K** (`token_governor.tier1_hotfeed_tokens`). ⚠️ **[Harness-20 L.D neo-supersede S103]** lead 220K = giá-trị S83 tại thời-điểm delta này; **S94-override→380K** (SE-specific, lead KHÔNG còn AI_INFRA-parity — canonical = `budget.json` live-read; subs giữ 60K/50K). GIỮ 220K lịch-sử-dòng-dõi KHÔNG rewrite. SUPERSEDE S82 self-estimate (lead 60K / sub 20K-16K "vì SE nhỏ hơn / byte-cap binds") — đó là AI **tự-co-nhỏ**, đúng cái mark `RC-…01-58-01` cấm. anh: *"Giờ là 220k → đầu phiên nạp thêm tier1_lead cho đủ."*
|
||||
- **(2) Sub Tầng-1 = MEMORY.md (byte-cap) + SPAWN-PROMPT (🔴 sửa hiểu-nhầm S82):** byte-cap MEMORY.md (30720B ~9.3K tok) CHỈ LÀ 1 LÁT của Tầng-1 sub — **prompt-spawn em-main viết** (relevant gotcha + state + full task-context + docs/memory liên-quan) nạp PHẦN CÒN LẠI tới token-budget. ⇒ 60K/50K KHÔNG phải "headroom vô-dụng" (bác lập-luận S82 "byte-cap binds first"); nó là **target em-main NẠP-ĐẦY qua prompt giàu** (`spawn_fill_directive`).
|
||||
- **(3) Spawn-fill discipline (🔴 convention):** khi SPAWN bất-kỳ sub/workflow-agent → nạp context tới budget bằng **prompt GIÀU giá-trị-công-việc** (gotcha + state + task-context + docs/memory), KHÔNG nạp rác. Hot-load token đầu = token **GIÁ-TRỊ-NHẤT** (chắt-lọc qua nhiều giai-đoạn). RECONCILE `agents/README` "≤8K brief": heuristic cũ gác RETURN-truncation #53 (nay vá bằng memoryDelta return + recover-disk) → INPUT KHÔNG starve nữa, nạp giàu.
|
||||
- **Honest nấc:** (1) = config mechanized (`token_governor` số mới). (2)(3) = **convention** (kỷ-luật em-main viết-prompt-giàu mỗi spawn — KHÔNG tool-ép; cùng họ §G.2 "5/6 convention"). value-gate (highest-value, no-garbage) = judge em-main, không auto-enforce.
|
||||
@ -335,6 +335,48 @@ SE đã có RAG golden-set harness (KHÔNG phải gap): `eval/golden-set-solutio
|
||||
|
||||
---
|
||||
|
||||
## PHẦN L — Harness-20: Fix-all-structure (sửa drift ĐỦ-TẦNG khi supersede) (🔴 FUNCTION-FLOOR quy-trình + 🟡 form)
|
||||
|
||||
> **Adopt S103 (2026-07-06)** — AI_INFRA broadcast `2026-07-03-Governance-harness-20-fix-all-structure` (content_sha256 re-compute **MATCH ✓** `bd714a33…`; `reviewer_gate: PASS` + nac PUBLISHED). Áp qua 2-workflow Harness-9: **WF1 implement+verify `wf_55ef6778-a0d`** (Lane-C exhaustive sweep) + **WF2 review** (fable-clone ensemble, run-id ghi dưới). **Additive** — bổ-sung `governance-detectors.ps1` (§C detector DÒ; fix-all-structure ĐẢM-BẢO bản-sửa đủ-tầng), KHÔNG thay.
|
||||
|
||||
**L.A — Nguyên-lý (🔴 §1-2 sàn):** supersede/đổi 1 quy-tắc governance → drift KHÔNG tự biến mất; sót ở 4 tầng: **NHÌN** (mục-lục/bảng/sơ-đồ) · **NGUỒN** (văn-bản chuẩn — tiêu-đề + MỌI mệnh-đề active) · **DẤU** (sổ chữ-ký/hash) · **DẪN-XUẤT** (guide/template/onboarding) + 🔴 **PERSONA** (`.claude/agents/*.md` — nạp-lại MỖI spawn = drift độc-hại nhất, dễ sót nhất). Anti-pattern **SỬA-LỆCH-TẦNG**: sửa 1 tầng để tầng khác cũ = TỆ HƠN không-sửa (mâu-thuẫn + nếu tầng-cũ = authoritative → reader nhận quy-tắc SAI). Thứ-tự đúng: **đủ-tầng > không-sửa > sửa-lệch-tầng.**
|
||||
|
||||
**L.B — 4 bước (🔴 §3 sàn):** (1) **Quét cạn-kiệt** grep token/hash/tên-policy TOÀN-KHO (KHÔNG chỉ nơi-nhớ). (2) **Phân 4 nhóm** mỗi hit: ĐANG-SAI (mô-tả current sai → sửa + note-supersede) · LỊCH-SỬ-DÒNG-DÕI (saga có neo mốc → GIỮ) · DẪN-XUẤT (guide/template → update/note-đầu) · SNAPSHOT-THEO-NGÀY (chụp thời-điểm → GIỮ). (3) **Sửa HẾT ĐANG-SAI** mọi tầng (nhìn + tiêu-đề-nguồn + mệnh-đề active + dấu). (4) **KHÔNG rewrite LỊCH-SỬ.** + 🔴 **Kiểm 2-đầu khác-trục** (ground-truth + adversarial) chống "cùng-góc-cùng-điểm-mù".
|
||||
|
||||
**L.C — Ánh-xạ SE (🟡 form + honest):** SE = **convention** (grep + phân-loại = kỷ-luật người, KHÔNG cơ-chế-hóa auto-fix — trùng nấc D6 DÒ-only). Complements: detector PHÁT-HIỆN (C1/C2/C3), fix-all-structure ĐẢM-BẢO bản-sửa đủ-tầng. Adoption-checklist 6-mục = SE thực-hành từ S96-monthly (nay đặt-TÊN + neo floor). SE đã dogfood pattern (S100 J.B sweep 15-điểm/8-file `_ledger`-retire; S101 `workflows/README:51` 2-đầu bắt sweep-sót) — H20 = codify cái ngầm-có.
|
||||
|
||||
**L.D — Dogfood n=1 THIS session (🔴 executed — 2 live-application):**
|
||||
- **Model-note sweep (F2/F3 recheck-broadcast live-fix):** BƯỚC 0.6 bắt runtime S103 = **Opus** (Fable outage lại; per-session flip S98-Fable→S101-Opus→S102-Fable→**S103-Opus**) → thêm data-point tầng running-note: `agents/README.md:3` (PERSONA-tier) · `session-start.md:37` · `session-end.md:113` (Co-Authored-By "hiện=Fable"→Opus = ĐANG-SAI thật). LỊCH-SỬ-SAGA GIỮ: `agents/README:12` (H8-caveat) + STATUS/HANDOFF S98-blurb. STATUS/HANDOFF mega-line current-claim → cập-nhật @session-end blurb (natural update-point).
|
||||
- **220K→380K superseded-pointer:** engine `§G.5` "lead 220K" = S83-value, S94-override→380K → neo-supersede (GIỮ 220K + note "→S94 380K", KHÔNG rewrite lịch-sử).
|
||||
|
||||
- **2-đầu-catch (🔴 Harness-20 §4 dogfood value — REVIEW bắt sweep-gap thật):** fable-clone review `wf_3c5c37cb-aa2` (Lane-C PASS; 2 lane #53-garble→recover, Lane-C phủ redundant) bắt **2 DẪN-XUẤT stale-trailer** `docs/rules.md:220` + `docs/guides/multi-agent-setup-guide.md:428` (`Opus 4.7`→`4.8`) mà sweep-đầu-1 SÓT → **FIXED**. Phân-loại 4-nhóm L.B đúng: 2 DẪN-XUẤT (sửa) vs **~14 `sessions/*.md:3` "Opus 4.7" = SNAPSHOT-THEO-NGÀY (GIỮ NGUYÊN**, session-log mốc-cũ tháng-5). = đúng §4 "2-đầu-khác-trục bắt sửa-tầng-nhìn-quên-tầng-nguồn".
|
||||
|
||||
**Honest nấc §L:** convention (KHÔNG mechanized auto-fix — nhánh chỉ-DÒ per CAVEAT "auto-WRITE luật = mối-nguy #1"). Dogfood n=1, CHƯA phổ-quát. Mechanized THẬT = CHỈ grep (detector); phân-loại + sửa = người.
|
||||
|
||||
---
|
||||
|
||||
## PHẦN M — crystallized-backfill (measure-then-fill) + bảng-số ngân-sách + run-loop 2-tầng + Applied%-no-key (🔴 FUNCTION-FLOOR + 🟡 form)
|
||||
|
||||
> **Adopt S103 (2026-07-06)** — AI_INFRA 4 broadcast owner-directive + 1 reference, content_sha256 re-compute **MATCH ✓ cả 6**: `harness-full-recheck-crystallized-backfill` (`94c78d1d`, F1-F4) · `session-cmd-budget-display-runloop` (`d47333e0`) · `harness-16-nokey` (`a1dc3a20…`, reviewer_gate PASS-WITH-FIXES) · `Agent-memory-hygiene-mechanization` (`43c9e56f…`, A/B/C) · reference `consolidation-crystallization-measurement` (`5bba339b…`). 2-workflow: **WF1 implement `wf_55ef6778-a0d`** (2 script + Lane-C verify; selftest exit-0 ×2 + fault-inject teeth) + **WF2 review** (run-id ghi dưới). **Additive.**
|
||||
|
||||
**M.A — crystallized-backfill (🔴 F4 NEW function):** `scripts/crystallized-backfill.ps1` (NO-API DRY planner). "measure-then-fill" = đo REAL-token headroom hot-feed → đổ crystallized cold-tier vào chỗ-trống để KHÔNG phí trần. 🔴 **DISTINCT crystallization (§I distill):** distill = NÉN-về-nguồn giữ time-invariant; backfill = NGƯỢC, ĐỔ-vào-trống (consolidation Mục 1). 🔴 5 sàn bất-biến: (1) **default target=0=OFF** (owner-authority `budget.json:crystallized_backfill.target`; script READ-ONLY KHÔNG auto-tune) · (2) **NOT-for-sub** (sub-pack lead-curate per-task) · (3) **calibrated RANGE** [bytes/4..bytes/3.0], headroom dùng bytes/3.0 worst-case · (4) **PRECONDITION** mở CHỈ khi target>0 AND measured_headroom>0 · (5) **value-gated source-order** gist→value-marked-archive→curated-RAG, dedup, DRY-no-pour. 🟡 Honest: hotload_sources = **FILE-FLOOR ổn-định** (6 file) → measured_headroom = **UPPER-BOUND** (peak thêm task-context biến-thiên KHÔNG trong list → real-headroom NHỎ HƠN; ~368K peak gần cap). backfill **inert-today** (target=0). = đúng cảnh-báo F4 "byte/4 undercount = ảo-giác còn-chỗ".
|
||||
|
||||
**M.B — bảng-số ngân-sách (🔴 #4-Upgrade1):** script in BẢNG số THẬT: cap-live / hotload-đo-bytes / tok-RANGE / measured_headroom / target / expected_backfill — MỌI số đọc-sống 0-hardcode. Wired `session-start §2.1.6` + `session-end §L.b(c)` (bổ-sung %-print). **F1-tightening:** bảng-live thay prose-echo "380K" (dù SE 0-hardcoded-violation, echo session-start:122 nay có nguồn-sống thay).
|
||||
|
||||
**M.C — run-loop 2-tầng (🔴 #4-Upgrade2 — 🟡 LARGELY ALREADY-MET honest):** Tầng-1 ĐO mỗi session-end (deterministic: memory-selfimprove-audit + mfe-eval + governance-detectors + archive-gate + crystallized-backfill) → khối-số tươi (cấu-trúc chống "khai-chạy-mà-không-chạy"). Tầng-2 TINH-CHỈNH on-signal (new-gap/drift-vs-last/orphan-TĂNG/coverage-tụt → **cảnh-báo ĐỎ** + refine-in-session HOẶC carry-hi-prio nếu đứt-phiên; KHÔNG nuốt). Weekly full-refine backstop. 🟡 **Honest ALREADY-MET:** `§L.b(c)` ĐÃ có H17 loop-REFINE + %-print + 4 script; M.C = FORMALIZE 2-tầng-framing + khối-số-mỗi-end. Tầng-2-signal-fire dogfood CHƯA chạy thật (như hub n=1).
|
||||
|
||||
**M.D — Applied%-no-key (🔴 H16-update mechanism):** `scripts/applied-eval-nokey.ps1`. Cổng đối-kháng fail-closed (control-cố-ý-sai chấm-CAO→BLOCK / control-BỎ-QUÊN→BLOCK / control-thấp→PASS) + merge (loại control, KHÔNG bịa null→0) + selftest 3-ca (fault-inject FLIP-proven, bắt real-bug `$script:`-scope). 2-agent-pass (thí-sinh bịt-đáp-án đúng-persona / trọng-tài khác-phiên sạch-ngữ-cảnh) = DOCUMENTED runtime-via-workflow. 🔴 4 caveat: proxy-điểm-thời-gian / chung-họ-model-chưa-khử / bịt-mắt-chỉ-dặn / chưa-đo-tuổi. Honest: **MECHANISM built, con-số DEFERRED** (sample-Q chín + judge độc-lập khác-phiên). API-key nay **TÙY-CHỌN**.
|
||||
|
||||
**M.E — F1/F2/F3 recheck (🟡 already-met):** **F1** (số=con-trỏ): Lane-C sweep = **0 hardcoded-violation** toàn-kho, persona CLEAN → already-met (M.B retire echo). **F2** (sweep-incl-persona) = §L H20. **F3** (model-routing REAL-metadata): **BƯỚC 0.6 ĐÃ đọc env-runtime-thật** — S103 bắt Opus KHÔNG tin comment (đúng bài F3 "ghim thắng inherit khi model blank → đứt âm-thầm") → already-met + live-evidence.
|
||||
|
||||
**M.F — memory-hygiene-mechanization (🟡 ALREADY-MET via Harness-9/11 + 🔴 C n/a):** **A** archival = `memory-archive-gate.ps1` (DRY-RUN + value_protect ADVISORY-only + keep-floor + 2-strike + A7 byte-preserve → SIDESTEP grep-gate-trap vì em-main-decides) · **B** drift-detector = `governance-detectors.ps1` 4-layer 1:1 (C1 broken-ref · C2 mismatch-only `if n≠canon` · C3 vocab-fork · C4 self-exclusion SEPARATE-namespace) · **C** launcher-allowlist = **n/a-by-architecture** (SE = Anthropic Workflow JS-sandbox, KHÔNG CLI-launcher; hmw.js:1-5 + workflows/README:51) · **wire** = §2.1.2/§2.1.3 @start + §L.b(c) @end. Đã adopt via Harness-9/11 — M.F = confirm-mapping 1:1 (KHÔNG rebuild).
|
||||
|
||||
**M.G — consolidation (🟢 reference, no-mandate):** absorb: crystallization≠backfill (§I vs §M) · staleness-check by CONTENT-diff KHÔNG mtime (harvest-curator đã làm S102 recovery byte-match) · 60K sub-reserve = owner-set KHÔNG converged-measure (đã đúng) · measurement-gap priority-1 (chưa official-tokenizer — SE dùng calibrated-range honest).
|
||||
|
||||
**Honest nấc tổng §M:** mechanized-THẬT (NO-API deterministic, selftest exit-0) = crystallized-backfill + budget-table + applied-eval-nokey gate + fault-inject-teeth. Convention = run-loop framing (M.C already-met §L.b) + fix-all sweep (§L). **Inert/deferred honest:** backfill target=0 (peak gần-cap → real-headroom nhỏ) · Applied% numbers DEFERRED (mechanism-only) · measure = calibrated-range KHÔNG official-API-tokenizer (measurement-gap fleet-wide). Owner-authority: mọi con-số ngân-sách READ-ONLY.
|
||||
|
||||
---
|
||||
|
||||
## CAVEAT (trung-thực — đọc trước khi tự nhận "đã tự-bảo-trì")
|
||||
- **No-OS-hook:** detector + gate chạy TRONG thân session-start/end body do em-main kích — KHÔNG fully-autonomous. Đúng mức: **DÒ tự-động + toàn-diện; SỬA + GÁC dựa người-chủ-trì.**
|
||||
- **Auto-WRITE luật/copy = MỐI-NGUY #1, CỐ Ý CHƯA LÀM** — defer tới ≥2 sự-cố thật mà thủ-công thất-bại (hiện 0). Chọn nhánh chỉ-DÒ-NÊU-CỜ cho mọi thứ chạm luật/copy (1-sửa-sai → N-chỗ-sai + phá hash broadcast đóng-băng).
|
||||
|
||||
@ -425,7 +425,7 @@ Verify:
|
||||
|
||||
Pending Chunk <Y+1>: <next>
|
||||
|
||||
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||||
Co-Authored-By: Claude Opus 4.8 (1M) <noreply@anthropic.com> # <lead model hiện tại — đổi theo BƯỚC 0.6 session-start>
|
||||
```
|
||||
|
||||
## ⚠️ Anti-patterns (DO NOT)
|
||||
|
||||
@ -217,7 +217,7 @@ Full: xem [`database/database-guide.md`](database/database-guide.md).
|
||||
|
||||
<body optional — chi tiết what + why>
|
||||
|
||||
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||||
Co-Authored-By: Claude Opus 4.8 (1M) <noreply@anthropic.com> # <lead model hiện tại — đổi theo BƯỚC 0.6 session-start>
|
||||
```
|
||||
|
||||
**Scope:** `Contract` · `Form` · `Workflow` · `Supplier` · `Auth` · `Admin` · `Api` · `App` · `Domain` · `Infra` · `FE-Admin` · `FE-User` · `Docs` · `CICD` · `Scripts` · `Report` · `Dashboard`
|
||||
|
||||
362
scripts/applied-eval-nokey.ps1
Normal file
362
scripts/applied-eval-nokey.ps1
Normal file
@ -0,0 +1,362 @@
|
||||
# applied-eval-nokey.ps1 - Harness-16 UPDATE: Applied% WITHOUT an API key + adversarial gate - S102 (2026-07-06)
|
||||
#
|
||||
# ADAPT of AI_INFRA broadcast H16-update (owner-directive, 2026-07-04/05). SISTER-side KHUNG,
|
||||
# tailored to SOLUTION_ERP (self=se). Function-floor kept; form tailored. NO copy-paste.
|
||||
#
|
||||
# ============================================================================
|
||||
# WHAT THIS IS (and, loudly, what it is NOT)
|
||||
# ============================================================================
|
||||
# Two SEPARATE things live in this file, and they must never be confused:
|
||||
#
|
||||
# [A] SCRIPTABLE / DETERMINISTIC ($0) <-- the REAL teeth of this script, runs here, now.
|
||||
# An ADVERSARIAL GATE + a MERGE + a 3-case SELFTEST. Given a set of judge
|
||||
# verdicts (each {id, score, is_control, control_expected_low}), the gate
|
||||
# decides BLOCK / PASS, and the merge folds surviving real questions into a
|
||||
# single Applied% number. Zero model calls. Pure arithmetic + set logic.
|
||||
#
|
||||
# [B] RUNTIME / 2-AGENT-PASS <-- DOCUMENTED ONLY here; runs later, via a workflow,
|
||||
# when the sample-questions corpus is mature. NOT executed by this script.
|
||||
# This block exists so the mechanism is written down and auditable, not so a
|
||||
# number is produced today.
|
||||
#
|
||||
# The honesty ceiling (printed by -Honest and at the end of -Selftest):
|
||||
# "We have an adversarial GATE (MANUAL: you supply the verdicts + the control
|
||||
# list) + a 3-case selftest. We do NOT claim any live number has passed this
|
||||
# gate. Applied% numbers are DEFERRED until the sample-questions mature AND an
|
||||
# independent, different-session judge scores them. This file is a MECHANISM,
|
||||
# NOT a number."
|
||||
#
|
||||
# ============================================================================
|
||||
# [B] THE NO-KEY APPLIED% FLOW (documented; RUNTIME, not run here)
|
||||
# ============================================================================
|
||||
# The point: measure "does the hot-feed actually get APPLIED" without any paid
|
||||
# API / external key -- using two in-harness sub-agents instead of an oracle key.
|
||||
#
|
||||
# STEP 1 - PROBE with the ANSWER BLANKED (the "candidate" sub-agent)
|
||||
# * Take a sample question that has a known answer-anchor (the gotcha #, the
|
||||
# mark-id, the file:line, the root-cause phrase). BLANK IT OUT: strip the
|
||||
# answer-anchor from the probe so the candidate cannot read the answer back.
|
||||
# * Spawn a sub-agent IN THE RIGHT PERSONA for that question (the role whose
|
||||
# diary is supposed to carry that memory), carrying that role's diary as it
|
||||
# normally would. The candidate is told NOTHING about being graded and sees
|
||||
# NO answer key -- it just does the task and emits its working (a "diary" of
|
||||
# what it recalled / applied for that role).
|
||||
#
|
||||
# STEP 2 - JUDGE in a CLEAN, SEPARATE CONTEXT (the "referee" sub-agent)
|
||||
# * A DIFFERENT sub-agent, in a FRESH context window, DIFFERENT session/turn
|
||||
# from the candidate (no shared scratch, no candidate's chain-of-thought),
|
||||
# is GIVEN the ground-truth answer-anchor and scores the candidate 0..1 on
|
||||
# whether the required memory was actually recalled/applied.
|
||||
# * Control/sentinel probes are mixed in (see below): questions the referee
|
||||
# SHOULD score low (answer deliberately absent from any diary). They are the
|
||||
# adversarial tripwire for a too-lenient judge.
|
||||
#
|
||||
# STEP 3 - MERGE LOCALLY ($0) -> Applied%
|
||||
# * The verdicts come back here. The GATE (block A, deterministic) runs FIRST:
|
||||
# drop the whole batch if any control scored high, or if any control was
|
||||
# silently skipped. Only then MERGE: strip controls, average the real
|
||||
# scores, Applied% = round(mean * 100). Unscored (null) real questions are
|
||||
# NOT invented -- excluded + counted (N excluded).
|
||||
#
|
||||
# ============================================================================
|
||||
# 4 CAVEATS (MANDATORY -- this measurement is weak in exactly these 4 ways)
|
||||
# ============================================================================
|
||||
# (a) POINT-IN-TIME PROXY, not real behavior. A judged score at one instant is a
|
||||
# proxy for "was it applied", NOT observed downstream behavior over a real
|
||||
# task. High Applied% != the memory changed what the system actually did.
|
||||
#
|
||||
# (b) SHARED MODEL-FAMILY NOT NEUTRALIZED. Candidate and referee share the same
|
||||
# base model + the same corpus/RAG. Blanking the ANSWER-ANCHOR does NOT blank
|
||||
# the WHOLE CORPUS -- the referee (and even the candidate) may reconstruct the
|
||||
# answer from common training / shared store rather than from the diary under
|
||||
# test. The ONLY model-independent signal is RECURRENCE-FREQUENCY anchoring
|
||||
# (does the SAME bug/mark stop recurring over sessions) -- that lives in the
|
||||
# OLD measurable-now block (recurrence tokens / AS-class registry), NOT here.
|
||||
# This no-key score is the WEAKER, model-entangled cousin of that.
|
||||
#
|
||||
# (c) BLINDING IS AN INSTRUCTION, NOT AN ENFORCEMENT. "Candidate doesn't see the
|
||||
# answer / doesn't know it's graded" and "referee is a clean separate context"
|
||||
# are DIRECTIVES to the spawn, not a sandbox that makes leakage impossible. A
|
||||
# shared file, a chatty prompt, or a resumed session can defeat it. Treat the
|
||||
# separation as best-effort, and prefer the control tripwire over trusting it.
|
||||
#
|
||||
# (d) NO AGE DIMENSION YET, SMALL SAMPLE. This does not measure retention-over-age
|
||||
# (does an OLD memory still get applied), and the sample-question set is small.
|
||||
# So even a clean pass is a thin, young signal -- a FLAG, never a grade.
|
||||
#
|
||||
# ============================================================================
|
||||
# NON-NEGOTIABLES (Harness-11 / Harness-16 house rules)
|
||||
# ============================================================================
|
||||
# (1) NO-API : deterministic arithmetic + set logic ONLY. NEVER calls a model.
|
||||
# (The 2-agent pass in block [B] is RUNTIME via a workflow, not here.)
|
||||
# (2) READ-ONLY on the budget : this script NEVER reads-to-tune nor writes the
|
||||
# memory-budget.json caps. Budget numbers are the OWNER's authority (anh /
|
||||
# chu-du-an); scripts only ever measure-and-report. This file does not even
|
||||
# need the budget -- it touches NO owner-set number.
|
||||
# (3) PS 5.1, ASCII-only script body (gotcha #30). Any glyph via [char]0xXXXX
|
||||
# code-point; any target file read with -Encoding UTF8 explicitly.
|
||||
# (4) Exit 0 in normal + -Honest runs (measure-and-report, NOT a build gate).
|
||||
# -Selftest is the ONE exception: it exits 0 only if all 3 cases behave as
|
||||
# specified, non-zero otherwise, so CI/a human can trust the gate has teeth.
|
||||
#
|
||||
# Usage:
|
||||
# powershell.exe -ExecutionPolicy Bypass -File scripts\applied-eval-nokey.ps1 -Selftest
|
||||
# powershell.exe -ExecutionPolicy Bypass -File scripts\applied-eval-nokey.ps1 -Honest
|
||||
# powershell.exe -ExecutionPolicy Bypass -File scripts\applied-eval-nokey.ps1 # prints honesty rung + usage
|
||||
|
||||
param(
|
||||
[switch]$Selftest = $false,
|
||||
[switch]$Honest = $false
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$CHECK = [char]0x2705 # green check, kept as code-point (ASCII body, gotcha #30)
|
||||
$CROSS = [char]0x274C # red cross, kept as code-point
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Constant: a control (sentinel) probe should score BELOW this to be "correctly
|
||||
# rejected". At-or-above = the referee wrongly credited a control = too lenient.
|
||||
# ---------------------------------------------------------------------------
|
||||
Set-Variable -Name CONTROL_HIGH_THRESHOLD -Value 0.5 -Option Constant
|
||||
|
||||
# ===========================================================================
|
||||
# [A] ADVERSARIAL GATE (deterministic -- the real, tested teeth)
|
||||
# ===========================================================================
|
||||
# INPUT : array of verdict objects (PSCustomObject or hashtable), each with
|
||||
# id : string, probe id
|
||||
# score : double 0..1, OR $null = judge did not score it
|
||||
# is_control : bool, true = sentinel/control probe
|
||||
# control_expected_low : bool, (advisory) a control is expected low
|
||||
# OUTPUT : PSCustomObject { Decision = 'BLOCK'|'PASS'; Reasons = string[];
|
||||
# Controls = int; ControlsHighOrMissing = int }
|
||||
#
|
||||
# LOGIC (fail-closed -- any doubt about the referee's rigor => BLOCK the batch):
|
||||
# * If ANY control has a null/missing score -> BLOCK
|
||||
# (a control that was silently dropped means the judge quietly skipped the
|
||||
# tripwire; we do NOT let a batch through with an un-checked control.)
|
||||
# * If ANY control scored >= CONTROL_HIGH_THRESHOLD -> BLOCK
|
||||
# (the judge credited a probe whose answer is deliberately absent = too
|
||||
# lenient => every real score from this same judge is suspect => drop all.)
|
||||
# * Else (every control present AND every control < threshold) -> PASS.
|
||||
# ---------------------------------------------------------------------------
|
||||
function Get-ScoreOrNull($v) {
|
||||
# Read .score whether $v is a hashtable or a PSCustomObject; return $null if
|
||||
# absent or explicitly null. Do NOT coerce a missing key into 0 (that would
|
||||
# hide a skipped control).
|
||||
if ($null -eq $v) { return $null }
|
||||
if ($v -is [System.Collections.IDictionary]) {
|
||||
if (-not $v.Contains('score')) { return $null }
|
||||
$s = $v['score']
|
||||
} else {
|
||||
$prop = $v.PSObject.Properties['score']
|
||||
if ($null -eq $prop) { return $null }
|
||||
$s = $prop.Value
|
||||
}
|
||||
if ($null -eq $s) { return $null }
|
||||
return [double]$s
|
||||
}
|
||||
|
||||
function Get-BoolField($v, [string]$name) {
|
||||
if ($null -eq $v) { return $false }
|
||||
if ($v -is [System.Collections.IDictionary]) {
|
||||
if (-not $v.Contains($name)) { return $false }
|
||||
return [bool]$v[$name]
|
||||
}
|
||||
$prop = $v.PSObject.Properties[$name]
|
||||
if ($null -eq $prop) { return $false }
|
||||
return [bool]$prop.Value
|
||||
}
|
||||
|
||||
function Invoke-AdversarialGate {
|
||||
param([object[]]$Verdicts)
|
||||
|
||||
$reasons = New-Object System.Collections.Generic.List[string]
|
||||
$controls = 0
|
||||
$controlsHighOrMissing = 0
|
||||
|
||||
foreach ($v in $Verdicts) {
|
||||
$isControl = Get-BoolField $v 'is_control'
|
||||
if (-not $isControl) { continue }
|
||||
$controls++
|
||||
$id = if (Get-BoolField $v 'id') { $v.id } else { $v.id } # id passthrough (may be $null)
|
||||
$score = Get-ScoreOrNull $v
|
||||
|
||||
if ($null -eq $score) {
|
||||
$controlsHighOrMissing++
|
||||
$reasons.Add("control '$($v.id)' has NO score (silently skipped) -> BLOCK")
|
||||
continue
|
||||
}
|
||||
if ($score -ge $CONTROL_HIGH_THRESHOLD) {
|
||||
$controlsHighOrMissing++
|
||||
$reasons.Add("control '$($v.id)' scored $score >= $CONTROL_HIGH_THRESHOLD (judge too lenient) -> BLOCK")
|
||||
}
|
||||
}
|
||||
|
||||
if ($controls -eq 0) {
|
||||
# No tripwire at all: cannot certify the judge's rigor. Fail-closed.
|
||||
$reasons.Add("no control probes present -> cannot certify judge rigor -> BLOCK")
|
||||
return [pscustomobject]@{
|
||||
Decision = 'BLOCK'; Reasons = $reasons.ToArray()
|
||||
Controls = 0; ControlsHighOrMissing = 0
|
||||
}
|
||||
}
|
||||
|
||||
$decision = if ($controlsHighOrMissing -gt 0) { 'BLOCK' } else { 'PASS' }
|
||||
return [pscustomobject]@{
|
||||
Decision = $decision; Reasons = $reasons.ToArray()
|
||||
Controls = $controls; ControlsHighOrMissing = $controlsHighOrMissing
|
||||
}
|
||||
}
|
||||
|
||||
# ===========================================================================
|
||||
# MERGE (deterministic -- only reached AFTER the gate returns PASS)
|
||||
# ===========================================================================
|
||||
# Strip controls, average the REAL scores, Applied% = round(mean * 100).
|
||||
# A real question the judge did not score (null) is NOT invented -> excluded +
|
||||
# counted in ExcludedNull. If, after excluding controls + nulls, no real scored
|
||||
# question remains, AppliedPct = $null (report "no scored real questions"),
|
||||
# NEVER a fabricated 0.
|
||||
# ---------------------------------------------------------------------------
|
||||
function Merge-AppliedScore {
|
||||
param([object[]]$Verdicts)
|
||||
|
||||
$realScores = New-Object System.Collections.Generic.List[double]
|
||||
$excludedNull = 0
|
||||
$controlCount = 0
|
||||
|
||||
foreach ($v in $Verdicts) {
|
||||
if (Get-BoolField $v 'is_control') { $controlCount++; continue }
|
||||
$score = Get-ScoreOrNull $v
|
||||
if ($null -eq $score) { $excludedNull++; continue } # do NOT fabricate a number
|
||||
$realScores.Add($score)
|
||||
}
|
||||
|
||||
if ($realScores.Count -eq 0) {
|
||||
return [pscustomobject]@{
|
||||
AppliedPct = $null; RealN = 0; ExcludedNull = $excludedNull
|
||||
ControlN = $controlCount; Mean = $null
|
||||
}
|
||||
}
|
||||
$mean = ($realScores | Measure-Object -Average).Average
|
||||
return [pscustomobject]@{
|
||||
AppliedPct = [int][Math]::Round($mean * 100)
|
||||
RealN = $realScores.Count
|
||||
ExcludedNull = $excludedNull
|
||||
ControlN = $controlCount
|
||||
Mean = [Math]::Round($mean, 4)
|
||||
}
|
||||
}
|
||||
|
||||
# ===========================================================================
|
||||
# Honesty rung (printed on plain run + at end of -Selftest)
|
||||
# ===========================================================================
|
||||
function Write-HonestyRung {
|
||||
Write-Host ""
|
||||
Write-Host "--- HONESTY RUNG (applied-eval-nokey) ---"
|
||||
Write-Host "We HAVE : an adversarial GATE (MANUAL -- you supply the verdicts + the control list)"
|
||||
Write-Host " + a 3-case selftest proving the gate BLOCKs a lenient/dropped control."
|
||||
Write-Host "We do NOT claim any live number has passed this gate."
|
||||
Write-Host "Applied% numbers are DEFERRED until (a) the sample-questions mature AND"
|
||||
Write-Host " (b) an independent, DIFFERENT-SESSION judge scores them."
|
||||
Write-Host "This file is a MECHANISM, NOT a number."
|
||||
Write-Host ""
|
||||
Write-Host "4 CAVEATS baked in: (a) point-in-time proxy != real behavior; (b) shared model-family"
|
||||
Write-Host " not neutralized (blank-ANSWER != blank-CORPUS; only recurrence-freq anchoring"
|
||||
Write-Host " is model-independent, and that lives in the OLD measurable-now block);"
|
||||
Write-Host " (c) blinding is an instruction, not an enforcement; (d) no age dimension yet,"
|
||||
Write-Host " small sample -- a FLAG, never a grade."
|
||||
}
|
||||
|
||||
# ===========================================================================
|
||||
# SELFTEST (3 cases, internal fake data -- the ONE path that may exit non-zero)
|
||||
# ===========================================================================
|
||||
function Invoke-Selftest {
|
||||
# $script:-scoped so the nested Assert-Case can flip it and the flip survives
|
||||
# back here (a plain local would NOT propagate from the nested function --
|
||||
# caught by fault-injection: a sabotaged gate printed CASE FAIL yet the summary
|
||||
# still said ALL PASS + exit 0 when this was function-local).
|
||||
$script:allPass = $true
|
||||
|
||||
function Assert-Case {
|
||||
param([string]$Name, [bool]$Condition, [string]$Detail)
|
||||
if ($Condition) {
|
||||
Write-Host ("{0} CASE {1}: PASS ({2})" -f $CHECK, $Name, $Detail)
|
||||
} else {
|
||||
Write-Host ("{0} CASE {1}: FAIL ({2})" -f $CROSS, $Name, $Detail)
|
||||
$script:allPass = $false
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "=== applied-eval-nokey SELFTEST (3 cases) ==="
|
||||
|
||||
# -- Case (a): a control scored HIGH (0.9) -> MUST BLOCK -------------------
|
||||
$caseA = @(
|
||||
[pscustomobject]@{ id='q1'; score=0.8; is_control=$false; control_expected_low=$false }
|
||||
[pscustomobject]@{ id='q2'; score=0.7; is_control=$false; control_expected_low=$false }
|
||||
[pscustomobject]@{ id='ctlA'; score=0.9; is_control=$true; control_expected_low=$true }
|
||||
)
|
||||
$rA = Invoke-AdversarialGate -Verdicts $caseA
|
||||
Assert-Case -Name 'a-control-HIGH' -Condition ($rA.Decision -eq 'BLOCK') `
|
||||
-Detail ("control 0.9 -> Decision=$($rA.Decision) (expect BLOCK); reason=" + ($rA.Reasons -join '; '))
|
||||
|
||||
# -- Case (b): all controls LOW (0.1) -> MUST PASS + produce Applied% ------
|
||||
$caseB = @(
|
||||
[pscustomobject]@{ id='q1'; score=0.8; is_control=$false; control_expected_low=$false }
|
||||
[pscustomobject]@{ id='q2'; score=0.6; is_control=$false; control_expected_low=$false }
|
||||
[pscustomobject]@{ id='ctlB'; score=0.1; is_control=$true; control_expected_low=$true }
|
||||
)
|
||||
$rB = Invoke-AdversarialGate -Verdicts $caseB
|
||||
$mB = $null
|
||||
if ($rB.Decision -eq 'PASS') { $mB = Merge-AppliedScore -Verdicts $caseB }
|
||||
# real scores 0.8,0.6 -> mean 0.7 -> Applied% = 70; control excluded.
|
||||
$bOk = ($rB.Decision -eq 'PASS') -and ($null -ne $mB) -and ($mB.AppliedPct -eq 70) -and ($mB.ControlN -eq 1)
|
||||
$bDetail = if ($null -ne $mB) {
|
||||
"Decision=$($rB.Decision); Applied%=$($mB.AppliedPct) (expect 70); RealN=$($mB.RealN); ControlN=$($mB.ControlN)"
|
||||
} else {
|
||||
"Decision=$($rB.Decision) (expect PASS) -- merge not reached"
|
||||
}
|
||||
Assert-Case -Name 'b-control-LOW' -Condition $bOk -Detail $bDetail
|
||||
|
||||
# -- Case (c): a control was FORGOTTEN (null score) -> MUST BLOCK ----------
|
||||
$caseC = @(
|
||||
[pscustomobject]@{ id='q1'; score=0.9; is_control=$false; control_expected_low=$false }
|
||||
[pscustomobject]@{ id='q2'; score=0.8; is_control=$false; control_expected_low=$false }
|
||||
[pscustomobject]@{ id='ctlC'; score=$null; is_control=$true; control_expected_low=$true }
|
||||
)
|
||||
$rC = Invoke-AdversarialGate -Verdicts $caseC
|
||||
Assert-Case -Name 'c-control-FORGOTTEN' -Condition ($rC.Decision -eq 'BLOCK') `
|
||||
-Detail ("control score=null -> Decision=$($rC.Decision) (expect BLOCK); reason=" + ($rC.Reasons -join '; '))
|
||||
|
||||
Write-Host ""
|
||||
if ($script:allPass) {
|
||||
Write-Host ("{0} SELFTEST: ALL 3 CASES PASS" -f $CHECK)
|
||||
} else {
|
||||
Write-Host ("{0} SELFTEST: FAILURE -- at least one case did not behave as specified" -f $CROSS)
|
||||
}
|
||||
|
||||
Write-HonestyRung
|
||||
return $script:allPass
|
||||
}
|
||||
|
||||
# ===========================================================================
|
||||
# Entry point
|
||||
# ===========================================================================
|
||||
if ($Selftest) {
|
||||
$ok = Invoke-Selftest
|
||||
if ($ok) { exit 0 } else { exit 1 }
|
||||
}
|
||||
|
||||
if ($Honest) {
|
||||
Write-HonestyRung
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Plain run: no live data path exists yet (numbers DEFERRED). Print the rung + usage.
|
||||
Write-Host "applied-eval-nokey.ps1 -- MECHANISM for a no-API Applied% measurement (adversarial gate + merge)."
|
||||
Write-Host "No live numbers are produced: the 2-agent probe/judge pass is RUNTIME (via a workflow) and"
|
||||
Write-Host "runs only when the sample-questions corpus matures. This script contributes the DETERMINISTIC"
|
||||
Write-Host "gate + merge + selftest that the runtime verdicts flow through."
|
||||
Write-HonestyRung
|
||||
Write-Host ""
|
||||
Write-Host "Run the selftest: powershell.exe -ExecutionPolicy Bypass -File scripts\applied-eval-nokey.ps1 -Selftest"
|
||||
exit 0
|
||||
254
scripts/crystallized-backfill.ps1
Normal file
254
scripts/crystallized-backfill.ps1
Normal file
@ -0,0 +1,254 @@
|
||||
# crystallized-backfill.ps1 - Harness-... crystallized-backfill = "measure-then-fill"
|
||||
# Adopt: AI_INFRA broadcast F4 + session-cmd-budget-display Upgrade-1 (SE adapt 07-06).
|
||||
#
|
||||
# WHAT THIS IS
|
||||
# A PLANNER (DRY, NO-API) that answers ONE question for the LEAD hot-feed:
|
||||
# "After the always-loaded hot-load sources are in Tier-1, how much REAL-TOKEN
|
||||
# headroom is left under the live cap, and how many tokens of crystallized
|
||||
# (value-gated) backfill may we pull in WITHOUT over-stuffing?"
|
||||
# It MEASURES (byte-count the live hot-load files) then computes an EXPECTED
|
||||
# backfill under a hard precondition. It does NOT pour anything (no memory write,
|
||||
# no context change) - exactly like memory-archive-gate.ps1 it is a DRY planner.
|
||||
#
|
||||
# NON-NEGOTIABLES
|
||||
# (1) OWNER-READ-ONLY : every budget number (lead cap + backfill target) is the
|
||||
# OWNER's (chu-du-an) to set in memory-budget.json. This
|
||||
# script ONLY reads them LIVE. It NEVER computes, writes,
|
||||
# auto-tunes, or persists a budget number. (role_boundary_note)
|
||||
# (2) DEFAULT 0 = OFF : if the optional crystallized_backfill block is ABSENT (or
|
||||
# target<=0) the expected backfill is 0 (TAT / turned-off).
|
||||
# Backfill only "opens" when owner sets target>0 AND measured
|
||||
# headroom>0 (precondition). Standalone default = OFF.
|
||||
# (3) NOT-FOR-SUB : this measures the LEAD hot-feed only. Sub packs are
|
||||
# hand-distilled by em-main per task; blind-pouring backfill
|
||||
# into a sub dilutes relevance. If invoked -Tier sub => WARN.
|
||||
# (4) CALIBRATED RANGE: token headroom is a RANGE [bytes/4 .. bytes/3.0], NOT the
|
||||
# false-precise byte/4. VN-diacritic hot-memory ~3.0-3.5
|
||||
# byte/tok, so bytes/3.0 = worst-case (fewest tokens hidden
|
||||
# behind the bytes). measured_headroom uses the worst case.
|
||||
# (5) NO-API : Select-String + byte/file measure ONLY. NEVER calls a model.
|
||||
# (6) PS 5.1 / ASCII : script BODY is ASCII-only (gotcha #30); any glyph via
|
||||
# [char]0xXXXX code-point; target files read -Encoding UTF8.
|
||||
# (7) exit 0 ALWAYS : measure-and-report, NOT a build-gate.
|
||||
#
|
||||
# Usage:
|
||||
# powershell.exe -ExecutionPolicy Bypass -File scripts\crystallized-backfill.ps1
|
||||
# powershell.exe -ExecutionPolicy Bypass -File scripts\crystallized-backfill.ps1 -Json
|
||||
#
|
||||
# See [TAILOR] block at the bottom for the honest simplifications vs the maximal spec.
|
||||
|
||||
param(
|
||||
[string]$RepoRoot = "$PSScriptRoot\..",
|
||||
[switch]$Json = $false,
|
||||
[string]$Tier = "lead" # NOT-for-sub guard: anything but 'lead' => WARN (still measures lead)
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
# ---- glyphs as code-points (ASCII body, gotcha #30) -----------------------
|
||||
$WARN = [char]0x26A0 # warning sign
|
||||
$ARROW = [char]0x2192 # rightwards arrow (source-order display)
|
||||
|
||||
# ---- resolve paths --------------------------------------------------------
|
||||
$RepoRoot = (Resolve-Path $RepoRoot).Path
|
||||
$memRoot = Join-Path $RepoRoot '.claude\agent-memory'
|
||||
$budgetPath = Join-Path $memRoot 'memory-budget.json'
|
||||
|
||||
if (-not (Test-Path $budgetPath)) { Write-Error "memory-budget.json not found: $budgetPath"; exit 1 }
|
||||
|
||||
# ---- load LIVE budget -----------------------------------------------------
|
||||
$budget = Get-Content $budgetPath -Raw | ConvertFrom-Json
|
||||
|
||||
# (a) lead cap : LIVE-read, never hardcode (owner authority).
|
||||
$tg = $budget.token_governor
|
||||
if ($null -eq $tg -or $null -eq $tg.tier1_hotfeed_tokens) {
|
||||
Write-Error "memory-budget.json missing token_governor.tier1_hotfeed_tokens (lead cap source)"; exit 1
|
||||
}
|
||||
$leadCap = [int]$tg.tier1_hotfeed_tokens.lead_tokens # LIVE. owner-set. read-only here.
|
||||
|
||||
# (b) crystallized_backfill : OPTIONAL block. Absent => SAFE DEFAULT (target=0=OFF,
|
||||
# default hotload list). em-main adds the config block later; script runs
|
||||
# standalone with defaults now.
|
||||
$cb = $budget.crystallized_backfill
|
||||
$defaultHotload = @(
|
||||
'docs/STATUS.md',
|
||||
'docs/HANDOFF.md',
|
||||
'.claude/governance/ACTIVE-MARKS.md',
|
||||
'docs/changelog/migration-todos.md'
|
||||
)
|
||||
if ($null -eq $cb) {
|
||||
$target = 0 # DEFAULT OFF (TAT)
|
||||
$hotloadSources = $defaultHotload
|
||||
$cfgState = "ABSENT (safe default: target=0=OFF, default hotload list)"
|
||||
} else {
|
||||
# target : owner number. Read LIVE; default 0 if the field is missing.
|
||||
if ($null -ne $cb.target) { $target = [int]$cb.target } else { $target = 0 }
|
||||
# hotload_sources : owner list; fall back to default if missing/empty.
|
||||
$hotloadSources = @()
|
||||
if ($cb.hotload_sources) { foreach ($h in $cb.hotload_sources) { if ($h) { $hotloadSources += [string]$h } } }
|
||||
if ($hotloadSources.Count -eq 0) { $hotloadSources = $defaultHotload }
|
||||
$cfgState = "present (target + hotload_sources read LIVE)"
|
||||
}
|
||||
|
||||
# ---- NOT-FOR-SUB guard (invariant 3) --------------------------------------
|
||||
$subWarn = $false
|
||||
if ($Tier -ne 'lead') {
|
||||
$subWarn = $true
|
||||
}
|
||||
|
||||
# ==========================================================================
|
||||
# MEASURE : byte-count each LIVE hot-load source (UTF8), sum, derive RANGE.
|
||||
# ==========================================================================
|
||||
$srcRows = @()
|
||||
$totalBytes = 0
|
||||
$utf8 = New-Object System.Text.UTF8Encoding($false)
|
||||
foreach ($rel in $hotloadSources) {
|
||||
$full = Join-Path $RepoRoot ($rel -replace '/', '\')
|
||||
if (Test-Path $full) {
|
||||
# measure via UTF8 decode-length-in-bytes = on-disk byte size (explicit UTF8, gotcha #30)
|
||||
$b = ([System.IO.File]::ReadAllBytes($full)).Length
|
||||
$totalBytes += $b
|
||||
$srcRows += [pscustomobject]@{ src = $rel; bytes = $b; state = 'ok' }
|
||||
} else {
|
||||
$srcRows += [pscustomobject]@{ src = $rel; bytes = 0; state = 'MISSING' }
|
||||
}
|
||||
}
|
||||
|
||||
# calibrated RANGE (invariant 4): tok_low = optimistic (bytes/4), tok_high = worst (bytes/3.0)
|
||||
$tokLow = [int][math]::Round($totalBytes / 4.0)
|
||||
$tokHigh = [int][math]::Round($totalBytes / 3.0)
|
||||
|
||||
# measured_headroom = cap - worst-case-load (can be NEGATIVE = hot-feed near full)
|
||||
$measuredHeadroom = $leadCap - $tokHigh
|
||||
|
||||
# ---- expected_backfill (invariant 2 + precondition) -----------------------
|
||||
# precondition: only OPEN backfill when headroom>0 AND target>0. Else 0.
|
||||
if ($target -gt 0 -and $measuredHeadroom -gt 0) {
|
||||
$expectedBackfill = [math]::Min($target, $measuredHeadroom)
|
||||
$preconditionMet = $true
|
||||
} else {
|
||||
$expectedBackfill = 0
|
||||
$preconditionMet = $false
|
||||
}
|
||||
|
||||
# reason string (why backfill is what it is)
|
||||
if ($target -le 0) {
|
||||
$backReason = "target=0 => OFF (TAT, default until owner sets target>0)"
|
||||
} elseif ($measuredHeadroom -le 0) {
|
||||
$backReason = "measured_headroom<=0 => NO room (hot-feed at/over worst-case cap)"
|
||||
} elseif ($expectedBackfill -eq $target) {
|
||||
$backReason = "min(target,headroom)=target => full target fits under headroom"
|
||||
} else {
|
||||
$backReason = "min(target,headroom)=headroom => headroom binds (target exceeds room)"
|
||||
}
|
||||
|
||||
# ==========================================================================
|
||||
# -Json : one machine-readable line, then exit. (numbers all live-derived)
|
||||
# ==========================================================================
|
||||
if ($Json) {
|
||||
$out = [ordered]@{
|
||||
cap = $leadCap
|
||||
bytes = $totalBytes
|
||||
tok_low = $tokLow
|
||||
tok_high = $tokHigh
|
||||
headroom = $measuredHeadroom
|
||||
target = $target
|
||||
backfill = $expectedBackfill
|
||||
}
|
||||
Write-Output (($out | ConvertTo-Json -Compress))
|
||||
exit 0
|
||||
}
|
||||
|
||||
# ==========================================================================
|
||||
# HUMAN REPORT
|
||||
# ==========================================================================
|
||||
$dash = [string]([char]45) # '-' as a value, never a bare '--' run (PS 5.1 decrement-op trap)
|
||||
|
||||
Write-Output "============================================================"
|
||||
Write-Output " crystallized-backfill.ps1 - measure-then-fill (DRY planner)"
|
||||
Write-Output " tier : $Tier"
|
||||
Write-Output " budget.json : $budgetPath"
|
||||
Write-Output " cb config : $cfgState"
|
||||
Write-Output "============================================================"
|
||||
|
||||
if ($subWarn) {
|
||||
Write-Output ""
|
||||
Write-Output (" {0} NOT-FOR-SUB: -Tier '$Tier' requested. This planner measures the LEAD" -f $WARN)
|
||||
Write-Output " hot-feed ONLY. Sub packs are hand-distilled by em-main per task; blind"
|
||||
Write-Output " backfill into a sub dilutes relevance. Reporting LEAD numbers regardless."
|
||||
}
|
||||
|
||||
# ---- source measure table -------------------------------------------------
|
||||
Write-Output ""
|
||||
Write-Output "### hot-load sources (LIVE byte-measure, UTF8)"
|
||||
Write-Output ""
|
||||
Write-Output ("{0,-44} {1,10} {2,8}" -f 'source', 'bytes', 'state')
|
||||
Write-Output ("{0,-44} {1,10} {2,8}" -f ($dash*44), ($dash*10), ($dash*8))
|
||||
foreach ($r in $srcRows) {
|
||||
Write-Output ("{0,-44} {1,10} {2,8}" -f $r.src, $r.bytes, $r.state)
|
||||
}
|
||||
Write-Output ("{0,-44} {1,10} {2,8}" -f 'TOTAL', $totalBytes, '')
|
||||
|
||||
# ---- the budget number table (Upgrade-1) ----------------------------------
|
||||
# ALL numbers read-live; ZERO hardcoded budget values.
|
||||
Write-Output ""
|
||||
Write-Output "### budget numbers (Upgrade-1) - ALL live-read, 0 hardcoded"
|
||||
Write-Output ""
|
||||
$hr = if ($measuredHeadroom -ge 0) { "$measuredHeadroom" } else { "$measuredHeadroom (NEG=near-full)" }
|
||||
Write-Output ("{0,-22} : {1}" -f 'Tran tong (live cap)', "$leadCap tok")
|
||||
Write-Output ("{0,-22} : {1}" -f 'hotload measured', "$totalBytes bytes")
|
||||
Write-Output ("{0,-22} : {1}" -f 'tok RANGE [low..high]', "[$tokLow .. $tokHigh] tok (bytes/4 .. bytes/3.0)")
|
||||
Write-Output ("{0,-22} : {1}" -f 'measured_headroom', "$hr tok (cap - tok_high, worst-case)")
|
||||
Write-Output ("{0,-22} : {1}" -f 'target (owner)', "$target tok")
|
||||
Write-Output ("{0,-22} : {1}" -f 'expected_backfill', "$expectedBackfill tok ($backReason)")
|
||||
|
||||
# ---- value-gated source-order plan (invariant, inert while target=0) ------
|
||||
# When backfill>0 we would PULL crystallized content in this priority order,
|
||||
# dedup vs the hot-load already counted. We NEVER actually pour it here (DRY,
|
||||
# like archive-gate) - we only PRINT the order the fill WOULD follow.
|
||||
Write-Output ""
|
||||
Write-Output "### value-gated backfill source-order (planner / DRY - no pour)"
|
||||
Write-Output ""
|
||||
if ($preconditionMet) {
|
||||
Write-Output (" precondition MET (target>0 AND headroom>0): would pull up to $expectedBackfill tok in order:")
|
||||
Write-Output (" 1. gist {0} archive/*.gist.md (4-field distilled)" -f $ARROW)
|
||||
Write-Output (" 2. value-marked {0} archive lines carrying gotcha# / anti-pattern / root-cause" -f $ARROW)
|
||||
Write-Output (" 3. curated RAG {0} search_memory high-value hits" -f $ARROW)
|
||||
Write-Output " (each stage DEDUP vs the hot-load sources above; stop at expected_backfill)"
|
||||
} else {
|
||||
Write-Output (" precondition NOT met -> source-order INERT (no pull). Opens only when target>0 AND headroom>0.")
|
||||
Write-Output (" order (for reference): 1.gist {0} 2.value-marked-archive {0} 3.curated-RAG (dedup vs hot-load)" -f $ARROW)
|
||||
}
|
||||
|
||||
# ---- honest caveat (invariant, always printed) ----------------------------
|
||||
Write-Output ""
|
||||
Write-Output "------------------------------------------------------------"
|
||||
Write-Output " HONEST CAVEAT"
|
||||
Write-Output " char/4 is NOT a real token count; VN-diacritic hot-memory ~3.0-3.5 byte/tok."
|
||||
Write-Output " Headroom is a RANGE [bytes/4 .. bytes/3.0]; this planner uses bytes/3.0 (worst)."
|
||||
Write-Output " backfill defaults to 0 = TAT until the OWNER sets target>0 AND measured headroom>0."
|
||||
Write-Output " Every budget number is the OWNER's authority; this script is READ-ONLY (never tunes/writes)."
|
||||
Write-Output " HEADROOM is measured over a STABLE FILE-FLOOR (the configured hotload_sources) = an UPPER BOUND."
|
||||
Write-Output " The PEAK hot-feed also loads session-variable task-context NOT in this list; real headroom is SMALLER."
|
||||
Write-Output "------------------------------------------------------------"
|
||||
|
||||
# measure-and-report; NEVER a build-gate.
|
||||
exit 0
|
||||
|
||||
# ==========================================================================
|
||||
# [TAILOR] honest simplifications vs the maximal spec:
|
||||
# * headroom uses the WORST-CASE end of the RANGE (bytes/3.0 => fewest tokens
|
||||
# hidden behind the bytes => smallest headroom => most conservative "open"
|
||||
# decision). The optimistic bytes/4 is printed for context only.
|
||||
# * byte-measure = [IO.File]::ReadAllBytes(...).Length (true on-disk size);
|
||||
# NOT Get-Content length (which mangles VN/em-dash under PS 5.1 ANSI, gotcha
|
||||
# #30) and NOT a re-encode estimate. Exact bytes, honest tokens-as-range.
|
||||
# * the value-gated source-order is a PRINTED PLAN only (gist -> value-marked
|
||||
# archive -> curated RAG, dedup vs hot-load). It performs NO pull and changes
|
||||
# NO context - identical DRY-planner stance to memory-archive-gate.ps1.
|
||||
# * crystallized_backfill block is OPTIONAL: absent => target=0 (OFF) + the 4
|
||||
# default hotload sources, so the script is fully standalone before em-main
|
||||
# adds the config. Present => target + hotload_sources are read LIVE.
|
||||
# * NOT-FOR-SUB is a WARN (not a hard-exit): -Tier sub still prints LEAD numbers
|
||||
# but flags that sub-packs are hand-distilled, never blind-backfilled.
|
||||
# ==========================================================================
|
||||
Reference in New Issue
Block a user