Derive program behavior from deployments; stop persisting it

behavior (tool/daemon/frontend) is now a derived display label computed
from a program's deployments — path->tool, static->frontend, process->daemon
(behavior_for_runner). load_config populates it so every reader gets the live
value; _spec_to_yaml_dict excludes it so it is never written to disk.
_summary_from_service derives it from the runner instead of hardcoding daemon.
Fixtures gain path/python deployments so tool/daemon behaviors derive.
This commit is contained in:
2026-07-01 08:46:54 -07:00
parent fa65ae3d1c
commit 00e8d58c6a
6 changed files with 65 additions and 18 deletions

View File

@@ -11,7 +11,13 @@ from fastapi import APIRouter, HTTPException, status
from castle_core.config import SPECS_DIR
from castle_core.generators.caddyfile import generate_caddyfile_from_registry
from castle_core.manifest import ProgramSpec, JobSpec, ServiceSpec, manager_for
from castle_core.manifest import (
ProgramSpec,
JobSpec,
ServiceSpec,
behavior_for_runner,
manager_for,
)
from castle_core.stacks import available_actions
from castle_api.config import get_castle_root, get_registry
@@ -133,7 +139,7 @@ def _summary_from_service(
id=name,
category="service",
description=description,
behavior="daemon",
behavior=behavior_for_runner(runner),
stack=stack,
runner=runner,
port=port,

View File

@@ -42,19 +42,16 @@ def castle_root(tmp_path: Path) -> Generator[Path, None, None]:
"test-tool": {
"description": "Test tool",
"source": "test-tool",
"behavior": "tool",
"system_dependencies": ["pandoc"],
},
"test-tool-2": {
"description": "Another test tool",
"source": "test-tool-2",
"behavior": "tool",
"version": "2.0.0",
},
"wired-in": {
"description": "Adopted repo, no stack",
"source": "wired-in",
"behavior": "tool",
"repo": "https://github.com/someone/wired-in.git",
"commands": {
"lint": [["make", "lint"]],
@@ -64,6 +61,11 @@ def castle_root(tmp_path: Path) -> Generator[Path, None, None]:
},
},
"services": {
# Path deployments — behavior "tool" derives from the `path` runner
# (behavior is derived from deployments, never stored).
"test-tool": {"program": "test-tool", "run": {"runner": "path"}},
"test-tool-2": {"program": "test-tool-2", "run": {"runner": "path"}},
"wired-in": {"program": "wired-in", "run": {"runner": "path"}},
"test-svc": {
"program": "test-svc-comp",
"description": "Test service",