{
  "schema_version": "1.0",
  "baseline": "A-document-management-closeout-v1",
  "phase": "Batch 9 · closeout wave",
  "updated_at": "2026-04-20",
  "owner": "session_a",
  "purpose_en": "Aggregate backlog model: rules for combining per-document note stores (localStorage keys ds.notes:*) into a single cross-document view, plus filter/sort semantics used by document-note-backlog.html.",
  "purpose_th": "โมเดล backlog รวม · รวมโน้ตจาก localStorage ของทุกหน้า (ds.notes:*) · กฎ filter/sort ที่หน้ารวมใช้",
  "honest_state": "Backend for notes is still BROWSER-LOCAL. Aggregate view reads the current browser's localStorage only. Cross-browser / cross-device merge is NOT implemented.",
  "aggregation_rules": {
    "source": "localStorage keys matching prefix 'ds.notes:'",
    "doc_id_resolution": "Strip the 'ds.notes:' prefix from each key to recover doc_id",
    "per_doc_fields_preserved": [
      "note_id", "doc_id", "section_ref", "created_at", "created_by_type",
      "title", "body", "note_type", "priority", "status",
      "resolved_flag", "linked_change_ref", "resolved_at", "last_action_at"
    ],
    "derived_fields": {
      "group_id":          "Looked up from document-shell-coverage.json · 'unknown' when doc not in registry",
      "doc_title_en":      "Looked up from document-metadata-registry.json",
      "doc_title_th":      "Looked up from document-metadata-registry.json",
      "stakeholder_tags":  "Looked up from document-metadata-registry.json · empty when unknown"
    }
  },
  "filters": [
    { "id": "doc",        "label_en": "Document", "label_th": "เอกสาร", "kind": "select" },
    { "id": "group",      "label_en": "Group",    "label_th": "กลุ่ม",  "kind": "select", "values": ["start", "knowledge", "planning", "runtime", "operations", "journey"] },
    { "id": "status",     "label_en": "Status",   "label_th": "สถานะ",  "kind": "multi",  "values": ["open", "triaged", "in_review", "planned", "in_progress", "done", "deferred", "rejected"] },
    { "id": "priority",   "label_en": "Priority", "label_th": "ลำดับ",  "kind": "multi",  "values": ["P0", "P1", "P2", "P3"] },
    { "id": "note_type",  "label_en": "Type",     "label_th": "ประเภท", "kind": "multi",  "values": ["requirement", "enhancement", "bug", "content-gap", "structure", "linkage", "metadata", "glossary", "references", "export", "design", "runtime-mismatch"] },
    { "id": "stakeholder","label_en": "Stakeholder", "label_th": "Stakeholder", "kind": "multi", "note": "Matches against doc's stakeholder_tags from metadata registry" },
    { "id": "text",       "label_en": "Search text", "label_th": "ค้นหาข้อความ", "kind": "input" }
  ],
  "sort_orders": [
    { "id": "newest",     "label_en": "Newest first (created_at desc)", "label_th": "ใหม่สุดก่อน" },
    { "id": "oldest",     "label_en": "Oldest first (created_at asc)",  "label_th": "เก่าสุดก่อน" },
    { "id": "priority",   "label_en": "By priority (P0 first)",         "label_th": "ตามลำดับ" },
    { "id": "activity",   "label_en": "By last activity (desc)",        "label_th": "กิจกรรมล่าสุด" }
  ],
  "summaries": {
    "top_level_counters": [
      { "id": "total",     "label_en": "Total",    "label_th": "ทั้งหมด" },
      { "id": "open",      "label_en": "Open",     "label_th": "เปิด" },
      { "id": "done",      "label_en": "Done",     "label_th": "เสร็จ" },
      { "id": "deferred",  "label_en": "Deferred", "label_th": "เลื่อน" },
      { "id": "p0_open",   "label_en": "P0 open",  "label_th": "P0 ค้าง" }
    ],
    "top_documents_by_open_count": "sort docs by number of open notes · show top 5",
    "recent_activity": "notes with last_action_at within 24h · sorted desc"
  },
  "open_item_definition": "status in ('open','triaged','in_review','planned','in_progress')",
  "done_item_definition": "status in ('done','rejected')",
  "deferred_item_definition": "status = 'deferred'",
  "honest_limits": [
    "Browser-scoped. Aggregate reflects this browser only · not a server roll-up.",
    "No sync across devices.",
    "No user attribution beyond created_by_type (no real identity).",
    "Theme clustering (C-05 from sweep model) is not implemented in this wave.",
    "No export to CSV yet."
  ],
  "planned_upgrades": [
    "Server-side persistence of notes · Batch 10+",
    "Bulk export to CSV / JSON",
    "Theme clustering (NLP) over titles + bodies",
    "AI sweep automation consuming document_note_sweep_model.json"
  ],
  "cross_references": {
    "note_schema":       "docs/assets/notes/document_note_schema.json",
    "note_status_matrix":"docs/assets/notes/document_note_status_matrix.json",
    "note_sweep_model":  "docs/assets/notes/document_note_sweep_model.json",
    "note_examples":     "docs/assets/notes/document_note_examples.json",
    "aggregate_examples":"docs/assets/notes/document_note_aggregate_examples.json",
    "coverage":          "docs/assets/document-shell-coverage.json",
    "metadata_registry": "docs/assets/document-metadata-registry.json",
    "backlog_ui":        "docs/planning/document-note-backlog.html"
  }
}
