Stevesolun commited on
Commit
f144fc4
·
verified ·
1 Parent(s): 2a7e750

Sync ctx 8e56add (part 3)

Browse files

GitHub commit: 8e56add2dad3382f9427395b1433f8845134d7ae

src/tests/test_bug_smoke_tracker.py CHANGED
@@ -18,6 +18,7 @@ STATUSES = {
18
  "False Positive",
19
  }
20
  FIX_STATUSES = {"Fixed", "Blocked", "Not Started", "N/A"}
 
21
 
22
 
23
  def _tracker_rows() -> list[dict[str, str]]:
@@ -62,6 +63,9 @@ def test_bug_smoke_tracker_has_valid_rows() -> None:
62
  if row["status"] == "Retested Pass":
63
  assert row["fix_status"] == "Fixed"
64
  assert row["retest_evidence"].startswith("PASS:")
 
 
 
65
  if row["status"] == "Blocked/Human Decision":
66
  assert row["owner"] == "Human Owner"
67
  assert row["fix_status"] == "Blocked"
 
18
  "False Positive",
19
  }
20
  FIX_STATUSES = {"Fixed", "Blocked", "Not Started", "N/A"}
21
+ CLOSED_NEXT_ACTION_PREFIX = "Closed;"
22
 
23
 
24
  def _tracker_rows() -> list[dict[str, str]]:
 
63
  if row["status"] == "Retested Pass":
64
  assert row["fix_status"] == "Fixed"
65
  assert row["retest_evidence"].startswith("PASS:")
66
+ assert row["next_action"].startswith(CLOSED_NEXT_ACTION_PREFIX), (
67
+ f"{row['finding_id']} has non-closed next_action"
68
+ )
69
  if row["status"] == "Blocked/Human Decision":
70
  assert row["owner"] == "Human Owner"
71
  assert row["fix_status"] == "Blocked"
src/tests/test_ci_preflight.py CHANGED
@@ -1,9 +1,13 @@
1
  from __future__ import annotations
2
 
 
3
  from pathlib import Path
4
 
 
 
5
  from scripts.ci_preflight import _run_no_test_policy_for_files
6
  from scripts.ci_preflight import Check
 
7
  from scripts.ci_preflight import select_checks
8
 
9
 
@@ -22,6 +26,23 @@ def _names_for(files: list[str], *, profile: str = "pr") -> list[str]:
22
  return [check.name for check in checks]
23
 
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  def test_preflight_runs_docs_gate_for_docs_changes() -> None:
26
  names = _names_for(["docs/index.md"])
27
  tracker_checks = _checks_for(["qa/bug_smoke_status.csv"])
@@ -37,6 +58,7 @@ def test_preflight_runs_docs_gate_for_docs_changes() -> None:
37
  assert "docs strict build" in tracker_names
38
  assert "unit-linux equivalent" not in tracker_names
39
  assert "src/tests/test_bug_smoke_tracker.py" in public_docs_tracker.argv
 
40
 
41
 
42
  def test_preflight_runs_source_gates_for_source_changes() -> None:
@@ -89,6 +111,10 @@ def test_internal_no_test_policy_accepts_dirty_contract_with_tests() -> None:
89
  )
90
 
91
 
 
 
 
 
92
  def test_preflight_pr_profile_runs_package_build_for_source_prs() -> None:
93
  checks, _notes = select_checks(
94
  base_ref="origin/main",
 
1
  from __future__ import annotations
2
 
3
+ import shlex
4
  from pathlib import Path
5
 
6
+ import yaml # type: ignore[import-untyped]
7
+
8
  from scripts.ci_preflight import _run_no_test_policy_for_files
9
  from scripts.ci_preflight import Check
10
+ from scripts.ci_preflight import PUBLIC_DOCS_TRACKER_TESTS
11
  from scripts.ci_preflight import select_checks
12
 
13
 
 
26
  return [check.name for check in checks]
27
 
28
 
29
+ def _workflow_docs_tracker_tests() -> tuple[str, ...]:
30
+ workflow = yaml.safe_load(Path(".github/workflows/test.yml").read_text(encoding="utf-8"))
31
+ steps = workflow["jobs"]["docs-check"]["steps"]
32
+ run = next(
33
+ step["run"] for step in steps if step.get("name") == "Run public docs tracker checks"
34
+ )
35
+ command = " ".join(line.rstrip("\\").strip() for line in run.splitlines() if line.strip())
36
+ argv = shlex.split(command)
37
+
38
+ assert argv[:5] == ["python", "-m", "pytest", "-q", "--no-cov"]
39
+ return tuple(argv[5:])
40
+
41
+
42
+ def test_pr_docs_workflow_tracker_tests_match_preflight() -> None:
43
+ assert _workflow_docs_tracker_tests() == PUBLIC_DOCS_TRACKER_TESTS
44
+
45
+
46
  def test_preflight_runs_docs_gate_for_docs_changes() -> None:
47
  names = _names_for(["docs/index.md"])
48
  tracker_checks = _checks_for(["qa/bug_smoke_status.csv"])
 
58
  assert "docs strict build" in tracker_names
59
  assert "unit-linux equivalent" not in tracker_names
60
  assert "src/tests/test_bug_smoke_tracker.py" in public_docs_tracker.argv
61
+ assert "src/tests/test_dashboard_user_story_tracker.py" in public_docs_tracker.argv
62
 
63
 
64
  def test_preflight_runs_source_gates_for_source_changes() -> None:
 
111
  )
112
 
113
 
114
+ def test_internal_no_test_policy_rejects_metadata_without_diff_context() -> None:
115
+ assert _run_no_test_policy_for_files(["pyproject.toml"], diffs_by_file={}) == 1
116
+
117
+
118
  def test_preflight_pr_profile_runs_package_build_for_source_prs() -> None:
119
  checks, _notes = select_checks(
120
  base_ref="origin/main",
src/tests/test_ctx_monitor.py CHANGED
@@ -3959,6 +3959,8 @@ def test_entity_subgraph_wrapper_matches_extracted_wiki_renderer() -> None:
3959
 
3960
  assert wrapper_html == direct_html
3961
  assert "/wiki/github-api?type=mcp-server" in wrapper_html
 
 
3962
  assert "mcp-server" in wrapper_html
3963
 
3964
 
 
3959
 
3960
  assert wrapper_html == direct_html
3961
  assert "/wiki/github-api?type=mcp-server" in wrapper_html
3962
+ assert '[data-testid="entity-subgraph-node"]' in wrapper_html
3963
+ assert "[data-3d-node-id]" not in wrapper_html
3964
  assert "mcp-server" in wrapper_html
3965
 
3966
 
src/tests/test_ctx_monitor_3type.py CHANGED
@@ -32,7 +32,7 @@ import pytest
32
  sys.path.insert(0, str(Path(__file__).parents[1]))
33
 
34
  from ctx.core import entity_types as _entity_types
35
- from ctx.core.wiki.wiki_packs import write_wiki_base_pack
36
  from ctx.monitor import testing as _mt
37
  from ctx.monitor.services import wiki as _wiki_service
38
 
@@ -182,7 +182,7 @@ class TestWikiIndexEntries:
182
  path = _mt.wiki_entity_path("langgraph", entity_type="harness")
183
  assert path == wiki_3type / "entities" / "harnesses" / "langgraph.md"
184
 
185
- def test_wiki_pack_pages_override_physical_entity_pages(
186
  self,
187
  wiki_3type: Path,
188
  monkeypatch: pytest.MonkeyPatch,
@@ -199,6 +199,17 @@ class TestWikiIndexEntries:
199
  "# Stale Physical Page\n",
200
  encoding="utf-8",
201
  )
 
 
 
 
 
 
 
 
 
 
 
202
  write_wiki_base_pack(
203
  pack_dir=wiki_3type / "wiki-packs" / "base-export-1",
204
  pack_id="base-export-1",
@@ -225,6 +236,14 @@ class TestWikiIndexEntries:
225
  ),
226
  },
227
  )
 
 
 
 
 
 
 
 
228
 
229
  entries = _mt.wiki_index_entries(limit_per_type=None)
230
  slugs = {entry["slug"] for entry in entries}
@@ -235,10 +254,24 @@ class TestWikiIndexEntries:
235
  )
236
  detail = _mt.wiki_entity_detail("python-patterns", entity_type="skill")
237
  search = _mt.search_wiki_entities("merged body", entity_type="skill")
 
 
 
 
 
238
  html = _mt.render_wiki_entity("python-patterns", entity_type="skill")
239
  stats = _mt.wiki_stats()
240
 
241
- assert slugs == {"python-patterns", "github"}
 
 
 
 
 
 
 
 
 
242
  assert service_detail is not None
243
  assert service_detail["frontmatter"]["title"] == "Fresh Pack Page"
244
  assert "Merged wiki pack body" in service_detail["body"]
@@ -246,17 +279,100 @@ class TestWikiIndexEntries:
246
  assert detail["frontmatter"]["title"] == "Fresh Pack Page"
247
  assert "Merged wiki pack body" in detail["body"]
248
  assert [row["slug"] for row in search] == ["python-patterns"]
 
 
 
 
 
 
 
 
249
  assert "Fresh Pack Page" in html
250
  assert "Stale Physical Page" not in html
251
  assert stats == {
252
- "skills": 1,
253
- "agents": 0,
254
- "mcps": 1,
255
- "harnesses": 0,
256
- "total": 2,
257
  "split_known": True,
258
  }
259
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
  def test_wiki_search_indexes_tags_beyond_preview_limit(self, wiki_3type):
261
  page = wiki_3type / "entities" / "skills" / "many-tags.md"
262
  page.write_text(
 
32
  sys.path.insert(0, str(Path(__file__).parents[1]))
33
 
34
  from ctx.core import entity_types as _entity_types
35
+ from ctx.core.wiki.wiki_packs import write_wiki_base_pack, write_wiki_overlay_pack
36
  from ctx.monitor import testing as _mt
37
  from ctx.monitor.services import wiki as _wiki_service
38
 
 
182
  path = _mt.wiki_entity_path("langgraph", entity_type="harness")
183
  assert path == wiki_3type / "entities" / "harnesses" / "langgraph.md"
184
 
185
+ def test_wiki_pack_pages_override_physical_pages_and_include_local_only_pages(
186
  self,
187
  wiki_3type: Path,
188
  monkeypatch: pytest.MonkeyPatch,
 
199
  "# Stale Physical Page\n",
200
  encoding="utf-8",
201
  )
202
+ (wiki_3type / "entities" / "skills" / "manage-created.md").write_text(
203
+ "---\n"
204
+ "title: Manage Created\n"
205
+ "type: skill\n"
206
+ "tags: [local]\n"
207
+ "description: local manage page\n"
208
+ "---\n"
209
+ "# Manage Created\n\n"
210
+ "Local-only Manage-created body.\n",
211
+ encoding="utf-8",
212
+ )
213
  write_wiki_base_pack(
214
  pack_dir=wiki_3type / "wiki-packs" / "base-export-1",
215
  pack_id="base-export-1",
 
236
  ),
237
  },
238
  )
239
+ write_wiki_overlay_pack(
240
+ pack_dir=wiki_3type / "wiki-packs" / "overlay-delete-security-basics",
241
+ pack_id="overlay-delete-security-basics",
242
+ base_export_id="export-1",
243
+ parent_export_id="export-1",
244
+ pages={},
245
+ tombstones=["entities/skills/security-basics.md"],
246
+ )
247
 
248
  entries = _mt.wiki_index_entries(limit_per_type=None)
249
  slugs = {entry["slug"] for entry in entries}
 
254
  )
255
  detail = _mt.wiki_entity_detail("python-patterns", entity_type="skill")
256
  search = _mt.search_wiki_entities("merged body", entity_type="skill")
257
+ local_detail = _mt.wiki_entity_detail("manage-created", entity_type="skill")
258
+ local_search = _mt.search_wiki_entities("local-only manage", entity_type="skill")
259
+ local_html = _mt.render_wiki_entity("manage-created", entity_type="skill")
260
+ tombstoned_detail = _mt.wiki_entity_detail("security-basics", entity_type="skill")
261
+ tombstoned_search = _mt.search_wiki_entities("security-basics", entity_type="skill")
262
  html = _mt.render_wiki_entity("python-patterns", entity_type="skill")
263
  stats = _mt.wiki_stats()
264
 
265
+ assert slugs == {
266
+ "anthropic-python-sdk",
267
+ "atlassian-cloud",
268
+ "code-reviewer",
269
+ "github",
270
+ "langgraph",
271
+ "manage-created",
272
+ "pulsemcp-meta",
273
+ "python-patterns",
274
+ }
275
  assert service_detail is not None
276
  assert service_detail["frontmatter"]["title"] == "Fresh Pack Page"
277
  assert "Merged wiki pack body" in service_detail["body"]
 
279
  assert detail["frontmatter"]["title"] == "Fresh Pack Page"
280
  assert "Merged wiki pack body" in detail["body"]
281
  assert [row["slug"] for row in search] == ["python-patterns"]
282
+ assert local_detail is not None
283
+ assert local_detail["frontmatter"]["title"] == "Manage Created"
284
+ assert "Local-only Manage-created body" in local_detail["body"]
285
+ assert [row["slug"] for row in local_search] == ["manage-created"]
286
+ assert "Manage Created" in local_html
287
+ assert _mt.wiki_entity_path("security-basics", entity_type="skill") is None
288
+ assert tombstoned_detail is None
289
+ assert tombstoned_search == []
290
  assert "Fresh Pack Page" in html
291
  assert "Stale Physical Page" not in html
292
  assert stats == {
293
+ "skills": 2,
294
+ "agents": 1,
295
+ "mcps": 4,
296
+ "harnesses": 1,
297
+ "total": 8,
298
  "split_known": True,
299
  }
300
 
301
+ def test_untyped_pack_read_uses_resolved_local_entity_path(
302
+ self,
303
+ wiki_3type: Path,
304
+ ) -> None:
305
+ _wiki_service.reset_caches()
306
+ (wiki_3type / "entities" / "skills" / "shared-slug.md").write_text(
307
+ "---\n"
308
+ "title: Local Skill\n"
309
+ "type: skill\n"
310
+ "tags: [local]\n"
311
+ "---\n"
312
+ "# Local Skill\n\n"
313
+ "Local skill body.\n",
314
+ encoding="utf-8",
315
+ )
316
+ write_wiki_base_pack(
317
+ pack_dir=wiki_3type / "wiki-packs" / "base-export-1",
318
+ pack_id="base-export-1",
319
+ base_export_id="export-1",
320
+ pages={
321
+ "entities/agents/shared-slug.md": (
322
+ "---\n"
323
+ "title: Packed Agent\n"
324
+ "type: agent\n"
325
+ "tags: [pack]\n"
326
+ "---\n"
327
+ "# Packed Agent\n\n"
328
+ "Packed agent body.\n"
329
+ ),
330
+ },
331
+ )
332
+
333
+ detail = _mt.wiki_entity_detail("shared-slug")
334
+ agent_detail = _mt.wiki_entity_detail("shared-slug", entity_type="agent")
335
+
336
+ assert detail is not None
337
+ assert detail["type"] == "skill"
338
+ assert detail["frontmatter"]["title"] == "Local Skill"
339
+ assert "Local skill body" in detail["body"]
340
+ assert "Packed agent body" not in detail["body"]
341
+ assert agent_detail is not None
342
+ assert agent_detail["type"] == "agent"
343
+ assert agent_detail["frontmatter"]["title"] == "Packed Agent"
344
+
345
+ def test_wiki_entity_page_resolves_type_from_path_for_untyped_non_skill(
346
+ self,
347
+ wiki_3type: Path,
348
+ monkeypatch: pytest.MonkeyPatch,
349
+ ) -> None:
350
+ calls: dict[str, list[tuple[str, str | None]]] = {"sidecar": [], "subgraph": []}
351
+ (wiki_3type / "entities" / "agents" / "untyped-agent.md").write_text(
352
+ "---\ntitle: Untyped Agent\n---\n# Untyped Agent\n\nBody.\n",
353
+ encoding="utf-8",
354
+ )
355
+
356
+ def fake_sidecar(slug: str, entity_type: str | None = None) -> dict[str, Any]:
357
+ calls["sidecar"].append((slug, entity_type))
358
+ return {"grade": "A", "raw_score": 0.91}
359
+
360
+ def fake_subgraph(slug: str, entity_type: str | None = None) -> str:
361
+ calls["subgraph"].append((slug, entity_type))
362
+ return "<div>subgraph</div>"
363
+
364
+ monkeypatch.setattr(_mt, "load_sidecar", fake_sidecar)
365
+ monkeypatch.setattr(_mt, "render_entity_subgraph", fake_subgraph)
366
+
367
+ html = _mt.render_wiki_entity("untyped-agent")
368
+
369
+ assert calls == {
370
+ "sidecar": [("untyped-agent", "agent")],
371
+ "subgraph": [("untyped-agent", "agent")],
372
+ }
373
+ assert "/skill/untyped-agent?type=agent" in html
374
+ assert "/graph?slug=untyped-agent&amp;type=agent" in html
375
+
376
  def test_wiki_search_indexes_tags_beyond_preview_limit(self, wiki_3type):
377
  page = wiki_3type / "entities" / "skills" / "many-tags.md"
378
  page.write_text(
src/tests/test_quality_hook.py CHANGED
@@ -137,7 +137,10 @@ def test_hook_mains_exit_zero_and_dispatch_expected_work(
137
  # Point everything at tmp so no real state is touched.
138
  monkeypatch.setenv("HOME", str(tmp_path))
139
  events = tmp_path / "skill-events.jsonl"
140
- _write_events(events, [{"event": "load", "skill": "demo", "timestamp": _iso(NOW)}])
 
 
 
141
  monkeypatch.setattr(qh, "_EVENTS_PATH", events, raising=True)
142
  monkeypatch.setattr(qh, "_STATE_PATH", tmp_path / "state.json", raising=True)
143
 
@@ -149,6 +152,7 @@ def test_hook_mains_exit_zero_and_dispatch_expected_work(
149
  monkeypatch.setattr("sys.stdin", _StdinStub(""))
150
  rc = qh.main()
151
  assert rc == 0 # hook never propagates errors
 
152
 
153
  current = datetime.now(timezone.utc)
154
  (tmp_path / "state.json").write_text(
 
137
  # Point everything at tmp so no real state is touched.
138
  monkeypatch.setenv("HOME", str(tmp_path))
139
  events = tmp_path / "skill-events.jsonl"
140
+ _write_events(
141
+ events,
142
+ [{"event": "load", "skill": "demo", "timestamp": _iso(datetime.now(timezone.utc))}],
143
+ )
144
  monkeypatch.setattr(qh, "_EVENTS_PATH", events, raising=True)
145
  monkeypatch.setattr(qh, "_STATE_PATH", tmp_path / "state.json", raising=True)
146
 
 
152
  monkeypatch.setattr("sys.stdin", _StdinStub(""))
153
  rc = qh.main()
154
  assert rc == 0 # hook never propagates errors
155
+ assert not (tmp_path / "state.json").exists()
156
 
157
  current = datetime.now(timezone.utc)
158
  (tmp_path / "state.json").write_text(