fd-open-data-protocol 0.5.4__tar.gz → 0.5.6__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 (49) hide show
  1. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/PKG-INFO +1 -1
  2. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol/__init__.py +1 -1
  3. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol/line_ops/wellknown.py +10 -8
  4. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol/surface_selfcheck.py +6 -1
  5. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol.egg-info/PKG-INFO +1 -1
  6. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/tests/test_line_ops.py +13 -0
  7. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/tests/test_surface_selfcheck.py +16 -0
  8. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/LICENSE +0 -0
  9. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/README.md +0 -0
  10. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol/conformance_adapter.py +0 -0
  11. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol/constants.py +0 -0
  12. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol/line_ops/__init__.py +0 -0
  13. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol/line_ops/assemble.py +0 -0
  14. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol/line_ops/auth_gate.py +0 -0
  15. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol/line_ops/client.py +0 -0
  16. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol/line_ops/config.py +0 -0
  17. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol/loader.py +0 -0
  18. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol/openalex_provider.py +0 -0
  19. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol/provider.py +0 -0
  20. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol/registry.py +0 -0
  21. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol/registry_cli.py +0 -0
  22. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol/registry_store.py +0 -0
  23. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol/schema.py +0 -0
  24. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol/surface_report.py +0 -0
  25. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol/vocabulary/alignment/foundation.yaml +0 -0
  26. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol/vocabulary/concepts.yaml +0 -0
  27. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol/vocabulary/crosswalks/datacommons-worldbank.yaml +0 -0
  28. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol/vocabulary/entity_types.yaml +0 -0
  29. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol/vocabulary/event_types.yaml +0 -0
  30. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol/vocabulary/qualifiers.yaml +0 -0
  31. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol/vocabulary/relation_types.yaml +0 -0
  32. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol/vocabulary/units.yaml +0 -0
  33. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol/vocabulary.py +0 -0
  34. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol.egg-info/SOURCES.txt +0 -0
  35. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol.egg-info/dependency_links.txt +0 -0
  36. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol.egg-info/entry_points.txt +0 -0
  37. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol.egg-info/requires.txt +0 -0
  38. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/fd_open_data_protocol.egg-info/top_level.txt +0 -0
  39. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/pyproject.toml +0 -0
  40. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/setup.cfg +0 -0
  41. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/tests/test_drift_inventory.py +0 -0
  42. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/tests/test_loader.py +0 -0
  43. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/tests/test_openalex_provider.py +0 -0
  44. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/tests/test_registry_pipeline.py +0 -0
  45. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/tests/test_registry_schema.py +0 -0
  46. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/tests/test_schema_vocabulary.py +0 -0
  47. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/tests/test_surface_report.py +0 -0
  48. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/tests/test_vocabulary.py +0 -0
  49. {fd_open_data_protocol-0.5.4 → fd_open_data_protocol-0.5.6}/tests/test_vocabulary_additive.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fd-open-data-protocol
3
- Version: 0.5.4
3
+ Version: 0.5.6
4
4
  Summary: The open-data datasource protocol: a manifest contract a datasource exposes to be ingested by fd-open-data-mcp (or any consumer).
5
5
  Author: FindDataOfficial
6
6
  License: MIT
@@ -5,4 +5,4 @@ concept hints + fetch reference) so that fd-open-data-mcp - or any consumer -
5
5
  can ingest it via ``register_datasource``. Ship one manifest file -> the
6
6
  datasource is added; no consumer-side wiring.
7
7
  """
8
- __version__ = "0.5.4"
8
+ __version__ = "0.5.6"
@@ -15,7 +15,7 @@ LINE_MANIFEST_ENV = "LINE_MANIFEST_PATH"
15
15
  MANIFEST_CACHE_CONTROL = "public, max-age=300"
16
16
 
17
17
 
18
- def manifest_candidates(anchor: Path | str | None = None) -> list[Path]:
18
+ def manifest_candidates(anchor: Path | str | None = None, *, up: tuple[int, ...] = (1,)) -> list[Path]:
19
19
  """按优先级列出可能放清单的位置(`LINE_MANIFEST_PATH` 一项即封顶)。
20
20
 
21
21
  为什么要链而不是一条:**pip 装进去的包与源码树的 `__file__` 不同**。镜像是
@@ -33,29 +33,31 @@ def manifest_candidates(anchor: Path | str | None = None) -> list[Path]:
33
33
  return [Path(override)]
34
34
  here = Path(anchor).resolve() if anchor is not None else Path(__file__).resolve()
35
35
  return [
36
- here.parents[1] / "line-manifest.json", # 源码树 / 镜像里包与清单同根
36
+ # Flat layout uses parents[1]; a src/ layout (e.g. paper-trading) needs
37
+ # parents[2] because parents[1] is `src/`. Consumers name their depth.
38
+ *(here.parents[n] / "line-manifest.json" for n in up),
37
39
  Path.cwd() / "line-manifest.json", # pip 装的包:CWD 才是仓根
38
40
  here.parent / "line-manifest.json", # 清单与包同级(兜底)
39
41
  ]
40
42
 
41
43
 
42
- def manifest_path(anchor: Path | str | None = None) -> Path:
44
+ def manifest_path(anchor: Path | str | None = None, *, up: tuple[int, ...] = (1,)) -> Path:
43
45
  """实际取用的清单路径;都不存在时返回首选位置(让 404 能点名期望路径)。"""
44
- candidates = manifest_candidates(anchor)
46
+ candidates = manifest_candidates(anchor, up=up)
45
47
  for candidate in candidates:
46
48
  if candidate.exists():
47
49
  return candidate
48
50
  return candidates[0]
49
51
 
50
52
 
51
- def manifest_response(anchor: Path | str | None = None) -> tuple[int, bytes, list[tuple[bytes, bytes]]]:
53
+ def manifest_response(anchor: Path | str | None = None, *, up: tuple[int, ...] = (1,)) -> tuple[int, bytes, list[tuple[bytes, bytes]]]:
52
54
  """(status, body, extra_headers) —— 不读网络、不建会话。
53
55
 
54
56
  缺失=404(该线未发布清单,属配置事实);存在但不可解析=500(属缺陷,不能
55
57
  伪装成 404 让调用方以为「本来就没有」)。
56
58
  """
57
59
  json_headers = [(b"content-type", b"application/json; charset=utf-8")]
58
- path = manifest_path(anchor)
60
+ path = manifest_path(anchor, up=up)
59
61
  try:
60
62
  raw = path.read_bytes()
61
63
  except FileNotFoundError:
@@ -72,7 +74,7 @@ def manifest_response(anchor: Path | str | None = None) -> tuple[int, bytes, lis
72
74
  ]
73
75
 
74
76
 
75
- def register(mcp, anchor: Path | str | None = None) -> None:
77
+ def register(mcp, anchor: Path | str | None = None, *, up: tuple[int, ...] = (1,)) -> None:
76
78
  """Mount the endpoint on a FastMCP instance (stdio has no HTTP face, so skip).
77
79
 
78
80
  ``custom_route`` is used rather than wrapping ASGI so the route exists in
@@ -87,7 +89,7 @@ def register(mcp, anchor: Path | str | None = None) -> None:
87
89
  from starlette.responses import Response # only the HTTP branch needs it
88
90
 
89
91
  def _response() -> "Response":
90
- status, body, extra = manifest_response(anchor)
92
+ status, body, extra = manifest_response(anchor, up=up)
91
93
  headers = {k.decode(): v.decode() for k, v in extra}
92
94
  return Response(
93
95
  content=body,
@@ -92,11 +92,16 @@ def _levels(manifest: dict) -> tuple[dict[str, str], list[str]]:
92
92
 
93
93
 
94
94
  def _declared_fallback(manifest: dict) -> set[str]:
95
- """旧形状 `tools: [{name}]` 的声明集(只有本模块的甲臂会用到,判不出时不使用)。"""
95
+ """声明集:`tools: [{name}]` 或只列 `tool_annotations` 的旧形状。
96
+
97
+ 只列注解的 manifest(如 fd-info)没有 tool_groups;把注解键当作声明集,
98
+ 否则共享驱动会把运行时工具全部误判为「manifest 未声明」。
99
+ """
96
100
  out = set()
97
101
  for t in manifest.get("tools", []) or []:
98
102
  if isinstance(t, dict) and t.get("name"):
99
103
  out.add(t["name"])
104
+ out.update((manifest.get("tool_annotations") or {}).keys())
100
105
  return out
101
106
 
102
107
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fd-open-data-protocol
3
- Version: 0.5.4
3
+ Version: 0.5.6
4
4
  Summary: The open-data datasource protocol: a manifest contract a datasource exposes to be ingested by fd-open-data-mcp (or any consumer).
5
5
  Author: FindDataOfficial
6
6
  License: MIT
@@ -238,3 +238,16 @@ def test_register_supports_a_fastapi_style_app(tmp_path):
238
238
  wellknown.register(app, anchor=anchor)
239
239
  response = asyncio.run(app.routes[wellknown.WELL_KNOWN_PATH]())
240
240
  assert response.status_code == 200
241
+
242
+
243
+ def test_src_layout_uses_a_deeper_parent(tmp_path, monkeypatch):
244
+ """src 布局(src/pkg/wellknown.py)的仓根是 parents[2],由消费仓显式声明。"""
245
+ from fd_open_data_protocol.line_ops import wellknown
246
+
247
+ monkeypatch.delenv(wellknown.LINE_MANIFEST_ENV, raising=False)
248
+ repo = tmp_path / "repo"
249
+ (repo / "src" / "pkg").mkdir(parents=True)
250
+ (repo / "line-manifest.json").write_text("{}")
251
+ anchor = repo / "src" / "pkg" / "wellknown.py"
252
+ anchor.write_text("")
253
+ assert wellknown.manifest_path(anchor, up=(2,)) == repo / "line-manifest.json"
@@ -127,3 +127,19 @@ def test_ceiling_breach_fails():
127
127
  r = evaluate(repo="x", manifest=m, runtime={"a", "b"}, runtime_error=None,
128
128
  ceilings={"commercial_nonreadonly": 1})
129
129
  assert r.code == 1 and any("基线上限" in p for p in r.problems)
130
+
131
+
132
+ def test_declared_fallback_accepts_tool_annotations_only_manifests():
133
+ """只列 tool_annotations 的 manifest(fd-info 形状)也能被共享驱动读懂。"""
134
+ from fd_open_data_protocol.surface_selfcheck import evaluate
135
+
136
+ r = evaluate(
137
+ repo="x",
138
+ manifest={"tool_annotations": {"read": {"readOnlyHint": True,
139
+ "destructiveHint": False,
140
+ "idempotentHint": True,
141
+ "openWorldHint": False}}},
142
+ runtime={"read"},
143
+ runtime_error=None,
144
+ )
145
+ assert r.code == 0, (r.problems, r.undecidable)