A Contributor's Repository Tour#
This chapter connects the concepts in the learning path to the actual repository. It assumes you can edit text files and run commands, but not that you already know Svelte, RDF or the pack generators.
Read Before Editing#
Start with:
- the repository
AGENTS.mdfor working and publication rules; - Repository guide for the maintained architecture;
- the advanced document for the area you are changing;
- nearby tests that state current behaviour.
The worktree may contain another person's unfinished changes. Inspect it and avoid overwriting unrelated edits.
Top-Level Map#
| Path | What lives there |
|---|---|
apps/okf-explorer/ |
Canonical Svelte and TypeScript Explorer |
explorer/ |
Dependency-free compatibility PWA |
docs/ |
Manuals, architecture, evaluation and this learning path |
scripts/ |
Builders, validators, benchmarks and evaluation tools |
profiles/bundle-wiki/v1/ |
Context, schemas, SHACL shapes and profile docs |
profiles/authoring/v1/ |
Domain warm-up and build-handoff schema |
profiles/federation/v1/ |
Overview-first federation and relationship contracts |
registry/ |
Semantic source for public bundle registry projections |
constraints/ |
Machine-readable source constraint ledger |
release-assurance/ |
Hash-bound runtime acceptance and release evidence |
legislation/ |
Generated UK Legislation pack and maintained ontology pages |
uk-government-apis/ |
Generated multi-source API/data pack |
evaluation/ |
Question suites, journeys, rubrics and evidence |
stack/, standards/, federated/, frameworks/, research/ |
Original Markdown research corpus |
glossary/, organisations/, uk-government/, document/ |
Supporting corpus records and indexes |
okf.config.json |
Small-corpus configuration |
okf-bundle.json |
Generated small bundle |
viewer.html, view.html |
Generated or compatibility single-file viewers |
Canonical Explorer Code#
Within apps/okf-explorer/src/:
routes/+page.sveltecoordinates the main application state and views;lib/types.tsdefines shared runtime data shapes;lib/sources/loads, normalises and verifies small and large packs;lib/okfV02.tspresents structured v0.2 trust and lifecycle metadata;lib/sources/federation.tsvalidates overview-first federations;lib/search/defines search clients, static search and retrieval URL state;workers/largeSearch.worker.tsqueries sharded indexes off the main thread;lib/viewer/contains display and inspection logic;- governed-term, relationship-authority, model-enrichment and reconciliation
modules live under
lib/viewer/andlib/sources/; lib/geospatial/classifies spatial evidence and builds bounded previews;lib/legislation/parses official search and CLML structure;- colocated
.test.tsfiles define unit behaviour; tests/ui/contains Playwright journeys.
The main page is large because it coordinates many views. Prefer placing testable rules in focused modules rather than adding every rule directly to the component.
Small-Bundle Path#
The source path is:
Markdown → update_viewer parser → graph
Markdown → build_okf_bundle → okf-bundle.json
okf-bundle.json → smallBundle loader → normalized corpus → views
If you edit corpus Markdown:
- preserve frontmatter and browser-compatible links;
- regenerate the bundle;
- regenerate the legacy viewer;
- inspect warnings for unresolved links;
- run the publication checks.
Do not hand-edit the generated bundle to repair source content.
Large-Corpus Path#
The browser path is:
descriptor
→ large-corpus loader
→ data/search manifests
→ overview
→ worker-backed retrieval
→ compact result
→ selected full record/resources/relationships
The UK API and legislation builders produce related but domain-specific artefacts. Before changing a manifest field:
- find its TypeScript type;
- find the builder output;
- find schema or documented contract;
- find loader and worker use;
- find tests and fixtures;
- preserve old compatible forms where required.
A field rename can cross Python, JSON, TypeScript, worker messages and tests.
Federation Path#
The federation browser path is:
federation descriptor
→ child/source-family overview
→ explicit Load child bundle action
→ declared child descriptor route
→ ordinary small- or large-bundle loader
Do not fetch children during federation overview or imply cross-child record search without a governed federated search index.
Semantic Profile#
The bundle-wiki profile contains:
- a JSON-LD context mapping short terms to IRIs;
- JSON Schemas for JSON representations;
- SHACL shapes for graph validation;
- profile documentation.
The semantic helper:
- parses constrained YAML-LD;
- rejects unsafe or ambiguous representations;
- loads pinned contexts;
- validates schemas;
- expands and compacts JSON-LD.
When a semantic term changes, ask separately:
- Did the human meaning change?
- Did the JSON key change?
- Did its IRI change?
- Did the schema change?
- Did the SHACL shape change?
- Is migration or deprecation metadata needed?
Avoid changing a stable IRI merely to improve a display label.
Authoring And Release Profiles#
The authoring profile freezes domain research decisions before implementation. The federation profile defines cross-publication discovery. Release-assurance artefacts bind the tested browser build and corpus bytes.
When changing one of these contracts:
- update the machine schema;
- update its template and human profile;
- update validators and positive/negative fixtures;
- update TypeScript consumer types where applicable;
- test backward compatibility;
- update runtime or release receipts that consume the contract;
- document whether the change affects OKF core or only an additive profile.
Change Recipe: A Documentation Correction#
- Edit the authoritative Markdown.
- Check links and terminology against nearby documents.
- If the file belongs to the OKF corpus, rebuild bundle and viewer.
- Run the four required publication checks.
- Inspect generated differences for unrelated churn.
Change Recipe: A New Record Field#
- Define the user question the field answers.
- Name source authority and missing-value behaviour.
- Decide whether it is canonical record data, generated analysis or presentation.
- Add builder output.
- Add schema/type support.
- Add loader normalisation.
- Add display only where it helps a user task.
- Add unit and browser coverage.
- Document standards mapping and provenance.
- Rebuild and validate affected packs.
Change Recipe: A Search Feature#
- Decide whether it is candidate search, a hard filter, ranking, faceting or context assembly.
- Update the manifest contract if new index data is needed.
- Build deterministic shards and integrity metadata.
- update request and response types;
- implement worker logic within bounded budgets;
- expose match and truncation explanations;
- round-trip meaningful state through the URL;
- add unit, benchmark and browser tests;
- evaluate against real questions.
Do not hide a hard filter inside a ranking score.
Change Recipe: A New Graph Relationship#
- Identify source and target with stable IDs.
- Define direction and a human label.
- Prefer a canonical predicate IRI where governed.
- record assertion status, evidence and observation time;
- distinguish count, strength and confidence;
- update builder and relationship indexes;
- verify incoming and outgoing inspection;
- verify grouping by predicate and compatibility label;
- document any inference rule.
Screen placement is not part of the semantic definition.
Change Recipe: A New External Preview#
- Require a deliberate user action.
- define supported schemes, formats and CORS expectations;
- sanitise credential-like URL fields;
- cap response bytes and parsed complexity;
- avoid automatic proxying or private-network probing;
- preserve the original source and local metadata;
- design error and recovery states;
- test success, failure, keyboard and responsive interaction;
- record source terms and licence constraints.
Finding The Relevant Code#
Use fast text search for:
- a UI label;
- a schema name such as
okf-static-search.v2; - a JSON field;
- a type name;
- the error message shown to the user.
Then inspect both production use and tests. Similar terms can occur in the canonical app, the compatibility PWA and generated single-file viewer; confirm which surface owns the behaviour.
Testing In Proportion To Risk#
| Change | Minimum useful evidence |
|---|---|
| Prose only | Link review and publication checks |
| Small-bundle parsing | Python checks plus loader/unit tests |
| Component display | Svelte check and focused unit test |
| User interaction or URL state | Unit plus Playwright journey |
| Search index contract | Builder check, worker tests, benchmark and question evaluation |
| External fetch | Unit bounds, failure states and browser test |
| Semantic profile | JSON Schema, JSON-LD and SHACL validation |
| Federation contract | Schema, fallback, bounds and explicit-load browser tests |
| Authoring profile | Domain-profile schema, cross-reference and equivalence tests |
| Release assurance | Determinism, build-manifest, SBOM and runtime-receipt checks |
| Legislation generator | Corpus completeness and domain evaluation |
Run broader checks when a shared contract changes.
Generated Output Review#
After regeneration, inspect:
- file count;
- unexpectedly large changes;
- counts and snapshot identifiers;
- order stability;
- missing or new warnings;
- hash and manifest changes;
- forbidden temporary files.
A successful command is not enough if it generated the wrong scope.
First Contribution Ideas#
Good learning tasks have a small evidence boundary:
- clarify an advanced paragraph and link it from the beginner glossary;
- add a focused test for a documented edge case;
- improve a user-facing error without changing the data contract;
- add provenance to a value whose source is already known;
- document a fixture and the live behaviour it represents.
Avoid making a first change that simultaneously redesigns the semantic profile, large search contract and main page state.
Last Check#
Before handing off a change, be able to say:
- what source of truth changed;
- which generated artefacts were refreshed;
- what compatibility boundary was preserved;
- which checks passed;
- what remains uncertain or intentionally out of scope.
For documentation, follow the repository
British-English and plain-English guidance and
run uv run --locked python scripts/check_british_english.py. For semantic changes,
check the canonical semantic-authoring and rollout ledger
before describing implementation, review, release, deployment or public
verification state.
Next#
Use the Beginner glossary as a quick reference, read chapters 17 through 20 for the current v0.2, federation, Foundry and assurance contracts, then continue with the advanced document for your contribution area.