[CLAUDE] Infra: adopt AI_INFRA Harness 1/2/3 — monitor subs (roster 8->10) + wave-folder isolation + email channel (S49)
Harness 1 (Self-observability): NEW tooling-auditor (H1 tooling/docs-freshness 4-faceted) + harvest-curator (H2 harvest-integrity 5-axis) INFORM-only monitor subs, TACH BIET per anh-mandate -> roster 8->10. Wire session-start Phase 2.1.1 RE-REPORT + session-end L.b 6->7-step (H2 5-axis GATE + H1 chot + B5 wave-gom). H3 plugin/skill = gop-vai doc, 0 new agent. Harness 2 (wave-folder isolation): hmw.js WAVE-MODE (subMdPath + tool-aware writeGuard) + .gitignore wave-*/ + agent-teams/ (B6 git-check-ignore verified) + NEW workflows/README convention. Harness 3 (email channel): broadcasts/ (6+6 folder + 13 .gitkeep + _index + inbox/README, committed) + send/check-email cmd (self=se) + adap-apply base-path fix outbox/all/. HMW-mode ON: recon fan-out 4 read-only agent -> em main single-writer WRITE -> reviewer PASS all 3. Containment: git-diff 1 benign self-MEMORY + chunk-count 2414=2414 (0 RAG-write). Nac executed-file, verified-runtime PENDING CLI restart. 3 adap-reports + session log. Test 181 unchanged (no product code). CI runs (hmw.js/.gitignore/.gitkeep not path-ignored) but no bundle/migration change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@ -2,10 +2,11 @@
|
||||
// top-level await/return hợp lệ); KHÔNG node-runnable trực tiếp (`node hmw.js` sẽ lỗi await).
|
||||
// Em main lo P0/P1/P3/P4 NGOÀI workflow; script này CHỈ lo P2 fan-out.
|
||||
// Invoke bằng {scriptPath} (no hot-reload — restart/re-invoke sau khi sửa). Scope = repo SOLUTION_ERP ONLY (S1).
|
||||
// ⚠️ Script chạy JS-sandbox KHÔNG filesystem → KHÔNG tự tạo folder/ghi file. Scaffold wave-folder = EM MAIN @P1 (Harness 2 B3).
|
||||
|
||||
export const meta = {
|
||||
name: 'hmw',
|
||||
description: 'HMW P2 execute (SOLUTION_ERP) — fan-out 8-agent roster có MEMORY-PACK slice (qua args vì script không đọc file) + return findings + checklistEvidence + memoryDelta (spawn-record 4-field). DEFAULT read/analyze; write fan-out = file-disjoint + em main git-diff sau P2. taskList thoải mái (queue theo slot, không cap cứng). memoryDelta KHÔNG tự ghi — em main VERIFY + APPEND-only @P3 (no-overwrite-unverified, B3). Same-model inherit Opus. Scope = repo SOLUTION_ERP ONLY (S1 — KHÔNG fan-out repo/corpus khác).',
|
||||
description: 'HMW P2 execute (SOLUTION_ERP) — fan-out 8-agent roster có MEMORY-PACK slice (qua args vì script không đọc file) + return findings + checklistEvidence + memoryDelta (spawn-record 4-field). 2 MODE (Harness 2, 06-07): (A) DEFAULT return-delta-only — fan-out nhẹ, sub KHÔNG ghi file, git-diff verify. (B) WAVE-MODE (args.wave) — workflow DÀI, em main scaffold .claude/workflows/wave-<tên>/ @P1, sub ghi full-detail vào CHỈ sub-MD mình (B4/B6), H2 harvest-curator gom wave→agent-memory @session-end (B5). taskList thoải mái (queue theo slot, không cap cứng). memoryDelta KHÔNG tự ghi — em main VERIFY + APPEND-only @P3 (no-overwrite-unverified, B3). Same-model inherit Opus. Scope = repo SOLUTION_ERP ONLY (S1 — KHÔNG fan-out repo/corpus khác).',
|
||||
phases: [{ title: 'Execute', detail: 'fan-out memory-pack-injected agents, structured return' }],
|
||||
}
|
||||
|
||||
@ -15,6 +16,7 @@ export const meta = {
|
||||
// spec: '<acceptance-criteria / context chung>',
|
||||
// checkpointApproved: true, // em main set SAU khi BÁO {số agent·vai·task} @inform (S2)
|
||||
// taskList: [ { role:<VALID_ROLES|null>, label:'..', prompt:'..' }, ... ]
|
||||
// wave: { name:'<tên-wave>', dir:'.claude/workflows/wave-<tên>' } // OPTIONAL — bật WAVE-MODE (B). Folder + wave.md em main ĐÃ scaffold @P1 (script no-fs).
|
||||
// }
|
||||
|
||||
const VALID_ROLES = [
|
||||
@ -29,6 +31,7 @@ const SCHEMA = {
|
||||
properties: {
|
||||
findings: { type: 'string', description: 'Kết quả chính. MỌI claim kèm evidence file:line. KHÔNG narrative suông.' },
|
||||
checklistEvidence: { type: 'string', description: 'Bằng chứng cho acceptance-checklist P1 (số đo / PASS-FAIL / verdict).' },
|
||||
subMdPath: { type: 'string', description: 'WAVE-MODE: đường-dẫn sub-MD agent đã ghi (em main/H2 đọc on-demand). DEFAULT-mode: bỏ trống.' },
|
||||
memoryDelta: {
|
||||
type: 'object',
|
||||
description: 'Spawn-record 4-field — RETURN-only để EM MAIN harvest @P3. Agent KHÔNG tự ghi ký ức (KHÔNG file MEMORY.md, KHÔNG store_memory/RAG). Em main VERIFY + APPEND-only (KHÔNG overwrite entry cũ nếu chưa kiểm tra — B3).',
|
||||
@ -63,8 +66,14 @@ if (A.taskList.length > 16) {
|
||||
const memoryPack = A.memoryPack || {}
|
||||
const spec = A.spec || ''
|
||||
|
||||
// ─── WAVE-MODE (Harness 2 B) ─────────────────────────────────────────────────
|
||||
// wave = { name, dir }. Folder + wave.md em main ĐÃ scaffold @P1 (script no-fs). Bật → sub ghi full-detail
|
||||
// vào CHỈ sub-MD mình + return memoryDelta. Isolation B6 (gitignore wave-*/ + em main git-diff post-P2 + chunk-count).
|
||||
const wave = (A.wave && A.wave.dir) ? A.wave : null
|
||||
if (wave) log(`hmw: WAVE-MODE on → dir=${wave.dir} (sub ghi sub-MD isolated; em main scaffold @P1; H2 harvest-curator gom @session-end B5).`)
|
||||
|
||||
phase('Execute')
|
||||
log(`HMW P2: fan-out ${A.taskList.length} task (same-model inherit, memory-pack-injected, scope=SOLUTION_ERP repo only)`)
|
||||
log(`HMW P2: fan-out ${A.taskList.length} task (${wave ? 'WAVE-MODE' : 'return-delta-only'}, same-model inherit, memory-pack-injected, scope=SOLUTION_ERP repo only)`)
|
||||
|
||||
const results = await parallel(A.taskList.map((t, i) => () => {
|
||||
const raw = t && t.role
|
||||
@ -72,6 +81,26 @@ const results = await parallel(A.taskList.map((t, i) => () => {
|
||||
if (raw && !role) log(`⚠️ hmw: agentType "${raw}" ∉ VALID_ROLES → default subagent cho task #${i}`)
|
||||
|
||||
const mem = role && memoryPack[role] ? memoryPack[role] : ''
|
||||
const subMd = wave ? `${wave.dir}/sub-${role || 'task'}-${i}.md` : null
|
||||
|
||||
// Write-guard TOOL-AWARE theo MODE (B6 isolation). SE read-only sub (KHÔNG Write tool): investigator-codebase/api,
|
||||
// reviewer, cicd-monitor (+ monitor tooling-auditor/harvest-curator). Write sub: implementer-backend/frontend, test-specialist, frontend-designer.
|
||||
const writeGuard = wave
|
||||
? [
|
||||
`## ✍️ WAVE-MODE ghi sub-MD (Harness 2 B4/B6) — TOOL-AWARE (chống mojibake G-009):`,
|
||||
`- Full-detail công-việc của mày → ĐÚNG 1 file: \`${subMd}\` (folder đã scaffold sẵn — KHÔNG tạo folder).`,
|
||||
` • NẾU mày CÓ Write/Edit tool (implementer-backend/frontend, test-specialist, frontend-designer): GHI TRỰC TIẾP via Write/Edit. 🔴 KHÔNG Bash-write MD ($-expansion/mojibake).`,
|
||||
` • NẾU mày CHỈ có Bash (read-only sub: investigator-codebase/api, reviewer, cicd-monitor — KHÔNG Write tool): 🔴 TUYỆT ĐỐI KHÔNG Bash-write MD → để full-detail trong "findings" + đặt subMdPath="${subMd}"; EM MAIN scribe @P3 (single-writer Write-tool, no-corruption).`,
|
||||
`- 🔴 ISOLATION (B6, AUDIT): CHỈ ghi \`${subMd}\` (+ code-file-disjoint nếu task giao). TUYỆT ĐỐI KHÔNG ghi/sửa: agent-memory/* (MEMORY.md BẤT KỲ sub) · MD canonical (CLAUDE/README/STATUS/agents) · sub-MD agent khác. Em main git-status/diff audit sau P2 — tracked-file đổi ngoài code-disjoint = vi-phạm.`,
|
||||
`- LUÔN return: findings (FULL) + checklistEvidence + memoryDelta (4-field) + subMdPath="${subMd}". H2 harvest-curator gom @session-end (B5) → agent-memory/${role || 'sub'}.`,
|
||||
`- 🔴 KHÔNG store_memory/RAG-write · KHÔNG Bash curl/HTTP Qdrant (:6333 = git-diff MÙ, chỉ chunk-count bắt) · KHÔNG ghi file NGOÀI repo/wave-folder. RAG single-writer=em main; containment = git-diff(in-repo)+chunk-count(RAG) [G-015].`,
|
||||
].join('\n')
|
||||
: [
|
||||
`## OUTPUT write-guard (DEFAULT return-delta-only):`,
|
||||
`- ⚠️ KHÔNG ghi ký ức kênh nào: KHÔNG file MEMORY.md, KHÔNG store_memory/RAG-write (Qdrant). CHỈ return memoryDelta → em main VERIFY + APPEND-only @P3 (B3). KHÔNG overwrite file/chunk của sub khác.`,
|
||||
`- ⚠️ Nếu task có WRITE file: CHỈ file-disjoint được giao (em main git-diff verify sau P2). KHÔNG đụng file ngoài phạm vi. Scope = repo SOLUTION_ERP only (S1).`,
|
||||
].join('\n')
|
||||
|
||||
const prompt = [
|
||||
mem ? `## MEMORY-PACK (${role}) — SLICE ký ức tích lũy của sub này, ĐỌC trước khi làm (KHÔNG phải full memory):\n${mem}\n` : '',
|
||||
spec ? `## SPEC / acceptance-criteria (chung):\n${spec}\n` : '',
|
||||
@ -81,9 +110,9 @@ const results = await parallel(A.taskList.map((t, i) => () => {
|
||||
'- findings: kết quả + evidence file:line (KHÔNG narrative suông).',
|
||||
'- checklistEvidence: số đo / verdict cho acceptance-checklist.',
|
||||
'- memoryDelta {task·verdict·learned·surprise}: để EM MAIN harvest @P3.',
|
||||
'⚠️ KHÔNG ghi ký ức kênh nào: KHÔNG file MEMORY.md, KHÔNG store_memory/RAG-write (Qdrant). CHỈ return memoryDelta → em main VERIFY + APPEND-only @P3 (B3). KHÔNG overwrite file/chunk của sub khác.',
|
||||
'⚠️ Nếu task có WRITE file: CHỈ file-disjoint được giao (em main git-diff verify sau P2). KHÔNG đụng file ngoài phạm vi. Scope = repo SOLUTION_ERP only (S1).',
|
||||
].join('\n'),
|
||||
wave ? '- subMdPath: đường-dẫn sub-MD mày đã ghi.' : '',
|
||||
].filter(Boolean).join('\n'),
|
||||
writeGuard,
|
||||
].filter(Boolean).join('\n')
|
||||
|
||||
return agent(prompt, {
|
||||
|
||||
Reference in New Issue
Block a user