{
  "schema_version": "1.0",
  "baseline": "A-search-log-v1",
  "updated_at": "2026-04-19",
  "owner": "session_a",
  "honest_note": "This file is the SCHEMA + SEED for the search log · the actual log is stored CLIENT-SIDE in localStorage (key `pty-search-log`). No server-side persistence. If a user opens the portal on a different device/browser or clears site data, history is lost. The viewer page reads from localStorage first and falls back to `seed` for demo/empty-state rendering.",

  "storage": {
    "mechanism": "browser localStorage",
    "key": "pty-search-log",
    "cap_entries": 200,
    "eviction": "FIFO · oldest entry dropped when cap reached",
    "scope": "per-browser · per-origin · no cross-device sync"
  },

  "event_schema": {
    "id":              {"type": "string", "description": "client-generated uuid-ish id · unique per event"},
    "ts":              {"type": "string", "description": "ISO-8601 timestamp of the search event"},
    "search_type":     {"type": "enum", "values": ["title", "fulltext", "combined", "none"], "description": "which box(es) had content at event time"},
    "query_title":     {"type": "string", "description": "raw title query string · may be empty"},
    "query_fulltext":  {"type": "string", "description": "raw full-text query string · may be empty"},
    "result_count":    {"type": "integer", "description": "number of entries visible in the All tab at event time"},
    "filters_used":    {"type": "object", "description": "active filter values: owner · status · phase · type · surface · omitted if empty"},
    "source_page":     {"type": "string", "values": ["index-portal", "console"], "description": "where the search originated"},
    "clicked":         {
      "type": "object|null",
      "description": "set on the FIRST click into a result after this search event · null if the search was never clicked",
      "fields": {
        "ts":        "ISO-8601 of the click",
        "path":      "target path of clicked entry",
        "index_no":  "index number of clicked entry",
        "title":     "title of clicked entry"
      }
    }
  },

  "event_types": {
    "search": "fired on input event (debounced 400ms) OR on Enter key in either search input",
    "click":  "fired on anchor click within the results list · attaches to the most-recent `search` event in the same session",
    "noop":   "if both boxes are empty, NO event is recorded (we do not pollute the log with ambient state)"
  },

  "redaction_policy": {
    "user_ids":   "portal does not know any user id · nothing to redact",
    "pii":        "query strings are passed through verbatim · operators should NOT type PII here · browser-local only",
    "export":     "the viewer page offers `Export JSON` to copy the current log · ephemeral client action"
  },

  "viewer_features": [
    "latest searches with timestamp + count + query summary",
    "no-result filter (result_count === 0)",
    "clicked-only filter (events with a non-null click)",
    "per-search-type filter (title · fulltext · combined)",
    "re-run a logged search (loads ?q= and ?ft= into Index Portal)",
    "open the clicked destination directly",
    "clear log button (confirm dialog)",
    "export to JSON"
  ],

  "example_event_clicked": {
    "id": "sl-1745024000123-x7a2",
    "ts": "2026-04-19T07:00:00.000Z",
    "search_type": "combined",
    "query_title": "feature flags",
    "query_fulltext": "fastapi",
    "result_count": 2,
    "filters_used": {"owner": "A"},
    "source_page": "index-portal",
    "clicked": {
      "ts": "2026-04-19T07:00:08.211Z",
      "path": "/runtime/feature-flags-service/",
      "index_no": "04.01.09.00",
      "title": "FF · Service (Phase 2a+)"
    }
  },

  "example_event_no_result": {
    "id": "sl-1745024100987-m4q9",
    "ts": "2026-04-19T07:05:00.000Z",
    "search_type": "title",
    "query_title": "unicorn launcher",
    "query_fulltext": "",
    "result_count": 0,
    "filters_used": {},
    "source_page": "index-portal",
    "clicked": null
  },

  "seed": [
    {
      "id": "sl-seed-0001",
      "ts": "2026-04-19T00:00:00.000Z",
      "search_type": "title",
      "query_title": "evaluator service",
      "query_fulltext": "",
      "result_count": 4,
      "filters_used": {},
      "source_page": "index-portal",
      "clicked": {
        "ts": "2026-04-19T00:00:05.000Z",
        "path": "/runtime/feature-flags-service/",
        "index_no": "04.01.09.00",
        "title": "FF · Service (Phase 2a+)"
      }
    },
    {
      "id": "sl-seed-0002",
      "ts": "2026-04-19T00:01:00.000Z",
      "search_type": "fulltext",
      "query_title": "",
      "query_fulltext": "policy engine",
      "result_count": 23,
      "filters_used": {},
      "source_page": "index-portal",
      "clicked": null
    },
    {
      "id": "sl-seed-0003",
      "ts": "2026-04-19T00:02:00.000Z",
      "search_type": "combined",
      "query_title": "runtime",
      "query_fulltext": "fastapi",
      "result_count": 2,
      "filters_used": {"owner": "A"},
      "source_page": "index-portal",
      "clicked": {
        "ts": "2026-04-19T00:02:10.000Z",
        "path": "/runtime/feature-flags-service/service.html",
        "index_no": "04.01.09.02",
        "title": "FF Service · Debug (service.html)"
      }
    },
    {
      "id": "sl-seed-0004",
      "ts": "2026-04-19T00:03:00.000Z",
      "search_type": "title",
      "query_title": "unicorn",
      "query_fulltext": "",
      "result_count": 0,
      "filters_used": {},
      "source_page": "index-portal",
      "clicked": null
    }
  ]
}
