hypgraph 0.7.6__tar.gz → 0.7.7__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.
Files changed (98) hide show
  1. {hypgraph-0.7.6 → hypgraph-0.7.7}/CHANGELOG.md +8 -0
  2. {hypgraph-0.7.6 → hypgraph-0.7.7}/PKG-INFO +1 -1
  3. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/__init__.py +1 -1
  4. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/cli.py +3 -0
  5. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/server.py +29 -5
  6. hypgraph-0.7.7/tests/test_server_hosts.py +65 -0
  7. {hypgraph-0.7.6 → hypgraph-0.7.7}/.gitignore +0 -0
  8. {hypgraph-0.7.6 → hypgraph-0.7.7}/AGENTS.md +0 -0
  9. {hypgraph-0.7.6 → hypgraph-0.7.7}/CITATION.cff +0 -0
  10. {hypgraph-0.7.6 → hypgraph-0.7.7}/LICENSE +0 -0
  11. {hypgraph-0.7.6 → hypgraph-0.7.7}/NOTICE +0 -0
  12. {hypgraph-0.7.6 → hypgraph-0.7.7}/README.md +0 -0
  13. {hypgraph-0.7.6 → hypgraph-0.7.7}/docs/PLAN.md +0 -0
  14. {hypgraph-0.7.6 → hypgraph-0.7.7}/docs/decisions/ADR-001-token-bound-authors.md +0 -0
  15. {hypgraph-0.7.6 → hypgraph-0.7.7}/docs/decisions/ADR-002-governance-profiles.md +0 -0
  16. {hypgraph-0.7.6 → hypgraph-0.7.7}/docs/profile-workflows-plan.md +0 -0
  17. {hypgraph-0.7.6 → hypgraph-0.7.7}/docs/review-2026-10-24.md +0 -0
  18. {hypgraph-0.7.6 → hypgraph-0.7.7}/docs/site-plan.md +0 -0
  19. {hypgraph-0.7.6 → hypgraph-0.7.7}/docs/spec.md +0 -0
  20. {hypgraph-0.7.6 → hypgraph-0.7.7}/docs/ui-plan.md +0 -0
  21. {hypgraph-0.7.6 → hypgraph-0.7.7}/docs/workflows/README.md +0 -0
  22. {hypgraph-0.7.6 → hypgraph-0.7.7}/docs/workflows/knowledge.md +0 -0
  23. {hypgraph-0.7.6 → hypgraph-0.7.7}/docs/workflows/optimization.md +0 -0
  24. {hypgraph-0.7.6 → hypgraph-0.7.7}/docs/workflows/scientific.md +0 -0
  25. {hypgraph-0.7.6 → hypgraph-0.7.7}/docs/workflows/software.md +0 -0
  26. {hypgraph-0.7.6 → hypgraph-0.7.7}/docs/workflows/trading.md +0 -0
  27. {hypgraph-0.7.6 → hypgraph-0.7.7}/pyproject.toml +0 -0
  28. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/__main__.py +0 -0
  29. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/bundle.py +0 -0
  30. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/checks.py +0 -0
  31. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/coord.py +0 -0
  32. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/demos/__init__.py +0 -0
  33. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/demos/broad_street.py +0 -0
  34. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/derive.py +0 -0
  35. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/graph.py +0 -0
  36. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/language.py +0 -0
  37. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/mcp.py +0 -0
  38. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/plan.py +0 -0
  39. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/policy.py +0 -0
  40. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/profiles.py +0 -0
  41. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/refusals.py +0 -0
  42. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/report_check.py +0 -0
  43. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/schema.py +0 -0
  44. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/skill/SKILL.md +0 -0
  45. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/stats.py +0 -0
  46. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/store.py +0 -0
  47. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/ui/__init__.py +0 -0
  48. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/ui/atlas.css +0 -0
  49. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/ui/atlas.js +0 -0
  50. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/ui/hypgraph.css +0 -0
  51. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/ui/hypgraph.js +0 -0
  52. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/ui/hypgraph.svg +0 -0
  53. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/ui/index.html +0 -0
  54. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/ui/vendor/LICENSES.md +0 -0
  55. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/ui/vendor/cose-base.js +0 -0
  56. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/ui/vendor/cytoscape-fcose.js +0 -0
  57. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/ui/vendor/cytoscape.min.js +0 -0
  58. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/ui/vendor/layout-base.js +0 -0
  59. {hypgraph-0.7.6 → hypgraph-0.7.7}/src/hypgraph/workflow.py +0 -0
  60. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_accept_work_kind.py +0 -0
  61. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_bound_support.py +0 -0
  62. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_bundle_telemetry.py +0 -0
  63. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_cancel_releases_lease.py +0 -0
  64. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_cited_and_failed_support.py +0 -0
  65. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_coord.py +0 -0
  66. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_d10.py +0 -0
  67. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_engine.py +0 -0
  68. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_engine_fixes.py +0 -0
  69. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_incremental.py +0 -0
  70. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_link_translate.py +0 -0
  71. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_log_and_check.py +0 -0
  72. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_measure_questions.py +0 -0
  73. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_opposed_answers.py +0 -0
  74. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_option_lead.py +0 -0
  75. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_order_detail.py +0 -0
  76. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_profiles.py +0 -0
  77. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_profiles_041.py +0 -0
  78. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_questions_not_assertions.py +0 -0
  79. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_refusal_friction.py +0 -0
  80. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_refusal_results.py +0 -0
  81. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_refusals.py +0 -0
  82. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_relation_words.py +0 -0
  83. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_report_answers.py +0 -0
  84. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_rerunnable.py +0 -0
  85. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_restates_scale.py +0 -0
  86. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_server_auth.py +0 -0
  87. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_shape_refusals.py +0 -0
  88. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_stats_not_backtests.py +0 -0
  89. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_stats_values.py +0 -0
  90. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_surfaces.py +0 -0
  91. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_telemetry_stream.py +0 -0
  92. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_ui_app.py +0 -0
  93. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_ui_engine.py +0 -0
  94. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_uncorrected_effect.py +0 -0
  95. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_unnamed_inputs.py +0 -0
  96. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_versions_not_figures.py +0 -0
  97. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_vocabulary_friction.py +0 -0
  98. {hypgraph-0.7.6 → hypgraph-0.7.7}/tests/test_workflows.py +0 -0
@@ -1,4 +1,12 @@
1
1
  # Changelog
2
+
3
+ ## 0.7.7 — 2026-10-29: `hypgraph serve` inside a container
4
+
5
+ - **`hypgraph serve` bound to `0.0.0.0` answered 421 to everyone.** Its Host check knew only the bind address,
6
+ which no browser sends: inside a container with a published port, every request arrives as
7
+ `Host: 127.0.0.1:<host port>` and was refused as a possible DNS rebinding. A wildcard bind now accepts the
8
+ loopback names (the port was never part of the check), and `--allow-host NAME` (repeatable; `allow_hosts=` on
9
+ `make_server` / `serve`) adds a LAN or service name. A wildcard bind still never means "any Host".
2
10
 
3
11
  ## 0.7.6 — 2026-10-29: the swarm as swimlanes, and the UI walked on a real record
4
12
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: hypgraph
3
- Version: 0.7.6
3
+ Version: 0.7.7
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/
@@ -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.6"
19
+ __version__ = "0.7.7"
20
20
 
21
21
  from .bundle import verify_bundle # noqa: E402
22
22
  from .graph import Author, Graph, GraphError, file_sha256 # noqa: E402
@@ -425,6 +425,7 @@ def cmd_serve(args) -> int:
425
425
  if tokens and not args.writable:
426
426
  print("note: --token only matters with --writable (reads are open)")
427
427
  serve(args.db, host=args.host, port=args.port, writable=args.writable, open_browser=not args.no_browser,
428
+ allow_hosts=tuple(args.allow_host or ()),
428
429
  tokens=tokens or None, telemetry=(args.telemetry or "auto") if not args.no_telemetry else None)
429
430
  return 0
430
431
 
@@ -537,6 +538,8 @@ def build_parser() -> argparse.ArgumentParser:
537
538
  s = cmd("serve", cmd_serve, "the HypGraph UI and JSON API on localhost")
538
539
  s.add_argument("--host", default="127.0.0.1")
539
540
  s.add_argument("--port", type=int, default=8765)
541
+ s.add_argument("--allow-host", action="append", metavar="NAME",
542
+ help="a Host header name to answer to besides loopback (a LAN or service name); repeatable")
540
543
  s.add_argument("--writable", action="store_true", help="also accept writes (POST /api/graph/write)")
541
544
  s.add_argument("--no-browser", action="store_true")
542
545
  s.add_argument("--telemetry", default="", metavar="FILE",
@@ -236,6 +236,28 @@ def read_telemetry(path: Path | None, after: int = 0, inv: str = "", limit: int
236
236
  return out, after + end + 1
237
237
 
238
238
 
239
+ LOOPBACK_NAMES = frozenset({"localhost", "127.0.0.1", "::1"})
240
+ WILDCARD_BINDS = frozenset({"", "0.0.0.0", "::", "*"})
241
+
242
+
243
+ def accepted_hosts(host: str, allow_hosts: tuple[str, ...] | list[str] = ()) -> set[str]:
244
+ """The names a request's Host header may carry (port ignored); anything else is 421.
245
+
246
+ Bound to a loopback name, the server answers to every loopback name. Bound to a wildcard (``0.0.0.0``,
247
+ ``::``) — as inside a container whose port is published — it answers to the loopback names too, since the
248
+ browser reaches the published port as ``127.0.0.1:<host port>``; the bind address itself is never a name a
249
+ browser sends. ``allow_hosts`` adds names: a LAN hostname, a service name. The check is DNS-rebinding
250
+ defence (a page on another origin can't make the browser talk to this server by name), so a wildcard bind
251
+ never means "any Host"."""
252
+ names = {h.strip().lower() for h in allow_hosts if h and h.strip()}
253
+ h = (host or "").strip().lower()
254
+ if h in LOOPBACK_NAMES or h in WILDCARD_BINDS:
255
+ names |= LOOPBACK_NAMES
256
+ if h and h not in WILDCARD_BINDS:
257
+ names.add(h)
258
+ return names
259
+
260
+
239
261
  def make_handler(g: Graph, *, writable: bool, hosts: set[str], root: Path,
240
262
  tokens: dict[str, frozenset] | None = None, telemetry: Path | None = None):
241
263
  class Handler(BaseHTTPRequestHandler):
@@ -389,7 +411,8 @@ def make_handler(g: Graph, *, writable: bool, hosts: set[str], root: Path,
389
411
 
390
412
 
391
413
  def make_server(graph: Graph | str, host: str = "127.0.0.1", port: int = 8765, *, writable: bool = False,
392
- tokens: dict[str, frozenset] | None = None, telemetry: str | Path | None = "auto"):
414
+ tokens: dict[str, frozenset] | None = None, telemetry: str | Path | None = "auto",
415
+ allow_hosts: tuple[str, ...] | list[str] = ()):
393
416
  """``telemetry``: the swarm's sidecar to serve and stream — "auto" is ``<db>.telemetry.jsonl`` beside the record
394
417
  (it may appear later: a run started after the server is picked up), a path, or None for none."""
395
418
  g = graph if isinstance(graph, Graph) else Graph(graph)
@@ -399,19 +422,20 @@ def make_server(graph: Graph | str, host: str = "127.0.0.1", port: int = 8765, *
399
422
  tel = Path(g.path + ".telemetry.jsonl")
400
423
  elif telemetry:
401
424
  tel = Path(telemetry)
402
- hosts = {host.lower(), "localhost", "127.0.0.1", "::1"} if host in ("127.0.0.1", "localhost", "::1") else \
403
- {host.lower()}
425
+ hosts = accepted_hosts(host, allow_hosts)
404
426
  root = static_dir().resolve()
405
427
  return ThreadingHTTPServer((host, port), make_handler(g, writable=writable, hosts=hosts, root=root, tokens=tokens,
406
428
  telemetry=tel))
407
429
 
408
430
 
409
431
  def serve(db: str, host: str = "127.0.0.1", port: int = 8765, *, writable: bool = False,
410
- open_browser: bool = True, tokens: dict[str, frozenset] | None = None, telemetry: str | None = "auto") -> None:
432
+ open_browser: bool = True, tokens: dict[str, frozenset] | None = None, telemetry: str | None = "auto",
433
+ allow_hosts: tuple[str, ...] | list[str] = ()) -> None:
411
434
  if not Path(db).exists():
412
435
  print(f"{db} doesn't exist yet — `hypgraph demo` builds one to explore, `hypgraph init` starts your own.")
413
436
  return
414
- srv = make_server(db, host, port, writable=writable, tokens=tokens, telemetry=telemetry)
437
+ srv = make_server(db, host, port, writable=writable, tokens=tokens, telemetry=telemetry,
438
+ allow_hosts=allow_hosts)
415
439
  url = f"http://{host}:{srv.server_address[1]}/"
416
440
  auth = f", {len(tokens)} write token(s)" if tokens else (", writes unauthenticated" if writable else "")
417
441
  tel = telemetry if telemetry not in ("auto", None) else (db + ".telemetry.jsonl" if telemetry == "auto" else "")
@@ -0,0 +1,65 @@
1
+ """Which Host headers `serve` answers to. Bound to loopback: loopback names. Bound to a wildcard (a container
2
+ with a published port): loopback names too — the browser reaches the published port as 127.0.0.1:<host port>, and
3
+ the bind address is never a name a browser sends. Anything else is 421, unless --allow-host names it."""
4
+ import threading
5
+ import urllib.error
6
+ import urllib.request
7
+
8
+ import pytest
9
+
10
+ from hypgraph import Graph
11
+ from hypgraph.server import accepted_hosts, make_server
12
+
13
+
14
+ def _get(url, host_header):
15
+ req = urllib.request.Request(f"{url}/api/graph/investigations", headers={"Host": host_header})
16
+ try:
17
+ with urllib.request.urlopen(req) as r:
18
+ return r.status
19
+ except urllib.error.HTTPError as e:
20
+ return e.code
21
+
22
+
23
+ @pytest.fixture
24
+ def serve_on(tmp_path):
25
+ servers = []
26
+
27
+ def start(host, **kw):
28
+ g = Graph(str(tmp_path / f"{len(servers)}.hypgraph"))
29
+ srv = make_server(g, host, port=0, **kw)
30
+ threading.Thread(target=srv.serve_forever, daemon=True).start()
31
+ servers.append(srv)
32
+ return f"http://127.0.0.1:{srv.server_address[1]}"
33
+
34
+ yield start
35
+ for srv in servers:
36
+ srv.shutdown()
37
+
38
+
39
+ def test_accepted_hosts_rules():
40
+ assert accepted_hosts("127.0.0.1") == {"127.0.0.1", "localhost", "::1"}
41
+ assert accepted_hosts("0.0.0.0") == {"127.0.0.1", "localhost", "::1"} # the bind address is not a name
42
+ assert accepted_hosts("::") == {"127.0.0.1", "localhost", "::1"}
43
+ assert accepted_hosts("lab.local") == {"lab.local"} # a real name: that name only
44
+ assert accepted_hosts("0.0.0.0", ["Swarm.Internal", " "]) == {"127.0.0.1", "localhost", "::1", "swarm.internal"}
45
+
46
+
47
+ def test_loopback_bind_answers_loopback_names_and_refuses_others(serve_on):
48
+ url = serve_on("127.0.0.1")
49
+ assert _get(url, "127.0.0.1:9") == 200 # the port is not part of the check
50
+ assert _get(url, "localhost") == 200
51
+ assert _get(url, "evil.example") == 421
52
+
53
+
54
+ def test_wildcard_bind_answers_loopback_through_a_published_port(serve_on):
55
+ url = serve_on("0.0.0.0")
56
+ assert _get(url, "127.0.0.1:8100") == 200 # the host side of a container's published port
57
+ assert _get(url, "localhost:8100") == 200
58
+ assert _get(url, "0.0.0.0:8000") == 421 # no browser sends the bind address; a rebinding page might
59
+ assert _get(url, "evil.example") == 421
60
+
61
+
62
+ def test_allow_host_adds_a_name(serve_on):
63
+ url = serve_on("0.0.0.0", allow_hosts=["swarm.internal"])
64
+ assert _get(url, "swarm.internal:8000") == 200
65
+ assert _get(url, "other.internal") == 421
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes