diff --git a/CHANGELOG.md b/CHANGELOG.md index ea70f87..296d8df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- The cross-kit check (S7) is enforced, 2026-11-15 (K655). Phasing a kit with a parent now stops unless the two share parent-child cM, and rebuilding someone also needs the children to share full-sibling cM. `fittingRelationships` and `RELATIONSHIP_WORDS` say which relationships a cM fits, and the Kits screen lists them for each pair compared on the Mac. Tested on simulated kits; the screen text hasn't been seen in the built app. + - The app carries its own Node, 2026-11-15 (K338). `pnpm fetch:node` downloads Node v26.13.0 from nodejs.org, checks the pinned SHA-256 and puts it where Tauri bundles it, so the Mac app no longer needs Node installed. A release build never falls back to another Node on the Mac. Also fixed two faults in the packaged helper that kept a built app from opening a library: its shared code was split into chunk files the app didn't include, and the build dropped the `node:` prefix from `node:sqlite`. Checked by building the app and running its helper with no PATH; the app window wasn't clicked through. - Theory chart, 2026-11-15: the Theory screen now draws both candidate fathers side by side, each on its own branch marked uncertain with its chance, using OnePedigree's branches mode. A switch goes back to the tree as recorded. Tested in logic tests; not yet clicked in the built app. diff --git a/README.md b/README.md index 475bf94..4cc133e 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ DNA-first genetic genealogy for Mac. OneFamily groups your DNA matches before yo - OneFamily for Mac, v0: runs on a made-up demo family. It's been built and opened locally, not released. It carries its own copy of Node, so nothing extra needs installing (ADR 0007). - the Chrome extension the app collects with (`apps/extension`, ADR 0009). It stores nothing, talks to the app only through Chrome's native messaging, and asks for your OK in the app. It only works with a local mock site: every DNA service's terms say no to automated page visits. It's been tested with Vitest against the mock site, and hasn't been loaded into Chrome yet. -266 tests pass locally. The raw layouts haven't been checked against a real downloaded file. The register's verdicts are a careful reading of public pages, not legal advice, and a legal review is still to come. +270 tests pass locally. The raw layouts haven't been checked against a real downloaded file. The register's verdicts are a careful reading of public pages, not legal advice, and a legal review is still to come. ## What it will do diff --git a/apps/desktop/host/handlers.ts b/apps/desktop/host/handlers.ts index afcc311..213a2de 100644 --- a/apps/desktop/host/handlers.ts +++ b/apps/desktop/host/handlers.ts @@ -7,7 +7,7 @@ import { createHash } from 'node:crypto' import { appendFileSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs' import { DatabaseSync } from 'node:sqlite' import { isAbsolute, join, relative, resolve, sep } from 'node:path' -import { BlindGate, compareKits, ONE_CM_PER_MB, sha256Hex, TermsRegister, type Unblinding } from '@extantape/onefamily-core' +import { BlindGate, compareKits, fittingRelationships, ONE_CM_PER_MB, RELATIONSHIP_WORDS, sha256Hex, TermsRegister, type Unblinding } from '@extantape/onefamily-core' import { clusterKit, type ClusterRun } from '@extantape/onefamily-analysis' import { importCollectedPages, importGenealogyAssistant, importRawDna, type ImportResult, type RawImport } from '@extantape/onefamily-connectors' import { @@ -455,7 +455,7 @@ export function createHost(opts: { const b = data.kits[j]! if (!a.raw || !b.raw) continue const c = compareKits(a.raw.calls, b.raw.calls, { map: ONE_CM_PER_MB, errorTolerance: 50 }) - comparisons.push({ a: a.result.kit, b: b.result.kit, totalCm: Math.round(c.totalCm), segments: c.segments.length, longestCm: Math.round(c.longestCm), map: c.map }) + comparisons.push({ a: a.result.kit, b: b.result.kit, totalCm: Math.round(c.totalCm), segments: c.segments.length, longestCm: Math.round(c.longestCm), map: c.map, fits: fittingRelationships(c.totalCm).map((r) => RELATIONSHIP_WORDS[r]) }) } return { kits, comparisons } }, diff --git a/apps/desktop/host/protocol.ts b/apps/desktop/host/protocol.ts index cbb7a59..f683556 100644 --- a/apps/desktop/host/protocol.ts +++ b/apps/desktop/host/protocol.ts @@ -77,7 +77,8 @@ export type KitSummary = { export type KitsResult = { kits: KitSummary[] /** The family kits compared with each other on this Mac, from their raw DNA. */ - comparisons: { a: string; b: string; totalCm: number; segments: number; longestCm: number; map: string }[] + /** `fits`: every published relationship (Shared cM Project v4) whose range holds totalCm, in plain words. */ + comparisons: { a: string; b: string; totalCm: number; segments: number; longestCm: number; map: string; fits: string[] }[] } export type MatchRow = { diff --git a/apps/desktop/src/screens/Kits.tsx b/apps/desktop/src/screens/Kits.tsx index 560a5eb..971c7e5 100644 --- a/apps/desktop/src/screens/Kits.tsx +++ b/apps/desktop/src/screens/Kits.tsx @@ -62,13 +62,14 @@ export function KitsScreen({ data }: { data: KitsResult }) {
From their raw DNA, using an approximate map of 1 cM per million base pairs ({data.comparisons[0]!.map}). That’s good enough to see close - relatives, not to measure small segments exactly. + relatives, not to measure small segments exactly. The relationships listed are every one whose observed range in the Shared cM Project (version 4) holds that number, from DNA alone. Phasing and rebuilding stop if the DNA doesn’t fit the relationship they rely on.
)} diff --git a/apps/desktop/test/host.test.ts b/apps/desktop/test/host.test.ts index d4f4047..49cbdef 100644 --- a/apps/desktop/test/host.test.ts +++ b/apps/desktop/test/host.test.ts @@ -258,6 +258,7 @@ describe('the demo family', () => { expect(kits.every((k) => k.blind && k.matches > 0 && k.raw && k.raw.markers > 10000)).toBe(true) // The two family kits are parent and child: about half the genome, compared on this Mac. expect(comparisons[0]!.totalCm).toBeGreaterThan(3000) + expect(comparisons[0]!.fits).toContain('parent or child') // The chromosome browser's data: parent and child share along all 22 chromosomes. const seg = await h.segments({ a: kits[0]!.kit, b: kits[1]!.kit }) diff --git a/docs/architecture/0003-safeguards.md b/docs/architecture/0003-safeguards.md index 16e6276..5456770 100644 --- a/docs/architecture/0003-safeguards.md +++ b/docs/architecture/0003-safeguards.md @@ -12,7 +12,7 @@ Each safeguard is enforced in code and covered by tests. A promise that's only w | S4 | Import checks fail loudly | Expected columns and types, values in range (shared cM 6 to 3,600; longest segment no bigger than the total), known date formats | | S5 | Count reconciliation | Unique IDs; previous export + new − gone = this export; the row count equals the count the service showed, when recorded | | S6 | Spot checks against the source | A sample of matches compared with the service's own pages, where the terms register allows it | -| S7 | Genetic sanity across kits | Family kits share cM in range for their DNA relationship; side assignments agree across kits. Built in `sanity.ts` (2026-11-15): out-of-range pairs, missing close relatives and more than 5% of shared matches on the wrong side stop the run; relationships with no published range are reported as not checked | +| S7 | Genetic sanity across kits | Family kits share cM in range for their DNA relationship; side assignments agree across kits. Built in `sanity.ts` (2026-11-15): out-of-range pairs, missing close relatives and more than 5% of shared matches on the wrong side stop the run; relationships with no published range are reported as not checked. Enforced since 2026-11-15 (K655): `phaseWithParent` and `rebuildFromDescendants` measure the raw kits first and stop unless the parent and child share parent-child cM and the children share full-sibling cM; a relationship with no range can't be relied on there. The Kits screen lists what each measured pair fits. Any later analysis that combines kits must call `assertSane` first | | S8 | Stability report | A run stops for review if more than a few percent of placed people change lines | | S9 | Claims checked against data | Every match cited in a theory is checked against the stored observations | | S10 | People decide conclusions | A theory's status changes only with the user's approval, which is logged | diff --git a/docs/test-audit.md b/docs/test-audit.md index eb11471..28c47a6 100644 --- a/docs/test-audit.md +++ b/docs/test-audit.md @@ -52,7 +52,7 @@ Kept by this repo's owning session (Genealogy), per `~/Code/CLAUDE.md`, "Test se **Gaps skipped, and why:** - **S6, spot checks against a service's own pages:** they need automated visits to real services, which the terms register refuses. Revisit with a partnership. -- **S7, genetic sanity across family kits:** built 2026-11-15 in `packages/core/src/sanity.ts`, covered by `packages/core/test/sanity.test.ts` (9 tests): pairs in and out of range both ways, a missing close relative, an unranged relationship reported as not checked, lists that disagree, sides that agree and disagree for a mother and a father, small matches ignored, and too few to judge. No app screen calls it yet; combined runs must call `assertSane` first. +- **S7, genetic sanity across family kits:** built 2026-11-15 in `packages/core/src/sanity.ts`, covered by `packages/core/test/sanity.test.ts` (9 tests): pairs in and out of range both ways, a missing close relative, an unranged relationship reported as not checked, lists that disagree, sides that agree and disagree for a mother and a father, small matches ignored, and too few to judge. Since 2026-11-15 (K655) it guards phasing and rebuilding: `packages/connectors/test/raw-extras.test.ts` shows phasing stops on a stranger and on a grandparent stated as parent, and rebuilding stops on a wrong other parent and on half siblings; `fittingRelationships` is covered in core, and the Kits screen's list in the host test. There are no combined runs in the app yet, so there's nothing else to guard. - **Theory chart, both candidate fathers (K337):** 2026-11-15, `apps/desktop/test/logic.test.ts` checks that a theory document drawn with OnePedigree's `uncertainParents: 'branches'` shows both the recorded and the candidate father, each joined by an uncertain line. The screen's radio switch itself is covered only by the typecheck; it hasn't been clicked in the built app. - **Bundled Node (K338):** 2026-11-15, checked by hand: `tauri build --bundles app`, then the app's own `Contents/MacOS/node` ran `host.mjs` under `env -i` (no PATH) and answered a `status` request. That run found the chunk and `node:sqlite` faults, now fixed. Not automated: CI doesn't build the Mac app yet, and a unit test of the download script would only re-check the pinned hash. Worth adding a CI step that runs the built helper once the Mac build moves to CI. - **S8, the stability report between runs:** not built, since there's only one run so far. Filed as a task. diff --git a/packages/connectors/test/raw-extras.test.ts b/packages/connectors/test/raw-extras.test.ts index de13a59..f486038 100644 --- a/packages/connectors/test/raw-extras.test.ts +++ b/packages/connectors/test/raw-extras.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' import { fileURLToPath } from 'node:url' -import { compareHalves, compareKits, phaseWithParent, rebuildFromDescendants, RebuildRefused, xPathPossible } from '@extantape/onefamily-core' +import { checkRawPair, compareHalves, compareKits, phaseWithParent, rebuildFromDescendants, RebuildRefused, SanityStop, xPathPossible } from '@extantape/onefamily-core' import { loadTermsRegister } from '../../core/src/node.js' import { AlleleBook, child, founderGenome, genotypesOf, makePanel, Rng, writeRaw, type Genome } from '@extantape/onefamily-simulate' import { importRawDna } from '../src/index.js' @@ -66,6 +66,24 @@ describe('rebuilding someone who never tested', async () => { }) }) +describe('the cross-kit check guards both (S7)', async () => { + const halfSib = child(P, R, rng) + const [q, x, g1, hs, ...ch] = await Promise.all([kitOf(Q), kitOf(stranger), kitOf(G1), kitOf(halfSib), ...kids.map(kitOf)]) + it('phasing stops when the stated parent is a stranger or a grandparent', () => { + expect(() => phaseWithParent(ch[0]!, x)).toThrow(SanityStop) + expect(() => phaseWithParent(ch[0]!, g1)).toThrow(/outside 2376 to 3720 cM for parent-child/) + }) + it('rebuilding stops when the other parent is wrong, or the children are only half siblings', () => { + expect(() => rebuildFromDescendants(ch, x, { synthetic: true })).toThrow(SanityStop) + expect(() => rebuildFromDescendants([ch[0]!, hs], q, { synthetic: true })).toThrow(/child 1 and child 2.*full-sibling/) + }) + it('measures a pair and reports what was stated against what fits', () => { + const r = checkRawPair({ label: 'A', calls: ch[0]! }, { label: 'B', calls: ch[1]! }, 'full-sibling') + expect(r.cm).toBeGreaterThan(1613) + expect(r.issues).toEqual([]) + }) +}) + describe('X-DNA paths', () => { it('a man gets his X only from his mother', () => { expect(xPathPossible(['M', 'F', 'M', 'F'])).toBe(true) diff --git a/packages/core/src/raw-extras.ts b/packages/core/src/raw-extras.ts index 10ab5c2..119de11 100644 --- a/packages/core/src/raw-extras.ts +++ b/packages/core/src/raw-extras.ts @@ -7,9 +7,12 @@ * do it, on real data too, once they've chosen to and that choice is recorded in their decisions log. The * result is always labelled "rebuilt, partial", stays in their own library, and is never uploaded or shared * by the app. Without a recorded choice it's refused. + * - Both stop with `SanityStop` (S7, ADR 0003) unless the DNA fits the relationships they rest on: the + * parent and child share parent-child cM, and the children share full-sibling cM. * - `xPathPossible`: whether X DNA can pass along a line, which rules branches in or out for X matches. */ import type { KitCalls } from './compare.js' +import { requireRawRelationship } from './sanity.js' type Calls = { rsid: string[]; position: number[]; call: string[] } export type HalfKit = Map