Files
kebab/docs/wire-schema/v1/fetch_result.schema.json
th-kim0823 b86b763dfb fix(fb-35): address PR #126 round 2 review
- wire schema: relax effective_end.minimum 1 → 0 + expand
  description to cover line-clamp + out-of-range sentinel
  (panic-fix R1 emits Some(0) when line_start=1 and range is
  beyond doc end — schema must accept it)
- tests: tighten first-chunk-target boundary test to assert ≤ 2
  total neighbors (3-chunk doc, N=2). Strict "first chunk →
  context_before empty" not assertable until chunks.ordinal
  column lands (R1 #9 architectural caveat)
- store: trim contradiction in list_chunk_ids_for_doc warning
  comment — drop "good enough for sequentially chunked
  markdown" phrase that conflicts with "hash sort dominates"
  paragraph above

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-10 00:55:29 +09:00

25 lines
2.3 KiB
JSON

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://kb.local/wire/v1/fetch_result.schema.json",
"title": "FetchResult v1",
"description": "Verbatim text fetch from the indexed corpus. Discriminated by `kind`. All text is normalized markdown sourced from `CanonicalDocument` / `chunks.text` — original raw bytes are not exposed. PDF / audio span fetch returns `error.v1.code = span_not_supported`.",
"type": "object",
"required": ["schema_version", "kind", "doc_id", "doc_path", "indexed_at", "stale", "truncated"],
"properties": {
"schema_version": { "const": "fetch_result.v1" },
"kind": { "enum": ["chunk", "doc", "span"] },
"doc_id": { "type": "string" },
"doc_path": { "type": "string" },
"indexed_at": { "type": "string", "format": "date-time", "description": "fb-32 documents.updated_at" },
"stale": { "type": "boolean", "description": "fb-32 staleness flag against config.search.stale_threshold_days" },
"chunk": { "type": "object", "description": "kind=chunk: target chunk_inspection.v1 payload" },
"context_before": { "type": "array", "description": "kind=chunk: --context N preceding chunks (ordinal-sorted)" },
"context_after": { "type": "array", "description": "kind=chunk: --context N following chunks (ordinal-sorted)" },
"text": { "type": "string", "description": "kind=doc/span: markdown text (truncated if budget tripped)" },
"line_start": { "type": ["integer", "null"], "minimum": 1, "description": "kind=span: requested start line (1-based)" },
"line_end": { "type": ["integer", "null"], "minimum": 1, "description": "kind=span: requested end line (1-based, inclusive)" },
"effective_end": { "type": ["integer", "null"], "minimum": 0, "description": "kind=span: actual end line of emitted text (1-based, inclusive). Equals `line_end` on full slice; less than `line_end` when (a) requested range exceeded total lines (line clamp) or (b) `--max-tokens` budget trimmed the tail. Special case: `line_start - 1` (which is 0 when line_start=1) signals the entire requested range was beyond doc end — returned `text` is empty." },
"truncated": { "type": "boolean", "description": "kind=doc/span: budget forced text truncation. Always false for chunk." }
}
}