List unlinked places and unmapped words under Sources, fix them in code with the unmapped skill

Settings > Sources > Unmapped shows the place texts no place resolves, with
their roles' countries and companies, and the host words no table maps, and
copies both as text. Prep fingerprints places.seed(), so a town or spelling
added to the code is seeded and every open role is mapped again at the next
prep. app prep unlinked lists the places on the command line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-09-30 13:06:22 +02:00
1 parent ae978594b4
commit 06ff9f549b
13 files changed
+313 -43

No files matched your search

+13 -8
View File
@@ -4,9 +4,11 @@ A pull stores the host's own words and place texts (`Store.upsert_role`)
and marks the role due. `run` maps every due role: its company through
`company_aliases`, its places against the gazetteer, its level, contract
and remote through the host's tables (`app.prep.words`), and its country
from the places (`app.prep.country`). When the tables changed since the
last run (`fingerprint`, kept in state as `prep:tables`), every open role
is mapped again from its stored words, with no new pull. Then the words no
from the places (`app.prep.country`). When the tables or the gazetteer in
code (`places.seed`) changed since the last run (`fingerprint`, kept in
state as `prep:tables`), the new places and spellings are added to the
database and every open role is mapped again from its stored words, with
no new pull. Then the words no
table knows are listed in `unmapped`, and `Store.rebuild_dupes` folds the
copies across the whole database.
"""
@@ -49,9 +51,10 @@ class Prepped(NamedTuple):
def fingerprint(tables: Tables = TABLES) -> str:
"""A hash of every host table, the shared remote words and `VERSION`."""
blob = json.dumps({"version": VERSION, "tables": tables, "remote": words.REMOTE_WORDS},
sort_keys=True)
"""A hash of every host table, the shared remote words, the gazetteer the
code describes and `VERSION`."""
blob = json.dumps({"version": VERSION, "tables": tables, "remote": words.REMOTE_WORDS,
"places": repr(places.seed())}, sort_keys=True)
return hashlib.sha1(blob.encode()).hexdigest()
@@ -114,12 +117,14 @@ def unknown(field: str, host: str, word: str, gaz: places.Gazetteer,
def run(store: Store, *, remap: bool = False, tables: Tables = TABLES,
dupes: bool = True) -> Prepped:
"""Map the due roles, or every open one when the tables changed, or
every role with `remap`; list the unmapped words; fold the copies."""
"""Map the due roles, or every open one when the tables or the
gazetteer changed, or every role with `remap`; list the unmapped words;
fold the copies."""
mark = fingerprint(tables)
whole = remap or store.state.get(STATE) != mark
rows = store.prep_rows("due")
if whole:
store.seed_places()
due = {r["uid"] for r in rows}
rows += [r for r in store.prep_rows("all" if remap else "open") if r["uid"] not in due]
ids = store.resolve_role_places([r["uid"] for r in rows])