doubled-graph 3.1.1__tar.gz → 3.1.3__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.
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/PKG-INFO +1 -1
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/pyproject.toml +1 -1
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/integrations/graphd.py +8 -1
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/integrations/service.py +26 -1
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/setup.py +62 -4
- doubled_graph-3.1.3/tests/launchd_stub/fake_launchctl.py +272 -0
- doubled_graph-3.1.3/tests/launchd_stub/launchctl +14 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_cli_daemon.py +127 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_graphd_client.py +10 -1
- doubled_graph-3.1.3/tests/test_service_start_fallback.py +85 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_setup_coverage.py +41 -0
- doubled_graph-3.1.3/tests/test_setup_launchd_e2e.py +268 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/.gitignore +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/ARTICLE.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/INDEX.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/LICENSE +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/README.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/for-ai-existing-project/README.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/for-ai-maintenance/README.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/for-ai-new-project/README.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/for-humans/FAQ.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/for-humans/deep-dive.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/for-humans/getting-started.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/methodology/README.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/methodology/approval-checkpoints.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/methodology/artifacts.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/methodology/auto-scaling.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/methodology/ci-templates/github-actions.yml +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/methodology/ci-templates/gitlab-ci.yml +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/methodology/drift-and-priority.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/methodology/language-adapters/_template.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/methodology/language-adapters/csharp.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/methodology/language-adapters/go.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/methodology/language-adapters/java.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/methodology/language-adapters/python.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/methodology/language-adapters/rust.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/methodology/language-adapters/swift.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/methodology/language-adapters/typescript.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/methodology/principles.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/methodology/roles.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/methodology/runtime-adapters/_template.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/methodology/runtime-adapters/claude-code.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/methodology/runtime-adapters/codex.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/methodology/runtime-adapters/continue.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/methodology/runtime-adapters/cursor.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/methodology/runtime-adapters/local-llm.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/methodology/runtime-adapters/windsurf.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/methodology/tools.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/methodology/workflow.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/prompts/maintenance/on-after-edit.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/prompts/maintenance/on-before-edit.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/prompts/maintenance/on-drift-detected.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/prompts/maintenance/on-user-manual-edit.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/prompts/migrate-existing-project/00-entry-prompt.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/prompts/migrate-existing-project/01-discover.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/prompts/migrate-existing-project/02-reconstruct-intent.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/prompts/migrate-existing-project/03-draft-plan.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/prompts/migrate-existing-project/04-markup-codebase.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/prompts/migrate-existing-project/05-verification-and-logs.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/prompts/migrate-existing-project/06-validation-gates.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/prompts/new-project/00-entry-prompt.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/prompts/new-project/01-intent-interview.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/prompts/new-project/02-requirements.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/prompts/new-project/03-technology.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/prompts/new-project/04-development-plan.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/prompts/new-project/05-verification-plan.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/prompts/new-project/06-generate.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/prompts/new-project/07-post-init-sync.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/prompts/upgrade-methodology/00-entry-prompt.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/prompts/upgrade-methodology/01-content-gaps.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/__init__.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/__main__.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/artifacts_repair.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/cli.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/config.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/contracts.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/daemon/__init__.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/daemon/index_store.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/daemon/main.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/daemon/server.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/data/skills/doubled-graph-after-edit/SKILL.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/data/skills/doubled-graph-before-edit/SKILL.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/data/skills/doubled-graph-drift/SKILL.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/data/skills/doubled-graph-guide/SKILL.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/data/skills/doubled-graph-manual-edit/SKILL.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/data/skills/doubled-graph-refactor/SKILL.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/data/skills/doubled-graph-verify/SKILL.md +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/graphs/__init__.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/graphs/anchors.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/graphs/crossref.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/graphs/declared.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/graphs/grace4.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/health.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/hooks_installer.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/index/__init__.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/index/discovery.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/index/linker.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/index/manifest.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/index/parse_cache.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/index/parser.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/index/snapshot.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/integrations/__init__.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/integrations/cgc.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/integrations/grace_cli.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/migrations/__init__.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/migrations/grace3_to_grace4.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/policy/__init__.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/policy/agents_md.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/policy/phase.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/server.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/storage/__init__.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/storage/paths.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/tools/__init__.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/tools/_meta.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/tools/analyze.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/tools/analyze_sync.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/tools/check_drift.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/tools/context.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/tools/impact.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/tools/index_status.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/tools/post_tool.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/tools/provenance.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/src/doubled_graph/uninstall.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/__init__.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/conftest.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_analyze_sync.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_anchors.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_artifacts_repair.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_bom_support.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_cgc_backend.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_cgc_contract.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_cgc_lifecycle.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_check_drift.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_cli_entrypoint.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_cli_surface.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_command_surface.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_contracts.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_crossref_drift.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_daemon.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_daemon_main.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_declared_coverage.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_doc_contract.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_e2e_acceptance.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_grace4_artifacts.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_grace_cli_coverage.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_grace_cli_engine.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_health.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_hook_public_coverage.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_index_core.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_index_graph.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_index_manifest.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_integration_daemon_cgc.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_mcp_transport.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_mcp_validation.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_migration_coverage.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_migration_grace3_to_grace4.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_mutation_gate_script.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_mutation_kill_cgc_edges.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_mutation_kill_cgc_fallback.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_mutation_kill_cgc_misc.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_mutation_kill_context.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_mutation_kill_crossref.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_mutation_kill_hooks.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_mutation_kill_impact.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_mutation_probes.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_packaging.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_platform_branches.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_protocol_v2.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_provenance.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_release_edges.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_release_script.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_repo_hygiene.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_service.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_setup_artifacts.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_setup_failure_semantics.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_smoke.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_snapshot_oracle.py +0 -0
- {doubled_graph-3.1.1 → doubled_graph-3.1.3}/tests/test_uninstall.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: doubled-graph
|
|
3
|
-
Version: 3.1.
|
|
3
|
+
Version: 3.1.3
|
|
4
4
|
Summary: MCP facade over CodeGraphContext + GRACE 4 (.grace artifacts): impact, context, drift-detect, migration for LLM-driven codebases.
|
|
5
5
|
Project-URL: Homepage, https://github.com/rour/doubled-graph-mcp
|
|
6
6
|
Project-URL: Repository, https://github.com/rour/doubled-graph-mcp
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "doubled-graph"
|
|
7
|
-
version = "3.1.
|
|
7
|
+
version = "3.1.3"
|
|
8
8
|
description = "MCP facade over CodeGraphContext + GRACE 4 (.grace artifacts): impact, context, drift-detect, migration for LLM-driven codebases."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { text = "MIT" }
|
|
@@ -64,7 +64,11 @@ FAST_TIMEOUT_S = 2.0
|
|
|
64
64
|
#: Everything except indexing gets a bounded request timeout, so a wedged
|
|
65
65
|
#: daemon cannot hang an IDE forever.
|
|
66
66
|
DEFAULT_TIMEOUT_S = 60.0
|
|
67
|
-
#: Indexing is explicitly unbounded (§6)
|
|
67
|
+
#: Indexing is explicitly unbounded (§6): a full rebuild of a large repository
|
|
68
|
+
#: routinely outlives ``DEFAULT_TIMEOUT_S``. Capping it made the client abandon
|
|
69
|
+
#: an apply the daemon was still finishing — the graph got written, but the
|
|
70
|
+
#: manifest never advanced, so every retry resent the whole tree. A caller can
|
|
71
|
+
#: still bound it through ``GraphClient(timeouts={"index_apply": N})``.
|
|
68
72
|
INDEXING_TIMEOUT_S: float | None = None
|
|
69
73
|
#: Hard cap on a single JSON frame (a runaway query must not exhaust RAM).
|
|
70
74
|
MAX_MESSAGE_BYTES = 64 * 1024 * 1024
|
|
@@ -640,6 +644,9 @@ class GraphClient:
|
|
|
640
644
|
return self._timeouts[method]
|
|
641
645
|
if method in {"ping", "health"}:
|
|
642
646
|
return FAST_TIMEOUT_S
|
|
647
|
+
if method == "index_apply":
|
|
648
|
+
# ``None`` means "wait as long as the daemon needs" (DAEMON.md §6).
|
|
649
|
+
return INDEXING_TIMEOUT_S
|
|
643
650
|
return DEFAULT_TIMEOUT_S
|
|
644
651
|
|
|
645
652
|
def _roundtrip(
|
|
@@ -532,11 +532,36 @@ class ServiceManager:
|
|
|
532
532
|
# unloaded (after `daemon stop`) must still be startable.
|
|
533
533
|
if not self.unit_present():
|
|
534
534
|
return self._report("not_installed")
|
|
535
|
-
|
|
535
|
+
loaded = self._loaded()
|
|
536
|
+
result = self._kickstart() if loaded else self._bootstrap()
|
|
537
|
+
if not result.ok and loaded:
|
|
538
|
+
# `bootout` can return 0 while launchd still has the job in its
|
|
539
|
+
# table ("stale" job). `kickstart` against that half-unloaded job
|
|
540
|
+
# fails, and a plain retry of `bootstrap` is refused because the
|
|
541
|
+
# job is "already loaded". Drop the stale job first and load the
|
|
542
|
+
# unit from scratch; this is the repair launchd needs.
|
|
543
|
+
first = result
|
|
544
|
+
self._bootout()
|
|
545
|
+
result = self._bootstrap()
|
|
546
|
+
if not result.ok:
|
|
547
|
+
# Name both supervisor refusals: the kickstart failure is the
|
|
548
|
+
# reason the fallback ran, not noise to discard.
|
|
549
|
+
detail = "; ".join(
|
|
550
|
+
part
|
|
551
|
+
for part in dict.fromkeys((first.output, result.output))
|
|
552
|
+
if part
|
|
553
|
+
)
|
|
554
|
+
stderr = "\n".join(
|
|
555
|
+
part
|
|
556
|
+
for part in dict.fromkeys((first.stderr, result.stderr))
|
|
557
|
+
if part
|
|
558
|
+
)
|
|
559
|
+
return self._report("failed", detail=detail, stderr=stderr)
|
|
536
560
|
if not result.ok:
|
|
537
561
|
return self._report("failed", detail=result.output, stderr=result.stderr)
|
|
538
562
|
return self._report("started")
|
|
539
563
|
|
|
564
|
+
|
|
540
565
|
def stop(self) -> dict[str, Any]:
|
|
541
566
|
if not self.unit_present() and not self._loaded():
|
|
542
567
|
return self._report("not_installed")
|
|
@@ -1053,6 +1053,21 @@ def _ensure_agents_anti_patterns(repo: Path, dry_run: bool) -> dict[str, Any]:
|
|
|
1053
1053
|
return ensure_anti_patterns(repo, dry_run=dry_run)
|
|
1054
1054
|
|
|
1055
1055
|
|
|
1056
|
+
def _attempt_cause(report: dict[str, Any]) -> dict[str, Any]:
|
|
1057
|
+
"""The diagnostic part of a failed daemon attempt.
|
|
1058
|
+
|
|
1059
|
+
``restart`` reports the refusal per step; a retry must not throw that away.
|
|
1060
|
+
Kept as plain JSON values so the setup report stays serialisable.
|
|
1061
|
+
"""
|
|
1062
|
+
return {
|
|
1063
|
+
"status": report.get("status"),
|
|
1064
|
+
"failed_steps": list(report.get("failed_steps") or []),
|
|
1065
|
+
"detail": report.get("detail") or "",
|
|
1066
|
+
"stderr": report.get("stderr") or "",
|
|
1067
|
+
"hint": report.get("hint") or "",
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
|
|
1056
1071
|
def _install_daemon_service(repo: Path, dry_run: bool) -> dict[str, Any]:
|
|
1057
1072
|
"""Restart the OS-supervised graph daemon and register this project.
|
|
1058
1073
|
|
|
@@ -1073,6 +1088,12 @@ def _install_daemon_service(repo: Path, dry_run: bool) -> dict[str, Any]:
|
|
|
1073
1088
|
an "ok": the unit may point at another interpreter, or the old process may
|
|
1074
1089
|
still own the state directory.
|
|
1075
1090
|
|
|
1091
|
+
A failed restart is retried once when the supervisor reports no **running**
|
|
1092
|
+
daemon. The condition is ``running``, not ``loaded``, because launchd can
|
|
1093
|
+
keep a stale job loaded after ``bootout`` returned 0; that state used to
|
|
1094
|
+
suppress the retry. Both causes are preserved: the final attempt is the
|
|
1095
|
+
top-level report, the first one is ``retry.first_attempt``.
|
|
1096
|
+
|
|
1076
1097
|
``DOUBLED_GRAPH_NO_SERVICE=1`` is an explicit CI/test escape hatch: the
|
|
1077
1098
|
suite must never touch the developer's real launchd/systemd, and a
|
|
1078
1099
|
sandbox that forbids supervisor commands can still run ``setup`` with
|
|
@@ -1093,6 +1114,7 @@ def _install_daemon_service(repo: Path, dry_run: bool) -> dict[str, Any]:
|
|
|
1093
1114
|
"enable the unit if launchd/systemd has it disabled or masked",
|
|
1094
1115
|
"install/update the unit for this interpreter and --home",
|
|
1095
1116
|
"start (bootstrap) and surface the real supervisor stderr on failure",
|
|
1117
|
+
"retry once when the supervisor has no running daemon (stale job included)",
|
|
1096
1118
|
"wait for the daemon (60 s, backoff)",
|
|
1097
1119
|
"verify daemon.version == client version",
|
|
1098
1120
|
"register repo",
|
|
@@ -1109,10 +1131,24 @@ def _install_daemon_service(repo: Path, dry_run: bool) -> dict[str, Any]:
|
|
|
1109
1131
|
# booted out moments ago, an old unit is still cached). `setup` is the
|
|
1110
1132
|
# designated repair path, so it retries once instead of asking the user
|
|
1111
1133
|
# to run `daemon install` by hand.
|
|
1112
|
-
|
|
1134
|
+
#
|
|
1135
|
+
# The condition is "the supervisor does not report a running daemon",
|
|
1136
|
+
# not "the job is not loaded": `bootout` can return 0 while launchd
|
|
1137
|
+
# keeps the stale job in its table and the process is already dead.
|
|
1138
|
+
# That exact state made 3.1.2 skip the retry and leave the daemon down.
|
|
1139
|
+
status = manager.status()
|
|
1140
|
+
if result.get("status") != "running" and not status.get("running"):
|
|
1141
|
+
first_attempt = _attempt_cause(result)
|
|
1113
1142
|
retried = ensure_running(manager, repo_path=repo, restart=True)
|
|
1114
|
-
|
|
1115
|
-
|
|
1143
|
+
# Keep the failed attempt's cause on the success path too. When the
|
|
1144
|
+
# retry fails as well, the retried report becomes the top-level
|
|
1145
|
+
# result (it is the final truth) and the first cause stays nested.
|
|
1146
|
+
retried["retry"] = {
|
|
1147
|
+
"attempted": True,
|
|
1148
|
+
"recovered": retried.get("status") == "running",
|
|
1149
|
+
"first_attempt": first_attempt,
|
|
1150
|
+
}
|
|
1151
|
+
result = retried
|
|
1116
1152
|
result["service"] = manager.status()
|
|
1117
1153
|
result["client_version"] = __version__
|
|
1118
1154
|
daemon_version = (result.get("daemon") or {}).get("version")
|
|
@@ -1204,6 +1240,21 @@ def _first_analyze(repo: Path, dry_run: bool) -> dict[str, Any]:
|
|
|
1204
1240
|
"hint": str(e),
|
|
1205
1241
|
}
|
|
1206
1242
|
warning_codes = [w.code for w in res.warnings]
|
|
1243
|
+
# Codes alone are not a diagnosis: `CGC_BACKEND_FAIL` says "a backend
|
|
1244
|
+
# problem", the detail says *which* call failed and why. Keep the full
|
|
1245
|
+
# detail in the report so a failed setup can be investigated from its JSON.
|
|
1246
|
+
warning_details = [
|
|
1247
|
+
{
|
|
1248
|
+
"code": warning.code,
|
|
1249
|
+
"detail": str(getattr(warning, "detail", "") or ""),
|
|
1250
|
+
**(
|
|
1251
|
+
{"file": warning.file}
|
|
1252
|
+
if getattr(warning, "file", None)
|
|
1253
|
+
else {}
|
|
1254
|
+
),
|
|
1255
|
+
}
|
|
1256
|
+
for warning in res.warnings
|
|
1257
|
+
]
|
|
1207
1258
|
repaired = [
|
|
1208
1259
|
getattr(w, "detail", "")
|
|
1209
1260
|
for w in res.warnings
|
|
@@ -1217,12 +1268,18 @@ def _first_analyze(repo: Path, dry_run: bool) -> dict[str, Any]:
|
|
|
1217
1268
|
stats = getattr(res, "stats", None)
|
|
1218
1269
|
files_processed = int(getattr(stats, "files_processed", 0) or 0)
|
|
1219
1270
|
fatal = [code for code in warning_codes if code in _ANALYZE_FATAL_WARNINGS]
|
|
1271
|
+
fatal_details = [
|
|
1272
|
+
f"{item['code']}: {item['detail'][:300]}"
|
|
1273
|
+
for item in warning_details
|
|
1274
|
+
if item["code"] in _ANALYZE_FATAL_WARNINGS and item["detail"]
|
|
1275
|
+
]
|
|
1220
1276
|
result = {
|
|
1221
1277
|
"status": "ok",
|
|
1222
1278
|
"mode_used": res.mode_used,
|
|
1223
1279
|
"duration_ms": res.duration_ms,
|
|
1224
1280
|
"files_processed": files_processed,
|
|
1225
1281
|
"warnings": warning_codes,
|
|
1282
|
+
"warning_details": warning_details,
|
|
1226
1283
|
# The engine may have healed itself during this very step. Keep the
|
|
1227
1284
|
# evidence in the setup report: a silent repair looks like "it just
|
|
1228
1285
|
# worked", and the next failure would be investigated from scratch.
|
|
@@ -1233,12 +1290,13 @@ def _first_analyze(repo: Path, dry_run: bool) -> dict[str, Any]:
|
|
|
1233
1290
|
# Fail closed: `analyze()` reports backend/parse failures as warnings,
|
|
1234
1291
|
# not exceptions. The old code therefore labelled a run that indexed
|
|
1235
1292
|
# nothing as `ok` and printed "Setup complete." (audit cycle-26 P1-b).
|
|
1293
|
+
detail_text = "; ".join(fatal_details) if fatal_details else ", ".join(fatal)
|
|
1236
1294
|
result.update(
|
|
1237
1295
|
status="failed",
|
|
1238
1296
|
via="doubled-graph analyze",
|
|
1239
1297
|
error_type=fatal[0] if fatal else "CGC_NO_FILES",
|
|
1240
1298
|
hint=(
|
|
1241
|
-
f"first full analyze indexed 0 files (warnings: {
|
|
1299
|
+
f"first full analyze indexed 0 files (warnings: {detail_text})"
|
|
1242
1300
|
if fatal
|
|
1243
1301
|
else "first full analyze indexed 0 files"
|
|
1244
1302
|
),
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""PATH stand-in for macOS ``launchctl``, used by the setup/launchd e2e test.
|
|
3
|
+
|
|
4
|
+
The stand is deliberately **not** a mock of :class:`ServiceManager`: it is a
|
|
5
|
+
real executable named ``launchctl`` (the small launcher next to this file)
|
|
6
|
+
that the production code calls through ``subprocess``. It starts the
|
|
7
|
+
**real** graph daemon from the plist's ``ProgramArguments``, so the witnesses
|
|
8
|
+
in the test are the real process, socket, ``daemon.json`` and ``ping``.
|
|
9
|
+
|
|
10
|
+
State model (deterministic, no timing races):
|
|
11
|
+
|
|
12
|
+
* ``bootstrap`` starts the daemon and records a loaded job;
|
|
13
|
+
* the first ``bootout`` kills the process and returns 0 but leaves the job in
|
|
14
|
+
the table as *stale* — exactly the incident: the supervisor has not finished
|
|
15
|
+
unloading it, so ``print`` still succeeds while ``state`` is no longer
|
|
16
|
+
``running``;
|
|
17
|
+
* ``kickstart`` on a stale job fails with no output (the incident's
|
|
18
|
+
``start: failed`` with no detail);
|
|
19
|
+
* a **second** ``bootout`` removes the stale job and returns 0. This models
|
|
20
|
+
launchd completing the unload on the retry, and is what makes the fixed
|
|
21
|
+
setup able to bootstrap a fresh daemon.
|
|
22
|
+
|
|
23
|
+
Environment (all provided by the test):
|
|
24
|
+
|
|
25
|
+
``FAKE_LAUNCHCTL_STATE``
|
|
26
|
+
directory for ``job.json``, ``started-pids.log`` and ``launchctl.log``;
|
|
27
|
+
``FAKE_LAUNCHCTL_LOG``
|
|
28
|
+
invocation log (defaults to ``$FAKE_LAUNCHCTL_STATE/launchctl.log``).
|
|
29
|
+
|
|
30
|
+
The real ``launchd`` is never contacted: the test asserts that
|
|
31
|
+
``shutil.which("launchctl")`` resolves to this file before and after the run.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
from __future__ import annotations
|
|
35
|
+
|
|
36
|
+
import json
|
|
37
|
+
import os
|
|
38
|
+
import plistlib
|
|
39
|
+
import signal
|
|
40
|
+
import subprocess
|
|
41
|
+
import sys
|
|
42
|
+
import time
|
|
43
|
+
from pathlib import Path
|
|
44
|
+
from typing import Any
|
|
45
|
+
|
|
46
|
+
DEFAULT_LABEL = "com.doubled-graph.daemon"
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _state_dir() -> Path:
|
|
50
|
+
raw = os.environ.get("FAKE_LAUNCHCTL_STATE")
|
|
51
|
+
if not raw:
|
|
52
|
+
raise SystemExit("fake_launchctl: FAKE_LAUNCHCTL_STATE is not set")
|
|
53
|
+
path = Path(raw)
|
|
54
|
+
path.mkdir(parents=True, exist_ok=True)
|
|
55
|
+
return path
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _job_path() -> Path:
|
|
59
|
+
return _state_dir() / "job.json"
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def _log_path() -> Path:
|
|
63
|
+
raw = os.environ.get("FAKE_LAUNCHCTL_LOG")
|
|
64
|
+
return Path(raw) if raw else _state_dir() / "launchctl.log"
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _read_job() -> dict[str, Any] | None:
|
|
68
|
+
try:
|
|
69
|
+
data = json.loads(_job_path().read_text(encoding="utf-8"))
|
|
70
|
+
except (OSError, ValueError):
|
|
71
|
+
return None
|
|
72
|
+
return data if isinstance(data, dict) else None
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _write_job(job: dict[str, Any]) -> None:
|
|
76
|
+
path = _job_path()
|
|
77
|
+
tmp = path.with_name(path.name + ".tmp")
|
|
78
|
+
tmp.write_text(json.dumps(job, indent=2), encoding="utf-8")
|
|
79
|
+
os.replace(tmp, path)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def _remove_job() -> None:
|
|
83
|
+
try:
|
|
84
|
+
_job_path().unlink()
|
|
85
|
+
except FileNotFoundError:
|
|
86
|
+
pass
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def _append_pid(pid: int) -> None:
|
|
90
|
+
with open(_state_dir() / "started-pids.log", "a", encoding="utf-8") as handle:
|
|
91
|
+
handle.write(f"{pid}\n")
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def _alive(pid: int | None) -> bool:
|
|
95
|
+
if not pid or pid <= 0:
|
|
96
|
+
return False
|
|
97
|
+
try:
|
|
98
|
+
os.kill(int(pid), 0)
|
|
99
|
+
except ProcessLookupError:
|
|
100
|
+
return False
|
|
101
|
+
except PermissionError:
|
|
102
|
+
return True
|
|
103
|
+
except OSError:
|
|
104
|
+
return False
|
|
105
|
+
return True
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def _terminate(pid: int | None, *, timeout: float = 5.0) -> None:
|
|
109
|
+
"""Stop a daemon the way ``launchctl bootout`` does (SIGTERM, then KILL)."""
|
|
110
|
+
if not pid or not _alive(pid):
|
|
111
|
+
return
|
|
112
|
+
try:
|
|
113
|
+
os.kill(int(pid), signal.SIGTERM)
|
|
114
|
+
except ProcessLookupError:
|
|
115
|
+
return
|
|
116
|
+
deadline = time.monotonic() + timeout
|
|
117
|
+
while time.monotonic() < deadline:
|
|
118
|
+
if not _alive(pid):
|
|
119
|
+
return
|
|
120
|
+
time.sleep(0.02)
|
|
121
|
+
try:
|
|
122
|
+
os.kill(int(pid), signal.SIGKILL)
|
|
123
|
+
except ProcessLookupError:
|
|
124
|
+
return
|
|
125
|
+
deadline = time.monotonic() + 2.0
|
|
126
|
+
while time.monotonic() < deadline and _alive(pid):
|
|
127
|
+
time.sleep(0.02)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def _spawn_from_plist(plist_path: Path) -> dict[str, Any]:
|
|
131
|
+
"""Start the plist's real ``ProgramArguments`` and return the job record."""
|
|
132
|
+
data = plistlib.loads(plist_path.read_bytes())
|
|
133
|
+
argv = [str(part) for part in data["ProgramArguments"]]
|
|
134
|
+
home = os.environ.get("DOUBLED_GRAPH_HOME")
|
|
135
|
+
log_dir = (Path(home) if home else plist_path.parent) / "logs"
|
|
136
|
+
log_dir.mkdir(parents=True, exist_ok=True)
|
|
137
|
+
stdout_path = Path(str(data.get("StandardOutPath") or log_dir / "graphd.out.log"))
|
|
138
|
+
stderr_path = Path(str(data.get("StandardErrorPath") or log_dir / "graphd.err.log"))
|
|
139
|
+
stdout_path.parent.mkdir(parents=True, exist_ok=True)
|
|
140
|
+
stderr_path.parent.mkdir(parents=True, exist_ok=True)
|
|
141
|
+
with open(stdout_path, "ab") as stdout, open(stderr_path, "ab") as stderr:
|
|
142
|
+
proc = subprocess.Popen(
|
|
143
|
+
argv,
|
|
144
|
+
stdin=subprocess.DEVNULL,
|
|
145
|
+
stdout=stdout,
|
|
146
|
+
stderr=stderr,
|
|
147
|
+
start_new_session=True,
|
|
148
|
+
close_fds=True,
|
|
149
|
+
)
|
|
150
|
+
previous = _read_job() or {}
|
|
151
|
+
started = [int(pid) for pid in previous.get("started_pids") or []]
|
|
152
|
+
started.append(proc.pid)
|
|
153
|
+
_append_pid(proc.pid)
|
|
154
|
+
job = {
|
|
155
|
+
"label": str(data.get("Label") or DEFAULT_LABEL),
|
|
156
|
+
"pid": proc.pid,
|
|
157
|
+
"plist": str(plist_path),
|
|
158
|
+
"stale": False,
|
|
159
|
+
"started_pids": started,
|
|
160
|
+
}
|
|
161
|
+
_write_job(job)
|
|
162
|
+
return job
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def _print_job(target: str, job: dict[str, Any]) -> int:
|
|
166
|
+
pid = job.get("pid")
|
|
167
|
+
running = bool(pid) and not job.get("stale") and _alive(pid)
|
|
168
|
+
print(f"{target} = {{")
|
|
169
|
+
print(f"\tactive count = {1 if running else 0}")
|
|
170
|
+
print(f"\tstate = {'running' if running else 'exited'}")
|
|
171
|
+
if pid:
|
|
172
|
+
print(f"\tpid = {pid}")
|
|
173
|
+
print("}")
|
|
174
|
+
return 0
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def _target(argv: list[str]) -> str:
|
|
178
|
+
for arg in argv:
|
|
179
|
+
if arg.startswith("gui/"):
|
|
180
|
+
return arg
|
|
181
|
+
return f"gui/{os.getuid()}/{DEFAULT_LABEL}"
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def handle(argv: list[str]) -> tuple[int, str]:
|
|
185
|
+
if not argv:
|
|
186
|
+
return 2, "usage: launchctl <verb> ..."
|
|
187
|
+
verb = argv[0]
|
|
188
|
+
|
|
189
|
+
if verb == "print-disabled":
|
|
190
|
+
print(f'"{DEFAULT_LABEL}" => false')
|
|
191
|
+
return 0, ""
|
|
192
|
+
|
|
193
|
+
if verb == "enable":
|
|
194
|
+
return 0, ""
|
|
195
|
+
|
|
196
|
+
if verb == "bootstrap":
|
|
197
|
+
if len(argv) < 3:
|
|
198
|
+
return 2, "bootstrap: domain and plist are required"
|
|
199
|
+
if _read_job() is not None:
|
|
200
|
+
# A stale job is still in the table; launchd refuses a second load.
|
|
201
|
+
return 5, "Bootstrap failed: 5: Input/output error"
|
|
202
|
+
try:
|
|
203
|
+
_spawn_from_plist(Path(argv[2]))
|
|
204
|
+
except (OSError, KeyError, ValueError, plistlib.InvalidFileException) as exc:
|
|
205
|
+
return 1, f"Bootstrap failed: {type(exc).__name__}: {exc}"
|
|
206
|
+
return 0, ""
|
|
207
|
+
|
|
208
|
+
if verb == "print":
|
|
209
|
+
target = _target(argv[1:])
|
|
210
|
+
job = _read_job()
|
|
211
|
+
if job is None:
|
|
212
|
+
return 3, f'Could not find service "{target}" in domain'
|
|
213
|
+
return _print_job(target, job), ""
|
|
214
|
+
|
|
215
|
+
if verb == "bootout":
|
|
216
|
+
target = _target(argv[1:])
|
|
217
|
+
job = _read_job()
|
|
218
|
+
if job is None:
|
|
219
|
+
return 3, f'Could not find service "{target}" in domain'
|
|
220
|
+
if job.get("stale"):
|
|
221
|
+
# The supervisor finishes the unload on the retry.
|
|
222
|
+
_remove_job()
|
|
223
|
+
return 0, ""
|
|
224
|
+
pid = job.get("pid")
|
|
225
|
+
_terminate(pid)
|
|
226
|
+
job["stale"] = True
|
|
227
|
+
_write_job(job)
|
|
228
|
+
# Record the incident transition: rc=0, process dead, job still loaded.
|
|
229
|
+
with open(_state_dir() / "stale-events.log", "a", encoding="utf-8") as event:
|
|
230
|
+
event.write(json.dumps({"target": target, "pid": pid}) + "\n")
|
|
231
|
+
return 0, ""
|
|
232
|
+
|
|
233
|
+
if verb == "kickstart":
|
|
234
|
+
target = _target(argv[1:])
|
|
235
|
+
job = _read_job()
|
|
236
|
+
if job is None:
|
|
237
|
+
return 3, f'Could not find service "{target}" in domain'
|
|
238
|
+
if job.get("stale"):
|
|
239
|
+
# The incident: launchd is still tearing the job down, kickstart
|
|
240
|
+
# fails, and it prints nothing the caller can report.
|
|
241
|
+
return 1, ""
|
|
242
|
+
if job.get("pid") and _alive(job.get("pid")):
|
|
243
|
+
return 0, ""
|
|
244
|
+
try:
|
|
245
|
+
_spawn_from_plist(Path(job["plist"]))
|
|
246
|
+
except (OSError, KeyError, ValueError, plistlib.InvalidFileException) as exc:
|
|
247
|
+
return 1, f"Kickstart failed: {type(exc).__name__}: {exc}"
|
|
248
|
+
return 0, ""
|
|
249
|
+
|
|
250
|
+
return 2, f"unknown launchctl verb {verb!r}"
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
def main() -> int:
|
|
254
|
+
rc, stderr = handle(sys.argv[1:])
|
|
255
|
+
if stderr:
|
|
256
|
+
print(stderr, file=sys.stderr)
|
|
257
|
+
entry = {
|
|
258
|
+
"argv": list(sys.argv),
|
|
259
|
+
"rc": rc,
|
|
260
|
+
"stderr": stderr,
|
|
261
|
+
"stub": os.path.realpath(__file__),
|
|
262
|
+
}
|
|
263
|
+
try:
|
|
264
|
+
with open(_log_path(), "a", encoding="utf-8") as handle_log:
|
|
265
|
+
handle_log.write(json.dumps(entry) + "\n")
|
|
266
|
+
except OSError:
|
|
267
|
+
pass
|
|
268
|
+
return rc
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
if __name__ == "__main__":
|
|
272
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""PATH entry for the launchd stand-in.
|
|
3
|
+
|
|
4
|
+
The actual implementation is ``fake_launchctl.py`` so that ruff and editors
|
|
5
|
+
treat it as Python. This launcher exists only to provide the exact executable
|
|
6
|
+
name ``launchctl`` that the production code resolves through ``PATH``; it does
|
|
7
|
+
not touch the real launchd.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import runpy
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
_STAND = Path(__file__).resolve().with_name("fake_launchctl.py")
|
|
14
|
+
runpy.run_path(str(_STAND), run_name="__main__")
|
|
@@ -767,3 +767,130 @@ def test_setup_reports_a_daemon_that_never_starts(tmp_path: Path, monkeypatch) -
|
|
|
767
767
|
|
|
768
768
|
assert result["status"] == "failed"
|
|
769
769
|
assert result["stderr"] == "nope"
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
def test_setup_retries_when_the_stale_job_is_still_loaded(
|
|
773
|
+
tmp_path: Path, monkeypatch
|
|
774
|
+
) -> None:
|
|
775
|
+
"""The incident state: `loaded=true` but the daemon is not running.
|
|
776
|
+
|
|
777
|
+
The old condition retried only when the job was *not loaded*, so launchd
|
|
778
|
+
keeping a stale job after `bootout` suppressed the repair entirely.
|
|
779
|
+
"""
|
|
780
|
+
from doubled_graph import setup as setup_mod
|
|
781
|
+
from doubled_graph.integrations import service as service_mod
|
|
782
|
+
|
|
783
|
+
monkeypatch.delenv("DOUBLED_GRAPH_NO_SERVICE", raising=False)
|
|
784
|
+
calls = {"n": 0}
|
|
785
|
+
|
|
786
|
+
class _Manager:
|
|
787
|
+
running = False
|
|
788
|
+
|
|
789
|
+
def status(self):
|
|
790
|
+
return {"loaded": True, "running": self.running}
|
|
791
|
+
|
|
792
|
+
manager = _Manager()
|
|
793
|
+
|
|
794
|
+
def fake_ensure(current, repo_path, restart):
|
|
795
|
+
calls["n"] += 1
|
|
796
|
+
if calls["n"] == 1:
|
|
797
|
+
return {
|
|
798
|
+
"status": "failed",
|
|
799
|
+
"failed_steps": ["start"],
|
|
800
|
+
"detail": "start: failed",
|
|
801
|
+
"stderr": "",
|
|
802
|
+
}
|
|
803
|
+
current.running = True
|
|
804
|
+
return {"status": "running", "daemon": {"version": setup_mod.__version__}}
|
|
805
|
+
|
|
806
|
+
monkeypatch.setattr(service_mod, "get_service_manager", lambda: manager)
|
|
807
|
+
monkeypatch.setattr(service_mod, "ensure_running", fake_ensure)
|
|
808
|
+
|
|
809
|
+
result = setup_mod._install_daemon_service(tmp_path, dry_run=False)
|
|
810
|
+
|
|
811
|
+
assert calls["n"] == 2
|
|
812
|
+
assert result["status"] == "running"
|
|
813
|
+
assert result["retry"]["recovered"] is True
|
|
814
|
+
assert result["retry"]["first_attempt"]["failed_steps"] == ["start"]
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
def test_setup_keeps_the_cause_of_a_failed_retry(
|
|
818
|
+
tmp_path: Path, monkeypatch
|
|
819
|
+
) -> None:
|
|
820
|
+
from doubled_graph import setup as setup_mod
|
|
821
|
+
from doubled_graph.integrations import service as service_mod
|
|
822
|
+
|
|
823
|
+
monkeypatch.delenv("DOUBLED_GRAPH_NO_SERVICE", raising=False)
|
|
824
|
+
calls = {"n": 0}
|
|
825
|
+
|
|
826
|
+
class _Manager:
|
|
827
|
+
def status(self):
|
|
828
|
+
return {"loaded": True, "running": False}
|
|
829
|
+
|
|
830
|
+
def fake_ensure(manager, repo_path, restart):
|
|
831
|
+
calls["n"] += 1
|
|
832
|
+
if calls["n"] == 1:
|
|
833
|
+
return {
|
|
834
|
+
"status": "failed",
|
|
835
|
+
"failed_steps": ["start"],
|
|
836
|
+
"detail": "start: failed",
|
|
837
|
+
"stderr": "kickstart: stale job",
|
|
838
|
+
}
|
|
839
|
+
return {
|
|
840
|
+
"status": "failed",
|
|
841
|
+
"failed_steps": ["install"],
|
|
842
|
+
"detail": "install: bootstrap refused",
|
|
843
|
+
"stderr": "Bootstrap failed: 5",
|
|
844
|
+
"hint": "inspect launchd",
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
monkeypatch.setattr(service_mod, "get_service_manager", lambda: _Manager())
|
|
848
|
+
monkeypatch.setattr(service_mod, "ensure_running", fake_ensure)
|
|
849
|
+
|
|
850
|
+
result = setup_mod._install_daemon_service(tmp_path, dry_run=False)
|
|
851
|
+
|
|
852
|
+
assert calls["n"] == 2
|
|
853
|
+
assert result["status"] == "failed"
|
|
854
|
+
# The retried attempt is the final truth...
|
|
855
|
+
assert result["failed_steps"] == ["install"]
|
|
856
|
+
assert result["stderr"] == "Bootstrap failed: 5"
|
|
857
|
+
assert result["hint"] == "inspect launchd"
|
|
858
|
+
# ...and the first failure is not lost.
|
|
859
|
+
assert result["retry"] == {
|
|
860
|
+
"attempted": True,
|
|
861
|
+
"recovered": False,
|
|
862
|
+
"first_attempt": {
|
|
863
|
+
"status": "failed",
|
|
864
|
+
"failed_steps": ["start"],
|
|
865
|
+
"detail": "start: failed",
|
|
866
|
+
"stderr": "kickstart: stale job",
|
|
867
|
+
"hint": "",
|
|
868
|
+
},
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
|
|
872
|
+
def test_setup_does_not_retry_a_daemon_the_supervisor_reports_running(
|
|
873
|
+
tmp_path: Path, monkeypatch
|
|
874
|
+
) -> None:
|
|
875
|
+
from doubled_graph import setup as setup_mod
|
|
876
|
+
from doubled_graph.integrations import service as service_mod
|
|
877
|
+
|
|
878
|
+
monkeypatch.delenv("DOUBLED_GRAPH_NO_SERVICE", raising=False)
|
|
879
|
+
calls = {"n": 0}
|
|
880
|
+
|
|
881
|
+
class _Manager:
|
|
882
|
+
def status(self):
|
|
883
|
+
return {"loaded": True, "running": True}
|
|
884
|
+
|
|
885
|
+
def fake_ensure(manager, repo_path, restart):
|
|
886
|
+
calls["n"] += 1
|
|
887
|
+
return {"status": "failed", "stderr": "cold start is still importing"}
|
|
888
|
+
|
|
889
|
+
monkeypatch.setattr(service_mod, "get_service_manager", lambda: _Manager())
|
|
890
|
+
monkeypatch.setattr(service_mod, "ensure_running", fake_ensure)
|
|
891
|
+
|
|
892
|
+
result = setup_mod._install_daemon_service(tmp_path, dry_run=False)
|
|
893
|
+
|
|
894
|
+
assert calls["n"] == 1
|
|
895
|
+
assert result["status"] == "failed"
|
|
896
|
+
assert "retry" not in result
|
|
@@ -1090,11 +1090,20 @@ def test_roundtrip_accepts_matching_response(monkeypatch) -> None:
|
|
|
1090
1090
|
def test_timeout_for_reads_overrides_and_defaults() -> None:
|
|
1091
1091
|
client = graphd.GraphClient(Path("/tmp"), timeouts={"status": 0.25})
|
|
1092
1092
|
assert client._timeout_for("status") == 0.25
|
|
1093
|
-
|
|
1093
|
+
# Indexing is unbounded by design (§6): a 60 s cap abandoned applies the
|
|
1094
|
+
# daemon was still finishing, so the manifest never advanced.
|
|
1095
|
+
assert client._timeout_for("index_apply") is None
|
|
1096
|
+
assert client._timeout_for("index_apply") == graphd.INDEXING_TIMEOUT_S
|
|
1094
1097
|
assert client._timeout_for("ping") == graphd.FAST_TIMEOUT_S
|
|
1095
1098
|
assert client._timeout_for("impact") == graphd.DEFAULT_TIMEOUT_S
|
|
1096
1099
|
|
|
1097
1100
|
|
|
1101
|
+
def test_index_apply_timeout_can_be_bounded_by_the_caller() -> None:
|
|
1102
|
+
"""The unbounded default is a design choice, not a lock-in."""
|
|
1103
|
+
client = graphd.GraphClient(Path("/tmp"), timeouts={"index_apply": 5.0})
|
|
1104
|
+
assert client._timeout_for("index_apply") == 5.0
|
|
1105
|
+
|
|
1106
|
+
|
|
1098
1107
|
def test_apply_diag_ignores_unknown_and_non_dict(monkeypatch) -> None:
|
|
1099
1108
|
client = graphd.GraphClient(Path("/tmp"))
|
|
1100
1109
|
assert client._apply_diag(5) == 5
|