-
Notifications
You must be signed in to change notification settings - Fork 7
Add FileExtraction ontology schema #1110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| { | ||
| "$schema": "http://json-schema.org/draft-07/schema#", | ||
| "schemaId": "3d5b71e2-9c84-4a16-b0f3-6e28d95a7c41", | ||
| "title": "FileExtraction", | ||
| "type": "object", | ||
| "description": "What a machine made of a file — the text read off a photo, the transcript of a recording, the body of a document, or a set of observations about what an image shows. It exists as its own record because the File ontology is closed and has no field for extracted content, and because a reading has provenance of its own: which model produced it, how confidently, and when. The same file may be read more than once, by different models or at different times, and each reading is a separate record rather than an overwrite — a later reading does not make an earlier one untrue about what was believed then. A FileExtraction is always DERIVED: it is evidence about the file, never a fact about the world, and anything asserted on its basis should reference it.", | ||
| "properties": { | ||
| "id": { "type": "string", "description": "Stable identifier for this reading" }, | ||
| "kind": { | ||
| "type": "string", | ||
| "enum": ["ocr", "transcript", "vision", "extraction"], | ||
| "description": "How the file was read: text visible in an image (ocr), speech turned to text (transcript), what a picture depicts (vision), or content parsed out of a structured document (extraction)" | ||
| }, | ||
| "text": { | ||
| "type": ["string", "null"], | ||
| "description": "The content verbatim, when the reading IS text — OCR output, a transcript, a document body. Never a summary: the words themselves are what cannot be recovered later without paying to read the file again. Null when the reading is not text." | ||
| }, | ||
| "observations": { | ||
| "type": "array", | ||
| "description": "What the reading claims about the file's contents. One file yields many: a street photo carries a car, a road surface, shop signs, traffic signs, weather, a city. Modelled on schema.org/Observation.", | ||
| "items": { | ||
| "type": "object", | ||
| "properties": { | ||
| "measuredProperty": { "type": "string", "description": "What is being observed, using an established schema.org property name wherever one exists (vehicle, brand, contentLocation, numberOfFloors). A coined name is acceptable when nothing established fits, but must then be reused rather than re-invented — a synonym makes both observations uncountable." }, | ||
| "observationAbout": { "type": "string", "description": "The THING observed, identified as briefly and stably as it can be — its eName where it has one, otherwise the plain name one would use for it anywhere else ('Finish', 'Utrecht', 'Renault Kangoo'). Never a phrase describing where it appears and never a filename: the reading is already linked to its file, and a locator that changes with every file makes the same thing uncountable, which is the one thing this field exists to prevent." }, | ||
| "valueText": { "type": "string", "description": "What the reading would say about it in words, kept verbatim alongside the reference. A reference can resolve to the wrong thing, and these words are how anyone notices." }, | ||
| "confidence": { "type": "number", "minimum": 0, "maximum": 1, "description": "How sure the model is of THIS observation. Per-observation, not per-reading: a photo can show an unmistakable traffic sign and a barely legible shop front." } | ||
| }, | ||
| "required": ["measuredProperty", "confidence"] | ||
| } | ||
| }, | ||
| "fileRef": { | ||
| "type": "string", | ||
| "description": "The file this reading was made from, as its `w3ds://` URI. A reading that pointed at nothing would be a claim about a file the vault does not have, so this is what makes the record meaningful at all — and what lets a reader fetch the bytes and disagree with the reading." | ||
| }, | ||
|
Comment on lines
+32
to
+35
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win Validate the
Proposed constraint "fileRef": {
"type": "string",
+ "format": "uri",
+ "pattern": "^w3ds://",
"description": "The file this reading was made from, as its `w3ds://` URI. A reading that pointed at nothing would be a claim about a file the vault does not have, so this is what makes the record meaningful at all — and what lets a reader fetch the bytes and disagree with the reading."
},🤖 Prompt for AI Agents |
||
| "derivedFrom": { | ||
| "type": ["string", "null"], | ||
| "description": "Envelope id of the record this reading was made in the course of capturing — typically the PersonalNote the file was attached to. Null when the file was read on its own. The inverse of PersonalNote.derivedRecords." | ||
| }, | ||
| "language": { "type": "string", "description": "BCP-47 language of `text`, when it is text" }, | ||
| "model": { "type": "string", "description": "Which model produced this reading. Without it a stale or discredited reading cannot be found and revisited." }, | ||
| "readAt": { "type": "string", "format": "date-time", "description": "When the file was read, which is not when the file was made" }, | ||
| "capturedBy": { "type": "string", "description": "eName of the application that performed the reading" }, | ||
|
Comment on lines
+41
to
+43
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win Require or explicitly model missing provenance. The Proposed required fields- "required": ["id", "kind", "readAt", "fileRef"],
+ "required": ["id", "kind", "readAt", "fileRef", "model", "capturedBy"],Also applies to: 46-46 🤖 Prompt for AI Agents |
||
| "isArchived": { "type": "boolean", "default": false } | ||
| }, | ||
| "required": ["id", "kind", "readAt", "fileRef"], | ||
|
Comment on lines
+44
to
+46
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -eu
file="services/ontology/schemas/fileExtraction.json"
printf '%s\n' '--- schema ---'
cat -n "$file"
printf '%s\n' '--- related references ---'
rg -n --glob '!node_modules' --glob '!dist' --glob '!build' 'fileExtraction|FileExtraction|isArchived' .
printf '%s\n' '--- schema inventory and nearby documentation ---'
git ls-files 'services/ontology' | sed -n '1,160p'Repository: MetaState-Prototype-Project/prototype Length of output: 28051 🏁 Script executed: #!/bin/bash
set -eu
file="services/ontology/schemas/fileExtraction.json"
printf '%s\n' '--- schema ---'
cat -n "$file"
printf '%s\n' '--- related references ---'
rg -n --glob '!node_modules' --glob '!dist' --glob '!build' 'fileExtraction|FileExtraction|isArchived' .
printf '%s\n' '--- schema inventory ---'
git ls-files 'services/ontology'Repository: MetaState-Prototype-Project/prototype Length of output: 28026 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- ontology loader ---'
cat -n services/ontology/src/index.js
printf '%s\n' '--- ontology package metadata ---'
cat -n services/ontology/package.json
printf '%s\n' '--- analogous archival fields ---'
for f in services/ontology/schemas/communityActivity.json services/ontology/schemas/bookmark.json services/ontology/schemas/file.json; do
printf '\n--- %s ---\n' "$f"
rg -n -C 4 '"isArchived"|"required"|default' "$f"
done
printf '%s\n' '--- documentation mentioning FileExtraction or archival state ---'
rg -n -i --glob '!node_modules' --glob '!dist' --glob '!build' 'FileExtraction|file extraction|isArchived|archiv' docs services/ontology README.md 2>/dev/null || true
printf '%s\n' '--- minimal Draft-07 default behavior probe ---'
python3 - <<'PY'
import json
from pathlib import Path
schema = json.loads(Path("services/ontology/schemas/fileExtraction.json").read_text())
instance = {
"id": "x",
"kind": "ocr",
"readAt": "2026-01-01T00:00:00Z",
"fileRef": "w3ds://file/x",
}
before = json.dumps(instance, sort_keys=True)
required = set(schema["required"])
properties = schema["properties"]
valid_required = required <= instance.keys()
default = properties["isArchived"].get("default")
after = json.dumps(instance, sort_keys=True)
print("required_contains_isArchived:", "isArchived" in required)
print("missing_isArchived_satisfies_required:", "isArchived" in instance or "isArchived" not in required)
print("declared_default:", default)
print("instance_before:", before)
print("instance_after:", after)
print("default_materialized:", "isArchived" in instance)
PYRepository: MetaState-Prototype-Project/prototype Length of output: 11254 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- ontology loader ---'
cat -n services/ontology/src/index.js
printf '%s\n' '--- ontology package metadata ---'
cat -n services/ontology/package.json
printf '%s\n' '--- analogous archival fields ---'
for f in services/ontology/schemas/communityActivity.json services/ontology/schemas/bookmark.json services/ontology/schemas/file.json; do
printf '\n--- %s ---\n' "$f"
rg -n -C 4 '"isArchived"|"required"|default' "$f"
done
printf '%s\n' '--- documentation mentioning FileExtraction or archival state ---'
rg -n -i --glob '!node_modules' --glob '!dist' --glob '!build' 'FileExtraction|file extraction|isArchived|archiv' docs services/ontology README.md 2>/dev/null || true
printf '%s\n' '--- minimal Draft-07 default behavior probe ---'
python3 - <<'PY'
import json
from pathlib import Path
schema = json.loads(Path("services/ontology/schemas/fileExtraction.json").read_text())
instance = {
"id": "x",
"kind": "ocr",
"readAt": "2026-01-01T00:00:00Z",
"fileRef": "w3ds://file/x",
}
before = json.dumps(instance, sort_keys=True)
required = set(schema["required"])
properties = schema["properties"]
default = properties["isArchived"].get("default")
after = json.dumps(instance, sort_keys=True)
print("required_contains_isArchived:", "isArchived" in required)
print("missing_isArchived_satisfies_required:", "isArchived" in instance or "isArchived" not in required)
print("declared_default:", default)
print("instance_before:", before)
print("instance_after:", after)
print("default_materialized:", "isArchived" in instance)
PYRepository: MetaState-Prototype-Project/prototype Length of output: 11254 Materialize 🤖 Prompt for AI AgentsSource: MCP tools |
||
| "additionalProperties": true | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: MetaState-Prototype-Project/prototype
Length of output: 8401
🏁 Script executed:
Repository: MetaState-Prototype-Project/prototype
Length of output: 25144
🏁 Script executed:
Repository: MetaState-Prototype-Project/prototype
Length of output: 50394
🏁 Script executed:
Repository: MetaState-Prototype-Project/prototype
Length of output: 26348
Enforce the
kindpayload matrix.The schema accepts
kind: "ocr"withtext: nullandkind: "vision"with a stringtext. Add draft-07if/thenoroneOfbranches that enforce the agreed relationship betweenkind,text, andobservations.🤖 Prompt for AI Agents
Source: MCP tools