Repository navigation
1.1.0
Composite ids and watch keys, a performance and production-runtime round for the demo and the docs, and record linkage as an experimental, opt-in
part of the package (see docs/linkage.md): a lookup, training on your own data (retrained by the worker), batch deduplication,
a review queue with decisions and a hash-chained audit log, erasure, subject access and retention tools, scoring rules for hard cases and
fuzzphony:linkage:evaluate. The linkage types, configuration and commands carry no backward-compatibility promise yet.
Added
-
Demo: the Linkage page completed with Clusters (dedupe run, truth metrics, histograms), Review, Quality (
evaluate()sweep) and Privacy (subject report, dry run, erasure, audit chain) tabs, hard-case chips andrule:lines;DEMO_LINKAGE_DEDUPE,DEMO_ALLOW_DECIDE,DEMO_ALLOW_FORGET(off by default). -
Record linkage evaluation (experimental):
fuzzphony:linkage:evaluate <profile> <pairs.csv>measures precision, recall and F1 of a profile on your own labelled pairs (key_a,key_b,label[,tenant]), with a threshold sweep, the review band (size, how many are truly the same),--what-if=match:0.97,review:0.7,--errors=N(the worst false positives and negatives: keys, bits, levels, never a value) and--json. Pairs are scored like lookup candidates, as the actor of--tenant/--user(rows that are missing, hidden or of another tenant are only counted); see tools/linkage/README.md. -
Record linkage, public experimental API:
Linker,LinkQuery,LinkResult,Candidate,FieldComparison,Verdict,Thresholds,AsLinkProfile,LinkProfile,Definition\Comparator,ProfileDefinition,LinkageNotTrained,LinkAuthorizerandWeightsProviderare public, tagged@experimental(no BC promise until declared stable, see CONTRIBUTING); the rest stays@internal. NewLinker::explain()(the blocking statement of a probe with its time and plan,LinkExplanation) andLinker::activeWeights()(LinkWeights) replace the demo's reach into internal classes. -
Linkage similarity (experimental): each lookup candidate has a
similarity(0..1: the evidence of the fields present on both sides as a share of the probe scored against itself, so an identical record is 100 %) andcomparedFields/probedFields(the coverage); JSON and thefuzzphony:linkage:matchoutput carry them. Candidates are now ordered by bits, then probability, kind, id: the probability saturates at 1 for strong matches and hid the order. Probability, bits and verdict are unchanged. The demo shows the percentage as a banded badge with "4/5 fields" and a best-match chip. -
Demo, Linkage page (experimental):
/linkagewith a Person / Company switch, example chips from the seeded corrupted rows, per-field evidence bars, timing, a Ground truth badge and "true duplicates found k of n", an SQL / EXPLAIN tab and the trained weights;docker/init.shgeneratestools/linkage/generate.sql(DEMO_LINKAGE,DEMO_LINKAGE_ROWS, default 100 000, dev 20 000), indexes it and trains both profiles. -
Record linkage (experimental, in progress): profiles, comparators and the opt-in
fuzzphony.linkagekey (absent = nothing is built); not part of the BC promise yet, see CONTRIBUTING.
Lookup:Linker::profile('person')->asActor($actor)->match([...])(blocking passes in one statement, scored candidates with verdicts and per-field explanations, gated like a search: tenant, guards, one rate-limit token,FUZZPHONY_LINK, a search-log row with the keys only) andfuzzphony:linkage:match; an untrained profile is refused (LinkageNotTrained).
Training:fuzzphony:linkage:train <profile> [--tenant=|--all-tenants]learns Fellegi-Sunter weights from the index itself, no labels (u from seeded random pairs, m and lambda by EM per blocking pass with the comparators' priors as start values and Dirichlet pseudo-counts, identifiers as anchors against households, every trained m floored at 1e-3, a sanity fallback and monotonic Bayes factors (a weaker level's m is lowered, levels with negligible evidence never cap the others), lambda over the candidates without the comparators the blocking selected on (a warning above 0.3), frequent names term-frequency adjusted with a 50-row floor; bounded seeded samples: the same data and seed give the same weights); versions per profile and tenant infuzzphony_linkage_weights(activated in one transaction, last 5 kept, a run that did not converge is stored but activated only with--force;fuzzphony:linkage:weightsshows them and rolls back, refusing without--forcea version trained for other comparators or not converged); lookups read the active version (PostgresWeights, the bundle default) and refuse weights trained for another comparator;fuzzphony:doctorchecks the profiles and their weights (missing, untrained tenants, changed comparators, row drift, unclean training incl. a high lambda, an unreadable stored row);fuzzphony:schemaand--dump-grantsinclude the weights table only whenlinkageis configured.
Candidate retrieval: a profile with a text pass gets a trigram GIN of its own per text pass field, over the field joined with its alsoAgainst field (trigram_index, on by default for such a profile,falseturns it off;LinkProfile::trigramIndex()); the name pass looks its tokens up there instead of infz(which also holds mother's names and places): the same candidates, at 1M rows SQL p95 100 -> 27 ms. Built only for an index a linkage profile links against and only withlinkageconfigured (every other schema is unchanged), byfuzzphony:schema --apply(idempotent; a no longer needed one is dropped), kept by the shadow rebuild, checked by the doctor (missing, INVALID, STALE), with statistics target 10 on its expression (the planner's estimate of a<%condition costs ~1 ms per condition at the default 100). Scoring: bounded memos (comparisons, parsed names, token similarities, explanations), Jaro-Winkler on ASCII by byte offsets, the name parser reads once for both orders: comparators + scoring ~4x faster, results byte-identical (a 4 400-probe diff). Training: the trained weights are unchanged, person training at 20k rows about 40 % faster with the trigram index (tools/linkage/README.md). -
Record linkage batch dedupe (experimental):
fuzzphony:linkage:dedupe <profile> [--tenant=] [--resume|--restart] [--dry-run]groups a profile's rows (withdedupe:) into clusters: set-based block keys, the lookup's scorer and weights, a chaining guard (max_cluster_size,veto), stored decisions (on_change: keep|suspend), one atomic swap per tenant, resumable;
tables per profile fromfuzzphony:schema --apply(stable cluster ids, salted fingerprints, an erasure block list the run honours), doctor checks; numbers in tools/linkage/README.md. -
Record linkage scoring rules (experimental): a profile's
rules:(bonus / penalty in bits,floor= hard evidence,cap= veto) on comparator outcomes,
applied after the Fellegi-Sunter sum, each one an explainedrule:<name>line; a probe may carry thealso_againstfield (a birth name), counted once; a field
used twice (also_againstand a comparator of its own) is now a profile error. Twins / namesakes no longer match: numbers. -
Record linkage review queue and decisions (experimental):
Linker::profile()->reviewQueue($limit, $after)(the open pairs of the last
dedupe run, the most uncertain first, paged by cursor, each with its explanation rebuilt from the stored levels),->clusterOf($key)
(ClusterInfo: stable cluster id, member keys),->decide($a, $b, Decision::Same|Different, $note)and->undo($a, $b); the commands
fuzzphony:linkage:reviewandfuzzphony:linkage:decide(--undo,--note). Gated like a lookup (tenant, guards, search log with the
action only) withFUZZPHONY_LINK(clusterOf),FUZZPHONY_LINK_REVIEW(queue) andFUZZPHONY_LINK_DECIDE(decisions); a viewer from
whom a compared field is hidden is refused (the stored output embodies every compared field). Who decided comes from the gate (user:<id>,
system:<label>), never from a parameter; a decision stores what the reviewer saw and salted fingerprints of both rows, and appends a row
to a hash-chained decision audit log (who, when, via, previous state; the note is never copied;dedupe: {notes: false, audit_chain: false}).
Decisions apply at the next dedupe run;on_change: keep(default) orsuspend(a decision on a changed row returns to review with its
previous decision); conflicts are explained at decide time ("different" wins).--dump-grants: the search role reads__clustersand
__review, the worker role writes the decisions. Doctor: decisions pending, changed, orphan, and the audit chain. -
Record linkage data protection (experimental, GDPR):
LinkQuery::forget($key, 'erasure'|'objection', dryRun)and
fuzzphony:linkage:forgeterase a key from linkage in one transaction (block list of salted digests that every dedupe run, a run that
was running and decisions honour; pairs, review, decisions and membership deleted; audit rows redacted with the chain kept valid; the
rest of the cluster re-clustered),--all --tenant --yesoffboards a tenant (a dry run without--yes); the dedupe swap always filters and re-clusters against the current block list;subjectReport()/fuzzphony:linkage:subject(keys and level
names only); new attributeFUZZPHONY_LINK_ERASE(no default voter grants it). Retention:fuzzphony.linkage.retention(audit 730 days,
orphan decisions 30, review 180; guarded against an emptied index and never the last run's queue) with a daily worker job andfuzzphony:linkage:purge;fuzzphony:linkage:erased --export|--import
(MAC-protected, for backup restores; the doctor detects a restore);fuzzphony:linkage:audit(verify, anchor);
training.frequent_values(enabled,floor>= 20);fuzzphony.linkage.pepper(default the kernel secret, never change it once keys are erased; checked on every path that reads the block list, stored as a check value byfuzzphony:schema --apply, a forget without a stored check that the role cannot store is refused, the key is a bound parameter and never in statement text; no rotation tool, no row-level security between tenants: documented) keeps the digests unguessable from a database copy. See Record linkage and data protection. -
Record linkage audit rows are inserted complete: the number comes from
__audit_seqand the hash is computed before the insert;
the worker role lost its UPDATE grant on the hash columns (it may only redact the key columns on an erasure); every suspend, forget,
unforget and purge is logged too. Runfuzzphony:schema --applyand--dump-grantsagain (unreleased branch: no migration). -
Record linkage retrains itself (experimental): the worker retrains a profile (per tenant) when the doctor would ask for it (no weights, changed profile, rows 25 % off);
fuzzphony.linkage.retrain(interval,max_per_day,window,false= off), andfuzzphony:linkage:train <profile> --if-stalefor deploy steps and cron; see docs/linkage-freshness.md. -
Composite ids and watch keys (one block, additive): an index can be identified by up to 8 columns (
id: [order_id, line_no],
idType([...]),#[Searchable(id: [...])], also a Doctrine composite identifier) and a watch can key on several columns (SELECT :order_id, :line_no);
every sync mode follows them. A hit'sidis the canonical text key ("10|2") and the newHit::$idPartsthe typed parts (nullfor a
single-column id; a single-idHitand every single-id index are unchanged);refresh()andreindex --from='10|2'take the key, andwith()
reads the source row by it (tenant condition andgrantedfields as for a single id). A source of a multi-source index may be composite
too (stored asline:10|2; the hit'skindisline, itsid10|2,idPartsthe typed parts). Amanyfield or filter of a composite index
links its child rows by one column per id part (many: { key: [tenant_id, order_no], id: [tenant_id, order_no, line_no] }:ManyValues::$key
and$idarestring|list<string>now). See Configuration and the write cost. -
Doctor and wizard know composite keys: the doctor counts the columns of a composite index's watch queries (one short is an error), checks
every id part and the unique key of the source table (and its column order), and warns when a key part is agrantedfield or several composite
indexes watch one table; it warns aboutchar(n)andcitextkey parts, counts the source rows with a NULL key part and measures the longest
encoded key (an error over 2000 bytes; a sample of 100 000 rows without--deep); a compositemanykey wants a child index led by all its key columns (any order).fuzzphony:wizardfinds a composite primary key, takes--id=a,b, and its exports keep the compositeid,id_typeand watchkey. -
fuzzphony:schema,reindexanddoctorwith no index configured print "No search index is configured: nothing to do." and exit with code 0.
Fixed
-
Record linkage review (experimental): a pair decided while a dedupe run ran no longer stays in the review queue; keys with a
trailing newline and review cursors with an out-of-range number are refused asInvalidQuery; the refusal of a viewer from whom a
compared field is hidden comes before the rate-limit token and is in the search log; fingerprint values are length-prefixed. -
refresh()of a multi-source index refuses an id its single-column source cannot take (order:abcfor an int id) with an
InvalidArgumentthat does not echo it, instead of failing the whole batch in PostgreSQL with a misleading "run fuzzphony:schema" hint. -
Refreshing and reindexing a composite-id index is linear in the batch (a 5000-key batch compared every key with every document):
a 200 000-row reindex takes about 1.7x the single-id time instead of 25x; single-id indexes are unchanged. -
A writer with the search role's grants could not write a table watched by a
trigger_level: rowqueue index ("permission denied for table
fuzzphony_queue": the trigger'sON CONFLICTneedsSELECTon the queue's key columns).--dump-grants --role=searchnow prints
SELECT (index_name, doc_id)on the queue as well; run it again and apply the new line. See Database roles.
Changed
- Demo, header: between 768 and 960 px the brand sits on its own line above the centred links (the search button next to the brand had pushed the links 27 px
off centre at 900 px); the Ctrl K hint now hides below 1056 px. - Demo, runtime: PostgreSQL
jit=off, a persistent PDO connection for PHP-FPM,opcache.jit=disable, and pages that never search (doctor, observability,
analytics, benchmark, ERP sync) no longer query the synonym version. Measured on the 20k-row demo stack: typo search with a large-table JIT threshold
662 / 742 / 487 ms with JIT, 115 / 52 / 44 ms without; observability page 81.6 to 68.6 ms,/?q=mouse31.2 to 20.8 ms; a new connection costs 9.7 ms, a
persistent one 1.0 ms.
Documentation
- New Production runtime checklist: OPcache/preload, classmap, cache warmup, persistent connections or PgBouncer (transaction
mode for the search), PostgreSQLjit=off, worker limits and the measuredbatch_sizetable (default unchanged).