Discovery Index Format: draft notes

wiki

Version: 0.0.1-notes · Date: 2026-11-30 · Companion to the PublicTxt Format Specification 0.1

Defines the files in an Index Repository so that any aggregator can write one and any client can read and merge several. Markers follow the main spec: [D] decided, [P] proposed, [O] open.

Status: notes, not yet a spec. Nothing here is decided.

1. Goals and non-goals

Goals:

  • Clone an index repo and find repos, resources and tags with no server.
  • Merge many index repos deterministically.
  • Readable diffs: one snapshot commit shows what changed.
  • Reuse the main spec’s Document model (§10) and resource_id (§8.2). No second vocabulary.

Non-goals (v0):

  • Full text or page bodies.
  • Search ranking.
  • Real-time updates (that’s the aggregator’s API, not the repo).

2. Layout

[P]

publictxt-index.yaml        # manifest: marks this as an index repo
trust.yaml                  # inclusion + federation (§6)
repos/<host>/<owner>/<repo>.json      # one file per indexed content repo (§4)
resources/<xx>.jsonl        # resource records, sharded by first 2 hex chars of resource_id (§5)
tags.jsonl                  # optional: tag → counts summary (§7)

Why this shape:

  • Repos as one file each: a fetch of one repo touches one file, and opting out deletes one file.
  • Resources sharded into 256 JSONL files: bounded file count, one line per resource, so line-level diffs work.
  • [O] JSONL shards vs one JSON file per resource. Per-file gives cleaner diffs but 100k+ files hurt Git. Measure in the spike.

3. Manifest: publictxt-index.yaml

[P]

publictxt-index: "0.1"          # required: index format version
publisher:
  name: Jaysen's index          # required
  contact: https://…            # optional
  repo: https://github.com/jaysen/publictxt-index   # self URL
spec: "0.1"                     # PublicTxt spec version used to read sources
normalize: "v0"                 # resource_id normalisation version (main spec §8.2)
generated_at: 2026-11-30T21:00:00+02:00
generator: publictxt-aggregator/0.1.0
  • The presence of this file is what makes a repo an index repo (and exempt from ADR-0003).
  • normalize matters: consumers MUST NOT merge resources across index repos with different normalize versions without recomputing.

4. Repo records: repos/<host>/<owner>/<repo>.json

[P] One record per indexed content repo. The path is derived from the canonical repo URL ([O] main spec §13.2).

{
  "url": "https://github.com/jaysen/notes",
  "kind": "publictxt",
  "inclusion": "opt-in",
  "author": "Jaysen",
  "spec": "0.1",
  "head": "3f2a9c1…",
  "head_at": "2026-11-30T18:12:04+02:00",
  "fetched_at": "2026-11-30T20:55:00+02:00",
  "licence": "CC-BY-SA-4.0",
  "documents": 412,
  "bookmarks": 187,
  "tags": [{ "match": "dotnet", "count": 34 }],
  "diagnostics": []
}
  • kind: publictxt | agora | … (the source adapter used).
  • inclusion: opt-in | trusted | via:<index repo url> (inherited through federation).
  • head + head_at + fetched_at are the staleness stamps: what was indexed, and when it was checked.
  • [O] Include a per-document list (path, type, title, tags)? It’s useful for search but multiplies size. Leaning: yes, but in a separate docs/ tree, added later.

5. Resource records: resources/<xx>.jsonl

[P] One line per resource_id, sorted by resource_id. It merges every indexed document that bookmarks the resource.

{"resource_id":"sha256:ab12…","url":"https://example.com/a","seen":[{"repo":"https://github.com/jaysen/notes","path":"metaweb/example.com/a.md","title":"Example A","tags":["reading","dotnet"],"date":"2026-10-13","head":"3f2a9c1…"}],"tags":[{"match":"dotnet","repos":2},{"match":"reading","repos":1}]}
  • url is the normalised URL (the hash input), not each author’s raw value.
  • seen[] is sorted by repo then path. tags are match forms (spec §7.3); raw forms stay in the content repos.
  • tags[].repos counts distinct repos, not documents. One author tagging twice shouldn’t look like consensus.
  • Co-occurrence and emergent tags are derived by consumers from seen[]; they’re not stored.

6. Trust and federation: trust.yaml

[P]

repos:                          # content repos included without an explicit opt-in
  - url: https://github.com/example/garden
    kind: agora
indexes:                        # other index repos this publisher follows
  - url: https://github.com/someone/publictxt-index
    hops: 1                     # 0 = use their records, don't follow their trust list
    inherit: repos              # repos | none
deny:                           # repos never included, even if inherited
  - url: https://github.com/spam/repo
  • Inherited repos are recorded with inclusion: via:<index url>, so provenance is visible.
  • deny always wins.
  • [O] Hop limit default (1 or 2), and whether hops is a cap set by the follower, the followed, or both.

7. Tag summary: tags.jsonl (optional)

[P] {"match":"dotnet","repos":12,"resources":340}, sorted by match. A convenience for clients; fully recomputable.

8. Determinism

[P] Required for “no change, no commit” and for clean diffs:

  • UTF-8, LF, no BOM, final newline.
  • JSON object keys in a fixed order (as listed in this doc); no insignificant whitespace in JSONL; 2-space indent in .json.
  • All arrays sorted as specified.
  • generated_at changes on every run, so the manifest is only rewritten when another file changes.

9. Merging several index repos (consumers)

[P]

  • Repos: key on canonical URL. The record with the newer head_at wins; on a tie, the newer fetched_at.
  • Resources: key on resource_id (same normalize only). Union seen[] by (repo, path), taking each entry from the winning repo record above.
  • Recompute tags[].repos after the union. Never sum counts across indexes, because that double-counts shared repos.

[P]

  • An index MUST NOT include a repo that carries an opt-out flag ([O] its format: spec/consent-and-trust.md).
  • An index MUST drop a repo’s records in the first snapshot after it sees an opt-out.
  • Only metadata, links and tags. No document bodies in v0.

11. Versioning

[P] SemVer on publictxt-index. Readers SHOULD skip index repos with an unsupported major version and report it.

12. Open questions

  1. JSONL shards vs a file per resource (§2): measure at 10k and 100k resources.
  2. Per-document records (§4).
  3. Canonical repo URL: blocked on main spec §13.2.
  4. Hop-limit semantics (§6).
  5. Opt-out flag format.
  6. History growth and squashing (see Index Repository).
  7. Signing index commits.
  8. Non-bookmark discovery: index wiki pages and notes by tag too?
  9. Do Agora and other kinds map cleanly to the Document model, or do they need an extension block?