Skip to content

Write a pack

A pack is a YAML file that tells Analects about a domain: its entity types, their properties and edges, how to tell two mentions apart, what every entity should have, and where new members show up. The engine knows nothing about data centres or politicians — the packs do.

my-domain@0.1/
  pack.yaml        # types, properties, edges, identity, expectations, channels, fixtures
  FINDINGS.md      # what real sources forced, with links to the decisions

Start one with analects schema new. It writes a working pack into your project's packs/ folder, beside the packs Analects ships with (D68b):

analects schema new my-domain --type facility --about "Every facility in the region."
analects schema test             # your packs load, with what they import; fixtures hold
analects schema show facility    # what analects understood
analects init --pack my-domain@0.1 --title "…" --about "…"   # this graph is built on it (D68)

Every block of the new file says what to change. Change it a block at a time, running analects schema test after each. A pack in your packs/ with the same name as a shipped pack stands in for it. ANALECTS_PACKS names one folder to use instead.

The parts

pack: my-domain
version: "0.1"
imports: [_shared@0.1]          # organisation, person_base and the source types
entities:
  facility:
    identity:
      external_ids: [registry_id]          # an id that settles identity outright
      name_fields: [name, aliases]
      blocking: {any_of: [[country]]}      # only compare within a country
      discriminators: [country, registry_id]   # differ here: never the same
      create_requires: {any_of: [[external_id], [prop: country, prop: operator]]}
    properties:
      name:      {type: string, value_shape: point, temporal: static, required: true}
      capacity:  {type: number, unit: MW, value_shape: point_with_range, temporal: valid_range}
      status:    {type: enum, values: [proposed, built, closed], temporal: valid_range, max_age: 180}
    edges:
      operator:  {to: organisation, evidence_policy: required, temporal: valid_range}
    expectations:
      - {rule: required_when, property: capacity, when: "status in [built]", severity: 2}
    discovery:
      - name: national-register
        kind: register
        how: "the national register of facilities, searched by {counties}"
        cadence_days: 30
        playbook: |
          How to work this source, step by step.
        traps: ["What goes wrong with it."]
        evidence: "official_record: the register's own page."
fixtures:
  - a: {name: "Example Facility Ltd", country: GB}
    b: {name: "Example Facility", country: GB}
    expect: match
    layer: alias
  • Properties have a type, a shape (a point, a range, or both) and a temporal kind: static (a name), valid_range (holds over an interval), period (about one period), event (happened on a date). multi: true makes a set.
  • Identity is what keeps the graph honest: external ids match outright, discriminators keep look-alikes apart, and anything the resolver is unsure of is a question for a person.
  • Expectations say what every entity should have, and power analects gaps.
  • Discovery channels are where members show up; a scope instantiates them, and a sweep brief quotes their playbook and traps to the researcher.
  • Fixtures are pairs the resolver must match or keep apart; analects schema test runs them.

The format's every key is documented at the top of _shared@0.1/pack.yaml; the packs reference summarises it.