Replaces LICENSE (GPLv3 -> AGPLv3) and prepends `SPDX-License-Identifier: AGPL-3.0-or-later` to every source file across decnet/, decnet_web/, tests/, scripts/, and tools/. Rationale: closes the GPLv3 ASP loophole so any party operating a modified DECNET as a network service must offer their modified source. Personal copyright (Samuel Paschuan) + inbound=outbound contributions make a future unilateral relicense infeasible. - LICENSE: full AGPL-3.0 text (gnu.org/licenses/agpl-3.0.txt) - COPYRIGHT: project copyright notice - tools/add_spdx_headers.py: idempotent header injector (shebang- and PEP 263-aware) Touches 1565 source files (.py, .ts, .tsx, .js, .jsx, .css, .sh). No behavior change; comments only.
67 lines
2.1 KiB
Python
67 lines
2.1 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""Agent-mode gating for the `ttp` worker (DEBT-047).
|
|
|
|
`decnet ttp` runs the live TTP-tagging worker against local bus events
|
|
and the local artifacts tree. After DEBT-047 it MUST be available on
|
|
agent hosts so EmailLifter R0047 (BEC) can disk-reach .eml files
|
|
without round-tripping raw body text through the master.
|
|
|
|
`decnet ttp-backfill` walks the master DB and stays master-only.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import pathlib
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
REPO = pathlib.Path(__file__).resolve().parent.parent.parent
|
|
DECNET_BIN = Path(sys.executable).parent / "decnet"
|
|
|
|
|
|
def _clean_env(**overrides: str) -> dict[str, str]:
|
|
base = {"PATH": os.environ["PATH"], "HOME": "/nonexistent-for-test"}
|
|
base.update(overrides)
|
|
base["DECNET_CONFIG"] = "/nonexistent/decnet.ini"
|
|
base.setdefault("DECNET_JWT_SECRET", "x" * 32)
|
|
return base
|
|
|
|
|
|
def _help_text(env: dict[str, str]) -> str:
|
|
result = subprocess.run(
|
|
[str(DECNET_BIN), "--help"],
|
|
env=env, cwd=str(REPO),
|
|
capture_output=True, text=True, timeout=20,
|
|
)
|
|
assert result.returncode == 0, result.stderr
|
|
return result.stdout
|
|
|
|
|
|
def test_ttp_visible_on_agent_mode():
|
|
out = _help_text(_clean_env(DECNET_MODE="agent", DECNET_DISALLOW_MASTER="true"))
|
|
assert "ttp " in out or "ttp\n" in out, (
|
|
"`ttp` worker must be agent-runnable after DEBT-047 (disk-reach unblock)"
|
|
)
|
|
|
|
|
|
def test_ttp_backfill_hidden_on_agent_mode():
|
|
out = _help_text(_clean_env(DECNET_MODE="agent", DECNET_DISALLOW_MASTER="true"))
|
|
assert "ttp-backfill" not in out, (
|
|
"`ttp-backfill` walks the master DB and must stay master-only"
|
|
)
|
|
|
|
|
|
def test_ttp_visible_on_master_mode():
|
|
out = _help_text(_clean_env(DECNET_MODE="master"))
|
|
assert "ttp " in out or "ttp\n" in out
|
|
assert "ttp-backfill" in out
|
|
|
|
|
|
def test_master_only_set_excludes_ttp():
|
|
"""Source-level guard against re-adding `ttp` to the master-only set."""
|
|
from decnet.cli.gating import MASTER_ONLY_COMMANDS
|
|
assert "ttp" not in MASTER_ONLY_COMMANDS
|
|
assert "ttp-backfill" in MASTER_ONLY_COMMANDS
|