trustship 0.1.0__py3-none-any.whl
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.
- trustship/__init__.py +3 -0
- trustship/__main__.py +3 -0
- trustship/adoption.py +33 -0
- trustship/check_sync.py +167 -0
- trustship/cli.py +88 -0
- trustship/codex_review.py +506 -0
- trustship/decision_brief.py +1195 -0
- trustship/doctor.py +46 -0
- trustship/eval_review.py +1777 -0
- trustship/executables.py +159 -0
- trustship/gate-node.Dockerfile +25 -0
- trustship/gate-python-deps.Dockerfile +20 -0
- trustship/gate.Dockerfile +9 -0
- trustship/gemini_review.py +539 -0
- trustship/install.py +535 -0
- trustship/migrate.py +403 -0
- trustship/native.py +196 -0
- trustship/orca_client.py +113 -0
- trustship/policy.py +205 -0
- trustship/providers.py +259 -0
- trustship/resume_dispatch.py +163 -0
- trustship/review.py +1531 -0
- trustship/review_gate.py +634 -0
- trustship/run_gates.py +607 -0
- trustship/sandbox_worker.py +831 -0
- trustship/sensitive.json +19 -0
- trustship/start.py +349 -0
- trustship/task_plan.py +769 -0
- trustship/task_scope.py +1797 -0
- trustship/template/AGENTS.md +49 -0
- trustship/template/CLAUDE.md +4 -0
- trustship/template/agents/LICENSE +21 -0
- trustship/template/agents/README.md +62 -0
- trustship/template/agents/WORKFLOW.md +73 -0
- trustship/template/agents/docs/cross-provider.md +79 -0
- trustship/template/agents/docs/roles/implementer.md +15 -0
- trustship/template/agents/docs/task-permissions.md +124 -0
- trustship/template/agents/skills/project-handoff/SKILL.md +23 -0
- trustship/template/agents/skills/review-pr/SKILL.md +41 -0
- trustship/template/agents/skills/review-pr/references/record.example.json +31 -0
- trustship/template/agents/skills/review-pr/references/reviewer.md +20 -0
- trustship/template/agents/skills/session-recover/SKILL.md +17 -0
- trustship/template/agents/skills/session-recover/references/recovery.md +38 -0
- trustship/template/agents/skills/session-recover/scripts/session_context.py +246 -0
- trustship/template/agents/skills/spec-and-delegate/SKILL.md +45 -0
- trustship/template/agents/skills/spec-and-delegate/references/spec-template.md +53 -0
- trustship/template/agents/skills/start-task/SKILL.md +72 -0
- trustship/template/agents/workflow.json +64 -0
- trustship/template/agents/workflow.py +146 -0
- trustship/template/claude/skills/project-handoff/SKILL.md +12 -0
- trustship/template/claude/skills/review-pr/SKILL.md +12 -0
- trustship/template/claude/skills/session-recover/SKILL.md +12 -0
- trustship/template/claude/skills/spec-and-delegate/SKILL.md +12 -0
- trustship/template/claude/skills/start-task/SKILL.md +12 -0
- trustship/template/gitattributes +5 -0
- trustship/template/githooks/pre-push +11 -0
- trustship/template/gitignore +3 -0
- trustship/template/opencode/commands/project-handoff.md +7 -0
- trustship/template/opencode/commands/review-pr.md +7 -0
- trustship/template/opencode/commands/session-recover.md +7 -0
- trustship/template/opencode/commands/spec-and-delegate.md +7 -0
- trustship/template/opencode/commands/start-task.md +9 -0
- trustship-0.1.0.dist-info/METADATA +190 -0
- trustship-0.1.0.dist-info/RECORD +68 -0
- trustship-0.1.0.dist-info/WHEEL +5 -0
- trustship-0.1.0.dist-info/entry_points.txt +2 -0
- trustship-0.1.0.dist-info/licenses/LICENSE +21 -0
- trustship-0.1.0.dist-info/top_level.txt +1 -0
trustship/__init__.py
ADDED
trustship/__main__.py
ADDED
trustship/adoption.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""Describe the local Git revisions used at the first project handoff."""
|
|
2
|
+
|
|
3
|
+
import subprocess
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from trustship import task_scope
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def revisions(root: Path) -> dict[str, str]:
|
|
10
|
+
def git_text(*args: str) -> str:
|
|
11
|
+
try:
|
|
12
|
+
return task_scope.git_bytes(root, *args).decode().strip()
|
|
13
|
+
except (subprocess.CalledProcessError, FileNotFoundError):
|
|
14
|
+
return ""
|
|
15
|
+
|
|
16
|
+
def policy(commit: str) -> str:
|
|
17
|
+
if not commit:
|
|
18
|
+
return "unresolved"
|
|
19
|
+
entry = git_text("ls-tree", commit, "--", task_scope.CONFIG)
|
|
20
|
+
return f"{commit} (policy {'present' if entry else 'unavailable'})"
|
|
21
|
+
|
|
22
|
+
head = gate = worker = default_ref = ""
|
|
23
|
+
if (root / ".git").exists():
|
|
24
|
+
head = git_text("rev-parse", "--verify", "HEAD^{commit}")
|
|
25
|
+
default_ref = git_text("symbolic-ref", "--quiet", "refs/remotes/origin/HEAD")
|
|
26
|
+
if default_ref:
|
|
27
|
+
gate = git_text("rev-parse", "--verify", default_ref + "^{commit}")
|
|
28
|
+
worker = git_text("merge-base", "HEAD", "origin/HEAD")
|
|
29
|
+
return {
|
|
30
|
+
"workspace (committed HEAD)": policy(head),
|
|
31
|
+
"gate (origin default branch)": policy(gate) if default_ref else "origin/HEAD unavailable",
|
|
32
|
+
"worker (merge base with origin/HEAD)": policy(worker) if default_ref else "origin/HEAD unavailable",
|
|
33
|
+
}
|
trustship/check_sync.py
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Check the project's workflow contract without calling a model or changing settings."""
|
|
3
|
+
|
|
4
|
+
import sys
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from trustship import __version__, providers, task_scope
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def _read_text(path: Path) -> str | None:
|
|
11
|
+
if not path.is_file():
|
|
12
|
+
return None
|
|
13
|
+
try:
|
|
14
|
+
return path.read_text(encoding="utf-8")
|
|
15
|
+
except (OSError, UnicodeDecodeError):
|
|
16
|
+
return None
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def check(root: Path) -> list[str]:
|
|
20
|
+
problems = []
|
|
21
|
+
try:
|
|
22
|
+
config = task_scope.load_config((root / task_scope.CONFIG).read_bytes())
|
|
23
|
+
policy = task_scope.roles_policy(config)
|
|
24
|
+
pinned = config["runtime"].get("version")
|
|
25
|
+
if config["runtime"].get("package") != "trustship" or not pinned:
|
|
26
|
+
problems.append("runtime must pin an trustship version")
|
|
27
|
+
elif pinned != __version__:
|
|
28
|
+
problems.append(f"Runtime {__version__} differs from the pinned {pinned}")
|
|
29
|
+
install_mode = config["runtime"].get("install_mode", "full")
|
|
30
|
+
if install_mode not in ("full", "minimal"):
|
|
31
|
+
problems.append('runtime.install_mode must be "full" or "minimal"')
|
|
32
|
+
checks = config["project"].get("checks", [])
|
|
33
|
+
if not isinstance(checks, list) or any(
|
|
34
|
+
not isinstance(command, str) or not command.strip() for command in checks
|
|
35
|
+
):
|
|
36
|
+
problems.append("project.checks must be a list of non-empty commands")
|
|
37
|
+
if policy.get("reviewer_provider_differs_from_planner") != "preferred":
|
|
38
|
+
problems.append('reviewer_provider_differs_from_planner must be "preferred"')
|
|
39
|
+
for role in ("planner", "implementer", "reviewer"):
|
|
40
|
+
profiles = policy.get("roles", {}).get(role)
|
|
41
|
+
if not isinstance(profiles, list):
|
|
42
|
+
problems.append(f"Missing role: {role}")
|
|
43
|
+
continue
|
|
44
|
+
for profile in profiles:
|
|
45
|
+
if not isinstance(profile, dict):
|
|
46
|
+
problems.append(f"Invalid {role} profile: expected an object")
|
|
47
|
+
continue
|
|
48
|
+
if profile.get("enabled") is not True:
|
|
49
|
+
if (
|
|
50
|
+
role == "implementer"
|
|
51
|
+
and profile.get("agent") != "claude"
|
|
52
|
+
and profile.get("enabled")
|
|
53
|
+
):
|
|
54
|
+
problems.append(
|
|
55
|
+
"Only the qualified Claude file-only implementer is supported"
|
|
56
|
+
)
|
|
57
|
+
continue
|
|
58
|
+
agent = profile.get("agent")
|
|
59
|
+
model = profile.get("model")
|
|
60
|
+
adapter = providers.get_provider(agent)
|
|
61
|
+
if adapter is not None and not adapter.supports_role(role):
|
|
62
|
+
if adapter.name == "antigravity":
|
|
63
|
+
problems.append(
|
|
64
|
+
f"Antigravity supports planning only and cannot be an enabled {role}"
|
|
65
|
+
)
|
|
66
|
+
continue
|
|
67
|
+
if role == "implementer":
|
|
68
|
+
if not adapter.supports_model(model):
|
|
69
|
+
problems.append(f"Enabled {role} requires an exact model ID")
|
|
70
|
+
problems.append(
|
|
71
|
+
"Only the qualified Claude file-only implementer is supported"
|
|
72
|
+
)
|
|
73
|
+
continue
|
|
74
|
+
problems.append(f"Provider {adapter.name!r} does not support role {role!r}")
|
|
75
|
+
continue
|
|
76
|
+
if not providers.exact_model(agent, model, role=role):
|
|
77
|
+
problems.append(f"Enabled {role} requires an exact model ID")
|
|
78
|
+
if role == "implementer" and adapter is None:
|
|
79
|
+
problems.append("Only the qualified Claude file-only implementer is supported")
|
|
80
|
+
if install_mode == "minimal":
|
|
81
|
+
agents_md = root / "AGENTS.md"
|
|
82
|
+
if not agents_md.is_file():
|
|
83
|
+
problems.append("Missing workflow file: AGENTS.md")
|
|
84
|
+
else:
|
|
85
|
+
agents_text = _read_text(agents_md)
|
|
86
|
+
if agents_text is None or (
|
|
87
|
+
".agents/workflow.json" not in agents_text
|
|
88
|
+
and "trustship" not in agents_text
|
|
89
|
+
):
|
|
90
|
+
problems.append(
|
|
91
|
+
"AGENTS.md must reference the workflow contract "
|
|
92
|
+
"(.agents/workflow.json or trustship)"
|
|
93
|
+
)
|
|
94
|
+
return problems
|
|
95
|
+
if install_mode != "full":
|
|
96
|
+
return problems
|
|
97
|
+
skills = (
|
|
98
|
+
"start-task",
|
|
99
|
+
"spec-and-delegate",
|
|
100
|
+
"review-pr",
|
|
101
|
+
"project-handoff",
|
|
102
|
+
"session-recover",
|
|
103
|
+
)
|
|
104
|
+
for skill in skills:
|
|
105
|
+
canonical = root / f".agents/skills/{skill}/SKILL.md"
|
|
106
|
+
adapter = root / f".claude/skills/{skill}/SKILL.md"
|
|
107
|
+
command = root / f".opencode/commands/{skill}.md"
|
|
108
|
+
if not canonical.is_file():
|
|
109
|
+
problems.append(f"Missing shared skill: {skill}")
|
|
110
|
+
adapter_text = _read_text(adapter)
|
|
111
|
+
if adapter_text is None or f".agents/skills/{skill}/SKILL.md" not in adapter_text:
|
|
112
|
+
problems.append(f"Claude adapter drift: {skill}")
|
|
113
|
+
# OpenCode commands are optional; once installed they must stay thin.
|
|
114
|
+
if (root / ".opencode/commands").is_dir():
|
|
115
|
+
command_text = _read_text(command)
|
|
116
|
+
if command_text is None or f".agents/skills/{skill}/SKILL.md" not in command_text:
|
|
117
|
+
problems.append(f"OpenCode command drift: {skill}")
|
|
118
|
+
agents_md = root / "AGENTS.md"
|
|
119
|
+
if not agents_md.is_file():
|
|
120
|
+
problems.append("Missing workflow file: AGENTS.md")
|
|
121
|
+
else:
|
|
122
|
+
agents_text = _read_text(agents_md)
|
|
123
|
+
if agents_text is None or ".agents/skills/start-task/SKILL.md" not in agents_text:
|
|
124
|
+
problems.append(
|
|
125
|
+
"AGENTS.md must route substantive tasks to the shared start-task skill"
|
|
126
|
+
)
|
|
127
|
+
claude_md = root / "CLAUDE.md"
|
|
128
|
+
if not claude_md.is_file():
|
|
129
|
+
problems.append("Missing workflow file: CLAUDE.md")
|
|
130
|
+
else:
|
|
131
|
+
claude_text = _read_text(claude_md)
|
|
132
|
+
if claude_text is None or "@AGENTS.md" not in claude_text:
|
|
133
|
+
problems.append("CLAUDE.md must import the shared contract")
|
|
134
|
+
for path in (
|
|
135
|
+
".agents/workflow.py",
|
|
136
|
+
".agents/WORKFLOW.md",
|
|
137
|
+
".agents/docs/roles/implementer.md",
|
|
138
|
+
".agents/skills/spec-and-delegate/references/spec-template.md",
|
|
139
|
+
):
|
|
140
|
+
if not (root / path).is_file():
|
|
141
|
+
problems.append(f"Missing workflow file: {path}")
|
|
142
|
+
except (OSError, ValueError, KeyError, TypeError) as exc:
|
|
143
|
+
problems.append(f"Invalid workflow configuration: {exc}")
|
|
144
|
+
return problems
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def main() -> int:
|
|
148
|
+
root = task_scope.project_folder()
|
|
149
|
+
problems = check(root)
|
|
150
|
+
for problem in problems:
|
|
151
|
+
print("workflow-check: " + problem, file=sys.stderr)
|
|
152
|
+
if not problems:
|
|
153
|
+
mode = "full"
|
|
154
|
+
try:
|
|
155
|
+
config = task_scope.load_config((root / task_scope.CONFIG).read_bytes())
|
|
156
|
+
mode = config["runtime"].get("install_mode", "full")
|
|
157
|
+
except (OSError, ValueError, KeyError, TypeError):
|
|
158
|
+
pass
|
|
159
|
+
if mode == "minimal":
|
|
160
|
+
print("workflow-check: OK (minimal mode: shared contract and roles)")
|
|
161
|
+
else:
|
|
162
|
+
print("workflow-check: OK (shared contract, roles, and thin adapters)")
|
|
163
|
+
return int(bool(problems))
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
if __name__ == "__main__":
|
|
167
|
+
raise SystemExit(main())
|
trustship/cli.py
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"""One command for the workflow runtime; each subcommand keeps its module's own options."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import importlib
|
|
6
|
+
import json
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
from trustship import __version__
|
|
10
|
+
|
|
11
|
+
COMMANDS = {
|
|
12
|
+
"init": ("install", "Install the project files (preview; --apply writes)"),
|
|
13
|
+
"migrate": ("migrate", "Convert a v1 project to the pinned runtime (preview first)"),
|
|
14
|
+
"start": ("start", "Open a planning task in a fresh Orca worktree"),
|
|
15
|
+
"status": ("start", "Show what is needed before a task can start"),
|
|
16
|
+
"check": ("check_sync", "Check the project's workflow contract"),
|
|
17
|
+
"doctor": ("doctor", "Inspect local prerequisites"),
|
|
18
|
+
"plan": ("task_plan", "Generate a worker or reviewer manifest and brief"),
|
|
19
|
+
"scope": ("task_scope", "Prepare, probe, launch or serve a scoped client"),
|
|
20
|
+
"sandbox-worker": ("sandbox_worker", "Run a native coding agent in a credential-scrubbed sandbox"),
|
|
21
|
+
"resume-dispatch": ("resume_dispatch", "Wait for Claude trust and dispatch a prepared brief"),
|
|
22
|
+
"gate": ("run_gates", "Run project checks in the isolated gate container"),
|
|
23
|
+
"native-check": ("native", "Run reviewed Xcode tests on the coordinator host"),
|
|
24
|
+
"review": ("review", "Run a fresh standalone read-only review and validate evidence"),
|
|
25
|
+
"review-gate": ("review_gate", "Validate revision-bound review evidence"),
|
|
26
|
+
"codex-review": ("codex_review", "Qualify or run the Codex reviewer adapter"),
|
|
27
|
+
"gemini-review": ("gemini_review", "Qualify or run the Gemini CLI reviewer adapter"),
|
|
28
|
+
"eval-review": ("eval_review", "Score a reviewer against labeled synthetic defect/clean diffs"),
|
|
29
|
+
"decision-brief": ("decision_brief", "Emit a fail-closed advisory routing and human decision brief"),
|
|
30
|
+
}
|
|
31
|
+
# init and migrate run before a project pins a version; review-gate checks itself against
|
|
32
|
+
# the reviewed base's pin, not the branch's working tree.
|
|
33
|
+
UNPINNED = {"init", "migrate", "review-gate"}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def usage() -> str:
|
|
37
|
+
lines = [f"usage: trustship <command> [options] (version {__version__})", ""]
|
|
38
|
+
lines += [f" {name:<14}{summary}" for name, (_, summary) in COMMANDS.items()]
|
|
39
|
+
return "\n".join(lines)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def pin_problem() -> str | None:
|
|
43
|
+
"""A project pins one runtime version; any other version refuses to act on it."""
|
|
44
|
+
from trustship import task_scope
|
|
45
|
+
|
|
46
|
+
try:
|
|
47
|
+
data = (task_scope.project_folder() / task_scope.CONFIG).read_bytes()
|
|
48
|
+
except (OSError, ValueError):
|
|
49
|
+
return None # outside a configured project; the command reports what it needs
|
|
50
|
+
try:
|
|
51
|
+
pinned = json.loads(data)["runtime"]["version"]
|
|
52
|
+
except (ValueError, KeyError, TypeError):
|
|
53
|
+
return f"{task_scope.CONFIG} has no runtime version pin"
|
|
54
|
+
if pinned != __version__:
|
|
55
|
+
return (
|
|
56
|
+
f"this is trustship {__version__}, but the project pins {pinned}; "
|
|
57
|
+
"run it through python3 .agents/workflow.py"
|
|
58
|
+
)
|
|
59
|
+
return None
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def main(argv: list[str] | None = None) -> int:
|
|
63
|
+
for stream in (sys.stdout, sys.stderr):
|
|
64
|
+
# Windows pipes use the ANSI code page; printing must never fail a finished launch.
|
|
65
|
+
if hasattr(stream, "reconfigure"):
|
|
66
|
+
stream.reconfigure(errors="replace")
|
|
67
|
+
argv = sys.argv[1:] if argv is None else argv
|
|
68
|
+
if not argv or argv[0] in ("-h", "--help"):
|
|
69
|
+
print(usage())
|
|
70
|
+
return 0 if argv else 2
|
|
71
|
+
if argv[0] == "--version":
|
|
72
|
+
print(__version__)
|
|
73
|
+
return 0
|
|
74
|
+
if argv[0] not in COMMANDS:
|
|
75
|
+
print(usage(), file=sys.stderr)
|
|
76
|
+
return 2
|
|
77
|
+
if argv[0] not in UNPINNED:
|
|
78
|
+
problem = pin_problem()
|
|
79
|
+
if problem:
|
|
80
|
+
print(f"trustship: {problem}", file=sys.stderr)
|
|
81
|
+
return 1
|
|
82
|
+
module = importlib.import_module("trustship." + COMMANDS[argv[0]][0])
|
|
83
|
+
if module.__name__.endswith(".start"):
|
|
84
|
+
sys.argv = ["trustship", *argv] # start and status share one parser
|
|
85
|
+
else:
|
|
86
|
+
sys.argv = [f"trustship {argv[0]}", *argv[1:]]
|
|
87
|
+
result = module.main()
|
|
88
|
+
return result if isinstance(result, int) else 0
|