hypgraph 0.7.25__tar.gz → 0.7.27__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {hypgraph-0.7.25 → hypgraph-0.7.27}/CHANGELOG.md +44 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/PKG-INFO +33 -6
- {hypgraph-0.7.25 → hypgraph-0.7.27}/README.md +32 -5
- {hypgraph-0.7.25 → hypgraph-0.7.27}/docs/PLAN.md +1 -1
- {hypgraph-0.7.25 → hypgraph-0.7.27}/docs/RELEASE-READINESS.md +30 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/__init__.py +1 -1
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/checks.py +212 -23
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/language.py +13 -5
- hypgraph-0.7.27/tests/test_borrowed_words.py +130 -0
- hypgraph-0.7.27/tests/test_what_a_count_is_of.py +152 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/.gitignore +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/AGENTS.md +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/CITATION.cff +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/DISCLAIMER.md +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/LICENSE +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/NOTICE +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/docs/decisions/ADR-001-token-bound-authors.md +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/docs/decisions/ADR-002-governance-profiles.md +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/docs/profile-workflows-plan.md +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/docs/review-2026-10-24.md +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/docs/site-plan.md +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/docs/spec.md +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/docs/ui-plan.md +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/docs/verification.md +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/docs/workflows/README.md +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/docs/workflows/knowledge.md +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/docs/workflows/optimization.md +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/docs/workflows/scientific.md +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/docs/workflows/software.md +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/docs/workflows/trading.md +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/examples/frameworks/README.md +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/pyproject.toml +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/__main__.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/blind.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/bundle.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/cli.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/coord.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/demos/__init__.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/demos/broad_street.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/demos/linked.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/derive.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/graph.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/mcp.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/plan.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/policy.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/profiles.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/references.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/refusals.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/report_check.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/schema.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/server.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/skill/SKILL.md +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/stats.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/store.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/ui/__init__.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/ui/atlas.css +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/ui/atlas.js +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/ui/hypgraph.css +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/ui/hypgraph.i18n.js +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/ui/hypgraph.js +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/ui/hypgraph.svg +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/ui/index.html +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/ui/vendor/LICENSES.md +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/ui/vendor/cose-base.js +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/ui/vendor/cytoscape-fcose.js +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/ui/vendor/cytoscape.min.js +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/ui/vendor/layout-base.js +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/src/hypgraph/workflow.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_accept_work_kind.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_anchoring.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_blind.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_blind_oracles.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_bound_support.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_bundle_telemetry.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_cancel_releases_lease.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_cited_and_failed_support.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_contradictions.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_coord.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_counts_that_bear.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_d10.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_direction_and_units.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_engine.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_engine_fixes.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_framework_examples.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_i18n.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_incremental.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_link_translate.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_linked_records.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_log_and_check.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_measure_questions.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_opposed_answers.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_option_lead.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_order_detail.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_profiles.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_profiles_041.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_quantifiers_and_identity.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_questions_not_assertions.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_references.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_refusal_friction.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_refusal_results.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_refusals.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_relation_words.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_report_answers.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_rerunnable.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_restates_scale.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_server_auth.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_server_hosts.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_shape_refusals.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_stats_not_backtests.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_stats_values.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_surfaces.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_telemetry_stream.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_trust_boundary.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_ui_app.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_ui_engine.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_uncorrected_effect.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_unnamed_inputs.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_verify_complete.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_verify_lifecycle.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_verify_scope.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_verify_scoped_views.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_verify_trust.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_verify_views.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_versions_not_figures.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_vocabulary_friction.py +0 -0
- {hypgraph-0.7.25 → hypgraph-0.7.27}/tests/test_workflows.py +0 -0
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.7.27 — 2026-11-01: words said elsewhere, comparisons the checks didn't know
|
|
4
|
+
|
|
5
|
+
Fixes from an independent audit of 0.7.26 (HG-026-01, -02); each case below failed on 0.7.26 and is now a test
|
|
6
|
+
(`tests/test_borrowed_words.py`).
|
|
7
|
+
|
|
8
|
+
- **A word said in another clause doesn't make a count fit** (HG-026-01). What a count's key says it counted had to be
|
|
9
|
+
said by the measurement's name or anywhere in the statement, so "Speed was recorded separately; no route is longer
|
|
10
|
+
than 26 km" let a speed count named "routes longer than 26 km" back the length claim, and "Cargo routes were
|
|
11
|
+
inspected; no passenger route is longer …" did the same for a cargo count. The words must now be said where the
|
|
12
|
+
claim states the count's figure (its clause, from the comma before its absolute or extreme). Eight paraphrases over
|
|
13
|
+
other subjects and properties, written after the fix, are tests too: an extra clause never turns a refusal into an
|
|
14
|
+
acceptance, and an honest count backs the claim with or without one.
|
|
15
|
+
- **Any comparison makes an absolute** (HG-026-01, found while reproducing it). "No crate is heavier than 40 kg" and "no
|
|
16
|
+
shift had errors above 5" weren't read as absolutes, so they went in with no count, or with a count of crate prices.
|
|
17
|
+
"No …" before any comparison word is now an absolute; heavier / lighter, warmer / colder, older / younger, taller,
|
|
18
|
+
wider, deeper, louder and stronger are comparisons along their own axes (weight, temperature, age, height, width,
|
|
19
|
+
depth, loudness, strength), and a comparative the checks don't know ("brighter than") is met only by a count that
|
|
20
|
+
says the same word. A three-letter word before a comparison ("bridge age above 60") now names what was counted, and
|
|
21
|
+
"span" is a length, so an honest count of bridge spans backs "no bridge is longer than 60 m".
|
|
22
|
+
- **A mixed "and" / "or" clause has to be split** (HG-026-02). 0.7.26's notes said such a clause is unresolved "until a
|
|
23
|
+
count of the whole condition is bound"; nothing ties a count to the whole condition, so that never happened. The
|
|
24
|
+
refusal now says to split the claim into clauses that each join their comparisons one way.
|
|
25
|
+
|
|
26
|
+
## 0.7.26 — 2026-11-01: what a count is of, what its key compared, "and" with "or"
|
|
27
|
+
|
|
28
|
+
Fixes from an independent audit of 0.7.25 (HG-025-01 to -03); each case below failed on 0.7.25 and is now a test
|
|
29
|
+
(`tests/test_what_a_count_is_of.py`).
|
|
30
|
+
|
|
31
|
+
- **A count names its kind in the singular too** (HG-025-01). Kinds were read only before a plural, so none of 3
|
|
32
|
+
"cargo route longer than 26 km" (or "cargo longer than 26 km") backed "no passenger route is longer than 26 km"
|
|
33
|
+
while the passenger count was 1 of 3. What a count names before its comparison is now read singular or plural: a
|
|
34
|
+
count of cargo routes neither backs nor refutes a claim about passenger routes. A word that says what was compared
|
|
35
|
+
("selections worth more") isn't read as the kind, and a bound in the statement ("the limit is at most 49 kg") isn't
|
|
36
|
+
what the claim is about.
|
|
37
|
+
- **A count's name can't change what its key counted** (HG-025-02). A count the lab keyed `route_speed_above_26`,
|
|
38
|
+
named "routes longer than 26 km" by the claimant, backed a claim about length. The key is the result's own name for
|
|
39
|
+
what it counted: a measurement whose name compares along another axis (length, not speed), or whose key counts a
|
|
40
|
+
thing neither the name nor the statement says ("cargo" under a name for passenger routes), is now
|
|
41
|
+
`MEASUREMENT_MISMATCH`. "route length above 26 km" still names a count of routes longer than 26 km.
|
|
42
|
+
- **"And" with "or" in one clause is left unresolved** (HG-025-03). The parts were checked one by one, so routes of 5,
|
|
43
|
+
20 and 25 km, which make "every route is longer than 10 km and shorter than 30 km or shorter than 6 km" true, gave
|
|
44
|
+
`COUNT_CONTRADICTS`. Which parts go together isn't settled by the words, so no count of a part backs or refutes such
|
|
45
|
+
a clause: it is `ABSOLUTE_WITHOUT_COUNT` until a count of the whole condition is bound, or the claim is split.
|
|
46
|
+
|
|
3
47
|
## 0.7.25 — 2026-11-01: which counts bear on a claim, joined comparisons, boundaries in names
|
|
4
48
|
|
|
5
49
|
Fixes from an independent audit of 0.7.24 (HG-024-01 to -04); each case below failed on 0.7.24 and is now a test
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: hypgraph
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.27
|
|
4
4
|
Summary: The evidence layer for AI research agents: a hash-chained research record that checks every claim as it is written and derives how well each is known.
|
|
5
5
|
Project-URL: Homepage, https://hypgraph.com
|
|
6
6
|
Project-URL: Documentation, https://hypgraph.com/engineers/
|
|
@@ -38,13 +38,22 @@ The evidence layer for AI research agents.<br>
|
|
|
38
38
|
<a href="https://hypgraph.com">hypgraph.com</a> · <a href="https://hypgraph.com/agents/">for agents</a> ·
|
|
39
39
|
<a href="https://hypgraph.com/engineers/">for engineers</a> · <a href="https://hypgraph.com/spec/">record format</a></p>
|
|
40
40
|
|
|
41
|
+
<p align="center"><picture>
|
|
42
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://hypgraph.com/assets/readme/record-dark.png">
|
|
43
|
+
<img src="https://hypgraph.com/assets/readme/record-light.png" width="880" alt="The Graph view of a real research record: one question at the centre, 27 hypotheses around it, experiments and runs fanning out into 90 results, and 22 claims at the rim">
|
|
44
|
+
</picture></p>
|
|
45
|
+
<p align="center"><sub>A real research record in the HypGraph UI: one question, 27 hypotheses, 12 experiments and their runs, 90 results, 22 claims, 395 hash-chained events. <a href="https://hypgraph.com/examples/">Open an example live</a>.</sub></p>
|
|
46
|
+
|
|
41
47
|
---
|
|
42
48
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
Research agents write fluently, and fluency hides overclaims. Fifty clean prompts become "the model never leaks". A
|
|
50
|
+
search too weak to find anything becomes "ruled out". Three copies of one result become three independent lines of
|
|
51
|
+
evidence, and a number appears that no result contains. Every sentence reads fine, and the next claim, decision or
|
|
52
|
+
deployment gets built on top of it.
|
|
53
|
+
|
|
54
|
+
HypGraph is the record agents write into instead of prose. It checks each claim the moment it's written: its numbers
|
|
55
|
+
must come from a result, its "never" needs the trials behind it, its "better" needs both sides measured. When the
|
|
56
|
+
arithmetic doesn't hold, the claim is refused, with a code, the math, and the sentence that would be honest:
|
|
48
57
|
|
|
49
58
|
```text
|
|
50
59
|
$ hypgraph add claim statement="The model never leaks training data." exposure=1000000 exposure_unit=users …
|
|
@@ -61,6 +70,15 @@ The honest version goes in, and it carries its consequence wherever it's read:
|
|
|
61
70
|
active claim · unchecked · 1 independent line of support · … · 0 of 50 = at most 5.8% at 95%, up to 58,155 of 1,000,000 not ruled out
|
|
62
71
|
```
|
|
63
72
|
|
|
73
|
+
On the website, the same engine refused these as the page was built. Each gets a code and what to fix; the
|
|
74
|
+
rewrite underneath, on the same evidence, got in:
|
|
75
|
+
|
|
76
|
+
<p align="center"><a href="https://hypgraph.com/play/"><picture>
|
|
77
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://hypgraph.com/assets/readme/refusals-dark.png">
|
|
78
|
+
<img src="https://hypgraph.com/assets/readme/refusals-light.png" width="880" alt="Three overclaims struck through — 'always beats the baseline', '5 points better', 'never leaks training data' — each with its refusal code and what to fix, and the honest rewrite accepted as CL1, CL2, CL3">
|
|
79
|
+
</picture></a></p>
|
|
80
|
+
<p align="center"><sub>Try to get a claim past it yourself: <a href="https://hypgraph.com/play/">hypgraph.com/play</a>.</sub></p>
|
|
81
|
+
|
|
64
82
|
## The arithmetic of never
|
|
65
83
|
|
|
66
84
|
"Never" is the most expensive word in research, because everything built on it inherits it. Zero failures in *n*
|
|
@@ -133,6 +151,15 @@ Nothing in the record is ever *set* as known. How well each claim is known is **
|
|
|
133
151
|
Every write is an event in a **SHA-256 hash chain**. A record can be handed to a reviewer, a regulator or another
|
|
134
152
|
team, and they can verify it without trusting you.
|
|
135
153
|
|
|
154
|
+
Records can build on each other. A source in one record pins a node of another: the version it read and that
|
|
155
|
+
version's hash. The UI draws every pinned record beside yours, verifies each one, and checks each pin against it.
|
|
156
|
+
|
|
157
|
+
<p align="center"><a href="https://hypgraph.com/examples/linked/#view=graph"><picture>
|
|
158
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://hypgraph.com/assets/readme/linked-dark.png">
|
|
159
|
+
<img src="https://hypgraph.com/assets/readme/linked-light.png" width="880" alt="Three hash-chained records drawn together — London's water 1854–1866, Broad Street 1854 and East London 1866 — joined by pinned references labelled with the version each one read, every pin checked">
|
|
160
|
+
</picture></a></p>
|
|
161
|
+
<p align="center"><sub>Three records, each its own hash chain, joined only by pinned references. <a href="https://hypgraph.com/examples/linked/#view=graph">Open it live</a>.</sub></p>
|
|
162
|
+
|
|
136
163
|
## One record, five disciplines
|
|
137
164
|
|
|
138
165
|
The rules above are the scientific case written as code. A **profile** says what a domain means by evidence,
|
|
@@ -6,13 +6,22 @@ The evidence layer for AI research agents.<br>
|
|
|
6
6
|
<a href="https://hypgraph.com">hypgraph.com</a> · <a href="https://hypgraph.com/agents/">for agents</a> ·
|
|
7
7
|
<a href="https://hypgraph.com/engineers/">for engineers</a> · <a href="https://hypgraph.com/spec/">record format</a></p>
|
|
8
8
|
|
|
9
|
+
<p align="center"><picture>
|
|
10
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://hypgraph.com/assets/readme/record-dark.png">
|
|
11
|
+
<img src="https://hypgraph.com/assets/readme/record-light.png" width="880" alt="The Graph view of a real research record: one question at the centre, 27 hypotheses around it, experiments and runs fanning out into 90 results, and 22 claims at the rim">
|
|
12
|
+
</picture></p>
|
|
13
|
+
<p align="center"><sub>A real research record in the HypGraph UI: one question, 27 hypotheses, 12 experiments and their runs, 90 results, 22 claims, 395 hash-chained events. <a href="https://hypgraph.com/examples/">Open an example live</a>.</sub></p>
|
|
14
|
+
|
|
9
15
|
---
|
|
10
16
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
Research agents write fluently, and fluency hides overclaims. Fifty clean prompts become "the model never leaks". A
|
|
18
|
+
search too weak to find anything becomes "ruled out". Three copies of one result become three independent lines of
|
|
19
|
+
evidence, and a number appears that no result contains. Every sentence reads fine, and the next claim, decision or
|
|
20
|
+
deployment gets built on top of it.
|
|
21
|
+
|
|
22
|
+
HypGraph is the record agents write into instead of prose. It checks each claim the moment it's written: its numbers
|
|
23
|
+
must come from a result, its "never" needs the trials behind it, its "better" needs both sides measured. When the
|
|
24
|
+
arithmetic doesn't hold, the claim is refused, with a code, the math, and the sentence that would be honest:
|
|
16
25
|
|
|
17
26
|
```text
|
|
18
27
|
$ hypgraph add claim statement="The model never leaks training data." exposure=1000000 exposure_unit=users …
|
|
@@ -29,6 +38,15 @@ The honest version goes in, and it carries its consequence wherever it's read:
|
|
|
29
38
|
active claim · unchecked · 1 independent line of support · … · 0 of 50 = at most 5.8% at 95%, up to 58,155 of 1,000,000 not ruled out
|
|
30
39
|
```
|
|
31
40
|
|
|
41
|
+
On the website, the same engine refused these as the page was built. Each gets a code and what to fix; the
|
|
42
|
+
rewrite underneath, on the same evidence, got in:
|
|
43
|
+
|
|
44
|
+
<p align="center"><a href="https://hypgraph.com/play/"><picture>
|
|
45
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://hypgraph.com/assets/readme/refusals-dark.png">
|
|
46
|
+
<img src="https://hypgraph.com/assets/readme/refusals-light.png" width="880" alt="Three overclaims struck through — 'always beats the baseline', '5 points better', 'never leaks training data' — each with its refusal code and what to fix, and the honest rewrite accepted as CL1, CL2, CL3">
|
|
47
|
+
</picture></a></p>
|
|
48
|
+
<p align="center"><sub>Try to get a claim past it yourself: <a href="https://hypgraph.com/play/">hypgraph.com/play</a>.</sub></p>
|
|
49
|
+
|
|
32
50
|
## The arithmetic of never
|
|
33
51
|
|
|
34
52
|
"Never" is the most expensive word in research, because everything built on it inherits it. Zero failures in *n*
|
|
@@ -101,6 +119,15 @@ Nothing in the record is ever *set* as known. How well each claim is known is **
|
|
|
101
119
|
Every write is an event in a **SHA-256 hash chain**. A record can be handed to a reviewer, a regulator or another
|
|
102
120
|
team, and they can verify it without trusting you.
|
|
103
121
|
|
|
122
|
+
Records can build on each other. A source in one record pins a node of another: the version it read and that
|
|
123
|
+
version's hash. The UI draws every pinned record beside yours, verifies each one, and checks each pin against it.
|
|
124
|
+
|
|
125
|
+
<p align="center"><a href="https://hypgraph.com/examples/linked/#view=graph"><picture>
|
|
126
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://hypgraph.com/assets/readme/linked-dark.png">
|
|
127
|
+
<img src="https://hypgraph.com/assets/readme/linked-light.png" width="880" alt="Three hash-chained records drawn together — London's water 1854–1866, Broad Street 1854 and East London 1866 — joined by pinned references labelled with the version each one read, every pin checked">
|
|
128
|
+
</picture></a></p>
|
|
129
|
+
<p align="center"><sub>Three records, each its own hash chain, joined only by pinned references. <a href="https://hypgraph.com/examples/linked/#view=graph">Open it live</a>.</sub></p>
|
|
130
|
+
|
|
104
131
|
## One record, five disciplines
|
|
105
132
|
|
|
106
133
|
The rules above are the scientific case written as code. A **profile** says what a domain means by evidence,
|
|
@@ -109,7 +109,7 @@ claim's derived standing.
|
|
|
109
109
|
Multi-writer sync between graphs (bundles cover sharing), authentication (the host's job; the HTTP server binds to
|
|
110
110
|
loopback and is read-only unless started with `--writable`), and a hosted service.
|
|
111
111
|
|
|
112
|
-
## Status at 0.7.
|
|
112
|
+
## Status at 0.7.27 (2026-11-01)
|
|
113
113
|
|
|
114
114
|
All seven phases are done: the library, bundles, the server and UI, the MCP server, the website, Pegasus running on
|
|
115
115
|
the package, and releases to PyPI from tags with trusted publishing. What came after the plan, by release, is in
|
|
@@ -166,6 +166,36 @@ was taken from a changelog without being checked against the code.*
|
|
|
166
166
|
> suite is 574 passed, and hypswarm (118 passed) and hypmesh (37 passed) pass on it. Kinds are read from a plural noun
|
|
167
167
|
> and the words before it, a heuristic; the typed claim layer the audits recommend is not built. Released as 0.7.25.
|
|
168
168
|
|
|
169
|
+
> **Audit of 0.7.25 (2026-11-01), fixed for 0.7.26.** A sixth independent audit named three defects; each reproduced on
|
|
170
|
+
> the PyPI 0.7.25 wheel. Kinds were read only before a plural, so none of 3 "cargo route longer than 26 km" backed "no
|
|
171
|
+
> passenger route is longer than 26 km" while the passenger count was 1 of 3 (HG-025-01). A count the lab keyed
|
|
172
|
+
> `route_speed_above_26`, named "routes longer than 26 km" by the claimant, backed a claim about length (HG-025-02). A
|
|
173
|
+
> clause joining comparisons with both "and" and "or" was checked part by part, so a true one drew
|
|
174
|
+
> `COUNT_CONTRADICTS` (HG-025-03). What a count names before its comparison is now read singular or plural; a name
|
|
175
|
+
> that compares along another axis than its key, or a key that counts a kind neither the name nor the statement says,
|
|
176
|
+
> is `MEASUREMENT_MISMATCH`; a mixed "and" / "or" clause is unresolved until the whole condition is counted. Each case
|
|
177
|
+
> is a regression test written to fail on 0.7.25. Replaying the 1,900 recorded adversarial entries changes none; the
|
|
178
|
+
> replay caught two over-reaches of a first draft (a value word, "selections worth more", read as the kind; a bound,
|
|
179
|
+
> "the limit is at most 49 kg", read as the subject), now tests too.
|
|
180
|
+
>
|
|
181
|
+
> **Where that stands.** #96 is merged with green CI (17 of 17 checks). Kinds and subjects are still read from the
|
|
182
|
+
> words around a comparison, a heuristic; the typed claim layer the audits recommend is not built. Released as 0.7.26.
|
|
183
|
+
|
|
184
|
+
> **Audit of 0.7.26 (2026-11-01), fixed for 0.7.27.** A seventh independent audit named two defects; both reproduced on
|
|
185
|
+
> the PyPI 0.7.26 wheel. A clause that only mentioned speed ("Speed was recorded separately; no route is longer than
|
|
186
|
+
> 26 km") let a speed count named "routes longer than 26 km" back the length claim, and the same for cargo named as
|
|
187
|
+
> passenger routes: the key's words were looked for anywhere in the statement (HG-026-01). Reproducing it found a
|
|
188
|
+
> wider gap: "no crate is heavier than 40 kg" wasn't read as an absolute, so it went in with no count or with a count
|
|
189
|
+
> of crate prices. And the 0.7.26 note that a count of the whole condition settles a mixed "and" / "or" clause promised
|
|
190
|
+
> something nothing implements (HG-026-02). A key's words must now be said where the claim states the count's figure;
|
|
191
|
+
> "no …" before any comparison is an absolute; eight more comparison pairs have axes of their own, and an unknown
|
|
192
|
+
> "-er than" is met only by a count saying the same word; the mixed-clause refusal says to split the claim. Eleven
|
|
193
|
+
> paraphrases written after the first fix found three more gaps (a three-letter subject, "span", a comma-led aside),
|
|
194
|
+
> fixed before merge. Replaying the 1,900 recorded adversarial entries changes none.
|
|
195
|
+
>
|
|
196
|
+
> **Where that stands.** #98 is merged with green CI (17 of 17 checks). This is still word matching; the typed claim
|
|
197
|
+
> layer the audits recommend is not built. Released as 0.7.27.
|
|
198
|
+
|
|
169
199
|
## Recommendation: CONDITIONAL GO
|
|
170
200
|
|
|
171
201
|
HypGraph is ready for a public developer preview once #59, #60 and #61 are merged with green CI and released as one
|
|
@@ -16,7 +16,7 @@ Standing is derived on every read, never stored; every write is an event in a SH
|
|
|
16
16
|
their numbers; reviews pin versions; independence is counted, not assumed. See https://hypgraph.com.
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
|
-
__version__ = "0.7.
|
|
19
|
+
__version__ = "0.7.27"
|
|
20
20
|
|
|
21
21
|
from .bundle import anchored, verify_bundle # noqa: E402
|
|
22
22
|
from .graph import Author, Graph, GraphError, file_sha256 # noqa: E402
|
|
@@ -185,8 +185,9 @@ def _matches_stat(printed: tuple, candidates: list[float]) -> bool:
|
|
|
185
185
|
return printed[1] >= 1 and _matches(printed, candidates)
|
|
186
186
|
|
|
187
187
|
|
|
188
|
-
def _bound(s: Snap, meas: list) -> tuple[list[tuple[dict, dict]], list[Problem]]:
|
|
189
|
-
"""Measurements that check out against their results, and problems with the rest.
|
|
188
|
+
def _bound(s: Snap, meas: list, stmt: str = "") -> tuple[list[tuple[dict, dict]], list[Problem]]:
|
|
189
|
+
"""Measurements that check out against their results, and problems with the rest. With ``stmt``, the claim's
|
|
190
|
+
statement: what a key says it counted must be said by the measurement's name or by the statement."""
|
|
190
191
|
good, problems = [], []
|
|
191
192
|
for i, m in enumerate(meas):
|
|
192
193
|
if not isinstance(m, dict) or not m.get("result") or not m.get("key"):
|
|
@@ -228,11 +229,69 @@ def _bound(s: Snap, meas: list) -> tuple[list[tuple[dict, dict]], list[Problem]]
|
|
|
228
229
|
f"{m['result']} counted '{m['key']}' with {op}",
|
|
229
230
|
fix=f"name the count after the comparison it made ({op})"))
|
|
230
231
|
bad = True
|
|
232
|
+
# the key is the result's own name for what it counted, written by whoever ran it; the measurement's name is
|
|
233
|
+
# the claimant's. A name may shorten the key, not change it: "routes longer than 26 km" isn't a count of
|
|
234
|
+
# route_speed_above_26, nor of routes_faster_than_26 (audit HG-025-02)
|
|
235
|
+
key = str(m["key"]).replace("_", " ")
|
|
236
|
+
named_axes = {c[0] for c in _comparisons_in(str(m.get("name") or "")) if c[0]}
|
|
237
|
+
key_axes = {c[0] for c in _comparisons_in(key) if c[0]}
|
|
238
|
+
if not bad and named_axes and key_axes and not named_axes & key_axes:
|
|
239
|
+
problems.append(Problem("MEASUREMENT_MISMATCH", f"measurement {m.get('name')}: its name compares "
|
|
240
|
+
f"{_axis_words(named_axes)}, but result {m['result']} counted '{m['key']}', which "
|
|
241
|
+
f"compares {_axis_words(key_axes)}",
|
|
242
|
+
fix="name the count after what it compared, or bind the count that compared that"))
|
|
243
|
+
bad = True
|
|
244
|
+
# a name that says no comparison ("fitting selections") doesn't say another count; one that does must keep
|
|
245
|
+
# what the key counted, here or in the statement
|
|
246
|
+
unsaid = _unsaid(_subject_of(key), f"{m.get('name') or ''} . {_clauses_at(stmt, _count_figures(m, rv))}")
|
|
247
|
+
if not bad and unsaid and _comparisons_in(str(m.get("name") or "")):
|
|
248
|
+
problems.append(Problem("MEASUREMENT_MISMATCH", f"measurement {m.get('name')}: result {m['result']} "
|
|
249
|
+
f"counted '{m['key']}', and neither the name nor the statement says what it "
|
|
250
|
+
f"counted ({', '.join(sorted(_key_words(key, unsaid)))})",
|
|
251
|
+
fix="name the count after what it counted, or bind the count of what the claim "
|
|
252
|
+
"is about"))
|
|
253
|
+
bad = True
|
|
231
254
|
if not bad:
|
|
232
255
|
good.append((m, rv))
|
|
233
256
|
return good, problems
|
|
234
257
|
|
|
235
258
|
|
|
259
|
+
# where one thing said ends and another begins: a sentence, a semicolon or colon, or a comma before a conjunction
|
|
260
|
+
_SAYING = re.compile(r"[;:!?]|\.(?!\d)|,\s*(?=(?:and|but|while|whereas|although|though|so|yet)\b)|"
|
|
261
|
+
r"\b(?:although|though|whereas)\b", re.I)
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
def _clauses_at(stmt: str, figs: set[float]) -> str:
|
|
265
|
+
"""The parts of ``stmt`` that state one of ``figs``: what a count against that figure must be about is said there,
|
|
266
|
+
not in another sentence. "Speed was recorded separately; no route is longer than 26 km" says nothing about speed
|
|
267
|
+
where it says 26 km, so a speed count named "routes longer than 26 km" can't borrow the word (audit HG-026-01).
|
|
268
|
+
The whole statement when no part states one."""
|
|
269
|
+
if not stmt or not figs:
|
|
270
|
+
return stmt
|
|
271
|
+
parts = [p for p in _SAYING.split(stmt) if p and p.strip()]
|
|
272
|
+
hit = [_from_claim(p) for p in parts if {round(v[0], 6) for v in numbers(p)} & {round(f, 6) for f in figs}]
|
|
273
|
+
return " . ".join(hit) if hit else stmt
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
def _from_claim(part: str) -> str:
|
|
277
|
+
"""A part from the comma before its absolute or extreme: "Rural sites aside, no urban clinic had waits above 45"
|
|
278
|
+
claims only "no urban clinic had waits above 45"."""
|
|
279
|
+
hit = L.ABSOLUTE.search(part) or L.SUPERLATIVE.search(part)
|
|
280
|
+
if not hit:
|
|
281
|
+
return part
|
|
282
|
+
return part[max((x.end() for x in re.finditer(r",(?!\d)", part[:hit.start()])), default=0):]
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
def _axis_words(axes: set[str]) -> str:
|
|
286
|
+
return " / ".join(sorted("/".join(w for w, (a, _s) in _DIRECTION_OF.items() if a == x and not w.endswith("est"))
|
|
287
|
+
for x in axes))
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
def _key_words(key: str, stems: set[str]) -> set[str]:
|
|
291
|
+
"""The words of ``key`` whose stems are ``stems``, as written."""
|
|
292
|
+
return {w for w in re.findall(r"[a-z]+", key.lower()) if L.content_words(w) & stems} or stems
|
|
293
|
+
|
|
294
|
+
|
|
236
295
|
def _exposure_note(bound_rate: float, body: dict) -> str:
|
|
237
296
|
x = body.get("exposure")
|
|
238
297
|
if not isinstance(x, (int, float)) or x <= 0:
|
|
@@ -276,13 +335,11 @@ _PROVEN = re.compile(r"^prov(?:es?|en|ed)$|^proof$", re.I)
|
|
|
276
335
|
|
|
277
336
|
# the figure a count is about: "fitting selections worth more than 93", "routes shorter than 26 km" (or, matching a
|
|
278
337
|
# figure the claim names, "worth_more_93"). A count of nothing beyond 140 says nothing about 93 (audit HG-020-01/02).
|
|
279
|
-
_COUNT_FIGURE = re.compile(r"\b(?:(?:
|
|
280
|
-
r"slower|larger|smaller)\s+than|above|below|over|under|beyond|exceed\w*|beat\w*)\s+\$?"
|
|
338
|
+
_COUNT_FIGURE = re.compile(r"\b(?:(?:" + L.CMP_WORDS + r"|(?!(?:" + L.NOT_CMP + r")\b)[a-z]{3,}er)\s+than|above|below|over|under|beyond|exceed\w*|beat\w*)\s+\$?"
|
|
281
339
|
r"(-?\d[\d,]*(?:\.\d+)?)", re.I)
|
|
282
340
|
# the figure a name gives before its comparison or with "at least": "routes 26 km or longer", "routes at least 26 km"
|
|
283
341
|
_COUNT_FIGURE_BOUNDARY = re.compile(r"\bat\s+(?:least|most)\s+\$?(-?\d[\d,]*(?:\.\d+)?)|\$?(-?\d[\d,]*(?:\.\d+)?)"
|
|
284
|
-
r"(?:\s+[a-z%]+){0,2}\s+or\s+(?:
|
|
285
|
-
r"shorter|longer|cheaper|faster|slower|larger|smaller)\b", re.I)
|
|
342
|
+
r"(?:\s+[a-z%]+){0,2}\s+or\s+(?:" + L.CMP_WORDS + r")\b", re.I)
|
|
286
343
|
|
|
287
344
|
|
|
288
345
|
def _named_figure(name: str) -> tuple[float, str] | None:
|
|
@@ -296,16 +353,13 @@ def _named_figure(name: str) -> tuple[float, str] | None:
|
|
|
296
353
|
return None
|
|
297
354
|
|
|
298
355
|
|
|
299
|
-
_KEY_FIGURE = re.compile(r"\b(?:
|
|
300
|
-
r"slower|larger|smaller|above|below|over|under|beyond|exceed\w*|beat\w*)(?:\s+than)?\s+"
|
|
356
|
+
_KEY_FIGURE = re.compile(r"\b(?:" + L.CMP_WORDS + r"|above|below|over|under|beyond|exceed\w*|beat\w*)(?:\s+than)?\s+"
|
|
301
357
|
r"(\d+(?:\.\d+)?)$", re.I)
|
|
302
358
|
# the figure an absolute names in its own clause: "nothing worth more than 93 fits", "no route is shorter than 26 km"
|
|
303
|
-
_CLAIM_FIGURE = re.compile(r"\b(?:
|
|
304
|
-
r"slower|larger|smaller)\s+than\s+\$?(-?\d[\d,]*(?:\.\d+)?)|\b(?:above|below|beyond|"
|
|
359
|
+
_CLAIM_FIGURE = re.compile(r"\b(?:" + L.CMP_WORDS + r"|(?!(?:" + L.NOT_CMP + r")\b)[a-z]{3,}er)\s+than\s+\$?(-?\d[\d,]*(?:\.\d+)?)|\b(?:above|below|beyond|"
|
|
305
360
|
r"exceed(?:s|ing)?)\s+\$?(-?\d[\d,]*(?:\.\d+)?)", re.I)
|
|
306
361
|
_CLAIM_BOUNDARY = re.compile(r"\bat\s+(?:least|most)\s+\$?(-?\d[\d,]*(?:\.\d+)?)|\$?(-?\d[\d,]*(?:\.\d+)?)"
|
|
307
|
-
r"(?:\s+[a-z%]+){0,2}\s+or\s+(?:
|
|
308
|
-
r"shorter|longer|cheaper|faster|slower|larger|smaller)\b", re.I)
|
|
362
|
+
r"(?:\s+[a-z%]+){0,2}\s+or\s+(?:" + L.CMP_WORDS + r")\b", re.I)
|
|
309
363
|
_SUBCLAUSE = re.compile(r",(?!\d)|[;:!?()]|\.(?!\d)|\b(?:and|but|while|whereas|although|so)\b", re.I)
|
|
310
364
|
|
|
311
365
|
|
|
@@ -349,6 +403,14 @@ _DIRECTION_WORDS = {
|
|
|
349
403
|
"fast": {1: "faster fastest", -1: "slower slowest"},
|
|
350
404
|
"cost": {1: "dearer dearest", -1: "cheaper cheapest"},
|
|
351
405
|
"time": {1: "later latest", -1: "earlier earliest"},
|
|
406
|
+
"heavy": {1: "heavier heaviest", -1: "lighter lightest"},
|
|
407
|
+
"warm": {1: "warmer warmest hotter hottest", -1: "colder coldest cooler coolest"},
|
|
408
|
+
"old": {1: "older oldest", -1: "younger youngest newer newest"},
|
|
409
|
+
"tall": {1: "taller tallest"},
|
|
410
|
+
"wide": {1: "wider widest", -1: "narrower narrowest"},
|
|
411
|
+
"deep": {1: "deeper deepest", -1: "shallower shallowest"},
|
|
412
|
+
"loud": {1: "louder loudest", -1: "quieter quietest"},
|
|
413
|
+
"strong": {1: "stronger strongest", -1: "weaker weakest"},
|
|
352
414
|
}
|
|
353
415
|
_DIRECTION_OF = {w: (axis, sign) for axis, signs in _DIRECTION_WORDS.items() for sign, ws in signs.items()
|
|
354
416
|
for w in ws.split()}
|
|
@@ -356,8 +418,7 @@ _DIRECTION_OF = {w: (axis, sign) for axis, signs in _DIRECTION_WORDS.items() for
|
|
|
356
418
|
# not strict, so a route of exactly 26 lies inside them and outside "longer than" (audit HG-023-02). Six operators;
|
|
357
419
|
# "=" and "!=" point nowhere.
|
|
358
420
|
_OPS = {">": (1, True), ">=": (1, False), "<": (-1, True), "<=": (-1, False), "=": None, "!=": None}
|
|
359
|
-
_CMP = r"(
|
|
360
|
-
r"smaller|bigger|earlier|later)"
|
|
421
|
+
_CMP = r"(" + L.CMP_WORDS + r")"
|
|
361
422
|
_NOT_STRICT = re.compile(r"\bat\s+(least|most)\b|\b(?:not|no)\s+" + _CMP + r"\s+than\b|\bor\s+" + _CMP + r"\b", re.I)
|
|
362
423
|
|
|
363
424
|
|
|
@@ -375,7 +436,13 @@ def _comparisons_in(text: str) -> set[tuple[str, int, bool]]:
|
|
|
375
436
|
else:
|
|
376
437
|
out.add((*_DIRECTION_OF[h.group(3)], False))
|
|
377
438
|
rest = _NOT_STRICT.sub(" ", text)
|
|
378
|
-
|
|
439
|
+
# a comparative the checks don't know ("brighter than") is an axis of its own: only a count that says the same word
|
|
440
|
+
# meets it, so nothing else can back a claim made with it (audit HG-026-01)
|
|
441
|
+
unknown = {(w, 1, True) for w in _UNKNOWN_CMP.findall(rest) if w not in _DIRECTION_OF}
|
|
442
|
+
return out | unknown | {(*_DIRECTION_OF[w], True) for w in re.findall(r"[a-z]+", rest) if w in _DIRECTION_OF}
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
_UNKNOWN_CMP = re.compile(r"\b(?!(?:" + L.NOT_CMP + r")\b)([a-z]{3,}er)\s+than\b")
|
|
379
446
|
|
|
380
447
|
|
|
381
448
|
def _directions(text: str) -> set[tuple[str, int]]:
|
|
@@ -439,6 +506,9 @@ def _clause_comparisons(clause: str) -> list[tuple[float, tuple[str, int, bool]
|
|
|
439
506
|
return out
|
|
440
507
|
|
|
441
508
|
|
|
509
|
+
# a target group whose parts are joined by both "and" and "or" (``_target_groups``)
|
|
510
|
+
MIXED = (frozenset(), frozenset({("mixed", 0, False)}))
|
|
511
|
+
|
|
442
512
|
# "and" or "or" before a comparison with no subject of its own: "shorter than 20 km and longer than 30 km"
|
|
443
513
|
_JOINED = re.compile(r"\s+(?:also\s+)?(?:(?:not|no)\s+)?(?:" + _CMP + r"\s+than\b|at\s+(?:least|most)\b|above\b|below\b|"
|
|
444
514
|
r"beyond\b|exceed)", re.I)
|
|
@@ -464,7 +534,11 @@ def _target_groups(stmt: str, w: str) -> list[list[tuple[frozenset, frozenset]]]
|
|
|
464
534
|
falsifies the claim ("no route is shorter than 20 km or longer than 30 km"; "every route is longer than 10 km and
|
|
465
535
|
shorter than 30 km"), and one group where only an exception to both does ("no route is shorter than 20 km and
|
|
466
536
|
longer than 30 km" rules out a route that is both; "every route is shorter than 20 km or longer than 30 km" one that
|
|
467
|
-
is neither) (audit HG-024-03).
|
|
537
|
+
is neither) (audit HG-024-03).
|
|
538
|
+
|
|
539
|
+
A clause that joins comparisons with both "and" and "or" ("every route is longer than 10 km and shorter than 30 km
|
|
540
|
+
or shorter than 6 km") is one group marked ``MIXED``: which parts go together depends on a grouping the words don't
|
|
541
|
+
settle, so no count of a part backs or refutes it (audit HG-025-03)."""
|
|
468
542
|
out: list[list[tuple[frozenset, frozenset]]] = []
|
|
469
543
|
every = bool(_ALL.match(w)) and not _names_stated_count(stmt, w)
|
|
470
544
|
for m in re.finditer(r"\b" + re.escape(w) + r"\b", stmt, re.I):
|
|
@@ -473,7 +547,9 @@ def _target_groups(stmt: str, w: str) -> list[list[tuple[frozenset, frozenset]]]
|
|
|
473
547
|
for fig, c in _clause_comparisons(clause)]
|
|
474
548
|
ands = any(_JOINED.match(clause, x.end()) for x in re.finditer(r"\band\b", clause, re.I))
|
|
475
549
|
ors = any(_JOINED.match(clause, x.end()) for x in re.finditer(r"\bor\b", clause, re.I))
|
|
476
|
-
if len(targets) > 1 and ands
|
|
550
|
+
if len(targets) > 1 and ands and ors:
|
|
551
|
+
out.append([MIXED, *targets])
|
|
552
|
+
elif len(targets) > 1 and ands != ors and (ands != every):
|
|
477
553
|
out.append(targets)
|
|
478
554
|
else:
|
|
479
555
|
out += [[x] for x in targets]
|
|
@@ -482,7 +558,7 @@ def _target_groups(stmt: str, w: str) -> list[list[tuple[frozenset, frozenset]]]
|
|
|
482
558
|
|
|
483
559
|
def _absolute_targets(stmt: str, w: str) -> list[tuple[frozenset, frozenset]]:
|
|
484
560
|
"""Every thing an absolute rules out, each on its own (``_target_groups`` says which go together)."""
|
|
485
|
-
return [x for group in _target_groups(stmt, w) for x in group]
|
|
561
|
+
return [x for group in _target_groups(stmt, w) for x in group if x is not MIXED]
|
|
486
562
|
|
|
487
563
|
|
|
488
564
|
def _claim_directions(stmt: str, w: str = "") -> set[tuple[str, int]]:
|
|
@@ -540,18 +616,103 @@ _COUNTING = set("count counts counted counting number numbers total totals tally
|
|
|
540
616
|
_HOW_MANY = set("nothing none never nobody every always ever each whole entire".split())
|
|
541
617
|
|
|
542
618
|
|
|
619
|
+
# three-letter words that say nothing about what was counted
|
|
620
|
+
_SHORT_SKIP = set("has had did got get let may can one two six ten few new old top max min own via nor yet per".split())
|
|
621
|
+
|
|
622
|
+
|
|
623
|
+
def _stems(text: str) -> set[str]:
|
|
624
|
+
"""``L.content_words`` and the three-letter words it leaves out, which can name what was counted: a count of
|
|
625
|
+
"bridge age above 60" is of ages, and "age" must be said for it to back a claim (audit HG-026-01)."""
|
|
626
|
+
return L.content_words(text) | {w for w in re.findall(r"[a-z]+", (text or "").lower())
|
|
627
|
+
if len(w) == 3 and w not in L.STOP and w not in _SHORT_SKIP}
|
|
628
|
+
|
|
629
|
+
|
|
543
630
|
def _modifiers(words: list[str], i: int) -> set[str]:
|
|
544
631
|
"""The content words right before ``words[i]``, up to a determiner, number, preposition or comparison: "no passenger
|
|
545
632
|
route" gives {passeng}, "the 3 cargo routes" {cargo}, "the shortest route" nothing."""
|
|
546
633
|
out: set[str] = set()
|
|
547
634
|
for w in reversed(words[:i]):
|
|
548
|
-
cw =
|
|
635
|
+
cw = _stems(w)
|
|
549
636
|
if not cw or w in _DETERMINERS or w in _PREPOSITIONS or w in _DIRECTION_OF or w in _COUNTING | _HOW_MANY:
|
|
550
637
|
break
|
|
551
638
|
out |= cw
|
|
552
639
|
return out
|
|
553
640
|
|
|
554
641
|
|
|
642
|
+
def _subject_of(text: str) -> set[str]:
|
|
643
|
+
"""What a count against a figure is of: the content words right before its first comparison ("cargo route longer
|
|
644
|
+
than 26 km" and "cargo_routes_longer_26" give {cargo, route}; "speed above 26" {speed}); empty when it makes no
|
|
645
|
+
comparison or names nothing before it. Singular or plural alike (audit HG-025-01)."""
|
|
646
|
+
words = [w for w in re.findall(r"[a-z]+|\d[\d.,]*", text.lower().replace("_", " ")) if w not in _COPULAS]
|
|
647
|
+
i = next((j for j, w in enumerate(words) if w in _DIRECTION_OF or w == "at" and words[j + 1:j + 2] in
|
|
648
|
+
(["least"], ["most"])), None)
|
|
649
|
+
return _modifiers(words, i) if i else set()
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
def _subject_parts(text: str) -> tuple[set[str], set[str]]:
|
|
653
|
+
"""``_subject_of`` split into its head, the word right before the comparison, and the words before that: "cargo
|
|
654
|
+
route longer" gives ({route}, {cargo}), "fitting selections worth more" ({selection}, {fit})."""
|
|
655
|
+
words = [w for w in re.findall(r"[a-z]+|\d[\d.,]*", text.lower().replace("_", " ")) if w not in _COPULAS]
|
|
656
|
+
i = next((j for j, w in enumerate(words) if w in _DIRECTION_OF or w == "at" and words[j + 1:j + 2] in
|
|
657
|
+
(["least"], ["most"])), None)
|
|
658
|
+
if not i:
|
|
659
|
+
return set(), set()
|
|
660
|
+
whole = _modifiers(words, i)
|
|
661
|
+
while i > 1 and words[i - 1] in _MEASURED_BY: # "selections worth more": the head is selections
|
|
662
|
+
whole -= L.content_words(words[i - 1])
|
|
663
|
+
i -= 1
|
|
664
|
+
head = _stems(words[i - 1]) & whole
|
|
665
|
+
return head, whole - head
|
|
666
|
+
|
|
667
|
+
|
|
668
|
+
# words between what a count is of and its comparison that say what was compared, not which thing
|
|
669
|
+
_MEASURED_BY = set("worth valued priced weighing costing lasting taking".split())
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
_COPULAS = set("is are was were be been being".split())
|
|
673
|
+
# the property a comparison word compares: a count of "route length above 26" is said by "no route is longer than 26"
|
|
674
|
+
_PROPERTY_AXIS = {s: axis for axis, ws in {"long": "length distance span", "fast": "speed velocity pace",
|
|
675
|
+
"cost": "cost price", "time": "date time", "heavy": "weight mass",
|
|
676
|
+
"warm": "temperature heat", "old": "age", "tall": "height",
|
|
677
|
+
"wide": "width breadth", "deep": "depth", "loud": "loudness",
|
|
678
|
+
"strong": "strength"}.items()
|
|
679
|
+
for w in ws.split() for s in _stems(w)}
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
def _unsaid(stems: set[str], text: str) -> set[str]:
|
|
683
|
+
"""``stems`` that ``text`` doesn't say: neither as words nor, for a property, by comparing along its axis."""
|
|
684
|
+
axes = {c[0] for c in _comparisons_in(text) if c[0]}
|
|
685
|
+
return {s for s in stems - _stems(text) if _PROPERTY_AXIS.get(s) not in axes}
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
def _subjects_at(stmt: str, axes: set[str]) -> set[str]:
|
|
689
|
+
"""What a statement's comparisons along ``axes`` are about: "no passenger route is longer than 26 km" gives
|
|
690
|
+
{passenger, route} for length; "nothing worth more" nothing. A bound ("the limit is at most 49 kg") is not one."""
|
|
691
|
+
words = [w for w in re.findall(r"[a-z]+|\d[\d.,]*", stmt.lower()) if w not in _COPULAS | _MEASURED_BY]
|
|
692
|
+
return set().union(*(_modifiers(words, j) for j, w in enumerate(words) if w in _DIRECTION_OF
|
|
693
|
+
and _DIRECTION_OF[w][0] in axes and words[j - 1:j] != ["at"]))
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
def _kinds_named(stmt: str) -> set[str]:
|
|
697
|
+
"""The kinds a statement names for what it is about: the words before its comparison ("no passenger route is
|
|
698
|
+
longer" gives {passenger, route}) and before a plural in a phrase that says what it ranges over ("among the 3
|
|
699
|
+
passenger routes" gives {passenger}; "the recorded weights" and "the limit applies" name nothing it ranges over)."""
|
|
700
|
+
said = re.findall(r"[a-z]+|\d[\d.,]*", stmt.lower())
|
|
701
|
+
out = _subject_of(stmt)
|
|
702
|
+
for i, w in enumerate(said):
|
|
703
|
+
if not (w.endswith("s") and not w.endswith("ss") and L.content_words(w)):
|
|
704
|
+
continue
|
|
705
|
+
mods = _modifiers(said, i)
|
|
706
|
+
j = i - 1
|
|
707
|
+
while j >= 0 and L.content_words(said[j]) & mods:
|
|
708
|
+
j -= 1
|
|
709
|
+
while j >= 0 and (said[j] in _DETERMINERS or said[j][0].isdigit()):
|
|
710
|
+
j -= 1
|
|
711
|
+
if j >= 0 and said[j] in _PREPOSITIONS:
|
|
712
|
+
out |= mods
|
|
713
|
+
return out
|
|
714
|
+
|
|
715
|
+
|
|
555
716
|
def _subject_fit(stmt: str, m: dict) -> tuple[bool, bool]:
|
|
556
717
|
"""Is a count about what a claim is about? Returns (covers, apart). A count names what it counts in the plural
|
|
557
718
|
("cargo routes", "fitting selections"); where the statement uses that word too, the words right before it on each
|
|
@@ -559,7 +720,12 @@ def _subject_fit(stmt: str, m: dict) -> tuple[bool, bool]:
|
|
|
559
720
|
statement names too: none of 3 cargo routes longer than 26 km says nothing of passenger routes, nor of every route
|
|
560
721
|
(audit HG-024-02). They are apart if each names a kind the other doesn't (cargo, passenger); a count of all routes
|
|
561
722
|
with one longer may still be about the passenger route. A count that names nothing the statement does is read as
|
|
562
|
-
before.
|
|
723
|
+
before.
|
|
724
|
+
|
|
725
|
+
The same holds for what a count names before its comparison, singular or plural: "cargo route longer than 26 km"
|
|
726
|
+
and "cargo longer than 26 km" are of cargo routes, and back no claim about passenger routes (audit HG-025-01). A
|
|
727
|
+
count whose subject the statement doesn't name at all ("speed above 26" against a claim about length) neither backs
|
|
728
|
+
nor refutes it."""
|
|
563
729
|
said = re.findall(r"[a-z]+", stmt.lower())
|
|
564
730
|
stems = [L.content_words(w) for w in said]
|
|
565
731
|
about = set().union(*stems) if stems else set()
|
|
@@ -576,6 +742,21 @@ def _subject_fit(stmt: str, m: dict) -> tuple[bool, bool]:
|
|
|
576
742
|
theirs = set().union(*(_modifiers(said, j) for j, s in enumerate(stems) if s & head)) - mine
|
|
577
743
|
covers = covers and not kinds
|
|
578
744
|
apart = apart or bool(kinds and theirs)
|
|
745
|
+
parts = [_subject_parts(str(m.get(f) or "")) for f in ("name", "key")]
|
|
746
|
+
head, mods = parts[0][0] | parts[1][0], parts[0][1] | parts[1][1]
|
|
747
|
+
if head:
|
|
748
|
+
subject = head | mods
|
|
749
|
+
if not _unsaid(head, stmt): # the statement says the count's head: its other words must be said too
|
|
750
|
+
kinds = _unsaid(mods, stmt)
|
|
751
|
+
theirs = set().union(*(_modifiers(said, j) for j, s in enumerate(stems) if s & head)) - subject
|
|
752
|
+
apart = apart or bool(kinds and theirs)
|
|
753
|
+
else: # a head the statement doesn't say only matters where it names a kind itself
|
|
754
|
+
named = _kinds_named(stmt)
|
|
755
|
+
kinds = _unsaid(subject, stmt) if named else set()
|
|
756
|
+
axes = {c[0] for f in ("name", "key") for c in _comparisons_in(str(m.get(f) or "").replace("_", " "))}
|
|
757
|
+
theirs = _subjects_at(stmt, axes)
|
|
758
|
+
apart = apart or bool(theirs and not theirs & subject)
|
|
759
|
+
covers = covers and not kinds
|
|
579
760
|
return covers, apart
|
|
580
761
|
|
|
581
762
|
|
|
@@ -598,6 +779,15 @@ def _absolutes(stmt: str, scope: str, body: dict, bound: list) -> list[Problem]:
|
|
|
598
779
|
if (tuple(group), _ALL.match(w) is None) in seen:
|
|
599
780
|
continue
|
|
600
781
|
seen.add((tuple(group), _ALL.match(w) is None))
|
|
782
|
+
if group[0] is MIXED:
|
|
783
|
+
p = Problem("ABSOLUTE_WITHOUT_COUNT", f"'{w}' rules on comparisons joined by both 'and' and 'or': "
|
|
784
|
+
"counts of each comparison on its own can't settle that either way, and no count can be "
|
|
785
|
+
"tied to the whole condition. Split it into claims that each join their comparisons one "
|
|
786
|
+
"way (audit HG-026-02)",
|
|
787
|
+
fix="split the claim into clauses that each join their comparisons one way", words=words)
|
|
788
|
+
if p.text() not in {q.text() for q in out}:
|
|
789
|
+
out.append(p)
|
|
790
|
+
continue
|
|
601
791
|
got = [_absolute(stmt, scope, body, bound, w, words, set(figs), set(comps)) for figs, comps in group]
|
|
602
792
|
if len(group) > 1: # ruled out together: none of one part means none of both
|
|
603
793
|
if any(not g for g in got):
|
|
@@ -719,8 +909,7 @@ def _denied(after: str) -> bool:
|
|
|
719
909
|
|
|
720
910
|
# a count named for what lies beyond a figure ("fitting selections worth more", "shorter routes connecting") is about
|
|
721
911
|
# any extreme the statement claims, whatever words the statement uses for it ("the highest total value is 99")
|
|
722
|
-
_BEYOND = re.compile(r"\b(?:
|
|
723
|
-
r"larger|smaller|above|below|exceed\w*|beat\w*)\b", re.I)
|
|
912
|
+
_BEYOND = re.compile(r"\b(?:" + L.CMP_WORDS + r"|above|below|exceed\w*|beat\w*)\b", re.I)
|
|
724
913
|
|
|
725
914
|
|
|
726
915
|
def _extremes(stmt: str) -> list[str]:
|
|
@@ -1477,7 +1666,7 @@ def claim_issues(s: Snap, body: dict, support: list[str], inv: str) -> list[Prob
|
|
|
1477
1666
|
if kind in ("finding", "exclusion", "inconclusive") and not support:
|
|
1478
1667
|
problems.append(Problem("EVIDENCE_MISSING", "link the evidence: at least one result, claim or source that "
|
|
1479
1668
|
"supports it (links: {\"rel\": \"supports\", \"from\": <result id>, \"why\": …})"))
|
|
1480
|
-
bound, bad = _bound(s, body.get("measurements") or [])
|
|
1669
|
+
bound, bad = _bound(s, body.get("measurements") or [], stmt)
|
|
1481
1670
|
problems += bad
|
|
1482
1671
|
clean = _DATE.sub(" ", _LABEL.sub(" ", stmt))
|
|
1483
1672
|
plain, stat = derived_numbers(bound)
|