From 969533ee3fe722f14983ed38268e76234474b1ad Mon Sep 17 00:00:00 2001 From: Yusuke-KOMIYAMA Date: Thu, 5 Nov 2026 20:11:44 +0900 Subject: [PATCH 01/12] =?UTF-8?q?feat(installer):=20grdm-dev=20=E3=83=91?= =?UTF-8?q?=E3=83=83=E3=82=B1=E3=83=BC=E3=82=B8=E3=81=AE=E9=AA=A8=E6=A0=BC?= =?UTF-8?q?=EF=BC=88CLI=20=E5=85=A5=E5=8F=A3=E3=83=BB=E7=B5=82=E4=BA=86?= =?UTF-8?q?=E3=82=B3=E3=83=BC=E3=83=89=E8=A1=A8=E3=83=BBTOON=E3=83=BB?= =?UTF-8?q?=E5=A0=B1=E5=91=8A=E3=83=BB=E3=83=A2=E3=82=B8=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E3=83=AB=E5=A5=91=E7=B4=84=EF=BC=89=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 理由: M2 のサブコマンドを複数のエージェントが並行実装するため、共通部品と契約を先に固定する(SPEC-02 §2.2, §6, §9, §10)。 内容: pyproject(標準ライブラリのみ、extra accept/docs)、messages.tsv(終了コードの正本、英和)、exit_codes、 toon 符号化、context(ルート検出・runtime/・--yes・非対話時の既定 no)、report(TOON/JSON 出力と runtime/reports/ 保存)、 cli(register/run 契約、未実装モジュールは help から隠す)、doctor(契約の参照実装。host.py は後続)。 検証: installer/tests 4 件 OK。 Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01BW1YQju1R8hU1GgE9LhLD4 --- installer/README.md | 58 +++++++++++++++++++++++ installer/grdm_dev/__init__.py | 11 +++++ installer/grdm_dev/cli.py | 68 ++++++++++++++++++++++++++ installer/grdm_dev/context.py | 54 +++++++++++++++++++++ installer/grdm_dev/doctor.py | 30 ++++++++++++ installer/grdm_dev/exit_codes.py | 38 +++++++++++++++ installer/grdm_dev/messages.tsv | 14 ++++++ installer/grdm_dev/report.py | 39 +++++++++++++++ installer/grdm_dev/toon.py | 71 ++++++++++++++++++++++++++++ installer/pyproject.toml | 26 ++++++++++ installer/tests/test_cli_skeleton.py | 31 ++++++++++++ 11 files changed, 440 insertions(+) create mode 100644 installer/README.md create mode 100644 installer/grdm_dev/__init__.py create mode 100644 installer/grdm_dev/cli.py create mode 100644 installer/grdm_dev/context.py create mode 100644 installer/grdm_dev/doctor.py create mode 100644 installer/grdm_dev/exit_codes.py create mode 100644 installer/grdm_dev/messages.tsv create mode 100644 installer/grdm_dev/report.py create mode 100644 installer/grdm_dev/toon.py create mode 100644 installer/pyproject.toml create mode 100644 installer/tests/test_cli_skeleton.py diff --git a/installer/README.md b/installer/README.md new file mode 100644 index 0000000..60f60d6 --- /dev/null +++ b/installer/README.md @@ -0,0 +1,58 @@ +# grdm-dev Installer / インストーラー + +> **Summary:** The Python package behind `./installer/install.sh`. One subcommand per module; standard library only. Normative text is [SPEC-02](../docs/spec/02_installer_cli.md). +> **概要:** `./installer/install.sh` の裏側にある Python パッケージ。モジュールごとに 1 サブコマンド、標準ライブラリのみ。規範は [SPEC-02](../docs/spec/02_installer_cli.md)。 + +**Jump:** [English](#english) · [日本語](#japanese) + +- Version / 版: 0.1 — 2026-11-05. **Learned:** the module contract (`register`/`run`, injectable runner) had to be fixed before several people could implement subcommands in parallel without stepping on each other. / 複数人が同時にサブコマンドを実装してもぶつからないよう、モジュールの契約(`register`/`run`、差し替え可能な runner)を先に固定する必要があると分かった。 +- Related: [docs/README.md](../docs/README.md) · [SPEC-02](../docs/spec/02_installer_cli.md) · [SPEC-04](../docs/spec/04_acceptance_tests.md) + +--- + + +## English + +[→ 日本語版へ](#japanese) + +### Layout + +See [SPEC-02 §9](../docs/spec/02_installer_cli.md). Shared parts: `cli.py` (parsing, dispatch), `context.py` (root, runtime/, `--yes`, confirm), `exit_codes.py` + `messages.tsv` (one table for bash and Python), `toon.py` (report encoder), `report.py` (`emit`, `error`). + +### Module contract + +```python +def register(subparsers): ... # add a sub-parser; call set_defaults(_module=sys.modules[__name__]) +def run(ctx, args) -> int: ... # return a code from grdm_dev.exit_codes +``` + +Modules that call external tools take an injectable `runner` so unit tests never need Docker. Run tests with `python3 -m unittest discover -s installer/tests` from the repository root (set `PYTHONPATH=installer` or `pip install -e installer`). + +--- + + +## 日本語 + +[→ To English](#english) + +### 構成 + +[SPEC-02 §9](../docs/spec/02_installer_cli.md) を参照。共通部品: `cli.py`(解析と振り分け)、`context.py`(ルート、runtime/、`--yes`、確認)、`exit_codes.py` と `messages.tsv`(bash と Python が同じ表を使う)、`toon.py`(報告の符号化)、`report.py`(`emit`、`error`)。 + +### モジュールの契約 + +```python +def register(subparsers): ... # サブパーサを追加し set_defaults(_module=sys.modules[__name__]) を呼ぶ +def run(ctx, args) -> int: ... # grdm_dev.exit_codes の値を返す +``` + +外部の道具を呼ぶモジュールは差し替え可能な `runner` を受け取り、単体テストで Docker を要らなくする。テストはリポジトリのルートで `python3 -m unittest discover -s installer/tests`(`PYTHONPATH=installer` か `pip install -e installer`)。 + +--- + +## Glossary / 用語 + +| Term | English note | 日本語注 | +|---|---|---| +| Subcommand | A word after the command that picks what to do, like `doctor` in `grdm-dev doctor`. | コマンドの後ろに付けて何をするか選ぶ言葉。`grdm-dev doctor` の `doctor`。 | +| Runner | A small function that runs another program; tests swap it for a fake. | 別のプログラムを実行する小さな関数。テストでは偽物に差し替える。 | diff --git a/installer/grdm_dev/__init__.py b/installer/grdm_dev/__init__.py new file mode 100644 index 0000000..a68699b --- /dev/null +++ b/installer/grdm_dev/__init__.py @@ -0,0 +1,11 @@ +"""grdm-dev: one-command installer for the GakuNin RDM developer environment 2027 (SPEC-02). + +Standard library only. Every subcommand lives in its own module and follows one contract: + + def register(subparsers) -> None # add its argparse sub-parser(s) + def run(ctx: Context, args) -> int # do the work, return an exit code from exit_codes + +Reports are produced through `grdm_dev.report.emit(ctx, name, data)`, which prints TOON by +default or JSON with --json and keeps a copy under runtime/reports/. +""" +__version__ = "0.1.0" diff --git a/installer/grdm_dev/cli.py b/installer/grdm_dev/cli.py new file mode 100644 index 0000000..e0c2074 --- /dev/null +++ b/installer/grdm_dev/cli.py @@ -0,0 +1,68 @@ +"""grdm-dev command line: argument parsing and subcommand dispatch (SPEC-02 §3, §5, §6).""" +from __future__ import annotations + +import argparse +import importlib +import sys + +from . import __version__, exit_codes +from .context import Context, find_repo_root + +# Each module exposes register(subparsers) and run(ctx, args). Order = help order. +SUBCOMMAND_MODULES = [ + "doctor", "plan", "secrets", "compose", "build", "lifecycle", "health", + "scan", "redteam", "accept", "upstream", "manifest_cmd", "docs", "report_cmd", "install", +] + + +def build_parser() -> argparse.ArgumentParser: + p = argparse.ArgumentParser( + prog="grdm-dev", + description="GakuNin RDM developer environment 2027 — one-command installer (SPEC-02)", + ) + p.add_argument("--version", action="version", version=f"grdm-dev {__version__}") + p.add_argument("--yes", action="store_true", help="answer every question with its default (required without a terminal)") + p.add_argument("--json", dest="json_output", action="store_true", help="print reports as JSON instead of TOON") + p.add_argument("--profile", choices=["minimum", "core", "full"], help="service profile (default: saved value or core)") + p.add_argument("--root", help="repository root (default: auto-detect from manifest/upstreams.json)") + p.add_argument("-v", "--verbose", action="store_true") + sub = p.add_subparsers(dest="command", metavar="") + for name in SUBCOMMAND_MODULES: + try: + mod = importlib.import_module(f".{name}", __package__) + except ModuleNotFoundError as exc: + # A subcommand (or one of its in-package helpers) is not implemented yet: hide it from + # help instead of breaking every other command. Errors outside this package still raise. + if exc.name and exc.name.startswith(__package__): + continue + raise + mod.register(sub) + return p + + +def main(argv: list[str] | None = None) -> int: + parser = build_parser() + try: + args = parser.parse_args(argv) + except SystemExit as exc: # argparse exits 2 on usage errors; keep SPEC-02's code 2 + return exit_codes.USAGE if exc.code not in (0, None) else 0 + if not getattr(args, "command", None): + parser.print_help() + return exit_codes.USAGE + from pathlib import Path + + root = Path(args.root).resolve() if args.root else find_repo_root() + ctx = Context(root=root, yes=args.yes, json_output=args.json_output, profile=args.profile, verbose=args.verbose) + mod = getattr(args, "_module", None) # set by each module's register(): parser.set_defaults(_module=sys.modules[__name__]) + if mod is None: + parser.print_help() + return exit_codes.USAGE + try: + return int(mod.run(ctx, args)) + except KeyboardInterrupt: + sys.stderr.write("\ninterrupted\n") + return exit_codes.USAGE + + +if __name__ == "__main__": # pragma: no cover + sys.exit(main()) diff --git a/installer/grdm_dev/context.py b/installer/grdm_dev/context.py new file mode 100644 index 0000000..74a7f1a --- /dev/null +++ b/installer/grdm_dev/context.py @@ -0,0 +1,54 @@ +"""Shared execution context passed to every subcommand (SPEC-02 §7 behavior rules).""" +from __future__ import annotations + +import os +import sys +from dataclasses import dataclass, field +from pathlib import Path + + +def find_repo_root(start: Path | None = None) -> Path: + """The repository root is the first parent that contains manifest/upstreams.json.""" + p = (start or Path.cwd()).resolve() + for cand in (p, *p.parents): + if (cand / "manifest" / "upstreams.json").exists(): + return cand + env = os.environ.get("GRDM_DEV_ROOT") + if env and (Path(env) / "manifest" / "upstreams.json").exists(): + return Path(env).resolve() + return p + + +@dataclass +class Context: + root: Path + yes: bool = False + json_output: bool = False + profile: str | None = None + verbose: bool = False + lang: str = field(default_factory=lambda: "ja" if os.environ.get("LANG", "").startswith("ja") else "en") + stdin_is_tty: bool = field(default_factory=lambda: sys.stdin.isatty()) + env: dict[str, str] = field(default_factory=lambda: dict(os.environ)) + + @property + def runtime(self) -> Path: + return self.root / "runtime" + + @property + def reports_dir(self) -> Path: + return self.runtime / "reports" + + @property + def manifest_path(self) -> Path: + return self.root / "manifest" / "upstreams.json" + + def confirm(self, question: str, default: bool = False) -> bool: + """Ask a yes/no question. Non-interactive without --yes answers 'no' (SPEC-02 §7).""" + if self.yes: + return True + if not self.stdin_is_tty: + return False + ans = input(f"{question} [{'Y/n' if default else 'y/N'}] ").strip().lower() + if not ans: + return default + return ans in ("y", "yes") diff --git a/installer/grdm_dev/doctor.py b/installer/grdm_dev/doctor.py new file mode 100644 index 0000000..2e25d25 --- /dev/null +++ b/installer/grdm_dev/doctor.py @@ -0,0 +1,30 @@ +"""grdm-dev doctor — host detection (SPEC-02 §3). Reference implementation of the module contract. + +Contract for every subcommand module: + register(subparsers): add the sub-parser and call set_defaults(_module=sys.modules[__name__]) + run(ctx, args) -> int: return an exit code from grdm_dev.exit_codes +Tests inject a fake `runner` (callable taking argv list, returning (returncode, stdout)) so Docker +is never required by unit tests (SPEC-02 §10). +""" +from __future__ import annotations + +import sys + +from . import exit_codes, host, report +from .context import Context + + +def register(subparsers) -> None: + p = subparsers.add_parser("doctor", help="detect OS, CPU, memory, disk, Docker; exit 10/11 if unsupported") + p.set_defaults(_module=sys.modules[__name__]) + + +def run(ctx: Context, args, runner=None) -> int: + info = host.detect(runner=runner) + data = host.as_report(info) + report.emit(ctx, "doctor", data) + if not info.supported: + return report.error(ctx, exit_codes.HOST_UNSUPPORTED, "; ".join(info.problems)) + if not info.docker_ok: + return report.error(ctx, exit_codes.DOCKER_MISSING, "; ".join(info.problems)) + return exit_codes.OK diff --git a/installer/grdm_dev/exit_codes.py b/installer/grdm_dev/exit_codes.py new file mode 100644 index 0000000..a0b2f84 --- /dev/null +++ b/installer/grdm_dev/exit_codes.py @@ -0,0 +1,38 @@ +"""Exit codes of grdm-dev (SPEC-02 §6). The canonical table is messages.tsv next to this file.""" +from __future__ import annotations + +import csv +from pathlib import Path + +OK = 0 +USAGE = 2 +HOST_UNSUPPORTED = 10 +DOCKER_MISSING = 11 +PORT_IN_USE = 12 +MANIFEST_INVALID = 20 +BUILD_FAILED = 30 +HEALTH_FAILED = 40 +SCAN_GATE_FAILED = 50 +SCANNER_UNAVAILABLE = 51 +SERVICES_UNHEALTHY = 52 +REDTEAM_PREFLIGHT_FAILED = 53 +ACCEPTANCE_FAILED = 60 + +_MESSAGES: dict[int, tuple[str, str]] | None = None + + +def messages() -> dict[int, tuple[str, str]]: + """Return {code: (english, japanese)} read from messages.tsv (cached).""" + global _MESSAGES + if _MESSAGES is None: + table: dict[int, tuple[str, str]] = {} + with (Path(__file__).parent / "messages.tsv").open(encoding="utf-8", newline="") as fh: + for row in csv.DictReader(fh, delimiter="\t"): + table[int(row["code"])] = (row["en"], row["ja"]) + _MESSAGES = table + return _MESSAGES + + +def describe(code: int, lang: str = "en") -> str: + en, ja = messages().get(code, ("unknown exit code", "不明な終了コード")) + return ja if lang == "ja" else en diff --git a/installer/grdm_dev/messages.tsv b/installer/grdm_dev/messages.tsv new file mode 100644 index 0000000..48fe6f4 --- /dev/null +++ b/installer/grdm_dev/messages.tsv @@ -0,0 +1,14 @@ +code en ja +0 success 成功 +2 usage error: unknown flag or bad value 使い方の誤り: 不明なフラグか不正な値 +10 host unsupported: OS, CPU, memory, or Python too old ホスト非対応: OS・CPU・メモリ・Python が古い +11 Docker missing, not running, or Compose / buildx plugin absent Docker がない、動いていない、または Compose / buildx プラグインがない +12 a required port on 127.0.0.1 is in use and no free alternative was found 127.0.0.1 の必要なポートが使用中で、空きの代替がない +20 manifest invalid or TOON excerpt disagrees with JSON manifest が不正、または TOON 抄録が JSON と一致しない +30 image build failed イメージのビルドに失敗 +40 health check failed, or a port listens on a non-loopback address 健康確認に失敗、またはループバック以外のアドレスでポートが待ち受けている +50 security scan gate failed for the current milestone 現在の節目のセキュリティ門に不合格 +51 scanner could not run: tool missing or vulnerability database download failed スキャナーが動かない: 道具がない、または脆弱性データベースの取得に失敗 +52 services not healthy, so scan --dynamic could not run サービスが健全でないため scan --dynamic を実行できない +53 red-team preflight failed: egress reachable or a target outside redteam-targets.json レッドチーム事前確認に失敗: 外向き通信が可能、または redteam-targets.json 外の対象がある +60 acceptance test failed 受入試験に失敗 diff --git a/installer/grdm_dev/report.py b/installer/grdm_dev/report.py new file mode 100644 index 0000000..e7b6d1d --- /dev/null +++ b/installer/grdm_dev/report.py @@ -0,0 +1,39 @@ +"""Report output: TOON to stdout by default, JSON with --json; copy kept under runtime/reports/.""" +from __future__ import annotations + +import datetime as _dt +import json +import sys +from typing import Any + +from . import toon +from .context import Context + + +def timestamp() -> str: + return _dt.datetime.now(_dt.timezone.utc).strftime("%Y%m%dT%H%M%SZ") + + +def emit(ctx: Context, name: str, data: dict[str, Any], *, save: bool = True) -> None: + """Print one report and (by default) save JSON + TOON copies as runtime/reports/_.*""" + text = json.dumps(data, ensure_ascii=False, indent=2) if ctx.json_output else toon.encode(data, name=name) + sys.stdout.write(text + "\n") + if save: + try: + ctx.reports_dir.mkdir(parents=True, exist_ok=True) + base = ctx.reports_dir / f"{name}_{timestamp()}" + base.with_suffix(".json").write_text(json.dumps(data, ensure_ascii=False, indent=2) + "\n", encoding="utf-8") + base.with_suffix(".toon").write_text(toon.encode(data, name=name) + "\n", encoding="utf-8") + latest = ctx.reports_dir / f"{name}_latest.json" + latest.write_text(json.dumps(data, ensure_ascii=False, indent=2) + "\n", encoding="utf-8") + except OSError as exc: # reports are evidence, but failing to save must not hide the result + sys.stderr.write(f"warning: could not save report: {exc}\n") + + +def error(ctx: Context, code: int, detail: str = "") -> int: + """Print the canonical message for an exit code (plus detail) to stderr and return the code.""" + from .exit_codes import describe + + msg = describe(code, ctx.lang) + sys.stderr.write(f"[grdm-dev] exit {code}: {msg}" + (f" — {detail}" if detail else "") + "\n") + return code diff --git a/installer/grdm_dev/toon.py b/installer/grdm_dev/toon.py new file mode 100644 index 0000000..886ccdf --- /dev/null +++ b/installer/grdm_dev/toon.py @@ -0,0 +1,71 @@ +"""Minimal TOON (Token-Oriented Object Notation) encoder for reports (SPEC-06 §4). + +Encodes JSON-compatible data: dicts become `key: value` lines, lists of flat dicts with the same +keys become tabular arrays `name[N]{k1,k2}:` followed by CSV rows, other lists become `- item` +lines. Strings containing a delimiter (`,` `:` `"` newline) or surrounding spaces are quoted. +The encoder is deliberately small; it is not a full TOON implementation. +""" +from __future__ import annotations + +import json +from typing import Any + +_DELIMS = (",", ":", '"', "\n", "[", "]", "{", "}") + + +def _scalar(v: Any) -> str: + if v is None: + return "null" + if isinstance(v, bool): + return "true" if v else "false" + if isinstance(v, (int, float)): + return json.dumps(v) + s = str(v) + if s == "" or s != s.strip() or any(d in s for d in _DELIMS) or s in ("true", "false", "null"): + return json.dumps(s, ensure_ascii=False) + return s + + +def _is_table(items: list) -> bool: + if not items or not all(isinstance(i, dict) for i in items): + return False + keys = list(items[0].keys()) + return all(list(i.keys()) == keys for i in items) and all( + not isinstance(v, (dict, list)) for i in items for v in i.values() + ) + + +def encode(data: Any, indent: int = 0, name: str | None = None) -> str: + pad = " " * indent + out: list[str] = [] + if isinstance(data, dict): + if name is not None: + out.append(f"{pad}{name}:") + indent += 1 + pad = " " * indent + for k, v in data.items(): + if isinstance(v, (dict, list)): + out.append(encode(v, indent, k)) + else: + out.append(f"{pad}{k}: {_scalar(v)}") + return "\n".join(out) + if isinstance(data, list): + label = name if name is not None else "items" + if _is_table(data): + keys = list(data[0].keys()) + out.append(f"{pad}{label}[{len(data)}]{{{','.join(keys)}}}:") + for row in data: + out.append(pad + " " + ",".join(_scalar(row[k]) for k in keys)) + return "\n".join(out) + out.append(f"{pad}{label}[{len(data)}]:") + for item in data: + if isinstance(item, (dict, list)): + sub = encode(item, indent + 1) + first, _, rest = sub.partition("\n") + out.append(pad + " - " + first.strip()) + if rest: + out.append(rest) + else: + out.append(pad + " - " + _scalar(item)) + return "\n".join(out) + return f"{pad}{name + ': ' if name else ''}{_scalar(data)}" diff --git a/installer/pyproject.toml b/installer/pyproject.toml new file mode 100644 index 0000000..a14f718 --- /dev/null +++ b/installer/pyproject.toml @@ -0,0 +1,26 @@ +[build-system] +requires = ["setuptools>=68"] +build-backend = "setuptools.build_meta" + +[project] +name = "grdm-dev" +version = "0.1.0" +description = "GakuNin RDM developer environment 2027: one-command installer (SPEC-02)" +readme = "README.md" +requires-python = ">=3.11" +license = {text = "MIT"} +dependencies = [] + +[project.optional-dependencies] +accept = ["pytest>=8", "pytest-playwright>=0.5", "playwright>=1.47"] +docs = ["mkdocs==1.6.1", "mkdocs-material==9.5.37", "pymdown-extensions==10.12"] + +[project.scripts] +grdm-dev = "grdm_dev.cli:main" + +[tool.setuptools] +packages = ["grdm_dev"] +include-package-data = true + +[tool.setuptools.package-data] +grdm_dev = ["messages.tsv"] diff --git a/installer/tests/test_cli_skeleton.py b/installer/tests/test_cli_skeleton.py new file mode 100644 index 0000000..33f0a28 --- /dev/null +++ b/installer/tests/test_cli_skeleton.py @@ -0,0 +1,31 @@ +import io +import unittest +from contextlib import redirect_stderr, redirect_stdout + +from grdm_dev import cli, exit_codes, toon + + +class CliSkeletonTests(unittest.TestCase): + def test_no_command_is_usage_error(self): + with redirect_stdout(io.StringIO()): + self.assertEqual(cli.main([]), exit_codes.USAGE) + + def test_unknown_flag_is_usage_error(self): + with redirect_stderr(io.StringIO()), redirect_stdout(io.StringIO()): + self.assertEqual(cli.main(["--no-such-flag"]), exit_codes.USAGE) + + def test_messages_table_matches_constants(self): + table = exit_codes.messages() + for code in (0, 2, 10, 11, 12, 20, 30, 40, 50, 51, 52, 53, 60): + self.assertIn(code, table) + self.assertTrue(table[code][0] and table[code][1]) + + def test_toon_table_and_quoting(self): + out = toon.encode({"rows": [{"a": 1, "b": "x,y"}, {"a": 2, "b": "z"}], "note": "a: b"}, name="r") + self.assertIn('rows[2]{a,b}:', out) + self.assertIn('1,"x,y"', out) + self.assertIn('note: "a: b"', out) + + +if __name__ == "__main__": + unittest.main() From e4ea1587cd603c56538281e824a2d9ba5e092caf Mon Sep 17 00:00:00 2001 From: Yusuke-KOMIYAMA Date: Thu, 5 Nov 2026 20:15:49 +0900 Subject: [PATCH 02/12] =?UTF-8?q?fix(installer),docs(status):=20=E6=9C=AA?= =?UTF-8?q?=E5=AE=9F=E8=A3=85=E3=83=A2=E3=82=B8=E3=83=A5=E3=83=BC=E3=83=AB?= =?UTF-8?q?=E3=81=AE=20ImportError=20=E3=82=92=E8=A8=B1=E5=AE=B9=E3=81=97?= =?UTF-8?q?=E3=80=81M1=20=E5=AE=8C=E4=BA=86=E3=83=BBM2=20=E7=9D=80?= =?UTF-8?q?=E6=89=8B=E3=82=92=E3=83=9C=E3=83=BC=E3=83=89=E3=81=AB=E5=8F=8D?= =?UTF-8?q?=E6=98=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 理由: doctor が host を import できない間も他のサブコマンドが動くようにする(並行実装のため)。 進捗ボードは PR #19 のマージで M1 を完了にし、M2 を進行中にする。dev2027 の厳密再構築 PR 8 本を残件に載せる。 Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01BW1YQju1R8hU1GgE9LhLD4 --- docs/status/README.md | 15 ++++++++------- installer/grdm_dev/cli.py | 5 +++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/docs/status/README.md b/docs/status/README.md index afdda39..7ecc0d6 100644 --- a/docs/status/README.md +++ b/docs/status/README.md @@ -5,7 +5,8 @@ **Jump:** [English](#english) · [日本語](#japanese) -- Version / 版: 0.2 — 2026-11-05. **Learned:** the board must say what a CI check covers at the current milestone (Trivy: file system, report-only), or a green run is read as full coverage. / ボードは CI の検査が今の節目で何を対象にしているか(Trivy はファイルシステムに対する報告のみ)を書かなければ、緑の結果が全範囲の合格と読まれてしまうと分かった。 +- Version / 版: 0.3 — 2026-11-05. **Learned:** a milestone is marked done only when its PR is merged, so M1 flipped to done at the merge of PR #19 and not when the documents were written. / 節目は PR がマージされたときにだけ完了にする。M1 は文書を書いた時点ではなく PR #19 のマージで完了になった。 + 0.2 — 2026-11-05. **Learned:** the board must say what a CI check covers at the current milestone (Trivy: file system, report-only), or a green run is read as full coverage. / ボードは CI の検査が今の節目で何を対象にしているか(Trivy はファイルシステムに対する報告のみ)を書かなければ、緑の結果が全範囲の合格と読まれてしまうと分かった。 - Version / 版: 0.1 — 2026-11-05. **Learned:** without a single source of truth, it was unclear whether M1 completion meant "docs written" or "PR merged"; the board's explicit rules resolve ambiguity. / 単一の正本がなければ、M1 完了が「文書を書いた」か「PR をマージした」か分からず、ボードの明示的な規則で曖昧さを解消すると分かった。 - Normative for: [status/upstream/](upstream/README.md) and all milestone progress tracking. - Related: [../README.md](../README.md) · [demo/](../demo/README.md) · [spec/00_overview.md#5-milestone-ladder](./../spec/00_overview.md#english) @@ -21,8 +22,8 @@ | Milestone | Goal | Security gate | Status | |---|---|---|---| -| M1 | Docs skeleton, manifest, dev2027 repos exist; reviewed PRs merged to develop | Report + allow-list | **In progress** | -| M2 | Core 6 install with one command on Mac Studio; Playwright acceptance passes; amd64 builds | Report + allow-list (fewer entries than M1) | Planned | +| M1 | Docs skeleton, manifest, dev2027 repos exist; reviewed PRs merged to develop | Report + allow-list | ✅ **Done** (PR #19 merged 2026-11-05) | +| M2 | Core 6 install with one command on Mac Studio; Playwright acceptance passes; amd64 builds | Report + allow-list (fewer entries than M1) | **In progress** (branch feat/m2-installer) | | M3 | 5 subsystems start; one success + one rejection case each | Report + allow-list (fewer entries than M2) | Planned | | M4 | Waterbutler, mfr, osf.io on Python 3.13 | Stop on HIGH or above; first AI red-team run | Planned | | M5 | ES2 and mongo removed; ES8 + postgres 15 or later; distributable abroad | Zero CRITICAL/HIGH; zero open AI red-team paths | Planned | @@ -34,7 +35,7 @@ | docs skeleton (READMEs for all folders) | ✅ Written | | manifest/upstreams.json | ✅ Created | | dev2027 integration repos (11) | ✅ Created | -| Integration PR osf.io #1 | 🔄 Open | +| dev2027 strict reconstruction PRs (8 repos, ADR-01 §5; osf.io #1 closed as superseded by #2) | 🔄 Open, Codex Astra review in progress | | MkDocs site build (`site/`, strict build passes) | ✅ Built | | Guides migration to `docs/guides/` (pointers kept at old paths) | ✅ Done | | Codex Astra review of RDM-osf.io-dev2027 PR #1 | 🔄 r1/r2 done: request changes. R1 fixed; R2 awaits the owner's decision on ADR-01 §5; R3 is the owner's call | @@ -62,8 +63,8 @@ This board is the **single source of truth** for milestone progress: | 節目 | ゴール | セキュリティ門 | ステータス | |---|---|---|---| -| M1 | docs の骨格・manifest・dev2027 リポジトリ群がある。レビュー済み PR が develop にマージ | 報告+許容リスト | **進行中** | -| M2 | コア 6 本が Mac Studio で一発導入。Playwright 受入合格。amd64 ビルド | 報告+許容リスト(M1 より件数を減らす) | 計画中 | +| M1 | docs の骨格・manifest・dev2027 リポジトリ群がある。レビュー済み PR が develop にマージ | 報告+許容リスト | ✅ **完了**(PR #19 を 2026-11-05 にマージ) | +| M2 | コア 6 本が Mac Studio で一発導入。Playwright 受入合格。amd64 ビルド | 報告+許容リスト(M1 より件数を減らす) | **進行中**(ブランチ feat/m2-installer) | | M3 | サブシステム 5 本が起動。各 1 本の正常系+拒否ケース | 報告+許容リスト(M2 より件数を減らす) | 計画中 | | M4 | waterbutler・mfr・osf.io を Python 3.13 へ | HIGH 以上で停止。AI レッドチーム初回 | 計画中 | | M5 | ES2・mongo 廃止。ES8+postgres 15 以降。海外配布可 | CRITICAL/HIGH ゼロ。AI レッドチームの未解決経路ゼロ | 計画中 | @@ -75,7 +76,7 @@ This board is the **single source of truth** for milestone progress: | docs の骨格(全フォルダの README) | ✅ 作成済み | | manifest/upstreams.json | ✅ 作成 | | dev2027 統合リポジトリ(11) | ✅ 作成 | -| 統合 PR RDM-osf.io-dev2027 #1 | 🔄 作成済み(レビュー対応中) | +| dev2027 の厳密再構築 PR(8 リポジトリ、ADR-01 §5。osf.io #1 は #2 に置き換えて閉鎖) | 🔄 作成済み、Codex Astra レビュー中 | | MkDocs サイトのビルド(`site/`、strict ビルド合格) | ✅ 生成済み | | ガイドの `docs/guides/` への移植(旧パスに誘導を残す) | ✅ 完了 | | Codex Astra による RDM-osf.io-dev2027 PR #1 のレビュー | 🔄 r1/r2 完了: request changes。R1 修正済み、R2 は ADR-01 §5 の所有者判断待ち、R3 は所有者判断 | diff --git a/installer/grdm_dev/cli.py b/installer/grdm_dev/cli.py index e0c2074..2fe19c3 100644 --- a/installer/grdm_dev/cli.py +++ b/installer/grdm_dev/cli.py @@ -30,10 +30,11 @@ def build_parser() -> argparse.ArgumentParser: for name in SUBCOMMAND_MODULES: try: mod = importlib.import_module(f".{name}", __package__) - except ModuleNotFoundError as exc: + except ImportError as exc: # A subcommand (or one of its in-package helpers) is not implemented yet: hide it from # help instead of breaking every other command. Errors outside this package still raise. - if exc.name and exc.name.startswith(__package__): + missing = getattr(exc, "name", None) or "" + if missing.startswith(__package__) or f"from '{__package__}'" in str(exc): continue raise mod.register(sub) From 6985d0600c2a9dcec5c50331aebcb60fb4f23b13 Mon Sep 17 00:00:00 2001 From: Yusuke-KOMIYAMA Date: Thu, 5 Nov 2026 20:33:00 +0900 Subject: [PATCH 03/12] =?UTF-8?q?feat(installer):=20grdm-dev=20=E3=81=AE?= =?UTF-8?q?=E3=82=B5=E3=83=96=E3=82=B3=E3=83=9E=E3=83=B3=E3=83=89=E4=B8=80?= =?UTF-8?q?=E5=BC=8F=EF=BC=88M2=20=E7=AC=AC=201=20=E6=AE=B5:=20=E5=AE=9F?= =?UTF-8?q?=E6=A9=9F=E5=B0=8E=E5=85=A5=E5=89=8D=E3=81=AE=E5=AE=9F=E8=A3=85?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 理由: SPEC-02 に従い、doctor/plan/secrets/compose render/build/up・down・reset/health/scan/redteam preflight/ accept/manifest/docs/report/install を実装し、Mac Studio での導入(M2)に必要な部品を揃える。 内容: host.py(OS/CPU/メモリ/Docker 検出、注入可能な runner)、install.sh(bash 3.2、python3≥3.11、.venv、exec)、 manifest.py(tools/manifest_check.py を再利用、profile→services)、plan.py、compose.py(内部網 grdm、127.0.0.1 公開、 非 root、cap_drop ALL、no-new-privileges、資源制限、hardening.json の例外、上流設定の書き換え、生成物に 192.168.168.167 を含めば拒否)、 templates/*.json(25 サービス)、secrets.py(乱数、0600、既定パスワードなし、rotate)、build.py(統合リポを名前と SHA で clone、buildx、--push は ghcr.io)、health.py(--network で非ループバック待受を 40)、lifecycle.py、install.py(§2.1 の順序)、 scan.py(baseline/Trivy/Semgrep/gitleaks/ZAP、allow-list、節目別の門)、redteam.py(egress なし・対象限定の事前確認)、 accept.py と installer/acceptance/(pytest-playwright、C1〜C6 成功+拒否、S1〜S5 は M3 まで skip)、 manifest_cmd/docs/report_cmd、upstream(M2 未実装スタブ)。manifest に allowlist/baseline/milestone/hardening/redteam-targets を追加。 SPEC-01 に integration_sha(null 可、M2 受入で必須)を追加し manifest_check で検証。SPEC-04 のブラウザ導入手順を実装に合わせた。 代替案: compose を YAML 生成する案は PyYAML 依存が増えるため JSON(Compose が受理)を採用。 検証: installer/tests 174 件 OK、tools/tests OK、manifest_check PASSED、docs_check exit 0、mkdocs --strict 合格、 非 editable の pip install で templates と messages.tsv が同梱されることを確認、doctor を本機で実行。 未実施: Docker 実機でのビルド・起動・受入(次段。所見は docs/demo/runs/ に残す)。 Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01BW1YQju1R8hU1GgE9LhLD4 --- ...loper-guide_PR20_Manifest_Shibboleth_r3.md | 95 + docs/spec/01_manifest.md | 5 +- docs/spec/04_acceptance_tests.md | 7 +- installer/acceptance/README.md | 116 + installer/acceptance/__init__.py | 1 + installer/acceptance/conftest.py | 294 ++ installer/acceptance/pytest.ini | 11 + installer/acceptance/selectors.py | 75 + installer/acceptance/test_c1_login.py | 31 + .../acceptance/test_c2_create_project.py | 60 + installer/acceptance/test_c3_file_upload.py | 49 + installer/acceptance/test_c4_wiki_collab.py | 83 + installer/acceptance/test_c5_file_preview.py | 41 + installer/acceptance/test_c6_admin.py | 40 + installer/acceptance/test_s1_y_websocket.py | 16 + installer/acceptance/test_s2_rdmcp.py | 16 + installer/acceptance/test_s3_aipf.py | 16 + installer/acceptance/test_s4_oasys.py | 16 + installer/acceptance/test_s5_shibboleth.py | 16 + installer/build/lib/grdm_dev/__init__.py | 11 + installer/build/lib/grdm_dev/accept.py | 346 ++ installer/build/lib/grdm_dev/build.py | 186 ++ installer/build/lib/grdm_dev/cli.py | 89 + installer/build/lib/grdm_dev/compose.py | 712 ++++ installer/build/lib/grdm_dev/context.py | 54 + installer/build/lib/grdm_dev/docs.py | 77 + installer/build/lib/grdm_dev/doctor.py | 39 + installer/build/lib/grdm_dev/exit_codes.py | 38 + installer/build/lib/grdm_dev/health.py | 249 ++ installer/build/lib/grdm_dev/host.py | 301 ++ installer/build/lib/grdm_dev/install.py | 96 + installer/build/lib/grdm_dev/lifecycle.py | 142 + installer/build/lib/grdm_dev/manifest.py | 367 ++ installer/build/lib/grdm_dev/manifest_cmd.py | 134 + installer/build/lib/grdm_dev/messages.tsv | 14 + installer/build/lib/grdm_dev/plan.py | 189 ++ installer/build/lib/grdm_dev/redteam.py | 159 + installer/build/lib/grdm_dev/report.py | 39 + installer/build/lib/grdm_dev/report_cmd.py | 80 + installer/build/lib/grdm_dev/scan.py | 675 ++++ installer/build/lib/grdm_dev/secrets.py | 252 ++ .../build/lib/grdm_dev/templates/admin.json | 57 + .../templates/aipf_mcp_data_grdm.json | 23 + .../build/lib/grdm_dev/templates/api.json | 56 + .../build/lib/grdm_dev/templates/cas.json | 33 + .../lib/grdm_dev/templates/elasticsearch.json | 22 + .../grdm_dev/templates/elasticsearch6.json | 25 + .../lib/grdm_dev/templates/ember_osf_web.json | 37 + .../build/lib/grdm_dev/templates/fakecas.json | 20 + .../build/lib/grdm_dev/templates/mfr.json | 30 + .../build/lib/grdm_dev/templates/mongo.json | 24 + .../build/lib/grdm_dev/templates/oasys.json | 25 + .../lib/grdm_dev/templates/postgres.json | 31 + .../lib/grdm_dev/templates/rabbitmq.json | 24 + .../build/lib/grdm_dev/templates/rdmcp.json | 23 + .../build/lib/grdm_dev/templates/redis.json | 28 + .../build/lib/grdm_dev/templates/sharejs.json | 24 + .../lib/grdm_dev/templates/shibboleth_sp.json | 25 + .../lib/grdm_dev/templates/test_idp.json | 17 + .../build/lib/grdm_dev/templates/unoconv.json | 25 + .../build/lib/grdm_dev/templates/wb.json | 39 + .../lib/grdm_dev/templates/wb_worker.json | 38 + .../build/lib/grdm_dev/templates/web.json | 62 + .../build/lib/grdm_dev/templates/wiki.json | 28 + .../build/lib/grdm_dev/templates/worker.json | 52 + .../lib/grdm_dev/templates/y_websocket.json | 24 + installer/build/lib/grdm_dev/toon.py | 73 + installer/build/lib/grdm_dev/upstream.py | 32 + installer/grdm_dev.egg-info/PKG-INFO | 74 + installer/grdm_dev.egg-info/SOURCES.txt | 75 + .../grdm_dev.egg-info/dependency_links.txt | 1 + installer/grdm_dev.egg-info/entry_points.txt | 2 + installer/grdm_dev.egg-info/requires.txt | 10 + installer/grdm_dev.egg-info/top_level.txt | 1 + installer/grdm_dev/accept.py | 346 ++ installer/grdm_dev/build.py | 186 ++ installer/grdm_dev/cli.py | 28 +- installer/grdm_dev/compose.py | 712 ++++ installer/grdm_dev/docs.py | 77 + installer/grdm_dev/doctor.py | 13 +- installer/grdm_dev/health.py | 249 ++ installer/grdm_dev/host.py | 301 ++ installer/grdm_dev/install.py | 96 + installer/grdm_dev/lifecycle.py | 142 + installer/grdm_dev/manifest.py | 367 ++ installer/grdm_dev/manifest_cmd.py | 134 + installer/grdm_dev/plan.py | 189 ++ installer/grdm_dev/redteam.py | 159 + installer/grdm_dev/report_cmd.py | 80 + installer/grdm_dev/scan.py | 675 ++++ installer/grdm_dev/secrets.py | 252 ++ installer/grdm_dev/templates/admin.json | 57 + .../templates/aipf_mcp_data_grdm.json | 23 + installer/grdm_dev/templates/api.json | 56 + installer/grdm_dev/templates/cas.json | 33 + .../grdm_dev/templates/elasticsearch.json | 22 + .../grdm_dev/templates/elasticsearch6.json | 25 + .../grdm_dev/templates/ember_osf_web.json | 37 + installer/grdm_dev/templates/fakecas.json | 20 + installer/grdm_dev/templates/mfr.json | 30 + installer/grdm_dev/templates/mongo.json | 24 + installer/grdm_dev/templates/oasys.json | 25 + installer/grdm_dev/templates/postgres.json | 31 + installer/grdm_dev/templates/rabbitmq.json | 24 + installer/grdm_dev/templates/rdmcp.json | 23 + installer/grdm_dev/templates/redis.json | 28 + installer/grdm_dev/templates/sharejs.json | 24 + .../grdm_dev/templates/shibboleth_sp.json | 25 + installer/grdm_dev/templates/test_idp.json | 17 + installer/grdm_dev/templates/unoconv.json | 25 + installer/grdm_dev/templates/wb.json | 39 + installer/grdm_dev/templates/wb_worker.json | 38 + installer/grdm_dev/templates/web.json | 62 + installer/grdm_dev/templates/wiki.json | 28 + installer/grdm_dev/templates/worker.json | 52 + installer/grdm_dev/templates/y_websocket.json | 24 + installer/grdm_dev/toon.py | 4 +- installer/grdm_dev/upstream.py | 32 + installer/install.sh | 145 + installer/pyproject.toml | 4 +- installer/tests/test_accept.py | 207 ++ installer/tests/test_build.py | 165 + installer/tests/test_compose.py | 256 ++ installer/tests/test_docs.py | 63 + installer/tests/test_doctor.py | 103 + installer/tests/test_health.py | 134 + installer/tests/test_host.py | 184 + installer/tests/test_install.py | 89 + installer/tests/test_install_sh.py | 117 + installer/tests/test_lifecycle.py | 120 + installer/tests/test_manifest.py | 137 + installer/tests/test_manifest_cmd.py | 94 + installer/tests/test_plan.py | 109 + installer/tests/test_redteam.py | 138 + installer/tests/test_report_cmd.py | 71 + installer/tests/test_scan.py | 309 ++ installer/tests/test_secrets.py | 117 + manifest/allowlist.baseline.json | 5 + manifest/allowlist.json | 6 + manifest/hardening.json | 127 + manifest/milestone.json | 5 + manifest/redteam-targets.json | 14 + manifest/upstreams.json | 20 + site/404.html | 21 + site/assets/index.html | 21 + .../index.html | 80 +- .../decisions/ADR-02_Network_Model/index.html | 21 + .../ADR-03_Staged_Security_Gate/index.html | 21 + .../ADR-04_AI_Autonomy_and_Roles/index.html | 106 +- site/decisions/index.html | 21 + site/demo/index.html | 21 + site/demo/runs/index.html | 21 + .../admin-addon/README.legacy/index.html | 21 + site/guides/admin-addon/index.html | 21 + site/guides/api/Decorators/index.html | 21 + site/guides/api/README.legacy/index.html | 21 + site/guides/api/index.html | 21 + site/guides/ec2/README.legacy/index.html | 21 + site/guides/ec2/index.html | 21 + .../environment/README.legacy/index.html | 21 + site/guides/environment/index.html | 21 + site/guides/index.html | 21 + .../screen-expansion/README.legacy/index.html | 21 + site/guides/screen-expansion/index.html | 21 + site/guides/skeleton/README.legacy/index.html | 21 + site/guides/skeleton/index.html | 21 + .../storage-addon/README.legacy/index.html | 21 + site/guides/storage-addon/index.html | 21 + site/handoff/index.html | 21 + site/index.html | 21 + .../index.html | 21 + site/policy/index.html | 21 + site/reference/REF-01_Glossary/index.html | 21 + site/reference/index.html | 21 + .../index.html | 21 + .../index.html | 23 +- .../index.html | 2964 +++++++++++++++++ .../index.html | 23 +- .../index.html | 21 + site/reviews/index.html | 21 + site/search/search_index.json | 2 +- site/spec/00_overview/index.html | 21 + site/spec/01_manifest/index.html | 34 +- site/spec/02_installer_cli/index.html | 21 + site/spec/03_security_gate/index.html | 21 + site/spec/04_acceptance_tests/index.html | 28 +- site/spec/05_upstream_tracking/index.html | 21 + .../06_documentation_conventions/index.html | 21 + site/spec/index.html | 21 + site/status/index.html | 40 +- site/status/upstream/index.html | 21 + tools/manifest_check.py | 8 +- 192 files changed, 17939 insertions(+), 58 deletions(-) create mode 100644 docs/reviews/2026-11-05_RDM-developer-guide_PR20_Manifest_Shibboleth_r3.md create mode 100644 installer/acceptance/README.md create mode 100644 installer/acceptance/__init__.py create mode 100644 installer/acceptance/conftest.py create mode 100644 installer/acceptance/pytest.ini create mode 100644 installer/acceptance/selectors.py create mode 100644 installer/acceptance/test_c1_login.py create mode 100644 installer/acceptance/test_c2_create_project.py create mode 100644 installer/acceptance/test_c3_file_upload.py create mode 100644 installer/acceptance/test_c4_wiki_collab.py create mode 100644 installer/acceptance/test_c5_file_preview.py create mode 100644 installer/acceptance/test_c6_admin.py create mode 100644 installer/acceptance/test_s1_y_websocket.py create mode 100644 installer/acceptance/test_s2_rdmcp.py create mode 100644 installer/acceptance/test_s3_aipf.py create mode 100644 installer/acceptance/test_s4_oasys.py create mode 100644 installer/acceptance/test_s5_shibboleth.py create mode 100644 installer/build/lib/grdm_dev/__init__.py create mode 100644 installer/build/lib/grdm_dev/accept.py create mode 100644 installer/build/lib/grdm_dev/build.py create mode 100644 installer/build/lib/grdm_dev/cli.py create mode 100644 installer/build/lib/grdm_dev/compose.py create mode 100644 installer/build/lib/grdm_dev/context.py create mode 100644 installer/build/lib/grdm_dev/docs.py create mode 100644 installer/build/lib/grdm_dev/doctor.py create mode 100644 installer/build/lib/grdm_dev/exit_codes.py create mode 100644 installer/build/lib/grdm_dev/health.py create mode 100644 installer/build/lib/grdm_dev/host.py create mode 100644 installer/build/lib/grdm_dev/install.py create mode 100644 installer/build/lib/grdm_dev/lifecycle.py create mode 100644 installer/build/lib/grdm_dev/manifest.py create mode 100644 installer/build/lib/grdm_dev/manifest_cmd.py create mode 100644 installer/build/lib/grdm_dev/messages.tsv create mode 100644 installer/build/lib/grdm_dev/plan.py create mode 100644 installer/build/lib/grdm_dev/redteam.py create mode 100644 installer/build/lib/grdm_dev/report.py create mode 100644 installer/build/lib/grdm_dev/report_cmd.py create mode 100644 installer/build/lib/grdm_dev/scan.py create mode 100644 installer/build/lib/grdm_dev/secrets.py create mode 100644 installer/build/lib/grdm_dev/templates/admin.json create mode 100644 installer/build/lib/grdm_dev/templates/aipf_mcp_data_grdm.json create mode 100644 installer/build/lib/grdm_dev/templates/api.json create mode 100644 installer/build/lib/grdm_dev/templates/cas.json create mode 100644 installer/build/lib/grdm_dev/templates/elasticsearch.json create mode 100644 installer/build/lib/grdm_dev/templates/elasticsearch6.json create mode 100644 installer/build/lib/grdm_dev/templates/ember_osf_web.json create mode 100644 installer/build/lib/grdm_dev/templates/fakecas.json create mode 100644 installer/build/lib/grdm_dev/templates/mfr.json create mode 100644 installer/build/lib/grdm_dev/templates/mongo.json create mode 100644 installer/build/lib/grdm_dev/templates/oasys.json create mode 100644 installer/build/lib/grdm_dev/templates/postgres.json create mode 100644 installer/build/lib/grdm_dev/templates/rabbitmq.json create mode 100644 installer/build/lib/grdm_dev/templates/rdmcp.json create mode 100644 installer/build/lib/grdm_dev/templates/redis.json create mode 100644 installer/build/lib/grdm_dev/templates/sharejs.json create mode 100644 installer/build/lib/grdm_dev/templates/shibboleth_sp.json create mode 100644 installer/build/lib/grdm_dev/templates/test_idp.json create mode 100644 installer/build/lib/grdm_dev/templates/unoconv.json create mode 100644 installer/build/lib/grdm_dev/templates/wb.json create mode 100644 installer/build/lib/grdm_dev/templates/wb_worker.json create mode 100644 installer/build/lib/grdm_dev/templates/web.json create mode 100644 installer/build/lib/grdm_dev/templates/wiki.json create mode 100644 installer/build/lib/grdm_dev/templates/worker.json create mode 100644 installer/build/lib/grdm_dev/templates/y_websocket.json create mode 100644 installer/build/lib/grdm_dev/toon.py create mode 100644 installer/build/lib/grdm_dev/upstream.py create mode 100644 installer/grdm_dev.egg-info/PKG-INFO create mode 100644 installer/grdm_dev.egg-info/SOURCES.txt create mode 100644 installer/grdm_dev.egg-info/dependency_links.txt create mode 100644 installer/grdm_dev.egg-info/entry_points.txt create mode 100644 installer/grdm_dev.egg-info/requires.txt create mode 100644 installer/grdm_dev.egg-info/top_level.txt create mode 100644 installer/grdm_dev/accept.py create mode 100644 installer/grdm_dev/build.py create mode 100644 installer/grdm_dev/compose.py create mode 100644 installer/grdm_dev/docs.py create mode 100644 installer/grdm_dev/health.py create mode 100644 installer/grdm_dev/host.py create mode 100644 installer/grdm_dev/install.py create mode 100644 installer/grdm_dev/lifecycle.py create mode 100644 installer/grdm_dev/manifest.py create mode 100644 installer/grdm_dev/manifest_cmd.py create mode 100644 installer/grdm_dev/plan.py create mode 100644 installer/grdm_dev/redteam.py create mode 100644 installer/grdm_dev/report_cmd.py create mode 100644 installer/grdm_dev/scan.py create mode 100644 installer/grdm_dev/secrets.py create mode 100644 installer/grdm_dev/templates/admin.json create mode 100644 installer/grdm_dev/templates/aipf_mcp_data_grdm.json create mode 100644 installer/grdm_dev/templates/api.json create mode 100644 installer/grdm_dev/templates/cas.json create mode 100644 installer/grdm_dev/templates/elasticsearch.json create mode 100644 installer/grdm_dev/templates/elasticsearch6.json create mode 100644 installer/grdm_dev/templates/ember_osf_web.json create mode 100644 installer/grdm_dev/templates/fakecas.json create mode 100644 installer/grdm_dev/templates/mfr.json create mode 100644 installer/grdm_dev/templates/mongo.json create mode 100644 installer/grdm_dev/templates/oasys.json create mode 100644 installer/grdm_dev/templates/postgres.json create mode 100644 installer/grdm_dev/templates/rabbitmq.json create mode 100644 installer/grdm_dev/templates/rdmcp.json create mode 100644 installer/grdm_dev/templates/redis.json create mode 100644 installer/grdm_dev/templates/sharejs.json create mode 100644 installer/grdm_dev/templates/shibboleth_sp.json create mode 100644 installer/grdm_dev/templates/test_idp.json create mode 100644 installer/grdm_dev/templates/unoconv.json create mode 100644 installer/grdm_dev/templates/wb.json create mode 100644 installer/grdm_dev/templates/wb_worker.json create mode 100644 installer/grdm_dev/templates/web.json create mode 100644 installer/grdm_dev/templates/wiki.json create mode 100644 installer/grdm_dev/templates/worker.json create mode 100644 installer/grdm_dev/templates/y_websocket.json create mode 100644 installer/grdm_dev/upstream.py create mode 100755 installer/install.sh create mode 100644 installer/tests/test_accept.py create mode 100644 installer/tests/test_build.py create mode 100644 installer/tests/test_compose.py create mode 100644 installer/tests/test_docs.py create mode 100644 installer/tests/test_doctor.py create mode 100644 installer/tests/test_health.py create mode 100644 installer/tests/test_host.py create mode 100644 installer/tests/test_install.py create mode 100644 installer/tests/test_install_sh.py create mode 100644 installer/tests/test_lifecycle.py create mode 100644 installer/tests/test_manifest.py create mode 100644 installer/tests/test_manifest_cmd.py create mode 100644 installer/tests/test_plan.py create mode 100644 installer/tests/test_redteam.py create mode 100644 installer/tests/test_report_cmd.py create mode 100644 installer/tests/test_scan.py create mode 100644 installer/tests/test_secrets.py create mode 100644 manifest/allowlist.baseline.json create mode 100644 manifest/allowlist.json create mode 100644 manifest/hardening.json create mode 100644 manifest/milestone.json create mode 100644 manifest/redteam-targets.json create mode 100644 site/reviews/2026-11-05_RDM-developer-guide_M1_Skeleton_PR_r3/index.html diff --git a/docs/reviews/2026-11-05_RDM-developer-guide_PR20_Manifest_Shibboleth_r3.md b/docs/reviews/2026-11-05_RDM-developer-guide_PR20_Manifest_Shibboleth_r3.md new file mode 100644 index 0000000..688d140 --- /dev/null +++ b/docs/reviews/2026-11-05_RDM-developer-guide_PR20_Manifest_Shibboleth_r3.md @@ -0,0 +1,95 @@ +# REV PR20 Manifest Shibboleth review r3 / Manifest Shibboleth レビュー r3 + +> **Summary:** The Shibboleth-SP tracking bullets are corrected and the manifest checks pass. Request changes because ADR-01 §5 still requires a public starting point for private-only components. +> **概要:** Shibboleth-SP の追跡記述は修正済みで manifest 検査も合格です。ADR-01 §5 が private 専用部品にも公開起点を要求するため、要修正とします。 + +**Jump:** [English](#english) · [日本語](#japanese) + +- Version / 版: 0.1 — 2026-11-05. **Learned:** fixing tracking bullets does not resolve a conflicting universal bootstrap procedure. / 追跡の箇条書きを直しても、全対象に適用する初回構築手順の矛盾は解消しないと分かった。 +- Applies to: [PR #20](https://github.com/RCOSDP/RDM-developer-guide/pull/20), reviewed by REV(担当レビュワ, Codex Astra). A PR is a proposed change / PR は変更の提案です。 +- Related: [Review index](README.md) · [r2](2026-11-05_dev2027_Strict_Reconstruction_PRs_r2.md) · [SPEC-06](../spec/06_documentation_conventions.md) · [SPEC-01](../spec/01_manifest.md) · [ADR-01](../decisions/ADR-01_Integration_Repository_Placement.md) · [Shared glossary](../reference/REF-01_Glossary.md). +- Used by: [Integration status](../status/README.md), QAE and the owner for verification and acceptance / QAE(QA担当)と所有者の検証・採否判断。 + +--- + + +## English + +[→ 日本語版へ](#japanese) + +### Verdict and scope + +**Verdict: request changes.** R2-01's §3 correction is complete; its requested §5 scope correction remains open as R3-01 (P2, a correctness issue requiring a fix before acceptance). + +A repository stores change history; a branch names a path through it. A commit is a saved change and its SHA is its fingerprint. A manifest is the component packing list, an upstream is its original source, and ADR is a decision record. See the [shared glossary](../reference/REF-01_Glossary.md). + +Reviewed head `b4bfc9919c26df67544328fabd265fe424c3126f`, from `fix/manifest-shibboleth-public` to `develop`. Files were read through `gh api` at that exact head; the local `feat/m2-installer` checkout was not used as PR evidence. The correction is commit `488e61ca154910055cd2509c9af0fb9e9821b147`; the later head commit adds the r1/r2 review records. This is a written verdict, not a GitHub approval or request-changes review action. + +### Resolved: Shibboleth-SP tracking and manifest + +Both ADR-01 §1 halves identify public `RDM-Shibboleth-SP` on `main`. Both §3 bullets (lines 60 and 150) now explicitly add `upstream/public-main`, retain `upstream/private-main`, and limit the no-public-upstream statement to OASys, rdmcp and aipf_mcp_data_grdm. For Shibboleth-SP, §5's public-first construction agrees with those statements. + +JSON (structured text data) and TOON (its compact text form) agree on the two Shibboleth-SP upstream rows, their order, and all seven fields. The public row names `RDM-Shibboleth-SP`, branch `main`, kind `public`, tracking branch `upstream/public-main`, status `merged`, SHA `7f1125bb2f5bccdce1b1fc55d1dcff602bc7d38a`, and date `2026-11-05`. The private row remains second, with SHA `218b07f4143834278e5289a2c95ee8fe6ff01cf1` and `upstream/private-main`. + +### R3-01: §5 still includes components without a public upstream + +At ADR-01 lines **96–99** (English) and **186–189** (Japanese), §5 says the procedure applies to every integration repository and directs the reader to start at `upstream/public-`, then merge the private branch. Yet §1 and §3 explicitly say OASys, rdmcp and aipf_mcp_data_grdm have only private upstreams and start at the private tip. Following §5 for these three components requires a nonexistent public starting point. The universal consequence at lines **104 / 194** also needs the same scope limitation. + +**Required correction:** in both language halves, restrict the public-first §5 procedure and consequence to components with a public upstream. Explicitly refer private-only components to the §1 private-tip start rule. Preserve the public-first rule for Shibboleth-SP. This is the outstanding §5 request already recorded in r2, not a new manifest defect. + +### Verification evidence and limits + +CI means automatic checks after a change. All six checks returned pass: Build MkDocs Site, Check Links, Manifest validation and private-URL policy, Secret scan (gitleaks), Semgrep static analysis, and Trivy filesystem scan. Trivy remains report-only at M1 (the first delivery milestone). + +The [manifest job log](https://github.com/RCOSDP/RDM-developer-guide/actions/runs/42019352111/job/127217919499) explicitly runs `python3 tools/manifest_check.py --manifest-only` and reports zero findings and PASSED, including JSON/TOON parity. This CI run belongs to head `b4bfc9919c26df67544328fabd265fe424c3126f`; it tested the proposed merge `3a7df1f`. The contents API confirms both manifest files have identical file fingerprints at the PR head and that merge: JSON `40d14dc2847028e126c4b485546af4a31f4f4f16`, TOON `93d34734b443001548a5374aed97e790149c3428`. Thus the parity result covers the reviewed files. No local checker execution is claimed. + +GitHub access used only `gh`. No merge, approval, closure, push, or commit was performed. The local record was manually checked for bilingual structure, anchors, Jump, version, glossary and relative-link targets. The coordinator still needs to publish and index this record; the author needs to fix R3-01 and obtain re-review. + +--- + + +## 日本語 + +[→ To English](#english) + +### 判定と範囲 + +**判定: request changes(要修正)。** R2-01 の §3 修正は完了しました。依頼済みの §5 の範囲修正は R3-01(P2、受け入れ前に直すべき正しさの問題)として残ります。 + +リポジトリは変更履歴の保管場所、ブランチは履歴の道筋の名前です。コミットは保存した変更、SHA はその指紋です。manifest は部品の梱包表、上流は元の取得先、ADR は決定の記録です。[共通用語集](../reference/REF-01_Glossary.md)も参照してください。 + +対象 head は `b4bfc9919c26df67544328fabd265fe424c3126f`、`fix/manifest-shibboleth-public` から `develop` への変更です。対象 head 固定の `gh api` で読み、ローカルの `feat/m2-installer` は PR の証拠に使っていません。修正は `488e61ca154910055cd2509c9af0fb9e9821b147`、後続の head コミットは r1/r2 記録の追加です。文章による判定であり、GitHub の承認・変更要求レビュー操作ではありません。 + +### 解決済み: Shibboleth-SP の追跡と manifest + +ADR-01 §1 の両言語は公開 `RDM-Shibboleth-SP` の `main` を示します。§3 の両言語の箇条書き(60行と150行)は `upstream/public-main` を明記し、`upstream/private-main` も保持し、「公開上流なし」を OASys・rdmcp・aipf_mcp_data_grdm に限定しました。Shibboleth-SP については §5 の公開起点手順も一致します。 + +JSON(構造のある文字データ)と TOON(その短い表記)は、Shibboleth-SP の上流2行、順序、全7項目が一致します。公開行は `RDM-Shibboleth-SP`、branch `main`、kind `public`、tracking_branch `upstream/public-main`、status `merged`、SHA `7f1125bb2f5bccdce1b1fc55d1dcff602bc7d38a`、日付 `2026-11-05` です。非公開行は2番目で、SHA `218b07f4143834278e5289a2c95ee8fe6ff01cf1` と `upstream/private-main` を保持します。 + +### R3-01: §5 が公開上流のない部品も対象にしている + +ADR-01 の **96〜99行**(英語)と **186〜189行**(日本語)は、全統合リポジトリに対し `upstream/public-` から始めて非公開ブランチを取り込むよう要求しています。しかし §1・§3 は OASys・rdmcp・aipf_mcp_data_grdm が private 専用であり、private の先端から始めると明記しています。この3部品で §5 に従うと、存在しない公開起点が必要になります。**104行 / 194行**の全対象に向けた結果の記述にも同じ範囲の限定が必要です。 + +**必要な修正:** 英日両方で §5 の公開起点手順と結果を、公開上流がある部品に限定してください。private 専用部品は §1 の private 先端からの開始規則を参照させてください。Shibboleth-SP の公開起点は維持します。r2 に記録済みの §5 修正依頼の残件であり、新しい manifest の不備ではありません。 + +### 検証証跡と限界 + +CI は変更後の自動検査です。6件すべて成功しました。MkDocs サイト構築、リンク、manifest と非公開 URL 規則、gitleaks、Semgrep、Trivy です。Trivy は M1(最初の開発到達点)では報告のみです。 + +[manifest 検査ログ](https://github.com/RCOSDP/RDM-developer-guide/actions/runs/42019352111/job/127217919499)には `python3 tools/manifest_check.py --manifest-only` の実行と、JSON/TOON 突合を含む指摘0件・PASSED が記録されています。head `b4bfc9919c26df67544328fabd265fe424c3126f` に対応する CI は仮のマージ `3a7df1f` を検査しました。contents API で両地点のファイル指紋を照合し、JSON は `40d14dc2847028e126c4b485546af4a31f4f4f16`、TOON は `93d34734b443001548a5374aed97e790149c3428` とそれぞれ一致しました。このため突合結果はレビュー対象にも適用できます。ローカルで検査を実行したとは主張しません。 + +GitHub へのアクセスは `gh` のみで、マージ・承認・クローズ・push・commit はしていません。ローカル記録の英日構成、アンカー、Jump、版、用語注、相対リンク先を手動確認しました。調整担当による記録の公開・索引追加と、作成者による R3-01 修正・再レビューが残ります。 + +--- + +## Glossary / 用語 + +| Term | English note | 日本語注 | +|---|---|---| +| PR | A proposed change for review. | レビューする変更の提案。 | +| SHA | A saved change or file's fingerprint. | 保存した変更やファイルの指紋。 | +| Tracking branch | A named copy following a source branch. | 元のブランチを追いかける写し。 | +| Bootstrap | The first construction of an environment. | 環境を最初に組み立てること。 | +| CI | Checks that run automatically after changes. | 変更後に自動で動く検査。 | +| JSON / TOON | Structured text data and its compact notation. | 構造のある文字データとその短い表記。 | +| QAE | Quality Assurance Engineer. | QA担当。 | diff --git a/docs/spec/01_manifest.md b/docs/spec/01_manifest.md index 73b4316..c00aca1 100644 --- a/docs/spec/01_manifest.md +++ b/docs/spec/01_manifest.md @@ -5,7 +5,8 @@ **Jump:** [English](#english) · [日本語](#japanese) -- Version / 版: 0.2 — 2026-11-05. **Learned:** a TOON block that is only an example must say so, or readers and the checker treat it as data that has to stay in step with the JSON. / 例にすぎない TOON ブロックはそう明記しないと、読者も検査も JSON と一致させるべきデータとして扱ってしまうと分かった。 +- Version / 版: 0.3 — 2026-11-05. **Learned:** building from "the tip of develop" is not reproducible unless the manifest pins that tip, so each component needs an `integration_sha` (nullable until the first strict merge). / 「develop の先端」から組むのでは再現できないため、各部品に `integration_sha`(最初の厳密マージまでは null 可)が要ると分かった。 + 0.2 — 2026-11-05. **Learned:** a TOON block that is only an example must say so, or readers and the checker treat it as data that has to stay in step with the JSON. / 例にすぎない TOON ブロックはそう明記しないと、読者も検査も JSON と一致させるべきデータとして扱ってしまうと分かった。 - Version / 版: 0.1 — 2026-11-05. **Learned:** the public osf.io `develop` (2026-11-05) is already newer than its `-private` twin (2026-11-02), so "the latest" is not one answer; only a file that pins each upstream to a SHA can say what "consistent" means. / 公開 osf.io の `develop`(2026-11-05)は `-private`(2026-11-02)より既に新しく、「最新」は一つに決まらない。各上流を SHA で固定したファイルがあってこそ「矛盾なく」を定義できると分かった。 - Normative for: `manifest/upstreams.json` (canonical), `manifest/upstreams.toon` (excerpt), `manifest/README.md`, the `manifest` subcommand of `grdm-dev` ([SPEC-02](02_installer_cli.md)), and every document that quotes the manifest. - Related: [SPEC-00 Overview](00_overview.md) · [SPEC-05 Upstream tracking](05_upstream_tracking.md) · [SPEC-06 Documentation conventions](06_documentation_conventions.md) · [POL-01 Position](../policy/POL-01_Developer_Environment_2027_Position.md) · [ADR-01 Integration repository placement](../decisions/ADR-01_Integration_Repository_Placement.md) · [ADR-03 Staged security gate](../decisions/ADR-03_Staged_Security_Gate.md) · [docs/README.md](../README.md) @@ -46,6 +47,7 @@ The top level has `schema_version` (integer, currently `1`), `generated_at` (ISO | `services[]` | list | The Compose service names the component provides, as used in [SPEC-02 §4](02_installer_cli.md#english) (for example `web`, `api`, `admin`, `worker` for `osf.io`). Never empty. | | `integration_repo` | string or `null` | Name of the private integration repository, `RDM--dev2027`. Name only, never a URL. `null` for `infra`. | | `integration_branch` | string or `null` | Always `develop`; `null` for `infra`. | +| `integration_sha` | string (40 hex) or null | The commit at the tip of the integration branch `develop` that this manifest pins. `grdm-dev build` and `compose render` use it for image tags. May be `null` until the strict reconstruction PRs are merged; required for M2 acceptance. | | `upstreams[]` | list | Each: `repo` (name), `branch`, `kind` (`public` \| `private` \| `cos`), `tracking_branch` (named by rule 7), `status` (`merged` \| `reference` \| `candidate`), `sha` (40 lowercase hex), `fetched_at` (ISO date). Empty for `infra`. | | `adopted_prs[]` | list | Each: `repo`, `number`, `title`, `reason`, `status` (`adopted`). PRs applied on top of the merged upstreams. | | `candidate_prs[]` | list | Same shape; `status` is `candidate` or `rejected`. Not built. | @@ -175,6 +177,7 @@ checks[13]{id,rule,severity}: | `services[]` | 配列 | その部品が提供する Compose のサービス名。[SPEC-02 §4](02_installer_cli.md#japanese) と同じ名前(例: `osf.io` は `web`、`api`、`admin`、`worker`)。空にしない。 | | `integration_repo` | 文字列または `null` | 非公開の統合リポジトリの名前 `RDM--dev2027`。名前だけで URL は書かない。`infra` は `null`。 | | `integration_branch` | 文字列または `null` | 常に `develop`。`infra` は `null`。 | +| `integration_sha` | string (40 hex) or null | The commit at the tip of the integration branch `develop` that this manifest pins. `grdm-dev build` and `compose render` use it for image tags. May be `null` until the strict reconstruction PRs are merged; required for M2 acceptance. | | `upstreams[]` | 配列 | 各要素: `repo`(名前)、`branch`、`kind`(`public` \| `private` \| `cos`)、`tracking_branch`(規則 7 で命名)、`status`(`merged` \| `reference` \| `candidate`)、`sha`(小文字 16 進 40 文字)、`fetched_at`(ISO 日付)。`infra` は空。 | | `adopted_prs[]` | 配列 | 各要素: `repo`、`number`、`title`、`reason`、`status`(`adopted`)。上流をマージした上に適用する PR。 | | `candidate_prs[]` | 配列 | 同じ形。`status` は `candidate` か `rejected`。組まない。 | diff --git a/docs/spec/04_acceptance_tests.md b/docs/spec/04_acceptance_tests.md index fd62b7c..14d89e7 100644 --- a/docs/spec/04_acceptance_tests.md +++ b/docs/spec/04_acceptance_tests.md @@ -5,7 +5,8 @@ **Jump:** [English](#english) · [日本語](#japanese) -- Version / 版: 0.2 — 2026-11-05. **Learned:** a case that may skip in the profile a milestone is judged on cannot be a pass criterion, and a diagram that renders in one language half must parse in the other too. / 節目を判定するプロファイルでスキップし得るケースは合格基準になれず、片方の言語で描ける図はもう片方でも解析できなければならないと分かった。 +- Version / 版: 0.3 — 2026-11-05. **Learned:** downloading a browser inside a test run would make the run depend on the network, so installation is a separate, explicit step and `accept` only checks for it. / 試験の実行中にブラウザをダウンロードすると実行がネットワークに依存するため、導入は別の明示的な手順にし、`accept` は有無を確かめるだけにする。 + 0.2 — 2026-11-05. **Learned:** a case that may skip in the profile a milestone is judged on cannot be a pass criterion, and a diagram that renders in one language half must parse in the other too. / 節目を判定するプロファイルでスキップし得るケースは合格基準になれず、片方の言語で描ける図はもう片方でも解析できなければならないと分かった。 - Version / 版: 0.1 — 2026-11-05. **Learned:** a scenario without a rejection case proves only that the happy path renders; permission and authentication bugs are found by the case that must fail. / 拒否ケースのないシナリオは画面が出ることしか示さず、権限と認証の不具合は「失敗しなければならないケース」で初めて見つかると分かった。 - Normative for: `installer/acceptance/`, `grdm-dev accept`, `docs/demo/` result files, CI workflow `acceptance-arm64`. - Related: [SPEC-00 Overview](00_overview.md) · [SPEC-01 Manifest](01_manifest.md) · [SPEC-02 Installer CLI](02_installer_cli.md) · [SPEC-03 Security Gate](03_security_gate.md) · [SPEC-05 Upstream Tracking](05_upstream_tracking.md) · [SPEC-06 Documentation Conventions](06_documentation_conventions.md) · [ADR-02 Network Model](../decisions/ADR-02_Network_Model.md) · [ADR-03 Staged Security Gate](../decisions/ADR-03_Staged_Security_Gate.md) · [POL-01 Position](../policy/POL-01_Developer_Environment_2027_Position.md) · [docs/README.md](../README.md) @@ -23,7 +24,7 @@ Acceptance tests drive a real browser against the environment that [SPEC-02](02_ - Location: `installer/acceptance/`, one file per scenario, named `test_.py`. - Runner: `grdm-dev accept [--profile ...] [--only ] [--json]`. It runs `pytest` inside the same `.venv/` that `install.sh` created ([SPEC-02 §2.2](02_installer_cli.md#english)) and exits 60 if any test fails. -- Browsers: `playwright install chromium` is run by `grdm-dev accept` on first use, with `PLAYWRIGHT_BROWSERS_PATH=.venv/.playwright/`. Nothing is installed outside the venv. +- Browsers: `grdm-dev accept` checks that Chromium is present under `PLAYWRIGHT_BROWSERS_PATH=.venv/.playwright/` and, if not, exits 2 and prints the exact install command (`pip install -e "installer[accept]"` then `playwright install chromium` with that variable). The download is a one-time setup step, never part of a test run. Nothing is installed outside the venv. - Target URL: always `http://127.0.0.1:` as published by `compose render` ([ADR-02](../decisions/ADR-02_Network_Model.md); defaults in the ports table of [SPEC-02 §4](02_installer_cli.md#2-en-ports)). Tests read the ports from `runtime/.env` (`GRDM_PORT_`); they never hard-code them. ### 2. Test tiers @@ -142,7 +143,7 @@ The Mac Studio self-hosted runner is registered only with the private `-dev2027` - 置き場: `installer/acceptance/`。シナリオごとに一ファイル、名前は `test_<シナリオ>.py`。 - 実行器: `grdm-dev accept [--profile ...] [--only <シナリオ>] [--json]`。`install.sh` が作った同じ `.venv/` の中で `pytest` を動かし([SPEC-02 §2.2](02_installer_cli.md#japanese))、一件でも失敗すれば終了 60。 -- ブラウザ: 初回に `grdm-dev accept` が `playwright install chromium` を実行し、`PLAYWRIGHT_BROWSERS_PATH=.venv/.playwright/` に入れる。venv の外には何も入れない。 +- ブラウザ: `grdm-dev accept` は `PLAYWRIGHT_BROWSERS_PATH=.venv/.playwright/` に Chromium があるかを確かめ、なければ終了コード 2 で導入コマンド(`pip install -e "installer[accept]"` のあと同じ変数を付けて `playwright install chromium`)をそのまま表示する。ダウンロードは一度だけの準備であり、試験の実行には含めない。venv の外には何も入れない。 - 対象 URL: 常に `compose render` が公開した `http://127.0.0.1:<ポート>`([ADR-02](../decisions/ADR-02_Network_Model.md)。既定値は [SPEC-02 §4](02_installer_cli.md#2-ja-ports) のポート表)。ポートは `runtime/.env`(`GRDM_PORT_`)から読み、決め打ちしない。 ### 2. 試験の段 diff --git a/installer/acceptance/README.md b/installer/acceptance/README.md new file mode 100644 index 0000000..9e6dac3 --- /dev/null +++ b/installer/acceptance/README.md @@ -0,0 +1,116 @@ +# Acceptance Suite / 受入試験スイート + +> **Summary:** The Playwright Python tests that `grdm-dev accept` runs against an installed environment: how to run them, which scenario lives in which file, and how the evidence folder is laid out. Normative text is [SPEC-04](../../docs/spec/04_acceptance_tests.md). +> **概要:** `grdm-dev accept` が導入済み環境に対して動かす Playwright Python の試験。実行方法、どのシナリオがどのファイルにあるか、証跡フォルダの中身を説明する。規範は [SPEC-04](../../docs/spec/04_acceptance_tests.md)。 + +**Jump:** [English](#english) · [日本語](#japanese) + +- Version / 版: 0.1 — 2026-11-05. **Learned:** a file named `selectors.py` shadows the standard-library module of the same name unless the suite is a package and imports it by package path; the locator table therefore lives behind `from acceptance import selectors`. / `selectors.py` という名前は標準ライブラリの同名モジュールを隠してしまうため、スイートをパッケージにして `from acceptance import selectors` で読む必要があると分かった。 +- Normative source: [SPEC-04 Acceptance Tests](../../docs/spec/04_acceptance_tests.md) · [SPEC-02 §3](../../docs/spec/02_installer_cli.md) +- Related: [installer/README.md](../README.md) · [docs/demo/runs/README.md](../../docs/demo/runs/README.md) · [ADR-02 Network Model](../../docs/decisions/ADR-02_Network_Model.md) + +--- + + +## English + +[→ 日本語版へ](#japanese) + +### How to run + +```sh +pip install -e "installer[accept]" +PLAYWRIGHT_BROWSERS_PATH=.venv/.playwright playwright install chromium +grdm-dev accept --seed # all scenarios, disposable users created and removed +grdm-dev accept --only C1 # one scenario (C1..C6, S1..S5, or a name fragment like login) +grdm-dev accept --only core --json # every M2 scenario, report as JSON +``` + +`grdm-dev accept` is the only supported entry point: it checks that *Playwright* (a library that drives a browser for you) and *pytest* (the Python test runner) are importable, refuses any `--base-url` whose host is not `127.0.0.1`, and sets the environment the fixtures read. Running `pytest` by hand works for debugging only (`GRDM_BASE_URL=http://127.0.0.1:5000 pytest installer/acceptance -k c1`). + +### Layout + +```toon +files[5]{path,purpose}: + conftest.py,"fixtures (base_url, ports, users, login, two_contexts, project, tmp_pdf/tmp_txt), time boxes, loopback guard, result collector" + selectors.py,"every locator and URL path in one table; TODO(M2) marks entries not yet verified on the real app" + test_c1_login.py … test_c6_admin.py,"core scenarios C1–C6; each has test_*_success and test_*_rejection; marker core" + test_s1_y_websocket.py … test_s5_shibboleth.py,"subsystem stubs S1–S5; marker subsystem; skipped with reason M3" + pytest.ini,"markers and default options" +``` + +Every test carries `scenario(id, name)` and `case("success" | "rejection")` markers; the collector hook copies them into `results.json`, together with `http_status` when a test calls `record_property("http_status", n)`. + +### Rules the fixtures enforce + +- **Loopback only.** Every browser context is routed so that a request to any host other than `127.0.0.1` is aborted and the test fails ([SPEC-04 §3.4](../../docs/spec/04_acceptance_tests.md), [ADR-02](../../docs/decisions/ADR-02_Network_Model.md)). +- **Time boxes.** 120 s per test (`SIGALRM`), 30 minutes per suite. +- **Disposable data.** Users come from `grdm-dev accept --seed` as `user-a-@acceptance.test` and similar; with *fakecas* (the fake login server of the development stack) the password is the e-mail address. Projects created by the `project` fixture are deleted in teardown. Test files are generated bytes. +- **No host state.** Only `runtime/.env` (`GRDM_PORT_`) and the `GRDM_*` variables set by `grdm-dev accept` are read. + +### Evidence + +`grdm-dev accept` writes `docs/demo/runs//` with `results.json` (canonical), `results.toon`, `junit.xml`, `pytest.log`, `collector.json` (raw per-test records), and `artifacts//` holding screenshots and Playwright traces only for failed tests. Each row of `results.json` has `id`, `name`, `case`, `test`, `status`, `duration_ms`, `http_status`, `evidence`. See [docs/demo/runs/README.md](../../docs/demo/runs/README.md). + +### Not yet verified (M2) + +Selectors and URL paths marked `TODO(M2)` in `selectors.py`, the seed management command in `grdm_dev/accept.py`, the CSRF header for session-cookie writes to the API, the waterbutler cookie forwarding, the websocket URL exposed by the wiki page, and the institution id used by C6. + +--- + + +## 日本語 + +[→ To English](#english) + +### 実行方法 + +```sh +pip install -e "installer[accept]" +PLAYWRIGHT_BROWSERS_PATH=.venv/.playwright playwright install chromium +grdm-dev accept --seed # 全シナリオ。使い捨て利用者を作って消す +grdm-dev accept --only C1 # 一つだけ(C1〜C6、S1〜S5、または login のような名前の一部) +grdm-dev accept --only core --json # M2 の全シナリオ。報告を JSON で +``` + +正式な入口は `grdm-dev accept` だけです。*Playwright*(ブラウザを代わりに操作してくれるライブラリ)と *pytest*(Python の試験を動かす道具)が読み込めることを確かめ、ホストが `127.0.0.1` でない `--base-url` を拒み、フィクスチャが読む環境変数を設定します。`pytest` を直接動かすのはデバッグ用です(`GRDM_BASE_URL=http://127.0.0.1:5000 pytest installer/acceptance -k c1`)。 + +### 構成 + +```toon +files[5]{path,purpose}: + conftest.py,"フィクスチャ(base_url・ports・利用者・login・two_contexts・project・tmp_pdf/tmp_txt)、時間制限、ループバック監視、結果収集" + selectors.py,"ロケータと URL パスを一つの表に。実機で未確認のものは TODO(M2)" + test_c1_login.py … test_c6_admin.py,"コアシナリオ C1〜C6。test_*_success と test_*_rejection。マーカー core" + test_s1_y_websocket.py … test_s5_shibboleth.py,"サブシステムの骨格 S1〜S5。マーカー subsystem。理由 M3 でスキップ" + pytest.ini,"マーカーと既定オプション" +``` + +各試験は `scenario(id, name)` と `case("success" | "rejection")` のマーカーを持ち、収集フックがそれを `results.json` に写します。試験が `record_property("http_status", n)` を呼ぶと `http_status` も記録されます。 + +### フィクスチャが守らせる規則 + +- **ループバックだけ。** すべてのブラウザ文脈に経路を仕込み、`127.0.0.1` 以外のホストへの要求は中断して試験を失敗にします([SPEC-04 §3.4](../../docs/spec/04_acceptance_tests.md)、[ADR-02](../../docs/decisions/ADR-02_Network_Model.md))。 +- **時間制限。** 試験ごとに 120 秒(`SIGALRM`)、スイート全体で 30 分。 +- **使い捨てデータ。** 利用者は `grdm-dev accept --seed` が `user-a-@acceptance.test` のように作ります。*fakecas*(開発環境の偽のログインサーバ)ではパスワードはメールアドレスです。`project` フィクスチャが作ったプロジェクトは後片付けで消します。試験ファイルは生成したバイト列です。 +- **ホストの状態を読まない。** 読むのは `runtime/.env`(`GRDM_PORT_`)と `grdm-dev accept` が設定する `GRDM_*` 変数だけです。 + +### 証跡 + +`grdm-dev accept` は `docs/demo/runs//` に `results.json`(正本)、`results.toon`、`junit.xml`、`pytest.log`、`collector.json`(試験ごとの生の記録)、失敗した試験だけのスクリーンショットとトレースを入れた `artifacts/<試験>/` を書きます。`results.json` の各行は `id`・`name`・`case`・`test`・`status`・`duration_ms`・`http_status`・`evidence` を持ちます。[docs/demo/runs/README.md](../../docs/demo/runs/README.md) を参照。 + +### 未確認事項(M2) + +`selectors.py` の `TODO(M2)` 付きのロケータと URL パス、`grdm_dev/accept.py` の seed 管理コマンド、セッション cookie で API に書き込むときの CSRF ヘッダ、waterbutler への cookie 転送、Wiki 画面が公開する websocket の URL、C6 で使う機関 ID。 + +--- + +## Glossary / 用語 + +| Term | English note | 日本語注 | +|---|---|---| +| Fixture | Ready-made data or setup a test receives before it starts. | 試験が始まる前に受け取る、用意済みのデータや準備。 | +| Browser context | A separate browser session with its own cookies, inside one test. | 一つの試験の中にある、cookie を別々に持つ独立したブラウザのセッション。 | +| Marker | A label on a test that lets the runner select or describe it. | 試験に付ける札。実行する試験の選択や説明に使う。 | +| Loopback | The network path back to your own computer; `127.0.0.1`. | 自分のコンピュータに戻る通信路。`127.0.0.1`。 | +| Seed | Creating the throw-away users a test run needs. | 試験の実行に必要な使い捨ての利用者を作ること。 | diff --git a/installer/acceptance/__init__.py b/installer/acceptance/__init__.py new file mode 100644 index 0000000..b83d86c --- /dev/null +++ b/installer/acceptance/__init__.py @@ -0,0 +1 @@ +"""Acceptance suite package (SPEC-04). Tests import shared locators as `from acceptance import selectors`.""" diff --git a/installer/acceptance/conftest.py b/installer/acceptance/conftest.py new file mode 100644 index 0000000..02974b0 --- /dev/null +++ b/installer/acceptance/conftest.py @@ -0,0 +1,294 @@ +"""Shared fixtures and hooks of the acceptance suite (SPEC-04 §3, §6, §7). + +Everything the tests need to know about the environment arrives through environment variables that +`grdm-dev accept` sets (GRDM_BASE_URL, GRDM_RUN_ID, GRDM_ENV_FILE, GRDM_ACCEPT_RESULTS, +GRDM_ACCEPT_USER_A/B, GRDM_ACCEPT_ADMIN) or through pytest's own --base-url option. Nothing else on +the host is read (SPEC-04 §6). Hooks here enforce the per-test and per-suite time boxes, block every +request that would leave 127.0.0.1, and write collector.json for results.json. +""" +from __future__ import annotations + +import datetime as _dt +import json +import os +import re +import signal +import time +from pathlib import Path +from typing import Any, Callable +from urllib.parse import urlparse + +import pytest + +from acceptance import selectors as sel + +TEST_TIMEOUT_S = 120 # SPEC-04 §3.3 +SUITE_TIMEOUT_S = 30 * 60 +LOOPBACK_HOSTS = {"127.0.0.1"} +DEFAULT_PORTS = {"WEB": 5000, "API": 8000, "ADMIN": 8001, "WB": 7777, "MFR": 7778, "FAKECAS": 8080, "EMBER_OSF_WEB": 4200} + +_SESSION_START = time.monotonic() +_RESULTS: dict[str, dict[str, Any]] = {} + + +# --- environment --------------------------------------------------------------------------------- + +def _read_env_file(path: str | None) -> dict[str, str]: + env: dict[str, str] = {} + if not path or not Path(path).exists(): + return env + for line in Path(path).read_text(encoding="utf-8").splitlines(): + line = line.strip() + if line and not line.startswith("#") and "=" in line: + k, _, v = line.partition("=") + env[k.strip()] = v.strip().strip('"').strip("'") + return env + + +def _assert_loopback(url: str) -> str: + host = urlparse(url).hostname + if host not in LOOPBACK_HOSTS: + pytest.fail(f"refusing non-loopback URL {url!r}: acceptance tests never leave this machine (ADR-02)") + return url.rstrip("/") + + +@pytest.fixture(scope="session") +def run_id() -> str: + return os.environ.get("GRDM_RUN_ID") or f"acc-{_dt.datetime.now(_dt.timezone.utc):%Y%m%dT%H%M%SZ}-local" + + +@pytest.fixture(scope="session") +def ports() -> dict[str, int]: + """Host ports from runtime/.env (GRDM_PORT_), falling back to the SPEC-02 §4 defaults.""" + env = _read_env_file(os.environ.get("GRDM_ENV_FILE")) + out = dict(DEFAULT_PORTS) + for k, v in env.items(): + if k.startswith("GRDM_PORT_") and v.isdigit(): + out[k[len("GRDM_PORT_"):]] = int(v) + return out + + +@pytest.fixture(scope="session") +def base_url(request, ports) -> str: + """Overrides pytest-base-url's fixture: env GRDM_BASE_URL, then --base-url, then the web port.""" + url = os.environ.get("GRDM_BASE_URL") or request.config.getoption("base_url", default=None) or f"http://127.0.0.1:{ports['WEB']}" + return _assert_loopback(url) + + +@pytest.fixture(scope="session") +def service_url(ports) -> Callable[[str], str]: + def _url(service: str) -> str: + return f"http://127.0.0.1:{ports[service.upper()]}" + return _url + + +@pytest.fixture(scope="session") +def api_url(service_url) -> str: + return service_url("api") + + +# --- disposable users (SPEC-04 §6; created by `grdm-dev accept --seed`) -------------------------- + +def _user(env_key: str, fallback: str, run_id: str) -> dict[str, str]: + email = os.environ.get(env_key) or f"{fallback}-{run_id}@acceptance.test" + # fakecas accepts any username; the password is the user's e-mail (upstream README-docker-compose). + return {"email": email, "password": email} + + +@pytest.fixture(scope="session") +def user_a(run_id) -> dict[str, str]: + return _user("GRDM_ACCEPT_USER_A", "user-a", run_id) + + +@pytest.fixture(scope="session") +def user_b(run_id) -> dict[str, str]: + return _user("GRDM_ACCEPT_USER_B", "user-b", run_id) + + +@pytest.fixture(scope="session") +def admin_user(run_id) -> dict[str, str]: + return _user("GRDM_ACCEPT_ADMIN", "admin-user", run_id) + + +# --- generated test files (never real files of real people) -------------------------------------- + +@pytest.fixture(scope="session") +def tmp_txt(run_id) -> bytes: + line = f"grdm acceptance {run_id} mock data\n".encode() + return (line * (1024 * 1024 // len(line) + 1))[: 1024 * 1024] + + +@pytest.fixture(scope="session") +def tmp_pdf(run_id) -> bytes: + """A minimal single-page PDF padded to 1 KiB.""" + body = ( + b"%PDF-1.4\n1 0 obj<>endobj\n" + b"2 0 obj<>endobj\n" + b"3 0 obj<>endobj\n" + b"4 0 obj<>stream\nBT /F1 12 Tf 10 50 Td (MOCK " + run_id.encode()[:12] + b") Tj ET\nendstream\nendobj\n" + b"trailer<>\n%%EOF\n" + ) + return body + b"%" * max(0, 1024 - len(body) - 1) + b"\n" + + +# --- browser helpers ----------------------------------------------------------------------------- + +def guard_context(context, offenders: list[str]) -> None: + """Abort any request whose host is not loopback and remember it (SPEC-04 §3.4).""" + def _route(route): + host = urlparse(route.request.url).hostname + if host in LOOPBACK_HOSTS: + route.continue_() + else: + offenders.append(route.request.url) + route.abort("blockedbyclient") + context.route("**/*", _route) + + +@pytest.fixture(autouse=True) +def external_guard(request): + """Attach the loopback guard to the default `context` fixture when a test uses it.""" + offenders: list[str] = [] + if "context" in request.fixturenames: + guard_context(request.getfixturevalue("context"), offenders) + yield offenders + if offenders: + pytest.fail(f"request(s) left the machine: {offenders[:5]}") + + +@pytest.fixture +def login(base_url, service_url): + """login(page, user): fakecas flow — web /login -> fakecas form -> back to the dashboard.""" + def _login(page, user: dict[str, str]) -> None: + page.goto(base_url + sel.PATHS["login"], wait_until="domcontentloaded") + # web redirects to fakecas (port FAKECAS). TODO(M2): confirm the redirect lands on the form directly. + page.wait_for_selector(sel.FAKECAS["username"], timeout=30_000) + page.fill(sel.FAKECAS["username"], user["email"]) + page.fill(sel.FAKECAS["password"], user["password"]) + page.click(sel.FAKECAS["submit"]) + page.wait_for_url(re.compile(re.escape(base_url) + r"/(dashboard|myprojects)"), timeout=60_000) + return _login + + +@pytest.fixture +def logged_in_page(page, login, user_a): + login(page, user_a) + return page + + +@pytest.fixture +def two_contexts(browser, external_guard): + """Two independent browser contexts (own cookies) for C4; both guarded, both closed.""" + a = browser.new_context() + b = browser.new_context() + guard_context(a, external_guard) + guard_context(b, external_guard) + try: + yield a.new_page(), b.new_page() + finally: + a.close() + b.close() + + +def csrf_headers(context) -> dict[str, str]: + """Session-cookie writes to the OSF API need the CSRF token. TODO(M2): confirm cookie/header names.""" + for c in context.cookies(): + if c["name"] in ("api-csrf", "csrftoken"): + return {"X-CSRFToken": c["value"], "Referer": "http://127.0.0.1/"} + return {} + + +@pytest.fixture +def api_write(): + """api_write(context, method, url, json) -> response, using the context's session cookies.""" + def _write(context, method: str, url: str, data: dict | None = None): + headers = {"Content-Type": "application/vnd.api+json", **csrf_headers(context)} + return getattr(context.request, method.lower())(url, data=json.dumps(data) if data is not None else None, headers=headers) + return _write + + +@pytest.fixture +def project(logged_in_page, api_url, api_write): + """A fresh private project owned by user_a, deleted in teardown. Yields the node id.""" + ctx = logged_in_page.context + resp = api_write(ctx, "POST", f"{api_url}{sel.API['nodes']}", { + "data": {"type": "nodes", "attributes": {"title": "acceptance project", "category": "project", "public": False}} + }) + assert resp.status == 201, f"project create failed: {resp.status} {resp.text()[:300]}" + node_id = resp.json()["data"]["id"] + try: + yield node_id + finally: + api_write(ctx, "DELETE", f"{api_url}{sel.API['node'].format(node_id=node_id)}") + + +# --- hooks: markers, time boxes, result collector ------------------------------------------------ + +def pytest_configure(config): + for m in ("core: M2 core scenario", "subsystem: M3 subsystem scenario", + "scenario(id, name): scenario id and name", "case(kind): success or rejection"): + config.addinivalue_line("markers", m) + + +def pytest_runtest_setup(item): + if time.monotonic() - _SESSION_START > SUITE_TIMEOUT_S: + pytest.fail("suite time box of 30 minutes exceeded (SPEC-04 §3.3)") + + +@pytest.hookimpl(hookwrapper=True) +def pytest_runtest_call(item): + if hasattr(signal, "SIGALRM"): + def _timeout(signum, frame): + raise TimeoutError(f"test exceeded {TEST_TIMEOUT_S}s (SPEC-04 §3.3)") + old = signal.signal(signal.SIGALRM, _timeout) + signal.alarm(TEST_TIMEOUT_S) + try: + yield + finally: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + else: # pragma: no cover - Windows is not a supported host + yield + + +def _marker_arg(item, name: str, index: int = 0): + m = item.get_closest_marker(name) + return m.args[index] if m and len(m.args) > index else None + + +@pytest.hookimpl(hookwrapper=True) +def pytest_runtest_makereport(item, call): + outcome = yield + rep = outcome.get_result() + rec = _RESULTS.setdefault(item.nodeid, { + "nodeid": item.nodeid, + "id": _marker_arg(item, "scenario", 0), + "name": _marker_arg(item, "scenario", 1), + "case": _marker_arg(item, "case", 0), + "status": "passed", "duration_ms": 0, "http_status": None, "evidence": None, + }) + rec["duration_ms"] += int(rep.duration * 1000) + for k, v in rep.user_properties: + if k == "http_status": + rec["http_status"] = v + if rep.when == "call" or rep.outcome != "passed": + if rep.skipped: + rec["status"] = "skipped" + elif rep.failed: + rec["status"] = "failed" if rep.when == "call" else "error" + + +def pytest_sessionfinish(session, exitstatus): + out = os.environ.get("GRDM_ACCEPT_RESULTS") + if not out: + return + output_dir = session.config.getoption("--output", default=None) + for rec in _RESULTS.values(): + if output_dir and rec["status"] in ("failed", "error"): + slug = re.sub(r"[^a-zA-Z0-9]+", "-", rec["nodeid"]).strip("-") + for cand in Path(output_dir).glob("*"): + if cand.is_dir() and (cand.name == slug[: len(cand.name)] or slug.endswith(cand.name)): + rec["evidence"] = str(cand) + break + Path(out).parent.mkdir(parents=True, exist_ok=True) + Path(out).write_text(json.dumps(list(_RESULTS.values()), ensure_ascii=False, indent=2) + "\n", encoding="utf-8") diff --git a/installer/acceptance/pytest.ini b/installer/acceptance/pytest.ini new file mode 100644 index 0000000..9e4c81f --- /dev/null +++ b/installer/acceptance/pytest.ini @@ -0,0 +1,11 @@ +[pytest] +# Acceptance suite (SPEC-04). Run through `grdm-dev accept`, which supplies --base-url, --junitxml, +# --screenshot/--tracing and the output directory. +testpaths = . +python_files = test_*.py +markers = + core: M2 core scenario (C1-C6), must pass in every profile + subsystem: M3 subsystem scenario (S1-S5) + scenario(id, name): scenario id and human name, copied into results.json + case(kind): "success" or "rejection" +addopts = -ra --strict-markers diff --git a/installer/acceptance/selectors.py b/installer/acceptance/selectors.py new file mode 100644 index 0000000..b611f6c --- /dev/null +++ b/installer/acceptance/selectors.py @@ -0,0 +1,75 @@ +"""One table of every page locator and URL path the acceptance suite uses (SPEC-04). + +Selectors were written against the upstream GakuNin RDM UI (RDM-osf.io, legacy Knockout pages plus +fakecas) without a running instance. Every entry marked TODO(M2) must be verified on the real app +once `grdm-dev install --profile core` is green; change them here only, never in test files. + +Rules: prefer ARIA roles / visible text over CSS classes; never hard-code a port (ports come from +runtime/.env through conftest.base_url / conftest.ports). +""" +from __future__ import annotations + +# --- URL paths (relative to base_url = web service) ----------------------------------------------- +PATHS = { + "login": "/login/", # web redirects here when a session is missing + "dashboard": "/dashboard/", + "my_projects": "/myprojects/", + "logout": "/logout/", + "new_project": "/dashboard/", # the "Create new project" button lives on the dashboard + "institutions_admin": "/institutions/", # TODO(M2): the admin app (port 8001) path for institution users +} + +API = { + "me": "/v2/users/me/", + "nodes": "/v2/nodes/", + "node": "/v2/nodes/{node_id}/", + "node_files": "/v2/nodes/{node_id}/files/osfstorage/", + "node_wikis": "/v2/nodes/{node_id}/wikis/", + "node_contributors": "/v2/nodes/{node_id}/contributors/", +} + +WATERBUTLER = { + # waterbutler v1: PUT ?kind=file&name= uploads into the root of a provider + "upload": "/v1/resources/{node_id}/providers/osfstorage/?kind=file&name={name}", + "download": "/v1/resources/{node_id}/providers/osfstorage{path}", +} + +MFR = { + "render": "/render?url={file_url}", # TODO(M2): confirm the exact render URL the web app embeds +} + +ADMIN = { + "login": "/account/login/", # TODO(M2): Django admin app login path + "institution_users": "/institutions/{institution_id}/users/", # TODO(M2): confirm +} + +# --- fakecas login form (upstream README: any username, password = the user's e-mail) ------------- +FAKECAS = { + "username": "input[name='username']", # TODO(M2): verify field names on the fakecas page + "password": "input[name='password']", + "submit": "button[type='submit'], input[type='submit']", +} + +# --- web (legacy Knockout UI) --------------------------------------------------------------------- +WEB = { + "dashboard_heading": "text=My Projects", # TODO(M2): confirm dashboard landing text + "user_menu": "#secondary-navigation", # TODO(M2): nav bar showing the user name + "create_project_button": "button:has-text('Create new project'), a:has-text('Create new project')", + "create_project_title": "input#projectName, input[name='title']", # TODO(M2) + "create_project_submit": "button:has-text('Create')", + "project_title": "#nodeTitleEditable, h2#nodeTitle", # TODO(M2) + "files_tab": "a:has-text('Files')", + "wiki_tab": "a:has-text('Wiki')", + "wiki_edit_button": "a:has-text('Edit'), button:has-text('Edit')", + "wiki_editor": ".CodeMirror textarea, textarea#editor", # TODO(M2): wiki editor widget (sharejs/CodeMirror) + "wiki_rendered": "#wikiViewRender, .wiki-content", # TODO(M2) + "file_preview_iframe": "iframe#mfrIframe, iframe[src*='render']", # TODO(M2) + "error_page": ".error, #error-page, text=Forbidden", +} + +ADMIN_UI = { + "login_user": "input[name='username'], input[name='email']", # TODO(M2) + "login_pass": "input[name='password']", + "login_submit": "button[type='submit'], input[type='submit']", + "institution_user_table": "table", # TODO(M2): institution users list +} diff --git a/installer/acceptance/test_c1_login.py b/installer/acceptance/test_c1_login.py new file mode 100644 index 0000000..7ee0eae --- /dev/null +++ b/installer/acceptance/test_c1_login.py @@ -0,0 +1,31 @@ +"""C1 — Login via fakecas (SPEC-04 §4). Services: web, api, fakecas.""" +import pytest + +from acceptance import selectors as sel + +pytestmark = [pytest.mark.core, pytest.mark.scenario("C1", "Login via fakecas")] + + +@pytest.mark.case("success") +def test_c1_login_success(page, login, user_a, base_url, record_property): + """Test user signs in through fakecas and lands on the dashboard.""" + login(page, user_a) + resp = page.goto(base_url + sel.PATHS["dashboard"], wait_until="domcontentloaded") + record_property("http_status", resp.status if resp else None) + page.wait_for_selector(sel.WEB["dashboard_heading"], timeout=30_000) + assert page.url.startswith(base_url), "dashboard must be served by web, not fakecas" + + +@pytest.mark.case("rejection") +def test_c1_login_rejection(playwright, base_url, api_url, record_property): + """Without a session: GET /dashboard -> 302 to login; API GET /v2/users/me/ -> 401.""" + anon = playwright.request.new_context() + try: + dash = anon.get(base_url + sel.PATHS["dashboard"], max_redirects=0) + me = anon.get(api_url + sel.API["me"]) + record_property("http_status", me.status) + assert dash.status in (301, 302, 303, 307) and "login" in (dash.headers.get("location") or "").lower(), \ + f"expected redirect to login, got {dash.status} {dash.headers.get('location')}" + assert me.status == 401, f"expected 401 from {sel.API['me']}, got {me.status}" + finally: + anon.dispose() diff --git a/installer/acceptance/test_c2_create_project.py b/installer/acceptance/test_c2_create_project.py new file mode 100644 index 0000000..14f31f1 --- /dev/null +++ b/installer/acceptance/test_c2_create_project.py @@ -0,0 +1,60 @@ +"""C2 — Create project (SPEC-04 §4). Services: web, api.""" +import pytest + +from acceptance import selectors as sel + +pytestmark = [pytest.mark.core, pytest.mark.scenario("C2", "Create project")] + + +@pytest.mark.case("success") +def test_c2_create_project_success(logged_in_page, base_url, api_url, api_write, run_id, record_property): + """A new project created in the UI appears with its title and the user as admin.""" + page = logged_in_page + title = f"acceptance C2 {run_id}" + page.goto(base_url + sel.PATHS["new_project"], wait_until="domcontentloaded") + page.click(sel.WEB["create_project_button"]) + page.fill(sel.WEB["create_project_title"], title) + page.click(sel.WEB["create_project_submit"]) + # TODO(M2): confirm the modal navigates to // (legacy UI shows a "Go to new project" link). + page.wait_for_url(lambda url: url.startswith(base_url) and "/dashboard" not in url, timeout=60_000) + page.wait_for_selector(f"text={title}", timeout=30_000) + + node_id = page.url.rstrip("/").rsplit("/", 1)[-1] + me = page.context.request.get(api_url + sel.API["node"].format(node_id=node_id)) + record_property("http_status", me.status) + try: + assert me.status == 200 + attrs = me.json()["data"]["attributes"] + assert attrs["title"] == title + assert attrs.get("current_user_permissions", ["admin"])[0] == "admin" + finally: + api_write(page.context, "DELETE", api_url + sel.API["node"].format(node_id=node_id)) + + +@pytest.mark.case("rejection") +def test_c2_create_project_rejection(logged_in_page, project, browser, login, user_b, api_url, api_write, + external_guard, record_property): + """A read-only contributor (user_b) PATCHing the project -> 403.""" + from acceptance.conftest import guard_context + + a_ctx = logged_in_page.context + # user_a adds user_b as read-only contributor. TODO(M2): confirm payload (users relationship by id). + b_ctx = browser.new_context() + guard_context(b_ctx, external_guard) + try: + b_page = b_ctx.new_page() + login(b_page, user_b) + b_id = b_ctx.request.get(api_url + sel.API["me"]).json()["data"]["id"] + added = api_write(a_ctx, "POST", api_url + sel.API["node_contributors"].format(node_id=project), { + "data": {"type": "contributors", "attributes": {"permission": "read", "bibliographic": False}, + "relationships": {"users": {"data": {"type": "users", "id": b_id}}}} + }) + assert added.status == 201, f"adding contributor failed: {added.status} {added.text()[:200]}" + + resp = api_write(b_ctx, "PATCH", api_url + sel.API["node"].format(node_id=project), { + "data": {"type": "nodes", "id": project, "attributes": {"title": "renamed by read-only user"}} + }) + record_property("http_status", resp.status) + assert resp.status == 403, f"expected 403, got {resp.status}" + finally: + b_ctx.close() diff --git a/installer/acceptance/test_c3_file_upload.py b/installer/acceptance/test_c3_file_upload.py new file mode 100644 index 0000000..327556e --- /dev/null +++ b/installer/acceptance/test_c3_file_upload.py @@ -0,0 +1,49 @@ +"""C3 — Upload and download file (SPEC-04 §4). Services: wb, wb_worker, osfstorage.""" +import pytest + +from acceptance import selectors as sel + +pytestmark = [pytest.mark.core, pytest.mark.scenario("C3", "Upload and download file")] + + +def upload(context, wb_url: str, node_id: str, name: str, data: bytes): + """PUT bytes to waterbutler with the session cookie; returns the waterbutler file entity (dict). + + TODO(M2): confirm waterbutler accepts the `osf` session cookie forwarded by Playwright and that + the response is 201 with data.attributes.path / links.download. + """ + resp = context.request.put(wb_url + sel.WATERBUTLER["upload"].format(node_id=node_id, name=name), + data=data, headers={"Content-Type": "application/octet-stream"}) + assert resp.status in (200, 201), f"upload failed: {resp.status} {resp.text()[:300]}" + return resp.json()["data"] + + +@pytest.mark.case("success") +def test_c3_file_upload_success(logged_in_page, project, service_url, tmp_txt, run_id, record_property): + """Upload 1 MiB through waterbutler, download it back, bytes must be identical.""" + ctx = logged_in_page.context + entity = upload(ctx, service_url("wb"), project, f"c3-{run_id}.txt", tmp_txt) + link = entity["links"]["download"] if "links" in entity else service_url("wb") + sel.WATERBUTLER["download"].format( + node_id=project, path=entity["attributes"]["path"]) + assert link.startswith("http://127.0.0.1"), f"download link must stay on loopback: {link}" + down = ctx.request.get(link) + record_property("http_status", down.status) + assert down.status == 200 + assert down.body() == tmp_txt, "downloaded bytes differ from uploaded bytes" + + +@pytest.mark.case("rejection") +def test_c3_file_upload_rejection(logged_in_page, project, service_url, tmp_txt, run_id, playwright, record_property): + """Anonymous GET of a private file -> 401/403 (and the anonymous PUT -> 401/403).""" + ctx = logged_in_page.context + entity = upload(ctx, service_url("wb"), project, f"c3-private-{run_id}.txt", tmp_txt[:1024]) + path = entity["attributes"]["path"] + anon = playwright.request.new_context() + try: + get = anon.get(service_url("wb") + sel.WATERBUTLER["download"].format(node_id=project, path=path)) + put = anon.put(service_url("wb") + sel.WATERBUTLER["upload"].format(node_id=project, name="intruder.txt"), data=b"x") + record_property("http_status", get.status) + assert get.status in (401, 403), f"anonymous download returned {get.status}" + assert put.status in (401, 403), f"anonymous upload returned {put.status}" + finally: + anon.dispose() diff --git a/installer/acceptance/test_c4_wiki_collab.py b/installer/acceptance/test_c4_wiki_collab.py new file mode 100644 index 0000000..14defe1 --- /dev/null +++ b/installer/acceptance/test_c4_wiki_collab.py @@ -0,0 +1,83 @@ +"""C4 — Wiki collaborative edit with two browser contexts (SPEC-04 §4). Services: web, y_websocket, sharejs. + +Never skipped: y_websocket belongs to the `core` profile (SPEC-02 §4). +""" +import pytest + +from acceptance import selectors as sel +from acceptance.conftest import csrf_headers + +pytestmark = [pytest.mark.core, pytest.mark.scenario("C4", "Wiki collaborative edit")] + +CONVERGE_MS = 5_000 # SPEC-04 §5 S1 budget, reused for the M2 case + + +def _wiki_edit_url(base_url: str, node_id: str) -> str: + return f"{base_url}/{node_id}/wiki/home/?edit&view&menu" # TODO(M2): confirm the edit-mode query string + + +def _add_write_contributor(ctx_a, api_url: str, node_id: str, user_id: str) -> None: + headers = {"Content-Type": "application/vnd.api+json", **csrf_headers(ctx_a)} + resp = ctx_a.request.post(api_url + sel.API["node_contributors"].format(node_id=node_id), headers=headers, data= + '{"data":{"type":"contributors","attributes":{"permission":"write","bibliographic":false},' + '"relationships":{"users":{"data":{"type":"users","id":"%s"}}}}}' % user_id) + assert resp.status == 201, f"adding write contributor failed: {resp.status} {resp.text()[:200]}" + + +@pytest.mark.case("success") +def test_c4_wiki_collab_success(two_contexts, login, user_a, user_b, base_url, api_url, run_id, record_property): + """Both users open the same wiki page; text typed by B appears in A's editor.""" + page_a, page_b = two_contexts + login(page_a, user_a) + login(page_b, user_b) + + headers = {"Content-Type": "application/vnd.api+json", **csrf_headers(page_a.context)} + created = page_a.context.request.post(api_url + sel.API["nodes"], headers=headers, data= + '{"data":{"type":"nodes","attributes":{"title":"acceptance C4","category":"project","public":false}}}') + assert created.status == 201, created.text()[:200] + node_id = created.json()["data"]["id"] + try: + b_id = page_b.context.request.get(api_url + sel.API["me"]).json()["data"]["id"] + _add_write_contributor(page_a.context, api_url, node_id, b_id) + + resp_a = page_a.goto(_wiki_edit_url(base_url, node_id), wait_until="domcontentloaded") + record_property("http_status", resp_a.status if resp_a else None) + page_a.wait_for_selector(sel.WEB["wiki_editor"], timeout=60_000) + page_b.goto(_wiki_edit_url(base_url, node_id), wait_until="domcontentloaded") + page_b.wait_for_selector(sel.WEB["wiki_editor"], timeout=60_000) + + marker = f"collab-{run_id}" + page_b.click(sel.WEB["wiki_editor"]) + page_b.keyboard.type(marker) + # Deterministic wait: the text must appear in A's editor through y-websocket within the budget. + page_a.wait_for_function("m => document.body.innerText.includes(m) || " + "[...document.querySelectorAll('textarea')].some(t => t.value.includes(m))", + arg=marker, timeout=CONVERGE_MS) + finally: + page_a.context.request.delete(api_url + sel.API["node"].format(node_id=node_id), + headers={"Content-Type": "application/vnd.api+json", **csrf_headers(page_a.context)}) + + +@pytest.mark.case("rejection") +def test_c4_wiki_collab_rejection(two_contexts, login, user_a, base_url, api_url, project, record_property): + """A logged-out context connecting to the wiki websocket is closed with code 4401.""" + page_a, page_anon = two_contexts + login(page_a, user_a) + page_a.goto(_wiki_edit_url(base_url, project), wait_until="domcontentloaded") + page_a.wait_for_selector(sel.WEB["wiki_editor"], timeout=60_000) + # The web page tells the browser where the collaboration socket is. TODO(M2): confirm contextVars key. + ws_url = page_a.evaluate("() => (window.contextVars && window.contextVars.wiki && " + "(window.contextVars.wiki.urls.y_websocket || window.contextVars.wiki.urls.sharejs)) || null") + assert ws_url, "wiki page did not expose the websocket URL (window.contextVars.wiki.urls)" + assert "127.0.0.1" in ws_url, f"websocket URL must stay on loopback: {ws_url}" + + page_anon.goto(base_url + sel.PATHS["login"], wait_until="domcontentloaded") # same origin, no session + close_code = page_anon.evaluate( + """url => new Promise(resolve => { + const ws = new WebSocket(url); + const timer = setTimeout(() => { ws.close(); resolve('timeout'); }, 10000); + ws.onclose = ev => { clearTimeout(timer); resolve(ev.code); }; + ws.onerror = () => {}; + })""", ws_url) + record_property("http_status", close_code) + assert close_code == 4401, f"expected websocket close code 4401, got {close_code!r}" diff --git a/installer/acceptance/test_c5_file_preview.py b/installer/acceptance/test_c5_file_preview.py new file mode 100644 index 0000000..c514d5e --- /dev/null +++ b/installer/acceptance/test_c5_file_preview.py @@ -0,0 +1,41 @@ +"""C5 — File preview (SPEC-04 §4). Services: mfr, unoconv.""" +import pytest + +from acceptance import selectors as sel +from acceptance.test_c3_file_upload import upload + +pytestmark = [pytest.mark.core, pytest.mark.scenario("C5", "File preview")] + + +def _file_page_url(base_url: str, node_id: str, path: str) -> str: + # osfstorage paths are "/"; the web file page is //files/osfstorage// + return f"{base_url}/{node_id}/files/osfstorage{path.rstrip('/')}/" # TODO(M2): confirm + + +@pytest.mark.case("success") +def test_c5_file_preview_success(logged_in_page, project, base_url, service_url, tmp_pdf, run_id, record_property): + """An uploaded PDF renders inside the mfr iframe (mfr answers 200 for the render request).""" + page = logged_in_page + entity = upload(page.context, service_url("wb"), project, f"c5-{run_id}.pdf", tmp_pdf) + mfr_origin = service_url("mfr") + with page.expect_response(lambda r: r.url.startswith(mfr_origin) and "/render" in r.url, timeout=90_000) as render: + page.goto(_file_page_url(base_url, project, entity["attributes"]["path"]), wait_until="domcontentloaded") + page.wait_for_selector(sel.WEB["file_preview_iframe"], timeout=60_000) + record_property("http_status", render.value.status) + assert render.value.status == 200, f"mfr render returned {render.value.status}" + + +@pytest.mark.case("rejection") +def test_c5_file_preview_rejection(logged_in_page, project, service_url, tmp_pdf, run_id, playwright, record_property): + """The preview URL of a private file without a session -> 401/403.""" + page = logged_in_page + entity = upload(page.context, service_url("wb"), project, f"c5-private-{run_id}.pdf", tmp_pdf) + file_url = entity["links"]["download"] if "links" in entity else service_url("wb") + sel.WATERBUTLER["download"].format( + node_id=project, path=entity["attributes"]["path"]) + anon = playwright.request.new_context() + try: + resp = anon.get(service_url("mfr") + sel.MFR["render"].format(file_url=file_url)) + record_property("http_status", resp.status) + assert resp.status in (401, 403), f"anonymous preview returned {resp.status}" + finally: + anon.dispose() diff --git a/installer/acceptance/test_c6_admin.py b/installer/acceptance/test_c6_admin.py new file mode 100644 index 0000000..4e1bca1 --- /dev/null +++ b/installer/acceptance/test_c6_admin.py @@ -0,0 +1,40 @@ +"""C6 — Institution admin screen (SPEC-04 §4). Services: admin, api.""" +import pytest + +from acceptance import selectors as sel + +pytestmark = [pytest.mark.core, pytest.mark.scenario("C6", "Institution admin screen")] + + +def _admin_login(page, admin_url: str, user: dict[str, str]) -> None: + """The admin app (port ADMIN) has its own Django login form. TODO(M2): confirm path and field names.""" + page.goto(admin_url + sel.ADMIN["login"], wait_until="domcontentloaded") + page.fill(sel.ADMIN_UI["login_user"], user["email"]) + page.fill(sel.ADMIN_UI["login_pass"], user["password"]) + page.click(sel.ADMIN_UI["login_submit"]) + page.wait_for_load_state("domcontentloaded") + + +@pytest.mark.case("success") +def test_c6_admin_success(page, service_url, admin_user, record_property): + """The institution admin signs in to the admin app and sees the institution's user list.""" + admin_url = service_url("admin") + _admin_login(page, admin_url, admin_user) + # TODO(M2): the institution id of the seeded admin; "1" assumes the first institution created by --seed. + resp = page.goto(admin_url + sel.ADMIN["institution_users"].format(institution_id="1"), wait_until="domcontentloaded") + record_property("http_status", resp.status if resp else None) + assert resp is not None and resp.status == 200, f"institution users page returned {resp and resp.status}" + page.wait_for_selector(sel.ADMIN_UI["institution_user_table"], timeout=30_000) + + +@pytest.mark.case("rejection") +def test_c6_admin_rejection(logged_in_page, service_url, api_url, record_property): + """An ordinary user opening the admin URL -> 403 or redirect to login; the API answers 403.""" + page = logged_in_page + admin_url = service_url("admin") + screen = page.context.request.get(admin_url + sel.ADMIN["institution_users"].format(institution_id="1"), max_redirects=0) + assert screen.status in (301, 302, 303, 307, 401, 403), f"admin screen answered {screen.status} to an ordinary user" + # TODO(M2): confirm the admin-only API endpoint an ordinary user is denied on (institution users listing). + api = page.context.request.get(api_url + "/v2/institutions/1/users/") + record_property("http_status", api.status) + assert api.status in (403, 404), f"expected 403 (or 404 if hidden), got {api.status}" diff --git a/installer/acceptance/test_s1_y_websocket.py b/installer/acceptance/test_s1_y_websocket.py new file mode 100644 index 0000000..8095157 --- /dev/null +++ b/installer/acceptance/test_s1_y_websocket.py @@ -0,0 +1,16 @@ +"""S1 — y-websocket (SPEC-04 §5). Subsystem scenario; implemented at M3.""" +import pytest + +pytestmark = [pytest.mark.subsystem, pytest.mark.scenario("S1", "y-websocket"), pytest.mark.skip(reason="M3")] + + +@pytest.mark.case("success") +def test_s1_y_websocket_success(): + """two contexts converge on the same Wiki document within 5 s.""" + raise NotImplementedError("M3") + + +@pytest.mark.case("rejection") +def test_s1_y_websocket_rejection(): + """connection without a valid token -> close code 4401, no document state leaked.""" + raise NotImplementedError("M3") diff --git a/installer/acceptance/test_s2_rdmcp.py b/installer/acceptance/test_s2_rdmcp.py new file mode 100644 index 0000000..72e6a65 --- /dev/null +++ b/installer/acceptance/test_s2_rdmcp.py @@ -0,0 +1,16 @@ +"""S2 — rdmcp (MCP endpoint) (SPEC-04 §5). Subsystem scenario; implemented at M3.""" +import pytest + +pytestmark = [pytest.mark.subsystem, pytest.mark.scenario("S2", "rdmcp (MCP endpoint)"), pytest.mark.skip(reason="M3")] + + +@pytest.mark.case("success") +def test_s2_rdmcp_success(): + """authenticated MCP client lists tools and reads one project resource.""" + raise NotImplementedError("M3") + + +@pytest.mark.case("rejection") +def test_s2_rdmcp_rejection(): + """no token -> 401; token of user B reading project of user A -> 403.""" + raise NotImplementedError("M3") diff --git a/installer/acceptance/test_s3_aipf.py b/installer/acceptance/test_s3_aipf.py new file mode 100644 index 0000000..99b9ebe --- /dev/null +++ b/installer/acceptance/test_s3_aipf.py @@ -0,0 +1,16 @@ +"""S3 — aipf_mcp_data_grdm (SPEC-04 §5). Subsystem scenario; implemented at M3.""" +import pytest + +pytestmark = [pytest.mark.subsystem, pytest.mark.scenario("S3", "aipf_mcp_data_grdm"), pytest.mark.skip(reason="M3")] + + +@pytest.mark.case("success") +def test_s3_aipf_success(): + """MCP data query returns the run's project metadata.""" + raise NotImplementedError("M3") + + +@pytest.mark.case("rejection") +def test_s3_aipf_rejection(): + """query for a project id the user cannot see -> 403 or empty with explicit code.""" + raise NotImplementedError("M3") diff --git a/installer/acceptance/test_s4_oasys.py b/installer/acceptance/test_s4_oasys.py new file mode 100644 index 0000000..6eead55 --- /dev/null +++ b/installer/acceptance/test_s4_oasys.py @@ -0,0 +1,16 @@ +"""S4 — OASys (SPEC-04 §5). Subsystem scenario; implemented at M3.""" +import pytest + +pytestmark = [pytest.mark.subsystem, pytest.mark.scenario("S4", "OASys"), pytest.mark.skip(reason="M3")] + + +@pytest.mark.case("success") +def test_s4_oasys_success(): + """OASys page loads and shows the run's project linked from GRDM.""" + raise NotImplementedError("M3") + + +@pytest.mark.case("rejection") +def test_s4_oasys_rejection(): + """unauthenticated OASys API call -> 401.""" + raise NotImplementedError("M3") diff --git a/installer/acceptance/test_s5_shibboleth.py b/installer/acceptance/test_s5_shibboleth.py new file mode 100644 index 0000000..3e48e03 --- /dev/null +++ b/installer/acceptance/test_s5_shibboleth.py @@ -0,0 +1,16 @@ +"""S5 — Shibboleth-SP via test IdP (SPEC-04 §5). Subsystem scenario; implemented at M3.""" +import pytest + +pytestmark = [pytest.mark.subsystem, pytest.mark.scenario("S5", "Shibboleth-SP via test IdP"), pytest.mark.skip(reason="M3")] + + +@pytest.mark.case("success") +def test_s5_shibboleth_success(): + """SP -> IdP login -> GRDM dashboard with institution attribute.""" + raise NotImplementedError("M3") + + +@pytest.mark.case("rejection") +def test_s5_shibboleth_rejection(): + """IdP user without the required eduPersonEntitlement -> SP error page, no GRDM session.""" + raise NotImplementedError("M3") diff --git a/installer/build/lib/grdm_dev/__init__.py b/installer/build/lib/grdm_dev/__init__.py new file mode 100644 index 0000000..a68699b --- /dev/null +++ b/installer/build/lib/grdm_dev/__init__.py @@ -0,0 +1,11 @@ +"""grdm-dev: one-command installer for the GakuNin RDM developer environment 2027 (SPEC-02). + +Standard library only. Every subcommand lives in its own module and follows one contract: + + def register(subparsers) -> None # add its argparse sub-parser(s) + def run(ctx: Context, args) -> int # do the work, return an exit code from exit_codes + +Reports are produced through `grdm_dev.report.emit(ctx, name, data)`, which prints TOON by +default or JSON with --json and keeps a copy under runtime/reports/. +""" +__version__ = "0.1.0" diff --git a/installer/build/lib/grdm_dev/accept.py b/installer/build/lib/grdm_dev/accept.py new file mode 100644 index 0000000..cd6583b --- /dev/null +++ b/installer/build/lib/grdm_dev/accept.py @@ -0,0 +1,346 @@ +"""grdm-dev accept — run the Playwright Python acceptance suite (SPEC-02 §3, SPEC-04). + +Flow: check that pytest + playwright are importable in this venv (exit 2 with an install hint +otherwise), refuse any base URL that is not loopback, optionally seed disposable users through the +`web` container (`--seed`), run pytest on installer/acceptance/ with JUnit output, then write +results.json + results.toon into docs/demo/runs// and exit 60 if any test failed. + +Standard library only. Every external call (pytest, docker compose) goes through an injectable +`runner(argv, env=None, cwd=None) -> (returncode, output)` so unit tests never need a browser, +Docker, or the application. +""" +from __future__ import annotations + +import datetime as _dt +import importlib +import json +import os +import re +import secrets +import subprocess +import sys +import xml.etree.ElementTree as ET +from pathlib import Path +from urllib.parse import urlparse + +from . import exit_codes, report, toon +from .context import Context + +# SPEC-04 §4 / §5. Shared with installer/acceptance/conftest.py by convention (ids in file names). +SCENARIOS: dict[str, str] = { + "C1": "Login via fakecas", + "C2": "Create project", + "C3": "Upload and download file", + "C4": "Wiki collaborative edit", + "C5": "File preview", + "C6": "Institution admin screen", + "S1": "y-websocket", + "S2": "rdmcp (MCP endpoint)", + "S3": "aipf_mcp_data_grdm", + "S4": "OASys", + "S5": "Shibboleth-SP via test IdP", +} + +ACCEPTANCE_DIR = Path(__file__).resolve().parent.parent / "acceptance" +DEFAULT_WEB_PORT = 5000 +# Browsers live inside the venv, never in the user's home (SPEC-04 §1). Relative to the repo root. +BROWSERS_PATH = Path(".venv") / ".playwright" +INSTALL_HINT = 'pip install -e "installer[accept]" && PLAYWRIGHT_BROWSERS_PATH=.venv/.playwright playwright install chromium' +REQUIRED_MODULES = ("pytest", "playwright", "pytest_playwright") +# Disposable-user mailbox domain. `.test` is reserved (RFC 2606): never a real person (POL-01). +SEED_DOMAIN = "acceptance.test" + +# Django management call executed inside the `web` container by `--seed`. +# TODO(M2): confirm on the real app. OSFUser.create_confirmed(username, password, fullname) exists in +# osf/models/user.py upstream; the institution-admin flag for C6 (admin app permission / group) is +# unverified and may need `is_staff` plus an institution affiliation instead of `is_superuser`. +SEED_SNIPPET = ( + "from osf.models import OSFUser; " + "u = OSFUser.create_confirmed(username={email!r}, password={email!r}, fullname={fullname!r}); " + "u.is_staff = {admin}; u.is_superuser = {admin}; u.save(); print('seeded', u._id)" +) +CLEANUP_SNIPPET = ( + "from osf.models import OSFUser; " + "n, _ = OSFUser.objects.filter(username__endswith='@{domain}', username__contains={run_id!r}).delete(); " + "print('deleted', n)" +) + + +def register(subparsers) -> None: + p = subparsers.add_parser("accept", help="run the Playwright acceptance suite in this venv; exit 60 on any failing test") + p.add_argument("--only", metavar="SCENARIO", help="run one scenario (C1..C6, S1..S5, a name fragment like 'login', or a marker: core, subsystem)") + p.add_argument("--seed", action="store_true", help="create disposable test users in the web container before running (removed afterwards)") + p.add_argument("--base-url", dest="base_url", help="web URL; must be http://127.0.0.1: (default: GRDM_PORT_WEB from runtime/.env, else 5000)") + p.add_argument("--headed", action="store_true", help="show the browser window (debugging only)") + p.set_defaults(_module=sys.modules[__name__]) + + +# --- helpers ------------------------------------------------------------------------------------- + +def default_runner(argv: list[str], env: dict[str, str] | None = None, cwd: str | Path | None = None, + timeout: int = 1900) -> tuple[int, str]: + try: + proc = subprocess.run(argv, capture_output=True, text=True, env=env, cwd=cwd, timeout=timeout) + except FileNotFoundError as exc: + return 127, str(exc) + except subprocess.TimeoutExpired: + return 124, "timed out" + return proc.returncode, (proc.stdout or "") + (proc.stderr or "") + + +def missing_modules(importer=None) -> list[str]: + importer = importer or importlib.import_module + missing = [] + for name in REQUIRED_MODULES: + try: + importer(name) + except ImportError: + missing.append(name) + return missing + + +def read_env_file(path: Path) -> dict[str, str]: + env: dict[str, str] = {} + if not path.exists(): + return env + for line in path.read_text(encoding="utf-8").splitlines(): + line = line.strip() + if not line or line.startswith("#") or "=" not in line: + continue + k, _, v = line.partition("=") + env[k.strip()] = v.strip().strip('"').strip("'") + return env + + +def default_base_url(ctx: Context) -> str: + port = read_env_file(ctx.runtime / ".env").get("GRDM_PORT_WEB", str(DEFAULT_WEB_PORT)) + return f"http://127.0.0.1:{port}" + + +def loopback_problem(url: str) -> str | None: + """Return why `url` is not an acceptable loopback target, or None if it is (ADR-02 §3.5).""" + u = urlparse(url) + if u.scheme != "http": + return f"scheme must be http, got {u.scheme!r}" + if u.hostname != "127.0.0.1": + return f"host must be 127.0.0.1, got {u.hostname!r} (tests never leave the machine)" + if u.username or u.password: + return "credentials in URL are not allowed" + return None + + +def make_run_id(now: _dt.datetime | None = None) -> str: + now = now or _dt.datetime.now(_dt.timezone.utc) + return f"acc-{now.strftime('%Y%m%dT%H%M%SZ')}-{secrets.token_hex(3)}" + + +def seed_users(run_id: str) -> dict[str, dict[str, str]]: + """Disposable identities for one run. With fakecas the password is the e-mail (upstream README).""" + users = {} + for key, admin in (("user_a", False), ("user_b", False), ("admin_user", True)): + email = f"{key.replace('_', '-')}-{run_id}@{SEED_DOMAIN}" + users[key] = {"email": email, "password": email, "fullname": f"Acceptance {key} {run_id}", "admin": admin} + return users + + +def compose_exec(ctx: Context, service: str, *cmd: str) -> list[str]: + argv = ["docker", "compose"] + if (ctx.runtime / "docker-compose.yml").exists(): + argv += ["-f", str(ctx.runtime / "docker-compose.yml")] + if (ctx.runtime / ".env").exists(): + argv += ["--env-file", str(ctx.runtime / ".env")] + return argv + ["exec", "-T", service, *cmd] + + +def select_tests(only: str | None) -> tuple[list[str], list[str]] | None: + """Translate --only into (paths, extra pytest args). None means the selection matched nothing.""" + if not only: + return [str(ACCEPTANCE_DIR)], [] + key = only.strip().lower() + if key in ("core", "subsystem"): + return [str(ACCEPTANCE_DIR)], ["-m", key] + files = sorted(ACCEPTANCE_DIR.glob("test_*.py")) + hits = [str(f) for f in files if key in f.stem.lower()] + if not hits and re.fullmatch(r"[cs][0-9]+", key): + hits = [str(f) for f in files if f.stem.lower().startswith(f"test_{key}_")] + return (hits, []) if hits else None + + +def pytest_argv(paths: list[str], extra: list[str], run_dir: Path, base_url: str, headed: bool) -> list[str]: + argv = [sys.executable, "-m", "pytest", *paths, "-q", "--no-header", + "-p", "no:cacheprovider", + # pytest-playwright registers itself through its entry point; naming it again with -p would + # register the same module twice and pluggy rejects that. Autoload stays on. + "--base-url", base_url, + "--junitxml", str(run_dir / "junit.xml"), + "--screenshot", "only-on-failure", + "--tracing", "retain-on-failure", + "--output", str(run_dir / "artifacts"), + "--browser", "chromium", + *extra] + if headed: + argv.append("--headed") + return argv + + +# --- result collection --------------------------------------------------------------------------- + +def _classify(nodeid: str) -> tuple[str, str, str]: + """(scenario id, scenario name, case) from a nodeid like .../test_c1_login.py::test_c1_login_success.""" + m = re.search(r"test_([cs][0-9]+)_", nodeid.lower()) + sid = m.group(1).upper() if m else "?" + test = nodeid.rsplit("::", 1)[-1].lower() + case = "success" if "success" in test else "rejection" if "reject" in test else "other" + return sid, SCENARIOS.get(sid, sid), case + + +def _evidence_path(run_dir: Path, nodeid: str) -> str | None: + """pytest-playwright writes // on failure; return it relative to run_dir.""" + art = run_dir / "artifacts" + if not art.is_dir(): + return None + name = nodeid.rsplit("::", 1)[-1] + for d in sorted(art.iterdir()): + if d.is_dir() and name[:40].replace("_", "-") in d.name.replace("_", "-"): + return str(d.relative_to(run_dir)) + return None + + +def collect_results(run_dir: Path) -> list[dict]: + """Prefer the conftest collector file; fall back to junit.xml. Returns one row per test.""" + rows: list[dict] = [] + collector = run_dir / "collector.json" + if collector.exists(): + try: + for r in json.loads(collector.read_text(encoding="utf-8")): + sid, name, case = _classify(r.get("nodeid", "")) + rows.append({ + "id": r.get("id") or sid, "name": r.get("name") or name, "case": r.get("case") or case, + "test": r.get("nodeid", "").rsplit("::", 1)[-1], "status": r.get("status", "error"), + "duration_ms": int(r.get("duration_ms", 0)), "http_status": r.get("http_status"), + "evidence": r.get("evidence") or _evidence_path(run_dir, r.get("nodeid", "")), + }) + return rows + except (ValueError, AttributeError): + rows = [] + junit = run_dir / "junit.xml" + if not junit.exists(): + return rows + try: + tree = ET.parse(junit) + except ET.ParseError: + return rows + for tc in tree.iter("testcase"): + nodeid = f"{tc.get('classname', '')}::{tc.get('name', '')}" + sid, name, case = _classify(nodeid) + status = "passed" + for child in tc: + if child.tag in ("failure",): + status = "failed" + elif child.tag == "error": + status = "error" + elif child.tag == "skipped": + status = "skipped" + http_status = None + for prop in tc.iter("property"): + if prop.get("name") == "http_status": + try: + http_status = int(prop.get("value", "")) + except ValueError: + http_status = prop.get("value") + rows.append({"id": sid, "name": name, "case": case, "test": tc.get("name", ""), "status": status, + "duration_ms": int(float(tc.get("time", "0") or 0) * 1000), "http_status": http_status, + "evidence": _evidence_path(run_dir, nodeid)}) + return rows + + +def write_results(run_dir: Path, data: dict) -> None: + run_dir.mkdir(parents=True, exist_ok=True) + (run_dir / "results.json").write_text(json.dumps(data, ensure_ascii=False, indent=2) + "\n", encoding="utf-8") + (run_dir / "results.toon").write_text(toon.encode(data, name="accept") + "\n", encoding="utf-8") + + +# --- entry point --------------------------------------------------------------------------------- + +def run(ctx: Context, args, runner=None, importer=None, now=None) -> int: + runner = runner or default_runner + missing = missing_modules(importer) + if missing: + return report.error(ctx, exit_codes.USAGE, f"missing {', '.join(missing)}; run: {INSTALL_HINT}") + + base_url = (getattr(args, "base_url", None) or default_base_url(ctx)).rstrip("/") + problem = loopback_problem(base_url) + if problem: + return report.error(ctx, exit_codes.USAGE, f"--base-url {base_url}: {problem}") + + browsers = ctx.root / BROWSERS_PATH + if not browsers.is_dir() or not any(browsers.iterdir()): + return report.error(ctx, exit_codes.USAGE, f"no Playwright browser under {browsers}; run: {INSTALL_HINT}") + + selection = select_tests(getattr(args, "only", None)) + if selection is None: + return report.error(ctx, exit_codes.USAGE, f"--only {args.only!r} matches no scenario in {ACCEPTANCE_DIR}") + paths, extra = selection + + started = now or _dt.datetime.now(_dt.timezone.utc) + run_id = make_run_id(started) + run_dir = ctx.root / "docs" / "demo" / "runs" / run_id + run_dir.mkdir(parents=True, exist_ok=True) + users = seed_users(run_id) + + env = dict(ctx.env) + env.update({ + "PLAYWRIGHT_BROWSERS_PATH": str(browsers), + "GRDM_BASE_URL": base_url, + "GRDM_RUN_ID": run_id, + "GRDM_ENV_FILE": str(ctx.runtime / ".env"), + "GRDM_ACCEPT_RESULTS": str(run_dir / "collector.json"), + "GRDM_ACCEPT_USER_A": users["user_a"]["email"], + "GRDM_ACCEPT_USER_B": users["user_b"]["email"], + "GRDM_ACCEPT_ADMIN": users["admin_user"]["email"], + }) + + seeded = False + if getattr(args, "seed", False): + for u in users.values(): + snippet = SEED_SNIPPET.format(email=u["email"], fullname=u["fullname"], admin=u["admin"]) + rc, out = runner(compose_exec(ctx, "web", "python3", "manage.py", "shell", "-c", snippet), env=env, cwd=ctx.root) + if rc != 0: + return report.error(ctx, exit_codes.SERVICES_UNHEALTHY, f"seed failed for {u['email']}: {out.strip()[-400:]}") + seeded = True + + try: + rc, out = runner(pytest_argv(paths, extra, run_dir, base_url, getattr(args, "headed", False)), env=env, cwd=ctx.root) + finally: + if seeded: + cleanup = CLEANUP_SNIPPET.format(domain=SEED_DOMAIN, run_id=run_id) + crc, cout = runner(compose_exec(ctx, "web", "python3", "manage.py", "shell", "-c", cleanup), env=env, cwd=ctx.root) + if crc != 0: + sys.stderr.write(f"warning: cleanup of seeded users failed: {cout.strip()[-200:]}\n") + (run_dir / "pytest.log").write_text(out, encoding="utf-8") + + rows = collect_results(run_dir) + finished = _dt.datetime.now(_dt.timezone.utc) + summary = {s: sum(1 for r in rows if r["status"] == s) for s in ("passed", "failed", "error", "skipped")} + summary["total"] = len(rows) + data = { + "run_id": run_id, + "base_url": base_url, + "started": started.strftime("%Y-%m-%dT%H:%M:%SZ"), + "duration_ms": int((finished - started).total_seconds() * 1000) if now is None else sum(r["duration_ms"] for r in rows), + "only": getattr(args, "only", None), + "seeded": seeded, + "pytest_returncode": rc, + "evidence_dir": str(run_dir.relative_to(ctx.root)) if run_dir.is_relative_to(ctx.root) else str(run_dir), + "summary": summary, + "tests": rows, + } + write_results(run_dir, data) + report.emit(ctx, "accept", data) + + if rc == 5: # pytest: no tests collected + return report.error(ctx, exit_codes.USAGE, "pytest collected no tests") + if rc != 0 or summary["failed"] or summary["error"]: + return report.error(ctx, exit_codes.ACCEPTANCE_FAILED, + f"{summary['failed'] + summary['error']} failing test(s); see {run_dir}") + return exit_codes.OK diff --git a/installer/build/lib/grdm_dev/build.py b/installer/build/lib/grdm_dev/build.py new file mode 100644 index 0000000..34f0955 --- /dev/null +++ b/installer/build/lib/grdm_dev/build.py @@ -0,0 +1,186 @@ +"""grdm-dev build — clone integration repositories and build images with docker buildx (SPEC-02 §3). + +For every buildable component of the resolved profile (a component with an `integration_repo`), +the integration repository `RDM--dev2027` is cloned into runtime/src/ with +`git clone --filter=blob:none` (or fetched when already present), checked out at the pinned +commit, and built with `docker buildx build`. The clone URL is composed at run time from the +bare repository name in the manifest (SPEC-01 rule 5: names only in files). + +Pinned commit: `Component.build_sha` from grdm_dev.manifest — the component's `integration_sha` +when the weekly integration PR has written one, else the first merged upstream SHA in SPEC-01 +rule 3 order (public, then private). Without any SHA the head of `origin/` is +checked out; the SHA actually checked out is always re-read with `git rev-parse` and recorded in +the build report (`components[]{component,sha12}`), which `compose render` reads as image tags. + +Images: local builds use `--load` for the host platform (or --platform) and tag +`grdm-dev/:`. With --push, the multi-arch manifest is pushed to +`ghcr.io/rcosdp/:` as well. Exit 30 names the failing component. + +Runner: `runner(argv) -> (returncode, stdout)`; the default streams the child's output lines to +stderr while collecting them, so a long build stays visible. Tests inject a fake. +""" +from __future__ import annotations + +import platform as _platform +import subprocess +import sys +from pathlib import Path + +from . import exit_codes, report +from .context import Context + +GITHUB_ORG = "RCOSDP" +REGISTRY = "ghcr.io/rcosdp" +LOCAL_IMAGE_PREFIX = "grdm-dev" +PROFILE_RANK = {"minimum": 0, "core": 1, "full": 2} +DEFAULT_PROFILE = "core" + + +def default_runner(argv: list[str]) -> tuple[int, str]: + """Run argv, stream every output line to stderr, return (returncode, collected output).""" + lines: list[str] = [] + try: + proc = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) + except OSError as exc: + return 127, str(exc) + assert proc.stdout is not None + for line in proc.stdout: + sys.stderr.write(line) + lines.append(line) + return proc.wait(), "".join(lines) + + +def host_platform() -> str: + machine = _platform.machine().lower() + if machine in ("arm64", "aarch64"): + return "linux/arm64" + if machine in ("x86_64", "amd64"): + return "linux/amd64" + return f"linux/{machine}" + + +def clone_url(repo_name: str) -> str: + """Compose the HTTPS URL from the bare name; the URL is never stored in the manifest or docs.""" + return f"https://github.com/{GITHUB_ORG}/{repo_name}.git" + + +def load_components(ctx: Context) -> list: + """Components of the manifest (grdm_dev.manifest dataclasses; dict-compatible).""" + from . import manifest as _manifest + + return list(_manifest.load(ctx).components) + + +def resolve_profile(ctx: Context) -> str: + if ctx.profile: + return ctx.profile + from .secrets import env_path, read_env + + return read_env(env_path(ctx)).get("GRDM_PROFILE") or DEFAULT_PROFILE + + +def buildable_components(components: list[dict], profile: str, only: str | None = None) -> list[dict]: + rank = PROFILE_RANK.get(profile, PROFILE_RANK[DEFAULT_PROFILE]) + out = [] + for comp in components: + if not comp.get("integration_repo"): + continue + if PROFILE_RANK.get(comp.get("profile", "full"), 2) > rank and only is None: + continue + if only is not None and comp.get("id") != only: + continue + out.append(comp) + return out + + +def image_name(component_id: str) -> str: + return component_id.lower() + + +def sync_source(repo: str, dest: Path, ref: str, runner) -> tuple[int, str, str]: + """Clone or fetch `repo` into dest and check out `ref`. Returns (rc, resolved_sha, log).""" + log: list[str] = [] + if (dest / ".git").exists(): + rc, out = runner(["git", "-C", str(dest), "fetch", "--filter=blob:none", "origin"]) + else: + dest.parent.mkdir(parents=True, exist_ok=True) + rc, out = runner(["git", "clone", "--filter=blob:none", "--no-checkout", clone_url(repo), str(dest)]) + log.append(out) + if rc != 0: + return rc, "", "".join(log) + rc, out = runner(["git", "-C", str(dest), "checkout", "--detach", "--force", ref]) + log.append(out) + if rc != 0: + return rc, "", "".join(log) + rc, out = runner(["git", "-C", str(dest), "rev-parse", "HEAD"]) + log.append(out) + return rc, out.strip().splitlines()[-1] if out.strip() else "", "".join(log) + + +def buildx_argv(component_id: str, context_dir: Path, sha12: str, platforms: list[str], push: bool) -> list[str]: + name = image_name(component_id) + argv = ["docker", "buildx", "build", "--platform", ",".join(platforms)] + argv += ["--push" if push else "--load"] + argv += ["-t", f"{LOCAL_IMAGE_PREFIX}/{name}:{sha12}"] + if push: + argv += ["-t", f"{REGISTRY}/{name}:{sha12}"] + argv += ["--label", f"org.gakunin-rdm.component={component_id}", "--label", f"org.gakunin-rdm.sha={sha12}"] + argv.append(str(context_dir)) + return argv + + +def pinned_ref(comp) -> str: + sha = getattr(comp, "build_sha", None) or comp.get("integration_sha") + if sha: + return sha + return f"origin/{comp.get('integration_branch') or 'develop'}" + + +def register(subparsers) -> None: + p = subparsers.add_parser("build", help="clone integration repos at the pinned SHA and build images with buildx; exit 30 on failure") + p.add_argument("--platform", help="comma-separated platforms (default: host platform only)") + p.add_argument("--push", action="store_true", help=f"push the multi-arch manifest to {REGISTRY}/") + p.add_argument("--component", help="build only this component id") + p.set_defaults(_module=sys.modules[__name__]) + + +def run(ctx: Context, args, runner=None) -> int: + runner = runner or default_runner + platforms = [s.strip() for s in (getattr(args, "platform", None) or host_platform()).split(",") if s.strip()] + push = bool(getattr(args, "push", False)) + only = getattr(args, "component", None) + profile = resolve_profile(ctx) + try: + components = load_components(ctx) + except Exception as exc: # manifest.ManifestError, OSError, ValueError → SPEC-02 exit 20 + detail = "; ".join(getattr(exc, "errors", []) or [str(exc)]) + return report.error(ctx, exit_codes.MANIFEST_INVALID, detail) + selected = buildable_components(components, profile, only) + if only is not None and not selected: + return report.error(ctx, exit_codes.USAGE, f"unknown or non-buildable component: {only}") + + rows: list[dict] = [] + failed: str | None = None + detail = "" + for comp in selected: + cid = comp["id"] + repo = comp["integration_repo"] + dest = ctx.runtime / "src" / repo + rc, sha, log = sync_source(repo, dest, pinned_ref(comp), runner) + if rc != 0 or not sha: + rows.append({"component": cid, "repo": repo, "sha12": "", "platforms": ",".join(platforms), "status": "source-failed"}) + failed, detail = cid, f"could not fetch {repo} at {pinned_ref(comp)}" + break + sha12 = sha[:12] + rc, out = runner(buildx_argv(cid, dest, sha12, platforms, push)) + status = "pushed" if (rc == 0 and push) else "built" if rc == 0 else "build-failed" + rows.append({"component": cid, "repo": repo, "sha12": sha12, "platforms": ",".join(platforms), "status": status}) + if rc != 0: + failed, detail = cid, f"docker buildx build exited {rc}" + break + + data = {"profile": profile, "platforms": platforms, "push": push, "components": rows, "failed": failed} + report.emit(ctx, "build", data) + if failed is not None: + return report.error(ctx, exit_codes.BUILD_FAILED, f"component {failed}: {detail}") + return exit_codes.OK diff --git a/installer/build/lib/grdm_dev/cli.py b/installer/build/lib/grdm_dev/cli.py new file mode 100644 index 0000000..4571e3d --- /dev/null +++ b/installer/build/lib/grdm_dev/cli.py @@ -0,0 +1,89 @@ +"""grdm-dev command line: argument parsing and subcommand dispatch (SPEC-02 §3, §5, §6).""" +from __future__ import annotations + +import argparse +import importlib +import sys + +from . import __version__, exit_codes +from .context import Context, find_repo_root + +# Each module exposes register(subparsers) and run(ctx, args). Order = help order. +SUBCOMMAND_MODULES = [ + "doctor", "plan", "secrets", "compose", "build", "lifecycle", "health", + "scan", "redteam", "accept", "upstream", "manifest_cmd", "docs", "report_cmd", "install", +] + + +def build_parser() -> argparse.ArgumentParser: + p = argparse.ArgumentParser( + prog="grdm-dev", + description="GakuNin RDM developer environment 2027 — one-command installer (SPEC-02)", + ) + p.add_argument("--version", action="version", version=f"grdm-dev {__version__}") + _add_global_flags(p) + p.add_argument("--root", help="repository root (default: auto-detect from manifest/upstreams.json)") + sub = p.add_subparsers(dest="command", metavar="") + for name in SUBCOMMAND_MODULES: + try: + mod = importlib.import_module(f".{name}", __package__) + except ImportError as exc: + # A subcommand (or one of its in-package helpers) is not implemented yet: hide it from + # help instead of breaking every other command. Errors outside this package still raise. + missing = getattr(exc, "name", None) or "" + if missing.startswith(__package__) or f"from '{__package__}'" in str(exc): + continue + raise + mod.register(sub) + # SPEC-02 §2.2: every subcommand accepts --json (and the other global flags) after its name too, + # e.g. `grdm-dev doctor --json`. Add them to each sub-parser with SUPPRESS defaults so that a + # value given in either position wins and the global default is kept otherwise. + for sp in sub.choices.values(): + _add_global_flags_recursive(sp) + return p + + +def _add_global_flags_recursive(p: argparse.ArgumentParser) -> None: + """Add the global flags to a sub-parser and to any nested sub-parsers (e.g. `secrets init`).""" + _add_global_flags(p, suppress=True) + for action in p._actions: # noqa: SLF001 - argparse has no public API for nested sub-parsers + if isinstance(action, argparse._SubParsersAction): + for child in action.choices.values(): + _add_global_flags_recursive(child) + + +def _add_global_flags(p: argparse.ArgumentParser, suppress: bool = False) -> None: + d = argparse.SUPPRESS if suppress else None + kw = {"default": d} if suppress else {} + p.add_argument("--yes", action="store_true", help="answer every question with its default (required without a terminal)", **kw) + p.add_argument("--json", dest="json_output", action="store_true", help="print reports as JSON instead of TOON", **kw) + p.add_argument("--profile", choices=["minimum", "core", "full"], help="service profile (default: saved value or core)", **kw) + p.add_argument("-v", "--verbose", action="store_true", **kw) + + +def main(argv: list[str] | None = None) -> int: + parser = build_parser() + try: + args = parser.parse_args(argv) + except SystemExit as exc: # argparse exits 2 on usage errors; keep SPEC-02's code 2 + return exit_codes.USAGE if exc.code not in (0, None) else 0 + if not getattr(args, "command", None): + parser.print_help() + return exit_codes.USAGE + from pathlib import Path + + root = Path(args.root).resolve() if args.root else find_repo_root() + ctx = Context(root=root, yes=args.yes, json_output=args.json_output, profile=args.profile, verbose=args.verbose) + mod = getattr(args, "_module", None) # set by each module's register(): parser.set_defaults(_module=sys.modules[__name__]) + if mod is None: + parser.print_help() + return exit_codes.USAGE + try: + return int(mod.run(ctx, args)) + except KeyboardInterrupt: + sys.stderr.write("\ninterrupted\n") + return exit_codes.USAGE + + +if __name__ == "__main__": # pragma: no cover + sys.exit(main()) diff --git a/installer/build/lib/grdm_dev/compose.py b/installer/build/lib/grdm_dev/compose.py new file mode 100644 index 0000000..65d8d19 --- /dev/null +++ b/installer/build/lib/grdm_dev/compose.py @@ -0,0 +1,712 @@ +"""grdm-dev compose render — write runtime/docker-compose.yml from templates + manifest (SPEC-02 §3, ADR-02). + +Output is JSON (Compose accepts JSON because JSON is YAML). Rules applied to every service: + +* one bridge network `grdm`; services address each other by Compose service name (ADR-02 §3.1); +* ports only as `127.0.0.1::`; host ports from the SPEC-02 §4 table, overridden by + `GRDM_PORT_` in runtime/.env, remapped to the next free port on collision (exit 12 when + none is free within +100); every chosen port is written back to runtime/.env; +* `user:` non-root (uid from the template), `read_only: true` with explicit `tmpfs`/volumes, + `cap_drop: [ALL]`, `security_opt: [no-new-privileges:true]`, `mem_limit`/`cpus`/`pids_limit` + scaled from the detected memory (argument; default 16 GiB), `platform:` from the argument or + host detection; per-service exceptions come from manifest/hardening.json (SPEC-03 §3.3); +* named volumes are local bind volumes under runtime/volumes/; +* secrets never enter generated files: the compose file references `${KEY}` and Compose reads + runtime/.env (same directory) at `up`; `secrets init` must have run (exit 2 otherwise). + +Template schema (templates/.json): service, component, profile?, container_port?, +host_port?, expose?, command?, environment?, env_files?, volumes? ([{volume|config|config_dir, +target, ro?}]), tmpfs?, user?, depends_on?, weight, mem_min_mb, pids_limit, note?. Strings may use +`{{HOST_PORT:}}` / `{{CONTAINER_PORT:}}`. + +Upstream settings are rewritten under runtime/config/ (ADR-02 §3.3): osf/local.py, osf/api_local.py, +osf.env, wb.env, mfr.env, sharejs.env, postgres-init/10-cas.sql, cas/cas.properties. Internal URLs use +service names, browser-facing URLs use http://127.0.0.1:. +""" +from __future__ import annotations + +import json +import math +import os +import re +import socket +import sys +from pathlib import Path +from typing import Any, Callable + +from . import exit_codes, manifest as _manifest, report +from .context import Context +from .plan import ( + DEFAULT_PORTS, + LOOPBACK, + PROFILE_ENV_KEY, + detect_platform, + env_path, + port_key, + published_ports, + read_dotenv, + resolve_profile, + volumes_of, +) + +NETWORK = "grdm" +PROJECT_NAME = "grdm-dev" +COMPOSE_FILE = "docker-compose.yml" +CONFIG_DIR = "config" +VOLUMES_DIR = "volumes" +DEFAULT_MEMORY_GIB = 16.0 +DEFAULT_CPUS = 4.0 +MEMORY_SHARE = 0.70 # fraction of host memory handed out as the sum of mem_limit +CPU_OVERSUBSCRIBE = 2.0 # limits may add up to twice the host CPUs (they are ceilings) +PORT_SEARCH_RANGE = 100 +FORBIDDEN_ADDRESS = "192.168.168.167" # the old loopback alias; must never appear (ADR-02) + +# Keys that compose output references; all are written by `grdm-dev secrets init` (secrets.py). +REQUIRED_SECRETS: tuple[str, ...] = ( + "POSTGRES_PASSWORD", + "DJANGO_SECRET_KEY", + "API_SECRET_KEY", + "SESSION_COOKIE_SECRET", + "RABBITMQ_DEFAULT_PASS", + "WATERBUTLER_JWE_SECRET", + "WATERBUTLER_JWE_SALT", + "WATERBUTLER_JWT_SECRET", + "MFR_SERVER_SECRET", + "SHAREJS_SECRET", + "Y_WEBSOCKET_JWT_SECRET", +) + +PortChecker = Callable[[int], bool] + +GENERATED_HEADER = "generated by grdm-dev compose render; do not edit (SPEC-02 §3, ADR-02)" + + +def register(subparsers) -> None: + p = subparsers.add_parser("compose", help="render runtime/docker-compose.yml from manifest, profile and templates") + sub = p.add_subparsers(dest="compose_command", metavar="") + r = sub.add_parser("render", help="write runtime/docker-compose.yml and runtime/config/*; touches no Docker") + r.add_argument("--auth", choices=[_manifest.AUTH_FAKECAS, _manifest.AUTH_SHIBBOLETH], default=_manifest.AUTH_FAKECAS, + help="auth provider for the full profile (shibboleth replaces fakecas)") + r.add_argument("--platform", help="Compose platform, e.g. linux/arm64 (default: detected host)") + r.add_argument("--memory-gib", type=float, help="host memory to scale resource limits from (default: detected, else 16)") + r.add_argument("--cpus", type=float, help="host CPUs to scale cpu limits from (default: detected, else 4)") + p.set_defaults(_module=sys.modules[__name__]) + + +# --------------------------------------------------------------------------- hardening + + +def load_hardening(root: Path) -> dict[str, dict[str, Any]]: + """manifest/hardening.json exceptions keyed by service. Missing file -> no exceptions.""" + path = root / "manifest" / "hardening.json" + if not path.exists(): + return {} + data = json.loads(path.read_text(encoding="utf-8")) + out: dict[str, dict[str, Any]] = {} + for entry in data.get("exceptions", []): + if not entry.get("reason") or not entry.get("review"): + raise ValueError(f"hardening.json: exception for {entry.get('service')!r} needs reason and review") + out[entry["service"]] = entry + return out + + +# --------------------------------------------------------------------------- ports + + +def default_port_checker(port: int) -> bool: + """True when 127.0.0.1: can be bound right now.""" + with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: + s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + try: + s.bind((LOOPBACK, port)) + return True + except OSError: + return False + + +def assign_ports(rows: list[dict[str, Any]], checker: PortChecker) -> tuple[list[dict[str, Any]], list[dict[str, Any]], list[str]]: + """Remap busy ports to the next free one. Returns (rows, remapped, unresolved).""" + taken: set[int] = set() + remapped: list[dict[str, Any]] = [] + unresolved: list[str] = [] + out: list[dict[str, Any]] = [] + for row in rows: + wanted = int(row["host_port"]) + chosen = None + for cand in range(wanted, wanted + PORT_SEARCH_RANGE + 1): + if cand in taken or cand > 65535: + continue + if checker(cand): + chosen = cand + break + if chosen is None: + unresolved.append(row["service"]) + out.append(row) + continue + taken.add(chosen) + new = dict(row) + new["host_port"] = chosen + new["url"] = f"http://{LOOPBACK}:{chosen}" + if chosen != wanted: + new["source"] = "remapped" + remapped.append({"service": row["service"], "wanted": wanted, "chosen": chosen}) + out.append(new) + return out, remapped, unresolved + + +def host_port_map(env: dict[str, str], rows: list[dict[str, Any]]) -> dict[str, int]: + """Host port per service: assigned rows first, then .env overrides, then the SPEC-02 §4 defaults. + + Services outside the profile still get a port so generated settings (e.g. WATERBUTLER_URL) are complete. + """ + ports = dict(DEFAULT_PORTS) + for name in DEFAULT_PORTS: + raw = env.get(port_key(name)) + if raw and raw.isdigit(): + ports[name] = int(raw) + for row in rows: + ports[row["service"]] = int(row["host_port"]) + return ports + + +_PLACEHOLDER = re.compile(r"\{\{(HOST_PORT|CONTAINER_PORT):([A-Za-z0-9_]+)\}\}") + + +def substitute(value: Any, host_ports: dict[str, int], container_ports: dict[str, int]) -> Any: + if isinstance(value, str): + def repl(m: re.Match) -> str: + table = host_ports if m.group(1) == "HOST_PORT" else container_ports + if m.group(2) not in table: + raise ValueError(f"template placeholder {m.group(0)} has no known port") + return str(table[m.group(2)]) + return _PLACEHOLDER.sub(repl, value) + if isinstance(value, list): + return [substitute(v, host_ports, container_ports) for v in value] + if isinstance(value, dict): + return {k: substitute(v, host_ports, container_ports) for k, v in value.items()} + return value + + +# --------------------------------------------------------------------------- resources + + +def scale_resources(services: list[_manifest.Service], memory_gib: float, cpus: float) -> dict[str, dict[str, Any]]: + budget_mb = memory_gib * 1024 * MEMORY_SHARE + total_weight = sum(float(s.template.get("weight", 1)) for s in services) or 1.0 + out: dict[str, dict[str, Any]] = {} + for svc in services: + tpl = svc.template + weight = float(tpl.get("weight", 1)) + mem = max(int(tpl.get("mem_min_mb", 128)), int(math.floor(budget_mb * weight / total_weight))) + cpu = min(cpus, max(0.5, cpus * CPU_OVERSUBSCRIBE * weight / total_weight)) + out[svc.name] = {"mem_limit": f"{mem}m", "cpus": round(cpu, 2), "pids_limit": int(tpl.get("pids_limit", 512))} + return out + + +# --------------------------------------------------------------------------- rendering + + +def _mount(entry: dict[str, Any]) -> str: + target = entry["target"] + suffix = ":ro" if entry.get("ro") else "" + if "volume" in entry: + return f"{entry['volume']}:{target}{suffix}" + if "config" in entry: + return f"./{CONFIG_DIR}/{entry['config']}:{target}{suffix}" + if "config_dir" in entry: + return f"./{CONFIG_DIR}/{entry['config_dir']}:{target}{suffix}" + raise ValueError(f"unknown volume entry {entry!r}") + + +def render_service( + svc: _manifest.Service, + *, + in_profile: set[str], + host_ports: dict[str, int], + container_ports: dict[str, int], + published: dict[str, int], + hardening: dict[str, dict[str, Any]], + resources: dict[str, Any], + platform_string: str, +) -> dict[str, Any]: + tpl = substitute(svc.template, host_ports, container_ports) + exc = hardening.get(svc.name, {}) + relaxed = set(exc.get("controls", [])) + out: dict[str, Any] = {"image": svc.image} + if platform_string and platform_string != "unknown": + out["platform"] = platform_string + if "command" in tpl: + out["command"] = tpl["command"] + if "user" not in relaxed: + out["user"] = tpl.get("user", "1000:1000") + out["read_only"] = "read_only" not in relaxed + out["cap_drop"] = ["ALL"] + if "cap_add" in relaxed and exc.get("cap_add"): + out["cap_add"] = list(exc["cap_add"]) + out["security_opt"] = ["no-new-privileges:true"] + if tpl.get("environment"): + out["environment"] = dict(tpl["environment"]) + if tpl.get("env_files"): + out["env_file"] = [f"./{CONFIG_DIR}/{name}" for name in tpl["env_files"]] + if tpl.get("volumes"): + out["volumes"] = [_mount(v) for v in tpl["volumes"]] + if tpl.get("tmpfs"): + out["tmpfs"] = list(tpl["tmpfs"]) + if svc.name in published: + out["ports"] = [f"{LOOPBACK}:{published[svc.name]}:{container_ports[svc.name]}"] + expose = [str(p) for p in tpl.get("expose", [])] + if "container_port" in tpl and str(tpl["container_port"]) not in expose and svc.name not in published: + expose.insert(0, str(tpl["container_port"])) + if expose: + out["expose"] = expose + deps = [d for d in tpl.get("depends_on", []) if d in in_profile] + if deps: + out["depends_on"] = deps + out["networks"] = [NETWORK] + out["restart"] = tpl.get("restart", "unless-stopped") + out["init"] = True + out.update(resources) + out["labels"] = { + "org.gakunin-rdm.component": svc.component, + "org.gakunin-rdm.profile": svc.profile, + "org.gakunin-rdm.hardening-exception": ",".join(sorted(relaxed)) if relaxed else "none", + } + return out + + +def render_compose( + services: list[_manifest.Service], + *, + runtime: Path, + host_ports: dict[str, int], + published: dict[str, int], + hardening: dict[str, dict[str, Any]], + memory_gib: float, + cpus: float, + platform_string: str, +) -> dict[str, Any]: + in_profile = {s.name for s in services} + container_ports = {s.name: int(s.template.get("container_port", DEFAULT_PORTS.get(s.name, 0))) for s in services} + for name, port in DEFAULT_PORTS.items(): + container_ports.setdefault(name, port) + resources = scale_resources(services, memory_gib, cpus) + rendered = { + svc.name: render_service( + svc, + in_profile=in_profile, + host_ports=host_ports, + container_ports=container_ports, + published=published, + hardening=hardening, + resources=resources[svc.name], + platform_string=platform_string, + ) + for svc in services + } + volumes = { + name: { + "driver": "local", + "driver_opts": {"type": "none", "o": "bind", "device": str(runtime / VOLUMES_DIR / name)}, + } + for name in volumes_of(services) + } + return { + "name": PROJECT_NAME, + "x-grdm-dev": {"generated": GENERATED_HEADER, "network_model": "ADR-02", "memory_gib": memory_gib, "cpus": cpus}, + "networks": {NETWORK: {"driver": "bridge", "name": f"{PROJECT_NAME}_{NETWORK}"}}, + "volumes": volumes, + "services": rendered, + } + + +# --------------------------------------------------------------------------- settings rewrite (ADR-02 §3.3) + + +def _ext(host_ports: dict[str, int], service: str, trailing: str = "") -> str: + return f"http://{LOOPBACK}:{host_ports[service]}{trailing}" + + +def render_website_local_py(host_ports: dict[str, int]) -> str: + """website/settings/local.py — internal URLs by service name, browser URLs on 127.0.0.1.""" + lines = [ + "# -*- coding: utf-8 -*-", + f"# {GENERATED_HEADER}", + "# Internal URLs use Compose service names; browser-facing URLs use http://127.0.0.1:/ (ADR-02 §3.3).", + "# Secrets come from the environment (runtime/.env via Compose), never from this file.", + "import logging", + "from os import environ", + "", + "from . import defaults", + "", + "DEV_MODE = True", + "DEBUG_MODE = True", + "SECURE_MODE = False", + "PROTOCOL = 'http://'", + "", + f"DOMAIN = '{_ext(host_ports, 'web', '/')}'", + "INTERNAL_DOMAIN = 'http://web:5000/'", + f"API_DOMAIN = '{_ext(host_ports, 'api', '/')}'", + f"WATERBUTLER_URL = '{_ext(host_ports, 'wb')}'", + "WATERBUTLER_INTERNAL_URL = 'http://wb:7777'", + f"MFR_SERVER_URL = '{_ext(host_ports, 'mfr')}'", + "MFR_INTERNAL_SERVER_URL = 'http://mfr:7778'", + f"CAS_SERVER_URL = '{_ext(host_ports, 'fakecas')}'", + "CAS_INTERNAL_SERVER_URL = 'http://fakecas:8080' # server-side ticket validation inside the network", + f"ADMIN_URL = '{_ext(host_ports, 'admin', '/')}'", + "ADMIN_INTERNAL_DOCKER_URL = 'http://admin:8001/'", + "", + "USE_EXTERNAL_EMBER = True", + "PROXY_EMBER_APPS = True", + "EMBER_DOMAIN = 'ember_osf_web' # web proxies to the ember container by service name", + f"LIVE_RELOAD_DOMAIN = '{_ext(host_ports, 'ember_osf_web')}' # the browser reaches live reload on the host", + "EXTERNAL_EMBER_APPS = {", + " 'ember_osf_web': {", + " 'server': 'http://ember_osf_web:4200/',", + " 'path': '/ember_osf_web/',", + " 'routes': ['collections', 'registries', 'handbook'],", + " },", + "}", + "PREPRINT_PROVIDER_DOMAINS = {'enabled': False, 'prefix': 'http://local.', 'suffix': ':4201/'}", + "", + "SEARCH_ENGINE = 'elastic'", + "ELASTIC_URI = 'elasticsearch:9200'", + "ELASTIC6_URI = 'elasticsearch6:9200'", + "ELASTIC_TIMEOUT = 10", + "", + "USE_EMAIL = False", + "MAIL_SERVER = 'localhost:1025'", + "ENABLE_EMAIL_SUBSCRIPTIONS = False", + "", + "COOKIE_NAME = 'osf'", + "OSF_COOKIE_DOMAIN = None", + "SECRET_KEY = environ['SECRET_KEY']", + "SESSION_COOKIE_SECURE = SECURE_MODE", + "SESSION_COOKIE_SAMESITE = 'Lax'", + "OSF_SERVER_KEY = None", + "OSF_SERVER_CERT = None", + "", + "WATERBUTLER_JWE_SALT = environ['WATERBUTLER_JWE_SALT']", + "WATERBUTLER_JWE_SECRET = environ['WATERBUTLER_JWE_SECRET']", + "WATERBUTLER_JWT_SECRET = environ['WATERBUTLER_JWT_SECRET']", + "", + "", + "class CeleryConfig(defaults.CeleryConfig):", + " broker_url = environ['BROKER_URL']", + "", + "", + "USE_CDN_FOR_CLIENT_LIBS = False", + "SENDGRID_WHITELIST_MODE = True", + "SENDGRID_EMAIL_WHITELIST = []", + "OSF_SUPPORT_EMAIL = 'support@example.invalid'", + "OSF_CONTACT_EMAIL = 'contact@example.invalid'", + "DOI_FORMAT = '{prefix}/FK2osf.io/{guid}'", + "CHRONOS_USE_FAKE_FILE = True", + "ENABLE_TIMESTAMP = False", + "SHARE_ENABLED = False", + "logging.getLogger('website.mails.mails').setLevel(logging.DEBUG)", + "", + ] + return "\n".join(lines) + + +def render_api_local_py(host_ports: dict[str, int]) -> str: + return "\n".join([ + f"# {GENERATED_HEADER}", + "from .defaults import * # noqa", + "from os import environ", + "from website import settings as osf_settings", + "", + "DEBUG = osf_settings.DEBUG_MODE", + "SECRET_KEY = environ['API_SECRET_KEY']", + "VARNISH_SERVERS = []", + "ENABLE_VARNISH = False", + "ENABLE_ESI = False", + "CORS_ORIGIN_ALLOW_ALL = True", + f"ALLOWED_HOSTS += ['{LOOPBACK}', 'localhost', 'api', 'web']", + "", + "REST_FRAMEWORK['DEFAULT_THROTTLE_RATES'] = {", + " 'user': '1000000/second',", + " 'non-cookie-auth': '1000000/second',", + " 'add-contributor': '1000000/second',", + " 'create-guid': '1000000/second',", + " 'root-anon-throttle': '1000000/second',", + " 'test-user': '2/hour',", + " 'test-anon': '1/hour',", + " 'send-email': '2/minute',", + " 'burst': '10/second',", + "}", + "", + ]) + + +def _env_text(pairs: list[tuple[str, str]]) -> str: + return f"# {GENERATED_HEADER}\n" + "".join(f"{k}={v}\n" for k, v in pairs) + + +def render_osf_env(host_ports: dict[str, int]) -> str: + return _env_text([ + ("DOMAIN", _ext(host_ports, "web", "/")), + ("INTERNAL_DOMAIN", "http://web:5000/"), + ("API_DOMAIN", _ext(host_ports, "api", "/")), + ("ELASTIC_URI", "elasticsearch:9200"), + ("ELASTIC6_URI", "elasticsearch6:9200"), + ("OSF_DB_HOST", "postgres"), + ("OSF_DB_PORT", "5432"), + ("OSF_DB_NAME", "osf"), + ("OSF_DB_USER", "postgres"), + ("DB_HOST", "postgres"), + ("WATERBUTLER_URL", _ext(host_ports, "wb")), + ("WATERBUTLER_INTERNAL_URL", "http://wb:7777"), + ("CAS_SERVER_URL", _ext(host_ports, "fakecas")), + ("CAS_INTERNAL_SERVER_URL", "http://fakecas:8080"), + ("MFR_SERVER_URL", _ext(host_ports, "mfr")), + ("MFR_INTERNAL_SERVER_URL", "http://mfr:7778"), + ("REDIS_URL", "redis://redis:6379/1"), + ("EMBER_DOMAIN", "ember_osf_web"), + ("ADMIN_URL", _ext(host_ports, "admin", "/")), + ("ADMIN_INTERNAL_DOCKER_URL", "http://admin:8001/"), + ]) + + +def render_wb_env(host_ports: dict[str, int]) -> str: + return _env_text([ + ("DEBUG", ""), + ("SERVER_CONFIG_DEBUG", ""), + ("SERVER_CONFIG_ADDRESS", "0.0.0.0"), + ("SERVER_CONFIG_PORT", "7777"), + ("SERVER_CONFIG_DOMAIN", _ext(host_ports, "wb")), + ("OSF_AUTH_CONFIG_API_URL", "http://web:5000/api/v1/files/auth/"), + ("OSF_URL", "http://web:5000"), + ]) + + +def render_mfr_env(host_ports: dict[str, int]) -> str: + allowed = " ".join(["http://web:5000/", "http://wb:7777/", _ext(host_ports, "web", "/"), _ext(host_ports, "wb", "/")]) + return _env_text([ + ("DEBUG", ""), + ("SERVER_CONFIG_DEBUG", ""), + ("SERVER_CONFIG_ADDRESS", "0.0.0.0"), + ("SERVER_CONFIG_PORT", "7778"), + ("SERVER_CONFIG_ALLOWED_PROVIDER_DOMAINS", f"'{allowed}'"), + ("UNOCONV_PORT_2002_TCP_ADDR", "unoconv"), + ("UNOCONV_PORT_2002_TCP_PORT", "2002"), + ("EXTENSION_CONFIG_LOCAL_DEVELOPMENT", "1"), + ("EXTENSION_CONFIG_DOCKER_LOCAL_HOST", "wb"), + ("EXTENSION_CONFIG_LOCAL_HOST", LOOPBACK), + ]) + + +def render_sharejs_env(host_ports: dict[str, int]) -> str: + return _env_text([ + ("SHAREJS_SERVER_HOST", "0.0.0.0"), + ("SHAREJS_SERVER_PORT", "7007"), + ("SHAREJS_DB_NAME", "sharejs"), + ("SHAREJS_DB_URL", "mongodb://mongo:27017/sharejs?ssl=true"), + ("SHAREJS_CORS_ALLOW_ORIGIN", _ext(host_ports, "web")), + ]) + + +def render_postgres_init() -> str: + return f"-- {GENERATED_HEADER}\n-- cas-overlay keeps its tickets in a second database on the shared postgres.\nCREATE DATABASE cas;\n" + + +def render_cas_properties(host_ports: dict[str, int]) -> str: + return "\n".join([ + f"# {GENERATED_HEADER}", + "server.name=http://cas:8080", + "server.prefix=${server.name}", + f"osf.url={_ext(host_ports, 'web', '/')}", + "osf.api.url=http://api:8000/", + "database.url=jdbc:postgresql://postgres:5432/cas", + "database.user=postgres", + "# database.password is read from the DATABASE_PASSWORD environment variable", + "", + ]) + + +def config_files(host_ports: dict[str, int]) -> dict[str, str]: + """Relative path under runtime/config -> content.""" + return { + "osf/local.py": render_website_local_py(host_ports), + "osf/api_local.py": render_api_local_py(host_ports), + "osf.env": render_osf_env(host_ports), + "wb.env": render_wb_env(host_ports), + "mfr.env": render_mfr_env(host_ports), + "sharejs.env": render_sharejs_env(host_ports), + "postgres-init/10-cas.sql": render_postgres_init(), + "cas/cas.properties": render_cas_properties(host_ports), + } + + +# --------------------------------------------------------------------------- files + + +def _write_if_changed(path: Path, text: str, mode: int = 0o644) -> bool: + path.parent.mkdir(parents=True, exist_ok=True) + if path.exists() and path.read_text(encoding="utf-8") == text: + return False + tmp = path.with_name(path.name + ".tmp") + fd = os.open(tmp, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, mode) + with os.fdopen(fd, "w", encoding="utf-8") as fh: + fh.write(text) + os.replace(tmp, path) + return True + + +def update_dotenv(path: Path, updates: dict[str, str]) -> bool: + """Set keys in runtime/.env in place, keeping every other line and mode 0600.""" + lines = path.read_text(encoding="utf-8").splitlines() if path.exists() else [] + seen: set[str] = set() + out: list[str] = [] + for line in lines: + key = line.partition("=")[0].strip() if "=" in line and not line.lstrip().startswith("#") else None + if key in updates: + out.append(f"{key}={updates[key]}") + seen.add(key) + else: + out.append(line) + for key, value in updates.items(): + if key not in seen: + out.append(f"{key}={value}") + text = "\n".join(out) + "\n" + changed = _write_if_changed(path, text, mode=0o600) + os.chmod(path, 0o600) + return changed + + +def built_image_tags(ctx: Context) -> dict[str, str]: + """component id -> sha12 from the latest build report, when one exists.""" + path = ctx.reports_dir / "build_latest.json" + if not path.exists(): + return {} + try: + data = json.loads(path.read_text(encoding="utf-8")) + except (OSError, ValueError): + return {} + return { + row["component"]: row["sha12"] + for row in data.get("components", []) + if row.get("sha12") and row.get("status") in ("built", "pushed") + } + + +def detect_memory_gib() -> float | None: + """Physical memory from os.sysconf (Linux, macOS); None when unknown. No subprocess, no Docker.""" + try: + pages = os.sysconf("SC_PHYS_PAGES") + page_size = os.sysconf("SC_PAGE_SIZE") + if pages > 0 and page_size > 0: + return pages * page_size / (1024 ** 3) + except (ValueError, OSError, AttributeError): + pass + return None + + +# --------------------------------------------------------------------------- entry point + + +def run( + ctx: Context, + args, + *, + memory_gib: float | None = None, + cpus: float | None = None, + port_checker: PortChecker | None = None, + platform_string: str | None = None, +) -> int: + if getattr(args, "compose_command", "render") != "render": + return report.error(ctx, exit_codes.USAGE, "usage: grdm-dev compose render [--profile ...]") + + errors = _manifest.validate(ctx) + if errors: + for line in errors: + sys.stderr.write(f" - {line}\n") + return report.error(ctx, exit_codes.MANIFEST_INVALID, f"{len(errors)} finding(s); run `grdm-dev manifest check`") + + dotenv = env_path(ctx) + if not dotenv.exists(): + return report.error(ctx, exit_codes.USAGE, f"{dotenv} not found; run `grdm-dev secrets init` first") + env = read_dotenv(dotenv) + missing = [k for k in REQUIRED_SECRETS if not env.get(k)] + if missing: + return report.error(ctx, exit_codes.USAGE, f"runtime/.env lacks {', '.join(missing)}; run `grdm-dev secrets init --force` or `secrets rotate`") + + try: + man = _manifest.load(ctx) + profile = resolve_profile(ctx, env) + auth = getattr(args, "auth", None) or _manifest.AUTH_FAKECAS + services = _manifest.services_for_profile(man, profile, auth, image_tags=built_image_tags(ctx)) + hardening = load_hardening(ctx.root) + except (_manifest.ManifestError, ValueError, OSError) as exc: + return report.error(ctx, exit_codes.MANIFEST_INVALID, str(exc)) + + rows, remapped, unresolved = assign_ports(published_ports(services, env), port_checker or default_port_checker) + if unresolved: + return report.error(ctx, exit_codes.PORT_IN_USE, f"no free port within +{PORT_SEARCH_RANGE} for: {', '.join(unresolved)}") + published = {r["service"]: int(r["host_port"]) for r in rows} + host_ports = host_port_map(env, rows) + + if memory_gib is None: + memory_gib = getattr(args, "memory_gib", None) or detect_memory_gib() or DEFAULT_MEMORY_GIB + if cpus is None: + cpus = getattr(args, "cpus", None) or float(os.cpu_count() or 0) or DEFAULT_CPUS + platform_string = platform_string or getattr(args, "platform", None) or detect_platform() + + compose = render_compose( + services, + runtime=ctx.runtime, + host_ports=host_ports, + published=published, + hardening=hardening, + memory_gib=float(memory_gib), + cpus=float(cpus), + platform_string=platform_string, + ) + compose_text = json.dumps(compose, indent=2, ensure_ascii=False) + "\n" + configs = config_files(host_ports) + for text in [compose_text, *configs.values()]: + if FORBIDDEN_ADDRESS in text: # defence in depth: ADR-02 forbids the alias anywhere + return report.error(ctx, exit_codes.MANIFEST_INVALID, f"generated output contains {FORBIDDEN_ADDRESS}") + + ctx.runtime.mkdir(parents=True, exist_ok=True) + written: list[str] = [] + if _write_if_changed(ctx.runtime / COMPOSE_FILE, compose_text): + written.append(COMPOSE_FILE) + for rel, text in configs.items(): + if _write_if_changed(ctx.runtime / CONFIG_DIR / rel, text): + written.append(f"{CONFIG_DIR}/{rel}") + for name in compose["volumes"]: + (ctx.runtime / VOLUMES_DIR / name).mkdir(parents=True, exist_ok=True) + env_updates = {PROFILE_ENV_KEY: profile} + env_updates.update({port_key(name): str(port) for name, port in published.items()}) + if update_dotenv(dotenv, env_updates): + written.append(".env (GRDM_PROFILE, GRDM_PORT_*)") + + data = { + "profile": profile, + "auth": auth, + "platform": platform_string, + "compose_file": str(ctx.runtime / COMPOSE_FILE), + "network": NETWORK, + "memory_gib": round(float(memory_gib), 1), + "cpus": float(cpus), + "services": [ + { + "service": s.name, + "image": s.image, + "user": compose["services"][s.name].get("user", "image default"), + "read_only": compose["services"][s.name]["read_only"], + "mem_limit": compose["services"][s.name]["mem_limit"], + "cpus": compose["services"][s.name]["cpus"], + "exceptions": compose["services"][s.name]["labels"]["org.gakunin-rdm.hardening-exception"], + } + for s in services + ], + "ports": rows, + "remapped_ports": remapped, + "volumes": list(compose["volumes"]), + "config_files": [f"{CONFIG_DIR}/{rel}" for rel in configs], + "written": written or ["(unchanged)"], + } + report.emit(ctx, "compose", data) + return exit_codes.OK diff --git a/installer/build/lib/grdm_dev/context.py b/installer/build/lib/grdm_dev/context.py new file mode 100644 index 0000000..74a7f1a --- /dev/null +++ b/installer/build/lib/grdm_dev/context.py @@ -0,0 +1,54 @@ +"""Shared execution context passed to every subcommand (SPEC-02 §7 behavior rules).""" +from __future__ import annotations + +import os +import sys +from dataclasses import dataclass, field +from pathlib import Path + + +def find_repo_root(start: Path | None = None) -> Path: + """The repository root is the first parent that contains manifest/upstreams.json.""" + p = (start or Path.cwd()).resolve() + for cand in (p, *p.parents): + if (cand / "manifest" / "upstreams.json").exists(): + return cand + env = os.environ.get("GRDM_DEV_ROOT") + if env and (Path(env) / "manifest" / "upstreams.json").exists(): + return Path(env).resolve() + return p + + +@dataclass +class Context: + root: Path + yes: bool = False + json_output: bool = False + profile: str | None = None + verbose: bool = False + lang: str = field(default_factory=lambda: "ja" if os.environ.get("LANG", "").startswith("ja") else "en") + stdin_is_tty: bool = field(default_factory=lambda: sys.stdin.isatty()) + env: dict[str, str] = field(default_factory=lambda: dict(os.environ)) + + @property + def runtime(self) -> Path: + return self.root / "runtime" + + @property + def reports_dir(self) -> Path: + return self.runtime / "reports" + + @property + def manifest_path(self) -> Path: + return self.root / "manifest" / "upstreams.json" + + def confirm(self, question: str, default: bool = False) -> bool: + """Ask a yes/no question. Non-interactive without --yes answers 'no' (SPEC-02 §7).""" + if self.yes: + return True + if not self.stdin_is_tty: + return False + ans = input(f"{question} [{'Y/n' if default else 'y/N'}] ").strip().lower() + if not ans: + return default + return ans in ("y", "yes") diff --git a/installer/build/lib/grdm_dev/docs.py b/installer/build/lib/grdm_dev/docs.py new file mode 100644 index 0000000..3133816 --- /dev/null +++ b/installer/build/lib/grdm_dev/docs.py @@ -0,0 +1,77 @@ +"""grdm-dev docs build | check — MkDocs build and the SPEC-06 §8 checks (SPEC-02 §3). + +`build` runs `mkdocs build --strict` with the MkDocs of the current virtual environment (installed by +`pip install -e "installer[docs]"`); a missing mkdocs is exit 2 with that hint. `check` runs the CI +validator tools/docs_check.py in-process and returns its exit code (0 pass, 1 failure, 2 usage). +""" +from __future__ import annotations + +import shutil +import subprocess +import sys +from pathlib import Path +from typing import Callable + +from . import exit_codes, report +from .context import Context +from .manifest_cmd import load_tool + +INSTALL_HINT = 'pip install -e "installer[docs]"' +Runner = Callable[[list[str]], tuple[int, str]] + + +def register(subparsers) -> None: + p = subparsers.add_parser("docs", help="build the MkDocs site or run the SPEC-06 documentation checks") + sub = p.add_subparsers(dest="docs_action", metavar="") + sub.add_parser("build", help="mkdocs build --strict into site/ (exit 2 with install hint if mkdocs is missing)") + c = sub.add_parser("check", help="SPEC-06 §8 checks via tools/docs_check.py") + c.add_argument("--all-warnings", action="store_true", help="print every glossary warning") + p.set_defaults(_module=sys.modules[__name__]) + + +def find_mkdocs() -> str | None: + """Prefer the mkdocs next to the running Python (the .venv), then PATH.""" + cand = Path(sys.executable).parent / ("mkdocs.exe" if sys.platform == "win32" else "mkdocs") + if cand.exists(): + return str(cand) + return shutil.which("mkdocs") + + +def _default_runner(cwd: Path) -> Runner: + def _run(argv: list[str]) -> tuple[int, str]: + try: + proc = subprocess.run(argv, cwd=str(cwd), capture_output=True, text=True) + except FileNotFoundError: + return 127, "" + sys.stdout.write(proc.stdout) + sys.stderr.write(proc.stderr) + return proc.returncode, proc.stdout + return _run + + +def run(ctx: Context, args, runner: Runner | None = None, mkdocs: str | None = None) -> int: + action = getattr(args, "docs_action", None) + if action == "build": + exe = mkdocs or find_mkdocs() + if not exe: + return report.error(ctx, exit_codes.USAGE, f"mkdocs not found; install with {INSTALL_HINT}") + runner = runner or _default_runner(ctx.root) + rc, _ = runner([exe, "build", "--strict", "-f", str(ctx.root / "mkdocs.yml")]) + if rc == 127: + return report.error(ctx, exit_codes.USAGE, f"mkdocs could not start; install with {INSTALL_HINT}") + if rc != 0: + sys.stderr.write(f"[grdm-dev] mkdocs build --strict failed (rc {rc})\n") + return 1 + sys.stdout.write(f"site built into {ctx.root / 'site'}\n") + return exit_codes.OK + if action == "check": + try: + dc = load_tool(ctx.root, "docs_check") + except FileNotFoundError as exc: + return report.error(ctx, exit_codes.USAGE, f"validator not found: {exc}") + argv = ["--root", str(ctx.root)] + if getattr(args, "all_warnings", False): + argv.append("--all-warnings") + return int(dc.main(argv)) + sys.stderr.write("usage: grdm-dev docs \n") + return exit_codes.USAGE diff --git a/installer/build/lib/grdm_dev/doctor.py b/installer/build/lib/grdm_dev/doctor.py new file mode 100644 index 0000000..3f7382e --- /dev/null +++ b/installer/build/lib/grdm_dev/doctor.py @@ -0,0 +1,39 @@ +"""grdm-dev doctor — host detection (SPEC-02 §3). Reference implementation of the module contract. + +Contract for every subcommand module: + register(subparsers): add the sub-parser and call set_defaults(_module=sys.modules[__name__]) + run(ctx, args) -> int: return an exit code from grdm_dev.exit_codes +Tests inject a fake `runner` (callable taking argv list, returning (returncode, stdout)) so Docker +is never required by unit tests (SPEC-02 §10). + +Exit codes: 10 when the host itself is unsupported (OS, CPU, memory, Python), 11 when Docker is +missing, not running, or lacks the Compose / buildx plugin. Warnings (best-effort host, low +memory, little disk) do not change the exit code unless `--strict` is given, which turns them +into exit 10 so CI can insist on an official host. +""" +from __future__ import annotations + +import sys + +from . import exit_codes, host, report +from .context import Context + + +def register(subparsers) -> None: + p = subparsers.add_parser("doctor", help="detect OS, CPU, memory, disk, Docker; exit 10/11 if unsupported") + p.add_argument("--strict", action="store_true", help="treat warnings (best-effort host, low memory) as exit 10") + p.set_defaults(_module=sys.modules[__name__]) + + +def run(ctx: Context, args, runner=None, probe=None) -> int: + info = host.detect(runner=runner, probe=probe, root=ctx.root) + data = host.as_report(info) + data["strict"] = bool(getattr(args, "strict", False)) + report.emit(ctx, "doctor", data) + if not info.supported: + return report.error(ctx, exit_codes.HOST_UNSUPPORTED, "; ".join(info.problems)) + if not info.docker_ok: + return report.error(ctx, exit_codes.DOCKER_MISSING, "; ".join(info.problems)) + if data["strict"] and info.warnings: + return report.error(ctx, exit_codes.HOST_UNSUPPORTED, "--strict: " + "; ".join(info.warnings)) + return exit_codes.OK diff --git a/installer/build/lib/grdm_dev/exit_codes.py b/installer/build/lib/grdm_dev/exit_codes.py new file mode 100644 index 0000000..a0b2f84 --- /dev/null +++ b/installer/build/lib/grdm_dev/exit_codes.py @@ -0,0 +1,38 @@ +"""Exit codes of grdm-dev (SPEC-02 §6). The canonical table is messages.tsv next to this file.""" +from __future__ import annotations + +import csv +from pathlib import Path + +OK = 0 +USAGE = 2 +HOST_UNSUPPORTED = 10 +DOCKER_MISSING = 11 +PORT_IN_USE = 12 +MANIFEST_INVALID = 20 +BUILD_FAILED = 30 +HEALTH_FAILED = 40 +SCAN_GATE_FAILED = 50 +SCANNER_UNAVAILABLE = 51 +SERVICES_UNHEALTHY = 52 +REDTEAM_PREFLIGHT_FAILED = 53 +ACCEPTANCE_FAILED = 60 + +_MESSAGES: dict[int, tuple[str, str]] | None = None + + +def messages() -> dict[int, tuple[str, str]]: + """Return {code: (english, japanese)} read from messages.tsv (cached).""" + global _MESSAGES + if _MESSAGES is None: + table: dict[int, tuple[str, str]] = {} + with (Path(__file__).parent / "messages.tsv").open(encoding="utf-8", newline="") as fh: + for row in csv.DictReader(fh, delimiter="\t"): + table[int(row["code"])] = (row["en"], row["ja"]) + _MESSAGES = table + return _MESSAGES + + +def describe(code: int, lang: str = "en") -> str: + en, ja = messages().get(code, ("unknown exit code", "不明な終了コード")) + return ja if lang == "ja" else en diff --git a/installer/build/lib/grdm_dev/health.py b/installer/build/lib/grdm_dev/health.py new file mode 100644 index 0000000..9f0cc9b --- /dev/null +++ b/installer/build/lib/grdm_dev/health.py @@ -0,0 +1,249 @@ +"""grdm-dev health [--network] — service health and loopback-only check (SPEC-02 §3, SPEC-03 §3.2, ADR-02). + +Reads runtime/docker-compose.yml (written as JSON by `compose render`) for the service names, +asks `docker compose ps --format json` for container state and health, and probes the browser- +facing HTTP endpoints on 127.0.0.1: for the services of the SPEC-02 §4 ports table that the +Compose file defines. Any missing, stopped, unhealthy or unreachable service is exit 40. + +--network lists the listening TCP sockets of the host (`lsof -nP -iTCP -sTCP:LISTEN` on macOS, +`ss -ltnp` on Linux) and fails with exit 40 when a Docker-owned socket (docker-proxy, com.docker) +is bound to 0.0.0.0, :: / * or any other non-loopback address. + +Injection points for tests: `runner(argv) -> (rc, stdout)`, `prober(url) -> (ok, detail)`, +`system` ("Darwin" / "Linux"). +""" +from __future__ import annotations + +import json +import platform as _platform +import subprocess +import sys +import time +import urllib.error +import urllib.request +from pathlib import Path + +from . import exit_codes, report +from .context import Context + +COMPOSE_PROJECT = "grdm-dev" +HTTP_SERVICES: tuple[str, ...] = ("web", "api", "admin", "wb", "mfr", "ember_osf_web", "fakecas") +DOCKER_PROCESS_MARKERS: tuple[str, ...] = ("docker-proxy", "docker-pr", "com.docker", "com.docke", "vpnkit") +HTTP_TIMEOUT = 3.0 + + +def default_runner(argv: list[str]) -> tuple[int, str]: + try: + proc = subprocess.run(argv, capture_output=True, text=True) + except OSError as exc: + return 127, str(exc) + return proc.returncode, proc.stdout + + +def default_prober(url: str) -> tuple[bool, str]: + """HTTP GET; any response below 500 counts as reachable (login redirects are fine).""" + try: + with urllib.request.urlopen(url, timeout=HTTP_TIMEOUT) as resp: # noqa: S310 - loopback only + return resp.status < 500, f"HTTP {resp.status}" + except urllib.error.HTTPError as exc: + return exc.code < 500, f"HTTP {exc.code}" + except (urllib.error.URLError, OSError, ValueError) as exc: + return False, str(getattr(exc, "reason", exc)) + + +def compose_path(ctx: Context) -> Path: + return ctx.runtime / "docker-compose.yml" + + +def compose_base(ctx: Context) -> list[str]: + return ["docker", "compose", "-f", str(compose_path(ctx)), "--project-name", COMPOSE_PROJECT] + + +def load_compose(path: Path) -> dict: + return json.loads(path.read_text(encoding="utf-8")) + + +def parse_ps(output: str) -> dict[str, dict]: + """`docker compose ps --format json` prints either a JSON array or one object per line.""" + text = output.strip() + if not text: + return {} + items: list[dict] = [] + try: + parsed = json.loads(text) + items = parsed if isinstance(parsed, list) else [parsed] + except ValueError: + for line in text.splitlines(): + line = line.strip() + if line.startswith("{"): + try: + items.append(json.loads(line)) + except ValueError: + continue + by_service: dict[str, dict] = {} + for it in items: + name = it.get("Service") or it.get("service") or it.get("Name") or "" + if name: + by_service[name] = it + return by_service + + +def host_port(service: str, compose: dict, env: dict[str, str]) -> int | None: + """Host port from the Compose `ports` entry (127.0.0.1:host:container) or GRDM_PORT_.""" + svc = compose.get("services", {}).get(service) or {} + for entry in svc.get("ports", []) or []: + if isinstance(entry, dict): + published = entry.get("published") + if published: + try: + return int(str(published)) + except ValueError: + pass + continue + parts = str(entry).split(":") + if len(parts) >= 2: + try: + return int(parts[-2]) + except ValueError: + continue + value = env.get(f"GRDM_PORT_{service.upper()}") + if value and value.isdigit(): + return int(value) + return None + + +def check_services(ctx: Context, runner, prober) -> tuple[list[dict], bool]: + """One row per service of the Compose file; returns (rows, all_healthy).""" + from .secrets import env_path, read_env + + compose = load_compose(compose_path(ctx)) + env = read_env(env_path(ctx)) + services = list((compose.get("services") or {}).keys()) + rc, out = runner(compose_base(ctx) + ["ps", "--all", "--format", "json"]) + ps = parse_ps(out) if rc == 0 else {} + rows: list[dict] = [] + all_ok = rc == 0 + for name in services: + info = ps.get(name, {}) + state = str(info.get("State") or info.get("state") or ("missing" if not info else "unknown")).lower() + health = str(info.get("Health") or info.get("health") or "").lower() + ok = state == "running" and health in ("", "healthy") + url = "" + http = "" + if name in HTTP_SERVICES: + port = host_port(name, compose, env) + if port: + url = f"http://127.0.0.1:{port}/" + reachable, http = prober(url) + ok = ok and reachable + rows.append({"service": name, "state": state, "health": health or "n/a", "url": url, "http": http, "ok": ok}) + all_ok = all_ok and ok + return rows, all_ok + + +def _addr_port(addr: str) -> tuple[str, str]: + addr = addr.strip() + if addr.startswith("["): # [::1]:5000 + host, _, port = addr[1:].partition("]:") + return host, port + host, _, port = addr.rpartition(":") + return host, port + + +def is_loopback(host: str) -> bool: + host = host.strip("[]") + return host.startswith("127.") or host in ("::1", "localhost", "::ffff:127.0.0.1") + + +def is_docker_process(name: str) -> bool: + low = name.lower() + return any(marker in low for marker in DOCKER_PROCESS_MARKERS) + + +def parse_lsof(output: str) -> list[dict]: + rows = [] + for line in output.splitlines()[1:]: + parts = line.split() + if len(parts) < 9 or "LISTEN" not in line: + continue + host, port = _addr_port(parts[8]) + rows.append({"process": parts[0], "address": host or "*", "port": port, "loopback": is_loopback(host)}) + return rows + + +def parse_ss(output: str) -> list[dict]: + rows = [] + for line in output.splitlines(): + parts = line.split() + if len(parts) < 5 or parts[0] != "LISTEN": + continue + host, port = _addr_port(parts[3]) + proc = "" + for p in parts[5:]: + if p.startswith("users:(("): + proc = p[len("users:((") :].split('"')[1] if '"' in p else p + rows.append({"process": proc, "address": host or "*", "port": port, "loopback": is_loopback(host)}) + return rows + + +def listening_sockets(runner, system: str | None = None) -> tuple[list[dict], str]: + system = system or _platform.system() + if system == "Darwin": + rc, out = runner(["lsof", "-nP", "-iTCP", "-sTCP:LISTEN"]) + # lsof exits 1 when nothing matched; that is still a valid (empty) answer + return (parse_lsof(out) if rc in (0, 1) else []), ("" if rc in (0, 1) else f"lsof exited {rc}") + rc, out = runner(["ss", "-ltnp"]) + return (parse_ss(out) if rc == 0 else []), ("" if rc == 0 else f"ss exited {rc}") + + +def check_network(runner, system: str | None = None) -> tuple[list[dict], list[dict], str]: + """Return (docker sockets, offending non-loopback docker sockets, error).""" + sockets, err = listening_sockets(runner, system) + docker = [s for s in sockets if is_docker_process(s["process"])] + bad = [s for s in docker if not s["loopback"]] + return docker, bad, err + + +def wait_until_healthy(ctx: Context, timeout: float, runner=None, prober=None, sleep=time.sleep, interval: float = 5.0) -> tuple[list[dict], bool]: + """Poll check_services until every service is healthy or the timeout passes.""" + runner = runner or default_runner + prober = prober or default_prober + deadline = time.monotonic() + timeout + rows, ok = check_services(ctx, runner, prober) + while not ok and time.monotonic() < deadline: + sleep(interval) + rows, ok = check_services(ctx, runner, prober) + return rows, ok + + +def register(subparsers) -> None: + p = subparsers.add_parser("health", help="check every service; --network also fails on non-loopback listeners (exit 40)") + p.add_argument("--network", action="store_true", help="list listening sockets and require 127.0.0.1 only") + p.set_defaults(_module=sys.modules[__name__]) + + +def run(ctx: Context, args, runner=None, prober=None, system: str | None = None) -> int: + runner = runner or default_runner + prober = prober or default_prober + path = compose_path(ctx) + if not path.exists(): + return report.error(ctx, exit_codes.USAGE, f"{path} not found; run `grdm-dev compose render` first") + try: + rows, ok = check_services(ctx, runner, prober) + except ValueError as exc: + return report.error(ctx, exit_codes.HEALTH_FAILED, f"cannot parse {path}: {exc}") + data: dict = {"services": rows, "healthy": ok} + problems: list[str] = [f"{r['service']} ({r['state']}, {r['health']}{', ' + r['http'] if r['http'] else ''})" for r in rows if not r["ok"]] + if getattr(args, "network", False): + docker, bad, err = check_network(runner, system) + data["sockets"] = docker + data["loopback_only"] = not bad and not err + if err: + problems.append(err) + for s in bad: + problems.append(f"{s['process']} listens on {s['address']}:{s['port']} (not loopback)") + ok = ok and not bad and not err + report.emit(ctx, "health", data) + if not ok: + return report.error(ctx, exit_codes.HEALTH_FAILED, "; ".join(problems)) + return exit_codes.OK diff --git a/installer/build/lib/grdm_dev/host.py b/installer/build/lib/grdm_dev/host.py new file mode 100644 index 0000000..8c66917 --- /dev/null +++ b/installer/build/lib/grdm_dev/host.py @@ -0,0 +1,301 @@ +"""Host detection: OS, CPU, memory, disk, Python, Docker (SPEC-02 §3 `doctor`, §8 supported hosts). + +Everything that touches the machine goes through two seams so unit tests never need Docker: + +* `Probe` — plain facts read with `platform`, `os`, `shutil` (OS name, kernel, /etc/os-release, + /proc/version, memory, free disk). Tests build a `Probe` by hand. +* `runner(argv) -> (returncode, stdout)` — runs `docker ...`. Tests pass a fake. + +`detect()` turns those facts into a `HostInfo`; `as_report()` flattens it for TOON/JSON. +""" +from __future__ import annotations + +import os +import platform +import re +import shutil +import subprocess +import sys +from dataclasses import asdict, dataclass, field +from pathlib import Path +from typing import Callable, Optional + +Runner = Callable[[list[str]], tuple[int, str]] + +GIB = 1024 ** 3 +MIN_MEMORY_BYTES = 8 * GIB +RECOMMENDED_MEMORY_BYTES = 16 * GIB +MIN_DISK_FREE_BYTES = 40 * GIB +MIN_PYTHON = (3, 11) +MIN_DOCKER_MAJOR = 27 +MIN_COMPOSE_MAJOR = 2 +SUBPROCESS_TIMEOUT = 15 + +# Official hosts (SPEC-02 §8). Anything else is best-effort: a warning, not a problem. +OFFICIAL = {("macos", "arm64"), ("ubuntu", "amd64"), ("ubuntu", "arm64"), ("wsl2", "amd64")} + + +def default_runner(argv: list[str]) -> tuple[int, str]: + """Run a command, merging stderr into stdout; a missing or hanging tool is a non-zero result.""" + try: + cp = subprocess.run( + argv, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, timeout=SUBPROCESS_TIMEOUT + ) + return cp.returncode, cp.stdout + except FileNotFoundError: + return 127, f"{argv[0]}: command not found" + except subprocess.TimeoutExpired: + return 124, f"{' '.join(argv)}: timed out after {SUBPROCESS_TIMEOUT}s" + except OSError as exc: + return 126, f"{argv[0]}: {exc}" + + +@dataclass +class Probe: + """Raw facts about the machine. `Probe.from_system()` reads them; tests set them directly.""" + + system: str = "" # platform.system(): Darwin | Linux | Windows | ... + release: str = "" # platform.release(): kernel version + machine: str = "" # platform.machine(): arm64 | x86_64 | aarch64 | ... + mac_ver: str = "" # platform.mac_ver()[0] on macOS, else "" + os_release: str = "" # contents of /etc/os-release (Linux), else "" + proc_version: str = "" # contents of /proc/version (Linux), else "" + env: dict[str, str] = field(default_factory=dict) + python_version: tuple[int, int, int] = (0, 0, 0) + memory_bytes: Optional[int] = None + disk_free_bytes: Optional[int] = None + docker_path: Optional[str] = None # shutil.which("docker") + + @classmethod + def from_system(cls, root: Path | None = None, runner: Runner | None = None) -> "Probe": + root = root or Path.cwd() + system = platform.system() + p = cls( + system=system, + release=platform.release(), + machine=platform.machine(), + mac_ver=platform.mac_ver()[0] if system == "Darwin" else "", + os_release=_read_text("/etc/os-release") or _read_text("/usr/lib/os-release") if system == "Linux" else "", + proc_version=_read_text("/proc/version") if system == "Linux" else "", + env=dict(os.environ), + python_version=tuple(sys.version_info[:3]), # type: ignore[arg-type] + memory_bytes=_memory_bytes(runner or default_runner, system), + disk_free_bytes=_disk_free_bytes(root), + docker_path=shutil.which("docker"), + ) + return p + + +@dataclass +class HostInfo: + os_name: str = "unsupported" # macos | ubuntu | wsl2 | linux-other | unsupported + os_version: str = "" + arch: str = "other" # arm64 | amd64 | other + memory_bytes: Optional[int] = None + disk_free_bytes: Optional[int] = None + python_version: str = "" + docker_version: str = "" + compose_version: str = "" + buildx_present: bool = False + docker_running: bool = False + supported: bool = False + docker_ok: bool = False + problems: list[str] = field(default_factory=list) + warnings: list[str] = field(default_factory=list) + platform_string: str = "" # linux/arm64 | linux/amd64 (empty when arch is other) + + +# --- raw readers ------------------------------------------------------------------------------- + +def _read_text(path: str) -> str: + try: + return Path(path).read_text(encoding="utf-8", errors="replace") + except OSError: + return "" + + +def _memory_bytes(runner: Runner, system: str) -> Optional[int]: + try: + pages = os.sysconf("SC_PHYS_PAGES") + page = os.sysconf("SC_PAGE_SIZE") + if pages > 0 and page > 0: + return int(pages) * int(page) + except (ValueError, OSError, AttributeError): + pass + if system == "Darwin": + rc, out = runner(["sysctl", "-n", "hw.memsize"]) + if rc == 0 and out.strip().isdigit(): + return int(out.strip()) + return None + + +def _disk_free_bytes(root: Path) -> Optional[int]: + try: + return shutil.disk_usage(str(root)).free + except OSError: + return None + + +# --- classification ---------------------------------------------------------------------------- + +def parse_os_release(text: str) -> dict[str, str]: + out: dict[str, str] = {} + for line in text.splitlines(): + line = line.strip() + if not line or line.startswith("#") or "=" not in line: + continue + k, _, v = line.partition("=") + out[k.strip()] = v.strip().strip('"').strip("'") + return out + + +def classify_arch(machine: str) -> str: + m = (machine or "").lower() + if m in ("arm64", "aarch64"): + return "arm64" + if m in ("x86_64", "amd64"): + return "amd64" + return "other" + + +def classify_os(probe: Probe) -> tuple[str, str]: + """Return (os_name, os_version).""" + system = (probe.system or "").strip() + if system == "Darwin": + return "macos", probe.mac_ver or probe.release + if system == "Linux": + rel = parse_os_release(probe.os_release) + version = rel.get("VERSION_ID", "") or rel.get("PRETTY_NAME", "") + is_wsl = "microsoft" in (probe.proc_version or "").lower() or "microsoft" in (probe.release or "").lower() \ + or bool(probe.env.get("WSL_DISTRO_NAME")) + if is_wsl: + return "wsl2", version + if rel.get("ID", "").lower() == "ubuntu": + return "ubuntu", version + return "linux-other", version + return "unsupported", f"{system} {probe.release}".strip() + + +def parse_version(text: str) -> tuple[int, ...]: + """First dotted number in `text` as a tuple of ints; () when none.""" + m = re.search(r"(\d+)(?:\.(\d+))?(?:\.(\d+))?", text or "") + if not m: + return () + return tuple(int(g) for g in m.groups() if g is not None) + + +def _fmt_gib(n: Optional[int]) -> str: + return "unknown" if n is None else f"{n / GIB:.1f} GiB" + + +# --- docker ------------------------------------------------------------------------------------ + +def check_docker(runner: Runner, info: HostInfo) -> None: + """Fill docker_* fields and append problems; docker_ok is True only when every check passes.""" + rc, out = runner(["docker", "version", "--format", "{{.Server.Version}}"]) + out = (out or "").strip() + if rc == 127 or (rc != 0 and "command not found" in out): + info.problems.append("docker command not found / docker コマンドが見つかりません") + return + if rc != 0 or not parse_version(out): + detail = out.splitlines()[0] if out else f"exit {rc}" + info.problems.append(f"docker daemon not running or unreachable ({detail}) / Docker デーモンが動いていないか到達できません") + return + info.docker_running = True + info.docker_version = out.splitlines()[0] + ver = parse_version(info.docker_version) + if ver and ver[0] < MIN_DOCKER_MAJOR: + info.problems.append( + f"docker {info.docker_version} is older than {MIN_DOCKER_MAJOR} / Docker {info.docker_version} は {MIN_DOCKER_MAJOR} より古いです" + ) + + rc, out = runner(["docker", "compose", "version"]) + cver = parse_version(out or "") + if rc != 0 or not cver: + info.problems.append("docker compose plugin missing / Docker Compose プラグインがありません") + else: + info.compose_version = ".".join(str(x) for x in cver) + if cver[0] < MIN_COMPOSE_MAJOR: + info.problems.append( + f"docker compose v{info.compose_version} is older than v{MIN_COMPOSE_MAJOR} / Docker Compose v{info.compose_version} は v{MIN_COMPOSE_MAJOR} より古いです" + ) + + rc, out = runner(["docker", "buildx", "version"]) + if rc == 0 and parse_version(out or ""): + info.buildx_present = True + else: + info.problems.append("docker buildx plugin missing / Docker buildx プラグインがありません") + + +# --- entry points ------------------------------------------------------------------------------ + +def detect(runner: Runner | None = None, probe: Probe | None = None, root: Path | None = None) -> HostInfo: + """Detect the host. `runner` and `probe` are injectable so tests never touch Docker or the OS.""" + runner = runner or default_runner + probe = probe or Probe.from_system(root=root, runner=runner) + info = HostInfo() + + info.os_name, info.os_version = classify_os(probe) + info.arch = classify_arch(probe.machine) + info.memory_bytes = probe.memory_bytes + info.disk_free_bytes = probe.disk_free_bytes + info.python_version = ".".join(str(x) for x in probe.python_version) if probe.python_version else "" + if info.arch in ("arm64", "amd64"): + info.platform_string = f"linux/{info.arch}" + + # Host problems (-> exit 10) + if info.os_name == "unsupported": + info.problems.append( + f"operating system not supported: {info.os_version} / 対応していない OS です: {info.os_version}" + ) + if info.arch == "other": + info.problems.append( + f"CPU architecture not supported: {probe.machine} / 対応していない CPU です: {probe.machine}" + ) + if probe.python_version and tuple(probe.python_version[:2]) < MIN_PYTHON: + info.problems.append( + f"Python {info.python_version} is older than 3.11 / Python {info.python_version} は 3.11 より古いです" + ) + if info.memory_bytes is not None and info.memory_bytes < MIN_MEMORY_BYTES: + info.problems.append( + f"memory {_fmt_gib(info.memory_bytes)} is below the 8 GiB minimum / メモリ {_fmt_gib(info.memory_bytes)} は最低 8 GiB 未満です" + ) + + # Host warnings (best-effort hosts, SPEC-02 §8) + if info.os_name in ("macos", "ubuntu", "wsl2", "linux-other") and info.arch != "other" \ + and (info.os_name, info.arch) not in OFFICIAL: + info.warnings.append( + f"{info.os_name}/{info.arch} is best-effort, not an official host / {info.os_name}/{info.arch} は公式対応外(可能な限りの対応)です" + ) + if info.os_name == "macos" and parse_version(info.os_version)[:1] and parse_version(info.os_version)[0] < 14: + info.warnings.append(f"macOS {info.os_version} is older than 14 / macOS {info.os_version} は 14 より古いです") + if info.os_name in ("ubuntu", "wsl2") and info.os_version and parse_version(info.os_version)[:1] \ + and parse_version(info.os_version)[0] < 24: + info.warnings.append(f"Ubuntu {info.os_version} is older than 24.04 / Ubuntu {info.os_version} は 24.04 より古いです") + if info.memory_bytes is None: + info.warnings.append("memory size could not be read / メモリ量を読めませんでした") + elif info.memory_bytes < RECOMMENDED_MEMORY_BYTES: + info.warnings.append( + f"memory {_fmt_gib(info.memory_bytes)} is below the recommended 16 GiB / メモリ {_fmt_gib(info.memory_bytes)} は推奨 16 GiB 未満です" + ) + if info.disk_free_bytes is not None and info.disk_free_bytes < MIN_DISK_FREE_BYTES: + info.warnings.append( + f"free disk {_fmt_gib(info.disk_free_bytes)} is below the recommended 40 GiB / 空き容量 {_fmt_gib(info.disk_free_bytes)} は推奨 40 GiB 未満です" + ) + + info.supported = not info.problems + + # Docker (-> exit 11); counted separately so doctor can tell 10 from 11. + before = len(info.problems) + check_docker(runner, info) + info.docker_ok = len(info.problems) == before + return info + + +def as_report(info: HostInfo) -> dict: + """Flat, TOON-friendly dict (SPEC-06 §4): scalars plus two string lists.""" + d = asdict(info) + d["memory_gib"] = None if info.memory_bytes is None else round(info.memory_bytes / GIB, 1) + d["disk_free_gib"] = None if info.disk_free_bytes is None else round(info.disk_free_bytes / GIB, 1) + d["official"] = (info.os_name, info.arch) in OFFICIAL + return d diff --git a/installer/build/lib/grdm_dev/install.py b/installer/build/lib/grdm_dev/install.py new file mode 100644 index 0000000..e46811d --- /dev/null +++ b/installer/build/lib/grdm_dev/install.py @@ -0,0 +1,96 @@ +"""grdm-dev install — the SPEC-02 §2.1 sequence, stopping at the first non-zero step. + + doctor → plan → secrets init (skipped when runtime/.env exists) → compose render → build + → up → health --network → scan (if the module exists) → report + +Each step is run through the normal CLI parser so that every sibling module keeps ownership of its +own flags: the step's argv is parsed with cli.build_parser() and `args._module.run(ctx, args)` is +called. Modules are imported lazily by the parser, so a step whose module is not yet implemented +is reported as "not available" — fatal for required steps, a notice for optional ones (scan, report). + +Tests inject `run_step(ctx, argv) -> int` and never touch Docker. +""" +from __future__ import annotations + +import sys +from collections.abc import Callable + +from . import exit_codes, report +from .context import Context + +OPTIONAL_STEPS: frozenset[str] = frozenset({"scan", "report"}) + + +def default_run_step(ctx: Context, argv: list[str]) -> int: + """Parse argv with the real parser and run the matching module. Returns -1 when the subcommand is missing.""" + from . import cli + + parser = cli.build_parser() + try: + args = parser.parse_args(argv) + except SystemExit: + return -1 + mod = getattr(args, "_module", None) + if mod is None: + return -1 + return int(mod.run(ctx, args)) + + +def plan_steps(ctx: Context, *, platform: str | None, no_open: bool) -> list[tuple[str, list[str]]]: + from .secrets import env_path + + steps: list[tuple[str, list[str]]] = [("doctor", ["doctor"]), ("plan", ["plan"])] + if not env_path(ctx).exists(): + steps.append(("secrets init", ["secrets", "init"])) + steps.append(("compose render", ["compose", "render"])) + build = ["build"] + (["--platform", platform] if platform else []) + steps.append(("build", build)) + steps.append(("up", ["up"] + (["--no-open"] if no_open else []))) + steps.append(("health --network", ["health", "--network"])) + steps.append(("scan", ["scan"])) + steps.append(("report", ["report"])) + return steps + + +def register(subparsers) -> None: + p = subparsers.add_parser("install", help="doctor → plan → secrets → compose → build → up → health → scan → report") + p.add_argument("--platform", help="comma-separated platforms for build (default: host platform)") + p.add_argument("--no-open", dest="no_open", action="store_true", help="do not open the browser after up") + p.set_defaults(_module=sys.modules[__name__]) + + +def run(ctx: Context, args, run_step: Callable[[Context, list[str]], int] | None = None) -> int: + from .lifecycle import web_url + from .secrets import env_path + + run_step = run_step or default_run_step + steps = plan_steps(ctx, platform=getattr(args, "platform", None), no_open=bool(getattr(args, "no_open", False))) + skipped_secrets = env_path(ctx).exists() + rows: list[dict] = [] + if skipped_secrets: + rows.append({"step": "secrets init", "code": 0, "status": "skipped (runtime/.env exists)"}) + final = exit_codes.OK + for name, argv in steps: + sys.stderr.write(f"[grdm-dev] install: {name}\n") + code = run_step(ctx, argv) + if code == -1: + key = argv[0] + if key in OPTIONAL_STEPS: + sys.stderr.write(f"[grdm-dev] install: `{name}` is not yet available; continuing\n") + rows.append({"step": name, "code": 0, "status": "not available"}) + continue + rows.append({"step": name, "code": exit_codes.USAGE, "status": "not available"}) + final = exit_codes.USAGE + report.emit(ctx, "install", {"steps": rows, "result": final, "url": None}) + return report.error(ctx, exit_codes.USAGE, f"required step `{name}` is not available in this build of grdm-dev") + rows.append({"step": name, "code": code, "status": "ok" if code == 0 else "failed"}) + if code != 0: + final = code + break + url = web_url(ctx) if final == exit_codes.OK else None + report.emit(ctx, "install", {"steps": rows, "result": final, "url": url}) + if final != exit_codes.OK: + failed = next((r["step"] for r in rows if r["status"] == "failed"), "?") + return report.error(ctx, final, f"stopped at `{failed}`") + sys.stdout.write(f"\nGakuNin RDM developer environment is ready: {url}\n") + return exit_codes.OK diff --git a/installer/build/lib/grdm_dev/lifecycle.py b/installer/build/lib/grdm_dev/lifecycle.py new file mode 100644 index 0000000..d2d6454 --- /dev/null +++ b/installer/build/lib/grdm_dev/lifecycle.py @@ -0,0 +1,142 @@ +"""grdm-dev up / down / reset — container lifecycle for the rendered profile (SPEC-02 §3, §7). + +up `docker compose up -d`, then wait for health (exit 40 on timeout), then open the browser at + http://127.0.0.1: unless --no-open; the browser is only opened when stdin is a + terminal. Idempotent: healthy services are left alone by Compose. +down `docker compose down` — containers stop, volumes stay. +reset down, then delete runtime/volumes/ after ctx.confirm(). Non-interactive without --yes → exit 2. + +Helpers for other modules: running_services(ctx) and restart(ctx, services) (used by secrets rotate). +Runner: `runner(argv) -> (rc, stdout)`; tests inject a fake and never need Docker. +""" +from __future__ import annotations + +import shutil +import sys +import webbrowser + +from . import exit_codes, health, report +from .context import Context + +DEFAULT_TIMEOUT = 300.0 + + +def default_runner(argv: list[str]) -> tuple[int, str]: + return health.default_runner(argv) + + +def streaming_runner(argv: list[str]) -> tuple[int, str]: + from .build import default_runner as _stream + + return _stream(argv) + + +def web_url(ctx: Context) -> str: + from .secrets import DEFAULT_PORTS, env_path, read_env + + port = read_env(env_path(ctx)).get("GRDM_PORT_WEB") or str(DEFAULT_PORTS["web"]) + return f"http://127.0.0.1:{port}/" + + +def running_services(ctx: Context, runner=None) -> list[str]: + runner = runner or default_runner + if not health.compose_path(ctx).exists(): + return [] + rc, out = runner(health.compose_base(ctx) + ["ps", "--format", "json"]) + if rc != 0: + raise RuntimeError(f"docker compose ps exited {rc}") + ps = health.parse_ps(out) + return [name for name, info in ps.items() if str(info.get("State") or info.get("state") or "").lower() == "running"] + + +def restart(ctx: Context, services: list[str] | None = None, runner=None) -> int: + runner = runner or default_runner + rc, _ = runner(health.compose_base(ctx) + ["restart", *(services or [])]) + return rc + + +def register(subparsers) -> None: + up = subparsers.add_parser("up", help="start the profile and wait for health; exit 40 on failure") + up.add_argument("--no-open", dest="no_open", action="store_true", help="do not open the browser") + up.add_argument("--timeout", type=float, default=DEFAULT_TIMEOUT, help=f"seconds to wait for health (default {int(DEFAULT_TIMEOUT)})") + up.set_defaults(_module=sys.modules[__name__], lifecycle_action="up") + down = subparsers.add_parser("down", help="stop containers, keep volumes") + down.set_defaults(_module=sys.modules[__name__], lifecycle_action="down") + reset = subparsers.add_parser("reset", help="stop containers and delete runtime/volumes/ (asks first; --yes skips)") + reset.set_defaults(_module=sys.modules[__name__], lifecycle_action="reset") + + +def run(ctx: Context, args, runner=None, prober=None, opener=None, sleep=None, rmtree=None) -> int: + action = getattr(args, "lifecycle_action", None) + if action == "up": + return run_up(ctx, no_open=bool(getattr(args, "no_open", False)), timeout=float(getattr(args, "timeout", DEFAULT_TIMEOUT)), + runner=runner, prober=prober, opener=opener, sleep=sleep) + if action == "down": + return run_down(ctx, runner=runner) + if action == "reset": + return run_reset(ctx, runner=runner, rmtree=rmtree) + return report.error(ctx, exit_codes.USAGE, "choose up, down or reset") + + +def _require_compose(ctx: Context) -> int | None: + path = health.compose_path(ctx) + if not path.exists(): + return report.error(ctx, exit_codes.USAGE, f"{path} not found; run `grdm-dev compose render` first") + return None + + +def run_up(ctx: Context, no_open: bool = False, timeout: float = DEFAULT_TIMEOUT, runner=None, prober=None, opener=None, sleep=None) -> int: + missing = _require_compose(ctx) + if missing is not None: + return missing + runner = runner or streaming_runner + rc, out = runner(health.compose_base(ctx) + ["up", "-d", "--remove-orphans"]) + if rc != 0: + return report.error(ctx, exit_codes.HEALTH_FAILED, f"docker compose up exited {rc}") + kwargs = {"runner": runner, "prober": prober} + if sleep is not None: + kwargs["sleep"] = sleep + rows, ok = health.wait_until_healthy(ctx, timeout, **kwargs) + url = web_url(ctx) + report.emit(ctx, "up", {"url": url, "healthy": ok, "timeout_s": timeout, "services": rows}) + if not ok: + bad = ", ".join(r["service"] for r in rows if not r["ok"]) + return report.error(ctx, exit_codes.HEALTH_FAILED, f"not healthy after {int(timeout)}s: {bad}") + if not no_open and ctx.stdin_is_tty: + (opener or webbrowser.open)(url) + sys.stderr.write(f"[grdm-dev] ready: {url}\n") + return exit_codes.OK + + +def run_down(ctx: Context, runner=None, volumes: bool = False) -> int: + missing = _require_compose(ctx) + if missing is not None: + return missing + runner = runner or streaming_runner + argv = health.compose_base(ctx) + ["down", "--remove-orphans"] + if volumes: + argv.append("--volumes") + rc, _ = runner(argv) + report.emit(ctx, "down", {"stopped": rc == 0, "volumes_removed": volumes and rc == 0}) + if rc != 0: + return report.error(ctx, exit_codes.HEALTH_FAILED, f"docker compose down exited {rc}") + return exit_codes.OK + + +def run_reset(ctx: Context, runner=None, rmtree=None) -> int: + volumes_dir = ctx.runtime / "volumes" + if not ctx.confirm(f"Stop all services and delete {volumes_dir} (all data)?", default=False): + if not ctx.yes and not ctx.stdin_is_tty: + return report.error(ctx, exit_codes.USAGE, "reset needs a confirmation; add --yes when no terminal is attached") + sys.stderr.write("[grdm-dev] reset cancelled\n") + return exit_codes.OK + if health.compose_path(ctx).exists(): + rc = run_down(ctx, runner=runner, volumes=True) + if rc != exit_codes.OK: + return rc + removed = False + if volumes_dir.exists(): + (rmtree or shutil.rmtree)(volumes_dir) + removed = True + report.emit(ctx, "reset", {"volumes_dir": str(volumes_dir), "removed": removed}) + return exit_codes.OK diff --git a/installer/build/lib/grdm_dev/manifest.py b/installer/build/lib/grdm_dev/manifest.py new file mode 100644 index 0000000..78c0a9e --- /dev/null +++ b/installer/build/lib/grdm_dev/manifest.py @@ -0,0 +1,367 @@ +"""grdm-dev manifest — load and validate manifest/upstreams.json, derive services (SPEC-01, SPEC-02 §4). + +Three jobs: + +* `load(ctx_or_path)` parses the manifest into dataclasses (`Manifest`, `Component`, `Upstream`, `PR`). + Components stay dict-compatible (`comp["id"]`, `comp.get(...)`) so modules written against the + raw JSON keep working. +* `validate(ctx_or_path)` runs the SPEC-01 §5 checks (MC-01..MC-11, MC-13) by delegating to + tools/manifest_check.py, which stays the single implementation. An empty list means valid; + callers map a non-empty list to exit 20 (`exit_codes.MANIFEST_INVALID`). +* `services_for_profile(manifest, profile, auth)` turns components into `Service` objects for one + profile, following the SPEC-02 §4 table. Service templates under `templates/.json` + (SPEC-02 §3 `compose render`) supply the service-level profile where it differs from the + component (`admin` and `worker` belong to `osf.io`, profile minimum, but are core services). + +Images: a component with an integration repository is built locally as +`grdm-dev/:` (same rule as build.py); an infra component runs its +pinned upstream image, `base_image[@base_image_digest]`. The build SHA is the integration +commit when the manifest carries one (`integration_sha`, optional, written by the weekly +integration PR), else the first merged upstream in SPEC-01 rule 3 order (public, then private). +The clone URL is composed at run time from the bare repository name; it is never stored here. +""" +from __future__ import annotations + +import importlib.util +import json +import sys +from dataclasses import dataclass, field +from pathlib import Path +from typing import Any, Iterable + +from . import exit_codes + +PROFILES: tuple[str, ...] = ("minimum", "core", "full") +PROFILE_RANK: dict[str, int] = {name: i for i, name in enumerate(PROFILES)} +DEFAULT_PROFILE = "core" +LOCAL_IMAGE_PREFIX = "grdm-dev" +TEMPLATE_DIR = Path(__file__).parent / "templates" + +# SPEC-02 §4: the `shibboleth` auth variant swaps fakecas for shibboleth_sp + test_idp in `full`. +AUTH_FAKECAS = "fakecas" +AUTH_SHIBBOLETH = "shibboleth" +SHIBBOLETH_SERVICES: frozenset[str] = frozenset({"shibboleth_sp", "test_idp"}) + + +class ManifestError(Exception): + """The manifest is invalid (exit 20). `errors` holds one line per finding.""" + + def __init__(self, errors: list[str]): + super().__init__("; ".join(errors) if errors else "manifest invalid") + self.errors = errors + self.exit_code = exit_codes.MANIFEST_INVALID + + +@dataclass(frozen=True) +class Upstream: + repo: str + branch: str + kind: str + tracking_branch: str + status: str + sha: str + fetched_at: str + + +@dataclass(frozen=True) +class PR: + repo: str + number: int + title: str + reason: str + status: str + + +@dataclass +class Component: + id: str + role: str + services: list[str] + integration_repo: str | None + integration_branch: str | None + upstreams: list[Upstream] + adopted_prs: list[PR] + candidate_prs: list[PR] + base_image: str + base_image_digest: str | None + target_image: dict[str, str | None] + profile: str + platforms: list[str] + note: str | None + raw: dict[str, Any] = field(default_factory=dict, repr=False, compare=False) + + # dict compatibility for modules written against the raw JSON + def __getitem__(self, key: str) -> Any: + return self.raw[key] + + def get(self, key: str, default: Any = None) -> Any: + return self.raw.get(key, default) + + @property + def is_built(self) -> bool: + return bool(self.integration_repo) + + @property + def build_sha(self) -> str | None: + """Commit the local image is built from (see module docstring).""" + explicit = self.raw.get("integration_sha") + if isinstance(explicit, str) and explicit: + return explicit + for kind in ("public", "private"): + for up in self.upstreams: + if up.kind == kind and up.status == "merged": + return up.sha + return None + + @property + def sha12(self) -> str | None: + sha = self.build_sha + return sha[:12] if sha else None + + @property + def pinned_image(self) -> str: + """Infra: the upstream image, with its digest once pinned (SPEC-03 §3.4).""" + if self.base_image_digest: + return f"{self.base_image}@{self.base_image_digest}" + return self.base_image + + def local_image(self, sha12: str | None = None) -> str: + return f"{LOCAL_IMAGE_PREFIX}/{self.id.lower()}:{sha12 or self.sha12 or 'develop'}" + + def image_reference(self, sha12: str | None = None) -> str: + return self.local_image(sha12) if self.is_built else self.pinned_image + + +@dataclass +class Manifest: + schema_version: int + generated_at: str + note: str | None + components: list[Component] + path: Path | None = None + + def component(self, component_id: str) -> Component: + for c in self.components: + if c.id == component_id: + return c + raise KeyError(component_id) + + def component_for_service(self, service: str) -> Component: + for c in self.components: + if service in c.services: + return c + raise KeyError(service) + + @property + def service_names(self) -> list[str]: + return [s for c in self.components for s in c.services] + + +@dataclass(frozen=True) +class BuildInfo: + repo: str # integration repository name, e.g. RDM-osf.io-dev2027 (name only, SPEC-01 rule 5) + branch: str # always develop + sha: str | None # 40-hex commit the image is built from, when the manifest knows it + sha12: str | None + + +@dataclass +class Service: + name: str + component: str + role: str + image: str + profile: str + build: BuildInfo | None + template: dict[str, Any] = field(default_factory=dict, repr=False) + + @property + def is_built(self) -> bool: + return self.build is not None + + +# --------------------------------------------------------------------------- loading + + +def _path_of(ctx_or_path: Any) -> Path: + if isinstance(ctx_or_path, (str, Path)): + return Path(ctx_or_path) + return Path(ctx_or_path.manifest_path) + + +def _root_of(ctx_or_path: Any) -> Path: + if isinstance(ctx_or_path, (str, Path)): + return Path(ctx_or_path).resolve().parent.parent + return Path(ctx_or_path.root) + + +def parse(data: dict[str, Any], path: Path | None = None) -> Manifest: + """Build the dataclasses from already-parsed JSON. Raises ManifestError on a structural problem.""" + try: + components = [] + for c in data["components"]: + components.append( + Component( + id=c["id"], + role=c["role"], + services=list(c["services"]), + integration_repo=c.get("integration_repo"), + integration_branch=c.get("integration_branch"), + upstreams=[Upstream(**{k: u[k] for k in Upstream.__dataclass_fields__}) for u in c.get("upstreams", [])], + adopted_prs=[PR(**{k: p[k] for k in PR.__dataclass_fields__}) for p in c.get("adopted_prs", [])], + candidate_prs=[PR(**{k: p[k] for k in PR.__dataclass_fields__}) for p in c.get("candidate_prs", [])], + base_image=c["base_image"], + base_image_digest=c.get("base_image_digest"), + target_image=dict(c.get("target_image") or {}), + profile=c["profile"], + platforms=list(c.get("platforms", [])), + note=c.get("note"), + raw=c, + ) + ) + return Manifest( + schema_version=int(data["schema_version"]), + generated_at=str(data["generated_at"]), + note=data.get("note"), + components=components, + path=path, + ) + except (KeyError, TypeError, ValueError) as exc: + raise ManifestError([f"MC-01: manifest structure invalid: {exc.__class__.__name__}: {exc}"]) from exc + + +def load(ctx_or_path: Any) -> Manifest: + """Parse manifest/upstreams.json. Accepts a Context or a path. Raises ManifestError (exit 20).""" + path = _path_of(ctx_or_path) + try: + data = json.loads(path.read_text(encoding="utf-8")) + except FileNotFoundError as exc: + raise ManifestError([f"MC-01: {path} not found"]) from exc + except (json.JSONDecodeError, UnicodeDecodeError) as exc: + raise ManifestError([f"MC-01: {path} is not valid JSON: {exc}"]) from exc + if not isinstance(data, dict): + raise ManifestError([f"MC-01: {path} must contain a JSON object"]) + return parse(data, path) + + +# --------------------------------------------------------------------------- validation + + +def _checker_module(root: Path): + """Import tools/manifest_check.py (the one SPEC-01 implementation) from the repository root. + + Falls back to the copy next to this package (installer/../tools) so tests that use a temporary + root still validate with the real checker. + """ + candidates = [root / "tools" / "manifest_check.py", Path(__file__).resolve().parents[2] / "tools" / "manifest_check.py"] + for cand in candidates: + if cand.exists(): + name = "grdm_dev._manifest_check" + spec = importlib.util.spec_from_file_location(name, cand) + if spec is None or spec.loader is None: # pragma: no cover + continue + mod = importlib.util.module_from_spec(spec) + sys.modules[name] = mod + spec.loader.exec_module(mod) + return mod + raise FileNotFoundError("tools/manifest_check.py not found; it is the SPEC-01 checker") + + +def validate(ctx_or_path: Any) -> list[str]: + """Run SPEC-01 §5 checks. Returns [] when valid; otherwise one line per finding (exit 20).""" + json_path = _path_of(ctx_or_path) + toon_path = json_path.with_suffix(".toon") + try: + checker = _checker_module(_root_of(ctx_or_path)) + except FileNotFoundError as exc: + return [f"MC-01: {exc}"] + try: + return list(checker.check_manifest_files(json_path, toon_path)) + except Exception as exc: # the checker must never end in a traceback (same rule as its main()) + return [f"MC-01: manifest could not be validated: {exc.__class__.__name__}: {exc}"] + + +def load_validated(ctx_or_path: Any) -> Manifest: + """validate() then load(); raises ManifestError carrying the findings.""" + errors = validate(ctx_or_path) + if errors: + raise ManifestError(errors) + return load(ctx_or_path) + + +# --------------------------------------------------------------------------- templates and services + + +def load_templates(template_dir: Path | None = None) -> dict[str, dict[str, Any]]: + """Read templates/.json. Keyed by service name; a template's `service` field must match its file.""" + out: dict[str, dict[str, Any]] = {} + for path in sorted((template_dir or TEMPLATE_DIR).glob("*.json")): + with path.open(encoding="utf-8") as fh: + tpl = json.load(fh) + name = tpl.get("service", path.stem) + if name != path.stem: + raise ValueError(f"template {path.name}: service field {name!r} does not match the file name") + out[name] = tpl + return out + + +def service_profile(component: Component, template: dict[str, Any] | None) -> str: + """The smallest profile that includes a service: the template may narrow the component's profile.""" + prof = (template or {}).get("profile") or component.profile + if prof not in PROFILE_RANK: + raise ManifestError([f"MC-10: unknown profile {prof!r} for component {component.id}"]) + return prof + + +def services_for_profile( + manifest: Manifest, + profile: str = DEFAULT_PROFILE, + auth: str = AUTH_FAKECAS, + templates: dict[str, dict[str, Any]] | None = None, + image_tags: dict[str, str] | None = None, +) -> list[Service]: + """Services started by `profile`, in manifest order (SPEC-02 §4). + + `auth` is `fakecas` (default) or `shibboleth`; the latter is only meaningful for `full`, where it + removes `fakecas` and adds `shibboleth_sp` and `test_idp`. `image_tags` maps component id to the + sha12 actually built (from the build report) and overrides the manifest-derived tag. + """ + if profile not in PROFILE_RANK: + raise ValueError(f"unknown profile {profile!r}; expected one of {', '.join(PROFILES)}") + if auth not in (AUTH_FAKECAS, AUTH_SHIBBOLETH): + raise ValueError(f"unknown auth {auth!r}; expected fakecas or shibboleth") + templates = templates if templates is not None else load_templates() + rank = PROFILE_RANK[profile] + use_shib = profile == "full" and auth == AUTH_SHIBBOLETH + out: list[Service] = [] + for comp in manifest.components: + for name in comp.services: + tpl = templates.get(name) + if PROFILE_RANK[service_profile(comp, tpl)] > rank: + continue + if name in SHIBBOLETH_SERVICES and not use_shib: + continue + if name == "fakecas" and use_shib: + continue + build = None + if comp.is_built: + sha12 = (image_tags or {}).get(comp.id) or comp.sha12 + build = BuildInfo(repo=comp.integration_repo or "", branch=comp.integration_branch or "develop", sha=comp.build_sha, sha12=sha12) + else: + sha12 = None + out.append( + Service( + name=name, + component=comp.id, + role=comp.role, + image=comp.image_reference(sha12), + profile=service_profile(comp, tpl), + build=build, + template=tpl or {}, + ) + ) + return out + + +def service_names(services: Iterable[Service]) -> list[str]: + return [s.name for s in services] diff --git a/installer/build/lib/grdm_dev/manifest_cmd.py b/installer/build/lib/grdm_dev/manifest_cmd.py new file mode 100644 index 0000000..9746f81 --- /dev/null +++ b/installer/build/lib/grdm_dev/manifest_cmd.py @@ -0,0 +1,134 @@ +"""grdm-dev manifest check | toon — SPEC-01 validation and the TOON excerpt (SPEC-02 §3). + +`check` runs the CI validator tools/manifest_check.py in-process (loaded with importlib from +/tools so the two never drift) and maps its exit codes: 20 manifest invalid or TOON excerpt +disagrees with JSON (SPEC-02 §6), 1 repository policy violation (private URL / token, SPEC-01 §5), +2 usage. `toon` prints the excerpt that manifest/upstreams.toon must equal (SPEC-01 §2), built from +the validator's own projection so `check` and `toon` agree by construction. +""" +from __future__ import annotations + +import importlib.util +import json +import sys +from pathlib import Path +from types import ModuleType +from typing import Any + +from . import exit_codes, report, toon +from .context import Context + + +def register(subparsers) -> None: + p = subparsers.add_parser("manifest", help="validate manifest/upstreams.json or print its TOON excerpt (SPEC-01)") + sub = p.add_subparsers(dest="manifest_action", metavar="") + c = sub.add_parser("check", help="validate the manifest, TOON parity and repository policy; exit 20 / 1 on failure") + c.add_argument("--manifest-only", action="store_true", help="skip the repository policy scan") + c.add_argument("--policy-only", action="store_true", help="run only the repository policy scan") + t = sub.add_parser("toon", help="print the excerpt that manifest/upstreams.toon must equal") + t.add_argument("--check", action="store_true", help="compare with manifest/upstreams.toon instead of printing; exit 20 on mismatch") + t.add_argument("--write", action="store_true", help="write manifest/upstreams.toon") + p.set_defaults(_module=sys.modules[__name__]) + + +def load_tool(root: Path, name: str) -> ModuleType: + """Import /tools/.py as a module without touching sys.path.""" + path = root / "tools" / f"{name}.py" + if not path.exists(): + raise FileNotFoundError(path) + spec = importlib.util.spec_from_file_location(f"grdm_dev_tools_{name}", path) + if spec is None or spec.loader is None: # pragma: no cover + raise ImportError(name) + mod = importlib.util.module_from_spec(spec) + sys.modules[spec.name] = mod # @dataclass in the tool looks its module up in sys.modules + try: + spec.loader.exec_module(mod) + except Exception: + sys.modules.pop(spec.name, None) + raise + return mod + + +def map_check_exit(code: int) -> int: + """tools/manifest_check.py codes -> grdm-dev codes (they already share SPEC-02's numbers).""" + if code == 0: + return exit_codes.OK + if code == 20: + return exit_codes.MANIFEST_INVALID + if code == 2: + return exit_codes.USAGE + return 1 # policy violation: SPEC-01 §5 / SPEC-06 §5, not a manifest schema error + + +# --------------------------------------------------------------------------- TOON excerpt + +def _table(label: str, rows: list[dict[str, Any]], fields: tuple[str, ...], pad: str) -> list[str]: + if not rows: + return [f"{pad}{label}[0]:"] + out = [f"{pad}{label}[{len(rows)}]{{{','.join(fields)}}}:"] + for r in rows: + out.append(pad + " " + ",".join(toon._scalar(r.get(f)) for f in fields)) + return out + + +def excerpt(data: dict[str, Any], mc: ModuleType) -> str: + """Render the SPEC-01 §2 projection in the layout of manifest/upstreams.toon.""" + proj = mc.project_manifest(data) + lines: list[str] = [] + for key in ("schema_version", "generated_at", "note"): + if key in proj: + lines.append(f"{key}: {toon._scalar(proj[key])}") + comps = proj.get("components", []) + lines.append(f"components[{len(comps)}]:") + for c in comps: + lines.append(f" - id: {toon._scalar(c['id'])}") + for key in ("role", "integration_repo", "profile"): + lines.append(f" {key}: {toon._scalar(c.get(key))}") + lines += _table("upstreams", c.get("upstreams", []), tuple(mc.UPSTREAM_FIELDS), " ") + lines += _table("adopted_prs", c.get("adopted_prs", []), ("repo", "number", "status"), " ") + return "\n".join(lines) + "\n" + + +# --------------------------------------------------------------------------- run + +def run(ctx: Context, args) -> int: + action = getattr(args, "manifest_action", None) + if action not in ("check", "toon"): + sys.stderr.write("usage: grdm-dev manifest \n") + return exit_codes.USAGE + try: + mc = load_tool(ctx.root, "manifest_check") + except FileNotFoundError as exc: + return report.error(ctx, exit_codes.USAGE, f"validator not found: {exc}") + + if action == "check": + argv = ["--root", str(ctx.root)] + if getattr(args, "manifest_only", False): + argv.append("--manifest-only") + if getattr(args, "policy_only", False): + argv.append("--policy-only") + code = map_check_exit(int(mc.main(argv))) + if code != exit_codes.OK: + return report.error(ctx, code, "see the findings above") + return code + + try: + data = json.loads(ctx.manifest_path.read_text(encoding="utf-8")) + except (OSError, json.JSONDecodeError) as exc: + return report.error(ctx, exit_codes.MANIFEST_INVALID, f"{ctx.manifest_path}: {exc}") + if mc.validate_structure(data): + return report.error(ctx, exit_codes.MANIFEST_INVALID, "manifest fails structural checks; run manifest check") + text = excerpt(data, mc) + toon_path = ctx.root / "manifest" / "upstreams.toon" + if getattr(args, "write", False): + toon_path.write_text(text, encoding="utf-8") + sys.stdout.write(f"wrote {toon_path}\n") + return exit_codes.OK + if getattr(args, "check", False): + current = toon_path.read_text(encoding="utf-8") if toon_path.exists() else "" + if current != text: + return report.error(ctx, exit_codes.MANIFEST_INVALID, f"{toon_path} differs from the generated excerpt") + sys.stdout.write(f"{toon_path} is up to date\n") + return exit_codes.OK + sys.stdout.write(text) + return exit_codes.OK diff --git a/installer/build/lib/grdm_dev/messages.tsv b/installer/build/lib/grdm_dev/messages.tsv new file mode 100644 index 0000000..48fe6f4 --- /dev/null +++ b/installer/build/lib/grdm_dev/messages.tsv @@ -0,0 +1,14 @@ +code en ja +0 success 成功 +2 usage error: unknown flag or bad value 使い方の誤り: 不明なフラグか不正な値 +10 host unsupported: OS, CPU, memory, or Python too old ホスト非対応: OS・CPU・メモリ・Python が古い +11 Docker missing, not running, or Compose / buildx plugin absent Docker がない、動いていない、または Compose / buildx プラグインがない +12 a required port on 127.0.0.1 is in use and no free alternative was found 127.0.0.1 の必要なポートが使用中で、空きの代替がない +20 manifest invalid or TOON excerpt disagrees with JSON manifest が不正、または TOON 抄録が JSON と一致しない +30 image build failed イメージのビルドに失敗 +40 health check failed, or a port listens on a non-loopback address 健康確認に失敗、またはループバック以外のアドレスでポートが待ち受けている +50 security scan gate failed for the current milestone 現在の節目のセキュリティ門に不合格 +51 scanner could not run: tool missing or vulnerability database download failed スキャナーが動かない: 道具がない、または脆弱性データベースの取得に失敗 +52 services not healthy, so scan --dynamic could not run サービスが健全でないため scan --dynamic を実行できない +53 red-team preflight failed: egress reachable or a target outside redteam-targets.json レッドチーム事前確認に失敗: 外向き通信が可能、または redteam-targets.json 外の対象がある +60 acceptance test failed 受入試験に失敗 diff --git a/installer/build/lib/grdm_dev/plan.py b/installer/build/lib/grdm_dev/plan.py new file mode 100644 index 0000000..958c335 --- /dev/null +++ b/installer/build/lib/grdm_dev/plan.py @@ -0,0 +1,189 @@ +"""grdm-dev plan — what would be built and started for a profile, with published ports (SPEC-02 §3, §4). + +Touches no Docker. Resolves the profile (flag > runtime/.env GRDM_PROFILE > core), validates the +manifest (exit 20 on any SPEC-01 finding), and prints a TOON report: profile, platform, services +with image and build origin (integration repository name + sha12), published ports (SPEC-02 §4 +table, honoring GRDM_PORT_ overrides in runtime/.env), and named volumes. + +The helpers here (`read_dotenv`, `resolve_profile`, `published_ports`, `detect_platform`) are +shared with compose.py. +""" +from __future__ import annotations + +import platform as _platform +import sys +from pathlib import Path +from typing import Any + +from . import exit_codes, manifest as _manifest, report +from .context import Context + +# SPEC-02 §4 ports table: the only place default host ports are defined. Container ports equal the +# default host ports (SPEC-03 §4.3). +DEFAULT_PORTS: dict[str, int] = { + "web": 5000, + "api": 8000, + "admin": 8001, + "wb": 7777, + "mfr": 7778, + "fakecas": 8080, + "ember_osf_web": 4200, +} +PORT_ENV_PREFIX = "GRDM_PORT_" +PROFILE_ENV_KEY = "GRDM_PROFILE" +LOOPBACK = "127.0.0.1" + + +def register(subparsers) -> None: + p = subparsers.add_parser("plan", help="show images to build and services to start with their ports; exit 20 if the manifest is invalid") + p.add_argument("--auth", choices=[_manifest.AUTH_FAKECAS, _manifest.AUTH_SHIBBOLETH], default=_manifest.AUTH_FAKECAS, + help="auth provider for the full profile (shibboleth replaces fakecas with shibboleth_sp + test_idp)") + p.set_defaults(_module=sys.modules[__name__]) + + +# --------------------------------------------------------------------------- shared helpers + + +def env_path(ctx: Context) -> Path: + return ctx.runtime / ".env" + + +def read_dotenv(path: Path) -> dict[str, str]: + """Parse KEY=value lines; comments and blanks ignored, surrounding quotes stripped. Missing file -> {}.""" + values: dict[str, str] = {} + if not path.exists(): + return values + for raw in path.read_text(encoding="utf-8").splitlines(): + line = raw.strip() + if not line or line.startswith("#") or "=" not in line: + continue + key, _, value = line.partition("=") + key, value = key.strip(), value.strip() + if len(value) >= 2 and value[0] == value[-1] and value[0] in "\"'": + value = value[1:-1] + if key: + values[key] = value + return values + + +def port_key(service: str) -> str: + return PORT_ENV_PREFIX + service.upper() + + +def resolve_profile(ctx: Context, env: dict[str, str] | None = None) -> str: + """Flag > runtime/.env GRDM_PROFILE > core. An unknown saved value falls back to core.""" + if ctx.profile: + return ctx.profile + env = env if env is not None else read_dotenv(env_path(ctx)) + saved = env.get(PROFILE_ENV_KEY, "") + return saved if saved in _manifest.PROFILE_RANK else _manifest.DEFAULT_PROFILE + + +def published_ports(services: list[_manifest.Service], env: dict[str, str]) -> list[dict[str, Any]]: + """Rows {service, host_port, container_port, url, source} for services with a host port. + + The default is the template's host_port (SPEC-02 §4 table); a valid GRDM_PORT_ in + runtime/.env overrides it (source = env). Services without a host_port are internal only. + """ + rows: list[dict[str, Any]] = [] + for svc in services: + tpl = svc.template + default = tpl.get("host_port", DEFAULT_PORTS.get(svc.name)) + if default is None: + continue + container = int(tpl.get("container_port", default)) + host, source = int(default), "default" + raw = env.get(port_key(svc.name)) + if raw and raw.isdigit() and 0 < int(raw) < 65536: + host, source = int(raw), "env" + rows.append({ + "service": svc.name, + "host_port": host, + "container_port": container, + "url": f"http://{LOOPBACK}:{host}", + "source": source, + }) + return rows + + +def detect_platform(host_info: Any = None) -> str: + """linux/arm64 or linux/amd64. Uses a HostInfo when given, else host.classify_arch (pure) when + importable, else platform.machine(). Never probes Docker (plan touches no Docker).""" + if host_info is not None: + plat = getattr(host_info, "platform_string", "") or "" + if plat: + return plat + arch = getattr(host_info, "arch", "") + return f"linux/{arch}" if arch in ("arm64", "amd64") else "unknown" + machine = _platform.machine() + try: + from . import host # other owner; optional + + arch = host.classify_arch(machine) + if arch in ("arm64", "amd64"): + return f"linux/{arch}" + except Exception: + pass + m = machine.lower() + if m in ("arm64", "aarch64"): + return "linux/arm64" + if m in ("x86_64", "amd64"): + return "linux/amd64" + return "unknown" + + +def volumes_of(services: list[_manifest.Service]) -> list[str]: + names: list[str] = [] + for svc in services: + for vol in svc.template.get("volumes", []): + name = vol.get("volume") + if name and name not in names: + names.append(name) + return names + + +# --------------------------------------------------------------------------- report + + +def build_report(ctx: Context, profile: str, auth: str, services: list[_manifest.Service], env: dict[str, str], platform_string: str) -> dict[str, Any]: + rows = [] + for svc in services: + rows.append({ + "service": svc.name, + "component": svc.component, + "role": svc.role, + "image": svc.image, + "build_from": f"{svc.build.repo}@{svc.build.sha12}" if svc.build and svc.build.sha12 else (svc.build.repo if svc.build else "pinned image"), + "profile": svc.profile, + }) + ports = published_ports(services, env) + return { + "profile": profile, + "auth": auth, + "platform": platform_string, + "manifest": str(ctx.manifest_path.relative_to(ctx.root)) if ctx.manifest_path.is_relative_to(ctx.root) else str(ctx.manifest_path), + "services": rows, + "images_to_build": sorted({svc.image for svc in services if svc.is_built}), + "ports": ports, + "volumes": volumes_of(services), + "network": "grdm", + } + + +def run(ctx: Context, args, platform_string: str | None = None) -> int: + errors = _manifest.validate(ctx) + if errors: + for line in errors: + sys.stderr.write(f" - {line}\n") + return report.error(ctx, exit_codes.MANIFEST_INVALID, f"{len(errors)} finding(s); run `grdm-dev manifest check`") + try: + man = _manifest.load(ctx) + env = read_dotenv(env_path(ctx)) + profile = resolve_profile(ctx, env) + auth = getattr(args, "auth", None) or _manifest.AUTH_FAKECAS + services = _manifest.services_for_profile(man, profile, auth) + except (_manifest.ManifestError, ValueError, OSError) as exc: + return report.error(ctx, exit_codes.MANIFEST_INVALID, str(exc)) + data = build_report(ctx, profile, auth, services, env, platform_string or detect_platform()) + report.emit(ctx, "plan", data) + return exit_codes.OK diff --git a/installer/build/lib/grdm_dev/redteam.py b/installer/build/lib/grdm_dev/redteam.py new file mode 100644 index 0000000..fd9a439 --- /dev/null +++ b/installer/build/lib/grdm_dev/redteam.py @@ -0,0 +1,159 @@ +"""grdm-dev redteam preflight — isolation checks before an AI red-team run (SPEC-02 §3, SPEC-03 §6). + +Checks, all read-only and none of them an attack: + 1. an approval record `docs/demo/*_redteam_*.md` exists ("no record, no run"); + 2. the red-team Compose network exists and has `internal: true` (`docker network inspect`); + 3. a throw-away probe container on that network cannot reach an external address + (`docker run --rm --pull never --network alpine wget ... http://example.invalid`); + 4. every container attached to that network is one of the targets in manifest/redteam-targets.json. + +Exit 53 if any check fails, 20 if the targets manifest is missing or malformed, 0 otherwise. +External commands go through an injectable `runner(argv) -> (returncode, output)`. +""" +from __future__ import annotations + +import json +import re +import subprocess +import sys +from pathlib import Path + +from . import exit_codes, report +from .context import Context + +PROBE_URL = "http://example.invalid" # RFC 2606: never resolves; a reply proves a route or a resolver leak +PROBE_MARKER = "GRDM_EGRESS_REACHABLE" +REQUIRED_KEYS = ("project", "network", "targets") + + +def register(subparsers) -> None: + p = subparsers.add_parser("redteam", help="AI red-team helpers (preflight only; never runs attacks)") + sub = p.add_subparsers(dest="redteam_command", metavar="") + pre = sub.add_parser("preflight", help="verify no egress and targets only from manifest/redteam-targets.json; exit 53 on failure") + pre.add_argument("--targets", help="path to the targets manifest (default: manifest/redteam-targets.json)") + pre.add_argument("--approval", help="path to the approval record (default: newest docs/demo/*_redteam_*.md)") + p.set_defaults(_module=sys.modules[__name__]) + + +def default_runner(argv: list[str], timeout: int = 60) -> tuple[int, str]: + try: + proc = subprocess.run(argv, capture_output=True, text=True, timeout=timeout) + except FileNotFoundError as exc: + return 127, str(exc) + except subprocess.TimeoutExpired: + return 124, "timed out" + return proc.returncode, (proc.stdout or "") + (proc.stderr or "") + + +def load_targets(path: Path) -> dict: + """Parse and validate the targets manifest. Raises ValueError with a readable reason.""" + if not path.exists(): + raise ValueError(f"{path} not found") + try: + data = json.loads(path.read_text(encoding="utf-8")) + except json.JSONDecodeError as exc: + raise ValueError(f"{path}: {exc}") from exc + if not isinstance(data, dict): + raise ValueError(f"{path}: top level must be an object") + for k in REQUIRED_KEYS: + if k not in data: + raise ValueError(f"{path}: missing key {k!r}") + if not isinstance(data["targets"], list) or not data["targets"] or not all(isinstance(t, str) and t for t in data["targets"]): + raise ValueError(f"{path}: 'targets' must be a non-empty list of names") + for k in ("project", "network"): + if not isinstance(data[k], str) or not re.fullmatch(r"[a-z0-9][a-z0-9_.-]*", data[k]): + raise ValueError(f"{path}: {k!r} must be a plain Docker name") + return data + + +def service_of(container_name: str, project: str) -> str: + """Compose names containers `--` (or with `_` on old versions).""" + m = re.fullmatch(rf"{re.escape(project)}[-_](.+?)[-_][0-9]+", container_name) + return m.group(1) if m else container_name + + +def inspect_network(runner, network: str) -> tuple[dict | None, str]: + rc, out = runner(["docker", "network", "inspect", network, "--format", "{{json .}}"]) + if rc != 0: + return None, f"docker network inspect {network} failed: {out.strip()[-200:]}" + try: + data = json.loads(out.strip() or "null") + except json.JSONDecodeError: + return None, f"docker network inspect {network}: unreadable output" + if isinstance(data, list): + data = data[0] if data else None + if not isinstance(data, dict): + return None, f"network {network} not found" + return data, "" + + +def probe_egress(runner, network: str) -> tuple[str, str]: + """Return (verdict, detail): verdict is 'blocked', 'reachable', or 'inconclusive'.""" + argv = ["docker", "run", "--rm", "--pull", "never", "--network", network, "alpine", "sh", "-c", + f"wget -T 3 -q -O- {PROBE_URL} >/dev/null 2>&1 && echo {PROBE_MARKER} || echo blocked"] + rc, out = runner(argv) + if PROBE_MARKER in out: + return "reachable", f"probe fetched {PROBE_URL} from network {network}" + if rc == 0 and "blocked" in out: + return "blocked", "probe could not reach outside" + return "inconclusive", f"probe container did not run (rc={rc}): {out.strip()[-200:]}" + + +def preflight(ctx: Context, targets_path: Path, approval: Path | None, runner) -> tuple[dict, list[str]]: + """Run every check. Returns (report data, list of failure reasons).""" + failures: list[str] = [] + manifest = load_targets(targets_path) # ValueError propagates: caller maps it to exit 20 + project, network, targets = manifest["project"], manifest["network"], manifest["targets"] + data: dict = {"project": project, "network": network, "targets": targets, "checks": []} + + def check(name: str, ok: bool, detail: str) -> None: + data["checks"].append({"check": name, "ok": ok, "detail": detail}) + if not ok: + failures.append(f"{name}: {detail}") + + # 1. approval record (SPEC-03 §6 rule 3) + if approval is None: + candidates = sorted((ctx.root / "docs" / "demo").glob("*_redteam_*.md")) if (ctx.root / "docs" / "demo").is_dir() else [] + approval = candidates[-1] if candidates else None + if approval and approval.is_file(): + check("approval_record", True, str(approval.relative_to(ctx.root)) if approval.is_relative_to(ctx.root) else str(approval)) + else: + check("approval_record", False, "no docs/demo/nn_redteam_.md; no record, no run") + + # 2. network is internal + net, err = inspect_network(runner, network) + if net is None: + check("network_internal", False, err) + check("egress_blocked", False, "skipped: network unavailable") + check("targets_only", False, "skipped: network unavailable") + return data, failures + check("network_internal", bool(net.get("Internal")), f"Internal={net.get('Internal')}") + + # 3. egress probe + verdict, detail = probe_egress(runner, network) + check("egress_blocked", verdict == "blocked", detail) + + # 4. attached containers are exactly our targets + attached = sorted(c.get("Name", "") for c in (net.get("Containers") or {}).values()) + unknown = [n for n in attached if n not in targets and service_of(n, project) not in targets] + data["attached"] = attached + data["unknown"] = unknown + check("targets_only", not unknown, "all attached containers are listed" if not unknown else f"outside list: {', '.join(unknown)}") + return data, failures + + +def run(ctx: Context, args, runner=None) -> int: + runner = runner or default_runner + if getattr(args, "redteam_command", None) != "preflight": + return report.error(ctx, exit_codes.USAGE, "usage: grdm-dev redteam preflight") + targets_path = Path(args.targets) if getattr(args, "targets", None) else ctx.root / "manifest" / "redteam-targets.json" + approval = Path(args.approval) if getattr(args, "approval", None) else None + try: + data, failures = preflight(ctx, targets_path, approval, runner) + except ValueError as exc: + return report.error(ctx, exit_codes.MANIFEST_INVALID, str(exc)) + data["result"] = "pass" if not failures else "fail" + report.emit(ctx, "redteam_preflight", data) + if failures: + return report.error(ctx, exit_codes.REDTEAM_PREFLIGHT_FAILED, "; ".join(failures)) + return exit_codes.OK diff --git a/installer/build/lib/grdm_dev/report.py b/installer/build/lib/grdm_dev/report.py new file mode 100644 index 0000000..e7b6d1d --- /dev/null +++ b/installer/build/lib/grdm_dev/report.py @@ -0,0 +1,39 @@ +"""Report output: TOON to stdout by default, JSON with --json; copy kept under runtime/reports/.""" +from __future__ import annotations + +import datetime as _dt +import json +import sys +from typing import Any + +from . import toon +from .context import Context + + +def timestamp() -> str: + return _dt.datetime.now(_dt.timezone.utc).strftime("%Y%m%dT%H%M%SZ") + + +def emit(ctx: Context, name: str, data: dict[str, Any], *, save: bool = True) -> None: + """Print one report and (by default) save JSON + TOON copies as runtime/reports/_.*""" + text = json.dumps(data, ensure_ascii=False, indent=2) if ctx.json_output else toon.encode(data, name=name) + sys.stdout.write(text + "\n") + if save: + try: + ctx.reports_dir.mkdir(parents=True, exist_ok=True) + base = ctx.reports_dir / f"{name}_{timestamp()}" + base.with_suffix(".json").write_text(json.dumps(data, ensure_ascii=False, indent=2) + "\n", encoding="utf-8") + base.with_suffix(".toon").write_text(toon.encode(data, name=name) + "\n", encoding="utf-8") + latest = ctx.reports_dir / f"{name}_latest.json" + latest.write_text(json.dumps(data, ensure_ascii=False, indent=2) + "\n", encoding="utf-8") + except OSError as exc: # reports are evidence, but failing to save must not hide the result + sys.stderr.write(f"warning: could not save report: {exc}\n") + + +def error(ctx: Context, code: int, detail: str = "") -> int: + """Print the canonical message for an exit code (plus detail) to stderr and return the code.""" + from .exit_codes import describe + + msg = describe(code, ctx.lang) + sys.stderr.write(f"[grdm-dev] exit {code}: {msg}" + (f" — {detail}" if detail else "") + "\n") + return code diff --git a/installer/build/lib/grdm_dev/report_cmd.py b/installer/build/lib/grdm_dev/report_cmd.py new file mode 100644 index 0000000..8962283 --- /dev/null +++ b/installer/build/lib/grdm_dev/report_cmd.py @@ -0,0 +1,80 @@ +"""grdm-dev report — bundle the latest doctor / plan / health / scan / accept reports (SPEC-02 §3). + +Reads runtime/reports/_latest.json for each report, writes runtime/reports/report_.json +and .toon with a summary (which reports exist, their timestamps, overall status) and prints it. +Values found in runtime/.env are masked before anything is written (SPEC-03 §3.1). +""" +from __future__ import annotations + +import datetime as _dt +import json +import sys +from pathlib import Path +from typing import Any + +from . import exit_codes, report +from .context import Context + +REPORT_NAMES = ("doctor", "plan", "health", "scan", "accept") + + +def register(subparsers) -> None: + p = subparsers.add_parser("report", help="bundle the latest doctor, plan, health, scan and accept reports") + p.set_defaults(_module=sys.modules[__name__]) + + +def _status_of(data: Any) -> str: + if not isinstance(data, dict): + return "unreadable" + if "exit_code" in data: + return "ok" if data.get("exit_code") in (0, "0") else f"fail ({data.get('exit_code')})" + for key in ("gate", "status", "result"): + if key in data: + return str(data[key]) + return "present" + + +def collect(reports_dir: Path) -> tuple[list[dict[str, Any]], dict[str, Any]]: + rows: list[dict[str, Any]] = [] + bundle: dict[str, Any] = {} + for name in REPORT_NAMES: + path = reports_dir / f"{name}_latest.json" + if not path.exists(): + rows.append({"name": name, "present": False, "timestamp": "", "status": "missing"}) + continue + ts = _dt.datetime.fromtimestamp(path.stat().st_mtime, _dt.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ") + try: + data = json.loads(path.read_text(encoding="utf-8")) + except (OSError, json.JSONDecodeError): + data = None + rows.append({"name": name, "present": True, "timestamp": ts, "status": _status_of(data)}) + bundle[name] = data if data is not None else {"error": "unreadable"} + return rows, bundle + + +def run(ctx: Context, args) -> int: + from .scan import _env_secrets, mask_secrets # same masking rule as scan + + rows, bundle = collect(ctx.reports_dir) + present = [r["name"] for r in rows if r["present"]] + failed = [r["name"] for r in rows if r["present"] and r["status"].startswith("fail")] + if not present: + overall = "empty" + elif failed: + overall = "fail" + elif len(present) == len(REPORT_NAMES): + overall = "complete" + else: + overall = "partial" + data: dict[str, Any] = { + "date": _dt.datetime.now(_dt.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"), + "overall": overall, + "present": present, + "missing": [r["name"] for r in rows if not r["present"]], + "failed": failed, + "reports": rows, + "bundle": bundle, + } + data = mask_secrets(data, _env_secrets(ctx.runtime / ".env")) + report.emit(ctx, "report", data) + return exit_codes.OK diff --git a/installer/build/lib/grdm_dev/scan.py b/installer/build/lib/grdm_dev/scan.py new file mode 100644 index 0000000..8894883 --- /dev/null +++ b/installer/build/lib/grdm_dev/scan.py @@ -0,0 +1,675 @@ +"""grdm-dev scan — the security gate of SPEC-03 (baseline controls, Trivy, gitleaks, Semgrep, ZAP, +allow-list diff, staged gate per ADR-03). + +Usage: grdm-dev scan [--baseline] [--secrets] [--dynamic] [--milestone M1..M5] + +Without part flags the whole gate runs (baseline, Trivy, Semgrep, gitleaks, and ZAP only when the +services are healthy). Each part flag restricts the run to that part. Exit codes (SPEC-03 §8): +0 pass, 50 gate failed, 51 scanner unavailable, 52 --dynamic requested while services unhealthy. + +Every external program goes through an injectable `runner(argv) -> (returncode, stdout)` and tool +presence through an injectable `which(name) -> bool`, so unit tests feed canned scanner JSON and +never need Docker (SPEC-02 §10). Reports never contain secret values (SPEC-03 §3.1): gitleaks runs +with --redact, only rule id / file / line are kept, and every value of runtime/.env is masked. +""" +from __future__ import annotations + +import datetime as _dt +import json +import platform +import re +import shutil +import subprocess +import sys +from pathlib import Path +from typing import Any, Callable + +from . import exit_codes, report +from .context import Context + +Runner = Callable[[list[str]], tuple[int, str]] + +SEVERITIES = ("CRITICAL", "HIGH", "MEDIUM", "LOW", "INFO") +ALLOWLIST_FIELDS = ("cve", "component", "reason", "owner", "expires", "added_at") +MILESTONES = ("M1", "M2", "M3", "M4", "M5") +# Milestone -> gate rule name (SPEC-03 §5.2 / ADR-03 §3). manifest/milestone.json may carry the +# same word in its "gate" field; the milestone number decides when the two disagree. +GATE_BY_MILESTONE = { + "M1": "report-only", + "M2": "count-not-growing", + "M3": "count-not-growing", + "M4": "fail-high", + "M5": "zero-critical-high", +} +# ZAP targets by Compose service name and container port (SPEC-03 §4.3); only services that the +# rendered compose file defines are scanned. +ZAP_DEFAULT_TARGETS = {"web": 5000, "admin": 8001, "ember_osf_web": 4200} +ZAP_IMAGE = "ghcr.io/zaproxy/zaproxy:stable" +DEFAULT_NETWORK = "grdm" +FORBIDDEN_ALIAS = "192.168.168.167" +IMAGE_PREFIX = "grdm-dev/" + +DEFAULT_ALLOWLIST: dict[str, Any] = { + "schema_version": 1, + "note": "Accepted findings (SPEC-03 §5.1). Every entry needs cve, component, reason, owner, " + "expires, added_at; optional severity. Only the owner approves additions.", + "fields": list(ALLOWLIST_FIELDS), + "entries": [], +} +DEFAULT_BASELINE: dict[str, Any] = { + "schema_version": 1, + "note": "Allow-list entry count at each milestone exit, owner-maintained (SPEC-03 §5.1 rule 5). " + "The count for the current milestone is the ceiling; it must never grow.", + "counts": {"M1": 0}, +} +DEFAULT_MILESTONE: dict[str, Any] = {"milestone": "M1", "gate": "report-only"} + + +# --------------------------------------------------------------------------- CLI contract + +def register(subparsers) -> None: + p = subparsers.add_parser("scan", help="security gate: baseline, Trivy, gitleaks, Semgrep, ZAP (SPEC-03)") + p.add_argument("--baseline", action="store_true", help="only re-check the baseline controls of runtime/docker-compose.yml") + p.add_argument("--secrets", action="store_true", help="only run gitleaks over the repository") + p.add_argument("--dynamic", action="store_true", help="only run the OWASP ZAP baseline (exit 52 if services are unhealthy)") + p.add_argument("--milestone", choices=MILESTONES, help="override manifest/milestone.json for this run") + p.set_defaults(_module=sys.modules[__name__]) + + +def default_runner(cwd: Path) -> Runner: + def _run(argv: list[str]) -> tuple[int, str]: + try: + proc = subprocess.run(argv, capture_output=True, text=True, cwd=str(cwd)) + except FileNotFoundError: + return 127, "" + return proc.returncode, proc.stdout + return _run + + +def default_which(name: str) -> bool: + return shutil.which(name) is not None + + +# --------------------------------------------------------------------------- manifest files + +def _load_or_create(path: Path, default: dict[str, Any]) -> tuple[dict[str, Any], list[str]]: + """Read a JSON file; create it from `default` when missing. Returns (data, problems).""" + if not path.exists(): + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(json.dumps(default, ensure_ascii=False, indent=2) + "\n", encoding="utf-8") + return json.loads(json.dumps(default)), [] + try: + data = json.loads(path.read_text(encoding="utf-8")) + except (json.JSONDecodeError, UnicodeDecodeError) as exc: + return dict(default), [f"{path.name} is not valid JSON: {exc}"] + if not isinstance(data, dict): + return dict(default), [f"{path.name} must be a JSON object"] + return data, [] + + +def _parse_date(value: Any) -> _dt.date | None: + if not isinstance(value, str): + return None + try: + return _dt.date.fromisoformat(value[:10]) + except ValueError: + return None + + +def validate_allowlist(entries: Any, today: _dt.date) -> tuple[list[dict], list[dict]]: + """Split allow-list entries into (active, findings). Malformed or expired entries become findings + of tool `allowlist`; a malformed entry fails the gate at any milestone (SPEC-03 §5.1 rule 1).""" + active: list[dict] = [] + findings: list[dict] = [] + if not isinstance(entries, list): + return [], [_finding("allowlist", "ALLOWLIST-MALFORMED", "HIGH", "manifest/allowlist.json", "entries", + "entries must be a list")] + for idx, e in enumerate(entries): + loc = f"manifest/allowlist.json#entries[{idx}]" + if not isinstance(e, dict): + findings.append(_finding("allowlist", "ALLOWLIST-MALFORMED", "HIGH", "manifest/allowlist.json", loc, + "entry is not an object")) + continue + missing = [f for f in ALLOWLIST_FIELDS if not isinstance(e.get(f), str) or not e.get(f).strip()] + if missing: + findings.append(_finding("allowlist", "ALLOWLIST-MALFORMED", "HIGH", str(e.get("component", "")), loc, + f"missing or empty field(s): {', '.join(missing)}")) + continue + if str(e["owner"]).strip().lower() == "team": + findings.append(_finding("allowlist", "ALLOWLIST-MALFORMED", "HIGH", e["component"], loc, + "owner must be a person or a role, never 'team'")) + continue + expires = _parse_date(e["expires"]) + added = _parse_date(e["added_at"]) + if expires is None or added is None: + findings.append(_finding("allowlist", "ALLOWLIST-MALFORMED", "HIGH", e["component"], loc, + "expires and added_at must be ISO dates")) + continue + if expires < today: + findings.append(_finding("allowlist", "ALLOWLIST-EXPIRED", "MEDIUM", e["component"], loc, + f"{e['cve']} expired {expires.isoformat()}; the finding counts again")) + continue + active.append(e) + return active, findings + + +def _entry_matches(entry: dict, finding: dict) -> bool: + if entry["cve"] != finding["id"]: + return False + comp = entry.get("component", "*") + if comp in ("", "*"): + return True + fcomp = finding.get("component", "") or "" + return fcomp == comp or fcomp.startswith(comp.split("@")[0]) + + +# --------------------------------------------------------------------------- findings + +def _finding(tool: str, fid: str, severity: str, component: str, location: str, title: str) -> dict[str, Any]: + sev = str(severity or "").upper() + if sev == "UNKNOWN": + sev = "LOW" + if sev not in SEVERITIES: + sev = "INFO" + return {"tool": tool, "id": str(fid), "severity": sev, "component": str(component or ""), + "location": str(location or ""), "title": str(title or "")[:200]} + + +def _json_or_empty(text: str) -> Any: + try: + return json.loads(text) if text and text.strip() else None + except json.JSONDecodeError: + return None + + +def normalize_trivy(data: Any, target: str) -> list[dict]: + out: list[dict] = [] + if not isinstance(data, dict): + return out + for res in data.get("Results") or []: + loc = res.get("Target") or target + for v in res.get("Vulnerabilities") or []: + comp = f"{v.get('PkgName', '')}@{v.get('InstalledVersion', '')}".rstrip("@") + out.append(_finding("trivy", v.get("VulnerabilityID", ""), v.get("Severity", ""), comp, loc, v.get("Title", ""))) + for m in res.get("Misconfigurations") or []: + out.append(_finding("trivy", m.get("ID", ""), m.get("Severity", ""), loc, loc, m.get("Title", ""))) + return out + + +_SEMGREP_SEVERITY = {"ERROR": "HIGH", "WARNING": "MEDIUM", "INFO": "LOW"} + + +def normalize_semgrep(data: Any) -> list[dict]: + out: list[dict] = [] + if not isinstance(data, dict): + return out + for r in data.get("results") or []: + extra = r.get("extra") or {} + sev = _SEMGREP_SEVERITY.get(str(extra.get("severity", "")).upper(), "LOW") + path = r.get("path", "") + line = (r.get("start") or {}).get("line", "") + out.append(_finding("semgrep", r.get("check_id", ""), sev, path, f"{path}:{line}", extra.get("message", ""))) + return out + + +def normalize_gitleaks(data: Any) -> list[dict]: + """Keep only rule id, file, line, description; never Secret/Match/Line (SPEC-03 §3.1).""" + out: list[dict] = [] + if not isinstance(data, list): + return out + for leak in data: + if not isinstance(leak, dict): + continue + f = leak.get("File", "") + out.append(_finding("gitleaks", leak.get("RuleID", "secret"), "HIGH", f, + f"{f}:{leak.get('StartLine', '')}", leak.get("Description", "secret detected"))) + return out + + +_ZAP_RISK = {"3": "HIGH", "2": "MEDIUM", "1": "LOW", "0": "INFO"} + + +def normalize_zap(data: Any, target: str) -> list[dict]: + out: list[dict] = [] + if not isinstance(data, dict): + return out + for site in data.get("site") or []: + for a in site.get("alerts") or []: + inst = (a.get("instances") or [{}])[0] + out.append(_finding("zap", f"ZAP-{a.get('pluginid', '')}", _ZAP_RISK.get(str(a.get("riskcode", "0")), "INFO"), + target, inst.get("uri", target), a.get("alert") or a.get("name", ""))) + return out + + +# --------------------------------------------------------------------------- baseline controls + +def _load_compose(path: Path) -> tuple[dict | None, str]: + text = path.read_text(encoding="utf-8") + data = _json_or_empty(text) # compose render writes JSON, which Compose accepts as YAML (SPEC-02 §2.2) + return (data if isinstance(data, dict) else None), text + + +def check_baseline(compose_path: Path) -> tuple[list[dict], list[str]]: + """Re-check the SPEC-03 §3.2/§3.3 controls of a rendered compose file. Returns (findings, notes).""" + if not compose_path.exists(): + return [], ["runtime/docker-compose.yml not found; baseline controls not checked (run compose render)"] + data, text = _load_compose(compose_path) + findings: list[dict] = [] + loc = "runtime/docker-compose.yml" + if FORBIDDEN_ALIAS in text: + findings.append(_finding("baseline", "BASE-ALIAS", "HIGH", "compose", loc, + f"loopback alias {FORBIDDEN_ALIAS} must not appear (ADR-02)")) + if data is None: + # Not JSON: best-effort text checks only. + for m in re.finditer(r'^\s*-\s*"?(?P[^"\s]+)"?\s*$', text, re.M): + spec = m.group("spec") + if re.match(r"^\d+:\d+", spec) or re.match(r"^0\.0\.0\.0:", spec): + findings.append(_finding("baseline", "BASE-PUBLISH", "HIGH", "compose", loc, + f"port {spec} is not published on 127.0.0.1")) + if re.search(r"^\s*privileged:\s*true", text, re.M): + findings.append(_finding("baseline", "BASE-PRIVILEGED", "CRITICAL", "compose", loc, "privileged: true is forbidden")) + return findings, ["compose file is not JSON; user/cap_drop checks skipped"] + services = data.get("services") or {} + for name, svc in services.items(): + if not isinstance(svc, dict): + continue + for p in svc.get("ports") or []: + spec = p if isinstance(p, str) else str((p or {}).get("host_ip", "")) + ":" + str((p or {}).get("published", "")) + if isinstance(p, dict): + ok = p.get("host_ip") == "127.0.0.1" + else: + ok = spec.startswith("127.0.0.1:") + if not ok: + findings.append(_finding("baseline", "BASE-PUBLISH", "HIGH", name, f"{loc}#services.{name}.ports", + f"port {spec} is not published on 127.0.0.1")) + if not str(svc.get("user") or "").strip(): + findings.append(_finding("baseline", "BASE-USER", "HIGH", name, f"{loc}#services.{name}", "no user: set (runs as root)")) + caps = [str(c).upper() for c in (svc.get("cap_drop") or [])] + if "ALL" not in caps: + findings.append(_finding("baseline", "BASE-CAPDROP", "MEDIUM", name, f"{loc}#services.{name}", "cap_drop must contain ALL")) + if svc.get("privileged") is True: + findings.append(_finding("baseline", "BASE-PRIVILEGED", "CRITICAL", name, f"{loc}#services.{name}", "privileged: true is forbidden")) + return findings, [] + + +# --------------------------------------------------------------------------- secrets masking + +def _env_secrets(env_path: Path) -> list[str]: + if not env_path.exists(): + return [] + vals: list[str] = [] + for line in env_path.read_text(encoding="utf-8", errors="replace").splitlines(): + if "=" not in line or line.lstrip().startswith("#"): + continue + v = line.split("=", 1)[1].strip().strip("'\"") + if len(v) >= 8: + vals.append(v) + return vals + + +def mask_secrets(data: Any, secrets: list[str]) -> Any: + if not secrets: + return data + if isinstance(data, str): + for s in secrets: + if s in data: + data = data.replace(s, "***") + return data + if isinstance(data, list): + return [mask_secrets(x, secrets) for x in data] + if isinstance(data, dict): + return {k: mask_secrets(v, secrets) for k, v in data.items()} + return data + + +# --------------------------------------------------------------------------- scanners + +def _save_raw(ctx: Context, name: str, text: str, secrets: list[str]) -> Path: + """Save a scanner's raw output under runtime/reports/ with runtime/.env values masked.""" + ctx.reports_dir.mkdir(parents=True, exist_ok=True) + path = ctx.reports_dir / name + path.write_text(mask_secrets(text, secrets), encoding="utf-8") + return path + + +class ScannerMissing(Exception): + def __init__(self, tool: str, detail: str = ""): + super().__init__(tool) + self.tool = tool + self.detail = detail + + +def _require(which: Callable[[str], bool], tool: str) -> None: + if not which(tool): + raise ScannerMissing(tool, "not found on PATH") + + +def _tool_version(runner: Runner, argv: list[str]) -> str: + rc, out = runner(argv) + if rc != 0 or not out: + return "unknown" + m = re.search(r"\d+\.\d+(\.\d+)?", out) + return m.group(0) if m else out.strip().splitlines()[0][:40] + + +def run_trivy(ctx: Context, runner: Runner, which: Callable[[str], bool], ts: str, + secrets: list[str] | None = None) -> tuple[list[dict], dict, list[str]]: + secrets = secrets or [] + _require(which, "trivy") + notes: list[str] = [] + findings: list[dict] = [] + images: list[str] = [] + if which("docker"): + rc, out = runner(["docker", "image", "ls", "--format", "{{.Repository}}:{{.Tag}}"]) + if rc == 0: + images = [l.strip() for l in out.splitlines() if l.strip().startswith(IMAGE_PREFIX) and not l.strip().endswith(":")] + reports = ctx.reports_dir + reports.mkdir(parents=True, exist_ok=True) + if images: + for img in images: + safe = re.sub(r"[^A-Za-z0-9_.-]", "_", img) + sbom = reports / f"sbom_{safe}_{ts}.json" + rc, _ = runner(["trivy", "image", "--quiet", "--format", "cyclonedx", "--output", str(sbom), img]) + if rc != 0: + notes.append(f"trivy sbom failed for {img} (rc {rc})") + rc, out = runner(["trivy", "image", "--quiet", "--format", "json", "--scanners", "vuln", img]) + data = _json_or_empty(out) + if rc != 0 or data is None: + raise ScannerMissing("trivy", f"image scan of {img} failed (rc {rc}); vulnerability database download may have failed") + _save_raw(ctx, f"trivy_{safe}_{ts}.json", out, secrets) + findings.extend(normalize_trivy(data, img)) + else: + notes.append(f"no {IMAGE_PREFIX}* image found; trivy fs scan of the repository instead (SPEC-03 §4.1 M1 scope)") + sbom = reports / f"sbom_repo_{ts}.json" + rc, _ = runner(["trivy", "fs", "--quiet", "--format", "cyclonedx", "--output", str(sbom), "."]) + if rc != 0: + notes.append(f"trivy sbom of the repository failed (rc {rc})") + rc, out = runner(["trivy", "fs", "--quiet", "--format", "json", "--scanners", "vuln,misconfig", "."]) + data = _json_or_empty(out) + if rc != 0 or data is None: + raise ScannerMissing("trivy", f"fs scan failed (rc {rc}); vulnerability database download may have failed") + _save_raw(ctx, f"trivy_repo_{ts}.json", out, secrets) + findings.extend(normalize_trivy(data, ".")) + tool = {"name": "trivy", "version": _tool_version(runner, ["trivy", "--version"]), "result": "ok", + "targets": len(images) if images else 1} + return findings, tool, notes + + +def run_semgrep(ctx: Context, runner: Runner, which: Callable[[str], bool], ts: str, + secrets: list[str] | None = None) -> tuple[list[dict], dict]: + _require(which, "semgrep") + rc, out = runner(["semgrep", "scan", "--config", "p/default", "--json", "--quiet", "."]) + data = _json_or_empty(out) + if data is None: + raise ScannerMissing("semgrep", f"no JSON output (rc {rc})") + _save_raw(ctx, f"semgrep_{ts}.json", out, secrets or []) + return normalize_semgrep(data), {"name": "semgrep", "version": _tool_version(runner, ["semgrep", "--version"]), + "result": "ok", "targets": 1} + + +def run_gitleaks(ctx: Context, runner: Runner, which: Callable[[str], bool], ts: str, + secrets: list[str] | None = None) -> tuple[list[dict], dict]: + _require(which, "gitleaks") + ctx.reports_dir.mkdir(parents=True, exist_ok=True) + out_path = ctx.reports_dir / f"gitleaks_{ts}.json" + argv = ["gitleaks", "detect", "--source", ".", "--redact", "--report-format", "json", "--report-path", str(out_path), + "--exit-code", "0"] + if (ctx.root / ".gitleaks.toml").exists(): + argv[4:4] = ["--config", ".gitleaks.toml"] + rc, out = runner(argv) + data = None + if out_path.exists(): + data = _json_or_empty(out_path.read_text(encoding="utf-8")) + if data is None: + data = _json_or_empty(out) + if data is None: + if rc != 0: + raise ScannerMissing("gitleaks", f"rc {rc} and no report") + data = [] + findings = mask_secrets(normalize_gitleaks(data), secrets or []) + # Rewrite the saved report with only the normalized fields: never Secret / Match / Line. + out_path.write_text(json.dumps(findings, ensure_ascii=False, indent=2) + "\n", encoding="utf-8") + return findings, {"name": "gitleaks", "version": _tool_version(runner, ["gitleaks", "version"]), "result": "ok", "targets": 1} + + +def _compose_services_and_network(compose_path: Path) -> tuple[list[str], str]: + if not compose_path.exists(): + return list(ZAP_DEFAULT_TARGETS), DEFAULT_NETWORK + data, _ = _load_compose(compose_path) + if data is None: + return list(ZAP_DEFAULT_TARGETS), DEFAULT_NETWORK + services = list((data.get("services") or {}).keys()) + nets = data.get("networks") or {} + network = DEFAULT_NETWORK + for key, val in nets.items(): + network = (val or {}).get("name") if isinstance(val, dict) and (val or {}).get("name") else key + break + return services, network + + +def services_healthy(ctx: Context, runner: Runner, which: Callable[[str], bool], prober=None) -> bool: + """All services healthy? Uses grdm_dev.health.check_services when the module exists (its `prober` + is injectable so tests never open sockets); otherwise falls back to `docker compose ps`.""" + compose = ctx.runtime / "docker-compose.yml" + if not compose.exists() or not which("docker"): + return False + try: # health.py is owned by another task; use it when present, never require it + from . import health as _health # type: ignore + except ImportError: + _health = None + if _health is not None and callable(getattr(_health, "check_services", None)): + try: + _, ok = _health.check_services(ctx, runner, prober or _health.default_prober) + return bool(ok) + except Exception as exc: # a broken health probe is "not healthy", not a traceback + sys.stderr.write(f"[grdm-dev] health check failed: {exc}\n") + return False + rc, out = runner(["docker", "compose", "-f", str(compose), "ps", "--format", "json"]) + if rc != 0 or not out.strip(): + return False + rows: list[dict] = [] + data = _json_or_empty(out) + if isinstance(data, list): + rows = [r for r in data if isinstance(r, dict)] + else: + for line in out.splitlines(): + row = _json_or_empty(line) + if isinstance(row, dict): + rows.append(row) + if not rows: + return False + for r in rows: + if str(r.get("State", "")).lower() != "running": + return False + health = str(r.get("Health", "")).lower() + if health and health != "healthy": + return False + return True + + +def run_zap(ctx: Context, runner: Runner, which: Callable[[str], bool], ts: str, + secrets: list[str] | None = None) -> tuple[list[dict], dict, list[str]]: + _require(which, "docker") + services, network = _compose_services_and_network(ctx.runtime / "docker-compose.yml") + targets = {s: p for s, p in ZAP_DEFAULT_TARGETS.items() if s in services} + notes: list[str] = [] + if not targets: + notes.append("no ZAP target service (web, admin, ember_osf_web) in the compose file; dynamic scan skipped") + return [], {"name": "zap", "version": "stable", "result": "skipped", "targets": 0}, notes + ctx.reports_dir.mkdir(parents=True, exist_ok=True) + findings: list[dict] = [] + for svc, port in targets.items(): + url = f"http://{svc}:{port}" # service name, never 127.0.0.1 (SPEC-03 §4.3) + out_name = f"zap_{svc}_{ts}.json" + argv = ["docker", "run", "--rm", "--network", network, "-v", f"{ctx.reports_dir}:/zap/wrk:rw", + ZAP_IMAGE, "zap-baseline.py", "-t", url, "-J", out_name, "-I"] + rc, out = runner(argv) + if rc == 127: + raise ScannerMissing("docker", "docker not found") + out_path = ctx.reports_dir / out_name + data = _json_or_empty(out_path.read_text(encoding="utf-8")) if out_path.exists() else _json_or_empty(out) + if data is None: + raise ScannerMissing("zap", f"no ZAP report for {url} (rc {rc}); image {ZAP_IMAGE} pull may have failed") + if out_path.exists(): + _save_raw(ctx, out_name, json.dumps(data, ensure_ascii=False, indent=2), secrets or []) + findings.extend(normalize_zap(data, url)) + return findings, {"name": "zap", "version": "stable", "result": "ok", "targets": len(targets)}, notes + + +# --------------------------------------------------------------------------- gate + +def gate_decision(milestone: str, findings: list[dict], allowlisted: list[dict], allow_entries: list[dict], + baseline_failed: bool, allowlist_invalid: bool, count: int, baseline_count: int | None) -> dict[str, Any]: + rule = GATE_BY_MILESTONE.get(milestone, "report-only") + reasons: list[str] = [] + if baseline_failed: + reasons.append("baseline control violated (SPEC-03 §3)") + if allowlist_invalid: + reasons.append("allow-list entry malformed (SPEC-03 §5.1 rule 1)") + open_high = [f for f in findings if f["severity"] in ("CRITICAL", "HIGH") and f["tool"] not in ("baseline", "gitleaks", "allowlist")] + over = 0 + if rule in ("count-not-growing", "fail-high", "zero-critical-high") and baseline_count is not None and count > baseline_count: + reasons.append(f"allow-list grew: {count} > baseline {baseline_count} (SPEC-03 §5.1 rule 5)") + if rule in ("fail-high", "zero-critical-high"): + over = len(open_high) + if over: + reasons.append(f"{over} CRITICAL/HIGH finding(s) not in the allow-list") + if rule == "zero-critical-high": + hi_entries = [e for e in allow_entries if str(e.get("severity", "")).upper() in ("CRITICAL", "HIGH")] + hi_entries += [e for e in allowlisted if e["severity"] in ("CRITICAL", "HIGH")] + if hi_entries: + reasons.append(f"{len(hi_entries)} CRITICAL/HIGH allow-list entr(ies) at M5 (must be empty)") + return {"rule": rule, "over_threshold": over if rule in ("fail-high", "zero-critical-high") else len(open_high), + "pass": not reasons, "reasons": reasons} + + +# --------------------------------------------------------------------------- run + +def run(ctx: Context, args, runner: Runner | None = None, which: Callable[[str], bool] | None = None, + today: _dt.date | None = None, prober=None) -> int: + runner = runner or default_runner(ctx.root) + which = which or default_which + today = today or _dt.date.today() + ts = report.timestamp() + secrets = _env_secrets(ctx.runtime / ".env") + only = {k for k in ("baseline", "secrets", "dynamic") if getattr(args, k, False)} + full = not only + + milestone_data, problems = _load_or_create(ctx.root / "manifest" / "milestone.json", DEFAULT_MILESTONE) + allow_data, p2 = _load_or_create(ctx.root / "manifest" / "allowlist.json", DEFAULT_ALLOWLIST) + base_data, p3 = _load_or_create(ctx.root / "manifest" / "allowlist.baseline.json", DEFAULT_BASELINE) + problems += p2 + p3 + milestone = getattr(args, "milestone", None) or str(milestone_data.get("milestone", "M1")) + if milestone not in MILESTONES: + problems.append(f"unknown milestone {milestone!r}; treating as M1") + milestone = "M1" + + findings: list[dict] = [] + tools: list[dict] = [] + notes: list[str] = list(problems) + baseline_result = "not-run" + dynamic_unhealthy = False + missing: ScannerMissing | None = None + + try: + if full or "baseline" in only: + bfind, bnotes = check_baseline(ctx.runtime / "docker-compose.yml") + findings.extend(bfind) + notes.extend(bnotes) + baseline_result = "pass" if not bfind else "fail" + if bnotes and not (ctx.runtime / "docker-compose.yml").exists(): + baseline_result = "skipped" + if full: + tf, tt, tn = run_trivy(ctx, runner, which, ts, secrets) + findings.extend(tf) + tools.append(tt) + notes.extend(tn) + sf, st = run_semgrep(ctx, runner, which, ts, secrets) + findings.extend(sf) + tools.append(st) + if full or "secrets" in only: + gf, gt = run_gitleaks(ctx, runner, which, ts, secrets) + findings.extend(gf) + tools.append(gt) + if full or "dynamic" in only: + healthy = services_healthy(ctx, runner, which, prober) + if healthy: + zf, zt, zn = run_zap(ctx, runner, which, ts, secrets) + findings.extend(zf) + tools.append(zt) + notes.extend(zn) + elif "dynamic" in only: + dynamic_unhealthy = True + tools.append({"name": "zap", "version": "stable", "result": "services-unhealthy", "targets": 0}) + else: + notes.append("services not healthy; dynamic (ZAP) part skipped (SPEC-03 §4.3)") + tools.append({"name": "zap", "version": "stable", "result": "skipped", "targets": 0}) + except ScannerMissing as exc: + missing = exc + tools.append({"name": exc.tool, "version": "missing", "result": f"unavailable: {exc.detail}", "targets": 0}) + + # Allow-list + entries = allow_data.get("entries", []) + active, allow_findings = validate_allowlist(entries, today) + allowlist_invalid = any(f["id"] == "ALLOWLIST-MALFORMED" for f in allow_findings) + findings.extend(allow_findings) + open_findings: list[dict] = [] + allowlisted: list[dict] = [] + for f in findings: + if f["tool"] in ("baseline", "gitleaks", "allowlist"): # no allow-list for baseline controls (ADR-03 §3.2) + open_findings.append(f) + elif any(_entry_matches(e, f) for e in active): + allowlisted.append(f) + else: + open_findings.append(f) + counts = base_data.get("counts") if isinstance(base_data.get("counts"), dict) else {} + baseline_count: int | None = None + for m in reversed(MILESTONES[: MILESTONES.index(milestone) + 1]): + if isinstance(counts.get(m), int): + baseline_count = counts[m] + break + count = len(entries) if isinstance(entries, list) else 0 + baseline_failed = any(f["tool"] in ("baseline", "gitleaks") for f in findings) + gate = gate_decision(milestone, open_findings, allowlisted, active, baseline_failed, allowlist_invalid, count, baseline_count) + + by_sev = {s.lower(): sum(1 for f in open_findings if f["severity"] == s) for s in SEVERITIES} + if missing is not None: + code = exit_codes.SCANNER_UNAVAILABLE + elif dynamic_unhealthy: + code = exit_codes.SERVICES_UNHEALTHY + elif not gate["pass"]: + code = exit_codes.SCAN_GATE_FAILED + else: + code = exit_codes.OK + + rc, sha = runner(["git", "rev-parse", "--short", "HEAD"]) + data: dict[str, Any] = { + "date": _dt.datetime.now(_dt.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"), + "milestone": milestone, + "commit": sha.strip() if rc == 0 else "unknown", + "host": f"{platform.system().lower()}-{platform.machine().lower()}", + "parts": sorted(only) if only else ["baseline", "trivy", "semgrep", "gitleaks", "zap"], + "baseline": baseline_result, + "tools": tools, + "findings_total": len(open_findings), + "findings_by_severity": by_sev, + "allowlisted": len(allowlisted), + "allowlist_count": count, + "allowlist_baseline": baseline_count, + "over_threshold": gate["over_threshold"], + "gate_rule": gate["rule"], + "gate": "pass" if gate["pass"] else "fail", + "gate_reasons": gate["reasons"], + "notes": notes, + "findings": open_findings, + "exit_code": code, + } + data = mask_secrets(data, secrets) + report.emit(ctx, "scan", data) + if code == exit_codes.SCANNER_UNAVAILABLE and missing is not None: + return report.error(ctx, code, f"{missing.tool}: {missing.detail}") + if code == exit_codes.SERVICES_UNHEALTHY: + return report.error(ctx, code, "run grdm-dev up / grdm-dev health first") + if code == exit_codes.SCAN_GATE_FAILED: + return report.error(ctx, code, "; ".join(gate["reasons"])) + return code diff --git a/installer/build/lib/grdm_dev/secrets.py b/installer/build/lib/grdm_dev/secrets.py new file mode 100644 index 0000000..970ca3d --- /dev/null +++ b/installer/build/lib/grdm_dev/secrets.py @@ -0,0 +1,252 @@ +"""grdm-dev secrets init / secrets rotate — random secrets in runtime/.env (SPEC-02 §3, SPEC-03 §3.1). + +Key list written to runtime/.env. The service templates under templates/.json reference +these keys as `${KEY}`; `compose render` reads runtime/.env and substitutes the values into the +generated Compose file and the rewritten upstream env files. Add a key here first, then use it in +a template (the test suite checks that every key a template references is generated). + +Secret keys (regenerated by `secrets rotate`, never printed, never given a default value): + + POSTGRES_PASSWORD postgres superuser password (upstream default was postgres/postgres) + DJANGO_SECRET_KEY OSF website SECRET_KEY (>= 50 characters) + API_SECRET_KEY OSF api SECRET_KEY + SESSION_COOKIE_SECRET OSF session cookie signing secret + RABBITMQ_DEFAULT_PASS RabbitMQ password for the Celery broker (upstream default was guest) + WATERBUTLER_JWE_SECRET waterbutler <-> OSF JWE secret (upstream default was "changeme") + WATERBUTLER_JWE_SALT waterbutler <-> OSF JWE salt + WATERBUTLER_JWT_SECRET waterbutler <-> OSF JWT secret + WATERBUTLER_HMAC_SECRET waterbutler callback HMAC secret + OSFSTORAGE_HMAC_SECRET osfstorage provider HMAC secret + MFR_SERVER_SECRET mfr <-> OSF shared secret + SHAREJS_SECRET sharejs <-> OSF shared secret + Y_WEBSOCKET_JWT_SECRET y-websocket JWT auth secret (adopted PR RDM-osf.io#797) + CAS_TGC_ENCRYPTION_KEY CAS ticket-granting cookie encryption key + CAS_TGC_SIGNING_KEY CAS ticket-granting cookie signing key + CAS_WEBFLOW_ENCRYPTION_KEY CAS webflow encryption key + CAS_WEBFLOW_SIGNING_KEY CAS webflow signing key + +No Sentry key is written: the developer environment reports no errors to an external service. + +Non-secret keys (written by `init` only when absent, kept by `rotate`): + + GRDM_PROFILE minimum | core | full (SPEC-02 §5) + GRDM_PORT_ default host ports from the SPEC-02 §4 ports table; `compose render` + overwrites a value when it had to remap a busy port + +Behavior: the file is created with mode 0600 inside runtime/ (mode 0700). `init` refuses to overwrite +an existing file without --force (exit 2). `rotate` keeps non-secret keys, regenerates every secret, +and restarts running services through an injectable callable (default: lifecycle.restart). +""" +from __future__ import annotations + +import os +import secrets as _secrets +import stat +import sys +from pathlib import Path + +from . import exit_codes, report +from .context import Context + +SECRET_KEYS: tuple[str, ...] = ( + "POSTGRES_PASSWORD", + "DJANGO_SECRET_KEY", + "API_SECRET_KEY", + "SESSION_COOKIE_SECRET", + "RABBITMQ_DEFAULT_PASS", + "WATERBUTLER_JWE_SECRET", + "WATERBUTLER_JWE_SALT", + "WATERBUTLER_JWT_SECRET", + "WATERBUTLER_HMAC_SECRET", + "OSFSTORAGE_HMAC_SECRET", + "MFR_SERVER_SECRET", + "SHAREJS_SECRET", + "Y_WEBSOCKET_JWT_SECRET", + "CAS_TGC_ENCRYPTION_KEY", + "CAS_TGC_SIGNING_KEY", + "CAS_WEBFLOW_ENCRYPTION_KEY", + "CAS_WEBFLOW_SIGNING_KEY", +) + +# Bytes of randomness per key; token_urlsafe gives ~1.3 characters per byte. Django wants >= 50 chars. +_SECRET_BYTES: dict[str, int] = {"DJANGO_SECRET_KEY": 48, "API_SECRET_KEY": 48} +_DEFAULT_BYTES = 32 + +# SPEC-02 §4 ports table: the only place default host ports are defined; copied here as defaults. +DEFAULT_PORTS: dict[str, int] = { + "web": 5000, + "api": 8000, + "admin": 8001, + "wb": 7777, + "mfr": 7778, + "fakecas": 8080, + "ember_osf_web": 4200, +} + +# Values upstream compose files ship with; SPEC-03 §3.1 forbids them anywhere in runtime/.env. +FORBIDDEN_DEFAULTS: frozenset[str] = frozenset({"postgres", "changeme", "guest", "password", "secret", "osf", ""}) + +DEFAULT_PROFILE = "core" +HEADER = "# generated by grdm-dev secrets init — mode 0600, never commit (SPEC-03 §3.1)\n" + + +def env_path(ctx: Context) -> Path: + return ctx.runtime / ".env" + + +def port_key(service: str) -> str: + return f"GRDM_PORT_{service.upper()}" + + +def generate_secret(key: str) -> str: + return _secrets.token_urlsafe(_SECRET_BYTES.get(key, _DEFAULT_BYTES)) + + +def read_env(path: Path) -> dict[str, str]: + """Parse KEY=value lines (comments and blanks ignored; surrounding quotes stripped).""" + values: dict[str, str] = {} + if not path.exists(): + return values + for raw in path.read_text(encoding="utf-8").splitlines(): + line = raw.strip() + if not line or line.startswith("#") or "=" not in line: + continue + key, _, value = line.partition("=") + key = key.strip() + value = value.strip() + if len(value) >= 2 and value[0] == value[-1] and value[0] in "\"'": + value = value[1:-1] + if key: + values[key] = value + return values + + +def write_env(path: Path, values: dict[str, str]) -> None: + """Write the file atomically with mode 0600 inside a 0700 directory.""" + path.parent.mkdir(parents=True, exist_ok=True) + os.chmod(path.parent, 0o700) + body = HEADER + "".join(f"{k}={v}\n" for k, v in values.items()) + tmp = path.with_name(path.name + ".tmp") + fd = os.open(tmp, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600) + with os.fdopen(fd, "w", encoding="utf-8") as fh: + fh.write(body) + os.chmod(tmp, 0o600) + os.replace(tmp, path) + os.chmod(path, 0o600) + + +def fresh_secrets() -> dict[str, str]: + return {key: generate_secret(key) for key in SECRET_KEYS} + + +def default_non_secrets(profile: str) -> dict[str, str]: + values = {"GRDM_PROFILE": profile} + for service, port in DEFAULT_PORTS.items(): + values[port_key(service)] = str(port) + return values + + +def check_no_defaults(values: dict[str, str]) -> list[str]: + """Return secret keys whose value is a forbidden upstream default or too short.""" + bad = [] + for key in SECRET_KEYS: + v = values.get(key, "") + if v.lower() in FORBIDDEN_DEFAULTS or len(v) < 32: + bad.append(key) + if len(values.get("DJANGO_SECRET_KEY", "")) < 50: + bad.append("DJANGO_SECRET_KEY") + return sorted(set(bad)) + + +def file_mode(path: Path) -> int: + return stat.S_IMODE(path.stat().st_mode) + + +def register(subparsers) -> None: + p = subparsers.add_parser("secrets", help="init: write random secrets to runtime/.env (0600); rotate: regenerate them") + p.set_defaults(_module=sys.modules[__name__], secrets_action=None) + sub = p.add_subparsers(dest="secrets_action", metavar="") + init = sub.add_parser("init", help="create runtime/.env with random secrets; refuses to overwrite without --force") + init.add_argument("--force", action="store_true", help="overwrite an existing runtime/.env") + init.set_defaults(_module=sys.modules[__name__], secrets_action="init") + rot = sub.add_parser("rotate", help="regenerate every secret, keep non-secret keys, restart running services") + rot.set_defaults(_module=sys.modules[__name__], secrets_action="rotate") + + +def run(ctx: Context, args, runner=None, restart=None, running_services=None) -> int: + action = getattr(args, "secrets_action", None) + if action == "init": + return run_init(ctx, force=bool(getattr(args, "force", False))) + if action == "rotate": + return run_rotate(ctx, runner=runner, restart=restart, running_services=running_services) + return report.error(ctx, exit_codes.USAGE, "choose `secrets init` or `secrets rotate`") + + +def _report(ctx: Context, action: str, values: dict[str, str], path: Path, extra: dict | None = None) -> None: + data = { + "action": action, + "path": str(path), + "mode": oct(file_mode(path)), + "profile": values.get("GRDM_PROFILE"), + "secret_keys": [k for k in values if k in SECRET_KEYS], # names only, never values + "non_secret_keys": [k for k in values if k not in SECRET_KEYS], + } + if extra: + data.update(extra) + report.emit(ctx, "secrets", data) + + +def run_init(ctx: Context, force: bool = False) -> int: + path = env_path(ctx) + existing = read_env(path) if path.exists() else {} + if path.exists() and not force: + return report.error( + ctx, exit_codes.USAGE, f"{path} already exists; keep it (idempotent) or pass --force to overwrite" + ) + profile = ctx.profile or existing.get("GRDM_PROFILE") or DEFAULT_PROFILE + values: dict[str, str] = {} + values.update(default_non_secrets(profile)) + # keep non-secret keys that compose render may have written (remapped ports etc.) when forcing + for k, v in existing.items(): + if k not in SECRET_KEYS: + values[k] = v + if ctx.profile: + values["GRDM_PROFILE"] = ctx.profile + values.update(fresh_secrets()) + bad = check_no_defaults(values) + if bad: # cannot happen with token_urlsafe, but SPEC-03 §3.1 says fail rather than write a default + return report.error(ctx, exit_codes.USAGE, "refusing to write default-looking secrets: " + ", ".join(bad)) + write_env(path, values) + _report(ctx, "init", values, path, {"overwritten": bool(existing)}) + return exit_codes.OK + + +def run_rotate(ctx: Context, runner=None, restart=None, running_services=None) -> int: + path = env_path(ctx) + if not path.exists(): + return report.error(ctx, exit_codes.USAGE, f"{path} does not exist; run `grdm-dev secrets init` first") + values = read_env(path) + kept = {k: v for k, v in values.items() if k not in SECRET_KEYS} + new_values = dict(kept) + new_values.update(fresh_secrets()) + write_env(path, new_values) + + restarted: list[str] = [] + if running_services is None or restart is None: + from . import lifecycle # lazy: lifecycle imports health; avoid import cycles at module load + + running_services = running_services or (lambda: lifecycle.running_services(ctx, runner=runner)) + restart = restart or (lambda services: lifecycle.restart(ctx, services, runner=runner)) + try: + running = list(running_services()) + except Exception as exc: # docker absent: rotation still succeeded, just nothing to restart + sys.stderr.write(f"[grdm-dev] secrets rotate: could not list services ({exc}); nothing restarted\n") + running = [] + if running: + rc = restart(running) + if rc != 0: + _report(ctx, "rotate", new_values, path, {"restarted": [], "restart_failed": True}) + return report.error(ctx, exit_codes.HEALTH_FAILED, "services could not be restarted after rotation") + restarted = running + _report(ctx, "rotate", new_values, path, {"restarted": restarted}) + return exit_codes.OK diff --git a/installer/build/lib/grdm_dev/templates/admin.json b/installer/build/lib/grdm_dev/templates/admin.json new file mode 100644 index 0000000..279c40c --- /dev/null +++ b/installer/build/lib/grdm_dev/templates/admin.json @@ -0,0 +1,57 @@ +{ + "service": "admin", + "component": "osf.io", + "profile": "core", + "command": [ + "invoke", + "adminserver", + "-h", + "0.0.0.0" + ], + "environment": { + "DJANGO_SETTINGS_MODULE": "admin.base.settings", + "LANG": "en_US.UTF-8", + "PYTHONUNBUFFERED": "1", + "SECRET_KEY": "${DJANGO_SECRET_KEY}", + "API_SECRET_KEY": "${API_SECRET_KEY}", + "SESSION_COOKIE_SECRET": "${SESSION_COOKIE_SECRET}", + "OSF_DB_PASSWORD": "${POSTGRES_PASSWORD}", + "BROKER_URL": "amqp://grdm:${RABBITMQ_DEFAULT_PASS}@rabbitmq:5672/", + "WATERBUTLER_JWE_SECRET": "${WATERBUTLER_JWE_SECRET}", + "WATERBUTLER_JWE_SALT": "${WATERBUTLER_JWE_SALT}", + "WATERBUTLER_JWT_SECRET": "${WATERBUTLER_JWT_SECRET}", + "MFR_SERVER_SECRET": "${MFR_SERVER_SECRET}", + "SHAREJS_SECRET": "${SHAREJS_SECRET}", + "Y_WEBSOCKET_JWT_SECRET": "${Y_WEBSOCKET_JWT_SECRET}" + }, + "env_files": [ + "osf.env" + ], + "volumes": [ + { + "config": "osf/local.py", + "target": "/code/website/settings/local.py", + "ro": true + }, + { + "config": "osf/api_local.py", + "target": "/code/api/base/settings/local.py", + "ro": true + } + ], + "tmpfs": [ + "/tmp" + ], + "user": "1000:1000", + "depends_on": [ + "postgres", + "rabbitmq", + "elasticsearch" + ], + "weight": 2, + "mem_min_mb": 512, + "pids_limit": 1024, + "container_port": 8001, + "host_port": 8001, + "note": "Upstream also starts crond for rdm_statistics; cron needs root, so it is left to a later milestone (non-root rule, SPEC-03 §3.3)." +} diff --git a/installer/build/lib/grdm_dev/templates/aipf_mcp_data_grdm.json b/installer/build/lib/grdm_dev/templates/aipf_mcp_data_grdm.json new file mode 100644 index 0000000..8b63ab4 --- /dev/null +++ b/installer/build/lib/grdm_dev/templates/aipf_mcp_data_grdm.json @@ -0,0 +1,23 @@ +{ + "service": "aipf_mcp_data_grdm", + "component": "aipf_mcp_data_grdm", + "container_port": 8101, + "expose": [ + 8101 + ], + "environment": { + "OSF_API_URL": "http://api:8000/v2/", + "HOME": "/tmp" + }, + "tmpfs": [ + "/tmp" + ], + "user": "1000:1000", + "depends_on": [ + "api" + ], + "weight": 1, + "mem_min_mb": 256, + "pids_limit": 512, + "note": "Port provisional." +} diff --git a/installer/build/lib/grdm_dev/templates/api.json b/installer/build/lib/grdm_dev/templates/api.json new file mode 100644 index 0000000..e0f3f29 --- /dev/null +++ b/installer/build/lib/grdm_dev/templates/api.json @@ -0,0 +1,56 @@ +{ + "service": "api", + "component": "osf.io", + "profile": "minimum", + "command": [ + "invoke", + "apiserver", + "-h", + "0.0.0.0" + ], + "environment": { + "DJANGO_SETTINGS_MODULE": "api.base.settings", + "LANG": "en_US.UTF-8", + "PYTHONUNBUFFERED": "1", + "SECRET_KEY": "${DJANGO_SECRET_KEY}", + "API_SECRET_KEY": "${API_SECRET_KEY}", + "SESSION_COOKIE_SECRET": "${SESSION_COOKIE_SECRET}", + "OSF_DB_PASSWORD": "${POSTGRES_PASSWORD}", + "BROKER_URL": "amqp://grdm:${RABBITMQ_DEFAULT_PASS}@rabbitmq:5672/", + "WATERBUTLER_JWE_SECRET": "${WATERBUTLER_JWE_SECRET}", + "WATERBUTLER_JWE_SALT": "${WATERBUTLER_JWE_SALT}", + "WATERBUTLER_JWT_SECRET": "${WATERBUTLER_JWT_SECRET}", + "MFR_SERVER_SECRET": "${MFR_SERVER_SECRET}", + "SHAREJS_SECRET": "${SHAREJS_SECRET}", + "Y_WEBSOCKET_JWT_SECRET": "${Y_WEBSOCKET_JWT_SECRET}" + }, + "env_files": [ + "osf.env" + ], + "volumes": [ + { + "config": "osf/local.py", + "target": "/code/website/settings/local.py", + "ro": true + }, + { + "config": "osf/api_local.py", + "target": "/code/api/base/settings/local.py", + "ro": true + } + ], + "tmpfs": [ + "/tmp" + ], + "user": "1000:1000", + "depends_on": [ + "postgres", + "rabbitmq", + "elasticsearch" + ], + "weight": 4, + "mem_min_mb": 512, + "pids_limit": 1024, + "container_port": 8000, + "host_port": 8000 +} diff --git a/installer/build/lib/grdm_dev/templates/cas.json b/installer/build/lib/grdm_dev/templates/cas.json new file mode 100644 index 0000000..2d43d5f --- /dev/null +++ b/installer/build/lib/grdm_dev/templates/cas.json @@ -0,0 +1,33 @@ +{ + "service": "cas", + "component": "cas-overlay", + "container_port": 8080, + "expose": [ + 8080 + ], + "environment": { + "CAS_TGC_ENCRYPTION_KEY": "${CAS_TGC_ENCRYPTION_KEY}", + "CAS_TGC_SIGNING_KEY": "${CAS_TGC_SIGNING_KEY}", + "CAS_WEBFLOW_ENCRYPTION_KEY": "${CAS_WEBFLOW_ENCRYPTION_KEY}", + "CAS_WEBFLOW_SIGNING_KEY": "${CAS_WEBFLOW_SIGNING_KEY}", + "DATABASE_PASSWORD": "${POSTGRES_PASSWORD}" + }, + "volumes": [ + { + "config": "cas/cas.properties", + "target": "/code/etc/cas.properties", + "ro": true + } + ], + "tmpfs": [ + "/tmp" + ], + "user": "1000:1000", + "depends_on": [ + "postgres" + ], + "weight": 2, + "mem_min_mb": 512, + "pids_limit": 512, + "note": "Uses database `cas` on the shared postgres (created by config/postgres-init). Not published on the host while fakecas is the auth provider." +} diff --git a/installer/build/lib/grdm_dev/templates/elasticsearch.json b/installer/build/lib/grdm_dev/templates/elasticsearch.json new file mode 100644 index 0000000..956dc5c --- /dev/null +++ b/installer/build/lib/grdm_dev/templates/elasticsearch.json @@ -0,0 +1,22 @@ +{ + "service": "elasticsearch", + "component": "elasticsearch2", + "expose": [ + 9200 + ], + "environment": { + "ES_HEAP_SIZE": "512m" + }, + "volumes": [ + { + "volume": "elasticsearch_data", + "target": "/usr/share/elasticsearch/data" + } + ], + "tmpfs": [ + "/tmp" + ], + "weight": 3, + "mem_min_mb": 1024, + "pids_limit": 1024 +} diff --git a/installer/build/lib/grdm_dev/templates/elasticsearch6.json b/installer/build/lib/grdm_dev/templates/elasticsearch6.json new file mode 100644 index 0000000..51c4638 --- /dev/null +++ b/installer/build/lib/grdm_dev/templates/elasticsearch6.json @@ -0,0 +1,25 @@ +{ + "service": "elasticsearch6", + "component": "elasticsearch6", + "expose": [ + 9200 + ], + "environment": { + "discovery.type": "single-node", + "ES_JAVA_OPTS": "-Xms512m -Xmx512m", + "xpack.security.enabled": "false" + }, + "volumes": [ + { + "volume": "elasticsearch6_data", + "target": "/usr/share/elasticsearch/data" + } + ], + "tmpfs": [ + "/tmp" + ], + "user": "1000:1000", + "weight": 3, + "mem_min_mb": 1024, + "pids_limit": 1024 +} diff --git a/installer/build/lib/grdm_dev/templates/ember_osf_web.json b/installer/build/lib/grdm_dev/templates/ember_osf_web.json new file mode 100644 index 0000000..974d70f --- /dev/null +++ b/installer/build/lib/grdm_dev/templates/ember_osf_web.json @@ -0,0 +1,37 @@ +{ + "service": "ember_osf_web", + "component": "ember-osf-web", + "command": [ + "/bin/sh", + "-c", + "yarn --frozen-lockfile && yarn start --host 0.0.0.0 --port 4200 --live-reload-port 41953" + ], + "container_port": 4200, + "host_port": 4200, + "expose": [ + 41953 + ], + "environment": { + "BACKEND": "local", + "YARN_CACHE_FOLDER": "/tmp/yarn-cache", + "HOME": "/tmp" + }, + "volumes": [ + { + "volume": "ember_osf_web_dist", + "target": "/code/dist" + } + ], + "tmpfs": [ + "/tmp" + ], + "user": "1000:1000", + "depends_on": [ + "api", + "web" + ], + "weight": 3, + "mem_min_mb": 1024, + "pids_limit": 1024, + "note": "Live-reload port 41953 is reachable inside the network only; publishing it is not in the SPEC-02 §4 table." +} diff --git a/installer/build/lib/grdm_dev/templates/fakecas.json b/installer/build/lib/grdm_dev/templates/fakecas.json new file mode 100644 index 0000000..eb0c7bc --- /dev/null +++ b/installer/build/lib/grdm_dev/templates/fakecas.json @@ -0,0 +1,20 @@ +{ + "service": "fakecas", + "component": "fakecas", + "profile": "minimum", + "container_port": 8080, + "host_port": 8080, + "command": [ + "fakecas", + "-host=0.0.0.0:8080", + "-osfhost=127.0.0.1:{{HOST_PORT:web}}", + "-dbaddress=postgres://postgres:${POSTGRES_PASSWORD}@postgres:5432/osf?sslmode=disable" + ], + "user": "65534:65534", + "depends_on": [ + "postgres" + ], + "weight": 0.5, + "mem_min_mb": 64, + "pids_limit": 128 +} diff --git a/installer/build/lib/grdm_dev/templates/mfr.json b/installer/build/lib/grdm_dev/templates/mfr.json new file mode 100644 index 0000000..698763c --- /dev/null +++ b/installer/build/lib/grdm_dev/templates/mfr.json @@ -0,0 +1,30 @@ +{ + "service": "mfr", + "component": "modular-file-renderer", + "command": [ + "invoke", + "server" + ], + "container_port": 7778, + "host_port": 7778, + "environment": { + "PYTHONUNBUFFERED": "1", + "SERVER_CONFIG_HMAC_SECRET": "${MFR_SERVER_SECRET}" + }, + "env_files": [ + "mfr.env" + ], + "volumes": [ + { + "volume": "wb_tmp", + "target": "/tmp" + } + ], + "user": "1000:1000", + "depends_on": [ + "unoconv" + ], + "weight": 2, + "mem_min_mb": 256, + "pids_limit": 512 +} diff --git a/installer/build/lib/grdm_dev/templates/mongo.json b/installer/build/lib/grdm_dev/templates/mongo.json new file mode 100644 index 0000000..84ec02d --- /dev/null +++ b/installer/build/lib/grdm_dev/templates/mongo.json @@ -0,0 +1,24 @@ +{ + "service": "mongo", + "component": "mongo", + "expose": [ + 27017 + ], + "command": [ + "/bin/bash", + "-c", + "openssl req -newkey rsa:2048 -new -x509 -days 9999 -nodes -subj '/C=JP/ST=Tokyo/L=Chiyoda/O=NII/OU=GRDM dev/CN=mongo' -out /etc/ssl/mongodb.crt -keyout /etc/ssl/mongodb.key && cat /etc/ssl/mongodb.key /etc/ssl/mongodb.crt > /etc/ssl/mongodb.pem && chown -R mongodb:mongodb /etc/ssl /data/db && chmod -R 0600 /etc/ssl/* && gosu mongodb mongod --sslMode requireSSL --sslDisabledProtocols=TLS1_0,TLS1_1 --sslPEMKeyFile /etc/ssl/mongodb.pem" + ], + "volumes": [ + { + "volume": "mongo_data", + "target": "/data/db" + } + ], + "tmpfs": [ + "/tmp" + ], + "weight": 1, + "mem_min_mb": 256, + "pids_limit": 512 +} diff --git a/installer/build/lib/grdm_dev/templates/oasys.json b/installer/build/lib/grdm_dev/templates/oasys.json new file mode 100644 index 0000000..39aec6e --- /dev/null +++ b/installer/build/lib/grdm_dev/templates/oasys.json @@ -0,0 +1,25 @@ +{ + "service": "oasys", + "component": "OASys", + "container_port": 3100, + "expose": [ + 3100 + ], + "environment": { + "NODE_ENV": "development", + "PORT": "3100", + "OSF_URL": "http://127.0.0.1:{{HOST_PORT:web}}", + "HOME": "/tmp" + }, + "tmpfs": [ + "/tmp" + ], + "user": "1000:1000", + "depends_on": [ + "web" + ], + "weight": 2, + "mem_min_mb": 512, + "pids_limit": 512, + "note": "Port provisional." +} diff --git a/installer/build/lib/grdm_dev/templates/postgres.json b/installer/build/lib/grdm_dev/templates/postgres.json new file mode 100644 index 0000000..a1a6eb0 --- /dev/null +++ b/installer/build/lib/grdm_dev/templates/postgres.json @@ -0,0 +1,31 @@ +{ + "service": "postgres", + "component": "postgres", + "expose": [ + 5432 + ], + "environment": { + "POSTGRES_DB": "osf", + "POSTGRES_USER": "postgres", + "POSTGRES_PASSWORD": "${POSTGRES_PASSWORD}", + "POSTGRES_INITDB_ARGS": "--auth-host=scram-sha-256 --auth-local=trust" + }, + "volumes": [ + { + "volume": "postgres_data", + "target": "/var/lib/postgresql/data" + }, + { + "config_dir": "postgres-init", + "target": "/docker-entrypoint-initdb.d", + "ro": true + } + ], + "tmpfs": [ + "/tmp", + "/var/run/postgresql" + ], + "weight": 3, + "mem_min_mb": 512, + "pids_limit": 1024 +} diff --git a/installer/build/lib/grdm_dev/templates/rabbitmq.json b/installer/build/lib/grdm_dev/templates/rabbitmq.json new file mode 100644 index 0000000..ffe0f2e --- /dev/null +++ b/installer/build/lib/grdm_dev/templates/rabbitmq.json @@ -0,0 +1,24 @@ +{ + "service": "rabbitmq", + "component": "rabbitmq", + "expose": [ + 5672, + 15672 + ], + "environment": { + "RABBITMQ_DEFAULT_USER": "grdm", + "RABBITMQ_DEFAULT_PASS": "${RABBITMQ_DEFAULT_PASS}" + }, + "volumes": [ + { + "volume": "rabbitmq_data", + "target": "/var/lib/rabbitmq" + } + ], + "tmpfs": [ + "/tmp" + ], + "weight": 1, + "mem_min_mb": 256, + "pids_limit": 1024 +} diff --git a/installer/build/lib/grdm_dev/templates/rdmcp.json b/installer/build/lib/grdm_dev/templates/rdmcp.json new file mode 100644 index 0000000..e0ec499 --- /dev/null +++ b/installer/build/lib/grdm_dev/templates/rdmcp.json @@ -0,0 +1,23 @@ +{ + "service": "rdmcp", + "component": "rdmcp", + "container_port": 8100, + "expose": [ + 8100 + ], + "environment": { + "OSF_API_URL": "http://api:8000/v2/", + "HOME": "/tmp" + }, + "tmpfs": [ + "/tmp" + ], + "user": "1000:1000", + "depends_on": [ + "api" + ], + "weight": 1, + "mem_min_mb": 256, + "pids_limit": 512, + "note": "Port provisional." +} diff --git a/installer/build/lib/grdm_dev/templates/redis.json b/installer/build/lib/grdm_dev/templates/redis.json new file mode 100644 index 0000000..e19ec7d --- /dev/null +++ b/installer/build/lib/grdm_dev/templates/redis.json @@ -0,0 +1,28 @@ +{ + "service": "redis", + "component": "redis", + "expose": [ + 6379 + ], + "command": [ + "redis-server", + "--save", + "60", + "1", + "--appendonly", + "no" + ], + "volumes": [ + { + "volume": "redis_data", + "target": "/data" + } + ], + "tmpfs": [ + "/tmp" + ], + "user": "999:999", + "weight": 1, + "mem_min_mb": 128, + "pids_limit": 256 +} diff --git a/installer/build/lib/grdm_dev/templates/sharejs.json b/installer/build/lib/grdm_dev/templates/sharejs.json new file mode 100644 index 0000000..c0b7d93 --- /dev/null +++ b/installer/build/lib/grdm_dev/templates/sharejs.json @@ -0,0 +1,24 @@ +{ + "service": "sharejs", + "component": "sharejs", + "expose": [ + 7007 + ], + "env_files": [ + "sharejs.env" + ], + "environment": { + "SHAREJS_COOKIE_SECRET": "${SHAREJS_SECRET}" + }, + "tmpfs": [ + "/tmp" + ], + "user": "1000:1000", + "depends_on": [ + "mongo", + "web" + ], + "weight": 1, + "mem_min_mb": 128, + "pids_limit": 256 +} diff --git a/installer/build/lib/grdm_dev/templates/shibboleth_sp.json b/installer/build/lib/grdm_dev/templates/shibboleth_sp.json new file mode 100644 index 0000000..9c4620c --- /dev/null +++ b/installer/build/lib/grdm_dev/templates/shibboleth_sp.json @@ -0,0 +1,25 @@ +{ + "service": "shibboleth_sp", + "component": "Shibboleth-SP", + "container_port": 443, + "expose": [ + 443, + 80 + ], + "environment": { + "OSF_INTERNAL_URL": "http://web:5000/" + }, + "tmpfs": [ + "/tmp", + "/run", + "/var/run" + ], + "depends_on": [ + "web", + "test_idp" + ], + "weight": 1, + "mem_min_mb": 256, + "pids_limit": 512, + "note": "Apache + shibd on a CentOS base run as root; exceptions in manifest/hardening.json. Replaces fakecas with --auth shibboleth." +} diff --git a/installer/build/lib/grdm_dev/templates/test_idp.json b/installer/build/lib/grdm_dev/templates/test_idp.json new file mode 100644 index 0000000..8577830 --- /dev/null +++ b/installer/build/lib/grdm_dev/templates/test_idp.json @@ -0,0 +1,17 @@ +{ + "service": "test_idp", + "component": "Shibboleth-SP", + "container_port": 8443, + "expose": [ + 8443 + ], + "tmpfs": [ + "/tmp", + "/run", + "/var/run" + ], + "weight": 1, + "mem_min_mb": 256, + "pids_limit": 512, + "note": "Bundled test IdP for acceptance; runs as root until the image is rebuilt (hardening.json)." +} diff --git a/installer/build/lib/grdm_dev/templates/unoconv.json b/installer/build/lib/grdm_dev/templates/unoconv.json new file mode 100644 index 0000000..b596cc4 --- /dev/null +++ b/installer/build/lib/grdm_dev/templates/unoconv.json @@ -0,0 +1,25 @@ +{ + "service": "unoconv", + "component": "unoconv", + "expose": [ + 2002 + ], + "command": [ + "/bin/bash", + "-c", + "/usr/bin/python3.7 /usr/local/bin/unoconv --listener --server=0.0.0.0 --port=2002 -vvv" + ], + "environment": { + "UNO_PATH": "/usr/lib/libreoffice", + "HOME": "/tmp" + }, + "volumes": [ + { + "volume": "wb_tmp", + "target": "/tmp" + } + ], + "weight": 2, + "mem_min_mb": 512, + "pids_limit": 512 +} diff --git a/installer/build/lib/grdm_dev/templates/wb.json b/installer/build/lib/grdm_dev/templates/wb.json new file mode 100644 index 0000000..e4ffddc --- /dev/null +++ b/installer/build/lib/grdm_dev/templates/wb.json @@ -0,0 +1,39 @@ +{ + "service": "wb", + "component": "waterbutler", + "command": [ + "invoke", + "server" + ], + "container_port": 7777, + "host_port": 7777, + "environment": { + "PYTHONUNBUFFERED": "1", + "SERVER_CONFIG_HMAC_SECRET": "${WATERBUTLER_HMAC_SECRET:-${WATERBUTLER_JWT_SECRET}}", + "OSF_AUTH_CONFIG_JWE_SALT": "${WATERBUTLER_JWE_SALT}", + "OSF_AUTH_CONFIG_JWE_SECRET": "${WATERBUTLER_JWE_SECRET}", + "OSF_AUTH_CONFIG_JWT_SECRET": "${WATERBUTLER_JWT_SECRET}", + "OSFSTORAGE_PROVIDER_CONFIG_HMAC_SECRET": "${OSFSTORAGE_HMAC_SECRET:-${WATERBUTLER_JWT_SECRET}}", + "TASKS_CONFIG_BROKER_URL": "amqp://grdm:${RABBITMQ_DEFAULT_PASS}@rabbitmq:5672//" + }, + "depends_on": [ + "rabbitmq" + ], + "weight": 2, + "env_files": [ + "wb.env" + ], + "volumes": [ + { + "volume": "osfstoragecache", + "target": "/code/website/osfstoragecache" + }, + { + "volume": "wb_tmp", + "target": "/tmp" + } + ], + "user": "1000:1000", + "mem_min_mb": 256, + "pids_limit": 512 +} diff --git a/installer/build/lib/grdm_dev/templates/wb_worker.json b/installer/build/lib/grdm_dev/templates/wb_worker.json new file mode 100644 index 0000000..f6cbc06 --- /dev/null +++ b/installer/build/lib/grdm_dev/templates/wb_worker.json @@ -0,0 +1,38 @@ +{ + "service": "wb_worker", + "component": "waterbutler", + "command": [ + "invoke", + "celery" + ], + "environment": { + "PYTHONUNBUFFERED": "1", + "SERVER_CONFIG_HMAC_SECRET": "${WATERBUTLER_HMAC_SECRET:-${WATERBUTLER_JWT_SECRET}}", + "OSF_AUTH_CONFIG_JWE_SALT": "${WATERBUTLER_JWE_SALT}", + "OSF_AUTH_CONFIG_JWE_SECRET": "${WATERBUTLER_JWE_SECRET}", + "OSF_AUTH_CONFIG_JWT_SECRET": "${WATERBUTLER_JWT_SECRET}", + "OSFSTORAGE_PROVIDER_CONFIG_HMAC_SECRET": "${OSFSTORAGE_HMAC_SECRET:-${WATERBUTLER_JWT_SECRET}}", + "TASKS_CONFIG_BROKER_URL": "amqp://grdm:${RABBITMQ_DEFAULT_PASS}@rabbitmq:5672//" + }, + "depends_on": [ + "wb", + "rabbitmq" + ], + "weight": 2, + "env_files": [ + "wb.env" + ], + "volumes": [ + { + "volume": "osfstoragecache", + "target": "/code/website/osfstoragecache" + }, + { + "volume": "wb_tmp", + "target": "/tmp" + } + ], + "user": "1000:1000", + "mem_min_mb": 256, + "pids_limit": 512 +} diff --git a/installer/build/lib/grdm_dev/templates/web.json b/installer/build/lib/grdm_dev/templates/web.json new file mode 100644 index 0000000..f72389e --- /dev/null +++ b/installer/build/lib/grdm_dev/templates/web.json @@ -0,0 +1,62 @@ +{ + "service": "web", + "component": "osf.io", + "profile": "minimum", + "command": [ + "invoke", + "server", + "-h", + "0.0.0.0" + ], + "environment": { + "DJANGO_SETTINGS_MODULE": "api.base.settings", + "LANG": "en_US.UTF-8", + "PYTHONUNBUFFERED": "1", + "SECRET_KEY": "${DJANGO_SECRET_KEY}", + "API_SECRET_KEY": "${API_SECRET_KEY}", + "SESSION_COOKIE_SECRET": "${SESSION_COOKIE_SECRET}", + "OSF_DB_PASSWORD": "${POSTGRES_PASSWORD}", + "BROKER_URL": "amqp://grdm:${RABBITMQ_DEFAULT_PASS}@rabbitmq:5672/", + "WATERBUTLER_JWE_SECRET": "${WATERBUTLER_JWE_SECRET}", + "WATERBUTLER_JWE_SALT": "${WATERBUTLER_JWE_SALT}", + "WATERBUTLER_JWT_SECRET": "${WATERBUTLER_JWT_SECRET}", + "MFR_SERVER_SECRET": "${MFR_SERVER_SECRET}", + "SHAREJS_SECRET": "${SHAREJS_SECRET}", + "Y_WEBSOCKET_JWT_SECRET": "${Y_WEBSOCKET_JWT_SECRET}", + "SHAREJS_SERVER_HOST": "sharejs", + "SHAREJS_SERVER_PORT": "7007" + }, + "env_files": [ + "osf.env" + ], + "volumes": [ + { + "config": "osf/local.py", + "target": "/code/website/settings/local.py", + "ro": true + }, + { + "config": "osf/api_local.py", + "target": "/code/api/base/settings/local.py", + "ro": true + }, + { + "volume": "ember_osf_web_dist", + "target": "/ember_osf_web" + } + ], + "tmpfs": [ + "/tmp" + ], + "user": "1000:1000", + "depends_on": [ + "postgres", + "rabbitmq", + "elasticsearch" + ], + "weight": 4, + "mem_min_mb": 512, + "pids_limit": 1024, + "container_port": 5000, + "host_port": 5000 +} diff --git a/installer/build/lib/grdm_dev/templates/wiki.json b/installer/build/lib/grdm_dev/templates/wiki.json new file mode 100644 index 0000000..9aceb27 --- /dev/null +++ b/installer/build/lib/grdm_dev/templates/wiki.json @@ -0,0 +1,28 @@ +{ + "service": "wiki", + "component": "wiki-frontend", + "container_port": 3000, + "expose": [ + 3000 + ], + "environment": { + "NODE_ENV": "development", + "HOST": "0.0.0.0", + "PORT": "3000", + "OSF_URL": "http://127.0.0.1:{{HOST_PORT:web}}", + "Y_WEBSOCKET_URL": "ws://y_websocket:1234", + "HOME": "/tmp" + }, + "tmpfs": [ + "/tmp" + ], + "user": "1000:1000", + "depends_on": [ + "web", + "y_websocket" + ], + "weight": 1, + "mem_min_mb": 256, + "pids_limit": 512, + "note": "Container port and variable names are provisional until the integration repository documents them." +} diff --git a/installer/build/lib/grdm_dev/templates/worker.json b/installer/build/lib/grdm_dev/templates/worker.json new file mode 100644 index 0000000..c6012ef --- /dev/null +++ b/installer/build/lib/grdm_dev/templates/worker.json @@ -0,0 +1,52 @@ +{ + "service": "worker", + "component": "osf.io", + "profile": "core", + "command": [ + "invoke", + "celery_worker" + ], + "environment": { + "DJANGO_SETTINGS_MODULE": "api.base.settings", + "LANG": "en_US.UTF-8", + "PYTHONUNBUFFERED": "1", + "SECRET_KEY": "${DJANGO_SECRET_KEY}", + "API_SECRET_KEY": "${API_SECRET_KEY}", + "SESSION_COOKIE_SECRET": "${SESSION_COOKIE_SECRET}", + "OSF_DB_PASSWORD": "${POSTGRES_PASSWORD}", + "BROKER_URL": "amqp://grdm:${RABBITMQ_DEFAULT_PASS}@rabbitmq:5672/", + "WATERBUTLER_JWE_SECRET": "${WATERBUTLER_JWE_SECRET}", + "WATERBUTLER_JWE_SALT": "${WATERBUTLER_JWE_SALT}", + "WATERBUTLER_JWT_SECRET": "${WATERBUTLER_JWT_SECRET}", + "MFR_SERVER_SECRET": "${MFR_SERVER_SECRET}", + "SHAREJS_SECRET": "${SHAREJS_SECRET}", + "Y_WEBSOCKET_JWT_SECRET": "${Y_WEBSOCKET_JWT_SECRET}" + }, + "env_files": [ + "osf.env" + ], + "volumes": [ + { + "config": "osf/local.py", + "target": "/code/website/settings/local.py", + "ro": true + }, + { + "config": "osf/api_local.py", + "target": "/code/api/base/settings/local.py", + "ro": true + } + ], + "tmpfs": [ + "/tmp" + ], + "user": "1000:1000", + "depends_on": [ + "postgres", + "rabbitmq", + "elasticsearch" + ], + "weight": 3, + "mem_min_mb": 512, + "pids_limit": 1024 +} diff --git a/installer/build/lib/grdm_dev/templates/y_websocket.json b/installer/build/lib/grdm_dev/templates/y_websocket.json new file mode 100644 index 0000000..8a27f24 --- /dev/null +++ b/installer/build/lib/grdm_dev/templates/y_websocket.json @@ -0,0 +1,24 @@ +{ + "service": "y_websocket", + "component": "y-websocket", + "container_port": 1234, + "expose": [ + 1234 + ], + "environment": { + "HOST": "0.0.0.0", + "PORT": "1234", + "JWT_SECRET": "${Y_WEBSOCKET_JWT_SECRET}", + "HOME": "/tmp" + }, + "tmpfs": [ + "/tmp" + ], + "user": "1000:1000", + "depends_on": [ + "web" + ], + "weight": 1, + "mem_min_mb": 128, + "pids_limit": 256 +} diff --git a/installer/build/lib/grdm_dev/toon.py b/installer/build/lib/grdm_dev/toon.py new file mode 100644 index 0000000..b843b7b --- /dev/null +++ b/installer/build/lib/grdm_dev/toon.py @@ -0,0 +1,73 @@ +"""Minimal TOON (Token-Oriented Object Notation) encoder for reports (SPEC-06 §4). + +Encodes JSON-compatible data: dicts become `key: value` lines, lists of flat dicts with the same +keys become tabular arrays `name[N]{k1,k2}:` followed by CSV rows, other lists become `- item` +lines. Strings containing a delimiter (`,` `:` `"` newline) or surrounding spaces are quoted. +The encoder is deliberately small; it is not a full TOON implementation. +""" +from __future__ import annotations + +import json +from typing import Any + +_DELIMS = (",", ":", '"', "\n", "[", "]", "{", "}") + + +def _scalar(v: Any) -> str: + if v is None: + return "null" + if isinstance(v, bool): + return "true" if v else "false" + if isinstance(v, (int, float)): + return json.dumps(v) + s = str(v) + if s == "" or s != s.strip() or any(d in s for d in _DELIMS) or s in ("true", "false", "null"): + return json.dumps(s, ensure_ascii=False) + return s + + +def _is_table(items: list) -> bool: + if not items or not all(isinstance(i, dict) for i in items): + return False + keys = list(items[0].keys()) + return all(list(i.keys()) == keys for i in items) and all( + not isinstance(v, (dict, list)) for i in items for v in i.values() + ) + + +def encode(data: Any, indent: int = 0, name: str | None = None) -> str: + pad = " " * indent + out: list[str] = [] + if isinstance(data, dict): + if name is not None: + out.append(f"{pad}{name}:") + indent += 1 + pad = " " * indent + for k, v in data.items(): + if isinstance(v, (dict, list)): + out.append(encode(v, indent, k)) + else: + out.append(f"{pad}{k}: {_scalar(v)}") + return "\n".join(out) + if isinstance(data, list): + label = name if name is not None else "items" + if _is_table(data): + keys = list(data[0].keys()) + out.append(f"{pad}{label}[{len(data)}]{{{','.join(keys)}}}:") + for row in data: + out.append(pad + " " + ",".join(_scalar(row[k]) for k in keys)) + return "\n".join(out) + out.append(f"{pad}{label}[{len(data)}]:") + for item in data: + if isinstance(item, (dict, list)): + # "- " occupies the first two columns of the item; continuation lines align with + # the text after the dash (one indent level deeper than the dash itself). + sub = encode(item, indent + 2) + first, _, rest = sub.partition("\n") + out.append(pad + " - " + first.strip()) + if rest: + out.append(rest) + else: + out.append(pad + " - " + _scalar(item)) + return "\n".join(out) + return f"{pad}{name + ': ' if name else ''}{_scalar(data)}" diff --git a/installer/build/lib/grdm_dev/upstream.py b/installer/build/lib/grdm_dev/upstream.py new file mode 100644 index 0000000..98f06f4 --- /dev/null +++ b/installer/build/lib/grdm_dev/upstream.py @@ -0,0 +1,32 @@ +"""grdm-dev upstream mirror | integrate — placeholder for SPEC-05 upstream tracking. + +Not implemented in M2. The daily mirror and the weekly integration are specified in +docs/spec/05_upstream_tracking.md and need Git credentials for the private -dev2027 repositories, +so they never run in this repository's CI (SPEC-02 §3). Both subcommands exit 2 with that message +until the SPEC-05 implementation lands. +""" +from __future__ import annotations + +import sys + +from . import exit_codes +from .context import Context + +NOT_IMPLEMENTED = ( + "grdm-dev upstream {action} is not implemented in M2; see docs/spec/05_upstream_tracking.md " + "(SPEC-05) for the mirror / integrate procedure to run by hand." +) + + +def register(subparsers) -> None: + p = subparsers.add_parser("upstream", help="daily mirror / weekly integration of SPEC-05 (not implemented in M2)") + sub = p.add_subparsers(dest="upstream_action", metavar="") + sub.add_parser("mirror", help="mirror upstream branches into the -dev2027 repositories (SPEC-05)") + sub.add_parser("integrate", help="weekly integration merge (SPEC-05)") + p.set_defaults(_module=sys.modules[__name__]) + + +def run(ctx: Context, args) -> int: + action = getattr(args, "upstream_action", None) or "" + sys.stderr.write("[grdm-dev] exit 2: " + NOT_IMPLEMENTED.format(action=action) + "\n") + return exit_codes.USAGE diff --git a/installer/grdm_dev.egg-info/PKG-INFO b/installer/grdm_dev.egg-info/PKG-INFO new file mode 100644 index 0000000..fdeed52 --- /dev/null +++ b/installer/grdm_dev.egg-info/PKG-INFO @@ -0,0 +1,74 @@ +Metadata-Version: 2.4 +Name: grdm-dev +Version: 0.1.0 +Summary: GakuNin RDM developer environment 2027: one-command installer (SPEC-02) +License-Expression: MIT +Requires-Python: >=3.11 +Description-Content-Type: text/markdown +Provides-Extra: accept +Requires-Dist: pytest>=8; extra == "accept" +Requires-Dist: pytest-playwright>=0.5; extra == "accept" +Requires-Dist: playwright>=1.47; extra == "accept" +Provides-Extra: docs +Requires-Dist: mkdocs==1.6.1; extra == "docs" +Requires-Dist: mkdocs-material==9.5.37; extra == "docs" +Requires-Dist: pymdown-extensions==10.12; extra == "docs" + +# grdm-dev Installer / インストーラー + +> **Summary:** The Python package behind `./installer/install.sh`. One subcommand per module; standard library only. Normative text is [SPEC-02](../docs/spec/02_installer_cli.md). +> **概要:** `./installer/install.sh` の裏側にある Python パッケージ。モジュールごとに 1 サブコマンド、標準ライブラリのみ。規範は [SPEC-02](../docs/spec/02_installer_cli.md)。 + +**Jump:** [English](#english) · [日本語](#japanese) + +- Version / 版: 0.1 — 2026-11-05. **Learned:** the module contract (`register`/`run`, injectable runner) had to be fixed before several people could implement subcommands in parallel without stepping on each other. / 複数人が同時にサブコマンドを実装してもぶつからないよう、モジュールの契約(`register`/`run`、差し替え可能な runner)を先に固定する必要があると分かった。 +- Related: [docs/README.md](../docs/README.md) · [SPEC-02](../docs/spec/02_installer_cli.md) · [SPEC-04](../docs/spec/04_acceptance_tests.md) + +--- + + +## English + +[→ 日本語版へ](#japanese) + +### Layout + +See [SPEC-02 §9](../docs/spec/02_installer_cli.md). Shared parts: `cli.py` (parsing, dispatch), `context.py` (root, runtime/, `--yes`, confirm), `exit_codes.py` + `messages.tsv` (one table for bash and Python), `toon.py` (report encoder), `report.py` (`emit`, `error`). + +### Module contract + +```python +def register(subparsers): ... # add a sub-parser; call set_defaults(_module=sys.modules[__name__]) +def run(ctx, args) -> int: ... # return a code from grdm_dev.exit_codes +``` + +Modules that call external tools take an injectable `runner` so unit tests never need Docker. Run tests with `python3 -m unittest discover -s installer/tests` from the repository root (set `PYTHONPATH=installer` or `pip install -e installer`). + +--- + + +## 日本語 + +[→ To English](#english) + +### 構成 + +[SPEC-02 §9](../docs/spec/02_installer_cli.md) を参照。共通部品: `cli.py`(解析と振り分け)、`context.py`(ルート、runtime/、`--yes`、確認)、`exit_codes.py` と `messages.tsv`(bash と Python が同じ表を使う)、`toon.py`(報告の符号化)、`report.py`(`emit`、`error`)。 + +### モジュールの契約 + +```python +def register(subparsers): ... # サブパーサを追加し set_defaults(_module=sys.modules[__name__]) を呼ぶ +def run(ctx, args) -> int: ... # grdm_dev.exit_codes の値を返す +``` + +外部の道具を呼ぶモジュールは差し替え可能な `runner` を受け取り、単体テストで Docker を要らなくする。テストはリポジトリのルートで `python3 -m unittest discover -s installer/tests`(`PYTHONPATH=installer` か `pip install -e installer`)。 + +--- + +## Glossary / 用語 + +| Term | English note | 日本語注 | +|---|---|---| +| Subcommand | A word after the command that picks what to do, like `doctor` in `grdm-dev doctor`. | コマンドの後ろに付けて何をするか選ぶ言葉。`grdm-dev doctor` の `doctor`。 | +| Runner | A small function that runs another program; tests swap it for a fake. | 別のプログラムを実行する小さな関数。テストでは偽物に差し替える。 | diff --git a/installer/grdm_dev.egg-info/SOURCES.txt b/installer/grdm_dev.egg-info/SOURCES.txt new file mode 100644 index 0000000..f50d0a4 --- /dev/null +++ b/installer/grdm_dev.egg-info/SOURCES.txt @@ -0,0 +1,75 @@ +README.md +pyproject.toml +grdm_dev/__init__.py +grdm_dev/accept.py +grdm_dev/build.py +grdm_dev/cli.py +grdm_dev/compose.py +grdm_dev/context.py +grdm_dev/docs.py +grdm_dev/doctor.py +grdm_dev/exit_codes.py +grdm_dev/health.py +grdm_dev/host.py +grdm_dev/install.py +grdm_dev/lifecycle.py +grdm_dev/manifest.py +grdm_dev/manifest_cmd.py +grdm_dev/messages.tsv +grdm_dev/plan.py +grdm_dev/redteam.py +grdm_dev/report.py +grdm_dev/report_cmd.py +grdm_dev/scan.py +grdm_dev/secrets.py +grdm_dev/toon.py +grdm_dev/upstream.py +grdm_dev.egg-info/PKG-INFO +grdm_dev.egg-info/SOURCES.txt +grdm_dev.egg-info/dependency_links.txt +grdm_dev.egg-info/entry_points.txt +grdm_dev.egg-info/requires.txt +grdm_dev.egg-info/top_level.txt +grdm_dev/templates/admin.json +grdm_dev/templates/aipf_mcp_data_grdm.json +grdm_dev/templates/api.json +grdm_dev/templates/cas.json +grdm_dev/templates/elasticsearch.json +grdm_dev/templates/elasticsearch6.json +grdm_dev/templates/ember_osf_web.json +grdm_dev/templates/fakecas.json +grdm_dev/templates/mfr.json +grdm_dev/templates/mongo.json +grdm_dev/templates/oasys.json +grdm_dev/templates/postgres.json +grdm_dev/templates/rabbitmq.json +grdm_dev/templates/rdmcp.json +grdm_dev/templates/redis.json +grdm_dev/templates/sharejs.json +grdm_dev/templates/shibboleth_sp.json +grdm_dev/templates/test_idp.json +grdm_dev/templates/unoconv.json +grdm_dev/templates/wb.json +grdm_dev/templates/wb_worker.json +grdm_dev/templates/web.json +grdm_dev/templates/wiki.json +grdm_dev/templates/worker.json +grdm_dev/templates/y_websocket.json +tests/test_accept.py +tests/test_build.py +tests/test_cli_skeleton.py +tests/test_compose.py +tests/test_docs.py +tests/test_doctor.py +tests/test_health.py +tests/test_host.py +tests/test_install.py +tests/test_install_sh.py +tests/test_lifecycle.py +tests/test_manifest.py +tests/test_manifest_cmd.py +tests/test_plan.py +tests/test_redteam.py +tests/test_report_cmd.py +tests/test_scan.py +tests/test_secrets.py \ No newline at end of file diff --git a/installer/grdm_dev.egg-info/dependency_links.txt b/installer/grdm_dev.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/installer/grdm_dev.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/installer/grdm_dev.egg-info/entry_points.txt b/installer/grdm_dev.egg-info/entry_points.txt new file mode 100644 index 0000000..f1eef46 --- /dev/null +++ b/installer/grdm_dev.egg-info/entry_points.txt @@ -0,0 +1,2 @@ +[console_scripts] +grdm-dev = grdm_dev.cli:main diff --git a/installer/grdm_dev.egg-info/requires.txt b/installer/grdm_dev.egg-info/requires.txt new file mode 100644 index 0000000..c2b030f --- /dev/null +++ b/installer/grdm_dev.egg-info/requires.txt @@ -0,0 +1,10 @@ + +[accept] +pytest>=8 +pytest-playwright>=0.5 +playwright>=1.47 + +[docs] +mkdocs==1.6.1 +mkdocs-material==9.5.37 +pymdown-extensions==10.12 diff --git a/installer/grdm_dev.egg-info/top_level.txt b/installer/grdm_dev.egg-info/top_level.txt new file mode 100644 index 0000000..5e7722f --- /dev/null +++ b/installer/grdm_dev.egg-info/top_level.txt @@ -0,0 +1 @@ +grdm_dev diff --git a/installer/grdm_dev/accept.py b/installer/grdm_dev/accept.py new file mode 100644 index 0000000..cd6583b --- /dev/null +++ b/installer/grdm_dev/accept.py @@ -0,0 +1,346 @@ +"""grdm-dev accept — run the Playwright Python acceptance suite (SPEC-02 §3, SPEC-04). + +Flow: check that pytest + playwright are importable in this venv (exit 2 with an install hint +otherwise), refuse any base URL that is not loopback, optionally seed disposable users through the +`web` container (`--seed`), run pytest on installer/acceptance/ with JUnit output, then write +results.json + results.toon into docs/demo/runs// and exit 60 if any test failed. + +Standard library only. Every external call (pytest, docker compose) goes through an injectable +`runner(argv, env=None, cwd=None) -> (returncode, output)` so unit tests never need a browser, +Docker, or the application. +""" +from __future__ import annotations + +import datetime as _dt +import importlib +import json +import os +import re +import secrets +import subprocess +import sys +import xml.etree.ElementTree as ET +from pathlib import Path +from urllib.parse import urlparse + +from . import exit_codes, report, toon +from .context import Context + +# SPEC-04 §4 / §5. Shared with installer/acceptance/conftest.py by convention (ids in file names). +SCENARIOS: dict[str, str] = { + "C1": "Login via fakecas", + "C2": "Create project", + "C3": "Upload and download file", + "C4": "Wiki collaborative edit", + "C5": "File preview", + "C6": "Institution admin screen", + "S1": "y-websocket", + "S2": "rdmcp (MCP endpoint)", + "S3": "aipf_mcp_data_grdm", + "S4": "OASys", + "S5": "Shibboleth-SP via test IdP", +} + +ACCEPTANCE_DIR = Path(__file__).resolve().parent.parent / "acceptance" +DEFAULT_WEB_PORT = 5000 +# Browsers live inside the venv, never in the user's home (SPEC-04 §1). Relative to the repo root. +BROWSERS_PATH = Path(".venv") / ".playwright" +INSTALL_HINT = 'pip install -e "installer[accept]" && PLAYWRIGHT_BROWSERS_PATH=.venv/.playwright playwright install chromium' +REQUIRED_MODULES = ("pytest", "playwright", "pytest_playwright") +# Disposable-user mailbox domain. `.test` is reserved (RFC 2606): never a real person (POL-01). +SEED_DOMAIN = "acceptance.test" + +# Django management call executed inside the `web` container by `--seed`. +# TODO(M2): confirm on the real app. OSFUser.create_confirmed(username, password, fullname) exists in +# osf/models/user.py upstream; the institution-admin flag for C6 (admin app permission / group) is +# unverified and may need `is_staff` plus an institution affiliation instead of `is_superuser`. +SEED_SNIPPET = ( + "from osf.models import OSFUser; " + "u = OSFUser.create_confirmed(username={email!r}, password={email!r}, fullname={fullname!r}); " + "u.is_staff = {admin}; u.is_superuser = {admin}; u.save(); print('seeded', u._id)" +) +CLEANUP_SNIPPET = ( + "from osf.models import OSFUser; " + "n, _ = OSFUser.objects.filter(username__endswith='@{domain}', username__contains={run_id!r}).delete(); " + "print('deleted', n)" +) + + +def register(subparsers) -> None: + p = subparsers.add_parser("accept", help="run the Playwright acceptance suite in this venv; exit 60 on any failing test") + p.add_argument("--only", metavar="SCENARIO", help="run one scenario (C1..C6, S1..S5, a name fragment like 'login', or a marker: core, subsystem)") + p.add_argument("--seed", action="store_true", help="create disposable test users in the web container before running (removed afterwards)") + p.add_argument("--base-url", dest="base_url", help="web URL; must be http://127.0.0.1: (default: GRDM_PORT_WEB from runtime/.env, else 5000)") + p.add_argument("--headed", action="store_true", help="show the browser window (debugging only)") + p.set_defaults(_module=sys.modules[__name__]) + + +# --- helpers ------------------------------------------------------------------------------------- + +def default_runner(argv: list[str], env: dict[str, str] | None = None, cwd: str | Path | None = None, + timeout: int = 1900) -> tuple[int, str]: + try: + proc = subprocess.run(argv, capture_output=True, text=True, env=env, cwd=cwd, timeout=timeout) + except FileNotFoundError as exc: + return 127, str(exc) + except subprocess.TimeoutExpired: + return 124, "timed out" + return proc.returncode, (proc.stdout or "") + (proc.stderr or "") + + +def missing_modules(importer=None) -> list[str]: + importer = importer or importlib.import_module + missing = [] + for name in REQUIRED_MODULES: + try: + importer(name) + except ImportError: + missing.append(name) + return missing + + +def read_env_file(path: Path) -> dict[str, str]: + env: dict[str, str] = {} + if not path.exists(): + return env + for line in path.read_text(encoding="utf-8").splitlines(): + line = line.strip() + if not line or line.startswith("#") or "=" not in line: + continue + k, _, v = line.partition("=") + env[k.strip()] = v.strip().strip('"').strip("'") + return env + + +def default_base_url(ctx: Context) -> str: + port = read_env_file(ctx.runtime / ".env").get("GRDM_PORT_WEB", str(DEFAULT_WEB_PORT)) + return f"http://127.0.0.1:{port}" + + +def loopback_problem(url: str) -> str | None: + """Return why `url` is not an acceptable loopback target, or None if it is (ADR-02 §3.5).""" + u = urlparse(url) + if u.scheme != "http": + return f"scheme must be http, got {u.scheme!r}" + if u.hostname != "127.0.0.1": + return f"host must be 127.0.0.1, got {u.hostname!r} (tests never leave the machine)" + if u.username or u.password: + return "credentials in URL are not allowed" + return None + + +def make_run_id(now: _dt.datetime | None = None) -> str: + now = now or _dt.datetime.now(_dt.timezone.utc) + return f"acc-{now.strftime('%Y%m%dT%H%M%SZ')}-{secrets.token_hex(3)}" + + +def seed_users(run_id: str) -> dict[str, dict[str, str]]: + """Disposable identities for one run. With fakecas the password is the e-mail (upstream README).""" + users = {} + for key, admin in (("user_a", False), ("user_b", False), ("admin_user", True)): + email = f"{key.replace('_', '-')}-{run_id}@{SEED_DOMAIN}" + users[key] = {"email": email, "password": email, "fullname": f"Acceptance {key} {run_id}", "admin": admin} + return users + + +def compose_exec(ctx: Context, service: str, *cmd: str) -> list[str]: + argv = ["docker", "compose"] + if (ctx.runtime / "docker-compose.yml").exists(): + argv += ["-f", str(ctx.runtime / "docker-compose.yml")] + if (ctx.runtime / ".env").exists(): + argv += ["--env-file", str(ctx.runtime / ".env")] + return argv + ["exec", "-T", service, *cmd] + + +def select_tests(only: str | None) -> tuple[list[str], list[str]] | None: + """Translate --only into (paths, extra pytest args). None means the selection matched nothing.""" + if not only: + return [str(ACCEPTANCE_DIR)], [] + key = only.strip().lower() + if key in ("core", "subsystem"): + return [str(ACCEPTANCE_DIR)], ["-m", key] + files = sorted(ACCEPTANCE_DIR.glob("test_*.py")) + hits = [str(f) for f in files if key in f.stem.lower()] + if not hits and re.fullmatch(r"[cs][0-9]+", key): + hits = [str(f) for f in files if f.stem.lower().startswith(f"test_{key}_")] + return (hits, []) if hits else None + + +def pytest_argv(paths: list[str], extra: list[str], run_dir: Path, base_url: str, headed: bool) -> list[str]: + argv = [sys.executable, "-m", "pytest", *paths, "-q", "--no-header", + "-p", "no:cacheprovider", + # pytest-playwright registers itself through its entry point; naming it again with -p would + # register the same module twice and pluggy rejects that. Autoload stays on. + "--base-url", base_url, + "--junitxml", str(run_dir / "junit.xml"), + "--screenshot", "only-on-failure", + "--tracing", "retain-on-failure", + "--output", str(run_dir / "artifacts"), + "--browser", "chromium", + *extra] + if headed: + argv.append("--headed") + return argv + + +# --- result collection --------------------------------------------------------------------------- + +def _classify(nodeid: str) -> tuple[str, str, str]: + """(scenario id, scenario name, case) from a nodeid like .../test_c1_login.py::test_c1_login_success.""" + m = re.search(r"test_([cs][0-9]+)_", nodeid.lower()) + sid = m.group(1).upper() if m else "?" + test = nodeid.rsplit("::", 1)[-1].lower() + case = "success" if "success" in test else "rejection" if "reject" in test else "other" + return sid, SCENARIOS.get(sid, sid), case + + +def _evidence_path(run_dir: Path, nodeid: str) -> str | None: + """pytest-playwright writes // on failure; return it relative to run_dir.""" + art = run_dir / "artifacts" + if not art.is_dir(): + return None + name = nodeid.rsplit("::", 1)[-1] + for d in sorted(art.iterdir()): + if d.is_dir() and name[:40].replace("_", "-") in d.name.replace("_", "-"): + return str(d.relative_to(run_dir)) + return None + + +def collect_results(run_dir: Path) -> list[dict]: + """Prefer the conftest collector file; fall back to junit.xml. Returns one row per test.""" + rows: list[dict] = [] + collector = run_dir / "collector.json" + if collector.exists(): + try: + for r in json.loads(collector.read_text(encoding="utf-8")): + sid, name, case = _classify(r.get("nodeid", "")) + rows.append({ + "id": r.get("id") or sid, "name": r.get("name") or name, "case": r.get("case") or case, + "test": r.get("nodeid", "").rsplit("::", 1)[-1], "status": r.get("status", "error"), + "duration_ms": int(r.get("duration_ms", 0)), "http_status": r.get("http_status"), + "evidence": r.get("evidence") or _evidence_path(run_dir, r.get("nodeid", "")), + }) + return rows + except (ValueError, AttributeError): + rows = [] + junit = run_dir / "junit.xml" + if not junit.exists(): + return rows + try: + tree = ET.parse(junit) + except ET.ParseError: + return rows + for tc in tree.iter("testcase"): + nodeid = f"{tc.get('classname', '')}::{tc.get('name', '')}" + sid, name, case = _classify(nodeid) + status = "passed" + for child in tc: + if child.tag in ("failure",): + status = "failed" + elif child.tag == "error": + status = "error" + elif child.tag == "skipped": + status = "skipped" + http_status = None + for prop in tc.iter("property"): + if prop.get("name") == "http_status": + try: + http_status = int(prop.get("value", "")) + except ValueError: + http_status = prop.get("value") + rows.append({"id": sid, "name": name, "case": case, "test": tc.get("name", ""), "status": status, + "duration_ms": int(float(tc.get("time", "0") or 0) * 1000), "http_status": http_status, + "evidence": _evidence_path(run_dir, nodeid)}) + return rows + + +def write_results(run_dir: Path, data: dict) -> None: + run_dir.mkdir(parents=True, exist_ok=True) + (run_dir / "results.json").write_text(json.dumps(data, ensure_ascii=False, indent=2) + "\n", encoding="utf-8") + (run_dir / "results.toon").write_text(toon.encode(data, name="accept") + "\n", encoding="utf-8") + + +# --- entry point --------------------------------------------------------------------------------- + +def run(ctx: Context, args, runner=None, importer=None, now=None) -> int: + runner = runner or default_runner + missing = missing_modules(importer) + if missing: + return report.error(ctx, exit_codes.USAGE, f"missing {', '.join(missing)}; run: {INSTALL_HINT}") + + base_url = (getattr(args, "base_url", None) or default_base_url(ctx)).rstrip("/") + problem = loopback_problem(base_url) + if problem: + return report.error(ctx, exit_codes.USAGE, f"--base-url {base_url}: {problem}") + + browsers = ctx.root / BROWSERS_PATH + if not browsers.is_dir() or not any(browsers.iterdir()): + return report.error(ctx, exit_codes.USAGE, f"no Playwright browser under {browsers}; run: {INSTALL_HINT}") + + selection = select_tests(getattr(args, "only", None)) + if selection is None: + return report.error(ctx, exit_codes.USAGE, f"--only {args.only!r} matches no scenario in {ACCEPTANCE_DIR}") + paths, extra = selection + + started = now or _dt.datetime.now(_dt.timezone.utc) + run_id = make_run_id(started) + run_dir = ctx.root / "docs" / "demo" / "runs" / run_id + run_dir.mkdir(parents=True, exist_ok=True) + users = seed_users(run_id) + + env = dict(ctx.env) + env.update({ + "PLAYWRIGHT_BROWSERS_PATH": str(browsers), + "GRDM_BASE_URL": base_url, + "GRDM_RUN_ID": run_id, + "GRDM_ENV_FILE": str(ctx.runtime / ".env"), + "GRDM_ACCEPT_RESULTS": str(run_dir / "collector.json"), + "GRDM_ACCEPT_USER_A": users["user_a"]["email"], + "GRDM_ACCEPT_USER_B": users["user_b"]["email"], + "GRDM_ACCEPT_ADMIN": users["admin_user"]["email"], + }) + + seeded = False + if getattr(args, "seed", False): + for u in users.values(): + snippet = SEED_SNIPPET.format(email=u["email"], fullname=u["fullname"], admin=u["admin"]) + rc, out = runner(compose_exec(ctx, "web", "python3", "manage.py", "shell", "-c", snippet), env=env, cwd=ctx.root) + if rc != 0: + return report.error(ctx, exit_codes.SERVICES_UNHEALTHY, f"seed failed for {u['email']}: {out.strip()[-400:]}") + seeded = True + + try: + rc, out = runner(pytest_argv(paths, extra, run_dir, base_url, getattr(args, "headed", False)), env=env, cwd=ctx.root) + finally: + if seeded: + cleanup = CLEANUP_SNIPPET.format(domain=SEED_DOMAIN, run_id=run_id) + crc, cout = runner(compose_exec(ctx, "web", "python3", "manage.py", "shell", "-c", cleanup), env=env, cwd=ctx.root) + if crc != 0: + sys.stderr.write(f"warning: cleanup of seeded users failed: {cout.strip()[-200:]}\n") + (run_dir / "pytest.log").write_text(out, encoding="utf-8") + + rows = collect_results(run_dir) + finished = _dt.datetime.now(_dt.timezone.utc) + summary = {s: sum(1 for r in rows if r["status"] == s) for s in ("passed", "failed", "error", "skipped")} + summary["total"] = len(rows) + data = { + "run_id": run_id, + "base_url": base_url, + "started": started.strftime("%Y-%m-%dT%H:%M:%SZ"), + "duration_ms": int((finished - started).total_seconds() * 1000) if now is None else sum(r["duration_ms"] for r in rows), + "only": getattr(args, "only", None), + "seeded": seeded, + "pytest_returncode": rc, + "evidence_dir": str(run_dir.relative_to(ctx.root)) if run_dir.is_relative_to(ctx.root) else str(run_dir), + "summary": summary, + "tests": rows, + } + write_results(run_dir, data) + report.emit(ctx, "accept", data) + + if rc == 5: # pytest: no tests collected + return report.error(ctx, exit_codes.USAGE, "pytest collected no tests") + if rc != 0 or summary["failed"] or summary["error"]: + return report.error(ctx, exit_codes.ACCEPTANCE_FAILED, + f"{summary['failed'] + summary['error']} failing test(s); see {run_dir}") + return exit_codes.OK diff --git a/installer/grdm_dev/build.py b/installer/grdm_dev/build.py new file mode 100644 index 0000000..34f0955 --- /dev/null +++ b/installer/grdm_dev/build.py @@ -0,0 +1,186 @@ +"""grdm-dev build — clone integration repositories and build images with docker buildx (SPEC-02 §3). + +For every buildable component of the resolved profile (a component with an `integration_repo`), +the integration repository `RDM--dev2027` is cloned into runtime/src/ with +`git clone --filter=blob:none` (or fetched when already present), checked out at the pinned +commit, and built with `docker buildx build`. The clone URL is composed at run time from the +bare repository name in the manifest (SPEC-01 rule 5: names only in files). + +Pinned commit: `Component.build_sha` from grdm_dev.manifest — the component's `integration_sha` +when the weekly integration PR has written one, else the first merged upstream SHA in SPEC-01 +rule 3 order (public, then private). Without any SHA the head of `origin/` is +checked out; the SHA actually checked out is always re-read with `git rev-parse` and recorded in +the build report (`components[]{component,sha12}`), which `compose render` reads as image tags. + +Images: local builds use `--load` for the host platform (or --platform) and tag +`grdm-dev/:`. With --push, the multi-arch manifest is pushed to +`ghcr.io/rcosdp/:` as well. Exit 30 names the failing component. + +Runner: `runner(argv) -> (returncode, stdout)`; the default streams the child's output lines to +stderr while collecting them, so a long build stays visible. Tests inject a fake. +""" +from __future__ import annotations + +import platform as _platform +import subprocess +import sys +from pathlib import Path + +from . import exit_codes, report +from .context import Context + +GITHUB_ORG = "RCOSDP" +REGISTRY = "ghcr.io/rcosdp" +LOCAL_IMAGE_PREFIX = "grdm-dev" +PROFILE_RANK = {"minimum": 0, "core": 1, "full": 2} +DEFAULT_PROFILE = "core" + + +def default_runner(argv: list[str]) -> tuple[int, str]: + """Run argv, stream every output line to stderr, return (returncode, collected output).""" + lines: list[str] = [] + try: + proc = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) + except OSError as exc: + return 127, str(exc) + assert proc.stdout is not None + for line in proc.stdout: + sys.stderr.write(line) + lines.append(line) + return proc.wait(), "".join(lines) + + +def host_platform() -> str: + machine = _platform.machine().lower() + if machine in ("arm64", "aarch64"): + return "linux/arm64" + if machine in ("x86_64", "amd64"): + return "linux/amd64" + return f"linux/{machine}" + + +def clone_url(repo_name: str) -> str: + """Compose the HTTPS URL from the bare name; the URL is never stored in the manifest or docs.""" + return f"https://github.com/{GITHUB_ORG}/{repo_name}.git" + + +def load_components(ctx: Context) -> list: + """Components of the manifest (grdm_dev.manifest dataclasses; dict-compatible).""" + from . import manifest as _manifest + + return list(_manifest.load(ctx).components) + + +def resolve_profile(ctx: Context) -> str: + if ctx.profile: + return ctx.profile + from .secrets import env_path, read_env + + return read_env(env_path(ctx)).get("GRDM_PROFILE") or DEFAULT_PROFILE + + +def buildable_components(components: list[dict], profile: str, only: str | None = None) -> list[dict]: + rank = PROFILE_RANK.get(profile, PROFILE_RANK[DEFAULT_PROFILE]) + out = [] + for comp in components: + if not comp.get("integration_repo"): + continue + if PROFILE_RANK.get(comp.get("profile", "full"), 2) > rank and only is None: + continue + if only is not None and comp.get("id") != only: + continue + out.append(comp) + return out + + +def image_name(component_id: str) -> str: + return component_id.lower() + + +def sync_source(repo: str, dest: Path, ref: str, runner) -> tuple[int, str, str]: + """Clone or fetch `repo` into dest and check out `ref`. Returns (rc, resolved_sha, log).""" + log: list[str] = [] + if (dest / ".git").exists(): + rc, out = runner(["git", "-C", str(dest), "fetch", "--filter=blob:none", "origin"]) + else: + dest.parent.mkdir(parents=True, exist_ok=True) + rc, out = runner(["git", "clone", "--filter=blob:none", "--no-checkout", clone_url(repo), str(dest)]) + log.append(out) + if rc != 0: + return rc, "", "".join(log) + rc, out = runner(["git", "-C", str(dest), "checkout", "--detach", "--force", ref]) + log.append(out) + if rc != 0: + return rc, "", "".join(log) + rc, out = runner(["git", "-C", str(dest), "rev-parse", "HEAD"]) + log.append(out) + return rc, out.strip().splitlines()[-1] if out.strip() else "", "".join(log) + + +def buildx_argv(component_id: str, context_dir: Path, sha12: str, platforms: list[str], push: bool) -> list[str]: + name = image_name(component_id) + argv = ["docker", "buildx", "build", "--platform", ",".join(platforms)] + argv += ["--push" if push else "--load"] + argv += ["-t", f"{LOCAL_IMAGE_PREFIX}/{name}:{sha12}"] + if push: + argv += ["-t", f"{REGISTRY}/{name}:{sha12}"] + argv += ["--label", f"org.gakunin-rdm.component={component_id}", "--label", f"org.gakunin-rdm.sha={sha12}"] + argv.append(str(context_dir)) + return argv + + +def pinned_ref(comp) -> str: + sha = getattr(comp, "build_sha", None) or comp.get("integration_sha") + if sha: + return sha + return f"origin/{comp.get('integration_branch') or 'develop'}" + + +def register(subparsers) -> None: + p = subparsers.add_parser("build", help="clone integration repos at the pinned SHA and build images with buildx; exit 30 on failure") + p.add_argument("--platform", help="comma-separated platforms (default: host platform only)") + p.add_argument("--push", action="store_true", help=f"push the multi-arch manifest to {REGISTRY}/") + p.add_argument("--component", help="build only this component id") + p.set_defaults(_module=sys.modules[__name__]) + + +def run(ctx: Context, args, runner=None) -> int: + runner = runner or default_runner + platforms = [s.strip() for s in (getattr(args, "platform", None) or host_platform()).split(",") if s.strip()] + push = bool(getattr(args, "push", False)) + only = getattr(args, "component", None) + profile = resolve_profile(ctx) + try: + components = load_components(ctx) + except Exception as exc: # manifest.ManifestError, OSError, ValueError → SPEC-02 exit 20 + detail = "; ".join(getattr(exc, "errors", []) or [str(exc)]) + return report.error(ctx, exit_codes.MANIFEST_INVALID, detail) + selected = buildable_components(components, profile, only) + if only is not None and not selected: + return report.error(ctx, exit_codes.USAGE, f"unknown or non-buildable component: {only}") + + rows: list[dict] = [] + failed: str | None = None + detail = "" + for comp in selected: + cid = comp["id"] + repo = comp["integration_repo"] + dest = ctx.runtime / "src" / repo + rc, sha, log = sync_source(repo, dest, pinned_ref(comp), runner) + if rc != 0 or not sha: + rows.append({"component": cid, "repo": repo, "sha12": "", "platforms": ",".join(platforms), "status": "source-failed"}) + failed, detail = cid, f"could not fetch {repo} at {pinned_ref(comp)}" + break + sha12 = sha[:12] + rc, out = runner(buildx_argv(cid, dest, sha12, platforms, push)) + status = "pushed" if (rc == 0 and push) else "built" if rc == 0 else "build-failed" + rows.append({"component": cid, "repo": repo, "sha12": sha12, "platforms": ",".join(platforms), "status": status}) + if rc != 0: + failed, detail = cid, f"docker buildx build exited {rc}" + break + + data = {"profile": profile, "platforms": platforms, "push": push, "components": rows, "failed": failed} + report.emit(ctx, "build", data) + if failed is not None: + return report.error(ctx, exit_codes.BUILD_FAILED, f"component {failed}: {detail}") + return exit_codes.OK diff --git a/installer/grdm_dev/cli.py b/installer/grdm_dev/cli.py index 2fe19c3..4571e3d 100644 --- a/installer/grdm_dev/cli.py +++ b/installer/grdm_dev/cli.py @@ -21,11 +21,8 @@ def build_parser() -> argparse.ArgumentParser: description="GakuNin RDM developer environment 2027 — one-command installer (SPEC-02)", ) p.add_argument("--version", action="version", version=f"grdm-dev {__version__}") - p.add_argument("--yes", action="store_true", help="answer every question with its default (required without a terminal)") - p.add_argument("--json", dest="json_output", action="store_true", help="print reports as JSON instead of TOON") - p.add_argument("--profile", choices=["minimum", "core", "full"], help="service profile (default: saved value or core)") + _add_global_flags(p) p.add_argument("--root", help="repository root (default: auto-detect from manifest/upstreams.json)") - p.add_argument("-v", "--verbose", action="store_true") sub = p.add_subparsers(dest="command", metavar="") for name in SUBCOMMAND_MODULES: try: @@ -38,9 +35,32 @@ def build_parser() -> argparse.ArgumentParser: continue raise mod.register(sub) + # SPEC-02 §2.2: every subcommand accepts --json (and the other global flags) after its name too, + # e.g. `grdm-dev doctor --json`. Add them to each sub-parser with SUPPRESS defaults so that a + # value given in either position wins and the global default is kept otherwise. + for sp in sub.choices.values(): + _add_global_flags_recursive(sp) return p +def _add_global_flags_recursive(p: argparse.ArgumentParser) -> None: + """Add the global flags to a sub-parser and to any nested sub-parsers (e.g. `secrets init`).""" + _add_global_flags(p, suppress=True) + for action in p._actions: # noqa: SLF001 - argparse has no public API for nested sub-parsers + if isinstance(action, argparse._SubParsersAction): + for child in action.choices.values(): + _add_global_flags_recursive(child) + + +def _add_global_flags(p: argparse.ArgumentParser, suppress: bool = False) -> None: + d = argparse.SUPPRESS if suppress else None + kw = {"default": d} if suppress else {} + p.add_argument("--yes", action="store_true", help="answer every question with its default (required without a terminal)", **kw) + p.add_argument("--json", dest="json_output", action="store_true", help="print reports as JSON instead of TOON", **kw) + p.add_argument("--profile", choices=["minimum", "core", "full"], help="service profile (default: saved value or core)", **kw) + p.add_argument("-v", "--verbose", action="store_true", **kw) + + def main(argv: list[str] | None = None) -> int: parser = build_parser() try: diff --git a/installer/grdm_dev/compose.py b/installer/grdm_dev/compose.py new file mode 100644 index 0000000..65d8d19 --- /dev/null +++ b/installer/grdm_dev/compose.py @@ -0,0 +1,712 @@ +"""grdm-dev compose render — write runtime/docker-compose.yml from templates + manifest (SPEC-02 §3, ADR-02). + +Output is JSON (Compose accepts JSON because JSON is YAML). Rules applied to every service: + +* one bridge network `grdm`; services address each other by Compose service name (ADR-02 §3.1); +* ports only as `127.0.0.1::`; host ports from the SPEC-02 §4 table, overridden by + `GRDM_PORT_` in runtime/.env, remapped to the next free port on collision (exit 12 when + none is free within +100); every chosen port is written back to runtime/.env; +* `user:` non-root (uid from the template), `read_only: true` with explicit `tmpfs`/volumes, + `cap_drop: [ALL]`, `security_opt: [no-new-privileges:true]`, `mem_limit`/`cpus`/`pids_limit` + scaled from the detected memory (argument; default 16 GiB), `platform:` from the argument or + host detection; per-service exceptions come from manifest/hardening.json (SPEC-03 §3.3); +* named volumes are local bind volumes under runtime/volumes/; +* secrets never enter generated files: the compose file references `${KEY}` and Compose reads + runtime/.env (same directory) at `up`; `secrets init` must have run (exit 2 otherwise). + +Template schema (templates/.json): service, component, profile?, container_port?, +host_port?, expose?, command?, environment?, env_files?, volumes? ([{volume|config|config_dir, +target, ro?}]), tmpfs?, user?, depends_on?, weight, mem_min_mb, pids_limit, note?. Strings may use +`{{HOST_PORT:}}` / `{{CONTAINER_PORT:}}`. + +Upstream settings are rewritten under runtime/config/ (ADR-02 §3.3): osf/local.py, osf/api_local.py, +osf.env, wb.env, mfr.env, sharejs.env, postgres-init/10-cas.sql, cas/cas.properties. Internal URLs use +service names, browser-facing URLs use http://127.0.0.1:. +""" +from __future__ import annotations + +import json +import math +import os +import re +import socket +import sys +from pathlib import Path +from typing import Any, Callable + +from . import exit_codes, manifest as _manifest, report +from .context import Context +from .plan import ( + DEFAULT_PORTS, + LOOPBACK, + PROFILE_ENV_KEY, + detect_platform, + env_path, + port_key, + published_ports, + read_dotenv, + resolve_profile, + volumes_of, +) + +NETWORK = "grdm" +PROJECT_NAME = "grdm-dev" +COMPOSE_FILE = "docker-compose.yml" +CONFIG_DIR = "config" +VOLUMES_DIR = "volumes" +DEFAULT_MEMORY_GIB = 16.0 +DEFAULT_CPUS = 4.0 +MEMORY_SHARE = 0.70 # fraction of host memory handed out as the sum of mem_limit +CPU_OVERSUBSCRIBE = 2.0 # limits may add up to twice the host CPUs (they are ceilings) +PORT_SEARCH_RANGE = 100 +FORBIDDEN_ADDRESS = "192.168.168.167" # the old loopback alias; must never appear (ADR-02) + +# Keys that compose output references; all are written by `grdm-dev secrets init` (secrets.py). +REQUIRED_SECRETS: tuple[str, ...] = ( + "POSTGRES_PASSWORD", + "DJANGO_SECRET_KEY", + "API_SECRET_KEY", + "SESSION_COOKIE_SECRET", + "RABBITMQ_DEFAULT_PASS", + "WATERBUTLER_JWE_SECRET", + "WATERBUTLER_JWE_SALT", + "WATERBUTLER_JWT_SECRET", + "MFR_SERVER_SECRET", + "SHAREJS_SECRET", + "Y_WEBSOCKET_JWT_SECRET", +) + +PortChecker = Callable[[int], bool] + +GENERATED_HEADER = "generated by grdm-dev compose render; do not edit (SPEC-02 §3, ADR-02)" + + +def register(subparsers) -> None: + p = subparsers.add_parser("compose", help="render runtime/docker-compose.yml from manifest, profile and templates") + sub = p.add_subparsers(dest="compose_command", metavar="") + r = sub.add_parser("render", help="write runtime/docker-compose.yml and runtime/config/*; touches no Docker") + r.add_argument("--auth", choices=[_manifest.AUTH_FAKECAS, _manifest.AUTH_SHIBBOLETH], default=_manifest.AUTH_FAKECAS, + help="auth provider for the full profile (shibboleth replaces fakecas)") + r.add_argument("--platform", help="Compose platform, e.g. linux/arm64 (default: detected host)") + r.add_argument("--memory-gib", type=float, help="host memory to scale resource limits from (default: detected, else 16)") + r.add_argument("--cpus", type=float, help="host CPUs to scale cpu limits from (default: detected, else 4)") + p.set_defaults(_module=sys.modules[__name__]) + + +# --------------------------------------------------------------------------- hardening + + +def load_hardening(root: Path) -> dict[str, dict[str, Any]]: + """manifest/hardening.json exceptions keyed by service. Missing file -> no exceptions.""" + path = root / "manifest" / "hardening.json" + if not path.exists(): + return {} + data = json.loads(path.read_text(encoding="utf-8")) + out: dict[str, dict[str, Any]] = {} + for entry in data.get("exceptions", []): + if not entry.get("reason") or not entry.get("review"): + raise ValueError(f"hardening.json: exception for {entry.get('service')!r} needs reason and review") + out[entry["service"]] = entry + return out + + +# --------------------------------------------------------------------------- ports + + +def default_port_checker(port: int) -> bool: + """True when 127.0.0.1: can be bound right now.""" + with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: + s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + try: + s.bind((LOOPBACK, port)) + return True + except OSError: + return False + + +def assign_ports(rows: list[dict[str, Any]], checker: PortChecker) -> tuple[list[dict[str, Any]], list[dict[str, Any]], list[str]]: + """Remap busy ports to the next free one. Returns (rows, remapped, unresolved).""" + taken: set[int] = set() + remapped: list[dict[str, Any]] = [] + unresolved: list[str] = [] + out: list[dict[str, Any]] = [] + for row in rows: + wanted = int(row["host_port"]) + chosen = None + for cand in range(wanted, wanted + PORT_SEARCH_RANGE + 1): + if cand in taken or cand > 65535: + continue + if checker(cand): + chosen = cand + break + if chosen is None: + unresolved.append(row["service"]) + out.append(row) + continue + taken.add(chosen) + new = dict(row) + new["host_port"] = chosen + new["url"] = f"http://{LOOPBACK}:{chosen}" + if chosen != wanted: + new["source"] = "remapped" + remapped.append({"service": row["service"], "wanted": wanted, "chosen": chosen}) + out.append(new) + return out, remapped, unresolved + + +def host_port_map(env: dict[str, str], rows: list[dict[str, Any]]) -> dict[str, int]: + """Host port per service: assigned rows first, then .env overrides, then the SPEC-02 §4 defaults. + + Services outside the profile still get a port so generated settings (e.g. WATERBUTLER_URL) are complete. + """ + ports = dict(DEFAULT_PORTS) + for name in DEFAULT_PORTS: + raw = env.get(port_key(name)) + if raw and raw.isdigit(): + ports[name] = int(raw) + for row in rows: + ports[row["service"]] = int(row["host_port"]) + return ports + + +_PLACEHOLDER = re.compile(r"\{\{(HOST_PORT|CONTAINER_PORT):([A-Za-z0-9_]+)\}\}") + + +def substitute(value: Any, host_ports: dict[str, int], container_ports: dict[str, int]) -> Any: + if isinstance(value, str): + def repl(m: re.Match) -> str: + table = host_ports if m.group(1) == "HOST_PORT" else container_ports + if m.group(2) not in table: + raise ValueError(f"template placeholder {m.group(0)} has no known port") + return str(table[m.group(2)]) + return _PLACEHOLDER.sub(repl, value) + if isinstance(value, list): + return [substitute(v, host_ports, container_ports) for v in value] + if isinstance(value, dict): + return {k: substitute(v, host_ports, container_ports) for k, v in value.items()} + return value + + +# --------------------------------------------------------------------------- resources + + +def scale_resources(services: list[_manifest.Service], memory_gib: float, cpus: float) -> dict[str, dict[str, Any]]: + budget_mb = memory_gib * 1024 * MEMORY_SHARE + total_weight = sum(float(s.template.get("weight", 1)) for s in services) or 1.0 + out: dict[str, dict[str, Any]] = {} + for svc in services: + tpl = svc.template + weight = float(tpl.get("weight", 1)) + mem = max(int(tpl.get("mem_min_mb", 128)), int(math.floor(budget_mb * weight / total_weight))) + cpu = min(cpus, max(0.5, cpus * CPU_OVERSUBSCRIBE * weight / total_weight)) + out[svc.name] = {"mem_limit": f"{mem}m", "cpus": round(cpu, 2), "pids_limit": int(tpl.get("pids_limit", 512))} + return out + + +# --------------------------------------------------------------------------- rendering + + +def _mount(entry: dict[str, Any]) -> str: + target = entry["target"] + suffix = ":ro" if entry.get("ro") else "" + if "volume" in entry: + return f"{entry['volume']}:{target}{suffix}" + if "config" in entry: + return f"./{CONFIG_DIR}/{entry['config']}:{target}{suffix}" + if "config_dir" in entry: + return f"./{CONFIG_DIR}/{entry['config_dir']}:{target}{suffix}" + raise ValueError(f"unknown volume entry {entry!r}") + + +def render_service( + svc: _manifest.Service, + *, + in_profile: set[str], + host_ports: dict[str, int], + container_ports: dict[str, int], + published: dict[str, int], + hardening: dict[str, dict[str, Any]], + resources: dict[str, Any], + platform_string: str, +) -> dict[str, Any]: + tpl = substitute(svc.template, host_ports, container_ports) + exc = hardening.get(svc.name, {}) + relaxed = set(exc.get("controls", [])) + out: dict[str, Any] = {"image": svc.image} + if platform_string and platform_string != "unknown": + out["platform"] = platform_string + if "command" in tpl: + out["command"] = tpl["command"] + if "user" not in relaxed: + out["user"] = tpl.get("user", "1000:1000") + out["read_only"] = "read_only" not in relaxed + out["cap_drop"] = ["ALL"] + if "cap_add" in relaxed and exc.get("cap_add"): + out["cap_add"] = list(exc["cap_add"]) + out["security_opt"] = ["no-new-privileges:true"] + if tpl.get("environment"): + out["environment"] = dict(tpl["environment"]) + if tpl.get("env_files"): + out["env_file"] = [f"./{CONFIG_DIR}/{name}" for name in tpl["env_files"]] + if tpl.get("volumes"): + out["volumes"] = [_mount(v) for v in tpl["volumes"]] + if tpl.get("tmpfs"): + out["tmpfs"] = list(tpl["tmpfs"]) + if svc.name in published: + out["ports"] = [f"{LOOPBACK}:{published[svc.name]}:{container_ports[svc.name]}"] + expose = [str(p) for p in tpl.get("expose", [])] + if "container_port" in tpl and str(tpl["container_port"]) not in expose and svc.name not in published: + expose.insert(0, str(tpl["container_port"])) + if expose: + out["expose"] = expose + deps = [d for d in tpl.get("depends_on", []) if d in in_profile] + if deps: + out["depends_on"] = deps + out["networks"] = [NETWORK] + out["restart"] = tpl.get("restart", "unless-stopped") + out["init"] = True + out.update(resources) + out["labels"] = { + "org.gakunin-rdm.component": svc.component, + "org.gakunin-rdm.profile": svc.profile, + "org.gakunin-rdm.hardening-exception": ",".join(sorted(relaxed)) if relaxed else "none", + } + return out + + +def render_compose( + services: list[_manifest.Service], + *, + runtime: Path, + host_ports: dict[str, int], + published: dict[str, int], + hardening: dict[str, dict[str, Any]], + memory_gib: float, + cpus: float, + platform_string: str, +) -> dict[str, Any]: + in_profile = {s.name for s in services} + container_ports = {s.name: int(s.template.get("container_port", DEFAULT_PORTS.get(s.name, 0))) for s in services} + for name, port in DEFAULT_PORTS.items(): + container_ports.setdefault(name, port) + resources = scale_resources(services, memory_gib, cpus) + rendered = { + svc.name: render_service( + svc, + in_profile=in_profile, + host_ports=host_ports, + container_ports=container_ports, + published=published, + hardening=hardening, + resources=resources[svc.name], + platform_string=platform_string, + ) + for svc in services + } + volumes = { + name: { + "driver": "local", + "driver_opts": {"type": "none", "o": "bind", "device": str(runtime / VOLUMES_DIR / name)}, + } + for name in volumes_of(services) + } + return { + "name": PROJECT_NAME, + "x-grdm-dev": {"generated": GENERATED_HEADER, "network_model": "ADR-02", "memory_gib": memory_gib, "cpus": cpus}, + "networks": {NETWORK: {"driver": "bridge", "name": f"{PROJECT_NAME}_{NETWORK}"}}, + "volumes": volumes, + "services": rendered, + } + + +# --------------------------------------------------------------------------- settings rewrite (ADR-02 §3.3) + + +def _ext(host_ports: dict[str, int], service: str, trailing: str = "") -> str: + return f"http://{LOOPBACK}:{host_ports[service]}{trailing}" + + +def render_website_local_py(host_ports: dict[str, int]) -> str: + """website/settings/local.py — internal URLs by service name, browser URLs on 127.0.0.1.""" + lines = [ + "# -*- coding: utf-8 -*-", + f"# {GENERATED_HEADER}", + "# Internal URLs use Compose service names; browser-facing URLs use http://127.0.0.1:/ (ADR-02 §3.3).", + "# Secrets come from the environment (runtime/.env via Compose), never from this file.", + "import logging", + "from os import environ", + "", + "from . import defaults", + "", + "DEV_MODE = True", + "DEBUG_MODE = True", + "SECURE_MODE = False", + "PROTOCOL = 'http://'", + "", + f"DOMAIN = '{_ext(host_ports, 'web', '/')}'", + "INTERNAL_DOMAIN = 'http://web:5000/'", + f"API_DOMAIN = '{_ext(host_ports, 'api', '/')}'", + f"WATERBUTLER_URL = '{_ext(host_ports, 'wb')}'", + "WATERBUTLER_INTERNAL_URL = 'http://wb:7777'", + f"MFR_SERVER_URL = '{_ext(host_ports, 'mfr')}'", + "MFR_INTERNAL_SERVER_URL = 'http://mfr:7778'", + f"CAS_SERVER_URL = '{_ext(host_ports, 'fakecas')}'", + "CAS_INTERNAL_SERVER_URL = 'http://fakecas:8080' # server-side ticket validation inside the network", + f"ADMIN_URL = '{_ext(host_ports, 'admin', '/')}'", + "ADMIN_INTERNAL_DOCKER_URL = 'http://admin:8001/'", + "", + "USE_EXTERNAL_EMBER = True", + "PROXY_EMBER_APPS = True", + "EMBER_DOMAIN = 'ember_osf_web' # web proxies to the ember container by service name", + f"LIVE_RELOAD_DOMAIN = '{_ext(host_ports, 'ember_osf_web')}' # the browser reaches live reload on the host", + "EXTERNAL_EMBER_APPS = {", + " 'ember_osf_web': {", + " 'server': 'http://ember_osf_web:4200/',", + " 'path': '/ember_osf_web/',", + " 'routes': ['collections', 'registries', 'handbook'],", + " },", + "}", + "PREPRINT_PROVIDER_DOMAINS = {'enabled': False, 'prefix': 'http://local.', 'suffix': ':4201/'}", + "", + "SEARCH_ENGINE = 'elastic'", + "ELASTIC_URI = 'elasticsearch:9200'", + "ELASTIC6_URI = 'elasticsearch6:9200'", + "ELASTIC_TIMEOUT = 10", + "", + "USE_EMAIL = False", + "MAIL_SERVER = 'localhost:1025'", + "ENABLE_EMAIL_SUBSCRIPTIONS = False", + "", + "COOKIE_NAME = 'osf'", + "OSF_COOKIE_DOMAIN = None", + "SECRET_KEY = environ['SECRET_KEY']", + "SESSION_COOKIE_SECURE = SECURE_MODE", + "SESSION_COOKIE_SAMESITE = 'Lax'", + "OSF_SERVER_KEY = None", + "OSF_SERVER_CERT = None", + "", + "WATERBUTLER_JWE_SALT = environ['WATERBUTLER_JWE_SALT']", + "WATERBUTLER_JWE_SECRET = environ['WATERBUTLER_JWE_SECRET']", + "WATERBUTLER_JWT_SECRET = environ['WATERBUTLER_JWT_SECRET']", + "", + "", + "class CeleryConfig(defaults.CeleryConfig):", + " broker_url = environ['BROKER_URL']", + "", + "", + "USE_CDN_FOR_CLIENT_LIBS = False", + "SENDGRID_WHITELIST_MODE = True", + "SENDGRID_EMAIL_WHITELIST = []", + "OSF_SUPPORT_EMAIL = 'support@example.invalid'", + "OSF_CONTACT_EMAIL = 'contact@example.invalid'", + "DOI_FORMAT = '{prefix}/FK2osf.io/{guid}'", + "CHRONOS_USE_FAKE_FILE = True", + "ENABLE_TIMESTAMP = False", + "SHARE_ENABLED = False", + "logging.getLogger('website.mails.mails').setLevel(logging.DEBUG)", + "", + ] + return "\n".join(lines) + + +def render_api_local_py(host_ports: dict[str, int]) -> str: + return "\n".join([ + f"# {GENERATED_HEADER}", + "from .defaults import * # noqa", + "from os import environ", + "from website import settings as osf_settings", + "", + "DEBUG = osf_settings.DEBUG_MODE", + "SECRET_KEY = environ['API_SECRET_KEY']", + "VARNISH_SERVERS = []", + "ENABLE_VARNISH = False", + "ENABLE_ESI = False", + "CORS_ORIGIN_ALLOW_ALL = True", + f"ALLOWED_HOSTS += ['{LOOPBACK}', 'localhost', 'api', 'web']", + "", + "REST_FRAMEWORK['DEFAULT_THROTTLE_RATES'] = {", + " 'user': '1000000/second',", + " 'non-cookie-auth': '1000000/second',", + " 'add-contributor': '1000000/second',", + " 'create-guid': '1000000/second',", + " 'root-anon-throttle': '1000000/second',", + " 'test-user': '2/hour',", + " 'test-anon': '1/hour',", + " 'send-email': '2/minute',", + " 'burst': '10/second',", + "}", + "", + ]) + + +def _env_text(pairs: list[tuple[str, str]]) -> str: + return f"# {GENERATED_HEADER}\n" + "".join(f"{k}={v}\n" for k, v in pairs) + + +def render_osf_env(host_ports: dict[str, int]) -> str: + return _env_text([ + ("DOMAIN", _ext(host_ports, "web", "/")), + ("INTERNAL_DOMAIN", "http://web:5000/"), + ("API_DOMAIN", _ext(host_ports, "api", "/")), + ("ELASTIC_URI", "elasticsearch:9200"), + ("ELASTIC6_URI", "elasticsearch6:9200"), + ("OSF_DB_HOST", "postgres"), + ("OSF_DB_PORT", "5432"), + ("OSF_DB_NAME", "osf"), + ("OSF_DB_USER", "postgres"), + ("DB_HOST", "postgres"), + ("WATERBUTLER_URL", _ext(host_ports, "wb")), + ("WATERBUTLER_INTERNAL_URL", "http://wb:7777"), + ("CAS_SERVER_URL", _ext(host_ports, "fakecas")), + ("CAS_INTERNAL_SERVER_URL", "http://fakecas:8080"), + ("MFR_SERVER_URL", _ext(host_ports, "mfr")), + ("MFR_INTERNAL_SERVER_URL", "http://mfr:7778"), + ("REDIS_URL", "redis://redis:6379/1"), + ("EMBER_DOMAIN", "ember_osf_web"), + ("ADMIN_URL", _ext(host_ports, "admin", "/")), + ("ADMIN_INTERNAL_DOCKER_URL", "http://admin:8001/"), + ]) + + +def render_wb_env(host_ports: dict[str, int]) -> str: + return _env_text([ + ("DEBUG", ""), + ("SERVER_CONFIG_DEBUG", ""), + ("SERVER_CONFIG_ADDRESS", "0.0.0.0"), + ("SERVER_CONFIG_PORT", "7777"), + ("SERVER_CONFIG_DOMAIN", _ext(host_ports, "wb")), + ("OSF_AUTH_CONFIG_API_URL", "http://web:5000/api/v1/files/auth/"), + ("OSF_URL", "http://web:5000"), + ]) + + +def render_mfr_env(host_ports: dict[str, int]) -> str: + allowed = " ".join(["http://web:5000/", "http://wb:7777/", _ext(host_ports, "web", "/"), _ext(host_ports, "wb", "/")]) + return _env_text([ + ("DEBUG", ""), + ("SERVER_CONFIG_DEBUG", ""), + ("SERVER_CONFIG_ADDRESS", "0.0.0.0"), + ("SERVER_CONFIG_PORT", "7778"), + ("SERVER_CONFIG_ALLOWED_PROVIDER_DOMAINS", f"'{allowed}'"), + ("UNOCONV_PORT_2002_TCP_ADDR", "unoconv"), + ("UNOCONV_PORT_2002_TCP_PORT", "2002"), + ("EXTENSION_CONFIG_LOCAL_DEVELOPMENT", "1"), + ("EXTENSION_CONFIG_DOCKER_LOCAL_HOST", "wb"), + ("EXTENSION_CONFIG_LOCAL_HOST", LOOPBACK), + ]) + + +def render_sharejs_env(host_ports: dict[str, int]) -> str: + return _env_text([ + ("SHAREJS_SERVER_HOST", "0.0.0.0"), + ("SHAREJS_SERVER_PORT", "7007"), + ("SHAREJS_DB_NAME", "sharejs"), + ("SHAREJS_DB_URL", "mongodb://mongo:27017/sharejs?ssl=true"), + ("SHAREJS_CORS_ALLOW_ORIGIN", _ext(host_ports, "web")), + ]) + + +def render_postgres_init() -> str: + return f"-- {GENERATED_HEADER}\n-- cas-overlay keeps its tickets in a second database on the shared postgres.\nCREATE DATABASE cas;\n" + + +def render_cas_properties(host_ports: dict[str, int]) -> str: + return "\n".join([ + f"# {GENERATED_HEADER}", + "server.name=http://cas:8080", + "server.prefix=${server.name}", + f"osf.url={_ext(host_ports, 'web', '/')}", + "osf.api.url=http://api:8000/", + "database.url=jdbc:postgresql://postgres:5432/cas", + "database.user=postgres", + "# database.password is read from the DATABASE_PASSWORD environment variable", + "", + ]) + + +def config_files(host_ports: dict[str, int]) -> dict[str, str]: + """Relative path under runtime/config -> content.""" + return { + "osf/local.py": render_website_local_py(host_ports), + "osf/api_local.py": render_api_local_py(host_ports), + "osf.env": render_osf_env(host_ports), + "wb.env": render_wb_env(host_ports), + "mfr.env": render_mfr_env(host_ports), + "sharejs.env": render_sharejs_env(host_ports), + "postgres-init/10-cas.sql": render_postgres_init(), + "cas/cas.properties": render_cas_properties(host_ports), + } + + +# --------------------------------------------------------------------------- files + + +def _write_if_changed(path: Path, text: str, mode: int = 0o644) -> bool: + path.parent.mkdir(parents=True, exist_ok=True) + if path.exists() and path.read_text(encoding="utf-8") == text: + return False + tmp = path.with_name(path.name + ".tmp") + fd = os.open(tmp, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, mode) + with os.fdopen(fd, "w", encoding="utf-8") as fh: + fh.write(text) + os.replace(tmp, path) + return True + + +def update_dotenv(path: Path, updates: dict[str, str]) -> bool: + """Set keys in runtime/.env in place, keeping every other line and mode 0600.""" + lines = path.read_text(encoding="utf-8").splitlines() if path.exists() else [] + seen: set[str] = set() + out: list[str] = [] + for line in lines: + key = line.partition("=")[0].strip() if "=" in line and not line.lstrip().startswith("#") else None + if key in updates: + out.append(f"{key}={updates[key]}") + seen.add(key) + else: + out.append(line) + for key, value in updates.items(): + if key not in seen: + out.append(f"{key}={value}") + text = "\n".join(out) + "\n" + changed = _write_if_changed(path, text, mode=0o600) + os.chmod(path, 0o600) + return changed + + +def built_image_tags(ctx: Context) -> dict[str, str]: + """component id -> sha12 from the latest build report, when one exists.""" + path = ctx.reports_dir / "build_latest.json" + if not path.exists(): + return {} + try: + data = json.loads(path.read_text(encoding="utf-8")) + except (OSError, ValueError): + return {} + return { + row["component"]: row["sha12"] + for row in data.get("components", []) + if row.get("sha12") and row.get("status") in ("built", "pushed") + } + + +def detect_memory_gib() -> float | None: + """Physical memory from os.sysconf (Linux, macOS); None when unknown. No subprocess, no Docker.""" + try: + pages = os.sysconf("SC_PHYS_PAGES") + page_size = os.sysconf("SC_PAGE_SIZE") + if pages > 0 and page_size > 0: + return pages * page_size / (1024 ** 3) + except (ValueError, OSError, AttributeError): + pass + return None + + +# --------------------------------------------------------------------------- entry point + + +def run( + ctx: Context, + args, + *, + memory_gib: float | None = None, + cpus: float | None = None, + port_checker: PortChecker | None = None, + platform_string: str | None = None, +) -> int: + if getattr(args, "compose_command", "render") != "render": + return report.error(ctx, exit_codes.USAGE, "usage: grdm-dev compose render [--profile ...]") + + errors = _manifest.validate(ctx) + if errors: + for line in errors: + sys.stderr.write(f" - {line}\n") + return report.error(ctx, exit_codes.MANIFEST_INVALID, f"{len(errors)} finding(s); run `grdm-dev manifest check`") + + dotenv = env_path(ctx) + if not dotenv.exists(): + return report.error(ctx, exit_codes.USAGE, f"{dotenv} not found; run `grdm-dev secrets init` first") + env = read_dotenv(dotenv) + missing = [k for k in REQUIRED_SECRETS if not env.get(k)] + if missing: + return report.error(ctx, exit_codes.USAGE, f"runtime/.env lacks {', '.join(missing)}; run `grdm-dev secrets init --force` or `secrets rotate`") + + try: + man = _manifest.load(ctx) + profile = resolve_profile(ctx, env) + auth = getattr(args, "auth", None) or _manifest.AUTH_FAKECAS + services = _manifest.services_for_profile(man, profile, auth, image_tags=built_image_tags(ctx)) + hardening = load_hardening(ctx.root) + except (_manifest.ManifestError, ValueError, OSError) as exc: + return report.error(ctx, exit_codes.MANIFEST_INVALID, str(exc)) + + rows, remapped, unresolved = assign_ports(published_ports(services, env), port_checker or default_port_checker) + if unresolved: + return report.error(ctx, exit_codes.PORT_IN_USE, f"no free port within +{PORT_SEARCH_RANGE} for: {', '.join(unresolved)}") + published = {r["service"]: int(r["host_port"]) for r in rows} + host_ports = host_port_map(env, rows) + + if memory_gib is None: + memory_gib = getattr(args, "memory_gib", None) or detect_memory_gib() or DEFAULT_MEMORY_GIB + if cpus is None: + cpus = getattr(args, "cpus", None) or float(os.cpu_count() or 0) or DEFAULT_CPUS + platform_string = platform_string or getattr(args, "platform", None) or detect_platform() + + compose = render_compose( + services, + runtime=ctx.runtime, + host_ports=host_ports, + published=published, + hardening=hardening, + memory_gib=float(memory_gib), + cpus=float(cpus), + platform_string=platform_string, + ) + compose_text = json.dumps(compose, indent=2, ensure_ascii=False) + "\n" + configs = config_files(host_ports) + for text in [compose_text, *configs.values()]: + if FORBIDDEN_ADDRESS in text: # defence in depth: ADR-02 forbids the alias anywhere + return report.error(ctx, exit_codes.MANIFEST_INVALID, f"generated output contains {FORBIDDEN_ADDRESS}") + + ctx.runtime.mkdir(parents=True, exist_ok=True) + written: list[str] = [] + if _write_if_changed(ctx.runtime / COMPOSE_FILE, compose_text): + written.append(COMPOSE_FILE) + for rel, text in configs.items(): + if _write_if_changed(ctx.runtime / CONFIG_DIR / rel, text): + written.append(f"{CONFIG_DIR}/{rel}") + for name in compose["volumes"]: + (ctx.runtime / VOLUMES_DIR / name).mkdir(parents=True, exist_ok=True) + env_updates = {PROFILE_ENV_KEY: profile} + env_updates.update({port_key(name): str(port) for name, port in published.items()}) + if update_dotenv(dotenv, env_updates): + written.append(".env (GRDM_PROFILE, GRDM_PORT_*)") + + data = { + "profile": profile, + "auth": auth, + "platform": platform_string, + "compose_file": str(ctx.runtime / COMPOSE_FILE), + "network": NETWORK, + "memory_gib": round(float(memory_gib), 1), + "cpus": float(cpus), + "services": [ + { + "service": s.name, + "image": s.image, + "user": compose["services"][s.name].get("user", "image default"), + "read_only": compose["services"][s.name]["read_only"], + "mem_limit": compose["services"][s.name]["mem_limit"], + "cpus": compose["services"][s.name]["cpus"], + "exceptions": compose["services"][s.name]["labels"]["org.gakunin-rdm.hardening-exception"], + } + for s in services + ], + "ports": rows, + "remapped_ports": remapped, + "volumes": list(compose["volumes"]), + "config_files": [f"{CONFIG_DIR}/{rel}" for rel in configs], + "written": written or ["(unchanged)"], + } + report.emit(ctx, "compose", data) + return exit_codes.OK diff --git a/installer/grdm_dev/docs.py b/installer/grdm_dev/docs.py new file mode 100644 index 0000000..3133816 --- /dev/null +++ b/installer/grdm_dev/docs.py @@ -0,0 +1,77 @@ +"""grdm-dev docs build | check — MkDocs build and the SPEC-06 §8 checks (SPEC-02 §3). + +`build` runs `mkdocs build --strict` with the MkDocs of the current virtual environment (installed by +`pip install -e "installer[docs]"`); a missing mkdocs is exit 2 with that hint. `check` runs the CI +validator tools/docs_check.py in-process and returns its exit code (0 pass, 1 failure, 2 usage). +""" +from __future__ import annotations + +import shutil +import subprocess +import sys +from pathlib import Path +from typing import Callable + +from . import exit_codes, report +from .context import Context +from .manifest_cmd import load_tool + +INSTALL_HINT = 'pip install -e "installer[docs]"' +Runner = Callable[[list[str]], tuple[int, str]] + + +def register(subparsers) -> None: + p = subparsers.add_parser("docs", help="build the MkDocs site or run the SPEC-06 documentation checks") + sub = p.add_subparsers(dest="docs_action", metavar="") + sub.add_parser("build", help="mkdocs build --strict into site/ (exit 2 with install hint if mkdocs is missing)") + c = sub.add_parser("check", help="SPEC-06 §8 checks via tools/docs_check.py") + c.add_argument("--all-warnings", action="store_true", help="print every glossary warning") + p.set_defaults(_module=sys.modules[__name__]) + + +def find_mkdocs() -> str | None: + """Prefer the mkdocs next to the running Python (the .venv), then PATH.""" + cand = Path(sys.executable).parent / ("mkdocs.exe" if sys.platform == "win32" else "mkdocs") + if cand.exists(): + return str(cand) + return shutil.which("mkdocs") + + +def _default_runner(cwd: Path) -> Runner: + def _run(argv: list[str]) -> tuple[int, str]: + try: + proc = subprocess.run(argv, cwd=str(cwd), capture_output=True, text=True) + except FileNotFoundError: + return 127, "" + sys.stdout.write(proc.stdout) + sys.stderr.write(proc.stderr) + return proc.returncode, proc.stdout + return _run + + +def run(ctx: Context, args, runner: Runner | None = None, mkdocs: str | None = None) -> int: + action = getattr(args, "docs_action", None) + if action == "build": + exe = mkdocs or find_mkdocs() + if not exe: + return report.error(ctx, exit_codes.USAGE, f"mkdocs not found; install with {INSTALL_HINT}") + runner = runner or _default_runner(ctx.root) + rc, _ = runner([exe, "build", "--strict", "-f", str(ctx.root / "mkdocs.yml")]) + if rc == 127: + return report.error(ctx, exit_codes.USAGE, f"mkdocs could not start; install with {INSTALL_HINT}") + if rc != 0: + sys.stderr.write(f"[grdm-dev] mkdocs build --strict failed (rc {rc})\n") + return 1 + sys.stdout.write(f"site built into {ctx.root / 'site'}\n") + return exit_codes.OK + if action == "check": + try: + dc = load_tool(ctx.root, "docs_check") + except FileNotFoundError as exc: + return report.error(ctx, exit_codes.USAGE, f"validator not found: {exc}") + argv = ["--root", str(ctx.root)] + if getattr(args, "all_warnings", False): + argv.append("--all-warnings") + return int(dc.main(argv)) + sys.stderr.write("usage: grdm-dev docs \n") + return exit_codes.USAGE diff --git a/installer/grdm_dev/doctor.py b/installer/grdm_dev/doctor.py index 2e25d25..3f7382e 100644 --- a/installer/grdm_dev/doctor.py +++ b/installer/grdm_dev/doctor.py @@ -5,6 +5,11 @@ run(ctx, args) -> int: return an exit code from grdm_dev.exit_codes Tests inject a fake `runner` (callable taking argv list, returning (returncode, stdout)) so Docker is never required by unit tests (SPEC-02 §10). + +Exit codes: 10 when the host itself is unsupported (OS, CPU, memory, Python), 11 when Docker is +missing, not running, or lacks the Compose / buildx plugin. Warnings (best-effort host, low +memory, little disk) do not change the exit code unless `--strict` is given, which turns them +into exit 10 so CI can insist on an official host. """ from __future__ import annotations @@ -16,15 +21,19 @@ def register(subparsers) -> None: p = subparsers.add_parser("doctor", help="detect OS, CPU, memory, disk, Docker; exit 10/11 if unsupported") + p.add_argument("--strict", action="store_true", help="treat warnings (best-effort host, low memory) as exit 10") p.set_defaults(_module=sys.modules[__name__]) -def run(ctx: Context, args, runner=None) -> int: - info = host.detect(runner=runner) +def run(ctx: Context, args, runner=None, probe=None) -> int: + info = host.detect(runner=runner, probe=probe, root=ctx.root) data = host.as_report(info) + data["strict"] = bool(getattr(args, "strict", False)) report.emit(ctx, "doctor", data) if not info.supported: return report.error(ctx, exit_codes.HOST_UNSUPPORTED, "; ".join(info.problems)) if not info.docker_ok: return report.error(ctx, exit_codes.DOCKER_MISSING, "; ".join(info.problems)) + if data["strict"] and info.warnings: + return report.error(ctx, exit_codes.HOST_UNSUPPORTED, "--strict: " + "; ".join(info.warnings)) return exit_codes.OK diff --git a/installer/grdm_dev/health.py b/installer/grdm_dev/health.py new file mode 100644 index 0000000..9f0cc9b --- /dev/null +++ b/installer/grdm_dev/health.py @@ -0,0 +1,249 @@ +"""grdm-dev health [--network] — service health and loopback-only check (SPEC-02 §3, SPEC-03 §3.2, ADR-02). + +Reads runtime/docker-compose.yml (written as JSON by `compose render`) for the service names, +asks `docker compose ps --format json` for container state and health, and probes the browser- +facing HTTP endpoints on 127.0.0.1: for the services of the SPEC-02 §4 ports table that the +Compose file defines. Any missing, stopped, unhealthy or unreachable service is exit 40. + +--network lists the listening TCP sockets of the host (`lsof -nP -iTCP -sTCP:LISTEN` on macOS, +`ss -ltnp` on Linux) and fails with exit 40 when a Docker-owned socket (docker-proxy, com.docker) +is bound to 0.0.0.0, :: / * or any other non-loopback address. + +Injection points for tests: `runner(argv) -> (rc, stdout)`, `prober(url) -> (ok, detail)`, +`system` ("Darwin" / "Linux"). +""" +from __future__ import annotations + +import json +import platform as _platform +import subprocess +import sys +import time +import urllib.error +import urllib.request +from pathlib import Path + +from . import exit_codes, report +from .context import Context + +COMPOSE_PROJECT = "grdm-dev" +HTTP_SERVICES: tuple[str, ...] = ("web", "api", "admin", "wb", "mfr", "ember_osf_web", "fakecas") +DOCKER_PROCESS_MARKERS: tuple[str, ...] = ("docker-proxy", "docker-pr", "com.docker", "com.docke", "vpnkit") +HTTP_TIMEOUT = 3.0 + + +def default_runner(argv: list[str]) -> tuple[int, str]: + try: + proc = subprocess.run(argv, capture_output=True, text=True) + except OSError as exc: + return 127, str(exc) + return proc.returncode, proc.stdout + + +def default_prober(url: str) -> tuple[bool, str]: + """HTTP GET; any response below 500 counts as reachable (login redirects are fine).""" + try: + with urllib.request.urlopen(url, timeout=HTTP_TIMEOUT) as resp: # noqa: S310 - loopback only + return resp.status < 500, f"HTTP {resp.status}" + except urllib.error.HTTPError as exc: + return exc.code < 500, f"HTTP {exc.code}" + except (urllib.error.URLError, OSError, ValueError) as exc: + return False, str(getattr(exc, "reason", exc)) + + +def compose_path(ctx: Context) -> Path: + return ctx.runtime / "docker-compose.yml" + + +def compose_base(ctx: Context) -> list[str]: + return ["docker", "compose", "-f", str(compose_path(ctx)), "--project-name", COMPOSE_PROJECT] + + +def load_compose(path: Path) -> dict: + return json.loads(path.read_text(encoding="utf-8")) + + +def parse_ps(output: str) -> dict[str, dict]: + """`docker compose ps --format json` prints either a JSON array or one object per line.""" + text = output.strip() + if not text: + return {} + items: list[dict] = [] + try: + parsed = json.loads(text) + items = parsed if isinstance(parsed, list) else [parsed] + except ValueError: + for line in text.splitlines(): + line = line.strip() + if line.startswith("{"): + try: + items.append(json.loads(line)) + except ValueError: + continue + by_service: dict[str, dict] = {} + for it in items: + name = it.get("Service") or it.get("service") or it.get("Name") or "" + if name: + by_service[name] = it + return by_service + + +def host_port(service: str, compose: dict, env: dict[str, str]) -> int | None: + """Host port from the Compose `ports` entry (127.0.0.1:host:container) or GRDM_PORT_.""" + svc = compose.get("services", {}).get(service) or {} + for entry in svc.get("ports", []) or []: + if isinstance(entry, dict): + published = entry.get("published") + if published: + try: + return int(str(published)) + except ValueError: + pass + continue + parts = str(entry).split(":") + if len(parts) >= 2: + try: + return int(parts[-2]) + except ValueError: + continue + value = env.get(f"GRDM_PORT_{service.upper()}") + if value and value.isdigit(): + return int(value) + return None + + +def check_services(ctx: Context, runner, prober) -> tuple[list[dict], bool]: + """One row per service of the Compose file; returns (rows, all_healthy).""" + from .secrets import env_path, read_env + + compose = load_compose(compose_path(ctx)) + env = read_env(env_path(ctx)) + services = list((compose.get("services") or {}).keys()) + rc, out = runner(compose_base(ctx) + ["ps", "--all", "--format", "json"]) + ps = parse_ps(out) if rc == 0 else {} + rows: list[dict] = [] + all_ok = rc == 0 + for name in services: + info = ps.get(name, {}) + state = str(info.get("State") or info.get("state") or ("missing" if not info else "unknown")).lower() + health = str(info.get("Health") or info.get("health") or "").lower() + ok = state == "running" and health in ("", "healthy") + url = "" + http = "" + if name in HTTP_SERVICES: + port = host_port(name, compose, env) + if port: + url = f"http://127.0.0.1:{port}/" + reachable, http = prober(url) + ok = ok and reachable + rows.append({"service": name, "state": state, "health": health or "n/a", "url": url, "http": http, "ok": ok}) + all_ok = all_ok and ok + return rows, all_ok + + +def _addr_port(addr: str) -> tuple[str, str]: + addr = addr.strip() + if addr.startswith("["): # [::1]:5000 + host, _, port = addr[1:].partition("]:") + return host, port + host, _, port = addr.rpartition(":") + return host, port + + +def is_loopback(host: str) -> bool: + host = host.strip("[]") + return host.startswith("127.") or host in ("::1", "localhost", "::ffff:127.0.0.1") + + +def is_docker_process(name: str) -> bool: + low = name.lower() + return any(marker in low for marker in DOCKER_PROCESS_MARKERS) + + +def parse_lsof(output: str) -> list[dict]: + rows = [] + for line in output.splitlines()[1:]: + parts = line.split() + if len(parts) < 9 or "LISTEN" not in line: + continue + host, port = _addr_port(parts[8]) + rows.append({"process": parts[0], "address": host or "*", "port": port, "loopback": is_loopback(host)}) + return rows + + +def parse_ss(output: str) -> list[dict]: + rows = [] + for line in output.splitlines(): + parts = line.split() + if len(parts) < 5 or parts[0] != "LISTEN": + continue + host, port = _addr_port(parts[3]) + proc = "" + for p in parts[5:]: + if p.startswith("users:(("): + proc = p[len("users:((") :].split('"')[1] if '"' in p else p + rows.append({"process": proc, "address": host or "*", "port": port, "loopback": is_loopback(host)}) + return rows + + +def listening_sockets(runner, system: str | None = None) -> tuple[list[dict], str]: + system = system or _platform.system() + if system == "Darwin": + rc, out = runner(["lsof", "-nP", "-iTCP", "-sTCP:LISTEN"]) + # lsof exits 1 when nothing matched; that is still a valid (empty) answer + return (parse_lsof(out) if rc in (0, 1) else []), ("" if rc in (0, 1) else f"lsof exited {rc}") + rc, out = runner(["ss", "-ltnp"]) + return (parse_ss(out) if rc == 0 else []), ("" if rc == 0 else f"ss exited {rc}") + + +def check_network(runner, system: str | None = None) -> tuple[list[dict], list[dict], str]: + """Return (docker sockets, offending non-loopback docker sockets, error).""" + sockets, err = listening_sockets(runner, system) + docker = [s for s in sockets if is_docker_process(s["process"])] + bad = [s for s in docker if not s["loopback"]] + return docker, bad, err + + +def wait_until_healthy(ctx: Context, timeout: float, runner=None, prober=None, sleep=time.sleep, interval: float = 5.0) -> tuple[list[dict], bool]: + """Poll check_services until every service is healthy or the timeout passes.""" + runner = runner or default_runner + prober = prober or default_prober + deadline = time.monotonic() + timeout + rows, ok = check_services(ctx, runner, prober) + while not ok and time.monotonic() < deadline: + sleep(interval) + rows, ok = check_services(ctx, runner, prober) + return rows, ok + + +def register(subparsers) -> None: + p = subparsers.add_parser("health", help="check every service; --network also fails on non-loopback listeners (exit 40)") + p.add_argument("--network", action="store_true", help="list listening sockets and require 127.0.0.1 only") + p.set_defaults(_module=sys.modules[__name__]) + + +def run(ctx: Context, args, runner=None, prober=None, system: str | None = None) -> int: + runner = runner or default_runner + prober = prober or default_prober + path = compose_path(ctx) + if not path.exists(): + return report.error(ctx, exit_codes.USAGE, f"{path} not found; run `grdm-dev compose render` first") + try: + rows, ok = check_services(ctx, runner, prober) + except ValueError as exc: + return report.error(ctx, exit_codes.HEALTH_FAILED, f"cannot parse {path}: {exc}") + data: dict = {"services": rows, "healthy": ok} + problems: list[str] = [f"{r['service']} ({r['state']}, {r['health']}{', ' + r['http'] if r['http'] else ''})" for r in rows if not r["ok"]] + if getattr(args, "network", False): + docker, bad, err = check_network(runner, system) + data["sockets"] = docker + data["loopback_only"] = not bad and not err + if err: + problems.append(err) + for s in bad: + problems.append(f"{s['process']} listens on {s['address']}:{s['port']} (not loopback)") + ok = ok and not bad and not err + report.emit(ctx, "health", data) + if not ok: + return report.error(ctx, exit_codes.HEALTH_FAILED, "; ".join(problems)) + return exit_codes.OK diff --git a/installer/grdm_dev/host.py b/installer/grdm_dev/host.py new file mode 100644 index 0000000..8c66917 --- /dev/null +++ b/installer/grdm_dev/host.py @@ -0,0 +1,301 @@ +"""Host detection: OS, CPU, memory, disk, Python, Docker (SPEC-02 §3 `doctor`, §8 supported hosts). + +Everything that touches the machine goes through two seams so unit tests never need Docker: + +* `Probe` — plain facts read with `platform`, `os`, `shutil` (OS name, kernel, /etc/os-release, + /proc/version, memory, free disk). Tests build a `Probe` by hand. +* `runner(argv) -> (returncode, stdout)` — runs `docker ...`. Tests pass a fake. + +`detect()` turns those facts into a `HostInfo`; `as_report()` flattens it for TOON/JSON. +""" +from __future__ import annotations + +import os +import platform +import re +import shutil +import subprocess +import sys +from dataclasses import asdict, dataclass, field +from pathlib import Path +from typing import Callable, Optional + +Runner = Callable[[list[str]], tuple[int, str]] + +GIB = 1024 ** 3 +MIN_MEMORY_BYTES = 8 * GIB +RECOMMENDED_MEMORY_BYTES = 16 * GIB +MIN_DISK_FREE_BYTES = 40 * GIB +MIN_PYTHON = (3, 11) +MIN_DOCKER_MAJOR = 27 +MIN_COMPOSE_MAJOR = 2 +SUBPROCESS_TIMEOUT = 15 + +# Official hosts (SPEC-02 §8). Anything else is best-effort: a warning, not a problem. +OFFICIAL = {("macos", "arm64"), ("ubuntu", "amd64"), ("ubuntu", "arm64"), ("wsl2", "amd64")} + + +def default_runner(argv: list[str]) -> tuple[int, str]: + """Run a command, merging stderr into stdout; a missing or hanging tool is a non-zero result.""" + try: + cp = subprocess.run( + argv, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, timeout=SUBPROCESS_TIMEOUT + ) + return cp.returncode, cp.stdout + except FileNotFoundError: + return 127, f"{argv[0]}: command not found" + except subprocess.TimeoutExpired: + return 124, f"{' '.join(argv)}: timed out after {SUBPROCESS_TIMEOUT}s" + except OSError as exc: + return 126, f"{argv[0]}: {exc}" + + +@dataclass +class Probe: + """Raw facts about the machine. `Probe.from_system()` reads them; tests set them directly.""" + + system: str = "" # platform.system(): Darwin | Linux | Windows | ... + release: str = "" # platform.release(): kernel version + machine: str = "" # platform.machine(): arm64 | x86_64 | aarch64 | ... + mac_ver: str = "" # platform.mac_ver()[0] on macOS, else "" + os_release: str = "" # contents of /etc/os-release (Linux), else "" + proc_version: str = "" # contents of /proc/version (Linux), else "" + env: dict[str, str] = field(default_factory=dict) + python_version: tuple[int, int, int] = (0, 0, 0) + memory_bytes: Optional[int] = None + disk_free_bytes: Optional[int] = None + docker_path: Optional[str] = None # shutil.which("docker") + + @classmethod + def from_system(cls, root: Path | None = None, runner: Runner | None = None) -> "Probe": + root = root or Path.cwd() + system = platform.system() + p = cls( + system=system, + release=platform.release(), + machine=platform.machine(), + mac_ver=platform.mac_ver()[0] if system == "Darwin" else "", + os_release=_read_text("/etc/os-release") or _read_text("/usr/lib/os-release") if system == "Linux" else "", + proc_version=_read_text("/proc/version") if system == "Linux" else "", + env=dict(os.environ), + python_version=tuple(sys.version_info[:3]), # type: ignore[arg-type] + memory_bytes=_memory_bytes(runner or default_runner, system), + disk_free_bytes=_disk_free_bytes(root), + docker_path=shutil.which("docker"), + ) + return p + + +@dataclass +class HostInfo: + os_name: str = "unsupported" # macos | ubuntu | wsl2 | linux-other | unsupported + os_version: str = "" + arch: str = "other" # arm64 | amd64 | other + memory_bytes: Optional[int] = None + disk_free_bytes: Optional[int] = None + python_version: str = "" + docker_version: str = "" + compose_version: str = "" + buildx_present: bool = False + docker_running: bool = False + supported: bool = False + docker_ok: bool = False + problems: list[str] = field(default_factory=list) + warnings: list[str] = field(default_factory=list) + platform_string: str = "" # linux/arm64 | linux/amd64 (empty when arch is other) + + +# --- raw readers ------------------------------------------------------------------------------- + +def _read_text(path: str) -> str: + try: + return Path(path).read_text(encoding="utf-8", errors="replace") + except OSError: + return "" + + +def _memory_bytes(runner: Runner, system: str) -> Optional[int]: + try: + pages = os.sysconf("SC_PHYS_PAGES") + page = os.sysconf("SC_PAGE_SIZE") + if pages > 0 and page > 0: + return int(pages) * int(page) + except (ValueError, OSError, AttributeError): + pass + if system == "Darwin": + rc, out = runner(["sysctl", "-n", "hw.memsize"]) + if rc == 0 and out.strip().isdigit(): + return int(out.strip()) + return None + + +def _disk_free_bytes(root: Path) -> Optional[int]: + try: + return shutil.disk_usage(str(root)).free + except OSError: + return None + + +# --- classification ---------------------------------------------------------------------------- + +def parse_os_release(text: str) -> dict[str, str]: + out: dict[str, str] = {} + for line in text.splitlines(): + line = line.strip() + if not line or line.startswith("#") or "=" not in line: + continue + k, _, v = line.partition("=") + out[k.strip()] = v.strip().strip('"').strip("'") + return out + + +def classify_arch(machine: str) -> str: + m = (machine or "").lower() + if m in ("arm64", "aarch64"): + return "arm64" + if m in ("x86_64", "amd64"): + return "amd64" + return "other" + + +def classify_os(probe: Probe) -> tuple[str, str]: + """Return (os_name, os_version).""" + system = (probe.system or "").strip() + if system == "Darwin": + return "macos", probe.mac_ver or probe.release + if system == "Linux": + rel = parse_os_release(probe.os_release) + version = rel.get("VERSION_ID", "") or rel.get("PRETTY_NAME", "") + is_wsl = "microsoft" in (probe.proc_version or "").lower() or "microsoft" in (probe.release or "").lower() \ + or bool(probe.env.get("WSL_DISTRO_NAME")) + if is_wsl: + return "wsl2", version + if rel.get("ID", "").lower() == "ubuntu": + return "ubuntu", version + return "linux-other", version + return "unsupported", f"{system} {probe.release}".strip() + + +def parse_version(text: str) -> tuple[int, ...]: + """First dotted number in `text` as a tuple of ints; () when none.""" + m = re.search(r"(\d+)(?:\.(\d+))?(?:\.(\d+))?", text or "") + if not m: + return () + return tuple(int(g) for g in m.groups() if g is not None) + + +def _fmt_gib(n: Optional[int]) -> str: + return "unknown" if n is None else f"{n / GIB:.1f} GiB" + + +# --- docker ------------------------------------------------------------------------------------ + +def check_docker(runner: Runner, info: HostInfo) -> None: + """Fill docker_* fields and append problems; docker_ok is True only when every check passes.""" + rc, out = runner(["docker", "version", "--format", "{{.Server.Version}}"]) + out = (out or "").strip() + if rc == 127 or (rc != 0 and "command not found" in out): + info.problems.append("docker command not found / docker コマンドが見つかりません") + return + if rc != 0 or not parse_version(out): + detail = out.splitlines()[0] if out else f"exit {rc}" + info.problems.append(f"docker daemon not running or unreachable ({detail}) / Docker デーモンが動いていないか到達できません") + return + info.docker_running = True + info.docker_version = out.splitlines()[0] + ver = parse_version(info.docker_version) + if ver and ver[0] < MIN_DOCKER_MAJOR: + info.problems.append( + f"docker {info.docker_version} is older than {MIN_DOCKER_MAJOR} / Docker {info.docker_version} は {MIN_DOCKER_MAJOR} より古いです" + ) + + rc, out = runner(["docker", "compose", "version"]) + cver = parse_version(out or "") + if rc != 0 or not cver: + info.problems.append("docker compose plugin missing / Docker Compose プラグインがありません") + else: + info.compose_version = ".".join(str(x) for x in cver) + if cver[0] < MIN_COMPOSE_MAJOR: + info.problems.append( + f"docker compose v{info.compose_version} is older than v{MIN_COMPOSE_MAJOR} / Docker Compose v{info.compose_version} は v{MIN_COMPOSE_MAJOR} より古いです" + ) + + rc, out = runner(["docker", "buildx", "version"]) + if rc == 0 and parse_version(out or ""): + info.buildx_present = True + else: + info.problems.append("docker buildx plugin missing / Docker buildx プラグインがありません") + + +# --- entry points ------------------------------------------------------------------------------ + +def detect(runner: Runner | None = None, probe: Probe | None = None, root: Path | None = None) -> HostInfo: + """Detect the host. `runner` and `probe` are injectable so tests never touch Docker or the OS.""" + runner = runner or default_runner + probe = probe or Probe.from_system(root=root, runner=runner) + info = HostInfo() + + info.os_name, info.os_version = classify_os(probe) + info.arch = classify_arch(probe.machine) + info.memory_bytes = probe.memory_bytes + info.disk_free_bytes = probe.disk_free_bytes + info.python_version = ".".join(str(x) for x in probe.python_version) if probe.python_version else "" + if info.arch in ("arm64", "amd64"): + info.platform_string = f"linux/{info.arch}" + + # Host problems (-> exit 10) + if info.os_name == "unsupported": + info.problems.append( + f"operating system not supported: {info.os_version} / 対応していない OS です: {info.os_version}" + ) + if info.arch == "other": + info.problems.append( + f"CPU architecture not supported: {probe.machine} / 対応していない CPU です: {probe.machine}" + ) + if probe.python_version and tuple(probe.python_version[:2]) < MIN_PYTHON: + info.problems.append( + f"Python {info.python_version} is older than 3.11 / Python {info.python_version} は 3.11 より古いです" + ) + if info.memory_bytes is not None and info.memory_bytes < MIN_MEMORY_BYTES: + info.problems.append( + f"memory {_fmt_gib(info.memory_bytes)} is below the 8 GiB minimum / メモリ {_fmt_gib(info.memory_bytes)} は最低 8 GiB 未満です" + ) + + # Host warnings (best-effort hosts, SPEC-02 §8) + if info.os_name in ("macos", "ubuntu", "wsl2", "linux-other") and info.arch != "other" \ + and (info.os_name, info.arch) not in OFFICIAL: + info.warnings.append( + f"{info.os_name}/{info.arch} is best-effort, not an official host / {info.os_name}/{info.arch} は公式対応外(可能な限りの対応)です" + ) + if info.os_name == "macos" and parse_version(info.os_version)[:1] and parse_version(info.os_version)[0] < 14: + info.warnings.append(f"macOS {info.os_version} is older than 14 / macOS {info.os_version} は 14 より古いです") + if info.os_name in ("ubuntu", "wsl2") and info.os_version and parse_version(info.os_version)[:1] \ + and parse_version(info.os_version)[0] < 24: + info.warnings.append(f"Ubuntu {info.os_version} is older than 24.04 / Ubuntu {info.os_version} は 24.04 より古いです") + if info.memory_bytes is None: + info.warnings.append("memory size could not be read / メモリ量を読めませんでした") + elif info.memory_bytes < RECOMMENDED_MEMORY_BYTES: + info.warnings.append( + f"memory {_fmt_gib(info.memory_bytes)} is below the recommended 16 GiB / メモリ {_fmt_gib(info.memory_bytes)} は推奨 16 GiB 未満です" + ) + if info.disk_free_bytes is not None and info.disk_free_bytes < MIN_DISK_FREE_BYTES: + info.warnings.append( + f"free disk {_fmt_gib(info.disk_free_bytes)} is below the recommended 40 GiB / 空き容量 {_fmt_gib(info.disk_free_bytes)} は推奨 40 GiB 未満です" + ) + + info.supported = not info.problems + + # Docker (-> exit 11); counted separately so doctor can tell 10 from 11. + before = len(info.problems) + check_docker(runner, info) + info.docker_ok = len(info.problems) == before + return info + + +def as_report(info: HostInfo) -> dict: + """Flat, TOON-friendly dict (SPEC-06 §4): scalars plus two string lists.""" + d = asdict(info) + d["memory_gib"] = None if info.memory_bytes is None else round(info.memory_bytes / GIB, 1) + d["disk_free_gib"] = None if info.disk_free_bytes is None else round(info.disk_free_bytes / GIB, 1) + d["official"] = (info.os_name, info.arch) in OFFICIAL + return d diff --git a/installer/grdm_dev/install.py b/installer/grdm_dev/install.py new file mode 100644 index 0000000..e46811d --- /dev/null +++ b/installer/grdm_dev/install.py @@ -0,0 +1,96 @@ +"""grdm-dev install — the SPEC-02 §2.1 sequence, stopping at the first non-zero step. + + doctor → plan → secrets init (skipped when runtime/.env exists) → compose render → build + → up → health --network → scan (if the module exists) → report + +Each step is run through the normal CLI parser so that every sibling module keeps ownership of its +own flags: the step's argv is parsed with cli.build_parser() and `args._module.run(ctx, args)` is +called. Modules are imported lazily by the parser, so a step whose module is not yet implemented +is reported as "not available" — fatal for required steps, a notice for optional ones (scan, report). + +Tests inject `run_step(ctx, argv) -> int` and never touch Docker. +""" +from __future__ import annotations + +import sys +from collections.abc import Callable + +from . import exit_codes, report +from .context import Context + +OPTIONAL_STEPS: frozenset[str] = frozenset({"scan", "report"}) + + +def default_run_step(ctx: Context, argv: list[str]) -> int: + """Parse argv with the real parser and run the matching module. Returns -1 when the subcommand is missing.""" + from . import cli + + parser = cli.build_parser() + try: + args = parser.parse_args(argv) + except SystemExit: + return -1 + mod = getattr(args, "_module", None) + if mod is None: + return -1 + return int(mod.run(ctx, args)) + + +def plan_steps(ctx: Context, *, platform: str | None, no_open: bool) -> list[tuple[str, list[str]]]: + from .secrets import env_path + + steps: list[tuple[str, list[str]]] = [("doctor", ["doctor"]), ("plan", ["plan"])] + if not env_path(ctx).exists(): + steps.append(("secrets init", ["secrets", "init"])) + steps.append(("compose render", ["compose", "render"])) + build = ["build"] + (["--platform", platform] if platform else []) + steps.append(("build", build)) + steps.append(("up", ["up"] + (["--no-open"] if no_open else []))) + steps.append(("health --network", ["health", "--network"])) + steps.append(("scan", ["scan"])) + steps.append(("report", ["report"])) + return steps + + +def register(subparsers) -> None: + p = subparsers.add_parser("install", help="doctor → plan → secrets → compose → build → up → health → scan → report") + p.add_argument("--platform", help="comma-separated platforms for build (default: host platform)") + p.add_argument("--no-open", dest="no_open", action="store_true", help="do not open the browser after up") + p.set_defaults(_module=sys.modules[__name__]) + + +def run(ctx: Context, args, run_step: Callable[[Context, list[str]], int] | None = None) -> int: + from .lifecycle import web_url + from .secrets import env_path + + run_step = run_step or default_run_step + steps = plan_steps(ctx, platform=getattr(args, "platform", None), no_open=bool(getattr(args, "no_open", False))) + skipped_secrets = env_path(ctx).exists() + rows: list[dict] = [] + if skipped_secrets: + rows.append({"step": "secrets init", "code": 0, "status": "skipped (runtime/.env exists)"}) + final = exit_codes.OK + for name, argv in steps: + sys.stderr.write(f"[grdm-dev] install: {name}\n") + code = run_step(ctx, argv) + if code == -1: + key = argv[0] + if key in OPTIONAL_STEPS: + sys.stderr.write(f"[grdm-dev] install: `{name}` is not yet available; continuing\n") + rows.append({"step": name, "code": 0, "status": "not available"}) + continue + rows.append({"step": name, "code": exit_codes.USAGE, "status": "not available"}) + final = exit_codes.USAGE + report.emit(ctx, "install", {"steps": rows, "result": final, "url": None}) + return report.error(ctx, exit_codes.USAGE, f"required step `{name}` is not available in this build of grdm-dev") + rows.append({"step": name, "code": code, "status": "ok" if code == 0 else "failed"}) + if code != 0: + final = code + break + url = web_url(ctx) if final == exit_codes.OK else None + report.emit(ctx, "install", {"steps": rows, "result": final, "url": url}) + if final != exit_codes.OK: + failed = next((r["step"] for r in rows if r["status"] == "failed"), "?") + return report.error(ctx, final, f"stopped at `{failed}`") + sys.stdout.write(f"\nGakuNin RDM developer environment is ready: {url}\n") + return exit_codes.OK diff --git a/installer/grdm_dev/lifecycle.py b/installer/grdm_dev/lifecycle.py new file mode 100644 index 0000000..d2d6454 --- /dev/null +++ b/installer/grdm_dev/lifecycle.py @@ -0,0 +1,142 @@ +"""grdm-dev up / down / reset — container lifecycle for the rendered profile (SPEC-02 §3, §7). + +up `docker compose up -d`, then wait for health (exit 40 on timeout), then open the browser at + http://127.0.0.1: unless --no-open; the browser is only opened when stdin is a + terminal. Idempotent: healthy services are left alone by Compose. +down `docker compose down` — containers stop, volumes stay. +reset down, then delete runtime/volumes/ after ctx.confirm(). Non-interactive without --yes → exit 2. + +Helpers for other modules: running_services(ctx) and restart(ctx, services) (used by secrets rotate). +Runner: `runner(argv) -> (rc, stdout)`; tests inject a fake and never need Docker. +""" +from __future__ import annotations + +import shutil +import sys +import webbrowser + +from . import exit_codes, health, report +from .context import Context + +DEFAULT_TIMEOUT = 300.0 + + +def default_runner(argv: list[str]) -> tuple[int, str]: + return health.default_runner(argv) + + +def streaming_runner(argv: list[str]) -> tuple[int, str]: + from .build import default_runner as _stream + + return _stream(argv) + + +def web_url(ctx: Context) -> str: + from .secrets import DEFAULT_PORTS, env_path, read_env + + port = read_env(env_path(ctx)).get("GRDM_PORT_WEB") or str(DEFAULT_PORTS["web"]) + return f"http://127.0.0.1:{port}/" + + +def running_services(ctx: Context, runner=None) -> list[str]: + runner = runner or default_runner + if not health.compose_path(ctx).exists(): + return [] + rc, out = runner(health.compose_base(ctx) + ["ps", "--format", "json"]) + if rc != 0: + raise RuntimeError(f"docker compose ps exited {rc}") + ps = health.parse_ps(out) + return [name for name, info in ps.items() if str(info.get("State") or info.get("state") or "").lower() == "running"] + + +def restart(ctx: Context, services: list[str] | None = None, runner=None) -> int: + runner = runner or default_runner + rc, _ = runner(health.compose_base(ctx) + ["restart", *(services or [])]) + return rc + + +def register(subparsers) -> None: + up = subparsers.add_parser("up", help="start the profile and wait for health; exit 40 on failure") + up.add_argument("--no-open", dest="no_open", action="store_true", help="do not open the browser") + up.add_argument("--timeout", type=float, default=DEFAULT_TIMEOUT, help=f"seconds to wait for health (default {int(DEFAULT_TIMEOUT)})") + up.set_defaults(_module=sys.modules[__name__], lifecycle_action="up") + down = subparsers.add_parser("down", help="stop containers, keep volumes") + down.set_defaults(_module=sys.modules[__name__], lifecycle_action="down") + reset = subparsers.add_parser("reset", help="stop containers and delete runtime/volumes/ (asks first; --yes skips)") + reset.set_defaults(_module=sys.modules[__name__], lifecycle_action="reset") + + +def run(ctx: Context, args, runner=None, prober=None, opener=None, sleep=None, rmtree=None) -> int: + action = getattr(args, "lifecycle_action", None) + if action == "up": + return run_up(ctx, no_open=bool(getattr(args, "no_open", False)), timeout=float(getattr(args, "timeout", DEFAULT_TIMEOUT)), + runner=runner, prober=prober, opener=opener, sleep=sleep) + if action == "down": + return run_down(ctx, runner=runner) + if action == "reset": + return run_reset(ctx, runner=runner, rmtree=rmtree) + return report.error(ctx, exit_codes.USAGE, "choose up, down or reset") + + +def _require_compose(ctx: Context) -> int | None: + path = health.compose_path(ctx) + if not path.exists(): + return report.error(ctx, exit_codes.USAGE, f"{path} not found; run `grdm-dev compose render` first") + return None + + +def run_up(ctx: Context, no_open: bool = False, timeout: float = DEFAULT_TIMEOUT, runner=None, prober=None, opener=None, sleep=None) -> int: + missing = _require_compose(ctx) + if missing is not None: + return missing + runner = runner or streaming_runner + rc, out = runner(health.compose_base(ctx) + ["up", "-d", "--remove-orphans"]) + if rc != 0: + return report.error(ctx, exit_codes.HEALTH_FAILED, f"docker compose up exited {rc}") + kwargs = {"runner": runner, "prober": prober} + if sleep is not None: + kwargs["sleep"] = sleep + rows, ok = health.wait_until_healthy(ctx, timeout, **kwargs) + url = web_url(ctx) + report.emit(ctx, "up", {"url": url, "healthy": ok, "timeout_s": timeout, "services": rows}) + if not ok: + bad = ", ".join(r["service"] for r in rows if not r["ok"]) + return report.error(ctx, exit_codes.HEALTH_FAILED, f"not healthy after {int(timeout)}s: {bad}") + if not no_open and ctx.stdin_is_tty: + (opener or webbrowser.open)(url) + sys.stderr.write(f"[grdm-dev] ready: {url}\n") + return exit_codes.OK + + +def run_down(ctx: Context, runner=None, volumes: bool = False) -> int: + missing = _require_compose(ctx) + if missing is not None: + return missing + runner = runner or streaming_runner + argv = health.compose_base(ctx) + ["down", "--remove-orphans"] + if volumes: + argv.append("--volumes") + rc, _ = runner(argv) + report.emit(ctx, "down", {"stopped": rc == 0, "volumes_removed": volumes and rc == 0}) + if rc != 0: + return report.error(ctx, exit_codes.HEALTH_FAILED, f"docker compose down exited {rc}") + return exit_codes.OK + + +def run_reset(ctx: Context, runner=None, rmtree=None) -> int: + volumes_dir = ctx.runtime / "volumes" + if not ctx.confirm(f"Stop all services and delete {volumes_dir} (all data)?", default=False): + if not ctx.yes and not ctx.stdin_is_tty: + return report.error(ctx, exit_codes.USAGE, "reset needs a confirmation; add --yes when no terminal is attached") + sys.stderr.write("[grdm-dev] reset cancelled\n") + return exit_codes.OK + if health.compose_path(ctx).exists(): + rc = run_down(ctx, runner=runner, volumes=True) + if rc != exit_codes.OK: + return rc + removed = False + if volumes_dir.exists(): + (rmtree or shutil.rmtree)(volumes_dir) + removed = True + report.emit(ctx, "reset", {"volumes_dir": str(volumes_dir), "removed": removed}) + return exit_codes.OK diff --git a/installer/grdm_dev/manifest.py b/installer/grdm_dev/manifest.py new file mode 100644 index 0000000..78c0a9e --- /dev/null +++ b/installer/grdm_dev/manifest.py @@ -0,0 +1,367 @@ +"""grdm-dev manifest — load and validate manifest/upstreams.json, derive services (SPEC-01, SPEC-02 §4). + +Three jobs: + +* `load(ctx_or_path)` parses the manifest into dataclasses (`Manifest`, `Component`, `Upstream`, `PR`). + Components stay dict-compatible (`comp["id"]`, `comp.get(...)`) so modules written against the + raw JSON keep working. +* `validate(ctx_or_path)` runs the SPEC-01 §5 checks (MC-01..MC-11, MC-13) by delegating to + tools/manifest_check.py, which stays the single implementation. An empty list means valid; + callers map a non-empty list to exit 20 (`exit_codes.MANIFEST_INVALID`). +* `services_for_profile(manifest, profile, auth)` turns components into `Service` objects for one + profile, following the SPEC-02 §4 table. Service templates under `templates/.json` + (SPEC-02 §3 `compose render`) supply the service-level profile where it differs from the + component (`admin` and `worker` belong to `osf.io`, profile minimum, but are core services). + +Images: a component with an integration repository is built locally as +`grdm-dev/:` (same rule as build.py); an infra component runs its +pinned upstream image, `base_image[@base_image_digest]`. The build SHA is the integration +commit when the manifest carries one (`integration_sha`, optional, written by the weekly +integration PR), else the first merged upstream in SPEC-01 rule 3 order (public, then private). +The clone URL is composed at run time from the bare repository name; it is never stored here. +""" +from __future__ import annotations + +import importlib.util +import json +import sys +from dataclasses import dataclass, field +from pathlib import Path +from typing import Any, Iterable + +from . import exit_codes + +PROFILES: tuple[str, ...] = ("minimum", "core", "full") +PROFILE_RANK: dict[str, int] = {name: i for i, name in enumerate(PROFILES)} +DEFAULT_PROFILE = "core" +LOCAL_IMAGE_PREFIX = "grdm-dev" +TEMPLATE_DIR = Path(__file__).parent / "templates" + +# SPEC-02 §4: the `shibboleth` auth variant swaps fakecas for shibboleth_sp + test_idp in `full`. +AUTH_FAKECAS = "fakecas" +AUTH_SHIBBOLETH = "shibboleth" +SHIBBOLETH_SERVICES: frozenset[str] = frozenset({"shibboleth_sp", "test_idp"}) + + +class ManifestError(Exception): + """The manifest is invalid (exit 20). `errors` holds one line per finding.""" + + def __init__(self, errors: list[str]): + super().__init__("; ".join(errors) if errors else "manifest invalid") + self.errors = errors + self.exit_code = exit_codes.MANIFEST_INVALID + + +@dataclass(frozen=True) +class Upstream: + repo: str + branch: str + kind: str + tracking_branch: str + status: str + sha: str + fetched_at: str + + +@dataclass(frozen=True) +class PR: + repo: str + number: int + title: str + reason: str + status: str + + +@dataclass +class Component: + id: str + role: str + services: list[str] + integration_repo: str | None + integration_branch: str | None + upstreams: list[Upstream] + adopted_prs: list[PR] + candidate_prs: list[PR] + base_image: str + base_image_digest: str | None + target_image: dict[str, str | None] + profile: str + platforms: list[str] + note: str | None + raw: dict[str, Any] = field(default_factory=dict, repr=False, compare=False) + + # dict compatibility for modules written against the raw JSON + def __getitem__(self, key: str) -> Any: + return self.raw[key] + + def get(self, key: str, default: Any = None) -> Any: + return self.raw.get(key, default) + + @property + def is_built(self) -> bool: + return bool(self.integration_repo) + + @property + def build_sha(self) -> str | None: + """Commit the local image is built from (see module docstring).""" + explicit = self.raw.get("integration_sha") + if isinstance(explicit, str) and explicit: + return explicit + for kind in ("public", "private"): + for up in self.upstreams: + if up.kind == kind and up.status == "merged": + return up.sha + return None + + @property + def sha12(self) -> str | None: + sha = self.build_sha + return sha[:12] if sha else None + + @property + def pinned_image(self) -> str: + """Infra: the upstream image, with its digest once pinned (SPEC-03 §3.4).""" + if self.base_image_digest: + return f"{self.base_image}@{self.base_image_digest}" + return self.base_image + + def local_image(self, sha12: str | None = None) -> str: + return f"{LOCAL_IMAGE_PREFIX}/{self.id.lower()}:{sha12 or self.sha12 or 'develop'}" + + def image_reference(self, sha12: str | None = None) -> str: + return self.local_image(sha12) if self.is_built else self.pinned_image + + +@dataclass +class Manifest: + schema_version: int + generated_at: str + note: str | None + components: list[Component] + path: Path | None = None + + def component(self, component_id: str) -> Component: + for c in self.components: + if c.id == component_id: + return c + raise KeyError(component_id) + + def component_for_service(self, service: str) -> Component: + for c in self.components: + if service in c.services: + return c + raise KeyError(service) + + @property + def service_names(self) -> list[str]: + return [s for c in self.components for s in c.services] + + +@dataclass(frozen=True) +class BuildInfo: + repo: str # integration repository name, e.g. RDM-osf.io-dev2027 (name only, SPEC-01 rule 5) + branch: str # always develop + sha: str | None # 40-hex commit the image is built from, when the manifest knows it + sha12: str | None + + +@dataclass +class Service: + name: str + component: str + role: str + image: str + profile: str + build: BuildInfo | None + template: dict[str, Any] = field(default_factory=dict, repr=False) + + @property + def is_built(self) -> bool: + return self.build is not None + + +# --------------------------------------------------------------------------- loading + + +def _path_of(ctx_or_path: Any) -> Path: + if isinstance(ctx_or_path, (str, Path)): + return Path(ctx_or_path) + return Path(ctx_or_path.manifest_path) + + +def _root_of(ctx_or_path: Any) -> Path: + if isinstance(ctx_or_path, (str, Path)): + return Path(ctx_or_path).resolve().parent.parent + return Path(ctx_or_path.root) + + +def parse(data: dict[str, Any], path: Path | None = None) -> Manifest: + """Build the dataclasses from already-parsed JSON. Raises ManifestError on a structural problem.""" + try: + components = [] + for c in data["components"]: + components.append( + Component( + id=c["id"], + role=c["role"], + services=list(c["services"]), + integration_repo=c.get("integration_repo"), + integration_branch=c.get("integration_branch"), + upstreams=[Upstream(**{k: u[k] for k in Upstream.__dataclass_fields__}) for u in c.get("upstreams", [])], + adopted_prs=[PR(**{k: p[k] for k in PR.__dataclass_fields__}) for p in c.get("adopted_prs", [])], + candidate_prs=[PR(**{k: p[k] for k in PR.__dataclass_fields__}) for p in c.get("candidate_prs", [])], + base_image=c["base_image"], + base_image_digest=c.get("base_image_digest"), + target_image=dict(c.get("target_image") or {}), + profile=c["profile"], + platforms=list(c.get("platforms", [])), + note=c.get("note"), + raw=c, + ) + ) + return Manifest( + schema_version=int(data["schema_version"]), + generated_at=str(data["generated_at"]), + note=data.get("note"), + components=components, + path=path, + ) + except (KeyError, TypeError, ValueError) as exc: + raise ManifestError([f"MC-01: manifest structure invalid: {exc.__class__.__name__}: {exc}"]) from exc + + +def load(ctx_or_path: Any) -> Manifest: + """Parse manifest/upstreams.json. Accepts a Context or a path. Raises ManifestError (exit 20).""" + path = _path_of(ctx_or_path) + try: + data = json.loads(path.read_text(encoding="utf-8")) + except FileNotFoundError as exc: + raise ManifestError([f"MC-01: {path} not found"]) from exc + except (json.JSONDecodeError, UnicodeDecodeError) as exc: + raise ManifestError([f"MC-01: {path} is not valid JSON: {exc}"]) from exc + if not isinstance(data, dict): + raise ManifestError([f"MC-01: {path} must contain a JSON object"]) + return parse(data, path) + + +# --------------------------------------------------------------------------- validation + + +def _checker_module(root: Path): + """Import tools/manifest_check.py (the one SPEC-01 implementation) from the repository root. + + Falls back to the copy next to this package (installer/../tools) so tests that use a temporary + root still validate with the real checker. + """ + candidates = [root / "tools" / "manifest_check.py", Path(__file__).resolve().parents[2] / "tools" / "manifest_check.py"] + for cand in candidates: + if cand.exists(): + name = "grdm_dev._manifest_check" + spec = importlib.util.spec_from_file_location(name, cand) + if spec is None or spec.loader is None: # pragma: no cover + continue + mod = importlib.util.module_from_spec(spec) + sys.modules[name] = mod + spec.loader.exec_module(mod) + return mod + raise FileNotFoundError("tools/manifest_check.py not found; it is the SPEC-01 checker") + + +def validate(ctx_or_path: Any) -> list[str]: + """Run SPEC-01 §5 checks. Returns [] when valid; otherwise one line per finding (exit 20).""" + json_path = _path_of(ctx_or_path) + toon_path = json_path.with_suffix(".toon") + try: + checker = _checker_module(_root_of(ctx_or_path)) + except FileNotFoundError as exc: + return [f"MC-01: {exc}"] + try: + return list(checker.check_manifest_files(json_path, toon_path)) + except Exception as exc: # the checker must never end in a traceback (same rule as its main()) + return [f"MC-01: manifest could not be validated: {exc.__class__.__name__}: {exc}"] + + +def load_validated(ctx_or_path: Any) -> Manifest: + """validate() then load(); raises ManifestError carrying the findings.""" + errors = validate(ctx_or_path) + if errors: + raise ManifestError(errors) + return load(ctx_or_path) + + +# --------------------------------------------------------------------------- templates and services + + +def load_templates(template_dir: Path | None = None) -> dict[str, dict[str, Any]]: + """Read templates/.json. Keyed by service name; a template's `service` field must match its file.""" + out: dict[str, dict[str, Any]] = {} + for path in sorted((template_dir or TEMPLATE_DIR).glob("*.json")): + with path.open(encoding="utf-8") as fh: + tpl = json.load(fh) + name = tpl.get("service", path.stem) + if name != path.stem: + raise ValueError(f"template {path.name}: service field {name!r} does not match the file name") + out[name] = tpl + return out + + +def service_profile(component: Component, template: dict[str, Any] | None) -> str: + """The smallest profile that includes a service: the template may narrow the component's profile.""" + prof = (template or {}).get("profile") or component.profile + if prof not in PROFILE_RANK: + raise ManifestError([f"MC-10: unknown profile {prof!r} for component {component.id}"]) + return prof + + +def services_for_profile( + manifest: Manifest, + profile: str = DEFAULT_PROFILE, + auth: str = AUTH_FAKECAS, + templates: dict[str, dict[str, Any]] | None = None, + image_tags: dict[str, str] | None = None, +) -> list[Service]: + """Services started by `profile`, in manifest order (SPEC-02 §4). + + `auth` is `fakecas` (default) or `shibboleth`; the latter is only meaningful for `full`, where it + removes `fakecas` and adds `shibboleth_sp` and `test_idp`. `image_tags` maps component id to the + sha12 actually built (from the build report) and overrides the manifest-derived tag. + """ + if profile not in PROFILE_RANK: + raise ValueError(f"unknown profile {profile!r}; expected one of {', '.join(PROFILES)}") + if auth not in (AUTH_FAKECAS, AUTH_SHIBBOLETH): + raise ValueError(f"unknown auth {auth!r}; expected fakecas or shibboleth") + templates = templates if templates is not None else load_templates() + rank = PROFILE_RANK[profile] + use_shib = profile == "full" and auth == AUTH_SHIBBOLETH + out: list[Service] = [] + for comp in manifest.components: + for name in comp.services: + tpl = templates.get(name) + if PROFILE_RANK[service_profile(comp, tpl)] > rank: + continue + if name in SHIBBOLETH_SERVICES and not use_shib: + continue + if name == "fakecas" and use_shib: + continue + build = None + if comp.is_built: + sha12 = (image_tags or {}).get(comp.id) or comp.sha12 + build = BuildInfo(repo=comp.integration_repo or "", branch=comp.integration_branch or "develop", sha=comp.build_sha, sha12=sha12) + else: + sha12 = None + out.append( + Service( + name=name, + component=comp.id, + role=comp.role, + image=comp.image_reference(sha12), + profile=service_profile(comp, tpl), + build=build, + template=tpl or {}, + ) + ) + return out + + +def service_names(services: Iterable[Service]) -> list[str]: + return [s.name for s in services] diff --git a/installer/grdm_dev/manifest_cmd.py b/installer/grdm_dev/manifest_cmd.py new file mode 100644 index 0000000..9746f81 --- /dev/null +++ b/installer/grdm_dev/manifest_cmd.py @@ -0,0 +1,134 @@ +"""grdm-dev manifest check | toon — SPEC-01 validation and the TOON excerpt (SPEC-02 §3). + +`check` runs the CI validator tools/manifest_check.py in-process (loaded with importlib from +/tools so the two never drift) and maps its exit codes: 20 manifest invalid or TOON excerpt +disagrees with JSON (SPEC-02 §6), 1 repository policy violation (private URL / token, SPEC-01 §5), +2 usage. `toon` prints the excerpt that manifest/upstreams.toon must equal (SPEC-01 §2), built from +the validator's own projection so `check` and `toon` agree by construction. +""" +from __future__ import annotations + +import importlib.util +import json +import sys +from pathlib import Path +from types import ModuleType +from typing import Any + +from . import exit_codes, report, toon +from .context import Context + + +def register(subparsers) -> None: + p = subparsers.add_parser("manifest", help="validate manifest/upstreams.json or print its TOON excerpt (SPEC-01)") + sub = p.add_subparsers(dest="manifest_action", metavar="") + c = sub.add_parser("check", help="validate the manifest, TOON parity and repository policy; exit 20 / 1 on failure") + c.add_argument("--manifest-only", action="store_true", help="skip the repository policy scan") + c.add_argument("--policy-only", action="store_true", help="run only the repository policy scan") + t = sub.add_parser("toon", help="print the excerpt that manifest/upstreams.toon must equal") + t.add_argument("--check", action="store_true", help="compare with manifest/upstreams.toon instead of printing; exit 20 on mismatch") + t.add_argument("--write", action="store_true", help="write manifest/upstreams.toon") + p.set_defaults(_module=sys.modules[__name__]) + + +def load_tool(root: Path, name: str) -> ModuleType: + """Import /tools/.py as a module without touching sys.path.""" + path = root / "tools" / f"{name}.py" + if not path.exists(): + raise FileNotFoundError(path) + spec = importlib.util.spec_from_file_location(f"grdm_dev_tools_{name}", path) + if spec is None or spec.loader is None: # pragma: no cover + raise ImportError(name) + mod = importlib.util.module_from_spec(spec) + sys.modules[spec.name] = mod # @dataclass in the tool looks its module up in sys.modules + try: + spec.loader.exec_module(mod) + except Exception: + sys.modules.pop(spec.name, None) + raise + return mod + + +def map_check_exit(code: int) -> int: + """tools/manifest_check.py codes -> grdm-dev codes (they already share SPEC-02's numbers).""" + if code == 0: + return exit_codes.OK + if code == 20: + return exit_codes.MANIFEST_INVALID + if code == 2: + return exit_codes.USAGE + return 1 # policy violation: SPEC-01 §5 / SPEC-06 §5, not a manifest schema error + + +# --------------------------------------------------------------------------- TOON excerpt + +def _table(label: str, rows: list[dict[str, Any]], fields: tuple[str, ...], pad: str) -> list[str]: + if not rows: + return [f"{pad}{label}[0]:"] + out = [f"{pad}{label}[{len(rows)}]{{{','.join(fields)}}}:"] + for r in rows: + out.append(pad + " " + ",".join(toon._scalar(r.get(f)) for f in fields)) + return out + + +def excerpt(data: dict[str, Any], mc: ModuleType) -> str: + """Render the SPEC-01 §2 projection in the layout of manifest/upstreams.toon.""" + proj = mc.project_manifest(data) + lines: list[str] = [] + for key in ("schema_version", "generated_at", "note"): + if key in proj: + lines.append(f"{key}: {toon._scalar(proj[key])}") + comps = proj.get("components", []) + lines.append(f"components[{len(comps)}]:") + for c in comps: + lines.append(f" - id: {toon._scalar(c['id'])}") + for key in ("role", "integration_repo", "profile"): + lines.append(f" {key}: {toon._scalar(c.get(key))}") + lines += _table("upstreams", c.get("upstreams", []), tuple(mc.UPSTREAM_FIELDS), " ") + lines += _table("adopted_prs", c.get("adopted_prs", []), ("repo", "number", "status"), " ") + return "\n".join(lines) + "\n" + + +# --------------------------------------------------------------------------- run + +def run(ctx: Context, args) -> int: + action = getattr(args, "manifest_action", None) + if action not in ("check", "toon"): + sys.stderr.write("usage: grdm-dev manifest \n") + return exit_codes.USAGE + try: + mc = load_tool(ctx.root, "manifest_check") + except FileNotFoundError as exc: + return report.error(ctx, exit_codes.USAGE, f"validator not found: {exc}") + + if action == "check": + argv = ["--root", str(ctx.root)] + if getattr(args, "manifest_only", False): + argv.append("--manifest-only") + if getattr(args, "policy_only", False): + argv.append("--policy-only") + code = map_check_exit(int(mc.main(argv))) + if code != exit_codes.OK: + return report.error(ctx, code, "see the findings above") + return code + + try: + data = json.loads(ctx.manifest_path.read_text(encoding="utf-8")) + except (OSError, json.JSONDecodeError) as exc: + return report.error(ctx, exit_codes.MANIFEST_INVALID, f"{ctx.manifest_path}: {exc}") + if mc.validate_structure(data): + return report.error(ctx, exit_codes.MANIFEST_INVALID, "manifest fails structural checks; run manifest check") + text = excerpt(data, mc) + toon_path = ctx.root / "manifest" / "upstreams.toon" + if getattr(args, "write", False): + toon_path.write_text(text, encoding="utf-8") + sys.stdout.write(f"wrote {toon_path}\n") + return exit_codes.OK + if getattr(args, "check", False): + current = toon_path.read_text(encoding="utf-8") if toon_path.exists() else "" + if current != text: + return report.error(ctx, exit_codes.MANIFEST_INVALID, f"{toon_path} differs from the generated excerpt") + sys.stdout.write(f"{toon_path} is up to date\n") + return exit_codes.OK + sys.stdout.write(text) + return exit_codes.OK diff --git a/installer/grdm_dev/plan.py b/installer/grdm_dev/plan.py new file mode 100644 index 0000000..958c335 --- /dev/null +++ b/installer/grdm_dev/plan.py @@ -0,0 +1,189 @@ +"""grdm-dev plan — what would be built and started for a profile, with published ports (SPEC-02 §3, §4). + +Touches no Docker. Resolves the profile (flag > runtime/.env GRDM_PROFILE > core), validates the +manifest (exit 20 on any SPEC-01 finding), and prints a TOON report: profile, platform, services +with image and build origin (integration repository name + sha12), published ports (SPEC-02 §4 +table, honoring GRDM_PORT_ overrides in runtime/.env), and named volumes. + +The helpers here (`read_dotenv`, `resolve_profile`, `published_ports`, `detect_platform`) are +shared with compose.py. +""" +from __future__ import annotations + +import platform as _platform +import sys +from pathlib import Path +from typing import Any + +from . import exit_codes, manifest as _manifest, report +from .context import Context + +# SPEC-02 §4 ports table: the only place default host ports are defined. Container ports equal the +# default host ports (SPEC-03 §4.3). +DEFAULT_PORTS: dict[str, int] = { + "web": 5000, + "api": 8000, + "admin": 8001, + "wb": 7777, + "mfr": 7778, + "fakecas": 8080, + "ember_osf_web": 4200, +} +PORT_ENV_PREFIX = "GRDM_PORT_" +PROFILE_ENV_KEY = "GRDM_PROFILE" +LOOPBACK = "127.0.0.1" + + +def register(subparsers) -> None: + p = subparsers.add_parser("plan", help="show images to build and services to start with their ports; exit 20 if the manifest is invalid") + p.add_argument("--auth", choices=[_manifest.AUTH_FAKECAS, _manifest.AUTH_SHIBBOLETH], default=_manifest.AUTH_FAKECAS, + help="auth provider for the full profile (shibboleth replaces fakecas with shibboleth_sp + test_idp)") + p.set_defaults(_module=sys.modules[__name__]) + + +# --------------------------------------------------------------------------- shared helpers + + +def env_path(ctx: Context) -> Path: + return ctx.runtime / ".env" + + +def read_dotenv(path: Path) -> dict[str, str]: + """Parse KEY=value lines; comments and blanks ignored, surrounding quotes stripped. Missing file -> {}.""" + values: dict[str, str] = {} + if not path.exists(): + return values + for raw in path.read_text(encoding="utf-8").splitlines(): + line = raw.strip() + if not line or line.startswith("#") or "=" not in line: + continue + key, _, value = line.partition("=") + key, value = key.strip(), value.strip() + if len(value) >= 2 and value[0] == value[-1] and value[0] in "\"'": + value = value[1:-1] + if key: + values[key] = value + return values + + +def port_key(service: str) -> str: + return PORT_ENV_PREFIX + service.upper() + + +def resolve_profile(ctx: Context, env: dict[str, str] | None = None) -> str: + """Flag > runtime/.env GRDM_PROFILE > core. An unknown saved value falls back to core.""" + if ctx.profile: + return ctx.profile + env = env if env is not None else read_dotenv(env_path(ctx)) + saved = env.get(PROFILE_ENV_KEY, "") + return saved if saved in _manifest.PROFILE_RANK else _manifest.DEFAULT_PROFILE + + +def published_ports(services: list[_manifest.Service], env: dict[str, str]) -> list[dict[str, Any]]: + """Rows {service, host_port, container_port, url, source} for services with a host port. + + The default is the template's host_port (SPEC-02 §4 table); a valid GRDM_PORT_ in + runtime/.env overrides it (source = env). Services without a host_port are internal only. + """ + rows: list[dict[str, Any]] = [] + for svc in services: + tpl = svc.template + default = tpl.get("host_port", DEFAULT_PORTS.get(svc.name)) + if default is None: + continue + container = int(tpl.get("container_port", default)) + host, source = int(default), "default" + raw = env.get(port_key(svc.name)) + if raw and raw.isdigit() and 0 < int(raw) < 65536: + host, source = int(raw), "env" + rows.append({ + "service": svc.name, + "host_port": host, + "container_port": container, + "url": f"http://{LOOPBACK}:{host}", + "source": source, + }) + return rows + + +def detect_platform(host_info: Any = None) -> str: + """linux/arm64 or linux/amd64. Uses a HostInfo when given, else host.classify_arch (pure) when + importable, else platform.machine(). Never probes Docker (plan touches no Docker).""" + if host_info is not None: + plat = getattr(host_info, "platform_string", "") or "" + if plat: + return plat + arch = getattr(host_info, "arch", "") + return f"linux/{arch}" if arch in ("arm64", "amd64") else "unknown" + machine = _platform.machine() + try: + from . import host # other owner; optional + + arch = host.classify_arch(machine) + if arch in ("arm64", "amd64"): + return f"linux/{arch}" + except Exception: + pass + m = machine.lower() + if m in ("arm64", "aarch64"): + return "linux/arm64" + if m in ("x86_64", "amd64"): + return "linux/amd64" + return "unknown" + + +def volumes_of(services: list[_manifest.Service]) -> list[str]: + names: list[str] = [] + for svc in services: + for vol in svc.template.get("volumes", []): + name = vol.get("volume") + if name and name not in names: + names.append(name) + return names + + +# --------------------------------------------------------------------------- report + + +def build_report(ctx: Context, profile: str, auth: str, services: list[_manifest.Service], env: dict[str, str], platform_string: str) -> dict[str, Any]: + rows = [] + for svc in services: + rows.append({ + "service": svc.name, + "component": svc.component, + "role": svc.role, + "image": svc.image, + "build_from": f"{svc.build.repo}@{svc.build.sha12}" if svc.build and svc.build.sha12 else (svc.build.repo if svc.build else "pinned image"), + "profile": svc.profile, + }) + ports = published_ports(services, env) + return { + "profile": profile, + "auth": auth, + "platform": platform_string, + "manifest": str(ctx.manifest_path.relative_to(ctx.root)) if ctx.manifest_path.is_relative_to(ctx.root) else str(ctx.manifest_path), + "services": rows, + "images_to_build": sorted({svc.image for svc in services if svc.is_built}), + "ports": ports, + "volumes": volumes_of(services), + "network": "grdm", + } + + +def run(ctx: Context, args, platform_string: str | None = None) -> int: + errors = _manifest.validate(ctx) + if errors: + for line in errors: + sys.stderr.write(f" - {line}\n") + return report.error(ctx, exit_codes.MANIFEST_INVALID, f"{len(errors)} finding(s); run `grdm-dev manifest check`") + try: + man = _manifest.load(ctx) + env = read_dotenv(env_path(ctx)) + profile = resolve_profile(ctx, env) + auth = getattr(args, "auth", None) or _manifest.AUTH_FAKECAS + services = _manifest.services_for_profile(man, profile, auth) + except (_manifest.ManifestError, ValueError, OSError) as exc: + return report.error(ctx, exit_codes.MANIFEST_INVALID, str(exc)) + data = build_report(ctx, profile, auth, services, env, platform_string or detect_platform()) + report.emit(ctx, "plan", data) + return exit_codes.OK diff --git a/installer/grdm_dev/redteam.py b/installer/grdm_dev/redteam.py new file mode 100644 index 0000000..fd9a439 --- /dev/null +++ b/installer/grdm_dev/redteam.py @@ -0,0 +1,159 @@ +"""grdm-dev redteam preflight — isolation checks before an AI red-team run (SPEC-02 §3, SPEC-03 §6). + +Checks, all read-only and none of them an attack: + 1. an approval record `docs/demo/*_redteam_*.md` exists ("no record, no run"); + 2. the red-team Compose network exists and has `internal: true` (`docker network inspect`); + 3. a throw-away probe container on that network cannot reach an external address + (`docker run --rm --pull never --network alpine wget ... http://example.invalid`); + 4. every container attached to that network is one of the targets in manifest/redteam-targets.json. + +Exit 53 if any check fails, 20 if the targets manifest is missing or malformed, 0 otherwise. +External commands go through an injectable `runner(argv) -> (returncode, output)`. +""" +from __future__ import annotations + +import json +import re +import subprocess +import sys +from pathlib import Path + +from . import exit_codes, report +from .context import Context + +PROBE_URL = "http://example.invalid" # RFC 2606: never resolves; a reply proves a route or a resolver leak +PROBE_MARKER = "GRDM_EGRESS_REACHABLE" +REQUIRED_KEYS = ("project", "network", "targets") + + +def register(subparsers) -> None: + p = subparsers.add_parser("redteam", help="AI red-team helpers (preflight only; never runs attacks)") + sub = p.add_subparsers(dest="redteam_command", metavar="") + pre = sub.add_parser("preflight", help="verify no egress and targets only from manifest/redteam-targets.json; exit 53 on failure") + pre.add_argument("--targets", help="path to the targets manifest (default: manifest/redteam-targets.json)") + pre.add_argument("--approval", help="path to the approval record (default: newest docs/demo/*_redteam_*.md)") + p.set_defaults(_module=sys.modules[__name__]) + + +def default_runner(argv: list[str], timeout: int = 60) -> tuple[int, str]: + try: + proc = subprocess.run(argv, capture_output=True, text=True, timeout=timeout) + except FileNotFoundError as exc: + return 127, str(exc) + except subprocess.TimeoutExpired: + return 124, "timed out" + return proc.returncode, (proc.stdout or "") + (proc.stderr or "") + + +def load_targets(path: Path) -> dict: + """Parse and validate the targets manifest. Raises ValueError with a readable reason.""" + if not path.exists(): + raise ValueError(f"{path} not found") + try: + data = json.loads(path.read_text(encoding="utf-8")) + except json.JSONDecodeError as exc: + raise ValueError(f"{path}: {exc}") from exc + if not isinstance(data, dict): + raise ValueError(f"{path}: top level must be an object") + for k in REQUIRED_KEYS: + if k not in data: + raise ValueError(f"{path}: missing key {k!r}") + if not isinstance(data["targets"], list) or not data["targets"] or not all(isinstance(t, str) and t for t in data["targets"]): + raise ValueError(f"{path}: 'targets' must be a non-empty list of names") + for k in ("project", "network"): + if not isinstance(data[k], str) or not re.fullmatch(r"[a-z0-9][a-z0-9_.-]*", data[k]): + raise ValueError(f"{path}: {k!r} must be a plain Docker name") + return data + + +def service_of(container_name: str, project: str) -> str: + """Compose names containers `--` (or with `_` on old versions).""" + m = re.fullmatch(rf"{re.escape(project)}[-_](.+?)[-_][0-9]+", container_name) + return m.group(1) if m else container_name + + +def inspect_network(runner, network: str) -> tuple[dict | None, str]: + rc, out = runner(["docker", "network", "inspect", network, "--format", "{{json .}}"]) + if rc != 0: + return None, f"docker network inspect {network} failed: {out.strip()[-200:]}" + try: + data = json.loads(out.strip() or "null") + except json.JSONDecodeError: + return None, f"docker network inspect {network}: unreadable output" + if isinstance(data, list): + data = data[0] if data else None + if not isinstance(data, dict): + return None, f"network {network} not found" + return data, "" + + +def probe_egress(runner, network: str) -> tuple[str, str]: + """Return (verdict, detail): verdict is 'blocked', 'reachable', or 'inconclusive'.""" + argv = ["docker", "run", "--rm", "--pull", "never", "--network", network, "alpine", "sh", "-c", + f"wget -T 3 -q -O- {PROBE_URL} >/dev/null 2>&1 && echo {PROBE_MARKER} || echo blocked"] + rc, out = runner(argv) + if PROBE_MARKER in out: + return "reachable", f"probe fetched {PROBE_URL} from network {network}" + if rc == 0 and "blocked" in out: + return "blocked", "probe could not reach outside" + return "inconclusive", f"probe container did not run (rc={rc}): {out.strip()[-200:]}" + + +def preflight(ctx: Context, targets_path: Path, approval: Path | None, runner) -> tuple[dict, list[str]]: + """Run every check. Returns (report data, list of failure reasons).""" + failures: list[str] = [] + manifest = load_targets(targets_path) # ValueError propagates: caller maps it to exit 20 + project, network, targets = manifest["project"], manifest["network"], manifest["targets"] + data: dict = {"project": project, "network": network, "targets": targets, "checks": []} + + def check(name: str, ok: bool, detail: str) -> None: + data["checks"].append({"check": name, "ok": ok, "detail": detail}) + if not ok: + failures.append(f"{name}: {detail}") + + # 1. approval record (SPEC-03 §6 rule 3) + if approval is None: + candidates = sorted((ctx.root / "docs" / "demo").glob("*_redteam_*.md")) if (ctx.root / "docs" / "demo").is_dir() else [] + approval = candidates[-1] if candidates else None + if approval and approval.is_file(): + check("approval_record", True, str(approval.relative_to(ctx.root)) if approval.is_relative_to(ctx.root) else str(approval)) + else: + check("approval_record", False, "no docs/demo/nn_redteam_.md; no record, no run") + + # 2. network is internal + net, err = inspect_network(runner, network) + if net is None: + check("network_internal", False, err) + check("egress_blocked", False, "skipped: network unavailable") + check("targets_only", False, "skipped: network unavailable") + return data, failures + check("network_internal", bool(net.get("Internal")), f"Internal={net.get('Internal')}") + + # 3. egress probe + verdict, detail = probe_egress(runner, network) + check("egress_blocked", verdict == "blocked", detail) + + # 4. attached containers are exactly our targets + attached = sorted(c.get("Name", "") for c in (net.get("Containers") or {}).values()) + unknown = [n for n in attached if n not in targets and service_of(n, project) not in targets] + data["attached"] = attached + data["unknown"] = unknown + check("targets_only", not unknown, "all attached containers are listed" if not unknown else f"outside list: {', '.join(unknown)}") + return data, failures + + +def run(ctx: Context, args, runner=None) -> int: + runner = runner or default_runner + if getattr(args, "redteam_command", None) != "preflight": + return report.error(ctx, exit_codes.USAGE, "usage: grdm-dev redteam preflight") + targets_path = Path(args.targets) if getattr(args, "targets", None) else ctx.root / "manifest" / "redteam-targets.json" + approval = Path(args.approval) if getattr(args, "approval", None) else None + try: + data, failures = preflight(ctx, targets_path, approval, runner) + except ValueError as exc: + return report.error(ctx, exit_codes.MANIFEST_INVALID, str(exc)) + data["result"] = "pass" if not failures else "fail" + report.emit(ctx, "redteam_preflight", data) + if failures: + return report.error(ctx, exit_codes.REDTEAM_PREFLIGHT_FAILED, "; ".join(failures)) + return exit_codes.OK diff --git a/installer/grdm_dev/report_cmd.py b/installer/grdm_dev/report_cmd.py new file mode 100644 index 0000000..8962283 --- /dev/null +++ b/installer/grdm_dev/report_cmd.py @@ -0,0 +1,80 @@ +"""grdm-dev report — bundle the latest doctor / plan / health / scan / accept reports (SPEC-02 §3). + +Reads runtime/reports/_latest.json for each report, writes runtime/reports/report_.json +and .toon with a summary (which reports exist, their timestamps, overall status) and prints it. +Values found in runtime/.env are masked before anything is written (SPEC-03 §3.1). +""" +from __future__ import annotations + +import datetime as _dt +import json +import sys +from pathlib import Path +from typing import Any + +from . import exit_codes, report +from .context import Context + +REPORT_NAMES = ("doctor", "plan", "health", "scan", "accept") + + +def register(subparsers) -> None: + p = subparsers.add_parser("report", help="bundle the latest doctor, plan, health, scan and accept reports") + p.set_defaults(_module=sys.modules[__name__]) + + +def _status_of(data: Any) -> str: + if not isinstance(data, dict): + return "unreadable" + if "exit_code" in data: + return "ok" if data.get("exit_code") in (0, "0") else f"fail ({data.get('exit_code')})" + for key in ("gate", "status", "result"): + if key in data: + return str(data[key]) + return "present" + + +def collect(reports_dir: Path) -> tuple[list[dict[str, Any]], dict[str, Any]]: + rows: list[dict[str, Any]] = [] + bundle: dict[str, Any] = {} + for name in REPORT_NAMES: + path = reports_dir / f"{name}_latest.json" + if not path.exists(): + rows.append({"name": name, "present": False, "timestamp": "", "status": "missing"}) + continue + ts = _dt.datetime.fromtimestamp(path.stat().st_mtime, _dt.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ") + try: + data = json.loads(path.read_text(encoding="utf-8")) + except (OSError, json.JSONDecodeError): + data = None + rows.append({"name": name, "present": True, "timestamp": ts, "status": _status_of(data)}) + bundle[name] = data if data is not None else {"error": "unreadable"} + return rows, bundle + + +def run(ctx: Context, args) -> int: + from .scan import _env_secrets, mask_secrets # same masking rule as scan + + rows, bundle = collect(ctx.reports_dir) + present = [r["name"] for r in rows if r["present"]] + failed = [r["name"] for r in rows if r["present"] and r["status"].startswith("fail")] + if not present: + overall = "empty" + elif failed: + overall = "fail" + elif len(present) == len(REPORT_NAMES): + overall = "complete" + else: + overall = "partial" + data: dict[str, Any] = { + "date": _dt.datetime.now(_dt.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"), + "overall": overall, + "present": present, + "missing": [r["name"] for r in rows if not r["present"]], + "failed": failed, + "reports": rows, + "bundle": bundle, + } + data = mask_secrets(data, _env_secrets(ctx.runtime / ".env")) + report.emit(ctx, "report", data) + return exit_codes.OK diff --git a/installer/grdm_dev/scan.py b/installer/grdm_dev/scan.py new file mode 100644 index 0000000..8894883 --- /dev/null +++ b/installer/grdm_dev/scan.py @@ -0,0 +1,675 @@ +"""grdm-dev scan — the security gate of SPEC-03 (baseline controls, Trivy, gitleaks, Semgrep, ZAP, +allow-list diff, staged gate per ADR-03). + +Usage: grdm-dev scan [--baseline] [--secrets] [--dynamic] [--milestone M1..M5] + +Without part flags the whole gate runs (baseline, Trivy, Semgrep, gitleaks, and ZAP only when the +services are healthy). Each part flag restricts the run to that part. Exit codes (SPEC-03 §8): +0 pass, 50 gate failed, 51 scanner unavailable, 52 --dynamic requested while services unhealthy. + +Every external program goes through an injectable `runner(argv) -> (returncode, stdout)` and tool +presence through an injectable `which(name) -> bool`, so unit tests feed canned scanner JSON and +never need Docker (SPEC-02 §10). Reports never contain secret values (SPEC-03 §3.1): gitleaks runs +with --redact, only rule id / file / line are kept, and every value of runtime/.env is masked. +""" +from __future__ import annotations + +import datetime as _dt +import json +import platform +import re +import shutil +import subprocess +import sys +from pathlib import Path +from typing import Any, Callable + +from . import exit_codes, report +from .context import Context + +Runner = Callable[[list[str]], tuple[int, str]] + +SEVERITIES = ("CRITICAL", "HIGH", "MEDIUM", "LOW", "INFO") +ALLOWLIST_FIELDS = ("cve", "component", "reason", "owner", "expires", "added_at") +MILESTONES = ("M1", "M2", "M3", "M4", "M5") +# Milestone -> gate rule name (SPEC-03 §5.2 / ADR-03 §3). manifest/milestone.json may carry the +# same word in its "gate" field; the milestone number decides when the two disagree. +GATE_BY_MILESTONE = { + "M1": "report-only", + "M2": "count-not-growing", + "M3": "count-not-growing", + "M4": "fail-high", + "M5": "zero-critical-high", +} +# ZAP targets by Compose service name and container port (SPEC-03 §4.3); only services that the +# rendered compose file defines are scanned. +ZAP_DEFAULT_TARGETS = {"web": 5000, "admin": 8001, "ember_osf_web": 4200} +ZAP_IMAGE = "ghcr.io/zaproxy/zaproxy:stable" +DEFAULT_NETWORK = "grdm" +FORBIDDEN_ALIAS = "192.168.168.167" +IMAGE_PREFIX = "grdm-dev/" + +DEFAULT_ALLOWLIST: dict[str, Any] = { + "schema_version": 1, + "note": "Accepted findings (SPEC-03 §5.1). Every entry needs cve, component, reason, owner, " + "expires, added_at; optional severity. Only the owner approves additions.", + "fields": list(ALLOWLIST_FIELDS), + "entries": [], +} +DEFAULT_BASELINE: dict[str, Any] = { + "schema_version": 1, + "note": "Allow-list entry count at each milestone exit, owner-maintained (SPEC-03 §5.1 rule 5). " + "The count for the current milestone is the ceiling; it must never grow.", + "counts": {"M1": 0}, +} +DEFAULT_MILESTONE: dict[str, Any] = {"milestone": "M1", "gate": "report-only"} + + +# --------------------------------------------------------------------------- CLI contract + +def register(subparsers) -> None: + p = subparsers.add_parser("scan", help="security gate: baseline, Trivy, gitleaks, Semgrep, ZAP (SPEC-03)") + p.add_argument("--baseline", action="store_true", help="only re-check the baseline controls of runtime/docker-compose.yml") + p.add_argument("--secrets", action="store_true", help="only run gitleaks over the repository") + p.add_argument("--dynamic", action="store_true", help="only run the OWASP ZAP baseline (exit 52 if services are unhealthy)") + p.add_argument("--milestone", choices=MILESTONES, help="override manifest/milestone.json for this run") + p.set_defaults(_module=sys.modules[__name__]) + + +def default_runner(cwd: Path) -> Runner: + def _run(argv: list[str]) -> tuple[int, str]: + try: + proc = subprocess.run(argv, capture_output=True, text=True, cwd=str(cwd)) + except FileNotFoundError: + return 127, "" + return proc.returncode, proc.stdout + return _run + + +def default_which(name: str) -> bool: + return shutil.which(name) is not None + + +# --------------------------------------------------------------------------- manifest files + +def _load_or_create(path: Path, default: dict[str, Any]) -> tuple[dict[str, Any], list[str]]: + """Read a JSON file; create it from `default` when missing. Returns (data, problems).""" + if not path.exists(): + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(json.dumps(default, ensure_ascii=False, indent=2) + "\n", encoding="utf-8") + return json.loads(json.dumps(default)), [] + try: + data = json.loads(path.read_text(encoding="utf-8")) + except (json.JSONDecodeError, UnicodeDecodeError) as exc: + return dict(default), [f"{path.name} is not valid JSON: {exc}"] + if not isinstance(data, dict): + return dict(default), [f"{path.name} must be a JSON object"] + return data, [] + + +def _parse_date(value: Any) -> _dt.date | None: + if not isinstance(value, str): + return None + try: + return _dt.date.fromisoformat(value[:10]) + except ValueError: + return None + + +def validate_allowlist(entries: Any, today: _dt.date) -> tuple[list[dict], list[dict]]: + """Split allow-list entries into (active, findings). Malformed or expired entries become findings + of tool `allowlist`; a malformed entry fails the gate at any milestone (SPEC-03 §5.1 rule 1).""" + active: list[dict] = [] + findings: list[dict] = [] + if not isinstance(entries, list): + return [], [_finding("allowlist", "ALLOWLIST-MALFORMED", "HIGH", "manifest/allowlist.json", "entries", + "entries must be a list")] + for idx, e in enumerate(entries): + loc = f"manifest/allowlist.json#entries[{idx}]" + if not isinstance(e, dict): + findings.append(_finding("allowlist", "ALLOWLIST-MALFORMED", "HIGH", "manifest/allowlist.json", loc, + "entry is not an object")) + continue + missing = [f for f in ALLOWLIST_FIELDS if not isinstance(e.get(f), str) or not e.get(f).strip()] + if missing: + findings.append(_finding("allowlist", "ALLOWLIST-MALFORMED", "HIGH", str(e.get("component", "")), loc, + f"missing or empty field(s): {', '.join(missing)}")) + continue + if str(e["owner"]).strip().lower() == "team": + findings.append(_finding("allowlist", "ALLOWLIST-MALFORMED", "HIGH", e["component"], loc, + "owner must be a person or a role, never 'team'")) + continue + expires = _parse_date(e["expires"]) + added = _parse_date(e["added_at"]) + if expires is None or added is None: + findings.append(_finding("allowlist", "ALLOWLIST-MALFORMED", "HIGH", e["component"], loc, + "expires and added_at must be ISO dates")) + continue + if expires < today: + findings.append(_finding("allowlist", "ALLOWLIST-EXPIRED", "MEDIUM", e["component"], loc, + f"{e['cve']} expired {expires.isoformat()}; the finding counts again")) + continue + active.append(e) + return active, findings + + +def _entry_matches(entry: dict, finding: dict) -> bool: + if entry["cve"] != finding["id"]: + return False + comp = entry.get("component", "*") + if comp in ("", "*"): + return True + fcomp = finding.get("component", "") or "" + return fcomp == comp or fcomp.startswith(comp.split("@")[0]) + + +# --------------------------------------------------------------------------- findings + +def _finding(tool: str, fid: str, severity: str, component: str, location: str, title: str) -> dict[str, Any]: + sev = str(severity or "").upper() + if sev == "UNKNOWN": + sev = "LOW" + if sev not in SEVERITIES: + sev = "INFO" + return {"tool": tool, "id": str(fid), "severity": sev, "component": str(component or ""), + "location": str(location or ""), "title": str(title or "")[:200]} + + +def _json_or_empty(text: str) -> Any: + try: + return json.loads(text) if text and text.strip() else None + except json.JSONDecodeError: + return None + + +def normalize_trivy(data: Any, target: str) -> list[dict]: + out: list[dict] = [] + if not isinstance(data, dict): + return out + for res in data.get("Results") or []: + loc = res.get("Target") or target + for v in res.get("Vulnerabilities") or []: + comp = f"{v.get('PkgName', '')}@{v.get('InstalledVersion', '')}".rstrip("@") + out.append(_finding("trivy", v.get("VulnerabilityID", ""), v.get("Severity", ""), comp, loc, v.get("Title", ""))) + for m in res.get("Misconfigurations") or []: + out.append(_finding("trivy", m.get("ID", ""), m.get("Severity", ""), loc, loc, m.get("Title", ""))) + return out + + +_SEMGREP_SEVERITY = {"ERROR": "HIGH", "WARNING": "MEDIUM", "INFO": "LOW"} + + +def normalize_semgrep(data: Any) -> list[dict]: + out: list[dict] = [] + if not isinstance(data, dict): + return out + for r in data.get("results") or []: + extra = r.get("extra") or {} + sev = _SEMGREP_SEVERITY.get(str(extra.get("severity", "")).upper(), "LOW") + path = r.get("path", "") + line = (r.get("start") or {}).get("line", "") + out.append(_finding("semgrep", r.get("check_id", ""), sev, path, f"{path}:{line}", extra.get("message", ""))) + return out + + +def normalize_gitleaks(data: Any) -> list[dict]: + """Keep only rule id, file, line, description; never Secret/Match/Line (SPEC-03 §3.1).""" + out: list[dict] = [] + if not isinstance(data, list): + return out + for leak in data: + if not isinstance(leak, dict): + continue + f = leak.get("File", "") + out.append(_finding("gitleaks", leak.get("RuleID", "secret"), "HIGH", f, + f"{f}:{leak.get('StartLine', '')}", leak.get("Description", "secret detected"))) + return out + + +_ZAP_RISK = {"3": "HIGH", "2": "MEDIUM", "1": "LOW", "0": "INFO"} + + +def normalize_zap(data: Any, target: str) -> list[dict]: + out: list[dict] = [] + if not isinstance(data, dict): + return out + for site in data.get("site") or []: + for a in site.get("alerts") or []: + inst = (a.get("instances") or [{}])[0] + out.append(_finding("zap", f"ZAP-{a.get('pluginid', '')}", _ZAP_RISK.get(str(a.get("riskcode", "0")), "INFO"), + target, inst.get("uri", target), a.get("alert") or a.get("name", ""))) + return out + + +# --------------------------------------------------------------------------- baseline controls + +def _load_compose(path: Path) -> tuple[dict | None, str]: + text = path.read_text(encoding="utf-8") + data = _json_or_empty(text) # compose render writes JSON, which Compose accepts as YAML (SPEC-02 §2.2) + return (data if isinstance(data, dict) else None), text + + +def check_baseline(compose_path: Path) -> tuple[list[dict], list[str]]: + """Re-check the SPEC-03 §3.2/§3.3 controls of a rendered compose file. Returns (findings, notes).""" + if not compose_path.exists(): + return [], ["runtime/docker-compose.yml not found; baseline controls not checked (run compose render)"] + data, text = _load_compose(compose_path) + findings: list[dict] = [] + loc = "runtime/docker-compose.yml" + if FORBIDDEN_ALIAS in text: + findings.append(_finding("baseline", "BASE-ALIAS", "HIGH", "compose", loc, + f"loopback alias {FORBIDDEN_ALIAS} must not appear (ADR-02)")) + if data is None: + # Not JSON: best-effort text checks only. + for m in re.finditer(r'^\s*-\s*"?(?P[^"\s]+)"?\s*$', text, re.M): + spec = m.group("spec") + if re.match(r"^\d+:\d+", spec) or re.match(r"^0\.0\.0\.0:", spec): + findings.append(_finding("baseline", "BASE-PUBLISH", "HIGH", "compose", loc, + f"port {spec} is not published on 127.0.0.1")) + if re.search(r"^\s*privileged:\s*true", text, re.M): + findings.append(_finding("baseline", "BASE-PRIVILEGED", "CRITICAL", "compose", loc, "privileged: true is forbidden")) + return findings, ["compose file is not JSON; user/cap_drop checks skipped"] + services = data.get("services") or {} + for name, svc in services.items(): + if not isinstance(svc, dict): + continue + for p in svc.get("ports") or []: + spec = p if isinstance(p, str) else str((p or {}).get("host_ip", "")) + ":" + str((p or {}).get("published", "")) + if isinstance(p, dict): + ok = p.get("host_ip") == "127.0.0.1" + else: + ok = spec.startswith("127.0.0.1:") + if not ok: + findings.append(_finding("baseline", "BASE-PUBLISH", "HIGH", name, f"{loc}#services.{name}.ports", + f"port {spec} is not published on 127.0.0.1")) + if not str(svc.get("user") or "").strip(): + findings.append(_finding("baseline", "BASE-USER", "HIGH", name, f"{loc}#services.{name}", "no user: set (runs as root)")) + caps = [str(c).upper() for c in (svc.get("cap_drop") or [])] + if "ALL" not in caps: + findings.append(_finding("baseline", "BASE-CAPDROP", "MEDIUM", name, f"{loc}#services.{name}", "cap_drop must contain ALL")) + if svc.get("privileged") is True: + findings.append(_finding("baseline", "BASE-PRIVILEGED", "CRITICAL", name, f"{loc}#services.{name}", "privileged: true is forbidden")) + return findings, [] + + +# --------------------------------------------------------------------------- secrets masking + +def _env_secrets(env_path: Path) -> list[str]: + if not env_path.exists(): + return [] + vals: list[str] = [] + for line in env_path.read_text(encoding="utf-8", errors="replace").splitlines(): + if "=" not in line or line.lstrip().startswith("#"): + continue + v = line.split("=", 1)[1].strip().strip("'\"") + if len(v) >= 8: + vals.append(v) + return vals + + +def mask_secrets(data: Any, secrets: list[str]) -> Any: + if not secrets: + return data + if isinstance(data, str): + for s in secrets: + if s in data: + data = data.replace(s, "***") + return data + if isinstance(data, list): + return [mask_secrets(x, secrets) for x in data] + if isinstance(data, dict): + return {k: mask_secrets(v, secrets) for k, v in data.items()} + return data + + +# --------------------------------------------------------------------------- scanners + +def _save_raw(ctx: Context, name: str, text: str, secrets: list[str]) -> Path: + """Save a scanner's raw output under runtime/reports/ with runtime/.env values masked.""" + ctx.reports_dir.mkdir(parents=True, exist_ok=True) + path = ctx.reports_dir / name + path.write_text(mask_secrets(text, secrets), encoding="utf-8") + return path + + +class ScannerMissing(Exception): + def __init__(self, tool: str, detail: str = ""): + super().__init__(tool) + self.tool = tool + self.detail = detail + + +def _require(which: Callable[[str], bool], tool: str) -> None: + if not which(tool): + raise ScannerMissing(tool, "not found on PATH") + + +def _tool_version(runner: Runner, argv: list[str]) -> str: + rc, out = runner(argv) + if rc != 0 or not out: + return "unknown" + m = re.search(r"\d+\.\d+(\.\d+)?", out) + return m.group(0) if m else out.strip().splitlines()[0][:40] + + +def run_trivy(ctx: Context, runner: Runner, which: Callable[[str], bool], ts: str, + secrets: list[str] | None = None) -> tuple[list[dict], dict, list[str]]: + secrets = secrets or [] + _require(which, "trivy") + notes: list[str] = [] + findings: list[dict] = [] + images: list[str] = [] + if which("docker"): + rc, out = runner(["docker", "image", "ls", "--format", "{{.Repository}}:{{.Tag}}"]) + if rc == 0: + images = [l.strip() for l in out.splitlines() if l.strip().startswith(IMAGE_PREFIX) and not l.strip().endswith(":")] + reports = ctx.reports_dir + reports.mkdir(parents=True, exist_ok=True) + if images: + for img in images: + safe = re.sub(r"[^A-Za-z0-9_.-]", "_", img) + sbom = reports / f"sbom_{safe}_{ts}.json" + rc, _ = runner(["trivy", "image", "--quiet", "--format", "cyclonedx", "--output", str(sbom), img]) + if rc != 0: + notes.append(f"trivy sbom failed for {img} (rc {rc})") + rc, out = runner(["trivy", "image", "--quiet", "--format", "json", "--scanners", "vuln", img]) + data = _json_or_empty(out) + if rc != 0 or data is None: + raise ScannerMissing("trivy", f"image scan of {img} failed (rc {rc}); vulnerability database download may have failed") + _save_raw(ctx, f"trivy_{safe}_{ts}.json", out, secrets) + findings.extend(normalize_trivy(data, img)) + else: + notes.append(f"no {IMAGE_PREFIX}* image found; trivy fs scan of the repository instead (SPEC-03 §4.1 M1 scope)") + sbom = reports / f"sbom_repo_{ts}.json" + rc, _ = runner(["trivy", "fs", "--quiet", "--format", "cyclonedx", "--output", str(sbom), "."]) + if rc != 0: + notes.append(f"trivy sbom of the repository failed (rc {rc})") + rc, out = runner(["trivy", "fs", "--quiet", "--format", "json", "--scanners", "vuln,misconfig", "."]) + data = _json_or_empty(out) + if rc != 0 or data is None: + raise ScannerMissing("trivy", f"fs scan failed (rc {rc}); vulnerability database download may have failed") + _save_raw(ctx, f"trivy_repo_{ts}.json", out, secrets) + findings.extend(normalize_trivy(data, ".")) + tool = {"name": "trivy", "version": _tool_version(runner, ["trivy", "--version"]), "result": "ok", + "targets": len(images) if images else 1} + return findings, tool, notes + + +def run_semgrep(ctx: Context, runner: Runner, which: Callable[[str], bool], ts: str, + secrets: list[str] | None = None) -> tuple[list[dict], dict]: + _require(which, "semgrep") + rc, out = runner(["semgrep", "scan", "--config", "p/default", "--json", "--quiet", "."]) + data = _json_or_empty(out) + if data is None: + raise ScannerMissing("semgrep", f"no JSON output (rc {rc})") + _save_raw(ctx, f"semgrep_{ts}.json", out, secrets or []) + return normalize_semgrep(data), {"name": "semgrep", "version": _tool_version(runner, ["semgrep", "--version"]), + "result": "ok", "targets": 1} + + +def run_gitleaks(ctx: Context, runner: Runner, which: Callable[[str], bool], ts: str, + secrets: list[str] | None = None) -> tuple[list[dict], dict]: + _require(which, "gitleaks") + ctx.reports_dir.mkdir(parents=True, exist_ok=True) + out_path = ctx.reports_dir / f"gitleaks_{ts}.json" + argv = ["gitleaks", "detect", "--source", ".", "--redact", "--report-format", "json", "--report-path", str(out_path), + "--exit-code", "0"] + if (ctx.root / ".gitleaks.toml").exists(): + argv[4:4] = ["--config", ".gitleaks.toml"] + rc, out = runner(argv) + data = None + if out_path.exists(): + data = _json_or_empty(out_path.read_text(encoding="utf-8")) + if data is None: + data = _json_or_empty(out) + if data is None: + if rc != 0: + raise ScannerMissing("gitleaks", f"rc {rc} and no report") + data = [] + findings = mask_secrets(normalize_gitleaks(data), secrets or []) + # Rewrite the saved report with only the normalized fields: never Secret / Match / Line. + out_path.write_text(json.dumps(findings, ensure_ascii=False, indent=2) + "\n", encoding="utf-8") + return findings, {"name": "gitleaks", "version": _tool_version(runner, ["gitleaks", "version"]), "result": "ok", "targets": 1} + + +def _compose_services_and_network(compose_path: Path) -> tuple[list[str], str]: + if not compose_path.exists(): + return list(ZAP_DEFAULT_TARGETS), DEFAULT_NETWORK + data, _ = _load_compose(compose_path) + if data is None: + return list(ZAP_DEFAULT_TARGETS), DEFAULT_NETWORK + services = list((data.get("services") or {}).keys()) + nets = data.get("networks") or {} + network = DEFAULT_NETWORK + for key, val in nets.items(): + network = (val or {}).get("name") if isinstance(val, dict) and (val or {}).get("name") else key + break + return services, network + + +def services_healthy(ctx: Context, runner: Runner, which: Callable[[str], bool], prober=None) -> bool: + """All services healthy? Uses grdm_dev.health.check_services when the module exists (its `prober` + is injectable so tests never open sockets); otherwise falls back to `docker compose ps`.""" + compose = ctx.runtime / "docker-compose.yml" + if not compose.exists() or not which("docker"): + return False + try: # health.py is owned by another task; use it when present, never require it + from . import health as _health # type: ignore + except ImportError: + _health = None + if _health is not None and callable(getattr(_health, "check_services", None)): + try: + _, ok = _health.check_services(ctx, runner, prober or _health.default_prober) + return bool(ok) + except Exception as exc: # a broken health probe is "not healthy", not a traceback + sys.stderr.write(f"[grdm-dev] health check failed: {exc}\n") + return False + rc, out = runner(["docker", "compose", "-f", str(compose), "ps", "--format", "json"]) + if rc != 0 or not out.strip(): + return False + rows: list[dict] = [] + data = _json_or_empty(out) + if isinstance(data, list): + rows = [r for r in data if isinstance(r, dict)] + else: + for line in out.splitlines(): + row = _json_or_empty(line) + if isinstance(row, dict): + rows.append(row) + if not rows: + return False + for r in rows: + if str(r.get("State", "")).lower() != "running": + return False + health = str(r.get("Health", "")).lower() + if health and health != "healthy": + return False + return True + + +def run_zap(ctx: Context, runner: Runner, which: Callable[[str], bool], ts: str, + secrets: list[str] | None = None) -> tuple[list[dict], dict, list[str]]: + _require(which, "docker") + services, network = _compose_services_and_network(ctx.runtime / "docker-compose.yml") + targets = {s: p for s, p in ZAP_DEFAULT_TARGETS.items() if s in services} + notes: list[str] = [] + if not targets: + notes.append("no ZAP target service (web, admin, ember_osf_web) in the compose file; dynamic scan skipped") + return [], {"name": "zap", "version": "stable", "result": "skipped", "targets": 0}, notes + ctx.reports_dir.mkdir(parents=True, exist_ok=True) + findings: list[dict] = [] + for svc, port in targets.items(): + url = f"http://{svc}:{port}" # service name, never 127.0.0.1 (SPEC-03 §4.3) + out_name = f"zap_{svc}_{ts}.json" + argv = ["docker", "run", "--rm", "--network", network, "-v", f"{ctx.reports_dir}:/zap/wrk:rw", + ZAP_IMAGE, "zap-baseline.py", "-t", url, "-J", out_name, "-I"] + rc, out = runner(argv) + if rc == 127: + raise ScannerMissing("docker", "docker not found") + out_path = ctx.reports_dir / out_name + data = _json_or_empty(out_path.read_text(encoding="utf-8")) if out_path.exists() else _json_or_empty(out) + if data is None: + raise ScannerMissing("zap", f"no ZAP report for {url} (rc {rc}); image {ZAP_IMAGE} pull may have failed") + if out_path.exists(): + _save_raw(ctx, out_name, json.dumps(data, ensure_ascii=False, indent=2), secrets or []) + findings.extend(normalize_zap(data, url)) + return findings, {"name": "zap", "version": "stable", "result": "ok", "targets": len(targets)}, notes + + +# --------------------------------------------------------------------------- gate + +def gate_decision(milestone: str, findings: list[dict], allowlisted: list[dict], allow_entries: list[dict], + baseline_failed: bool, allowlist_invalid: bool, count: int, baseline_count: int | None) -> dict[str, Any]: + rule = GATE_BY_MILESTONE.get(milestone, "report-only") + reasons: list[str] = [] + if baseline_failed: + reasons.append("baseline control violated (SPEC-03 §3)") + if allowlist_invalid: + reasons.append("allow-list entry malformed (SPEC-03 §5.1 rule 1)") + open_high = [f for f in findings if f["severity"] in ("CRITICAL", "HIGH") and f["tool"] not in ("baseline", "gitleaks", "allowlist")] + over = 0 + if rule in ("count-not-growing", "fail-high", "zero-critical-high") and baseline_count is not None and count > baseline_count: + reasons.append(f"allow-list grew: {count} > baseline {baseline_count} (SPEC-03 §5.1 rule 5)") + if rule in ("fail-high", "zero-critical-high"): + over = len(open_high) + if over: + reasons.append(f"{over} CRITICAL/HIGH finding(s) not in the allow-list") + if rule == "zero-critical-high": + hi_entries = [e for e in allow_entries if str(e.get("severity", "")).upper() in ("CRITICAL", "HIGH")] + hi_entries += [e for e in allowlisted if e["severity"] in ("CRITICAL", "HIGH")] + if hi_entries: + reasons.append(f"{len(hi_entries)} CRITICAL/HIGH allow-list entr(ies) at M5 (must be empty)") + return {"rule": rule, "over_threshold": over if rule in ("fail-high", "zero-critical-high") else len(open_high), + "pass": not reasons, "reasons": reasons} + + +# --------------------------------------------------------------------------- run + +def run(ctx: Context, args, runner: Runner | None = None, which: Callable[[str], bool] | None = None, + today: _dt.date | None = None, prober=None) -> int: + runner = runner or default_runner(ctx.root) + which = which or default_which + today = today or _dt.date.today() + ts = report.timestamp() + secrets = _env_secrets(ctx.runtime / ".env") + only = {k for k in ("baseline", "secrets", "dynamic") if getattr(args, k, False)} + full = not only + + milestone_data, problems = _load_or_create(ctx.root / "manifest" / "milestone.json", DEFAULT_MILESTONE) + allow_data, p2 = _load_or_create(ctx.root / "manifest" / "allowlist.json", DEFAULT_ALLOWLIST) + base_data, p3 = _load_or_create(ctx.root / "manifest" / "allowlist.baseline.json", DEFAULT_BASELINE) + problems += p2 + p3 + milestone = getattr(args, "milestone", None) or str(milestone_data.get("milestone", "M1")) + if milestone not in MILESTONES: + problems.append(f"unknown milestone {milestone!r}; treating as M1") + milestone = "M1" + + findings: list[dict] = [] + tools: list[dict] = [] + notes: list[str] = list(problems) + baseline_result = "not-run" + dynamic_unhealthy = False + missing: ScannerMissing | None = None + + try: + if full or "baseline" in only: + bfind, bnotes = check_baseline(ctx.runtime / "docker-compose.yml") + findings.extend(bfind) + notes.extend(bnotes) + baseline_result = "pass" if not bfind else "fail" + if bnotes and not (ctx.runtime / "docker-compose.yml").exists(): + baseline_result = "skipped" + if full: + tf, tt, tn = run_trivy(ctx, runner, which, ts, secrets) + findings.extend(tf) + tools.append(tt) + notes.extend(tn) + sf, st = run_semgrep(ctx, runner, which, ts, secrets) + findings.extend(sf) + tools.append(st) + if full or "secrets" in only: + gf, gt = run_gitleaks(ctx, runner, which, ts, secrets) + findings.extend(gf) + tools.append(gt) + if full or "dynamic" in only: + healthy = services_healthy(ctx, runner, which, prober) + if healthy: + zf, zt, zn = run_zap(ctx, runner, which, ts, secrets) + findings.extend(zf) + tools.append(zt) + notes.extend(zn) + elif "dynamic" in only: + dynamic_unhealthy = True + tools.append({"name": "zap", "version": "stable", "result": "services-unhealthy", "targets": 0}) + else: + notes.append("services not healthy; dynamic (ZAP) part skipped (SPEC-03 §4.3)") + tools.append({"name": "zap", "version": "stable", "result": "skipped", "targets": 0}) + except ScannerMissing as exc: + missing = exc + tools.append({"name": exc.tool, "version": "missing", "result": f"unavailable: {exc.detail}", "targets": 0}) + + # Allow-list + entries = allow_data.get("entries", []) + active, allow_findings = validate_allowlist(entries, today) + allowlist_invalid = any(f["id"] == "ALLOWLIST-MALFORMED" for f in allow_findings) + findings.extend(allow_findings) + open_findings: list[dict] = [] + allowlisted: list[dict] = [] + for f in findings: + if f["tool"] in ("baseline", "gitleaks", "allowlist"): # no allow-list for baseline controls (ADR-03 §3.2) + open_findings.append(f) + elif any(_entry_matches(e, f) for e in active): + allowlisted.append(f) + else: + open_findings.append(f) + counts = base_data.get("counts") if isinstance(base_data.get("counts"), dict) else {} + baseline_count: int | None = None + for m in reversed(MILESTONES[: MILESTONES.index(milestone) + 1]): + if isinstance(counts.get(m), int): + baseline_count = counts[m] + break + count = len(entries) if isinstance(entries, list) else 0 + baseline_failed = any(f["tool"] in ("baseline", "gitleaks") for f in findings) + gate = gate_decision(milestone, open_findings, allowlisted, active, baseline_failed, allowlist_invalid, count, baseline_count) + + by_sev = {s.lower(): sum(1 for f in open_findings if f["severity"] == s) for s in SEVERITIES} + if missing is not None: + code = exit_codes.SCANNER_UNAVAILABLE + elif dynamic_unhealthy: + code = exit_codes.SERVICES_UNHEALTHY + elif not gate["pass"]: + code = exit_codes.SCAN_GATE_FAILED + else: + code = exit_codes.OK + + rc, sha = runner(["git", "rev-parse", "--short", "HEAD"]) + data: dict[str, Any] = { + "date": _dt.datetime.now(_dt.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"), + "milestone": milestone, + "commit": sha.strip() if rc == 0 else "unknown", + "host": f"{platform.system().lower()}-{platform.machine().lower()}", + "parts": sorted(only) if only else ["baseline", "trivy", "semgrep", "gitleaks", "zap"], + "baseline": baseline_result, + "tools": tools, + "findings_total": len(open_findings), + "findings_by_severity": by_sev, + "allowlisted": len(allowlisted), + "allowlist_count": count, + "allowlist_baseline": baseline_count, + "over_threshold": gate["over_threshold"], + "gate_rule": gate["rule"], + "gate": "pass" if gate["pass"] else "fail", + "gate_reasons": gate["reasons"], + "notes": notes, + "findings": open_findings, + "exit_code": code, + } + data = mask_secrets(data, secrets) + report.emit(ctx, "scan", data) + if code == exit_codes.SCANNER_UNAVAILABLE and missing is not None: + return report.error(ctx, code, f"{missing.tool}: {missing.detail}") + if code == exit_codes.SERVICES_UNHEALTHY: + return report.error(ctx, code, "run grdm-dev up / grdm-dev health first") + if code == exit_codes.SCAN_GATE_FAILED: + return report.error(ctx, code, "; ".join(gate["reasons"])) + return code diff --git a/installer/grdm_dev/secrets.py b/installer/grdm_dev/secrets.py new file mode 100644 index 0000000..970ca3d --- /dev/null +++ b/installer/grdm_dev/secrets.py @@ -0,0 +1,252 @@ +"""grdm-dev secrets init / secrets rotate — random secrets in runtime/.env (SPEC-02 §3, SPEC-03 §3.1). + +Key list written to runtime/.env. The service templates under templates/.json reference +these keys as `${KEY}`; `compose render` reads runtime/.env and substitutes the values into the +generated Compose file and the rewritten upstream env files. Add a key here first, then use it in +a template (the test suite checks that every key a template references is generated). + +Secret keys (regenerated by `secrets rotate`, never printed, never given a default value): + + POSTGRES_PASSWORD postgres superuser password (upstream default was postgres/postgres) + DJANGO_SECRET_KEY OSF website SECRET_KEY (>= 50 characters) + API_SECRET_KEY OSF api SECRET_KEY + SESSION_COOKIE_SECRET OSF session cookie signing secret + RABBITMQ_DEFAULT_PASS RabbitMQ password for the Celery broker (upstream default was guest) + WATERBUTLER_JWE_SECRET waterbutler <-> OSF JWE secret (upstream default was "changeme") + WATERBUTLER_JWE_SALT waterbutler <-> OSF JWE salt + WATERBUTLER_JWT_SECRET waterbutler <-> OSF JWT secret + WATERBUTLER_HMAC_SECRET waterbutler callback HMAC secret + OSFSTORAGE_HMAC_SECRET osfstorage provider HMAC secret + MFR_SERVER_SECRET mfr <-> OSF shared secret + SHAREJS_SECRET sharejs <-> OSF shared secret + Y_WEBSOCKET_JWT_SECRET y-websocket JWT auth secret (adopted PR RDM-osf.io#797) + CAS_TGC_ENCRYPTION_KEY CAS ticket-granting cookie encryption key + CAS_TGC_SIGNING_KEY CAS ticket-granting cookie signing key + CAS_WEBFLOW_ENCRYPTION_KEY CAS webflow encryption key + CAS_WEBFLOW_SIGNING_KEY CAS webflow signing key + +No Sentry key is written: the developer environment reports no errors to an external service. + +Non-secret keys (written by `init` only when absent, kept by `rotate`): + + GRDM_PROFILE minimum | core | full (SPEC-02 §5) + GRDM_PORT_ default host ports from the SPEC-02 §4 ports table; `compose render` + overwrites a value when it had to remap a busy port + +Behavior: the file is created with mode 0600 inside runtime/ (mode 0700). `init` refuses to overwrite +an existing file without --force (exit 2). `rotate` keeps non-secret keys, regenerates every secret, +and restarts running services through an injectable callable (default: lifecycle.restart). +""" +from __future__ import annotations + +import os +import secrets as _secrets +import stat +import sys +from pathlib import Path + +from . import exit_codes, report +from .context import Context + +SECRET_KEYS: tuple[str, ...] = ( + "POSTGRES_PASSWORD", + "DJANGO_SECRET_KEY", + "API_SECRET_KEY", + "SESSION_COOKIE_SECRET", + "RABBITMQ_DEFAULT_PASS", + "WATERBUTLER_JWE_SECRET", + "WATERBUTLER_JWE_SALT", + "WATERBUTLER_JWT_SECRET", + "WATERBUTLER_HMAC_SECRET", + "OSFSTORAGE_HMAC_SECRET", + "MFR_SERVER_SECRET", + "SHAREJS_SECRET", + "Y_WEBSOCKET_JWT_SECRET", + "CAS_TGC_ENCRYPTION_KEY", + "CAS_TGC_SIGNING_KEY", + "CAS_WEBFLOW_ENCRYPTION_KEY", + "CAS_WEBFLOW_SIGNING_KEY", +) + +# Bytes of randomness per key; token_urlsafe gives ~1.3 characters per byte. Django wants >= 50 chars. +_SECRET_BYTES: dict[str, int] = {"DJANGO_SECRET_KEY": 48, "API_SECRET_KEY": 48} +_DEFAULT_BYTES = 32 + +# SPEC-02 §4 ports table: the only place default host ports are defined; copied here as defaults. +DEFAULT_PORTS: dict[str, int] = { + "web": 5000, + "api": 8000, + "admin": 8001, + "wb": 7777, + "mfr": 7778, + "fakecas": 8080, + "ember_osf_web": 4200, +} + +# Values upstream compose files ship with; SPEC-03 §3.1 forbids them anywhere in runtime/.env. +FORBIDDEN_DEFAULTS: frozenset[str] = frozenset({"postgres", "changeme", "guest", "password", "secret", "osf", ""}) + +DEFAULT_PROFILE = "core" +HEADER = "# generated by grdm-dev secrets init — mode 0600, never commit (SPEC-03 §3.1)\n" + + +def env_path(ctx: Context) -> Path: + return ctx.runtime / ".env" + + +def port_key(service: str) -> str: + return f"GRDM_PORT_{service.upper()}" + + +def generate_secret(key: str) -> str: + return _secrets.token_urlsafe(_SECRET_BYTES.get(key, _DEFAULT_BYTES)) + + +def read_env(path: Path) -> dict[str, str]: + """Parse KEY=value lines (comments and blanks ignored; surrounding quotes stripped).""" + values: dict[str, str] = {} + if not path.exists(): + return values + for raw in path.read_text(encoding="utf-8").splitlines(): + line = raw.strip() + if not line or line.startswith("#") or "=" not in line: + continue + key, _, value = line.partition("=") + key = key.strip() + value = value.strip() + if len(value) >= 2 and value[0] == value[-1] and value[0] in "\"'": + value = value[1:-1] + if key: + values[key] = value + return values + + +def write_env(path: Path, values: dict[str, str]) -> None: + """Write the file atomically with mode 0600 inside a 0700 directory.""" + path.parent.mkdir(parents=True, exist_ok=True) + os.chmod(path.parent, 0o700) + body = HEADER + "".join(f"{k}={v}\n" for k, v in values.items()) + tmp = path.with_name(path.name + ".tmp") + fd = os.open(tmp, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600) + with os.fdopen(fd, "w", encoding="utf-8") as fh: + fh.write(body) + os.chmod(tmp, 0o600) + os.replace(tmp, path) + os.chmod(path, 0o600) + + +def fresh_secrets() -> dict[str, str]: + return {key: generate_secret(key) for key in SECRET_KEYS} + + +def default_non_secrets(profile: str) -> dict[str, str]: + values = {"GRDM_PROFILE": profile} + for service, port in DEFAULT_PORTS.items(): + values[port_key(service)] = str(port) + return values + + +def check_no_defaults(values: dict[str, str]) -> list[str]: + """Return secret keys whose value is a forbidden upstream default or too short.""" + bad = [] + for key in SECRET_KEYS: + v = values.get(key, "") + if v.lower() in FORBIDDEN_DEFAULTS or len(v) < 32: + bad.append(key) + if len(values.get("DJANGO_SECRET_KEY", "")) < 50: + bad.append("DJANGO_SECRET_KEY") + return sorted(set(bad)) + + +def file_mode(path: Path) -> int: + return stat.S_IMODE(path.stat().st_mode) + + +def register(subparsers) -> None: + p = subparsers.add_parser("secrets", help="init: write random secrets to runtime/.env (0600); rotate: regenerate them") + p.set_defaults(_module=sys.modules[__name__], secrets_action=None) + sub = p.add_subparsers(dest="secrets_action", metavar="") + init = sub.add_parser("init", help="create runtime/.env with random secrets; refuses to overwrite without --force") + init.add_argument("--force", action="store_true", help="overwrite an existing runtime/.env") + init.set_defaults(_module=sys.modules[__name__], secrets_action="init") + rot = sub.add_parser("rotate", help="regenerate every secret, keep non-secret keys, restart running services") + rot.set_defaults(_module=sys.modules[__name__], secrets_action="rotate") + + +def run(ctx: Context, args, runner=None, restart=None, running_services=None) -> int: + action = getattr(args, "secrets_action", None) + if action == "init": + return run_init(ctx, force=bool(getattr(args, "force", False))) + if action == "rotate": + return run_rotate(ctx, runner=runner, restart=restart, running_services=running_services) + return report.error(ctx, exit_codes.USAGE, "choose `secrets init` or `secrets rotate`") + + +def _report(ctx: Context, action: str, values: dict[str, str], path: Path, extra: dict | None = None) -> None: + data = { + "action": action, + "path": str(path), + "mode": oct(file_mode(path)), + "profile": values.get("GRDM_PROFILE"), + "secret_keys": [k for k in values if k in SECRET_KEYS], # names only, never values + "non_secret_keys": [k for k in values if k not in SECRET_KEYS], + } + if extra: + data.update(extra) + report.emit(ctx, "secrets", data) + + +def run_init(ctx: Context, force: bool = False) -> int: + path = env_path(ctx) + existing = read_env(path) if path.exists() else {} + if path.exists() and not force: + return report.error( + ctx, exit_codes.USAGE, f"{path} already exists; keep it (idempotent) or pass --force to overwrite" + ) + profile = ctx.profile or existing.get("GRDM_PROFILE") or DEFAULT_PROFILE + values: dict[str, str] = {} + values.update(default_non_secrets(profile)) + # keep non-secret keys that compose render may have written (remapped ports etc.) when forcing + for k, v in existing.items(): + if k not in SECRET_KEYS: + values[k] = v + if ctx.profile: + values["GRDM_PROFILE"] = ctx.profile + values.update(fresh_secrets()) + bad = check_no_defaults(values) + if bad: # cannot happen with token_urlsafe, but SPEC-03 §3.1 says fail rather than write a default + return report.error(ctx, exit_codes.USAGE, "refusing to write default-looking secrets: " + ", ".join(bad)) + write_env(path, values) + _report(ctx, "init", values, path, {"overwritten": bool(existing)}) + return exit_codes.OK + + +def run_rotate(ctx: Context, runner=None, restart=None, running_services=None) -> int: + path = env_path(ctx) + if not path.exists(): + return report.error(ctx, exit_codes.USAGE, f"{path} does not exist; run `grdm-dev secrets init` first") + values = read_env(path) + kept = {k: v for k, v in values.items() if k not in SECRET_KEYS} + new_values = dict(kept) + new_values.update(fresh_secrets()) + write_env(path, new_values) + + restarted: list[str] = [] + if running_services is None or restart is None: + from . import lifecycle # lazy: lifecycle imports health; avoid import cycles at module load + + running_services = running_services or (lambda: lifecycle.running_services(ctx, runner=runner)) + restart = restart or (lambda services: lifecycle.restart(ctx, services, runner=runner)) + try: + running = list(running_services()) + except Exception as exc: # docker absent: rotation still succeeded, just nothing to restart + sys.stderr.write(f"[grdm-dev] secrets rotate: could not list services ({exc}); nothing restarted\n") + running = [] + if running: + rc = restart(running) + if rc != 0: + _report(ctx, "rotate", new_values, path, {"restarted": [], "restart_failed": True}) + return report.error(ctx, exit_codes.HEALTH_FAILED, "services could not be restarted after rotation") + restarted = running + _report(ctx, "rotate", new_values, path, {"restarted": restarted}) + return exit_codes.OK diff --git a/installer/grdm_dev/templates/admin.json b/installer/grdm_dev/templates/admin.json new file mode 100644 index 0000000..279c40c --- /dev/null +++ b/installer/grdm_dev/templates/admin.json @@ -0,0 +1,57 @@ +{ + "service": "admin", + "component": "osf.io", + "profile": "core", + "command": [ + "invoke", + "adminserver", + "-h", + "0.0.0.0" + ], + "environment": { + "DJANGO_SETTINGS_MODULE": "admin.base.settings", + "LANG": "en_US.UTF-8", + "PYTHONUNBUFFERED": "1", + "SECRET_KEY": "${DJANGO_SECRET_KEY}", + "API_SECRET_KEY": "${API_SECRET_KEY}", + "SESSION_COOKIE_SECRET": "${SESSION_COOKIE_SECRET}", + "OSF_DB_PASSWORD": "${POSTGRES_PASSWORD}", + "BROKER_URL": "amqp://grdm:${RABBITMQ_DEFAULT_PASS}@rabbitmq:5672/", + "WATERBUTLER_JWE_SECRET": "${WATERBUTLER_JWE_SECRET}", + "WATERBUTLER_JWE_SALT": "${WATERBUTLER_JWE_SALT}", + "WATERBUTLER_JWT_SECRET": "${WATERBUTLER_JWT_SECRET}", + "MFR_SERVER_SECRET": "${MFR_SERVER_SECRET}", + "SHAREJS_SECRET": "${SHAREJS_SECRET}", + "Y_WEBSOCKET_JWT_SECRET": "${Y_WEBSOCKET_JWT_SECRET}" + }, + "env_files": [ + "osf.env" + ], + "volumes": [ + { + "config": "osf/local.py", + "target": "/code/website/settings/local.py", + "ro": true + }, + { + "config": "osf/api_local.py", + "target": "/code/api/base/settings/local.py", + "ro": true + } + ], + "tmpfs": [ + "/tmp" + ], + "user": "1000:1000", + "depends_on": [ + "postgres", + "rabbitmq", + "elasticsearch" + ], + "weight": 2, + "mem_min_mb": 512, + "pids_limit": 1024, + "container_port": 8001, + "host_port": 8001, + "note": "Upstream also starts crond for rdm_statistics; cron needs root, so it is left to a later milestone (non-root rule, SPEC-03 §3.3)." +} diff --git a/installer/grdm_dev/templates/aipf_mcp_data_grdm.json b/installer/grdm_dev/templates/aipf_mcp_data_grdm.json new file mode 100644 index 0000000..8b63ab4 --- /dev/null +++ b/installer/grdm_dev/templates/aipf_mcp_data_grdm.json @@ -0,0 +1,23 @@ +{ + "service": "aipf_mcp_data_grdm", + "component": "aipf_mcp_data_grdm", + "container_port": 8101, + "expose": [ + 8101 + ], + "environment": { + "OSF_API_URL": "http://api:8000/v2/", + "HOME": "/tmp" + }, + "tmpfs": [ + "/tmp" + ], + "user": "1000:1000", + "depends_on": [ + "api" + ], + "weight": 1, + "mem_min_mb": 256, + "pids_limit": 512, + "note": "Port provisional." +} diff --git a/installer/grdm_dev/templates/api.json b/installer/grdm_dev/templates/api.json new file mode 100644 index 0000000..e0f3f29 --- /dev/null +++ b/installer/grdm_dev/templates/api.json @@ -0,0 +1,56 @@ +{ + "service": "api", + "component": "osf.io", + "profile": "minimum", + "command": [ + "invoke", + "apiserver", + "-h", + "0.0.0.0" + ], + "environment": { + "DJANGO_SETTINGS_MODULE": "api.base.settings", + "LANG": "en_US.UTF-8", + "PYTHONUNBUFFERED": "1", + "SECRET_KEY": "${DJANGO_SECRET_KEY}", + "API_SECRET_KEY": "${API_SECRET_KEY}", + "SESSION_COOKIE_SECRET": "${SESSION_COOKIE_SECRET}", + "OSF_DB_PASSWORD": "${POSTGRES_PASSWORD}", + "BROKER_URL": "amqp://grdm:${RABBITMQ_DEFAULT_PASS}@rabbitmq:5672/", + "WATERBUTLER_JWE_SECRET": "${WATERBUTLER_JWE_SECRET}", + "WATERBUTLER_JWE_SALT": "${WATERBUTLER_JWE_SALT}", + "WATERBUTLER_JWT_SECRET": "${WATERBUTLER_JWT_SECRET}", + "MFR_SERVER_SECRET": "${MFR_SERVER_SECRET}", + "SHAREJS_SECRET": "${SHAREJS_SECRET}", + "Y_WEBSOCKET_JWT_SECRET": "${Y_WEBSOCKET_JWT_SECRET}" + }, + "env_files": [ + "osf.env" + ], + "volumes": [ + { + "config": "osf/local.py", + "target": "/code/website/settings/local.py", + "ro": true + }, + { + "config": "osf/api_local.py", + "target": "/code/api/base/settings/local.py", + "ro": true + } + ], + "tmpfs": [ + "/tmp" + ], + "user": "1000:1000", + "depends_on": [ + "postgres", + "rabbitmq", + "elasticsearch" + ], + "weight": 4, + "mem_min_mb": 512, + "pids_limit": 1024, + "container_port": 8000, + "host_port": 8000 +} diff --git a/installer/grdm_dev/templates/cas.json b/installer/grdm_dev/templates/cas.json new file mode 100644 index 0000000..2d43d5f --- /dev/null +++ b/installer/grdm_dev/templates/cas.json @@ -0,0 +1,33 @@ +{ + "service": "cas", + "component": "cas-overlay", + "container_port": 8080, + "expose": [ + 8080 + ], + "environment": { + "CAS_TGC_ENCRYPTION_KEY": "${CAS_TGC_ENCRYPTION_KEY}", + "CAS_TGC_SIGNING_KEY": "${CAS_TGC_SIGNING_KEY}", + "CAS_WEBFLOW_ENCRYPTION_KEY": "${CAS_WEBFLOW_ENCRYPTION_KEY}", + "CAS_WEBFLOW_SIGNING_KEY": "${CAS_WEBFLOW_SIGNING_KEY}", + "DATABASE_PASSWORD": "${POSTGRES_PASSWORD}" + }, + "volumes": [ + { + "config": "cas/cas.properties", + "target": "/code/etc/cas.properties", + "ro": true + } + ], + "tmpfs": [ + "/tmp" + ], + "user": "1000:1000", + "depends_on": [ + "postgres" + ], + "weight": 2, + "mem_min_mb": 512, + "pids_limit": 512, + "note": "Uses database `cas` on the shared postgres (created by config/postgres-init). Not published on the host while fakecas is the auth provider." +} diff --git a/installer/grdm_dev/templates/elasticsearch.json b/installer/grdm_dev/templates/elasticsearch.json new file mode 100644 index 0000000..956dc5c --- /dev/null +++ b/installer/grdm_dev/templates/elasticsearch.json @@ -0,0 +1,22 @@ +{ + "service": "elasticsearch", + "component": "elasticsearch2", + "expose": [ + 9200 + ], + "environment": { + "ES_HEAP_SIZE": "512m" + }, + "volumes": [ + { + "volume": "elasticsearch_data", + "target": "/usr/share/elasticsearch/data" + } + ], + "tmpfs": [ + "/tmp" + ], + "weight": 3, + "mem_min_mb": 1024, + "pids_limit": 1024 +} diff --git a/installer/grdm_dev/templates/elasticsearch6.json b/installer/grdm_dev/templates/elasticsearch6.json new file mode 100644 index 0000000..51c4638 --- /dev/null +++ b/installer/grdm_dev/templates/elasticsearch6.json @@ -0,0 +1,25 @@ +{ + "service": "elasticsearch6", + "component": "elasticsearch6", + "expose": [ + 9200 + ], + "environment": { + "discovery.type": "single-node", + "ES_JAVA_OPTS": "-Xms512m -Xmx512m", + "xpack.security.enabled": "false" + }, + "volumes": [ + { + "volume": "elasticsearch6_data", + "target": "/usr/share/elasticsearch/data" + } + ], + "tmpfs": [ + "/tmp" + ], + "user": "1000:1000", + "weight": 3, + "mem_min_mb": 1024, + "pids_limit": 1024 +} diff --git a/installer/grdm_dev/templates/ember_osf_web.json b/installer/grdm_dev/templates/ember_osf_web.json new file mode 100644 index 0000000..974d70f --- /dev/null +++ b/installer/grdm_dev/templates/ember_osf_web.json @@ -0,0 +1,37 @@ +{ + "service": "ember_osf_web", + "component": "ember-osf-web", + "command": [ + "/bin/sh", + "-c", + "yarn --frozen-lockfile && yarn start --host 0.0.0.0 --port 4200 --live-reload-port 41953" + ], + "container_port": 4200, + "host_port": 4200, + "expose": [ + 41953 + ], + "environment": { + "BACKEND": "local", + "YARN_CACHE_FOLDER": "/tmp/yarn-cache", + "HOME": "/tmp" + }, + "volumes": [ + { + "volume": "ember_osf_web_dist", + "target": "/code/dist" + } + ], + "tmpfs": [ + "/tmp" + ], + "user": "1000:1000", + "depends_on": [ + "api", + "web" + ], + "weight": 3, + "mem_min_mb": 1024, + "pids_limit": 1024, + "note": "Live-reload port 41953 is reachable inside the network only; publishing it is not in the SPEC-02 §4 table." +} diff --git a/installer/grdm_dev/templates/fakecas.json b/installer/grdm_dev/templates/fakecas.json new file mode 100644 index 0000000..eb0c7bc --- /dev/null +++ b/installer/grdm_dev/templates/fakecas.json @@ -0,0 +1,20 @@ +{ + "service": "fakecas", + "component": "fakecas", + "profile": "minimum", + "container_port": 8080, + "host_port": 8080, + "command": [ + "fakecas", + "-host=0.0.0.0:8080", + "-osfhost=127.0.0.1:{{HOST_PORT:web}}", + "-dbaddress=postgres://postgres:${POSTGRES_PASSWORD}@postgres:5432/osf?sslmode=disable" + ], + "user": "65534:65534", + "depends_on": [ + "postgres" + ], + "weight": 0.5, + "mem_min_mb": 64, + "pids_limit": 128 +} diff --git a/installer/grdm_dev/templates/mfr.json b/installer/grdm_dev/templates/mfr.json new file mode 100644 index 0000000..698763c --- /dev/null +++ b/installer/grdm_dev/templates/mfr.json @@ -0,0 +1,30 @@ +{ + "service": "mfr", + "component": "modular-file-renderer", + "command": [ + "invoke", + "server" + ], + "container_port": 7778, + "host_port": 7778, + "environment": { + "PYTHONUNBUFFERED": "1", + "SERVER_CONFIG_HMAC_SECRET": "${MFR_SERVER_SECRET}" + }, + "env_files": [ + "mfr.env" + ], + "volumes": [ + { + "volume": "wb_tmp", + "target": "/tmp" + } + ], + "user": "1000:1000", + "depends_on": [ + "unoconv" + ], + "weight": 2, + "mem_min_mb": 256, + "pids_limit": 512 +} diff --git a/installer/grdm_dev/templates/mongo.json b/installer/grdm_dev/templates/mongo.json new file mode 100644 index 0000000..84ec02d --- /dev/null +++ b/installer/grdm_dev/templates/mongo.json @@ -0,0 +1,24 @@ +{ + "service": "mongo", + "component": "mongo", + "expose": [ + 27017 + ], + "command": [ + "/bin/bash", + "-c", + "openssl req -newkey rsa:2048 -new -x509 -days 9999 -nodes -subj '/C=JP/ST=Tokyo/L=Chiyoda/O=NII/OU=GRDM dev/CN=mongo' -out /etc/ssl/mongodb.crt -keyout /etc/ssl/mongodb.key && cat /etc/ssl/mongodb.key /etc/ssl/mongodb.crt > /etc/ssl/mongodb.pem && chown -R mongodb:mongodb /etc/ssl /data/db && chmod -R 0600 /etc/ssl/* && gosu mongodb mongod --sslMode requireSSL --sslDisabledProtocols=TLS1_0,TLS1_1 --sslPEMKeyFile /etc/ssl/mongodb.pem" + ], + "volumes": [ + { + "volume": "mongo_data", + "target": "/data/db" + } + ], + "tmpfs": [ + "/tmp" + ], + "weight": 1, + "mem_min_mb": 256, + "pids_limit": 512 +} diff --git a/installer/grdm_dev/templates/oasys.json b/installer/grdm_dev/templates/oasys.json new file mode 100644 index 0000000..39aec6e --- /dev/null +++ b/installer/grdm_dev/templates/oasys.json @@ -0,0 +1,25 @@ +{ + "service": "oasys", + "component": "OASys", + "container_port": 3100, + "expose": [ + 3100 + ], + "environment": { + "NODE_ENV": "development", + "PORT": "3100", + "OSF_URL": "http://127.0.0.1:{{HOST_PORT:web}}", + "HOME": "/tmp" + }, + "tmpfs": [ + "/tmp" + ], + "user": "1000:1000", + "depends_on": [ + "web" + ], + "weight": 2, + "mem_min_mb": 512, + "pids_limit": 512, + "note": "Port provisional." +} diff --git a/installer/grdm_dev/templates/postgres.json b/installer/grdm_dev/templates/postgres.json new file mode 100644 index 0000000..a1a6eb0 --- /dev/null +++ b/installer/grdm_dev/templates/postgres.json @@ -0,0 +1,31 @@ +{ + "service": "postgres", + "component": "postgres", + "expose": [ + 5432 + ], + "environment": { + "POSTGRES_DB": "osf", + "POSTGRES_USER": "postgres", + "POSTGRES_PASSWORD": "${POSTGRES_PASSWORD}", + "POSTGRES_INITDB_ARGS": "--auth-host=scram-sha-256 --auth-local=trust" + }, + "volumes": [ + { + "volume": "postgres_data", + "target": "/var/lib/postgresql/data" + }, + { + "config_dir": "postgres-init", + "target": "/docker-entrypoint-initdb.d", + "ro": true + } + ], + "tmpfs": [ + "/tmp", + "/var/run/postgresql" + ], + "weight": 3, + "mem_min_mb": 512, + "pids_limit": 1024 +} diff --git a/installer/grdm_dev/templates/rabbitmq.json b/installer/grdm_dev/templates/rabbitmq.json new file mode 100644 index 0000000..ffe0f2e --- /dev/null +++ b/installer/grdm_dev/templates/rabbitmq.json @@ -0,0 +1,24 @@ +{ + "service": "rabbitmq", + "component": "rabbitmq", + "expose": [ + 5672, + 15672 + ], + "environment": { + "RABBITMQ_DEFAULT_USER": "grdm", + "RABBITMQ_DEFAULT_PASS": "${RABBITMQ_DEFAULT_PASS}" + }, + "volumes": [ + { + "volume": "rabbitmq_data", + "target": "/var/lib/rabbitmq" + } + ], + "tmpfs": [ + "/tmp" + ], + "weight": 1, + "mem_min_mb": 256, + "pids_limit": 1024 +} diff --git a/installer/grdm_dev/templates/rdmcp.json b/installer/grdm_dev/templates/rdmcp.json new file mode 100644 index 0000000..e0ec499 --- /dev/null +++ b/installer/grdm_dev/templates/rdmcp.json @@ -0,0 +1,23 @@ +{ + "service": "rdmcp", + "component": "rdmcp", + "container_port": 8100, + "expose": [ + 8100 + ], + "environment": { + "OSF_API_URL": "http://api:8000/v2/", + "HOME": "/tmp" + }, + "tmpfs": [ + "/tmp" + ], + "user": "1000:1000", + "depends_on": [ + "api" + ], + "weight": 1, + "mem_min_mb": 256, + "pids_limit": 512, + "note": "Port provisional." +} diff --git a/installer/grdm_dev/templates/redis.json b/installer/grdm_dev/templates/redis.json new file mode 100644 index 0000000..e19ec7d --- /dev/null +++ b/installer/grdm_dev/templates/redis.json @@ -0,0 +1,28 @@ +{ + "service": "redis", + "component": "redis", + "expose": [ + 6379 + ], + "command": [ + "redis-server", + "--save", + "60", + "1", + "--appendonly", + "no" + ], + "volumes": [ + { + "volume": "redis_data", + "target": "/data" + } + ], + "tmpfs": [ + "/tmp" + ], + "user": "999:999", + "weight": 1, + "mem_min_mb": 128, + "pids_limit": 256 +} diff --git a/installer/grdm_dev/templates/sharejs.json b/installer/grdm_dev/templates/sharejs.json new file mode 100644 index 0000000..c0b7d93 --- /dev/null +++ b/installer/grdm_dev/templates/sharejs.json @@ -0,0 +1,24 @@ +{ + "service": "sharejs", + "component": "sharejs", + "expose": [ + 7007 + ], + "env_files": [ + "sharejs.env" + ], + "environment": { + "SHAREJS_COOKIE_SECRET": "${SHAREJS_SECRET}" + }, + "tmpfs": [ + "/tmp" + ], + "user": "1000:1000", + "depends_on": [ + "mongo", + "web" + ], + "weight": 1, + "mem_min_mb": 128, + "pids_limit": 256 +} diff --git a/installer/grdm_dev/templates/shibboleth_sp.json b/installer/grdm_dev/templates/shibboleth_sp.json new file mode 100644 index 0000000..9c4620c --- /dev/null +++ b/installer/grdm_dev/templates/shibboleth_sp.json @@ -0,0 +1,25 @@ +{ + "service": "shibboleth_sp", + "component": "Shibboleth-SP", + "container_port": 443, + "expose": [ + 443, + 80 + ], + "environment": { + "OSF_INTERNAL_URL": "http://web:5000/" + }, + "tmpfs": [ + "/tmp", + "/run", + "/var/run" + ], + "depends_on": [ + "web", + "test_idp" + ], + "weight": 1, + "mem_min_mb": 256, + "pids_limit": 512, + "note": "Apache + shibd on a CentOS base run as root; exceptions in manifest/hardening.json. Replaces fakecas with --auth shibboleth." +} diff --git a/installer/grdm_dev/templates/test_idp.json b/installer/grdm_dev/templates/test_idp.json new file mode 100644 index 0000000..8577830 --- /dev/null +++ b/installer/grdm_dev/templates/test_idp.json @@ -0,0 +1,17 @@ +{ + "service": "test_idp", + "component": "Shibboleth-SP", + "container_port": 8443, + "expose": [ + 8443 + ], + "tmpfs": [ + "/tmp", + "/run", + "/var/run" + ], + "weight": 1, + "mem_min_mb": 256, + "pids_limit": 512, + "note": "Bundled test IdP for acceptance; runs as root until the image is rebuilt (hardening.json)." +} diff --git a/installer/grdm_dev/templates/unoconv.json b/installer/grdm_dev/templates/unoconv.json new file mode 100644 index 0000000..b596cc4 --- /dev/null +++ b/installer/grdm_dev/templates/unoconv.json @@ -0,0 +1,25 @@ +{ + "service": "unoconv", + "component": "unoconv", + "expose": [ + 2002 + ], + "command": [ + "/bin/bash", + "-c", + "/usr/bin/python3.7 /usr/local/bin/unoconv --listener --server=0.0.0.0 --port=2002 -vvv" + ], + "environment": { + "UNO_PATH": "/usr/lib/libreoffice", + "HOME": "/tmp" + }, + "volumes": [ + { + "volume": "wb_tmp", + "target": "/tmp" + } + ], + "weight": 2, + "mem_min_mb": 512, + "pids_limit": 512 +} diff --git a/installer/grdm_dev/templates/wb.json b/installer/grdm_dev/templates/wb.json new file mode 100644 index 0000000..e4ffddc --- /dev/null +++ b/installer/grdm_dev/templates/wb.json @@ -0,0 +1,39 @@ +{ + "service": "wb", + "component": "waterbutler", + "command": [ + "invoke", + "server" + ], + "container_port": 7777, + "host_port": 7777, + "environment": { + "PYTHONUNBUFFERED": "1", + "SERVER_CONFIG_HMAC_SECRET": "${WATERBUTLER_HMAC_SECRET:-${WATERBUTLER_JWT_SECRET}}", + "OSF_AUTH_CONFIG_JWE_SALT": "${WATERBUTLER_JWE_SALT}", + "OSF_AUTH_CONFIG_JWE_SECRET": "${WATERBUTLER_JWE_SECRET}", + "OSF_AUTH_CONFIG_JWT_SECRET": "${WATERBUTLER_JWT_SECRET}", + "OSFSTORAGE_PROVIDER_CONFIG_HMAC_SECRET": "${OSFSTORAGE_HMAC_SECRET:-${WATERBUTLER_JWT_SECRET}}", + "TASKS_CONFIG_BROKER_URL": "amqp://grdm:${RABBITMQ_DEFAULT_PASS}@rabbitmq:5672//" + }, + "depends_on": [ + "rabbitmq" + ], + "weight": 2, + "env_files": [ + "wb.env" + ], + "volumes": [ + { + "volume": "osfstoragecache", + "target": "/code/website/osfstoragecache" + }, + { + "volume": "wb_tmp", + "target": "/tmp" + } + ], + "user": "1000:1000", + "mem_min_mb": 256, + "pids_limit": 512 +} diff --git a/installer/grdm_dev/templates/wb_worker.json b/installer/grdm_dev/templates/wb_worker.json new file mode 100644 index 0000000..f6cbc06 --- /dev/null +++ b/installer/grdm_dev/templates/wb_worker.json @@ -0,0 +1,38 @@ +{ + "service": "wb_worker", + "component": "waterbutler", + "command": [ + "invoke", + "celery" + ], + "environment": { + "PYTHONUNBUFFERED": "1", + "SERVER_CONFIG_HMAC_SECRET": "${WATERBUTLER_HMAC_SECRET:-${WATERBUTLER_JWT_SECRET}}", + "OSF_AUTH_CONFIG_JWE_SALT": "${WATERBUTLER_JWE_SALT}", + "OSF_AUTH_CONFIG_JWE_SECRET": "${WATERBUTLER_JWE_SECRET}", + "OSF_AUTH_CONFIG_JWT_SECRET": "${WATERBUTLER_JWT_SECRET}", + "OSFSTORAGE_PROVIDER_CONFIG_HMAC_SECRET": "${OSFSTORAGE_HMAC_SECRET:-${WATERBUTLER_JWT_SECRET}}", + "TASKS_CONFIG_BROKER_URL": "amqp://grdm:${RABBITMQ_DEFAULT_PASS}@rabbitmq:5672//" + }, + "depends_on": [ + "wb", + "rabbitmq" + ], + "weight": 2, + "env_files": [ + "wb.env" + ], + "volumes": [ + { + "volume": "osfstoragecache", + "target": "/code/website/osfstoragecache" + }, + { + "volume": "wb_tmp", + "target": "/tmp" + } + ], + "user": "1000:1000", + "mem_min_mb": 256, + "pids_limit": 512 +} diff --git a/installer/grdm_dev/templates/web.json b/installer/grdm_dev/templates/web.json new file mode 100644 index 0000000..f72389e --- /dev/null +++ b/installer/grdm_dev/templates/web.json @@ -0,0 +1,62 @@ +{ + "service": "web", + "component": "osf.io", + "profile": "minimum", + "command": [ + "invoke", + "server", + "-h", + "0.0.0.0" + ], + "environment": { + "DJANGO_SETTINGS_MODULE": "api.base.settings", + "LANG": "en_US.UTF-8", + "PYTHONUNBUFFERED": "1", + "SECRET_KEY": "${DJANGO_SECRET_KEY}", + "API_SECRET_KEY": "${API_SECRET_KEY}", + "SESSION_COOKIE_SECRET": "${SESSION_COOKIE_SECRET}", + "OSF_DB_PASSWORD": "${POSTGRES_PASSWORD}", + "BROKER_URL": "amqp://grdm:${RABBITMQ_DEFAULT_PASS}@rabbitmq:5672/", + "WATERBUTLER_JWE_SECRET": "${WATERBUTLER_JWE_SECRET}", + "WATERBUTLER_JWE_SALT": "${WATERBUTLER_JWE_SALT}", + "WATERBUTLER_JWT_SECRET": "${WATERBUTLER_JWT_SECRET}", + "MFR_SERVER_SECRET": "${MFR_SERVER_SECRET}", + "SHAREJS_SECRET": "${SHAREJS_SECRET}", + "Y_WEBSOCKET_JWT_SECRET": "${Y_WEBSOCKET_JWT_SECRET}", + "SHAREJS_SERVER_HOST": "sharejs", + "SHAREJS_SERVER_PORT": "7007" + }, + "env_files": [ + "osf.env" + ], + "volumes": [ + { + "config": "osf/local.py", + "target": "/code/website/settings/local.py", + "ro": true + }, + { + "config": "osf/api_local.py", + "target": "/code/api/base/settings/local.py", + "ro": true + }, + { + "volume": "ember_osf_web_dist", + "target": "/ember_osf_web" + } + ], + "tmpfs": [ + "/tmp" + ], + "user": "1000:1000", + "depends_on": [ + "postgres", + "rabbitmq", + "elasticsearch" + ], + "weight": 4, + "mem_min_mb": 512, + "pids_limit": 1024, + "container_port": 5000, + "host_port": 5000 +} diff --git a/installer/grdm_dev/templates/wiki.json b/installer/grdm_dev/templates/wiki.json new file mode 100644 index 0000000..9aceb27 --- /dev/null +++ b/installer/grdm_dev/templates/wiki.json @@ -0,0 +1,28 @@ +{ + "service": "wiki", + "component": "wiki-frontend", + "container_port": 3000, + "expose": [ + 3000 + ], + "environment": { + "NODE_ENV": "development", + "HOST": "0.0.0.0", + "PORT": "3000", + "OSF_URL": "http://127.0.0.1:{{HOST_PORT:web}}", + "Y_WEBSOCKET_URL": "ws://y_websocket:1234", + "HOME": "/tmp" + }, + "tmpfs": [ + "/tmp" + ], + "user": "1000:1000", + "depends_on": [ + "web", + "y_websocket" + ], + "weight": 1, + "mem_min_mb": 256, + "pids_limit": 512, + "note": "Container port and variable names are provisional until the integration repository documents them." +} diff --git a/installer/grdm_dev/templates/worker.json b/installer/grdm_dev/templates/worker.json new file mode 100644 index 0000000..c6012ef --- /dev/null +++ b/installer/grdm_dev/templates/worker.json @@ -0,0 +1,52 @@ +{ + "service": "worker", + "component": "osf.io", + "profile": "core", + "command": [ + "invoke", + "celery_worker" + ], + "environment": { + "DJANGO_SETTINGS_MODULE": "api.base.settings", + "LANG": "en_US.UTF-8", + "PYTHONUNBUFFERED": "1", + "SECRET_KEY": "${DJANGO_SECRET_KEY}", + "API_SECRET_KEY": "${API_SECRET_KEY}", + "SESSION_COOKIE_SECRET": "${SESSION_COOKIE_SECRET}", + "OSF_DB_PASSWORD": "${POSTGRES_PASSWORD}", + "BROKER_URL": "amqp://grdm:${RABBITMQ_DEFAULT_PASS}@rabbitmq:5672/", + "WATERBUTLER_JWE_SECRET": "${WATERBUTLER_JWE_SECRET}", + "WATERBUTLER_JWE_SALT": "${WATERBUTLER_JWE_SALT}", + "WATERBUTLER_JWT_SECRET": "${WATERBUTLER_JWT_SECRET}", + "MFR_SERVER_SECRET": "${MFR_SERVER_SECRET}", + "SHAREJS_SECRET": "${SHAREJS_SECRET}", + "Y_WEBSOCKET_JWT_SECRET": "${Y_WEBSOCKET_JWT_SECRET}" + }, + "env_files": [ + "osf.env" + ], + "volumes": [ + { + "config": "osf/local.py", + "target": "/code/website/settings/local.py", + "ro": true + }, + { + "config": "osf/api_local.py", + "target": "/code/api/base/settings/local.py", + "ro": true + } + ], + "tmpfs": [ + "/tmp" + ], + "user": "1000:1000", + "depends_on": [ + "postgres", + "rabbitmq", + "elasticsearch" + ], + "weight": 3, + "mem_min_mb": 512, + "pids_limit": 1024 +} diff --git a/installer/grdm_dev/templates/y_websocket.json b/installer/grdm_dev/templates/y_websocket.json new file mode 100644 index 0000000..8a27f24 --- /dev/null +++ b/installer/grdm_dev/templates/y_websocket.json @@ -0,0 +1,24 @@ +{ + "service": "y_websocket", + "component": "y-websocket", + "container_port": 1234, + "expose": [ + 1234 + ], + "environment": { + "HOST": "0.0.0.0", + "PORT": "1234", + "JWT_SECRET": "${Y_WEBSOCKET_JWT_SECRET}", + "HOME": "/tmp" + }, + "tmpfs": [ + "/tmp" + ], + "user": "1000:1000", + "depends_on": [ + "web" + ], + "weight": 1, + "mem_min_mb": 128, + "pids_limit": 256 +} diff --git a/installer/grdm_dev/toon.py b/installer/grdm_dev/toon.py index 886ccdf..b843b7b 100644 --- a/installer/grdm_dev/toon.py +++ b/installer/grdm_dev/toon.py @@ -60,7 +60,9 @@ def encode(data: Any, indent: int = 0, name: str | None = None) -> str: out.append(f"{pad}{label}[{len(data)}]:") for item in data: if isinstance(item, (dict, list)): - sub = encode(item, indent + 1) + # "- " occupies the first two columns of the item; continuation lines align with + # the text after the dash (one indent level deeper than the dash itself). + sub = encode(item, indent + 2) first, _, rest = sub.partition("\n") out.append(pad + " - " + first.strip()) if rest: diff --git a/installer/grdm_dev/upstream.py b/installer/grdm_dev/upstream.py new file mode 100644 index 0000000..98f06f4 --- /dev/null +++ b/installer/grdm_dev/upstream.py @@ -0,0 +1,32 @@ +"""grdm-dev upstream mirror | integrate — placeholder for SPEC-05 upstream tracking. + +Not implemented in M2. The daily mirror and the weekly integration are specified in +docs/spec/05_upstream_tracking.md and need Git credentials for the private -dev2027 repositories, +so they never run in this repository's CI (SPEC-02 §3). Both subcommands exit 2 with that message +until the SPEC-05 implementation lands. +""" +from __future__ import annotations + +import sys + +from . import exit_codes +from .context import Context + +NOT_IMPLEMENTED = ( + "grdm-dev upstream {action} is not implemented in M2; see docs/spec/05_upstream_tracking.md " + "(SPEC-05) for the mirror / integrate procedure to run by hand." +) + + +def register(subparsers) -> None: + p = subparsers.add_parser("upstream", help="daily mirror / weekly integration of SPEC-05 (not implemented in M2)") + sub = p.add_subparsers(dest="upstream_action", metavar="") + sub.add_parser("mirror", help="mirror upstream branches into the -dev2027 repositories (SPEC-05)") + sub.add_parser("integrate", help="weekly integration merge (SPEC-05)") + p.set_defaults(_module=sys.modules[__name__]) + + +def run(ctx: Context, args) -> int: + action = getattr(args, "upstream_action", None) or "" + sys.stderr.write("[grdm-dev] exit 2: " + NOT_IMPLEMENTED.format(action=action) + "\n") + return exit_codes.USAGE diff --git a/installer/install.sh b/installer/install.sh new file mode 100755 index 0000000..db3ff88 --- /dev/null +++ b/installer/install.sh @@ -0,0 +1,145 @@ +#!/usr/bin/env bash +# grdm-dev bootstrap (SPEC-02 §2.1). Does four things and nothing else: +# 1. runs on the bash that ships with macOS (3.2): no associative arrays, no mapfile, no ${var,,} +# 2. finds python3 >= 3.11, or prints how to install one for this OS and exits 10 +# 3. creates .venv/ at the repository root and runs `pip install -e installer` +# 4. exec .venv/bin/grdm-dev install "$@" +# OS differences live in installer/grdm_dev/host.py. Exit-code messages come from +# installer/grdm_dev/messages.tsv so bash and Python say the same thing. +# +# Environment: GRDM_PYTHON= use this interpreter; GRDM_WITH_ACCEPT=1 also installs the +# [accept] extra (pytest-playwright); GRDM_SKIP_EXEC=1 stop after the venv (tests only). +# --- 0. CRLF guard. bash misreads a CRLF file, so this runs before `set` and stays on ONE line that ends in a +# comment: the stray \r then lands inside the comment and the line still parses. +if grep -q "$(printf '\r')" "${BASH_SOURCE[0]}" 2>/dev/null; then printf '[install.sh] exit 2: %s\n this script has CRLF line endings; fix: sed -i "" "s/\\r$//" installer/install.sh\n このスクリプトの改行が CRLF です。修正: sed -i "" "s/\\r$//" installer/install.sh\n' "$(awk -F '\t' '$1 == "2" { printf "%s / %s", $2, $3; exit }' "$(dirname "${BASH_SOURCE[0]}")/grdm_dev/messages.tsv" 2>/dev/null || echo 'usage error')" >&2; exit 2; fi # one line, see above +set -euo pipefail + +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +INST="${ROOT}/installer" +MESSAGES="${INST}/grdm_dev/messages.tsv" +VENV="${ROOT}/.venv" +MIN_MAJOR=3 +MIN_MINOR=11 + +# --- messages ------------------------------------------------------------------------------------ +# message : print "en / ja" for an exit code from messages.tsv (awk only; bash 3.2 safe). +message() { + if [ -f "${MESSAGES}" ]; then + awk -F '\t' -v code="$1" '$1 == code { printf "%s / %s\n", $2, $3; exit }' "${MESSAGES}" + else + printf 'exit %s\n' "$1" + fi +} +fail() { # fail + code="$1"; shift + printf '[install.sh] exit %s: %s\n' "${code}" "$(message "${code}")" >&2 + if [ $# -gt 0 ]; then printf '%s\n' "$@" | sed 's/^/ /' >&2; fi + exit "${code}" +} + +usage() { + cat <<'EOF' +Usage: ./installer/install.sh [grdm-dev install options...] + + Bootstraps the GakuNin RDM developer environment 2027: + 1. checks that python3 is 3.11 or newer (exit 10 with install hints otherwise) + 2. creates .venv/ at the repository root and installs installer/ into it + 3. runs .venv/bin/grdm-dev install "$@" and exits with its code + Options after the script name are passed to grdm-dev install unchanged, e.g. + --yes answer every question with its default + --profile minimum|core|full + --json print reports as JSON instead of TOON + Environment: GRDM_PYTHON=, GRDM_WITH_ACCEPT=1 (install the [accept] extra). + Exit codes: see installer/grdm_dev/messages.tsv (SPEC-02 §6). + +使い方: ./installer/install.sh [grdm-dev install のオプション...] + + GakuNin RDM 開発環境 2027 を起動する薄いスクリプトです: + 1. python3 が 3.11 以上か確かめる(違えば導入方法を示して終了コード 10) + 2. リポジトリのルートに .venv/ を作り installer/ を入れる + 3. .venv/bin/grdm-dev install "$@" を実行し、その終了コードで終わる + スクリプト名の後ろの引数はそのまま grdm-dev install に渡します。例: + --yes すべての質問に既定で答える + --profile minimum|core|full + --json 報告を TOON ではなく JSON で出す + 環境変数: GRDM_PYTHON=、GRDM_WITH_ACCEPT=1([accept] 追加分も入れる) + 終了コード: installer/grdm_dev/messages.tsv を参照(SPEC-02 §6) +EOF +} +for a in "$@"; do + case "$a" in + -h|--help) usage; exit 0 ;; + --) break ;; + esac +done + +# --- 1. find python3 >= 3.11 -------------------------------------------------------------------- +py_ok() { # py_ok : 0 when it runs and is >= MIN_MAJOR.MIN_MINOR + "$1" -c "import sys; sys.exit(0 if sys.version_info[:2] >= (${MIN_MAJOR}, ${MIN_MINOR}) else 1)" >/dev/null 2>&1 +} +py_version() { "$1" -c 'import sys; print("%d.%d.%d" % sys.version_info[:3])' 2>/dev/null || echo "unknown"; } + +PY="" +FOUND="" +for cand in ${GRDM_PYTHON:-} python3 python3.13 python3.12 python3.11 python; do + if command -v "${cand}" >/dev/null 2>&1; then + if [ -z "${FOUND}" ]; then FOUND="${cand} ($(py_version "${cand}"))"; fi + if py_ok "${cand}"; then PY="${cand}"; break; fi + fi +done + +os_hint() { # how to install Python for this OS (the only OS-specific text in this script) + uname_s="$(uname -s 2>/dev/null || echo unknown)" + case "${uname_s}" in + Darwin) + echo "macOS: brew install python@3.12 (Homebrew, https://brew.sh)" + echo "macOS: brew install python@3.12 (Homebrew、https://brew.sh)" ;; + Linux) + if grep -qi microsoft /proc/version 2>/dev/null; then + echo "WSL2 (Ubuntu): sudo apt update && sudo apt install -y python3.12 python3.12-venv" + echo "WSL2(Ubuntu): sudo apt update && sudo apt install -y python3.12 python3.12-venv" + else + echo "Ubuntu: sudo apt update && sudo apt install -y python3.12 python3.12-venv" + echo "Ubuntu: sudo apt update && sudo apt install -y python3.12 python3.12-venv" + fi ;; + *) + echo "install Python 3.11 or newer from https://www.python.org/downloads/" + echo "Python 3.11 以上を https://www.python.org/downloads/ から入れてください" ;; + esac +} + +if [ -z "${PY}" ]; then + if [ -n "${FOUND}" ]; then + detail="python3 found but too old: ${FOUND}; need ${MIN_MAJOR}.${MIN_MINOR} or newer / python3 が古すぎます: ${FOUND}(${MIN_MAJOR}.${MIN_MINOR} 以上が必要)" + else + detail="python3 not found on PATH / python3 が PATH にありません" + fi + fail 10 "${detail}" "$(os_hint)" +fi + +# --- 2. virtual environment --------------------------------------------------------------------- +if [ ! -x "${VENV}/bin/python" ]; then + printf '[install.sh] creating %s with %s (%s)\n' ".venv/" "${PY}" "$(py_version "${PY}")" + if ! "${PY}" -m venv "${VENV}"; then + rm -rf "${VENV}" + fail 10 "could not create .venv/ (python3-venv missing?) / .venv/ を作れません(python3-venv が無い?)" "$(os_hint)" + fi +fi +VPY="${VENV}/bin/python" +if ! py_ok "${VPY}"; then + fail 10 "existing .venv/ uses Python $(py_version "${VPY}"); remove .venv/ and rerun / 既存の .venv/ の Python $(py_version "${VPY}") が古いです。.venv/ を消して再実行してください" +fi + +EXTRA="" +if [ "${GRDM_WITH_ACCEPT:-0}" = "1" ]; then EXTRA="[accept]"; fi +"${VPY}" -m pip install -q --upgrade pip >/dev/null 2>&1 || true +if ! "${VPY}" -m pip install -q -e "${INST}${EXTRA}"; then + fail 2 "pip install -e installer${EXTRA} failed / pip install -e installer${EXTRA} に失敗しました" +fi + +if [ "${GRDM_SKIP_EXEC:-0}" = "1" ]; then exit 0; fi + +# --- 3. hand over ------------------------------------------------------------------------------- +[ -x "${VENV}/bin/grdm-dev" ] || fail 2 ".venv/bin/grdm-dev was not installed / .venv/bin/grdm-dev が入っていません" +cd "${ROOT}" +exec "${VENV}/bin/grdm-dev" install "$@" diff --git a/installer/pyproject.toml b/installer/pyproject.toml index a14f718..b8dac56 100644 --- a/installer/pyproject.toml +++ b/installer/pyproject.toml @@ -8,7 +8,7 @@ version = "0.1.0" description = "GakuNin RDM developer environment 2027: one-command installer (SPEC-02)" readme = "README.md" requires-python = ">=3.11" -license = {text = "MIT"} +license = "MIT" dependencies = [] [project.optional-dependencies] @@ -23,4 +23,4 @@ packages = ["grdm_dev"] include-package-data = true [tool.setuptools.package-data] -grdm_dev = ["messages.tsv"] +grdm_dev = ["messages.tsv", "templates/*.json"] diff --git a/installer/tests/test_accept.py b/installer/tests/test_accept.py new file mode 100644 index 0000000..9088be4 --- /dev/null +++ b/installer/tests/test_accept.py @@ -0,0 +1,207 @@ +import argparse +import io +import json +import tempfile +import unittest +from contextlib import redirect_stderr, redirect_stdout +from pathlib import Path + +from grdm_dev import accept, cli, exit_codes +from grdm_dev.context import Context + +JUNIT_ONE_FAILURE = """ + + + + + + AssertionError + + +""" + + +def importer_ok(name): + return object() + + +def importer_missing(name): + if name == "playwright": + raise ImportError(name) + return object() + + +class FakeRunner: + """Records argv; writes junit.xml when asked to run pytest.""" + + def __init__(self, pytest_rc=0, junit=None, seed_rc=0): + self.calls = [] + self.pytest_rc = pytest_rc + self.junit = junit + self.seed_rc = seed_rc + + def __call__(self, argv, env=None, cwd=None): + self.calls.append((argv, env)) + if "pytest" in argv: + if self.junit is not None: + Path(argv[argv.index("--junitxml") + 1]).write_text(self.junit, encoding="utf-8") + return self.pytest_rc, "pytest output" + if "manage.py" in argv: + return self.seed_rc, "seeded" + return 0, "" + + +class AcceptTests(unittest.TestCase): + def setUp(self): + self.tmp = tempfile.TemporaryDirectory() + self.root = Path(self.tmp.name) + (self.root / "manifest").mkdir() + (self.root / "manifest" / "upstreams.json").write_text("{}") + (self.root / ".venv" / ".playwright" / "chromium-1").mkdir(parents=True) + self.ctx = Context(root=self.root, yes=True) + self.ctx.env = {} + + def tearDown(self): + self.tmp.cleanup() + + def args(self, **kw): + base = dict(only=None, seed=False, base_url=None, headed=False) + base.update(kw) + return argparse.Namespace(**base) + + def run_accept(self, args, runner, importer=importer_ok): + err, out = io.StringIO(), io.StringIO() + with redirect_stderr(err), redirect_stdout(out): + rc = accept.run(self.ctx, args, runner=runner, importer=importer) + return rc, err.getvalue(), out.getvalue() + + def test_missing_playwright_is_usage_error_with_hint(self): + runner = FakeRunner() + rc, err, _ = self.run_accept(self.args(), runner, importer=importer_missing) + self.assertEqual(rc, exit_codes.USAGE) + self.assertIn("playwright", err) + self.assertIn('pip install -e "installer[accept]"', err) + self.assertIn("playwright install chromium", err) + self.assertEqual(runner.calls, []) + + def test_non_loopback_base_url_is_refused(self): + for url in ("http://localhost:5000", "http://192.168.1.10:5000", "https://127.0.0.1:5000", "http://example.com"): + runner = FakeRunner() + rc, err, _ = self.run_accept(self.args(base_url=url), runner) + self.assertEqual(rc, exit_codes.USAGE, url) + self.assertEqual(runner.calls, [], url) + self.assertIsNone(accept.loopback_problem("http://127.0.0.1:5001")) + + def test_missing_browser_cache_is_usage_error(self): + for p in (self.root / ".venv" / ".playwright").iterdir(): + p.rmdir() + rc, err, _ = self.run_accept(self.args(), FakeRunner()) + self.assertEqual(rc, exit_codes.USAGE) + self.assertIn(".playwright", err) + + def test_pytest_failure_maps_to_60_and_writes_results(self): + runner = FakeRunner(pytest_rc=1, junit=JUNIT_ONE_FAILURE) + rc, err, out = self.run_accept(self.args(base_url="http://127.0.0.1:5000"), runner) + self.assertEqual(rc, exit_codes.ACCEPTANCE_FAILED) + runs = list((self.root / "docs" / "demo" / "runs").iterdir()) + self.assertEqual(len(runs), 1) + run_dir = runs[0] + self.assertTrue(run_dir.name.startswith("acc-")) + results = json.loads((run_dir / "results.json").read_text()) + self.assertEqual(results["summary"], {"passed": 1, "failed": 1, "error": 0, "skipped": 1, "total": 3}) + by_test = {r["test"]: r for r in results["tests"]} + rej = by_test["test_c1_login_rejection"] + self.assertEqual((rej["id"], rej["name"], rej["case"], rej["status"]), ("C1", "Login via fakecas", "rejection", "failed")) + self.assertEqual(rej["http_status"], 200) + self.assertEqual(by_test["test_c1_login_success"]["duration_ms"], 1250) + self.assertEqual(by_test["test_s1_y_websocket_success"]["status"], "skipped") + toon_text = (run_dir / "results.toon").read_text() + self.assertIn("accept:", toon_text) + self.assertIn("tests[3]{", toon_text) + self.assertIn("C1,Login via fakecas,rejection", toon_text) + self.assertIn("results.toon", str(list(run_dir.iterdir()))) + self.assertTrue((run_dir / "junit.xml").exists()) + # pytest was invoked with the SPEC-04 evidence flags and the loopback URL, inside the venv browsers path + argv, env = runner.calls[-1] + self.assertIn("--junitxml", argv) + self.assertEqual(argv[argv.index("--base-url") + 1], "http://127.0.0.1:5000") + self.assertEqual(argv[argv.index("--screenshot") + 1], "only-on-failure") + self.assertEqual(argv[argv.index("--tracing") + 1], "retain-on-failure") + self.assertEqual(env["PLAYWRIGHT_BROWSERS_PATH"], str(self.root / ".venv" / ".playwright")) + self.assertEqual(env["GRDM_BASE_URL"], "http://127.0.0.1:5000") + self.assertTrue(env["GRDM_ACCEPT_USER_A"].endswith("@acceptance.test")) + + def test_all_green_is_exit_0_and_collector_preferred(self): + class CollectorRunner(FakeRunner): + def __call__(self, argv, env=None, cwd=None): + rc = super().__call__(argv, env, cwd) + if "pytest" in argv: + Path(env["GRDM_ACCEPT_RESULTS"]).write_text(json.dumps([ + {"nodeid": "installer/acceptance/test_c2_create_project.py::test_c2_create_project_success", + "id": "C2", "name": "Create project", "case": "success", "status": "passed", + "duration_ms": 900, "http_status": 201, "evidence": None}])) + return rc + + runner = CollectorRunner(pytest_rc=0, junit=JUNIT_ONE_FAILURE) + rc, _, _ = self.run_accept(self.args(), runner) + self.assertEqual(rc, exit_codes.OK) + run_dir = next((self.root / "docs" / "demo" / "runs").iterdir()) + results = json.loads((run_dir / "results.json").read_text()) + self.assertEqual(results["summary"]["total"], 1) + self.assertEqual(results["tests"][0]["id"], "C2") + self.assertEqual(results["base_url"], "http://127.0.0.1:5000") # default: no runtime/.env -> port 5000 + + def test_base_url_default_reads_runtime_env_port(self): + (self.root / "runtime").mkdir() + (self.root / "runtime" / ".env").write_text("GRDM_PORT_WEB=5050\nGRDM_PORT_API=8000\n") + self.assertEqual(accept.default_base_url(self.ctx), "http://127.0.0.1:5050") + + def test_seed_runs_management_command_then_cleanup(self): + runner = FakeRunner(pytest_rc=0, junit='') + rc, _, _ = self.run_accept(self.args(seed=True), runner) + self.assertEqual(rc, exit_codes.OK) + seed_calls = [a for a, _ in runner.calls if "manage.py" in a] + self.assertEqual(len(seed_calls), 4) # user_a, user_b, admin, cleanup + self.assertEqual(seed_calls[0][:3], ["docker", "compose", "exec"]) + self.assertIn("web", seed_calls[0]) + self.assertIn("create_confirmed", seed_calls[0][-1]) + self.assertIn("delete()", seed_calls[-1][-1]) + # pytest ran between seeding and cleanup + order = ["seed" if "manage.py" in a else "pytest" for a, _ in runner.calls] + self.assertEqual(order, ["seed", "seed", "seed", "pytest", "seed"]) + + def test_seed_failure_is_52(self): + runner = FakeRunner(seed_rc=1) + rc, err, _ = self.run_accept(self.args(seed=True), runner) + self.assertEqual(rc, exit_codes.SERVICES_UNHEALTHY) + self.assertFalse(any("pytest" in a for a, _ in runner.calls)) + + def test_only_selection(self): + paths, extra = accept.select_tests("C3") + self.assertEqual([Path(p).name for p in paths], ["test_c3_file_upload.py"]) + paths, extra = accept.select_tests("login") + self.assertEqual([Path(p).name for p in paths], ["test_c1_login.py"]) + paths, extra = accept.select_tests("subsystem") + self.assertEqual(extra, ["-m", "subsystem"]) + self.assertIsNone(accept.select_tests("no-such-scenario")) + rc, err, _ = self.run_accept(self.args(only="zzz"), FakeRunner()) + self.assertEqual(rc, exit_codes.USAGE) + + def test_scenario_files_cover_c1_to_c6_and_s1_to_s5_with_both_cases(self): + for sid in accept.SCENARIOS: + files = list(accept.ACCEPTANCE_DIR.glob(f"test_{sid.lower()}_*.py")) + self.assertEqual(len(files), 1, sid) + src = files[0].read_text() + self.assertIn("_success(", src, sid) + self.assertIn("_rejection(", src, sid) + self.assertIn("pytest.mark.core" if sid.startswith("C") else 'pytest.mark.skip(reason="M3")', src, sid) + + def test_cli_registers_accept(self): + parser = cli.build_parser() + args = parser.parse_args(["accept", "--only", "C1", "--seed", "--base-url", "http://127.0.0.1:5000"]) + self.assertIs(args._module, accept) + self.assertEqual((args.only, args.seed, args.base_url), ("C1", True, "http://127.0.0.1:5000")) + + +if __name__ == "__main__": + unittest.main() diff --git a/installer/tests/test_build.py b/installer/tests/test_build.py new file mode 100644 index 0000000..3759971 --- /dev/null +++ b/installer/tests/test_build.py @@ -0,0 +1,165 @@ +import argparse +import io +import json +import tempfile +import unittest +from contextlib import redirect_stderr, redirect_stdout +from pathlib import Path + +from grdm_dev import build, exit_codes +from grdm_dev.context import Context + +SHA_OSF = "bacfe64fdc002f09df47145fc17f57630772ac82" +SHA_WB = "004f407fefb071f1dc924d09f99916b1d5ea3561" + +def comp(cid, role, profile, repo, services, **extra): + base = {"id": cid, "role": role, "profile": profile, "integration_repo": repo, + "integration_branch": "develop" if repo else None, "services": services, "upstreams": [], + "adopted_prs": [], "candidate_prs": [], "base_image": "x", "base_image_digest": None, + "target_image": {"M4": None, "M5": None}, "platforms": ["linux/arm64", "linux/amd64"], "note": None} + base.update(extra) + return base + + +UPSTREAM_WB = {"repo": "RDM-waterbutler", "branch": "develop", "kind": "public", "tracking_branch": "upstream/public-develop", + "status": "merged", "sha": SHA_WB, "fetched_at": "2026-11-05"} + +MANIFEST = { + "schema_version": 1, + "generated_at": "2026-11-05", + "components": [ + comp("osf.io", "core", "minimum", "RDM-osf.io-dev2027", ["web"], integration_sha=SHA_OSF), + comp("waterbutler", "core", "core", "RDM-waterbutler-dev2027", ["wb"], upstreams=[UPSTREAM_WB]), + comp("OASys", "subsystem", "full", "RDM-OASys-dev2027", ["oasys"]), + comp("postgres", "infra", "minimum", None, ["postgres"]), + ], +} + + +class FakeRunner: + def __init__(self, fail_build_for=None, fail_git_for=None): + self.calls = [] + self.fail_build_for = fail_build_for + self.fail_git_for = fail_git_for + + def __call__(self, argv): + self.calls.append(argv) + if argv[0] == "git": + if argv[1] == "clone": + repo = argv[-2].rsplit("/", 1)[-1].removesuffix(".git") + if repo == self.fail_git_for: + return 128, "fatal: repository not found" + Path(argv[-1], ".git").mkdir(parents=True, exist_ok=True) + return 0, "" + if argv[-2] == "rev-parse": + return 0, (SHA_OSF if "osf.io" in argv[2] else SHA_WB) + "\n" + return 0, "" + if argv[:3] == ["docker", "buildx", "build"]: + tag = [a for a in argv if a.startswith("grdm-dev/")][0] + if self.fail_build_for and tag.startswith(f"grdm-dev/{self.fail_build_for}:"): + return 1, "ERROR: failed to solve" + return 0, "ok" + return 0, "" + + +class BuildTests(unittest.TestCase): + def setUp(self): + self.tmp = tempfile.TemporaryDirectory() + self.root = Path(self.tmp.name) + (self.root / "manifest").mkdir() + (self.root / "manifest" / "upstreams.json").write_text(json.dumps(MANIFEST)) + self.out, self.err = io.StringIO(), io.StringIO() + + def tearDown(self): + self.tmp.cleanup() + + def run_cmd(self, ctx, runner, **kw): + args = argparse.Namespace(platform=kw.pop("platform", None), push=kw.pop("push", False), component=kw.pop("component", None)) + with redirect_stdout(self.out), redirect_stderr(self.err): + return build.run(ctx, args, runner=runner) + + def test_local_build_argv_and_pinned_checkout(self): + ctx = Context(root=self.root, profile="minimum", stdin_is_tty=False) + runner = FakeRunner() + self.assertEqual(self.run_cmd(ctx, runner, platform="linux/arm64"), exit_codes.OK) + clone = [c for c in runner.calls if c[:2] == ["git", "clone"]] + self.assertEqual(len(clone), 1) + self.assertIn("--filter=blob:none", clone[0]) + self.assertEqual(clone[0][-2], "https://github.com/RCOSDP/RDM-osf.io-dev2027.git") + self.assertEqual(clone[0][-1], str(self.root / "runtime" / "src" / "RDM-osf.io-dev2027")) + checkout = [c for c in runner.calls if "checkout" in c][0] + self.assertEqual(checkout[-1], SHA_OSF) + bx = [c for c in runner.calls if c[:3] == ["docker", "buildx", "build"]] + self.assertEqual(len(bx), 1) # minimum profile builds only osf.io + self.assertEqual(bx[0][3:5], ["--platform", "linux/arm64"]) + self.assertIn("--load", bx[0]) + self.assertNotIn("--push", bx[0]) + self.assertIn(f"grdm-dev/osf.io:{SHA_OSF[:12]}", bx[0]) + self.assertNotIn(f"ghcr.io/rcosdp/osf.io:{SHA_OSF[:12]}", bx[0]) + self.assertEqual(bx[0][-1], str(self.root / "runtime" / "src" / "RDM-osf.io-dev2027")) + + def test_push_adds_registry_tag_and_branch_fallback(self): + ctx = Context(root=self.root, profile="core", stdin_is_tty=False) + runner = FakeRunner() + self.assertEqual(self.run_cmd(ctx, runner, platform="linux/arm64,linux/amd64", push=True), exit_codes.OK) + bx = [c for c in runner.calls if c[:3] == ["docker", "buildx", "build"]] + self.assertEqual(len(bx), 2) # osf.io + waterbutler, not OASys (full) nor postgres (infra) + wb = [c for c in bx if any(a.startswith("grdm-dev/waterbutler:") for a in c)][0] + self.assertIn("--push", wb) + self.assertIn(f"ghcr.io/rcosdp/waterbutler:{SHA_WB[:12]}", wb) + self.assertEqual(wb[3:5], ["--platform", "linux/arm64,linux/amd64"]) + checkout = [c for c in runner.calls if "checkout" in c and "waterbutler" in c[2]][0] + self.assertEqual(checkout[-1], SHA_WB) # no integration_sha → first merged public upstream SHA + + def test_no_sha_at_all_falls_back_to_branch_head(self): + ctx = Context(root=self.root, profile="minimum", stdin_is_tty=False) + runner = FakeRunner() + self.assertEqual(self.run_cmd(ctx, runner, component="OASys"), exit_codes.OK) + checkout = [c for c in runner.calls if "checkout" in c][0] + self.assertEqual(checkout[-1], "origin/develop") + + def test_invalid_manifest_is_20(self): + (self.root / "manifest" / "upstreams.json").write_text("{not json") + ctx = Context(root=self.root, profile="minimum", stdin_is_tty=False) + self.assertEqual(self.run_cmd(ctx, FakeRunner()), exit_codes.MANIFEST_INVALID) + + def test_rerun_fetches_instead_of_cloning(self): + ctx = Context(root=self.root, profile="minimum", stdin_is_tty=False) + runner = FakeRunner() + self.run_cmd(ctx, runner) + runner2 = FakeRunner() + self.assertEqual(self.run_cmd(ctx, runner2), exit_codes.OK) + self.assertFalse([c for c in runner2.calls if c[:2] == ["git", "clone"]]) + self.assertTrue([c for c in runner2.calls if "fetch" in c]) + + def test_build_failure_is_30_and_names_component(self): + ctx = Context(root=self.root, profile="core", stdin_is_tty=False) + runner = FakeRunner(fail_build_for="waterbutler") + self.assertEqual(self.run_cmd(ctx, runner), exit_codes.BUILD_FAILED) + self.assertIn("waterbutler", self.err.getvalue()) + self.assertIn("exit 30", self.err.getvalue()) + + def test_clone_failure_is_30(self): + ctx = Context(root=self.root, profile="minimum", stdin_is_tty=False) + rc = self.run_cmd(ctx, FakeRunner(fail_git_for="RDM-osf.io-dev2027")) + self.assertEqual(rc, exit_codes.BUILD_FAILED) + self.assertIn("osf.io", self.err.getvalue()) + + def test_unknown_component_is_usage_error(self): + ctx = Context(root=self.root, profile="core", stdin_is_tty=False) + self.assertEqual(self.run_cmd(ctx, FakeRunner(), component="nope"), exit_codes.USAGE) + + def test_component_filter_ignores_profile(self): + ctx = Context(root=self.root, profile="minimum", stdin_is_tty=False) + runner = FakeRunner() + self.assertEqual(self.run_cmd(ctx, runner, component="OASys"), exit_codes.OK) + bx = [c for c in runner.calls if c[:3] == ["docker", "buildx", "build"]] + self.assertEqual(len(bx), 1) + self.assertTrue(any(a.startswith("grdm-dev/oasys:") for a in bx[0])) # lower-cased image name + + def test_host_platform_mapping(self): + self.assertIn(build.host_platform(), ("linux/arm64", "linux/amd64") + (f"linux/{build._platform.machine().lower()}",)) + + +if __name__ == "__main__": + unittest.main() diff --git a/installer/tests/test_compose.py b/installer/tests/test_compose.py new file mode 100644 index 0000000..1b8357a --- /dev/null +++ b/installer/tests/test_compose.py @@ -0,0 +1,256 @@ +import argparse +import io +import json +import os +import shutil +import stat +import tempfile +import unittest +from contextlib import redirect_stderr, redirect_stdout +from pathlib import Path + +from grdm_dev import compose, exit_codes, plan +from grdm_dev.context import Context + +REPO_ROOT = Path(__file__).resolve().parents[2] +FORBIDDEN = "192.168.168.167" + + +def fake_secrets(**overrides) -> str: + values = {k: "x" * 48 for k in compose.REQUIRED_SECRETS} + values.update(overrides) + return "".join(f"{k}={v}\n" for k, v in values.items()) + + +def make_root(dotenv: str | None = fake_secrets(), hardening=True) -> Path: + root = Path(tempfile.mkdtemp(prefix="grdm-compose-")) + (root / "manifest").mkdir() + for name in ("upstreams.json", "upstreams.toon"): + shutil.copy(REPO_ROOT / "manifest" / name, root / "manifest" / name) + if hardening: + shutil.copy(REPO_ROOT / "manifest" / "hardening.json", root / "manifest" / "hardening.json") + if dotenv is not None: + (root / "runtime").mkdir() + p = root / "runtime" / ".env" + p.write_text(dotenv, encoding="utf-8") + os.chmod(p, 0o600) + return root + + +def render(root: Path, profile="core", auth="fakecas", checker=lambda port: True, memory_gib=16.0, cpus=4.0, json_output=True): + ctx = Context(root=root, yes=True, json_output=json_output, profile=profile) + args = argparse.Namespace(compose_command="render", auth=auth, platform="linux/arm64", memory_gib=None, cpus=None) + out, err = io.StringIO(), io.StringIO() + with redirect_stdout(out), redirect_stderr(err): + rc = compose.run(ctx, args, memory_gib=memory_gib, cpus=cpus, port_checker=checker, platform_string="linux/arm64") + return rc, out.getvalue(), err.getvalue(), ctx + + +def load_hardening(): + data = json.loads((REPO_ROOT / "manifest" / "hardening.json").read_text(encoding="utf-8")) + return {e["service"]: set(e["controls"]) for e in data["exceptions"]} + + +class ComposeRenderTests(unittest.TestCase): + def test_render_core_writes_valid_json_with_baseline_controls(self): + root = make_root() + rc, out, err, ctx = render(root) + self.assertEqual(rc, exit_codes.OK, err) + text = (root / "runtime" / "docker-compose.yml").read_text(encoding="utf-8") + doc = json.loads(text) # Compose accepts JSON + self.assertEqual(set(doc["networks"]), {"grdm"}) + self.assertNotIn(FORBIDDEN, text) + exceptions = load_hardening() + services = doc["services"] + self.assertEqual(set(services), {s["service"] for s in json.loads(out)["services"]}) + self.assertEqual(len(services), 20) # core profile (SPEC-02 §4) + for name, svc in services.items(): + relaxed = exceptions.get(name, set()) + self.assertEqual(svc["networks"], ["grdm"], name) + self.assertEqual(svc["cap_drop"], ["ALL"], name) + self.assertIn("no-new-privileges:true", svc["security_opt"], name) + self.assertNotIn("privileged", svc, name) + self.assertEqual(svc["platform"], "linux/arm64", name) + for key in ("mem_limit", "cpus", "pids_limit"): + self.assertIn(key, svc, name) + if "user" in relaxed: + self.assertNotIn("user", svc, name) + else: + uid = svc["user"].split(":")[0] + self.assertNotEqual(uid, "0", name) + self.assertTrue(uid.isdigit(), name) + self.assertEqual(svc["read_only"], "read_only" not in relaxed, name) + if "cap_add" in svc: + self.assertIn("cap_add", relaxed, name) + for port in svc.get("ports", []): + self.assertTrue(port.startswith("127.0.0.1:"), port) + for dep in svc.get("depends_on", []): + self.assertIn(dep, services, f"{name} depends on {dep} outside the profile") + published = {name: svc["ports"] for name, svc in services.items() if "ports" in svc} + self.assertEqual(set(published), set(plan.DEFAULT_PORTS)) + self.assertEqual(published["web"], ["127.0.0.1:5000:5000"]) + # volumes map under runtime/volumes/ and the directories exist + for name, vol in doc["volumes"].items(): + self.assertEqual(vol["driver_opts"]["device"], str(root / "runtime" / "volumes" / name)) + self.assertTrue((root / "runtime" / "volumes" / name).is_dir()) + + def test_secrets_stay_out_of_generated_files(self): + root = make_root(fake_secrets(POSTGRES_PASSWORD="S3cretPgValue" * 3)) + rc, _, _, _ = render(root) + self.assertEqual(rc, 0) + for path in (root / "runtime").rglob("*"): + if path.is_file() and path.name != ".env": + self.assertNotIn("S3cretPgValue", path.read_text(encoding="utf-8"), str(path)) + doc = json.loads((root / "runtime" / "docker-compose.yml").read_text(encoding="utf-8")) + self.assertEqual(doc["services"]["postgres"]["environment"]["POSTGRES_PASSWORD"], "${POSTGRES_PASSWORD}") + + def test_config_files_rewrite_upstream_settings(self): + root = make_root("GRDM_PORT_WEB=5050\n" + fake_secrets()) + rc, _, _, _ = render(root) + self.assertEqual(rc, 0) + cfg = root / "runtime" / "config" + local_py = (cfg / "osf" / "local.py").read_text(encoding="utf-8") + self.assertIn("DOMAIN = 'http://127.0.0.1:5050/'", local_py) + self.assertIn("INTERNAL_DOMAIN = 'http://web:5000/'", local_py) + self.assertIn("WATERBUTLER_INTERNAL_URL = 'http://wb:7777'", local_py) + self.assertIn("MFR_SERVER_URL = 'http://127.0.0.1:7778'", local_py) + self.assertIn("CAS_SERVER_URL = 'http://127.0.0.1:8080'", local_py) + self.assertIn("SECRET_KEY = environ['SECRET_KEY']", local_py) + self.assertNotIn("CHANGEME", local_py) + osf_env = plan.read_dotenv(cfg / "osf.env") + self.assertEqual(osf_env["OSF_DB_HOST"], "postgres") + self.assertEqual(osf_env["ELASTIC_URI"], "elasticsearch:9200") + self.assertEqual(osf_env["DOMAIN"], "http://127.0.0.1:5050/") + wb_env = plan.read_dotenv(cfg / "wb.env") + self.assertEqual(wb_env["OSF_URL"], "http://web:5000") + self.assertEqual(plan.read_dotenv(cfg / "mfr.env")["UNOCONV_PORT_2002_TCP_ADDR"], "unoconv") + self.assertIn("mongodb://mongo:27017/sharejs", plan.read_dotenv(cfg / "sharejs.env")["SHAREJS_DB_URL"]) + for path in cfg.rglob("*"): + if path.is_file(): + text = path.read_text(encoding="utf-8") + self.assertNotIn(FORBIDDEN, text, str(path)) + self.assertNotIn("changeme", text.lower(), str(path)) + # the compose file mounts the rewritten settings and the fakecas redirect uses the overridden port + doc = json.loads((root / "runtime" / "docker-compose.yml").read_text(encoding="utf-8")) + self.assertIn("./config/osf/local.py:/code/website/settings/local.py:ro", doc["services"]["web"]["volumes"]) + self.assertIn("-osfhost=127.0.0.1:5050", doc["services"]["fakecas"]["command"]) + self.assertEqual(doc["services"]["web"]["ports"], ["127.0.0.1:5050:5000"]) + + def test_missing_env_exits_2_with_hint(self): + rc, _, err, _ = render(make_root(dotenv=None)) + self.assertEqual(rc, exit_codes.USAGE) + self.assertIn("grdm-dev secrets init", err) + + def test_missing_secret_key_exits_2(self): + env = "".join(f"{k}=v\n" for k in compose.REQUIRED_SECRETS if k != "RABBITMQ_DEFAULT_PASS") + rc, _, err, _ = render(make_root(env)) + self.assertEqual(rc, exit_codes.USAGE) + self.assertIn("RABBITMQ_DEFAULT_PASS", err) + + def test_invalid_manifest_exits_20(self): + root = make_root() + path = root / "manifest" / "upstreams.json" + data = json.loads(path.read_text(encoding="utf-8")) + data["components"][0]["role"] = "weird" + path.write_text(json.dumps(data, indent=2, sort_keys=True) + "\n", encoding="utf-8") + rc, _, err, _ = render(root) + self.assertEqual(rc, exit_codes.MANIFEST_INVALID) + self.assertIn("MC-03", err) + + def test_port_collision_remaps_and_records_in_env(self): + root = make_root() + rc, out, _, _ = render(root, checker=lambda port: port not in (5000, 5001)) + self.assertEqual(rc, 0) + data = json.loads(out) + self.assertEqual(data["remapped_ports"], [{"service": "web", "wanted": 5000, "chosen": 5002}]) + env = plan.read_dotenv(root / "runtime" / ".env") + self.assertEqual(env["GRDM_PORT_WEB"], "5002") + self.assertEqual(env["GRDM_PORT_API"], "8000") + self.assertEqual(env["GRDM_PROFILE"], "core") + self.assertEqual(stat.S_IMODE((root / "runtime" / ".env").stat().st_mode), 0o600) + self.assertEqual(env["POSTGRES_PASSWORD"], "x" * 48) # secrets preserved + doc = json.loads((root / "runtime" / "docker-compose.yml").read_text(encoding="utf-8")) + self.assertEqual(doc["services"]["web"]["ports"], ["127.0.0.1:5002:5000"]) + + def test_no_free_port_exits_12(self): + rc, _, err, _ = render(make_root(), checker=lambda port: port != 5000 and not (5000 <= port <= 5100)) + self.assertEqual(rc, exit_codes.PORT_IN_USE) + self.assertIn("web", err) + + def test_idempotent_rerun_reports_unchanged(self): + root = make_root() + rc1, out1, _, _ = render(root) + before = (root / "runtime" / "docker-compose.yml").read_text(encoding="utf-8") + rc2, out2, _, _ = render(root) + self.assertEqual((rc1, rc2), (0, 0)) + self.assertEqual(before, (root / "runtime" / "docker-compose.yml").read_text(encoding="utf-8")) + self.assertEqual(json.loads(out2)["written"], ["(unchanged)"]) + + def test_profiles_minimum_and_full_shibboleth(self): + root = make_root() + rc, _, _, _ = render(root, profile="minimum") + self.assertEqual(rc, 0) + doc = json.loads((root / "runtime" / "docker-compose.yml").read_text(encoding="utf-8")) + self.assertEqual(set(doc["services"]), {"web", "api", "postgres", "elasticsearch", "rabbitmq", "fakecas"}) + self.assertEqual(doc["services"]["web"]["depends_on"], ["postgres", "rabbitmq", "elasticsearch"]) + rc, _, _, _ = render(root, profile="full", auth="shibboleth") + self.assertEqual(rc, 0) + doc = json.loads((root / "runtime" / "docker-compose.yml").read_text(encoding="utf-8")) + self.assertIn("shibboleth_sp", doc["services"]) + self.assertNotIn("fakecas", doc["services"]) + self.assertEqual(len(doc["services"]), 24) + + def test_resource_limits_scale_with_memory(self): + root = make_root() + render(root, memory_gib=8.0) + small = json.loads((root / "runtime" / "docker-compose.yml").read_text(encoding="utf-8"))["services"] + render(root, memory_gib=64.0) + big = json.loads((root / "runtime" / "docker-compose.yml").read_text(encoding="utf-8"))["services"] + mb = lambda s: int(s["mem_limit"].rstrip("m")) # noqa: E731 + self.assertGreater(mb(big["web"]), mb(small["web"])) + self.assertGreaterEqual(mb(small["web"]), 512) # template minimum + total = sum(mb(s) for s in big.values()) + self.assertLessEqual(total, 64 * 1024 * compose.MEMORY_SHARE + 2048) + self.assertTrue(all(0.5 <= s["cpus"] <= 4.0 for s in big.values())) + + def test_build_report_tags_win_over_manifest(self): + root = make_root() + reports = root / "runtime" / "reports" + reports.mkdir(parents=True) + (reports / "build_latest.json").write_text(json.dumps({"components": [ + {"component": "osf.io", "sha12": "feedfacecafe", "status": "built"}, + {"component": "waterbutler", "sha12": "000000000000", "status": "build-failed"}, + ]}), encoding="utf-8") + rc, _, _, _ = render(root) + self.assertEqual(rc, 0) + doc = json.loads((root / "runtime" / "docker-compose.yml").read_text(encoding="utf-8")) + self.assertEqual(doc["services"]["web"]["image"], "grdm-dev/osf.io:feedfacecafe") + self.assertTrue(doc["services"]["wb"]["image"].startswith("grdm-dev/waterbutler:")) + self.assertNotEqual(doc["services"]["wb"]["image"], "grdm-dev/waterbutler:000000000000") + + def test_hardening_file_is_well_formed(self): + data = json.loads((REPO_ROOT / "manifest" / "hardening.json").read_text(encoding="utf-8")) + self.assertEqual(data["schema_version"], 1) + for entry in data["exceptions"]: + self.assertTrue(entry["reason"]) + self.assertRegex(entry["review"], r"^\d{4}-\d{2}-\d{2}$") + self.assertTrue(set(entry["controls"]) <= {"user", "read_only", "cap_add"}, entry["service"]) + if "cap_add" in entry["controls"]: + self.assertTrue(entry.get("cap_add"), entry["service"]) + + def test_toon_summary(self): + rc, out, _, _ = render(make_root(), json_output=False) + self.assertEqual(rc, 0) + self.assertIn("compose:", out) + self.assertIn("network: grdm", out) + self.assertIn("ports[7]", out) + + def test_non_render_action_is_usage_error(self): + ctx = Context(root=make_root(), yes=True) + with redirect_stderr(io.StringIO()): + rc = compose.run(ctx, argparse.Namespace(compose_command=None)) + self.assertEqual(rc, exit_codes.USAGE) + + +if __name__ == "__main__": + unittest.main() diff --git a/installer/tests/test_docs.py b/installer/tests/test_docs.py new file mode 100644 index 0000000..e36c0ef --- /dev/null +++ b/installer/tests/test_docs.py @@ -0,0 +1,63 @@ +"""Unit tests for grdm-dev docs build | check (SPEC-02 §3, SPEC-06 §8).""" +from __future__ import annotations + +import io +import unittest +from argparse import Namespace +from contextlib import redirect_stderr, redirect_stdout +from pathlib import Path + +from grdm_dev import docs, exit_codes +from grdm_dev.context import Context, find_repo_root + +REPO = find_repo_root(Path(__file__).resolve().parent) + + +def run_cmd(ctx, runner=None, mkdocs=None, **kw): + args = Namespace(docs_action=None, all_warnings=False) + for k, v in kw.items(): + setattr(args, k, v) + out, err = io.StringIO(), io.StringIO() + with redirect_stdout(out), redirect_stderr(err): + code = docs.run(ctx, args, runner=runner, mkdocs=mkdocs) + return code, out.getvalue(), err.getvalue() + + +class DocsTests(unittest.TestCase): + def setUp(self): + self.ctx = Context(root=REPO, yes=True, stdin_is_tty=False) + + def test_check_wrapper_returns_0_on_repository(self): + code, out, _ = run_cmd(self.ctx, docs_action="check") + self.assertEqual(code, exit_codes.OK) + self.assertIn("PASSED", out) + + def test_build_runs_mkdocs_strict_with_fake_runner(self): + calls = [] + + def runner(argv): + calls.append(argv) + return 0, "" + + code, out, _ = run_cmd(self.ctx, runner=runner, mkdocs="/fake/mkdocs", docs_action="build") + self.assertEqual(code, exit_codes.OK) + self.assertEqual(calls[0][:3], ["/fake/mkdocs", "build", "--strict"]) + self.assertIn(str(REPO / "mkdocs.yml"), calls[0]) + + def test_build_failure_returns_1(self): + code, _, err = run_cmd(self.ctx, runner=lambda argv: (1, ""), mkdocs="/fake/mkdocs", docs_action="build") + self.assertEqual(code, 1) + self.assertIn("failed", err) + + def test_build_without_mkdocs_is_exit_2_with_install_hint(self): + code, _, err = run_cmd(self.ctx, runner=lambda argv: (127, ""), mkdocs="/nonexistent/mkdocs", docs_action="build") + self.assertEqual(code, exit_codes.USAGE) + self.assertIn(docs.INSTALL_HINT, err) + + def test_missing_action_is_usage(self): + code, _, _ = run_cmd(self.ctx) + self.assertEqual(code, exit_codes.USAGE) + + +if __name__ == "__main__": + unittest.main() diff --git a/installer/tests/test_doctor.py b/installer/tests/test_doctor.py new file mode 100644 index 0000000..41c5d58 --- /dev/null +++ b/installer/tests/test_doctor.py @@ -0,0 +1,103 @@ +"""Unit tests for grdm_dev.doctor: exit codes 0 / 10 / 11 and --strict (SPEC-02 §3, §6, §10).""" +import argparse +import io +import tempfile +import unittest +from contextlib import redirect_stderr, redirect_stdout +from pathlib import Path + +from grdm_dev import cli, doctor, exit_codes, host +from grdm_dev.context import Context + +from test_host import docker_runner, macos_probe, ubuntu_probe, GIB, DEBIAN_12 + + +def _args(strict=False): + return argparse.Namespace(command="doctor", strict=strict) + + +class DoctorRunTests(unittest.TestCase): + def setUp(self): + self.tmp = tempfile.TemporaryDirectory() + self.ctx = Context(root=Path(self.tmp.name), yes=True, stdin_is_tty=False) + + def tearDown(self): + self.tmp.cleanup() + + def _run(self, probe, runner, strict=False): + out, err = io.StringIO(), io.StringIO() + with redirect_stdout(out), redirect_stderr(err): + code = doctor.run(self.ctx, _args(strict), runner=runner, probe=probe) + return code, out.getvalue(), err.getvalue() + + def test_macos_arm64_docker29_exit_0(self): + code, out, err = self._run(macos_probe(), docker_runner()) + self.assertEqual(code, exit_codes.OK) + self.assertIn("doctor:", out) + self.assertIn("os_name: macos", out) + self.assertIn("docker_ok: true", out) + self.assertEqual(err, "") + self.assertTrue((self.ctx.reports_dir / "doctor_latest.json").exists()) + + def test_ubuntu_docker_missing_exit_11(self): + code, out, err = self._run(ubuntu_probe(), docker_runner(server=None)) + self.assertEqual(code, exit_codes.DOCKER_MISSING) + self.assertIn("exit 11", err) + self.assertIn(exit_codes.describe(11, "en"), err) + self.assertIn("docker_ok: false", out) + + def test_compose_missing_exit_11(self): + code, _, err = self._run(macos_probe(), docker_runner(compose=None)) + self.assertEqual(code, exit_codes.DOCKER_MISSING) + self.assertIn("compose plugin missing", err) + + def test_unsupported_os_exit_10(self): + probe = host.Probe(system="Windows", release="11", machine="AMD64", python_version=(3, 12, 0), + memory_bytes=32 * GIB, disk_free_bytes=100 * GIB) + code, _, err = self._run(probe, docker_runner()) + self.assertEqual(code, exit_codes.HOST_UNSUPPORTED) + self.assertIn("exit 10", err) + + def test_low_memory_exit_10(self): + code, _, err = self._run(macos_probe(memory_bytes=4 * GIB), docker_runner()) + self.assertEqual(code, exit_codes.HOST_UNSUPPORTED) + self.assertIn("8 GiB", err) + + def test_host_problem_wins_over_docker_problem(self): + # Both broken: the host code (10) is reported, not 11. + code, _, _ = self._run(macos_probe(memory_bytes=4 * GIB), docker_runner(server=None)) + self.assertEqual(code, exit_codes.HOST_UNSUPPORTED) + + def test_japanese_message_when_lang_ja(self): + self.ctx.lang = "ja" + code, _, err = self._run(ubuntu_probe(), docker_runner(server=None)) + self.assertEqual(code, exit_codes.DOCKER_MISSING) + self.assertIn(exit_codes.describe(11, "ja"), err) + + def test_best_effort_host_warns_but_exits_0(self): + code, out, _ = self._run(ubuntu_probe(os_release=DEBIAN_12), docker_runner()) + self.assertEqual(code, exit_codes.OK) + self.assertIn("best-effort", out) + + def test_strict_turns_warnings_into_exit_10(self): + code, out, err = self._run(ubuntu_probe(os_release=DEBIAN_12), docker_runner(), strict=True) + self.assertEqual(code, exit_codes.HOST_UNSUPPORTED) + self.assertIn("--strict", err) + self.assertIn("strict: true", out) + + def test_strict_with_no_warnings_exits_0(self): + code, _, _ = self._run(macos_probe(), docker_runner(), strict=True) + self.assertEqual(code, exit_codes.OK) + + +class DoctorCliTests(unittest.TestCase): + def test_doctor_is_registered_with_strict_flag(self): + parser = cli.build_parser() + args = parser.parse_args(["doctor", "--strict"]) + self.assertIs(args._module, doctor) + self.assertTrue(args.strict) + self.assertFalse(parser.parse_args(["doctor"]).strict) + + +if __name__ == "__main__": + unittest.main() diff --git a/installer/tests/test_health.py b/installer/tests/test_health.py new file mode 100644 index 0000000..dcdf481 --- /dev/null +++ b/installer/tests/test_health.py @@ -0,0 +1,134 @@ +import argparse +import io +import json +import tempfile +import unittest +from contextlib import redirect_stderr, redirect_stdout +from pathlib import Path + +from grdm_dev import exit_codes, health +from grdm_dev.context import Context + +COMPOSE = { + "services": { + "web": {"image": "grdm-dev/osf.io:abc", "ports": ["127.0.0.1:5000:5000"]}, + "api": {"image": "grdm-dev/osf.io:abc", "ports": ["127.0.0.1:8000:8000"]}, + "postgres": {"image": "postgres:9.6"}, + } +} + +PS_OK = "\n".join(json.dumps({"Service": s, "State": "running", "Health": "healthy"}) for s in ("web", "api", "postgres")) +PS_BAD = json.dumps([ + {"Service": "web", "State": "running", "Health": "healthy"}, + {"Service": "api", "State": "exited", "Health": ""}, + {"Service": "postgres", "State": "running", "Health": "unhealthy"}, +]) + +LSOF_BAD = """COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME +com.docke 4242 user 55u IPv4 0x1 0t0 TCP *:5000 (LISTEN) +com.docke 4242 user 56u IPv6 0x2 0t0 TCP [::]:8000 (LISTEN) +rapportd 512 user 4u IPv4 0x3 0t0 TCP *:49152 (LISTEN) +""" +LSOF_OK = """COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME +com.docke 4242 user 55u IPv4 0x1 0t0 TCP 127.0.0.1:5000 (LISTEN) +com.docke 4242 user 56u IPv4 0x2 0t0 TCP 127.0.0.1:8000 (LISTEN) +rapportd 512 user 4u IPv4 0x3 0t0 TCP *:49152 (LISTEN) +""" +SS_BAD = """State Recv-Q Send-Q Local Address:Port Peer Address:Port Process +LISTEN 0 4096 0.0.0.0:5000 0.0.0.0:* users:(("docker-proxy",pid=99,fd=4)) +LISTEN 0 4096 127.0.0.1:8000 0.0.0.0:* users:(("docker-proxy",pid=98,fd=4)) +LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=1,fd=3)) +""" + + +def make_runner(ps_output, sockets_output="", ps_rc=0): + calls = [] + + def runner(argv): + calls.append(argv) + if argv[:2] == ["docker", "compose"]: + return ps_rc, ps_output + if argv[0] in ("lsof", "ss"): + return 0, sockets_output + return 1, "" + + runner.calls = calls + return runner + + +def ok_prober(url): + return True, "HTTP 302" + + +class HealthTests(unittest.TestCase): + def setUp(self): + self.tmp = tempfile.TemporaryDirectory() + self.root = Path(self.tmp.name) + (self.root / "runtime").mkdir() + (self.root / "runtime" / "docker-compose.yml").write_text(json.dumps(COMPOSE)) + self.ctx = Context(root=self.root, stdin_is_tty=False) + self.out, self.err = io.StringIO(), io.StringIO() + + def tearDown(self): + self.tmp.cleanup() + + def run_cmd(self, network, runner, prober=ok_prober, system="Darwin"): + with redirect_stdout(self.out), redirect_stderr(self.err): + return health.run(self.ctx, argparse.Namespace(network=network), runner=runner, prober=prober, system=system) + + def test_all_healthy_is_0_and_probes_http_ports(self): + probed = [] + + def prober(url): + probed.append(url) + return True, "HTTP 200" + + self.assertEqual(self.run_cmd(False, make_runner(PS_OK), prober), exit_codes.OK) + self.assertEqual(sorted(probed), ["http://127.0.0.1:5000/", "http://127.0.0.1:8000/"]) + self.assertIn("services[3]", self.out.getvalue()) + + def test_unhealthy_service_is_40(self): + self.assertEqual(self.run_cmd(False, make_runner(PS_BAD)), exit_codes.HEALTH_FAILED) + self.assertIn("api", self.err.getvalue()) + self.assertIn("postgres", self.err.getvalue()) + + def test_http_probe_failure_is_40(self): + rc = self.run_cmd(False, make_runner(PS_OK), prober=lambda url: (False, "connection refused")) + self.assertEqual(rc, exit_codes.HEALTH_FAILED) + + def test_network_non_loopback_docker_port_is_40(self): + runner = make_runner(PS_OK, LSOF_BAD) + self.assertEqual(self.run_cmd(True, runner), exit_codes.HEALTH_FAILED) + self.assertIn(["lsof", "-nP", "-iTCP", "-sTCP:LISTEN"], runner.calls) + self.assertIn("5000", self.err.getvalue()) + self.assertIn("not loopback", self.err.getvalue()) + + def test_network_loopback_only_is_0_and_ignores_non_docker(self): + self.assertEqual(self.run_cmd(True, make_runner(PS_OK, LSOF_OK)), exit_codes.OK) + self.assertIn("loopback_only: true", self.out.getvalue()) + self.assertNotIn("rapportd", self.out.getvalue()) + + def test_network_linux_uses_ss(self): + runner = make_runner(PS_OK, SS_BAD) + self.assertEqual(self.run_cmd(True, runner, system="Linux"), exit_codes.HEALTH_FAILED) + self.assertIn(["ss", "-ltnp"], runner.calls) + _, bad, _ = health.check_network(runner, "Linux") + self.assertEqual([(s["address"], s["port"]) for s in bad], [("0.0.0.0", "5000")]) + + def test_missing_compose_is_usage_error(self): + (self.root / "runtime" / "docker-compose.yml").unlink() + self.assertEqual(self.run_cmd(False, make_runner(PS_OK)), exit_codes.USAGE) + + def test_parse_ps_accepts_array_and_lines(self): + self.assertEqual(set(health.parse_ps(PS_OK)), {"web", "api", "postgres"}) + self.assertEqual(health.parse_ps(PS_BAD)["api"]["State"], "exited") + self.assertEqual(health.parse_ps(""), {}) + + def test_host_port_from_env_fallback(self): + self.assertEqual(health.host_port("web", COMPOSE, {}), 5000) + self.assertEqual(health.host_port("mfr", {"services": {"mfr": {}}}, {"GRDM_PORT_MFR": "7778"}), 7778) + self.assertIsNone(health.host_port("mfr", {"services": {"mfr": {}}}, {})) + + +if __name__ == "__main__": + unittest.main() diff --git a/installer/tests/test_host.py b/installer/tests/test_host.py new file mode 100644 index 0000000..86c4911 --- /dev/null +++ b/installer/tests/test_host.py @@ -0,0 +1,184 @@ +"""Unit tests for grdm_dev.host (SPEC-02 §3, §8, §10). No Docker, no OS access: Probe + fake runner.""" +import unittest + +from grdm_dev import host + +GIB = host.GIB + +UBUNTU_2404 = 'NAME="Ubuntu"\nVERSION_ID="24.04"\nID=ubuntu\nID_LIKE=debian\nPRETTY_NAME="Ubuntu 24.04 LTS"\n' +DEBIAN_12 = 'NAME="Debian GNU/Linux"\nVERSION_ID="12"\nID=debian\n' + + +def macos_probe(**over): + base = dict(system="Darwin", release="24.1.0", machine="arm64", mac_ver="15.1", + python_version=(3, 12, 4), memory_bytes=32 * GIB, disk_free_bytes=200 * GIB, + docker_path="/usr/local/bin/docker") + base.update(over) + return host.Probe(**base) + + +def ubuntu_probe(**over): + base = dict(system="Linux", release="6.8.0-45-generic", machine="x86_64", os_release=UBUNTU_2404, + proc_version="Linux version 6.8.0-45-generic (buildd@lcy02) ...", + python_version=(3, 12, 3), memory_bytes=16 * GIB, disk_free_bytes=100 * GIB, + docker_path="/usr/bin/docker") + base.update(over) + return host.Probe(**base) + + +def docker_runner(server="29.0.1", compose="Docker Compose version v2.30.3", buildx="github.com/docker/buildx v0.18.0 abc"): + """A fake `docker` that answers the three doctor queries; None for a part means 'missing'.""" + calls = [] + + def run(argv): + calls.append(list(argv)) + if argv[:2] == ["docker", "version"]: + if server is None: + return 127, "docker: command not found" + if server == "down": + return 1, "Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?" + return 0, server + "\n" + if argv[:3] == ["docker", "compose", "version"]: + return (1, "docker: 'compose' is not a docker command.") if compose is None else (0, compose + "\n") + if argv[:3] == ["docker", "buildx", "version"]: + return (1, "docker: 'buildx' is not a docker command.") if buildx is None else (0, buildx + "\n") + return 1, f"unexpected: {argv}" + + run.calls = calls + return run + + +class ClassifyTests(unittest.TestCase): + def test_macos_arm64(self): + self.assertEqual(host.classify_os(macos_probe()), ("macos", "15.1")) + self.assertEqual(host.classify_arch("arm64"), "arm64") + + def test_ubuntu_from_os_release(self): + self.assertEqual(host.classify_os(ubuntu_probe()), ("ubuntu", "24.04")) + self.assertEqual(host.classify_arch("x86_64"), "amd64") + self.assertEqual(host.classify_arch("aarch64"), "arm64") + + def test_wsl2_from_proc_version(self): + p = ubuntu_probe(release="5.15.153.1-microsoft-standard-WSL2", + proc_version="Linux version 5.15.153.1-microsoft-standard-WSL2 (root@...) ...") + self.assertEqual(host.classify_os(p), ("wsl2", "24.04")) + + def test_wsl2_from_env(self): + p = ubuntu_probe(proc_version="Linux version 6.6.0 ...", env={"WSL_DISTRO_NAME": "Ubuntu-24.04"}) + self.assertEqual(host.classify_os(p)[0], "wsl2") + + def test_other_linux_and_unsupported(self): + self.assertEqual(host.classify_os(ubuntu_probe(os_release=DEBIAN_12))[0], "linux-other") + self.assertEqual(host.classify_os(host.Probe(system="Windows", release="11"))[0], "unsupported") + self.assertEqual(host.classify_arch("i686"), "other") + + def test_parse_version(self): + self.assertEqual(host.parse_version("Docker Compose version v2.30.3"), (2, 30, 3)) + self.assertEqual(host.parse_version("29.0.1\n"), (29, 0, 1)) + self.assertEqual(host.parse_version("no digits"), ()) + + +class DetectTests(unittest.TestCase): + def test_macos_arm64_docker29_supported(self): + run = docker_runner() + info = host.detect(runner=run, probe=macos_probe()) + self.assertTrue(info.supported, info.problems) + self.assertTrue(info.docker_ok, info.problems) + self.assertEqual(info.os_name, "macos") + self.assertEqual(info.arch, "arm64") + self.assertEqual(info.platform_string, "linux/arm64") + self.assertEqual(info.docker_version, "29.0.1") + self.assertEqual(info.compose_version, "2.30.3") + self.assertTrue(info.buildx_present) + self.assertTrue(info.docker_running) + self.assertEqual(info.python_version, "3.12.4") + self.assertEqual(info.warnings, []) + self.assertEqual(run.calls[0], ["docker", "version", "--format", "{{.Server.Version}}"]) + + def test_ubuntu_amd64_docker_missing(self): + info = host.detect(runner=docker_runner(server=None), probe=ubuntu_probe()) + self.assertTrue(info.supported) + self.assertFalse(info.docker_ok) + self.assertFalse(info.docker_running) + self.assertEqual(info.platform_string, "linux/amd64") + self.assertTrue(any("docker command not found" in p for p in info.problems), info.problems) + + def test_docker_daemon_not_running(self): + info = host.detect(runner=docker_runner(server="down"), probe=ubuntu_probe()) + self.assertTrue(info.supported) + self.assertFalse(info.docker_ok) + self.assertTrue(any("not running" in p for p in info.problems), info.problems) + + def test_docker_too_old(self): + info = host.detect(runner=docker_runner(server="24.0.7"), probe=ubuntu_probe()) + self.assertFalse(info.docker_ok) + self.assertTrue(any("older than 27" in p for p in info.problems), info.problems) + + def test_compose_plugin_missing(self): + info = host.detect(runner=docker_runner(compose=None), probe=macos_probe()) + self.assertTrue(info.supported) + self.assertFalse(info.docker_ok) + self.assertEqual(info.compose_version, "") + self.assertTrue(any("compose plugin missing" in p for p in info.problems), info.problems) + + def test_buildx_missing(self): + info = host.detect(runner=docker_runner(buildx=None), probe=macos_probe()) + self.assertFalse(info.docker_ok) + self.assertFalse(info.buildx_present) + + def test_unsupported_os(self): + probe = host.Probe(system="Windows", release="11", machine="AMD64", python_version=(3, 12, 0), + memory_bytes=32 * GIB, disk_free_bytes=100 * GIB) + info = host.detect(runner=docker_runner(), probe=probe) + self.assertFalse(info.supported) + self.assertEqual(info.os_name, "unsupported") + self.assertTrue(any("operating system not supported" in p for p in info.problems), info.problems) + + def test_low_memory_is_problem(self): + info = host.detect(runner=docker_runner(), probe=macos_probe(memory_bytes=4 * GIB)) + self.assertFalse(info.supported) + self.assertTrue(any("8 GiB" in p for p in info.problems), info.problems) + + def test_old_python_is_problem(self): + info = host.detect(runner=docker_runner(), probe=ubuntu_probe(python_version=(3, 9, 19))) + self.assertFalse(info.supported) + self.assertTrue(any("older than 3.11" in p for p in info.problems), info.problems) + + def test_best_effort_hosts_warn_and_continue(self): + intel_mac = host.detect(runner=docker_runner(), probe=macos_probe(machine="x86_64")) + self.assertTrue(intel_mac.supported) + self.assertTrue(any("best-effort" in w for w in intel_mac.warnings), intel_mac.warnings) + debian = host.detect(runner=docker_runner(), probe=ubuntu_probe(os_release=DEBIAN_12)) + self.assertTrue(debian.supported) + self.assertEqual(debian.os_name, "linux-other") + self.assertTrue(any("best-effort" in w for w in debian.warnings), debian.warnings) + + def test_memory_and_disk_warnings(self): + info = host.detect(runner=docker_runner(), probe=macos_probe(memory_bytes=12 * GIB, disk_free_bytes=10 * GIB)) + self.assertTrue(info.supported) + self.assertTrue(any("recommended 16 GiB" in w for w in info.warnings), info.warnings) + self.assertTrue(any("recommended 40 GiB" in w for w in info.warnings), info.warnings) + + def test_as_report_is_flat_and_toon_friendly(self): + from grdm_dev import toon + + info = host.detect(runner=docker_runner(), probe=macos_probe()) + data = host.as_report(info) + for key in ("os_name", "os_version", "arch", "memory_bytes", "disk_free_bytes", "python_version", + "docker_version", "compose_version", "buildx_present", "docker_running", "supported", + "docker_ok", "problems", "warnings", "platform_string", "memory_gib", "disk_free_gib", "official"): + self.assertIn(key, data) + self.assertTrue(data["official"]) + self.assertEqual(data["memory_gib"], 32.0) + text = toon.encode(data, name="doctor") + self.assertIn("platform_string: linux/arm64", text) + self.assertIn("supported: true", text) + + def test_default_runner_handles_missing_command(self): + rc, out = host.default_runner(["/nonexistent/grdm-dev-no-such-binary", "x"]) + self.assertEqual(rc, 127) + self.assertIn("not found", out) + + +if __name__ == "__main__": + unittest.main() diff --git a/installer/tests/test_install.py b/installer/tests/test_install.py new file mode 100644 index 0000000..a08d075 --- /dev/null +++ b/installer/tests/test_install.py @@ -0,0 +1,89 @@ +import argparse +import io +import tempfile +import unittest +from contextlib import redirect_stderr, redirect_stdout +from pathlib import Path + +from grdm_dev import exit_codes, install +from grdm_dev.context import Context + + +def fake_steps(codes: dict[str, int]): + """run_step that returns codes[argv[0]] (default 0) and records argv; -1 marks a missing module.""" + calls = [] + + def run_step(ctx, argv): + calls.append(argv) + return codes.get(argv[0], 0) + + run_step.calls = calls + return run_step + + +class InstallTests(unittest.TestCase): + def setUp(self): + self.tmp = tempfile.TemporaryDirectory() + self.root = Path(self.tmp.name) + self.ctx = Context(root=self.root, stdin_is_tty=False, yes=True) + self.out, self.err = io.StringIO(), io.StringIO() + + def tearDown(self): + self.tmp.cleanup() + + def run_cmd(self, run_step, **kw): + args = argparse.Namespace(platform=kw.get("platform"), no_open=kw.get("no_open", False)) + with redirect_stdout(self.out), redirect_stderr(self.err): + return install.run(self.ctx, args, run_step=run_step) + + def test_full_sequence_in_spec_order_and_prints_url(self): + step = fake_steps({}) + self.assertEqual(self.run_cmd(step, platform="linux/arm64", no_open=True), exit_codes.OK) + self.assertEqual( + step.calls, + [["doctor"], ["plan"], ["secrets", "init"], ["compose", "render"], ["build", "--platform", "linux/arm64"], + ["up", "--no-open"], ["health", "--network"], ["scan"], ["report"]], + ) + self.assertIn("http://127.0.0.1:5000/", self.out.getvalue()) + + def test_secrets_init_skipped_when_env_exists(self): + (self.root / "runtime").mkdir() + (self.root / "runtime" / ".env").write_text("GRDM_PROFILE=core\nGRDM_PORT_WEB=5001\n") + step = fake_steps({}) + self.assertEqual(self.run_cmd(step), exit_codes.OK) + self.assertNotIn(["secrets", "init"], step.calls) + self.assertIn("http://127.0.0.1:5001/", self.out.getvalue()) + + def test_stops_at_first_failure_with_its_code(self): + step = fake_steps({"plan": exit_codes.MANIFEST_INVALID, "build": exit_codes.BUILD_FAILED}) + self.assertEqual(self.run_cmd(step), exit_codes.MANIFEST_INVALID) + self.assertEqual(step.calls, [["doctor"], ["plan"]]) + self.assertIn("plan", self.err.getvalue()) + + def test_build_failure_returns_30_and_skips_up(self): + step = fake_steps({"build": exit_codes.BUILD_FAILED}) + self.assertEqual(self.run_cmd(step), exit_codes.BUILD_FAILED) + self.assertNotIn(["up"], step.calls) + self.assertNotIn("http://127.0.0.1", self.out.getvalue().split("install:")[0] if "ready" in self.out.getvalue() else "") + + def test_missing_scan_module_is_not_fatal(self): + step = fake_steps({"scan": -1, "report": -1}) + self.assertEqual(self.run_cmd(step), exit_codes.OK) + self.assertIn("not yet available", self.err.getvalue()) + self.assertIn(["report"], step.calls) + + def test_missing_required_module_is_usage_error(self): + step = fake_steps({"compose": -1}) + self.assertEqual(self.run_cmd(step), exit_codes.USAGE) + self.assertNotIn(["build"], step.calls) + + def test_default_run_step_reaches_real_modules(self): + # secrets init runs for real through the CLI parser (no Docker needed) + with redirect_stdout(self.out), redirect_stderr(self.err): + self.assertEqual(install.default_run_step(self.ctx, ["secrets", "init"]), exit_codes.OK) + self.assertEqual(install.default_run_step(self.ctx, ["no-such-command"]), -1) + self.assertTrue((self.root / "runtime" / ".env").exists()) + + +if __name__ == "__main__": + unittest.main() diff --git a/installer/tests/test_install_sh.py b/installer/tests/test_install_sh.py new file mode 100644 index 0000000..738c026 --- /dev/null +++ b/installer/tests/test_install_sh.py @@ -0,0 +1,117 @@ +"""Tests for installer/install.sh (SPEC-02 §2.1): syntax, --help, old python -> exit 10, CRLF -> exit 2. + +The script is copied into a temporary tree with a fake `python3` so no real .venv/ is created. +""" +import os +import shutil +import subprocess +import tempfile +import unittest +from pathlib import Path + +REPO = Path(__file__).resolve().parents[2] +SCRIPT = REPO / "installer" / "install.sh" +MESSAGES = REPO / "installer" / "grdm_dev" / "messages.tsv" + +FAKE_PY = """#!/bin/sh +# Fake python3 reporting {version}: understands the two -c snippets install.sh uses. +case "$*" in + *version_info*'>='*) exit {ok} ;; + *version_info*) echo '{version}' ;; + *) exit 99 ;; +esac +""" + + +def _which_bash(): + return shutil.which("bash") or "/bin/bash" + + +class InstallShTests(unittest.TestCase): + def setUp(self): + self.tmp = tempfile.TemporaryDirectory() + root = Path(self.tmp.name) + (root / "installer" / "grdm_dev").mkdir(parents=True) + (root / "bin").mkdir() + # Only these tools are on PATH, so the host's own python3 is never found by accident. + (root / "tools").mkdir() + for tool in ("grep", "awk", "sed", "uname", "dirname", "cat", "rm", "tr", "head", "bash"): + src = shutil.which(tool) + if src: + os.symlink(src, root / "tools" / tool) + self.script = root / "installer" / "install.sh" + shutil.copy(SCRIPT, self.script) + shutil.copy(MESSAGES, root / "installer" / "grdm_dev" / "messages.tsv") + self.root = root + self.bin = root / "bin" + + def tearDown(self): + self.tmp.cleanup() + + def _fake_python(self, version="3.9.19", ok=False): + for name in ("python3", "python3.13", "python3.12", "python3.11", "python"): + p = self.bin / name + p.write_text(FAKE_PY.format(version=version, ok=0 if ok else 1)) + p.chmod(0o755) + + def _run(self, *args, env_extra=None): + env = {"PATH": f"{self.bin}:{self.root / 'tools'}", "HOME": self.tmp.name, "LANG": "C"} + env.update(env_extra or {}) + return subprocess.run([_which_bash(), str(self.script), *args], env=env, capture_output=True, text=True, timeout=60) + + def test_bash_n_syntax(self): + cp = subprocess.run([_which_bash(), "-n", str(SCRIPT)], capture_output=True, text=True) + self.assertEqual(cp.returncode, 0, cp.stderr) + + def test_is_executable_and_has_no_crlf(self): + self.assertTrue(os.access(SCRIPT, os.X_OK), "install.sh must be executable") + self.assertNotIn(b"\r", SCRIPT.read_bytes()) + + def test_help_is_english_then_japanese(self): + cp = self._run("--help") + self.assertEqual(cp.returncode, 0, cp.stderr) + self.assertIn("Usage:", cp.stdout) + self.assertIn("使い方:", cp.stdout) + self.assertLess(cp.stdout.index("Usage:"), cp.stdout.index("使い方:")) + + def test_old_python_exits_10_with_hint(self): + self._fake_python("3.9.19", ok=False) + cp = self._run("--yes") + self.assertEqual(cp.returncode, 10, cp.stderr) + self.assertIn("exit 10", cp.stderr) + # Same wording as messages.tsv row 10, English and Japanese. + self.assertIn("host unsupported", cp.stderr) + self.assertIn("ホスト非対応", cp.stderr) + self.assertIn("3.9.19", cp.stderr) + # A per-OS hint is printed (brew / apt / python.org). + self.assertTrue(any(k in cp.stderr for k in ("brew install", "apt install", "python.org")), cp.stderr) + self.assertFalse((self.root / ".venv").exists()) + + def test_no_python_exits_10(self): + cp = self._run("--yes") # PATH has no python at all + self.assertEqual(cp.returncode, 10, cp.stderr) + self.assertIn("python3 not found", cp.stderr) + self.assertFalse((self.root / ".venv").exists()) + + def test_crlf_script_exits_2(self): + data = self.script.read_bytes().replace(b"\n", b"\r\n") + self.script.write_bytes(data) + self._fake_python("3.12.0", ok=True) + cp = self._run("--yes") + self.assertEqual(cp.returncode, 2, cp.stderr) + self.assertIn("CRLF", cp.stderr) + self.assertIn("usage error", cp.stderr) + self.assertFalse((self.root / ".venv").exists()) + + def test_messages_tsv_rows_are_used(self): + # The awk lookup reads messages.tsv: changing row 10 changes the output. + tsv = self.root / "installer" / "grdm_dev" / "messages.tsv" + tsv.write_text(tsv.read_text().replace("host unsupported", "HOST-UNSUPPORTED-MARKER")) + self._fake_python("3.8.0", ok=False) + cp = self._run() + self.assertEqual(cp.returncode, 10) + self.assertIn("HOST-UNSUPPORTED-MARKER", cp.stderr) + + +if __name__ == "__main__": + unittest.main() diff --git a/installer/tests/test_lifecycle.py b/installer/tests/test_lifecycle.py new file mode 100644 index 0000000..29cc27c --- /dev/null +++ b/installer/tests/test_lifecycle.py @@ -0,0 +1,120 @@ +import argparse +import io +import json +import tempfile +import unittest +from contextlib import redirect_stderr, redirect_stdout +from pathlib import Path + +from grdm_dev import exit_codes, lifecycle +from grdm_dev.context import Context + +COMPOSE = {"services": {"web": {"ports": ["127.0.0.1:5000:5000"]}, "postgres": {}}} +PS_OK = json.dumps([{"Service": "web", "State": "running", "Health": "healthy"}, + {"Service": "postgres", "State": "running", "Health": "healthy"}]) +PS_DOWN = json.dumps([{"Service": "web", "State": "created", "Health": ""}]) + + +def make_runner(ps_output, fail_cmd=None): + calls = [] + + def runner(argv): + calls.append(argv) + sub = argv[6] if argv[:2] == ["docker", "compose"] and len(argv) > 6 else argv[0] + if sub == fail_cmd: + return 1, "boom" + if sub == "ps": + return 0, ps_output + return 0, "" + + runner.calls = calls + return runner + + +class LifecycleTests(unittest.TestCase): + def setUp(self): + self.tmp = tempfile.TemporaryDirectory() + self.root = Path(self.tmp.name) + (self.root / "runtime").mkdir() + (self.root / "runtime" / "docker-compose.yml").write_text(json.dumps(COMPOSE)) + (self.root / "runtime" / ".env").write_text("GRDM_PROFILE=core\nGRDM_PORT_WEB=5001\n") + self.out, self.err = io.StringIO(), io.StringIO() + + def tearDown(self): + self.tmp.cleanup() + + def run_cmd(self, ctx, action, runner, **kw): + args = argparse.Namespace(lifecycle_action=action, no_open=kw.pop("no_open", False), timeout=kw.pop("timeout", 1.0)) + with redirect_stdout(self.out), redirect_stderr(self.err): + return lifecycle.run(ctx, args, runner=runner, prober=lambda url: (True, "HTTP 200"), sleep=lambda s: None, **kw) + + def test_up_starts_waits_and_opens_browser_on_tty(self): + ctx = Context(root=self.root, stdin_is_tty=True) + runner = make_runner(PS_OK) + opened = [] + self.assertEqual(self.run_cmd(ctx, "up", runner, opener=opened.append), exit_codes.OK) + up = [c for c in runner.calls if "up" in c][0] + self.assertEqual(up[:4], ["docker", "compose", "-f", str(self.root / "runtime" / "docker-compose.yml")]) + self.assertIn("-d", up) + self.assertEqual(opened, ["http://127.0.0.1:5001/"]) # port from runtime/.env + + def test_up_does_not_open_without_tty_or_with_no_open(self): + opened = [] + ctx = Context(root=self.root, stdin_is_tty=False) + self.assertEqual(self.run_cmd(ctx, "up", make_runner(PS_OK), opener=opened.append), exit_codes.OK) + ctx = Context(root=self.root, stdin_is_tty=True) + self.assertEqual(self.run_cmd(ctx, "up", make_runner(PS_OK), opener=opened.append, no_open=True), exit_codes.OK) + self.assertEqual(opened, []) + + def test_up_health_timeout_is_40(self): + ctx = Context(root=self.root, stdin_is_tty=False) + self.assertEqual(self.run_cmd(ctx, "up", make_runner(PS_DOWN), timeout=0.0), exit_codes.HEALTH_FAILED) + self.assertIn("postgres", self.err.getvalue()) + + def test_up_compose_failure_is_40(self): + ctx = Context(root=self.root, stdin_is_tty=False) + self.assertEqual(self.run_cmd(ctx, "up", make_runner(PS_OK, fail_cmd="up")), exit_codes.HEALTH_FAILED) + + def test_down_keeps_volumes(self): + ctx = Context(root=self.root, stdin_is_tty=False) + runner = make_runner(PS_OK) + self.assertEqual(self.run_cmd(ctx, "down", runner), exit_codes.OK) + down = [c for c in runner.calls if "down" in c][0] + self.assertNotIn("--volumes", down) + self.assertNotIn("-v", down) + + def test_reset_without_yes_and_no_tty_is_usage_error(self): + ctx = Context(root=self.root, stdin_is_tty=False, yes=False) + vol = self.root / "runtime" / "volumes" + vol.mkdir() + runner = make_runner(PS_OK) + self.assertEqual(self.run_cmd(ctx, "reset", runner), exit_codes.USAGE) + self.assertIn("--yes", self.err.getvalue()) + self.assertTrue(vol.exists()) + self.assertEqual(runner.calls, []) + + def test_reset_with_yes_downs_and_deletes_volumes(self): + ctx = Context(root=self.root, stdin_is_tty=False, yes=True) + vol = self.root / "runtime" / "volumes" + (vol / "postgres").mkdir(parents=True) + runner = make_runner(PS_OK) + self.assertEqual(self.run_cmd(ctx, "reset", runner), exit_codes.OK) + self.assertFalse(vol.exists()) + down = [c for c in runner.calls if "down" in c][0] + self.assertIn("--volumes", down) + + def test_running_services_and_restart_helpers(self): + ctx = Context(root=self.root, stdin_is_tty=False) + runner = make_runner(json.dumps([{"Service": "web", "State": "running"}, {"Service": "api", "State": "exited"}])) + self.assertEqual(lifecycle.running_services(ctx, runner=runner), ["web"]) + self.assertEqual(lifecycle.restart(ctx, ["web"], runner=runner), 0) + self.assertEqual(runner.calls[-1][-2:], ["restart", "web"]) + + def test_missing_compose_is_usage_error(self): + (self.root / "runtime" / "docker-compose.yml").unlink() + ctx = Context(root=self.root, stdin_is_tty=False) + self.assertEqual(self.run_cmd(ctx, "up", make_runner(PS_OK)), exit_codes.USAGE) + + +if __name__ == "__main__": + unittest.main() diff --git a/installer/tests/test_manifest.py b/installer/tests/test_manifest.py new file mode 100644 index 0000000..ca1913b --- /dev/null +++ b/installer/tests/test_manifest.py @@ -0,0 +1,137 @@ +import json +import shutil +import tempfile +import unittest +from pathlib import Path + +from grdm_dev import exit_codes, manifest +from grdm_dev.context import Context + +REPO_ROOT = Path(__file__).resolve().parents[2] + +# SPEC-02 §4 profiles table +MINIMUM = {"web", "api", "postgres", "elasticsearch", "rabbitmq", "fakecas"} +CORE = MINIMUM | {"admin", "worker", "wb", "wb_worker", "mfr", "unoconv", "ember_osf_web", "cas", "wiki", "mongo", + "sharejs", "elasticsearch6", "redis", "y_websocket"} +FULL_FAKECAS = CORE | {"rdmcp", "aipf_mcp_data_grdm", "oasys"} +FULL_SHIBBOLETH = (FULL_FAKECAS - {"fakecas"}) | {"shibboleth_sp", "test_idp"} + + +def temp_root_with_manifest(mutate=None) -> Path: + """Copy manifest/ into a temporary root; `mutate(data)` edits the JSON before writing.""" + root = Path(tempfile.mkdtemp(prefix="grdm-manifest-")) + (root / "manifest").mkdir() + data = json.loads((REPO_ROOT / "manifest" / "upstreams.json").read_text(encoding="utf-8")) + if mutate: + mutate(data) + (root / "manifest" / "upstreams.json").write_text(json.dumps(data, indent=2, sort_keys=True) + "\n", encoding="utf-8") + shutil.copy(REPO_ROOT / "manifest" / "upstreams.toon", root / "manifest" / "upstreams.toon") + return root + + +class ManifestLoadTests(unittest.TestCase): + def setUp(self): + self.ctx = Context(root=REPO_ROOT, yes=True) + + def test_real_manifest_loads_and_validates(self): + self.assertEqual(manifest.validate(self.ctx), []) + man = manifest.load(self.ctx) + self.assertEqual(man.schema_version, 1) + ids = {c.id for c in man.components} + self.assertIn("osf.io", ids) + self.assertIn("postgres", ids) + osf = man.component("osf.io") + self.assertTrue(osf.is_built) + self.assertEqual(len(osf.sha12), 12) + self.assertTrue(osf.local_image().startswith("grdm-dev/osf.io:")) + self.assertEqual(man.component("postgres").image_reference(), "postgres:9.6") + # dict compatibility for modules written against raw JSON + self.assertEqual(osf["id"], "osf.io") + self.assertEqual(osf.get("integration_repo"), "RDM-osf.io-dev2027") + + def test_load_accepts_path(self): + man = manifest.load(REPO_ROOT / "manifest" / "upstreams.json") + self.assertEqual(man.component_for_service("wb").id, "waterbutler") + + def test_build_sha_prefers_public_merged_upstream(self): + man = manifest.load(self.ctx) + wb = man.component("waterbutler") + public = [u for u in wb.upstreams if u.kind == "public" and u.status == "merged"][0] + self.assertEqual(wb.build_sha, public.sha) + oasys = man.component("OASys") # private only + self.assertEqual(oasys.build_sha, oasys.upstreams[0].sha) + + def test_invalid_manifest_reports_exit_20(self): + def bad(data): + data["components"][0]["upstreams"][0]["sha"] = "not-a-sha" + root = temp_root_with_manifest(bad) + ctx = Context(root=root, yes=True) + errors = manifest.validate(ctx) + self.assertTrue(errors) + self.assertTrue(any("MC-06" in e for e in errors), errors) + with self.assertRaises(manifest.ManifestError) as cm: + manifest.load_validated(ctx) + self.assertEqual(cm.exception.exit_code, exit_codes.MANIFEST_INVALID) + + def test_broken_json_is_manifest_error(self): + root = temp_root_with_manifest() + (root / "manifest" / "upstreams.json").write_text("{not json", encoding="utf-8") + ctx = Context(root=root, yes=True) + with self.assertRaises(manifest.ManifestError) as cm: + manifest.load(ctx) + self.assertEqual(cm.exception.exit_code, 20) + self.assertTrue(manifest.validate(ctx)) + + +class ServicesForProfileTests(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.man = manifest.load(Context(root=REPO_ROOT)) + + def names(self, profile, auth="fakecas"): + return {s.name for s in manifest.services_for_profile(self.man, profile, auth)} + + def test_templates_cover_every_manifest_service(self): + templates = manifest.load_templates() + for name in self.man.service_names: + self.assertIn(name, templates, f"missing template for {name}") + self.assertEqual(templates[name]["component"], self.man.component_for_service(name).id) + + def test_minimum(self): + self.assertEqual(self.names("minimum"), MINIMUM) + + def test_core(self): + self.assertEqual(self.names("core"), CORE) + + def test_full_default_keeps_fakecas(self): + self.assertEqual(self.names("full"), FULL_FAKECAS) + + def test_full_shibboleth_swaps_fakecas(self): + self.assertEqual(self.names("full", "shibboleth"), FULL_SHIBBOLETH) + + def test_service_fields(self): + services = {s.name: s for s in manifest.services_for_profile(self.man, "core")} + web = services["web"] + self.assertEqual(web.component, "osf.io") + self.assertEqual(web.role, "core") + self.assertEqual(web.build.repo, "RDM-osf.io-dev2027") + self.assertEqual(web.build.branch, "develop") + self.assertEqual(web.image, f"grdm-dev/osf.io:{web.build.sha12}") + self.assertEqual(services["admin"].profile, "core") + pg = services["postgres"] + self.assertIsNone(pg.build) + self.assertEqual(pg.image, "postgres:9.6") + self.assertEqual(pg.role, "infra") + + def test_image_tag_override_from_build_report(self): + services = {s.name: s for s in manifest.services_for_profile(self.man, "minimum", image_tags={"osf.io": "abcdef123456"})} + self.assertEqual(services["web"].image, "grdm-dev/osf.io:abcdef123456") + self.assertEqual(services["web"].build.sha12, "abcdef123456") + + def test_unknown_profile_rejected(self): + with self.assertRaises(ValueError): + manifest.services_for_profile(self.man, "huge") + + +if __name__ == "__main__": + unittest.main() diff --git a/installer/tests/test_manifest_cmd.py b/installer/tests/test_manifest_cmd.py new file mode 100644 index 0000000..7bbd8ba --- /dev/null +++ b/installer/tests/test_manifest_cmd.py @@ -0,0 +1,94 @@ +"""Unit tests for grdm-dev manifest check | toon (SPEC-01, SPEC-02 §3).""" +from __future__ import annotations + +import io +import json +import shutil +import tempfile +import unittest +from argparse import Namespace +from contextlib import redirect_stderr, redirect_stdout +from pathlib import Path + +from grdm_dev import exit_codes, manifest_cmd +from grdm_dev.context import Context, find_repo_root + +REPO = find_repo_root(Path(__file__).resolve().parent) + + +def run_cmd(ctx, **kw): + args = Namespace(manifest_action=None, manifest_only=False, policy_only=False, check=False, write=False) + for k, v in kw.items(): + setattr(args, k, v) + out, err = io.StringIO(), io.StringIO() + with redirect_stdout(out), redirect_stderr(err): + code = manifest_cmd.run(ctx, args) + return code, out.getvalue(), err.getvalue() + + +class ManifestCheckTests(unittest.TestCase): + def setUp(self): + self.ctx = Context(root=REPO, yes=True, stdin_is_tty=False) + + def test_check_passes_on_repository_manifest(self): + code, out, _ = run_cmd(self.ctx, manifest_action="check", manifest_only=True) + self.assertEqual(code, exit_codes.OK) + self.assertIn("PASSED", out) + + def test_map_exit_codes(self): + self.assertEqual(manifest_cmd.map_check_exit(0), exit_codes.OK) + self.assertEqual(manifest_cmd.map_check_exit(20), exit_codes.MANIFEST_INVALID) + self.assertEqual(manifest_cmd.map_check_exit(1), 1) + self.assertEqual(manifest_cmd.map_check_exit(2), exit_codes.USAGE) + + def test_invalid_manifest_exits_20(self): + with tempfile.TemporaryDirectory() as tmp: + root = Path(tmp) + (root / "manifest").mkdir() + (root / "tools").mkdir() + shutil.copy(REPO / "tools" / "manifest_check.py", root / "tools" / "manifest_check.py") + (root / "manifest" / "upstreams.json").write_text('{"schema_version": 2, "components": "nope"}') + ctx = Context(root=root, yes=True, stdin_is_tty=False) + code, _, err = run_cmd(ctx, manifest_action="check", manifest_only=True) + self.assertEqual(code, exit_codes.MANIFEST_INVALID) + self.assertIn("exit 20", err) + + def test_missing_action_is_usage(self): + code, _, _ = run_cmd(self.ctx) + self.assertEqual(code, exit_codes.USAGE) + + +class ManifestToonTests(unittest.TestCase): + def setUp(self): + self.ctx = Context(root=REPO, yes=True, stdin_is_tty=False) + + def test_toon_equals_committed_excerpt(self): + code, out, _ = run_cmd(self.ctx, manifest_action="toon") + self.assertEqual(code, exit_codes.OK) + self.assertEqual(out, (REPO / "manifest" / "upstreams.toon").read_text(encoding="utf-8")) + + def test_toon_check_detects_stale_excerpt(self): + with tempfile.TemporaryDirectory() as tmp: + root = Path(tmp) + (root / "manifest").mkdir() + (root / "tools").mkdir() + shutil.copy(REPO / "tools" / "manifest_check.py", root / "tools") + shutil.copy(REPO / "manifest" / "upstreams.json", root / "manifest") + (root / "manifest" / "upstreams.toon").write_text("schema_version: 1\n") + ctx = Context(root=root, yes=True, stdin_is_tty=False) + code, _, err = run_cmd(ctx, manifest_action="toon", check=True) + self.assertEqual(code, exit_codes.MANIFEST_INVALID) + code, out, _ = run_cmd(ctx, manifest_action="toon", write=True) + self.assertEqual(code, exit_codes.OK) + code, _, _ = run_cmd(ctx, manifest_action="toon", check=True) + self.assertEqual(code, exit_codes.OK) + + def test_excerpt_parses_back_to_the_projection(self): + mc = manifest_cmd.load_tool(REPO, "manifest_check") + data = json.loads((REPO / "manifest" / "upstreams.json").read_text(encoding="utf-8")) + parsed = mc.parse_toon(manifest_cmd.excerpt(data, mc)) + self.assertEqual(mc.compare_toon(data, parsed), []) + + +if __name__ == "__main__": + unittest.main() diff --git a/installer/tests/test_plan.py b/installer/tests/test_plan.py new file mode 100644 index 0000000..a7ef410 --- /dev/null +++ b/installer/tests/test_plan.py @@ -0,0 +1,109 @@ +import argparse +import io +import json +import shutil +import tempfile +import unittest +from contextlib import redirect_stderr, redirect_stdout +from pathlib import Path + +from grdm_dev import exit_codes, plan +from grdm_dev.context import Context + +REPO_ROOT = Path(__file__).resolve().parents[2] + + +def make_root(dotenv: str | None = None, mutate=None) -> Path: + root = Path(tempfile.mkdtemp(prefix="grdm-plan-")) + (root / "manifest").mkdir() + data = json.loads((REPO_ROOT / "manifest" / "upstreams.json").read_text(encoding="utf-8")) + if mutate: + mutate(data) + (root / "manifest" / "upstreams.json").write_text(json.dumps(data, indent=2, sort_keys=True) + "\n", encoding="utf-8") + shutil.copy(REPO_ROOT / "manifest" / "upstreams.toon", root / "manifest" / "upstreams.toon") + if dotenv is not None: + (root / "runtime").mkdir() + (root / "runtime" / ".env").write_text(dotenv, encoding="utf-8") + return root + + +def run_plan(root: Path, profile=None, auth="fakecas", json_output=True): + ctx = Context(root=root, yes=True, json_output=json_output, profile=profile) + args = argparse.Namespace(auth=auth) + out, err = io.StringIO(), io.StringIO() + with redirect_stdout(out), redirect_stderr(err): + rc = plan.run(ctx, args, platform_string="linux/arm64") + return rc, out.getvalue(), err.getvalue() + + +class PlanTests(unittest.TestCase): + def test_default_profile_is_core_and_report_lists_spec_ports(self): + rc, out, _ = run_plan(make_root()) + self.assertEqual(rc, exit_codes.OK) + data = json.loads(out) + self.assertEqual(data["profile"], "core") + self.assertEqual(data["platform"], "linux/arm64") + self.assertEqual(data["network"], "grdm") + ports = {r["service"]: r for r in data["ports"]} + self.assertEqual(set(ports), set(plan.DEFAULT_PORTS)) + for name, port in plan.DEFAULT_PORTS.items(): + self.assertEqual(ports[name]["host_port"], port) + self.assertEqual(ports[name]["url"], f"http://127.0.0.1:{port}") + self.assertEqual(ports[name]["source"], "default") + services = {r["service"]: r for r in data["services"]} + self.assertIn("y_websocket", services) + self.assertTrue(services["web"]["build_from"].startswith("RDM-osf.io-dev2027@")) + self.assertEqual(services["postgres"]["build_from"], "pinned image") + self.assertTrue(any(i.startswith("grdm-dev/waterbutler:") for i in data["images_to_build"])) + self.assertIn("postgres_data", data["volumes"]) + + def test_profile_from_dotenv_and_port_override(self): + root = make_root("GRDM_PROFILE=minimum\nGRDM_PORT_WEB=5050\nGRDM_PORT_API=abc\n") + rc, out, _ = run_plan(root) + data = json.loads(out) + self.assertEqual(rc, 0) + self.assertEqual(data["profile"], "minimum") + ports = {r["service"]: r for r in data["ports"]} + self.assertEqual(set(ports), {"web", "api", "fakecas"}) # minimum publishes only these + self.assertEqual(ports["web"]["host_port"], 5050) + self.assertEqual(ports["web"]["source"], "env") + self.assertEqual(ports["web"]["url"], "http://127.0.0.1:5050") + self.assertEqual(ports["api"]["host_port"], 8000) # invalid override ignored + + def test_flag_beats_dotenv(self): + root = make_root("GRDM_PROFILE=minimum\n") + rc, out, _ = run_plan(root, profile="full", auth="shibboleth") + data = json.loads(out) + names = {r["service"] for r in data["services"]} + self.assertEqual(data["profile"], "full") + self.assertIn("shibboleth_sp", names) + self.assertNotIn("fakecas", names) + self.assertNotIn("fakecas", {r["service"] for r in data["ports"]}) + + def test_invalid_manifest_exits_20(self): + def bad(data): + data["components"][0]["integration_repo"] = "RDM-osf.io" # MC-04: must end in -dev2027 + rc, out, err = run_plan(make_root(mutate=bad)) + self.assertEqual(rc, exit_codes.MANIFEST_INVALID) + self.assertIn("MC-04", err) + self.assertEqual(out, "") + + def test_toon_output_and_no_docker_files(self): + root = make_root() + rc, out, _ = run_plan(root, json_output=False) + self.assertEqual(rc, 0) + self.assertIn("plan:", out) + self.assertIn("ports[7]{service,host_port,container_port,url,source}:", out) + self.assertFalse((root / "runtime" / "docker-compose.yml").exists()) + self.assertTrue((root / "runtime" / "reports" / "plan_latest.json").exists()) + + def test_read_dotenv_and_resolve_profile(self): + root = make_root("# comment\nGRDM_PROFILE='full'\nX=\"1\"\n\nbad line\n") + env = plan.read_dotenv(root / "runtime" / ".env") + self.assertEqual(env, {"GRDM_PROFILE": "full", "X": "1"}) + self.assertEqual(plan.resolve_profile(Context(root=root), env), "full") + self.assertEqual(plan.resolve_profile(Context(root=root), {"GRDM_PROFILE": "nonsense"}), "core") + + +if __name__ == "__main__": + unittest.main() diff --git a/installer/tests/test_redteam.py b/installer/tests/test_redteam.py new file mode 100644 index 0000000..09a080d --- /dev/null +++ b/installer/tests/test_redteam.py @@ -0,0 +1,138 @@ +import argparse +import io +import json +import tempfile +import unittest +from contextlib import redirect_stderr, redirect_stdout +from pathlib import Path + +from grdm_dev import cli, exit_codes, redteam +from grdm_dev.context import Context + +REPO_MANIFEST = Path(__file__).resolve().parent.parent.parent / "manifest" / "redteam-targets.json" + + +def network_json(internal=True, containers=("grdm-redteam-web-1", "grdm-redteam-api-1")): + return json.dumps({ + "Name": "grdm-redteam", "Internal": internal, + "Containers": {f"id{i}": {"Name": n} for i, n in enumerate(containers)}, + }) + + +class FakeDocker: + def __init__(self, internal=True, containers=("grdm-redteam-web-1", "grdm-redteam-api-1"), + egress=False, network_missing=False, probe_rc=0): + self.internal, self.containers, self.egress = internal, containers, egress + self.network_missing, self.probe_rc = network_missing, probe_rc + self.calls = [] + + def __call__(self, argv): + self.calls.append(argv) + if argv[:3] == ["docker", "network", "inspect"]: + if self.network_missing: + return 1, "Error: No such network: grdm-redteam" + return 0, network_json(self.internal, self.containers) + if argv[:2] == ["docker", "run"]: + if self.probe_rc: + return self.probe_rc, "docker: Error response from daemon: No such image: alpine:latest" + return 0, (redteam.PROBE_MARKER if self.egress else "blocked") + "\n" + return 1, f"unexpected {argv}" + + +class RedteamPreflightTests(unittest.TestCase): + def setUp(self): + self.tmp = tempfile.TemporaryDirectory() + self.root = Path(self.tmp.name) + (self.root / "manifest").mkdir() + (self.root / "manifest" / "upstreams.json").write_text("{}") + (self.root / "manifest" / "redteam-targets.json").write_text(REPO_MANIFEST.read_text()) + (self.root / "docs" / "demo").mkdir(parents=True) + (self.root / "docs" / "demo" / "30_redteam_2026-11-05.md").write_text("# approval\n") + self.ctx = Context(root=self.root, yes=True) + + def tearDown(self): + self.tmp.cleanup() + + def preflight(self, runner, **kw): + args = argparse.Namespace(redteam_command="preflight", targets=None, approval=None, **kw) + err, out = io.StringIO(), io.StringIO() + with redirect_stderr(err), redirect_stdout(out): + rc = redteam.run(self.ctx, args, runner=runner) + return rc, err.getvalue(), out.getvalue() + + def test_repo_manifest_is_valid_and_lists_only_our_services(self): + data = redteam.load_targets(REPO_MANIFEST) + self.assertEqual(data["project"], "grdm-redteam") + self.assertEqual(data["network"], "grdm-redteam") + self.assertEqual(set(data["targets"]), {"web", "api", "admin", "wb", "mfr", "ember_osf_web", "cas"}) + + def test_all_checks_pass_is_exit_0(self): + docker = FakeDocker() + rc, err, out = self.preflight(docker) + self.assertEqual(rc, exit_codes.OK, err) + self.assertIn("result: pass", out) + self.assertIn("checks[4]{check,ok,detail}:", out) + run = [a for a in docker.calls if a[:2] == ["docker", "run"]][0] + self.assertIn("--pull", run) + self.assertIn("never", run) + self.assertEqual(run[run.index("--network") + 1], "grdm-redteam") + self.assertIn("example.invalid", run[-1]) + # preflight never runs anything but inspect + the probe + self.assertEqual(sorted(a[1] for a in docker.calls), ["network", "run"]) + + def test_network_not_internal_is_53(self): + rc, err, _ = self.preflight(FakeDocker(internal=False)) + self.assertEqual(rc, exit_codes.REDTEAM_PREFLIGHT_FAILED) + self.assertIn("network_internal", err) + + def test_egress_reachable_is_53(self): + rc, err, _ = self.preflight(FakeDocker(egress=True)) + self.assertEqual(rc, exit_codes.REDTEAM_PREFLIGHT_FAILED) + self.assertIn("egress_blocked", err) + + def test_probe_container_not_runnable_is_53_not_a_pass(self): + rc, err, _ = self.preflight(FakeDocker(probe_rc=125)) + self.assertEqual(rc, exit_codes.REDTEAM_PREFLIGHT_FAILED) + self.assertIn("did not run", err) + + def test_unknown_container_on_network_is_53(self): + rc, err, _ = self.preflight(FakeDocker(containers=("grdm-redteam-web-1", "grdm-core-postgres-1"))) + self.assertEqual(rc, exit_codes.REDTEAM_PREFLIGHT_FAILED) + self.assertIn("grdm-core-postgres-1", err) + + def test_missing_network_is_53(self): + rc, err, _ = self.preflight(FakeDocker(network_missing=True)) + self.assertEqual(rc, exit_codes.REDTEAM_PREFLIGHT_FAILED) + + def test_missing_approval_record_is_53(self): + (self.root / "docs" / "demo" / "30_redteam_2026-11-05.md").unlink() + rc, err, _ = self.preflight(FakeDocker()) + self.assertEqual(rc, exit_codes.REDTEAM_PREFLIGHT_FAILED) + self.assertIn("approval_record", err) + + def test_invalid_manifest_is_20(self): + (self.root / "manifest" / "redteam-targets.json").write_text('{"project": "x"}') + rc, err, _ = self.preflight(FakeDocker()) + self.assertEqual(rc, exit_codes.MANIFEST_INVALID) + (self.root / "manifest" / "redteam-targets.json").unlink() + rc, err, _ = self.preflight(FakeDocker()) + self.assertEqual(rc, exit_codes.MANIFEST_INVALID) + + def test_service_of_handles_compose_naming(self): + self.assertEqual(redteam.service_of("grdm-redteam-ember_osf_web-1", "grdm-redteam"), "ember_osf_web") + self.assertEqual(redteam.service_of("grdm-redteam_web_1", "grdm-redteam"), "web") + self.assertEqual(redteam.service_of("stray", "grdm-redteam"), "stray") + + def test_cli_registers_redteam_preflight_and_rejects_bare_redteam(self): + parser = cli.build_parser() + args = parser.parse_args(["redteam", "preflight"]) + self.assertIs(args._module, redteam) + self.assertEqual(args.redteam_command, "preflight") + err = io.StringIO() + with redirect_stderr(err), redirect_stdout(io.StringIO()): + rc = redteam.run(self.ctx, parser.parse_args(["redteam"]), runner=FakeDocker()) + self.assertEqual(rc, exit_codes.USAGE) + + +if __name__ == "__main__": + unittest.main() diff --git a/installer/tests/test_report_cmd.py b/installer/tests/test_report_cmd.py new file mode 100644 index 0000000..cc52b95 --- /dev/null +++ b/installer/tests/test_report_cmd.py @@ -0,0 +1,71 @@ +"""Unit tests for grdm-dev report (SPEC-02 §3): bundling of *_latest.json reports.""" +from __future__ import annotations + +import io +import json +import tempfile +import unittest +from argparse import Namespace +from contextlib import redirect_stdout +from pathlib import Path + +from grdm_dev import exit_codes, report_cmd +from grdm_dev.context import Context + + +class ReportCmdTests(unittest.TestCase): + def setUp(self): + self.tmp = tempfile.TemporaryDirectory() + self.root = Path(self.tmp.name) + (self.root / "runtime" / "reports").mkdir(parents=True) + self.ctx = Context(root=self.root, yes=True, json_output=True, stdin_is_tty=False) + + def tearDown(self): + self.tmp.cleanup() + + def _write_latest(self, name, data): + (self.root / "runtime" / "reports" / f"{name}_latest.json").write_text(json.dumps(data)) + + def run_report(self): + out = io.StringIO() + with redirect_stdout(out): + code = report_cmd.run(self.ctx, Namespace()) + return code, json.loads(out.getvalue()) + + def test_bundles_existing_reports_and_writes_files(self): + self._write_latest("doctor", {"os": "macos", "exit_code": 0}) + self._write_latest("scan", {"gate": "pass", "exit_code": 0, "findings_total": 3}) + code, data = self.run_report() + self.assertEqual(code, exit_codes.OK) + self.assertEqual(data["overall"], "partial") + self.assertEqual(data["present"], ["doctor", "scan"]) + self.assertEqual(data["missing"], ["plan", "health", "accept"]) + self.assertEqual(data["bundle"]["scan"]["findings_total"], 3) + rows = {r["name"]: r for r in data["reports"]} + self.assertTrue(rows["doctor"]["present"] and rows["doctor"]["timestamp"]) + self.assertEqual(rows["doctor"]["status"], "ok") + self.assertFalse(rows["health"]["present"]) + files = sorted(p.name for p in (self.root / "runtime" / "reports").glob("report_*")) + self.assertTrue(any(f.endswith(".json") and f != "report_latest.json" for f in files)) + self.assertTrue(any(f.endswith(".toon") for f in files)) + self.assertIn("report_latest.json", files) + + def test_failed_report_marks_overall_fail_and_secrets_are_masked(self): + (self.root / "runtime" / ".env").write_text("DB_PASSWORD=verysecretpw123\n") + self._write_latest("health", {"exit_code": 40, "detail": "db url postgres://u:verysecretpw123@db"}) + code, data = self.run_report() + self.assertEqual(code, exit_codes.OK) + self.assertEqual(data["overall"], "fail") + self.assertEqual(data["failed"], ["health"]) + self.assertNotIn("verysecretpw123", json.dumps(data)) + self.assertNotIn("verysecretpw123", (self.root / "runtime" / "reports" / "report_latest.json").read_text()) + + def test_empty_reports_dir(self): + code, data = self.run_report() + self.assertEqual(code, exit_codes.OK) + self.assertEqual(data["overall"], "empty") + self.assertEqual(len(data["reports"]), 5) + + +if __name__ == "__main__": + unittest.main() diff --git a/installer/tests/test_scan.py b/installer/tests/test_scan.py new file mode 100644 index 0000000..568a19e --- /dev/null +++ b/installer/tests/test_scan.py @@ -0,0 +1,309 @@ +"""Unit tests for grdm-dev scan (SPEC-03): staged gate, allow-list, scanner availability, --dynamic. + +All scanners are faked through the injectable runner / which; Docker is never required. +""" +from __future__ import annotations + +import datetime as _dt +import io +import json +import tempfile +import unittest +from argparse import Namespace +from contextlib import redirect_stderr, redirect_stdout +from pathlib import Path + +from grdm_dev import exit_codes, scan +from grdm_dev.context import Context + +TODAY = _dt.date(2026, 11, 5) + +TRIVY_HIGH = json.dumps({"Results": [{"Target": "grdm-dev/web:dev", "Vulnerabilities": [ + {"VulnerabilityID": "CVE-2021-3177", "Severity": "HIGH", "PkgName": "python", "InstalledVersion": "3.6.15", + "Title": "ctypes buffer overflow"}, + {"VulnerabilityID": "CVE-2020-0001", "Severity": "LOW", "PkgName": "zlib", "InstalledVersion": "1.2", "Title": "low"}, +]}]}) +TRIVY_CRITICAL = json.dumps({"Results": [{"Target": ".", "Vulnerabilities": [ + {"VulnerabilityID": "CVE-2020-8265", "Severity": "CRITICAL", "PkgName": "node", "InstalledVersion": "12", + "Title": "use after free"}]}]}) +TRIVY_CLEAN = json.dumps({"Results": []}) +SEMGREP_EMPTY = json.dumps({"results": [], "errors": []}) +SEMGREP_WARNING = json.dumps({"results": [{"check_id": "python.lang.security.audit.x", "path": "a.py", + "start": {"line": 3}, "extra": {"severity": "WARNING", "message": "m"}}]}) +GITLEAKS_EMPTY = "[]" + + +def fake_runner(trivy_json=TRIVY_CLEAN, semgrep_json=SEMGREP_EMPTY, gitleaks_json=GITLEAKS_EMPTY, + images="", compose_ps=None, zap_json=None, calls=None): + """Return a runner that answers canned output per tool and records argv in `calls`.""" + def _run(argv): + if calls is not None: + calls.append(list(argv)) + tool = argv[0] + if tool == "git": + return 0, "abc1234\n" + if tool == "trivy": + if "--version" in argv: + return 0, "Version: 0.68.0\n" + if "cyclonedx" in argv: + Path(argv[argv.index("--output") + 1]).write_text('{"bomFormat":"CycloneDX"}') + return 0, "" + return 0, trivy_json + if tool == "semgrep": + return (0, "1.140.0\n") if "--version" in argv else (0, semgrep_json) + if tool == "gitleaks": + if argv[1] == "version": + return 0, "8.21.2\n" + Path(argv[argv.index("--report-path") + 1]).write_text(gitleaks_json) + return 0, "" + if tool == "docker": + if argv[1:3] == ["image", "ls"]: + return 0, images + if argv[1:3] == ["compose", "ps"] if len(argv) > 2 else False: + return (0, compose_ps) if compose_ps is not None else (1, "") + if argv[1] == "compose": + return (0, compose_ps) if compose_ps is not None else (1, "") + if argv[1] == "run": + Path(argv[argv.index("-v") + 1].split(":")[0]) .joinpath(argv[argv.index("-J") + 1]).write_text(zap_json or '{"site":[]}') + return 0, "" + return 127, "" + return _run + + +def all_tools(name): + return True + + +class ScanTestBase(unittest.TestCase): + def setUp(self): + self.tmp = tempfile.TemporaryDirectory() + self.root = Path(self.tmp.name) + (self.root / "manifest").mkdir() + (self.root / "manifest" / "upstreams.json").write_text("{}") + self.ctx = Context(root=self.root, yes=True, json_output=True, stdin_is_tty=False) + + def tearDown(self): + self.tmp.cleanup() + + def write_manifest(self, name, data): + (self.root / "manifest" / name).write_text(json.dumps(data), encoding="utf-8") + + def write_compose(self, services=None, networks=None): + services = services if services is not None else { + "web": {"image": "grdm-dev/web", "user": "1000:1000", "cap_drop": ["ALL"], "ports": ["127.0.0.1:5000:5000"]}} + doc = {"services": services, "networks": networks or {"grdm": {"internal": True}}} + (self.root / "runtime").mkdir(exist_ok=True) + (self.root / "runtime" / "docker-compose.yml").write_text(json.dumps(doc)) + + def run_scan(self, runner, which=all_tools, **flags): + args = Namespace(baseline=False, secrets=False, dynamic=False, milestone=None) + for k, v in flags.items(): + setattr(args, k, v) + out, err = io.StringIO(), io.StringIO() + with redirect_stdout(out), redirect_stderr(err): + code = scan.run(self.ctx, args, runner=runner, which=which, today=TODAY, prober=lambda url: (True, "200")) + return code, json.loads(out.getvalue()), err.getvalue() + + def latest(self): + return json.loads((self.root / "runtime" / "reports" / "scan_latest.json").read_text()) + + +class StagedGateTests(ScanTestBase): + def test_m1_report_only_passes_with_high_findings_and_creates_manifest_files(self): + self.write_compose() + code, data, _ = self.run_scan(fake_runner(trivy_json=TRIVY_HIGH, images="grdm-dev/web:dev\n")) + self.assertEqual(code, exit_codes.OK) + self.assertEqual(data["milestone"], "M1") + self.assertEqual(data["gate"], "pass") + self.assertEqual(data["findings_by_severity"]["high"], 1) + self.assertEqual(data["baseline"], "pass") + for name in ("allowlist.json", "allowlist.baseline.json", "milestone.json"): + self.assertTrue((self.root / "manifest" / name).exists(), name) + allow = json.loads((self.root / "manifest" / "allowlist.json").read_text()) + self.assertEqual(allow["entries"], []) + self.assertEqual(allow["fields"], list(scan.ALLOWLIST_FIELDS)) + self.assertEqual(json.loads((self.root / "manifest" / "allowlist.baseline.json").read_text())["counts"], {"M1": 0}) + reports = list((self.root / "runtime" / "reports").glob("scan_*")) + self.assertTrue(any(p.suffix == ".json" and p.stem != "scan_latest" for p in reports)) + self.assertTrue(any(p.suffix == ".toon" for p in reports)) + + def test_m4_high_finding_fails_50(self): + self.write_manifest("milestone.json", {"milestone": "M4", "gate": "fail-high"}) + code, data, err = self.run_scan(fake_runner(trivy_json=TRIVY_HIGH, images="grdm-dev/web:dev\n")) + self.assertEqual(code, exit_codes.SCAN_GATE_FAILED) + self.assertEqual(data["gate"], "fail") + self.assertEqual(data["over_threshold"], 1) + self.assertIn("exit 50", err) + + def test_m4_passes_when_high_is_allowlisted(self): + self.write_manifest("milestone.json", {"milestone": "M4", "gate": "fail-high"}) + self.write_manifest("allowlist.json", {"entries": [{ + "cve": "CVE-2021-3177", "component": "python@3.6.15", "reason": "EOL interpreter, removed in M4 port", + "owner": "AID", "expires": "2027-03-31", "added_at": "2026-11-05"}]}) + self.write_manifest("allowlist.baseline.json", {"counts": {"M1": 1}}) + code, data, _ = self.run_scan(fake_runner(trivy_json=TRIVY_HIGH, images="grdm-dev/web:dev\n")) + self.assertEqual(code, exit_codes.OK) + self.assertEqual(data["allowlisted"], 1) + self.assertEqual(data["findings_by_severity"]["high"], 0) + + def test_m5_critical_fails_50_via_milestone_flag(self): + code, data, _ = self.run_scan(fake_runner(trivy_json=TRIVY_CRITICAL), milestone="M5") + self.assertEqual(code, exit_codes.SCAN_GATE_FAILED) + self.assertEqual(data["milestone"], "M5") + self.assertEqual(data["findings_by_severity"]["critical"], 1) + + def test_m2_count_grew_fails_50(self): + self.write_manifest("milestone.json", {"milestone": "M2"}) + self.write_manifest("allowlist.json", {"entries": [{ + "cve": "CVE-2021-3177", "component": "python", "reason": "r", "owner": "AID", + "expires": "2027-03-31", "added_at": "2026-11-05"}]}) + self.write_manifest("allowlist.baseline.json", {"counts": {"M1": 0}}) + code, data, _ = self.run_scan(fake_runner()) + self.assertEqual(code, exit_codes.SCAN_GATE_FAILED) + self.assertTrue(any("grew" in r for r in data["gate_reasons"])) + + def test_baseline_violation_fails_even_at_m1(self): + self.write_compose({"web": {"ports": ["0.0.0.0:5000:5000"], "privileged": True}}) + code, data, _ = self.run_scan(fake_runner(), baseline=True) + self.assertEqual(code, exit_codes.SCAN_GATE_FAILED) + ids = {f["id"] for f in data["findings"]} + self.assertEqual(ids, {"BASE-PUBLISH", "BASE-USER", "BASE-CAPDROP", "BASE-PRIVILEGED"}) + self.assertEqual(data["parts"], ["baseline"]) + self.assertEqual(data["tools"], []) + + def test_forbidden_alias_is_a_baseline_finding(self): + (self.root / "runtime").mkdir() + (self.root / "runtime" / "docker-compose.yml").write_text("services:\n web:\n extra_hosts:\n - 'x:192.168.168.167'\n") + code, data, _ = self.run_scan(fake_runner(), baseline=True) + self.assertEqual(code, exit_codes.SCAN_GATE_FAILED) + self.assertIn("BASE-ALIAS", {f["id"] for f in data["findings"]}) + + +class AllowlistTests(ScanTestBase): + def test_expired_entry_becomes_finding_and_stops_suppressing(self): + self.write_manifest("allowlist.json", {"entries": [{ + "cve": "CVE-2021-3177", "component": "python", "reason": "r", "owner": "AID", + "expires": "2026-01-31", "added_at": "2025-11-05"}]}) + code, data, _ = self.run_scan(fake_runner(trivy_json=TRIVY_HIGH, images="grdm-dev/web:dev\n")) + self.assertEqual(code, exit_codes.OK) # M1 is report-only + expired = [f for f in data["findings"] if f["id"] == "ALLOWLIST-EXPIRED"] + self.assertEqual(len(expired), 1) + self.assertEqual(expired[0]["tool"], "allowlist") + self.assertEqual(data["allowlisted"], 0) + self.assertEqual(data["findings_by_severity"]["high"], 1) + + def test_malformed_entry_fails_gate_at_m1(self): + self.write_manifest("allowlist.json", {"entries": [{"cve": "CVE-1", "component": "x", "reason": "r"}]}) + code, data, _ = self.run_scan(fake_runner()) + self.assertEqual(code, exit_codes.SCAN_GATE_FAILED) + f = [f for f in data["findings"] if f["id"] == "ALLOWLIST-MALFORMED"][0] + self.assertIn("owner", f["title"]) + self.assertIn("expires", f["title"]) + + def test_validate_allowlist_rejects_team_owner(self): + active, findings = scan.validate_allowlist([{ + "cve": "CVE-1", "component": "x", "reason": "r", "owner": "team", + "expires": "2027-01-01", "added_at": "2026-01-01"}], TODAY) + self.assertEqual(active, []) + self.assertEqual(findings[0]["id"], "ALLOWLIST-MALFORMED") + + +class ScannerAvailabilityTests(ScanTestBase): + def test_missing_trivy_exits_51_and_names_it(self): + code, data, err = self.run_scan(fake_runner(), which=lambda n: n != "trivy") + self.assertEqual(code, exit_codes.SCANNER_UNAVAILABLE) + self.assertIn("trivy", err) + self.assertEqual(data["exit_code"], 51) + self.assertEqual(data["tools"][0]["name"], "trivy") + self.assertEqual(data["tools"][0]["version"], "missing") + + def test_missing_gitleaks_with_secrets_flag_exits_51(self): + code, _, err = self.run_scan(fake_runner(), which=lambda n: n != "gitleaks", secrets=True) + self.assertEqual(code, exit_codes.SCANNER_UNAVAILABLE) + self.assertIn("gitleaks", err) + + def test_trivy_fs_used_when_no_images(self): + calls = [] + code, data, _ = self.run_scan(fake_runner(calls=calls)) + self.assertEqual(code, exit_codes.OK) + self.assertTrue(any(c[:2] == ["trivy", "fs"] for c in calls)) + self.assertTrue(any("sbom_repo_" in str(c) for c in calls)) + self.assertTrue(any("fs scan" in n for n in data["notes"])) + + def test_semgrep_warning_maps_to_medium(self): + code, data, _ = self.run_scan(fake_runner(semgrep_json=SEMGREP_WARNING)) + self.assertEqual(code, exit_codes.OK) + self.assertEqual(data["findings_by_severity"]["medium"], 1) + + +class DynamicTests(ScanTestBase): + def test_dynamic_with_unhealthy_services_exits_52(self): + self.write_compose() + ps = json.dumps([{"Service": "web", "State": "running", "Health": "unhealthy"}]) + code, data, err = self.run_scan(fake_runner(compose_ps=ps), dynamic=True) + self.assertEqual(code, exit_codes.SERVICES_UNHEALTHY) + self.assertIn("exit 52", err) + self.assertEqual(data["tools"][0]["result"], "services-unhealthy") + self.assertTrue((self.root / "runtime" / "reports" / "scan_latest.json").exists()) + + def test_full_scan_skips_dynamic_when_unhealthy(self): + self.write_compose() + code, data, _ = self.run_scan(fake_runner(compose_ps=None)) + self.assertEqual(code, exit_codes.OK) + self.assertTrue(any("dynamic (ZAP) part skipped" in n for n in data["notes"])) + + def test_dynamic_targets_service_names_on_compose_network(self): + self.write_compose({ + "web": {"user": "1", "cap_drop": ["ALL"], "ports": ["127.0.0.1:5000:5000"]}, + "admin": {"user": "1", "cap_drop": ["ALL"]}, + "postgres": {"user": "1", "cap_drop": ["ALL"]}, + }, networks={"grdm": {"name": "grdm", "internal": True}}) + ps = json.dumps([{"Service": s, "State": "running", "Health": "healthy"} for s in ("web", "admin", "postgres")]) + zap = json.dumps({"site": [{"alerts": [{"pluginid": "10038", "riskcode": "2", "alert": "CSP header missing", + "instances": [{"uri": "http://web:5000/"}]}]}]}) + calls = [] + code, data, _ = self.run_scan(fake_runner(compose_ps=ps, zap_json=zap, calls=calls), dynamic=True) + self.assertEqual(code, exit_codes.OK) + runs = [c for c in calls if c[:2] == ["docker", "run"]] + targets = sorted(c[c.index("-t") + 1] for c in runs) + self.assertEqual(targets, ["http://admin:8001", "http://web:5000"]) + for c in runs: + self.assertEqual(c[c.index("--network") + 1], "grdm") + self.assertIn(scan.ZAP_IMAGE, c) + self.assertNotIn("127.0.0.1", " ".join(c[c.index(scan.ZAP_IMAGE):])) + self.assertEqual(data["findings_by_severity"]["medium"], 2) + self.assertEqual(data["findings"][0]["tool"], "zap") + + +class SecretsHygieneTests(ScanTestBase): + def test_gitleaks_values_never_reach_the_report_and_env_values_are_masked(self): + (self.root / "runtime").mkdir() + (self.root / "runtime" / ".env").write_text("POSTGRES_PASSWORD=sup3rs3cretvalue\nSHORT=ab\n") + leak = json.dumps([{"RuleID": "generic-api-key", "File": "a.env", "StartLine": 2, "Secret": "sup3rs3cretvalue", + "Match": "KEY=sup3rs3cretvalue", "Description": "found sup3rs3cretvalue"}]) + code, data, _ = self.run_scan(fake_runner(gitleaks_json=leak), secrets=True) + self.assertEqual(code, exit_codes.SCAN_GATE_FAILED) # a secret in the repo is a baseline failure (§3.5) + text = json.dumps(data) + (self.root / "runtime" / "reports" / "scan_latest.json").read_text() + text += (self.root / "runtime" / "reports").joinpath( + next(p.name for p in (self.root / "runtime" / "reports").glob("gitleaks_*.json"))).read_text() + self.assertNotIn("sup3rs3cretvalue", text) + self.assertEqual(data["findings"][0]["tool"], "gitleaks") + self.assertEqual(data["findings"][0]["location"], "a.env:2") + + +class NormalizerTests(unittest.TestCase): + def test_trivy_unknown_severity_maps_low_and_shape(self): + f = scan.normalize_trivy({"Results": [{"Target": "t", "Vulnerabilities": [ + {"VulnerabilityID": "CVE-X", "Severity": "UNKNOWN", "PkgName": "p", "InstalledVersion": "1"}]}]}, "t")[0] + self.assertEqual(set(f), {"tool", "id", "severity", "component", "location", "title"}) + self.assertEqual(f["severity"], "LOW") + self.assertEqual(f["component"], "p@1") + + def test_zap_risk_mapping(self): + f = scan.normalize_zap({"site": [{"alerts": [{"pluginid": "1", "riskcode": "3", "name": "x"}]}]}, "http://web:5000")[0] + self.assertEqual(f["severity"], "HIGH") + self.assertEqual(f["location"], "http://web:5000") + + +if __name__ == "__main__": + unittest.main() diff --git a/installer/tests/test_secrets.py b/installer/tests/test_secrets.py new file mode 100644 index 0000000..1f5c9c8 --- /dev/null +++ b/installer/tests/test_secrets.py @@ -0,0 +1,117 @@ +import argparse +import io +import stat +import tempfile +import unittest +from contextlib import redirect_stderr, redirect_stdout +from pathlib import Path + +from grdm_dev import exit_codes, secrets +from grdm_dev.context import Context + + +def make_ctx(root: Path, **kw) -> Context: + return Context(root=root, stdin_is_tty=False, **kw) + + +def ns(**kw): + return argparse.Namespace(**kw) + + +class SecretsInitTests(unittest.TestCase): + def setUp(self): + self.tmp = tempfile.TemporaryDirectory() + self.root = Path(self.tmp.name) + self.out, self.err = io.StringIO(), io.StringIO() + + def tearDown(self): + self.tmp.cleanup() + + def run_cmd(self, ctx, args, **kw): + with redirect_stdout(self.out), redirect_stderr(self.err): + return secrets.run(ctx, args, **kw) + + def test_init_writes_0600_random_values_without_defaults(self): + ctx = make_ctx(self.root, profile="minimum") + self.assertEqual(self.run_cmd(ctx, ns(secrets_action="init", force=False)), exit_codes.OK) + path = self.root / "runtime" / ".env" + self.assertEqual(stat.S_IMODE(path.stat().st_mode), 0o600) + self.assertEqual(stat.S_IMODE(path.parent.stat().st_mode), 0o700) + values = secrets.read_env(path) + for key in secrets.SECRET_KEYS: + self.assertIn(key, values) + self.assertNotIn(values[key].lower(), secrets.FORBIDDEN_DEFAULTS) + self.assertGreaterEqual(len(values[key]), 32) + self.assertGreaterEqual(len(values["DJANGO_SECRET_KEY"]), 50) + self.assertEqual(values["GRDM_PROFILE"], "minimum") + self.assertEqual(values["GRDM_PORT_WEB"], "5000") + self.assertEqual(values["GRDM_PORT_EMBER_OSF_WEB"], "4200") + self.assertEqual(secrets.check_no_defaults(values), []) + # report prints key names only, never values + printed = self.out.getvalue() + self.assertIn("POSTGRES_PASSWORD", printed) + for key in secrets.SECRET_KEYS: + self.assertNotIn(values[key], printed) + # two inits produce different secrets + self.run_cmd(ctx, ns(secrets_action="init", force=True)) + self.assertNotEqual(secrets.read_env(path)["POSTGRES_PASSWORD"], values["POSTGRES_PASSWORD"]) + + def test_init_refuses_overwrite_without_force(self): + ctx = make_ctx(self.root) + self.assertEqual(self.run_cmd(ctx, ns(secrets_action="init", force=False)), exit_codes.OK) + before = secrets.read_env(self.root / "runtime" / ".env") + self.assertEqual(self.run_cmd(ctx, ns(secrets_action="init", force=False)), exit_codes.USAGE) + self.assertIn("--force", self.err.getvalue()) + self.assertEqual(secrets.read_env(self.root / "runtime" / ".env"), before) + + def test_rotate_changes_secrets_keeps_profile_and_restarts_running(self): + ctx = make_ctx(self.root, profile="full") + self.run_cmd(ctx, ns(secrets_action="init", force=False)) + path = self.root / "runtime" / ".env" + before = secrets.read_env(path) + # simulate compose render having remapped a port: must survive rotation + before["GRDM_PORT_WEB"] = "5001" + secrets.write_env(path, before) + restarted = [] + rc = self.run_cmd( + ctx, ns(secrets_action="rotate"), + running_services=lambda: ["web", "api"], + restart=lambda services: restarted.append(list(services)) or 0, + ) + self.assertEqual(rc, exit_codes.OK) + after = secrets.read_env(path) + self.assertEqual(after["GRDM_PROFILE"], "full") + self.assertEqual(after["GRDM_PORT_WEB"], "5001") + for key in secrets.SECRET_KEYS: + self.assertNotEqual(after[key], before[key], key) + self.assertEqual(restarted, [["web", "api"]]) + self.assertEqual(stat.S_IMODE(path.stat().st_mode), 0o600) + + def test_rotate_without_env_is_usage_error(self): + ctx = make_ctx(self.root) + rc = self.run_cmd(ctx, ns(secrets_action="rotate"), running_services=lambda: [], restart=lambda s: 0) + self.assertEqual(rc, exit_codes.USAGE) + + def test_rotate_restart_failure_is_40(self): + ctx = make_ctx(self.root) + self.run_cmd(ctx, ns(secrets_action="init", force=False)) + rc = self.run_cmd(ctx, ns(secrets_action="rotate"), running_services=lambda: ["web"], restart=lambda s: 1) + self.assertEqual(rc, exit_codes.HEALTH_FAILED) + + def test_every_key_referenced_by_a_template_is_generated(self): + import re + tpl_dir = Path(secrets.__file__).parent / "templates" + if not tpl_dir.exists(): + self.skipTest("templates/ not present") + referenced = set() + for f in tpl_dir.glob("*.json"): + referenced.update(re.findall(r"\$\{?([A-Z][A-Z0-9_]*)", f.read_text(encoding="utf-8"))) + generated = set(secrets.SECRET_KEYS) | set(secrets.default_non_secrets("core")) + self.assertEqual(sorted(referenced - generated), []) + + def test_no_action_is_usage_error(self): + self.assertEqual(self.run_cmd(make_ctx(self.root), ns(secrets_action=None)), exit_codes.USAGE) + + +if __name__ == "__main__": + unittest.main() diff --git a/manifest/allowlist.baseline.json b/manifest/allowlist.baseline.json new file mode 100644 index 0000000..0ae7b88 --- /dev/null +++ b/manifest/allowlist.baseline.json @@ -0,0 +1,5 @@ +{ + "schema_version": 1, + "note": "Allow-list entry count at each milestone exit, owner-maintained (SPEC-03 §5.1 rule 5). grdm-dev scan uses the count of the current (or latest earlier) milestone as the ceiling. M1: the allow-list was created empty.", + "counts": {"M1": 0} +} diff --git a/manifest/allowlist.json b/manifest/allowlist.json new file mode 100644 index 0000000..79cd5ff --- /dev/null +++ b/manifest/allowlist.json @@ -0,0 +1,6 @@ +{ + "schema_version": 1, + "note": "Accepted findings (SPEC-03 §5.1). Every entry needs cve, component, reason, owner, expires, added_at; optional severity. Only the owner approves additions; the count must never grow between milestones (ADR-03).", + "fields": ["cve", "component", "reason", "owner", "expires", "added_at"], + "entries": [] +} diff --git a/manifest/hardening.json b/manifest/hardening.json new file mode 100644 index 0000000..7ad5592 --- /dev/null +++ b/manifest/hardening.json @@ -0,0 +1,127 @@ +{ + "controls": { + "cap_add": "cap_drop: [ALL] stays; the listed capabilities are added back by name", + "read_only": "root filesystem stays writable (read_only: false)", + "user": "the image's own entrypoint keeps running as root and drops privileges itself; no user: line is written" + }, + "exceptions": [ + { + "cap_add": [ + "CHOWN", + "DAC_OVERRIDE", + "FOWNER", + "SETGID", + "SETUID" + ], + "controls": [ + "user", + "cap_add" + ], + "reason": "The official postgres entrypoint starts as root, fixes ownership of the data directory (bind-mounted under runtime/volumes/), runs the init scripts, then drops to the postgres user with gosu. A fixed user: breaks first start on Linux hosts where the bind mount is owned by the developer.", + "review": "2027-01-31", + "service": "postgres", + "target": "M5 (postgres:15 with a pre-created data volume)" + }, + { + "cap_add": [ + "CHOWN", + "DAC_OVERRIDE", + "SETGID", + "SETUID" + ], + "controls": [ + "user", + "read_only", + "cap_add" + ], + "reason": "elasticsearch:2 (end of life) starts as root, chowns its data directory and writes logs and plugin state under /usr/share/elasticsearch before dropping to the elasticsearch user.", + "review": "2027-01-31", + "service": "elasticsearch", + "target": "M5 (removed with ES8)" + }, + { + "controls": [ + "read_only" + ], + "reason": "elasticsearch 6.3.1 runs as uid 1000 but rewrites config/ and logs/ inside the image at start-up.", + "review": "2027-01-31", + "service": "elasticsearch6", + "target": "M5 (elasticsearch:8)" + }, + { + "cap_add": [ + "CHOWN", + "DAC_OVERRIDE", + "FOWNER", + "SETGID", + "SETUID" + ], + "controls": [ + "user", + "read_only", + "cap_add" + ], + "reason": "mongo:3.4 generates its TLS certificate under /etc/ssl at start-up, chowns it and the data directory, then drops to mongodb with gosu (same sequence as the upstream compose file, with CN=mongo instead of the loopback alias).", + "review": "2027-01-31", + "service": "mongo", + "target": "M5 (removed)" + }, + { + "cap_add": [ + "CHOWN", + "DAC_OVERRIDE", + "SETGID", + "SETUID" + ], + "controls": [ + "user", + "read_only", + "cap_add" + ], + "reason": "The rabbitmq image writes its generated configuration and cookie under /etc/rabbitmq and /var/lib/rabbitmq as root before dropping to the rabbitmq user.", + "review": "2027-01-31", + "service": "rabbitmq", + "target": "M5 (current stable with RABBITMQ_CONFIG_FILE on a volume)" + }, + { + "controls": [ + "user", + "read_only" + ], + "reason": "centerforopenscience/unoconv runs LibreOffice as root and writes its profile and lock files inside the image; the shared /tmp volume is needed to exchange files with mfr.", + "review": "2027-01-31", + "service": "unoconv", + "target": "M4 (unoserver, mfr PR #9)" + }, + { + "cap_add": [ + "CHOWN", + "DAC_OVERRIDE", + "NET_BIND_SERVICE", + "SETGID", + "SETUID" + ], + "controls": [ + "user", + "read_only", + "cap_add" + ], + "reason": "Apache httpd and shibd on the CentOS-based image start as root and bind ports 80/443.", + "review": "2027-01-31", + "service": "shibboleth_sp", + "target": "M4 (maintained base, non-root where possible)" + }, + { + "controls": [ + "user", + "read_only" + ], + "reason": "Bundled test IdP (Java) writes its configuration at first start and runs as root in the current image.", + "review": "2027-01-31", + "service": "test_idp", + "target": "M4" + } + ], + "note": "Per-service exceptions to SPEC-03 §3.3 (non-root user, read-only root, cap_drop ALL). Every entry names the controls it relaxes, why, and when it is reviewed. privileged: true and no-new-privileges are never relaxed.", + "schema_version": 1 +} diff --git a/manifest/milestone.json b/manifest/milestone.json new file mode 100644 index 0000000..ed642c6 --- /dev/null +++ b/manifest/milestone.json @@ -0,0 +1,5 @@ +{ + "milestone": "M1", + "gate": "report-only", + "note": "Current milestone, owner-maintained (SPEC-03 §5.2, ADR-03). gate: report-only (M1), count-not-growing (M2, M3), fail-high (M4), zero-critical-high (M5)." +} diff --git a/manifest/redteam-targets.json b/manifest/redteam-targets.json new file mode 100644 index 0000000..deaa07e --- /dev/null +++ b/manifest/redteam-targets.json @@ -0,0 +1,14 @@ +{ + "network": "grdm-redteam", + "note": "Allowed targets for the AI red team (SPEC-03 §6). Only containers of the isolated Compose project `grdm-redteam` on the `internal: true` network `grdm-redteam` may be probed; `grdm-dev redteam preflight` exits 53 if any other container is attached or if the network has egress. Never add the developer host, the `core`/`full` development project, or any address outside this project. Service names follow SPEC-02 §4.", + "project": "grdm-redteam", + "targets": [ + "web", + "api", + "admin", + "wb", + "mfr", + "ember_osf_web", + "cas" + ] +} diff --git a/manifest/upstreams.json b/manifest/upstreams.json index 5db2eca..ee3d39f 100644 --- a/manifest/upstreams.json +++ b/manifest/upstreams.json @@ -128,6 +128,7 @@ ], "id": "osf.io", "integration_branch": "develop", + "integration_sha": null, "integration_repo": "RDM-osf.io-dev2027", "note": null, "platforms": [ @@ -229,6 +230,7 @@ ], "id": "waterbutler", "integration_branch": "develop", + "integration_sha": null, "integration_repo": "RDM-waterbutler-dev2027", "note": null, "platforms": [ @@ -319,6 +321,7 @@ ], "id": "modular-file-renderer", "integration_branch": "develop", + "integration_sha": null, "integration_repo": "RDM-modular-file-renderer-dev2027", "note": null, "platforms": [ @@ -400,6 +403,7 @@ ], "id": "ember-osf-web", "integration_branch": "develop", + "integration_sha": null, "integration_repo": "RDM-ember-osf-web-dev2027", "note": null, "platforms": [ @@ -452,6 +456,7 @@ "candidate_prs": [], "id": "cas-overlay", "integration_branch": "develop", + "integration_sha": null, "integration_repo": "RDM-cas-overlay-dev2027", "note": null, "platforms": [ @@ -520,6 +525,7 @@ ], "id": "wiki-frontend", "integration_branch": "develop", + "integration_sha": null, "integration_repo": "RDM-wiki-frontend-dev2027", "note": null, "platforms": [ @@ -563,6 +569,7 @@ "candidate_prs": [], "id": "y-websocket", "integration_branch": "develop", + "integration_sha": null, "integration_repo": "RDM-y-websocket-dev2027", "note": null, "platforms": [ @@ -606,6 +613,7 @@ "candidate_prs": [], "id": "OASys", "integration_branch": "develop", + "integration_sha": null, "integration_repo": "RDM-OASys-dev2027", "note": null, "platforms": [ @@ -640,6 +648,7 @@ "candidate_prs": [], "id": "Shibboleth-SP", "integration_branch": "develop", + "integration_sha": null, "integration_repo": "RDM-Shibboleth-SP-dev2027", "note": "mutually exclusive with fakecas; bundled test IdP for acceptance", "platforms": [ @@ -675,6 +684,7 @@ "candidate_prs": [], "id": "rdmcp", "integration_branch": "develop", + "integration_sha": null, "integration_repo": "RDM-rdmcp-dev2027", "note": null, "platforms": [ @@ -709,6 +719,7 @@ "candidate_prs": [], "id": "aipf_mcp_data_grdm", "integration_branch": "develop", + "integration_sha": null, "integration_repo": "RDM-aipf_mcp_data_grdm-dev2027", "note": null, "platforms": [ @@ -743,6 +754,7 @@ "candidate_prs": [], "id": "postgres", "integration_branch": null, + "integration_sha": null, "integration_repo": null, "note": null, "platforms": [ @@ -767,6 +779,7 @@ "candidate_prs": [], "id": "elasticsearch2", "integration_branch": null, + "integration_sha": null, "integration_repo": null, "note": null, "platforms": [ @@ -791,6 +804,7 @@ "candidate_prs": [], "id": "elasticsearch6", "integration_branch": null, + "integration_sha": null, "integration_repo": null, "note": null, "platforms": [ @@ -815,6 +829,7 @@ "candidate_prs": [], "id": "mongo", "integration_branch": null, + "integration_sha": null, "integration_repo": null, "note": null, "platforms": [ @@ -839,6 +854,7 @@ "candidate_prs": [], "id": "rabbitmq", "integration_branch": null, + "integration_sha": null, "integration_repo": null, "note": null, "platforms": [ @@ -863,6 +879,7 @@ "candidate_prs": [], "id": "redis", "integration_branch": null, + "integration_sha": null, "integration_repo": null, "note": null, "platforms": [ @@ -887,6 +904,7 @@ "candidate_prs": [], "id": "sharejs", "integration_branch": null, + "integration_sha": null, "integration_repo": null, "note": null, "platforms": [ @@ -911,6 +929,7 @@ "candidate_prs": [], "id": "unoconv", "integration_branch": null, + "integration_sha": null, "integration_repo": null, "note": null, "platforms": [ @@ -935,6 +954,7 @@ "candidate_prs": [], "id": "fakecas", "integration_branch": null, + "integration_sha": null, "integration_repo": null, "note": null, "platforms": [ diff --git a/site/404.html b/site/404.html index 91a5352..e4d6465 100644 --- a/site/404.html +++ b/site/404.html @@ -1904,6 +1904,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/assets/index.html b/site/assets/index.html index 949c6a3..e428dc8 100644 --- a/site/assets/index.html +++ b/site/assets/index.html @@ -1978,6 +1978,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/decisions/ADR-01_Integration_Repository_Placement/index.html b/site/decisions/ADR-01_Integration_Repository_Placement/index.html index 70f22d3..783c7cc 100644 --- a/site/decisions/ADR-01_Integration_Repository_Placement/index.html +++ b/site/decisions/ADR-01_Integration_Repository_Placement/index.html @@ -717,9 +717,9 @@
  • - + - 5. Bootstrap interpretation of the integration order (proposed, awaiting owner approval) + 5. Bootstrap of the integration order (decided 2026-11-05: strict reconstruction) @@ -777,9 +777,9 @@
  • - + - 5. 統合順の「初回構築」の解釈(提案。所有者の承認待ち) + 5. 統合順の初回構築(2026-11-05 決定: 厳密に再構築する) @@ -2089,6 +2089,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • @@ -2557,9 +2578,9 @@
  • - + - 5. Bootstrap interpretation of the integration order (proposed, awaiting owner approval) + 5. Bootstrap of the integration order (decided 2026-11-05: strict reconstruction) @@ -2617,9 +2638,9 @@
  • - + - 5. 統合順の「初回構築」の解釈(提案。所有者の承認待ち) + 5. 統合順の初回構築(2026-11-05 決定: 厳密に再構築する) @@ -2664,7 +2685,8 @@

    English · 日本語

      -
    • Version / 版: 0.2 — 2026-11-05. Learned: the first construction of a -dev2027 repository cannot literally replay "public → private → adopted PRs", so the rule needs a stated bootstrap interpretation; it is proposed in §5 and awaits the owner. / -dev2027 の初回構築では「公開 → private → 採用 PR」を文字どおり再現できないため、初回構築の解釈を明文化する必要があると分かった。§5 に提案し所有者の承認を待つ。 +
    • Version / 版: 0.3 — 2026-11-05. Learned: the owner prefers a literal, reproducible integration order over a convenient bootstrap, so the first construction is redone public-first on a new branch and proposed as a superseding pull request. / 所有者は便利な初回構築より、文字どおり再現できる統合順を選ぶと分かった。初回構築は新しいブランチで「公開が先」にやり直し、置き換えの PR として提案する。 + 0.2 — 2026-11-05. Learned: the first construction of a -dev2027 repository cannot literally replay "public → private → adopted PRs", so the rule needs a stated bootstrap interpretation; it is proposed in §5 and awaits the owner. / -dev2027 の初回構築では「公開 → private → 採用 PR」を文字どおり再現できないため、初回構築の解釈を明文化する必要があると分かった。§5 に提案し所有者の承認を待つ。 0.1 — 2026-11-05. Learned: GitHub refuses a fork inside the same organization, so "fork and integrate" had to become "new repository with history pushed", and that in turn made the no-force-push and no-delete rules the only way to keep the pushed history trustworthy. / GitHub は同じ組織内へのフォークを許さないため「フォークして統合」は「履歴を push した新規リポジトリ」になり、その結果 force push 禁止と削除禁止が、push した履歴を信じられるものに保つ唯一の手段だと分かった。
    • Status: Accepted by the owner, 2026-11-05 (plan-interview).
    • Records a decision for: POL-01 §2 item 5 · SPEC-01 Manifest · SPEC-05 Upstream Tracking
    • @@ -2734,15 +2756,17 @@

      4. ConsequencesSPEC-01 §4 rule 6); the owner decides whether it is merged.


    -

    5. Bootstrap interpretation of the integration order (proposed, awaiting owner approval)

    -

    Status: proposed on 2026-11-05 after review r1/r2 of RDM-osf.io-dev2027 PR #1 (finding R2). Not yet approved by the owner.

    -

    SPEC-01 §4 fixes the integration order public → private → adopted PRs. The first construction of every -dev2027 repository did not replay that recipe: develop was seeded from the -private tip (which already contains the public history) and the newer public tip was then merged in as a normal two-parent merge. We propose to read the rule as follows:

    -
      -
    • Bootstrap (first construction): seeding develop from the -private tip and merging the newer public tip incrementally satisfies the rule, because the -private tip is a verified superset of the public history and the merge preserves both parents.
    • -
    • Steady state (weekly integration, SPEC-05): the literal order applies: merge upstream/public-*, then upstream/private-*, then re-apply adopted PRs.
    • -
    • Upstream history is never rewritten to make the bootstrap look like a literal replay.
    • -
    -

    If the owner rejects this interpretation, the alternative is a strict reconstruction of each develop from the public tip, proposed as a separate change without force-push.

    +

    5. Bootstrap of the integration order (decided 2026-11-05: strict reconstruction)

    +

    Status: the owner rejected the proposed interpretation "seed from the -private tip and merge the newer public tip" (review r1/r2 of RDM-osf.io-dev2027 PR #1, finding R2). The integration order of SPEC-01 §4 applies literally, also to the first construction.

    +

    Procedure for every -dev2027 repository:

    +
      +
    1. Start a branch integrate/strict-<YYYYMMDD> at the tip of upstream/public-<branch>.
    2. +
    3. Merge upstream/private-<branch> into it with a normal two-parent merge (--no-ff), resolving conflicts on the branch.
    4. +
    5. Re-apply adopted PRs from the manifest, each as its own merge.
    6. +
    7. Open a pull request from that branch to develop. The develop branch is never force-pushed or deleted; the pull request supersedes any earlier integration pull request, which is closed with a comment pointing to the new one.
    8. +
    9. Review by REV, check by QAE, merge by the owner (ADR-04).
    10. +
    +

    Consequence: the first develop of each repository (seeded from the -private tip during bootstrap) stays in history. The strictly reconstructed branch is merged on top of it, so from the first strict merge onward every develop carries the public-first order.


    日本語

    @@ -2807,15 +2831,17 @@

    4. 結果SPEC-01 §4 の規則 6)。マージするかは所有者が決めます。


  • -

    5. 統合順の「初回構築」の解釈(提案。所有者の承認待ち)

    -

    状態: 2026-11-05、RDM-osf.io-dev2027 PR #1 のレビュー r1/r2(指摘 R2)を受けて提案。所有者はまだ承認していない。

    -

    SPEC-01 §4 は統合順を「公開 → private → 採用 PR」と定める。各 -dev2027 リポジトリの初回構築はこの手順を文字どおりには再現していない。develop は -private の先端(公開の履歴を既に含む)を起点にし、より新しい公開の先端を通常の 2 親マージで取り込んだ。この規則を次のように読むことを提案する。

    -
      -
    • 初回構築: -private の先端を起点にして、より新しい公開の先端を増分でマージする形は、規則を満たす。-private の先端が公開履歴の上位互換であることを確認済みで、マージは両親を保持するからである。
    • -
    • 定常運転(週次統合、SPEC-05): 文字どおりの順序を適用する。upstream/public-*、次に upstream/private-*、最後に採用 PR を再適用する。
    • -
    • 初回構築を文字どおりの再現に見せるために上流の履歴を書き換えることはしない。
    • -
    -

    所有者がこの解釈を退ける場合の代替は、各 develop を公開の先端から厳密に再構築することで、force push なしの別の変更として提案する。

    +

    5. 統合順の初回構築(2026-11-05 決定: 厳密に再構築する)

    +

    状態: 所有者は「-private の先端を起点にして、より新しい公開の先端をマージする」という解釈の提案を 退けた(RDM-osf.io-dev2027 PR #1 のレビュー r1/r2、指摘 R2)。SPEC-01 §4 の統合順は、初回構築にも文字どおり適用する。

    +

    各 -dev2027 リポジトリの手順:

    +
      +
    1. upstream/public-<branch> の先端からブランチ integrate/strict-<YYYYMMDD> を切る。
    2. +
    3. そこへ upstream/private-<branch> を通常の 2 親マージ(--no-ff)で取り込み、衝突はそのブランチ上で解消する。
    4. +
    5. manifest の採用 PR を、それぞれ独立したマージとして再適用する。
    6. +
    7. そのブランチから develop へ PR を出す。develop は force push も削除もしない。この PR は以前の統合 PR を置き換え、以前の PR は新しい PR を示すコメントを付けて閉じる。
    8. +
    9. REV のレビュー、QAE の検査、所有者のマージ(ADR-04)。
    10. +
    +

    結果: 各リポジトリの最初の develop(初回構築で -private の先端から作ったもの)は履歴に残る。厳密に再構築したブランチはその上にマージされるので、最初の厳密マージ以降、どの develop も「公開が先」の順序を持つ。


    Glossary / 用語

    diff --git a/site/decisions/ADR-02_Network_Model/index.html b/site/decisions/ADR-02_Network_Model/index.html index 67f0428..e1bafbf 100644 --- a/site/decisions/ADR-02_Network_Model/index.html +++ b/site/decisions/ADR-02_Network_Model/index.html @@ -2071,6 +2071,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/decisions/ADR-03_Staged_Security_Gate/index.html b/site/decisions/ADR-03_Staged_Security_Gate/index.html index 5aae567..6c3780e 100644 --- a/site/decisions/ADR-03_Staged_Security_Gate/index.html +++ b/site/decisions/ADR-03_Staged_Security_Gate/index.html @@ -2089,6 +2089,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/decisions/ADR-04_AI_Autonomy_and_Roles/index.html b/site/decisions/ADR-04_AI_Autonomy_and_Roles/index.html index 1409b72..37d4d96 100644 --- a/site/decisions/ADR-04_AI_Autonomy_and_Roles/index.html +++ b/site/decisions/ADR-04_AI_Autonomy_and_Roles/index.html @@ -828,6 +828,15 @@ +
  • + +
  • + + + Recorded exceptions + + +
  • @@ -930,6 +939,15 @@ + + +
  • + + + 記録した例外 + + +
  • @@ -2173,6 +2191,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • @@ -2689,6 +2728,15 @@ +
  • + +
  • + + + Recorded exceptions + + +
  • @@ -2791,6 +2839,15 @@ + + +
  • + + + 記録した例外 + + +
  • @@ -2832,7 +2889,8 @@

    ADR-04 AI Autono

    Jump: English · 日本語

      -
    • Version / 版: 0.1 — 2026-11-05. Learned: the line between "automatic" and "human" is easiest to defend when it sits on two concrete commands, merge and publish, rather than on a judgment such as "important changes". / 「自動」と「人」の境目は、「重要な変更」のような判断ではなく、マージと公開という二つの具体的な操作に置くと最も守りやすいと分かった。
    • +
    • Version / 版: 0.2 — 2026-11-05. Learned: a one-time delegation must be written down with scope, grantor and evidence before it is used, or the human-merge rule erodes silently. / 一回限りの委任でも、使う前に範囲・許可者・証跡を書き残さなければ「人がマージする」規則が静かに崩れると分かった。 + 0.1 — 2026-11-05. Learned: the line between "automatic" and "human" is easiest to defend when it sits on two concrete commands, merge and publish, rather than on a judgment such as "important changes". / 「自動」と「人」の境目は、「重要な変更」のような判断ではなく、マージと公開という二つの具体的な操作に置くと最も守りやすいと分かった。
    • Status: Accepted (owner, 2026-11-05). Review date: after steady-state operation has run for one month (open question in §5).
    • Related: SPEC-00 Overview · SPEC-02 Installer CLI · SPEC-03 Security Gate · SPEC-04 Acceptance Tests · SPEC-05 Upstream Tracking · SPEC-06 Documentation Conventions · POL-01 Position · ADR-01 Integration Repository Placement · ADR-02 Network Model · ADR-03 Staged Security Gate · docs/README.md
    @@ -2928,6 +2986,29 @@

    4. Consequences5. Open question

    Should vulnerability-only fixes be allowed to auto-merge after REV approval and QAE pass? Arguments for: faster closure of HIGH findings in steady state. Arguments against: POL-05 keeps merge human; a wrong automatic merge in a security path is the most expensive kind of error. Decision deferred until steady-state operation has run for about one month and the owner has seen the real volume and quality of fix PRs. Until then, option 2 stands as written.


    +

    Recorded exceptions

    +
    + + + + + + + + + + + + + + + + + + +
    DateExceptionScopeGranted byEvidence
    2026-11-05QAE (Claude Code Fable) merges PR #19 of RDM-developer-guide itself, using the repository administrator path of the branch protection because the author cannot approve its own pull requestThis one pull request only. Merge, not approve; no other repositoryOwner, in the session dialogueREV r3 record docs/reviews/2026-11-05_RDM-developer-guide_M1_Skeleton_PR_r3.md (approve recommended), CI 6/6 green on the merged head
    +

    The rule "merge and publish are human" is unchanged; every further merge needs its own recorded exception or the owner's hand.

    +

    日本語

    → To English

    @@ -3019,6 +3100,29 @@

    4. 結果5. 未決事項

    脆弱性修正だけの PR に、REV 承認と QAE 合格の後の自動マージを認めるか。 賛成の理由: 恒常運用で HIGH の検出をより早く閉じられる。反対の理由: POL-05 はマージを人に残している。セキュリティの経路での誤った自動マージは最も高くつく種類の誤りである。恒常運用を約一か月回し、所有者が修正 PR の実際の量と質を見てから決める。それまでは選択肢 2 を書いたとおりに適用する。


    +

    記録した例外

    + + + + + + + + + + + + + + + + + + + +
    日付例外範囲許可者証跡
    2026-11-05QAE(Claude Code Fable)が RDM-developer-guide 自身の PR #19 をマージする。作者は自分の PR を承認できないため、ブランチ保護の管理者経路を使うこの PR 1 件のみ。承認ではなくマージ。他リポジトリには及ばない所有者(セッション内の対話)REV r3 記録 docs/reviews/2026-11-05_RDM-developer-guide_M1_Skeleton_PR_r3.md(approve 推奨)、マージ対象 head で CI 6/6 合格
    +

    「マージと公開は人が行う」という規則は変わらない。以後のマージはそれぞれ例外の記録か所有者の手を要する。

    +

    Glossary / 用語

    diff --git a/site/decisions/index.html b/site/decisions/index.html index ee1b353..fdb3f1a 100644 --- a/site/decisions/index.html +++ b/site/decisions/index.html @@ -2053,6 +2053,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/demo/index.html b/site/demo/index.html index 6e16794..bafe04c 100644 --- a/site/demo/index.html +++ b/site/demo/index.html @@ -2056,6 +2056,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/demo/runs/index.html b/site/demo/runs/index.html index 1232b8d..aa2b946 100644 --- a/site/demo/runs/index.html +++ b/site/demo/runs/index.html @@ -2040,6 +2040,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/guides/admin-addon/README.legacy/index.html b/site/guides/admin-addon/README.legacy/index.html index a98cff8..9a9605e 100644 --- a/site/guides/admin-addon/README.legacy/index.html +++ b/site/guides/admin-addon/README.legacy/index.html @@ -1992,6 +1992,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/guides/admin-addon/index.html b/site/guides/admin-addon/index.html index 769df2c..9bb45c5 100644 --- a/site/guides/admin-addon/index.html +++ b/site/guides/admin-addon/index.html @@ -2094,6 +2094,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/guides/api/Decorators/index.html b/site/guides/api/Decorators/index.html index aed2fe7..37e40b3 100644 --- a/site/guides/api/Decorators/index.html +++ b/site/guides/api/Decorators/index.html @@ -2046,6 +2046,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/guides/api/README.legacy/index.html b/site/guides/api/README.legacy/index.html index 5f1c10d..97ce667 100644 --- a/site/guides/api/README.legacy/index.html +++ b/site/guides/api/README.legacy/index.html @@ -1953,6 +1953,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/guides/api/index.html b/site/guides/api/index.html index 416a2d4..011880f 100644 --- a/site/guides/api/index.html +++ b/site/guides/api/index.html @@ -2094,6 +2094,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/guides/ec2/README.legacy/index.html b/site/guides/ec2/README.legacy/index.html index 7f9cc40..a197353 100644 --- a/site/guides/ec2/README.legacy/index.html +++ b/site/guides/ec2/README.legacy/index.html @@ -2130,6 +2130,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/guides/ec2/index.html b/site/guides/ec2/index.html index bbf5551..39f7ef9 100644 --- a/site/guides/ec2/index.html +++ b/site/guides/ec2/index.html @@ -2094,6 +2094,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/guides/environment/README.legacy/index.html b/site/guides/environment/README.legacy/index.html index 19bc0a5..298c193 100644 --- a/site/guides/environment/README.legacy/index.html +++ b/site/guides/environment/README.legacy/index.html @@ -1953,6 +1953,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/guides/environment/index.html b/site/guides/environment/index.html index 0b0966a..7dd8a02 100644 --- a/site/guides/environment/index.html +++ b/site/guides/environment/index.html @@ -2094,6 +2094,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/guides/index.html b/site/guides/index.html index ce88079..9ba6df9 100644 --- a/site/guides/index.html +++ b/site/guides/index.html @@ -2029,6 +2029,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/guides/screen-expansion/README.legacy/index.html b/site/guides/screen-expansion/README.legacy/index.html index 969d548..a8aee3f 100644 --- a/site/guides/screen-expansion/README.legacy/index.html +++ b/site/guides/screen-expansion/README.legacy/index.html @@ -1992,6 +1992,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/guides/screen-expansion/index.html b/site/guides/screen-expansion/index.html index dd3d3ae..4528e08 100644 --- a/site/guides/screen-expansion/index.html +++ b/site/guides/screen-expansion/index.html @@ -2094,6 +2094,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/guides/skeleton/README.legacy/index.html b/site/guides/skeleton/README.legacy/index.html index 6c56232..f8a9804 100644 --- a/site/guides/skeleton/README.legacy/index.html +++ b/site/guides/skeleton/README.legacy/index.html @@ -1992,6 +1992,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/guides/skeleton/index.html b/site/guides/skeleton/index.html index bd0dd8e..3a98a7a 100644 --- a/site/guides/skeleton/index.html +++ b/site/guides/skeleton/index.html @@ -2094,6 +2094,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/guides/storage-addon/README.legacy/index.html b/site/guides/storage-addon/README.legacy/index.html index c605601..4200db5 100644 --- a/site/guides/storage-addon/README.legacy/index.html +++ b/site/guides/storage-addon/README.legacy/index.html @@ -1992,6 +1992,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/guides/storage-addon/index.html b/site/guides/storage-addon/index.html index a611755..18e1c6d 100644 --- a/site/guides/storage-addon/index.html +++ b/site/guides/storage-addon/index.html @@ -2094,6 +2094,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/handoff/index.html b/site/handoff/index.html index 4b83aa7..cb0ebae 100644 --- a/site/handoff/index.html +++ b/site/handoff/index.html @@ -2053,6 +2053,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/index.html b/site/index.html index cf54060..772cdc2 100644 --- a/site/index.html +++ b/site/index.html @@ -2046,6 +2046,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/policy/POL-01_Developer_Environment_2027_Position/index.html b/site/policy/POL-01_Developer_Environment_2027_Position/index.html index 4b01028..20de195 100644 --- a/site/policy/POL-01_Developer_Environment_2027_Position/index.html +++ b/site/policy/POL-01_Developer_Environment_2027_Position/index.html @@ -2107,6 +2107,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/policy/index.html b/site/policy/index.html index aa59e67..84e3ac2 100644 --- a/site/policy/index.html +++ b/site/policy/index.html @@ -2053,6 +2053,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/reference/REF-01_Glossary/index.html b/site/reference/REF-01_Glossary/index.html index 21fb2e9..23ba831 100644 --- a/site/reference/REF-01_Glossary/index.html +++ b/site/reference/REF-01_Glossary/index.html @@ -2161,6 +2161,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/reference/index.html b/site/reference/index.html index e3b9cd2..1270734 100644 --- a/site/reference/index.html +++ b/site/reference/index.html @@ -2053,6 +2053,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/reviews/2026-11-05_RDM-developer-guide_M1_Skeleton_PR_r1/index.html b/site/reviews/2026-11-05_RDM-developer-guide_M1_Skeleton_PR_r1/index.html index 26e3d50..232a526 100644 --- a/site/reviews/2026-11-05_RDM-developer-guide_M1_Skeleton_PR_r1/index.html +++ b/site/reviews/2026-11-05_RDM-developer-guide_M1_Skeleton_PR_r1/index.html @@ -2071,6 +2071,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/reviews/2026-11-05_RDM-developer-guide_M1_Skeleton_PR_r2/index.html b/site/reviews/2026-11-05_RDM-developer-guide_M1_Skeleton_PR_r2/index.html index 9cc475b..2850a83 100644 --- a/site/reviews/2026-11-05_RDM-developer-guide_M1_Skeleton_PR_r2/index.html +++ b/site/reviews/2026-11-05_RDM-developer-guide_M1_Skeleton_PR_r2/index.html @@ -12,7 +12,7 @@ - + @@ -2089,6 +2089,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/reviews/2026-11-05_RDM-developer-guide_M1_Skeleton_PR_r3/index.html b/site/reviews/2026-11-05_RDM-developer-guide_M1_Skeleton_PR_r3/index.html new file mode 100644 index 0000000..09df3d4 --- /dev/null +++ b/site/reviews/2026-11-05_RDM-developer-guide_M1_Skeleton_PR_r3/index.html @@ -0,0 +1,2964 @@ + + + + + + + + + + + + + + + + + + + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 - GakuNin RDM Developer Environment 2027 / 開発環境 2027 版 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + +
    + + +
    + +
    + + + + + + + + + +
    +
    + + + +
    +
    +
    + + + + + + + +
    +
    +
    + + + + + + + +
    +
    + + + + + + + +

    REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3

    +
    +

    Summary: Approve recommendation for PR (pull request: a proposed change) #19 at 413520e. All three r2 findings are resolved; no regression was found in the r1 corrections within the checks recorded here. +概要: PR(プルリクエスト: 変更提案)#19 の 413520e は approve 推奨。r2 の3件は解消し、記録した検査の範囲では r1 修正の回帰も見つかりませんでした。

    +
    +

    Jump: English · 日本語

    +
      +
    • Version / 版: 0.1 — 2026-11-05. Learned: replaying the earlier failing inputs confirms both rejection and safe reporting; a passing normal-input check alone cannot establish either. / 過去に失敗した入力の再実行で、拒否と安全な報告の両方を確かめられた。正常入力の合格だけでは両方を保証できない。
    • +
    • Applies to: PR #19, feat/m1-skeleton → develop, head 413520e20a98862d7eb5b203bdda1900d49019ac.
    • +
    • Related: Review index · r1 · r2 · SPEC-01 · SPEC-06.
    • +
    • Used by: the owner's integration decision under ADR-01 §5.
    • +
    +
    +

    +

    English

    +

    → 日本語版へ

    +

    Verdict

    +

    Approve. No remaining technical findings from r2 and no newly identified regression in r1 fixes. This is an independent review recommendation, not a GitHub approval or merge. The three owner decisions remain open. CI (continuous integration: automatic checks of changes) passes on the exact reviewed head. See the shared glossary for background terms.

    +

    Resolution of r2 findings

    +
      +
    1. +

      R2-01 resolved. scan_policy in tools/manifest_check.py scans tracked files without path or extension exclusions. An independent temporary copy detected a runtime-built prohibited address on line 2 in each of seven paths: site/index.html, site/search/search_index.json, docs/guides/api/README.legacy.md, docs/guides/api/addon/x.py, docs/README.md, Dockerfile, and assets/data.unknownext. Each direct call returned one finding; the temporary Git repository's command-line policy check rejected the files with exit code (the completion status number) 1. Neither output included the matched address. The real tree reports 451 scanned, 62 skipped as non-UTF-8 (not readable in the expected text encoding), zero over 5 MB, and zero findings. Binary/size skip accounting and detection in former exclusions are covered by tests. Source inspection also shows unreadable files are recorded as skipped; this is a technical read limitation, not a path exemption. The scan does not inspect image pixels.

      +
    2. +
    3. +

      R2-02 resolved. STRUCT_TOP, STRUCT_COMPONENT, STRUCT_UPSTREAM, and STRUCT_PR declare field types; validate_structure runs before value comparisons and TOON (a compact text form of structured data) projection. Integer validation explicitly excludes booleans. The independent copy used the real JSON (structured data written as named fields), with the real TOON unchanged. Each original rejection case—schema_version: true, target_image.M4: true, components: "bad", and component role: []—now reports the relevant MC (manifest-check rule) finding, exits 20, and produces no traceback (an internal error stack). The unchanged copy exits 0. Structural failures do not attempt MC-11 comparison. Added subprocess tests in tools/tests/test_manifest_check.py assert these outcomes and additional malformed shapes; all pass.

      +
    4. +
    5. +

      R2-03 resolved. SPEC-06 §8 version 0.3 now describes file and fragment checking in both languages. The implementation checks same-file anchors (page bookmarks) and anchors/headings in Markdown targets. Independent negative checks reject a missing file with fragment, a missing same-file anchor, and a missing anchor in an existing Markdown file; an existing #english target passes. tools/docs_check.py is unchanged from r2.

      +
    6. +
    +

    Regression check of r1 fixes

    +
  • + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    r1 findingr3 evidence and disposition
    R1 published private addressesResolved: real-tree policy scan has zero findings, and old excluded locations now reject synthetic cases.
    R2 disabled gitleaksResolved: unchanged [extend] useDefault = true, four whole-line exceptions, no path exception; hosted secret scan passes. gitleaks is the secret-detection tool. Its synthetic-secret container test was not independently rerun in r3.
    R3 missing TrivyResolved: unchanged pinned filesystem job and report artifact, with explicit M1 report-only scope; hosted job passes. Trivy is the vulnerability/configuration scanner; a green report-only job does not mean zero vulnerabilities.
    R4 incomplete manifest validationResolved for the reviewed defects: 66 checker tests pass, normal JSON/TOON comparison passes, and original malformed-input cases now reject correctly.
    R5 ZAP scans itselfStill resolved in both language specifications: ZAP (the running-web-application scanner) uses service names and internal ports; host port remapping does not change those targets. Specification unchanged since r2; no deployed installer test was performed.
    R6 malformed diagram/data blocksAll 34 Mermaid (text-defined diagram) blocks reparse successfully using the existing Mermaid 11.4.1 harness. All 34 Mermaid and 44 TOON blocks are unchanged from r2; the 44 TOON blocks retain r2's independent parse evidence rather than a new external-parser run.
    R7 documentation checker gapsResolved within the disclosed M1 scope: checker tests pass, fragment rejection was independently reproduced, and explicit legacy-format exceptions and SHA-only excerpt checking remain documented. SHA is a revision fingerprint; excerpt checking does not prove equality of arbitrary fields.
    R8 C4/core/M2 conflictStill resolved: unchanged JSON/TOON and SPEC-00/02/04 place y_websocket in core and require C4 in both core/full without skipping.
    +

    Reproduction and CI evidence

    +

    Run these commands from the repository root; all returned 0:

    +
    python3 tools/manifest_check.py
    +python3 tools/docs_check.py
    +python3 -m unittest discover -s tools/tests -v
    +gh pr checks 19 -R RCOSDP/RDM-developer-guide
    +
    +

    The unit suite reports 66 tests passed. Documentation checking reports 46 checked files, 8 exempt files, and 116 nonblocking glossary warnings before adding this untracked review. The new review is checked separately through check_file; tracked-file enumeration does not include it yet.

    +

    The independent negative cases ran only in scratchpad/rev-r3-toxvm83j/ under the task's designated temporary directory. The checker and real manifest files were copied there; synthetic addresses were assembled at runtime and never written to this repository. The four original type mutations were tested separately with unchanged TOON. No production file was mutated for rejection tests.

    +

    Using only gh, PR (pull request: a proposed change) metadata and both run records confirmed head 413520e20a98862d7eb5b203bdda1900d49019ac. All six checks pass: MkDocs (the documentation-to-website tool) site build, links, manifest/policy, gitleaks, Semgrep (source-code pattern checking), and Trivy. Both the documentation run and security run conclude success. The generated SPEC-06 site page changed along with its source. This review does not newly audit private integration repositories, session-link contents, all image pixels, or deployed installer behavior.

    +

    Remaining owner decisions

    +
      +
    • ADR-01 §5 bootstrap interpretation: the initial integration-order interpretation remains explicitly proposed and awaiting the owner. This recommendation does not approve that exception; record the owner's decision and align affected normative records if accepted.
    • +
    • Claude-Session link retention: decide whether to retain the session link in public metadata after checking sharing visibility. The link's contents were not inspected or republished.
    • +
    • Legacy Semgrep deferral: explicitly accept or reject the documented M2/M3 deferral of historical sample-code findings. Publication-policy scanning now covers those paths even while Semgrep exceptions remain.
    • +
    +

    No code correction is requested by r3. The coordinator still needs to integrate this review record and handle the owner decisions; no commit, push, approval, or merge was performed by this reviewer.

    +
    +

    +

    日本語

    +

    → To English

    +

    判定

    +

    Approve。r2 の技術的指摘は残っておらず、r1 修正に新しい回帰も見つかりませんでした。 独立レビューの推奨であり、GitHub の承認やマージ操作ではありません。所有者の判断3点は未決です。CI(変更を自動検査する仕組み)は、確認対象と同じ head で合格しています。背景用語は共通用語集も参照してください。

    +

    r2 指摘の解消確認

    +
      +
    1. +

      R2-01 解消。 tools/manifest_check.py の scan_policy はパス・拡張子の除外なく追跡ファイルを検査します。独立した一時コピーで、実行時に組み立てた禁止アドレスを7種類のパスの2行目に配置しました。対象は site/index.html、site/search/search_index.json、docs/guides/api/README.legacy.md、docs/guides/api/addon/x.py、docs/README.md、Dockerfile、assets/data.unknownext です。直接呼出しは各1件を検出し、一時 Git リポジトリのコマンドライン検査も終了コード(処理結果を表す数)1で拒否しました。出力に一致アドレスはありません。実ツリーは451ファイル検査、UTF-8(想定する文字の符号化方式)で読めない62ファイルをスキップ、5 MB超は0件、検出0件でした。旧除外領域の検出とバイナリ・サイズ別の集計は試験でも確認しました。コード上は読取不能もスキップとして記録します。これは読取の技術的限界であり、パス例外ではありません。画像の画素は検査しません。

      +
    2. +
    3. +

      R2-02 解消。 STRUCT_TOP、STRUCT_COMPONENT、STRUCT_UPSTREAM、STRUCT_PR が項目の型を宣言し、validate_structure が値の比較と TOON(構造化データを短く表す文字形式)の抄録生成に先行します。整数判定は真偽値を明示的に除きます。独立コピーでは実際の JSON(名前付き項目で書く構造化データ)を使用し、TOON は変更していません。元の4ケース schema_version: true、target_image.M4: true、components: "bad"、部品の role: [] はすべて対応する MC(manifest 検査規則)の指摘を出し、終了20、traceback(内部エラーの呼出し履歴)なしでした。無変更コピーは終了0です。構造不正時は MC-11 比較を実行しません。tools/tests/test_manifest_check.py に追加された子プロセス試験もこれらと追加の不正構造を検査し、すべて合格しました。

      +
    4. +
    5. +

      R2-03 解消。 SPEC-06 §8 の版0.3は、両言語ともファイルとフラグメントの検査を説明しています。実装は同一ファイルのアンカー(ページ内のしおり)とリンク先 Markdown のアンカー・見出しを検査します。独立試験で、存在しないファイルにフラグメントを付けたリンク、同一ファイルの欠落アンカー、存在する Markdown 内の欠落アンカーを拒否し、存在する #english は合格しました。tools/docs_check.py は r2 から変更されていません。

      +
    6. +
    +

    r1 修正の回帰確認

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    r1 指摘r3 の根拠と扱い
    R1 非公開アドレス掲載解消。実ツリーの方針検出0件。旧除外領域の模擬ケースも拒否。
    R2 gitleaks 無効解消。[extend] useDefault = true、行全体に限定した4例外、パス例外なしを維持し、hosted 検査も合格。gitleaks は秘密検出ツール。模擬秘密のコンテナ試験は r3 で独立再実行していません。
    R3 Trivy 欠落解消。版固定のファイルシステム検査・報告保存と M1 報告のみの範囲は不変で、hosted 検査も合格。Trivy は脆弱性・設定の検査ツールで、報告のみの合格は脆弱性ゼロを意味しません。
    R4 manifest 検査不足レビュー対象の不具合は解消。66試験と正常 JSON/TOON 比較が合格し、元の不正型を正しく拒否。
    R5 ZAP が自身を検査英和仕様上の解消を維持。ZAP(稼働中の Web アプリを検査するツール)はサービス名・内部ポートを使用し、ホスト側ポート変更で対象は変わりません。仕様は r2 から不変。導入済みインストーラーは未検証。
    R6 図・データの構文既存 Mermaid 11.4.1 検証器で Mermaid(文字で図を定義する記法)34ブロックが再解析に合格。Mermaid 34件と TOON 44件はすべて r2 と同一。TOON は外部解析器の新規実行ではなく、r2 の独立解析の根拠を引き継ぎます。
    R7 文書検査の不足明示された M1 範囲では解消。試験合格とフラグメント拒否の独立再現を確認。旧形式の例外と SHA 限定の抄録検査は明記を維持。SHA は版を識別する指紋で、抄録の任意項目の同一性は保証しません。
    R8 C4/core/M2 矛盾解消を維持。JSON/TOON と SPEC-00/02/04 は不変で、y_websocket を core に含め、core/full とも C4 必須・スキップなし。
    +

    再現と CI の根拠

    +

    リポジトリルートで次を実行し、すべて終了0でした。

    +
    python3 tools/manifest_check.py
    +python3 tools/docs_check.py
    +python3 -m unittest discover -s tools/tests -v
    +gh pr checks 19 -R RCOSDP/RDM-developer-guide
    +
    +

    単体試験は 66件合格。新規の未追跡 r3 記録を追加する前の文書検査は 46ファイル検査、8例外、合否を左右しない用語警告116件 でした。新規記録は check_file で別途検査し、まだ追跡ファイル件数には含めていません。

    +

    独立した拒否試験は、指定一時ディレクトリ配下の scratchpad/rev-r3-toxvm83j/ のみで行いました。検査プログラムと実 manifest をコピーし、模擬禁止アドレスは実行時に組み立て、このリポジトリには一切書いていません。元の型不正4件は、TOON 無変更で個別に試験しました。拒否試験のために本体ファイルを変更していません。

    +

    GitHub の確認には gh だけを使い、PR 情報と両 run が head 413520e20a98862d7eb5b203bdda1900d49019ac を指すと確認しました。MkDocs(文書を Web サイトにする道具)の構築、リンク、manifest/方針、gitleaks、Semgrep(ソースコードの危険な書き方の検査)、Trivy の6件すべてが合格です。docs run と security run はいずれも success でした。生成された SPEC-06 のサイトページも元文書とともに変更されています。非公開統合リポジトリ、セッションリンクの内容、画像全画素、導入済みインストーラーは新規監査していません。

    +

    所有者に残る判断

    +
      +
    • ADR-01 §5 の初回構築解釈: 提案・所有者承認待ちのままです。この推奨で例外を承認したことにはなりません。所有者の決定を記録し、承認時は関連する規範記録を整合させてください。
    • +
    • Claude-Session リンク保持: 共有範囲を確認したうえで、公開メタデータに保持するか判断してください。リンクの内容は閲覧・再掲載していません。
    • +
    • 旧資料の Semgrep 延期: 歴史的サンプルの指摘を M2/M3 へ延期する記録について、明示的に承認または却下してください。Semgrep 例外が残る領域も、公開方針検査は対象に含めます。
    • +
    +

    r3 はコード修正を要求しません。調整担当にはレビュー記録の取り込みと所有者判断の整理が残ります。レビュワはコミット、push、承認、マージを行っていません。

    +
    +

    Glossary / 用語

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    TermEnglish note日本語注
    PRA proposed change awaiting review.レビューを求める変更提案。
    CIAutomatic checks of changes.変更の自動検査。
    Exit codeThe number a program returns on completion.処理終了時に返す結果の数。
    JSON / TOONText formats for structured data.構造化データを文字で書く形式。
    MCA named manifest-validation rule.manifest 検査規則の識別子。
    Anchor / fragmentA page bookmark and the link suffix naming it.ページ内のしおりと、その場所を指すリンク末尾。
    SHAA revision fingerprint.版を識別する指紋。
    TracebackAn internal error's call history.内部エラーの呼出し履歴。
    BootstrapThe first construction before routine updates.通常更新を始める前の初回構築。
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    + + + + + + + + + + + + + + \ No newline at end of file diff --git a/site/reviews/2026-11-05_RDM-osf.io-dev2027_PR1_Public_Develop_Merge_r1/index.html b/site/reviews/2026-11-05_RDM-osf.io-dev2027_PR1_Public_Develop_Merge_r1/index.html index c6056e1..33b5498 100644 --- a/site/reviews/2026-11-05_RDM-osf.io-dev2027_PR1_Public_Develop_Merge_r1/index.html +++ b/site/reviews/2026-11-05_RDM-osf.io-dev2027_PR1_Public_Develop_Merge_r1/index.html @@ -9,7 +9,7 @@ - + @@ -1918,6 +1918,27 @@ + + +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + diff --git a/site/reviews/2026-11-05_RDM-osf.io-dev2027_PR1_Public_Develop_Merge_r2/index.html b/site/reviews/2026-11-05_RDM-osf.io-dev2027_PR1_Public_Develop_Merge_r2/index.html index 368d23b..3db7eb1 100644 --- a/site/reviews/2026-11-05_RDM-osf.io-dev2027_PR1_Public_Develop_Merge_r2/index.html +++ b/site/reviews/2026-11-05_RDM-osf.io-dev2027_PR1_Public_Develop_Merge_r2/index.html @@ -1920,6 +1920,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/reviews/index.html b/site/reviews/index.html index b88b307..d0dca5f 100644 --- a/site/reviews/index.html +++ b/site/reviews/index.html @@ -2071,6 +2071,27 @@ +
  • + + + + + REV M1 Skeleton PR Review r3 / REV(担当レビュワ)M1 文書骨格 PR 再レビュー r3 + + + + +
  • + + + + + + + + + +
  • diff --git a/site/search/search_index.json b/site/search/search_index.json index 0ceba46..c4f5928 100644 --- a/site/search/search_index.json +++ b/site/search/search_index.json @@ -1 +1 @@ -{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Documentation Index / \u6587\u66f8\u7d22\u5f15","text":"

    Summary: The index of all documents in this repository: policies (our position), specifications (rules to implement), decisions (why we chose), demos (records of what was actually done), status (milestone progress), hand-offs (requests to other teams), reviews (review records), and reference (external facts). A Mermaid diagram shows how a change flows through the process. \u6982\u8981: \u3053\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u3059\u3079\u3066\u306e\u6587\u66f8\u306e\u7d22\u5f15\u3002\u65b9\u91dd\uff08\u79c1\u305f\u3061\u306e\u7acb\u5834\uff09\u3001\u4ed5\u69d8\uff08\u5b9f\u88c5\u3059\u308b\u30eb\u30fc\u30eb\uff09\u3001\u6c7a\u5b9a\uff08\u306a\u305c\u9078\u3093\u3060\u304b\uff09\u3001\u5b9f\u8a3c\uff08\u5b9f\u969b\u306b\u3084\u3063\u305f\u3053\u3068\u306e\u8a18\u9332\uff09\u3001\u9032\u6357\uff08\u7bc0\u76ee\u306e\u9032\u884c\u72b6\u6cc1\uff09\u3001\u5f15\u7d99\u304e\uff08\u4ed6\u306e\u30c1\u30fc\u30e0\u3078\u306e\u4f9d\u983c\uff09\u3001\u30ec\u30d3\u30e5\u30fc\uff08\u30ec\u30d3\u30e5\u30fc\u8a18\u9332\uff09\u3001\u53c2\u8003\uff08\u5916\u90e8\u4e8b\u5b9f\uff09\u3002Mermaid \u56f3\u306f\u3001\u5909\u66f4\u304c\u30d7\u30ed\u30bb\u30b9\u3092\u901a\u308b\u6d41\u308c\u3092\u793a\u3057\u307e\u3059\u3002

    Jump: English \u00b7 \u65e5\u672c\u8a9e

    • Version / \u7248: 0.1 \u2014 2026-11-05. Learned: without a single index page, it was unclear which folder to check for the latest milestone status or review records; putting everything in one place makes the documentation tree navigable. \uff0f \u5358\u4e00\u306e\u7d22\u5f15\u30da\u30fc\u30b8\u304c\u7121\u3051\u308c\u3070\u3001\u6700\u65b0\u306e\u7bc0\u76ee\u9032\u6357\u3084\u30ec\u30d3\u30e5\u30fc\u8a18\u9332\u3092\u3069\u306e\u30d5\u30a9\u30eb\u30c0\u3067\u63a2\u3059\u3079\u304d\u304b\u5206\u304b\u3089\u305a\u3001\u6587\u66f8\u30c4\u30ea\u30fc\u306e\u30ca\u30d3\u30b2\u30fc\u30c8\u304c\u4e0d\u53ef\u80fd\u306b\u306a\u308b\u3068\u5206\u304b\u3063\u305f\u3002
    • Normative for: every document under docs/, especially README.md files.
    • Related: ../README.md \u00b7 site/index.html

    "},{"location":"#english","title":"English","text":"

    \u2192 \u65e5\u672c\u8a9e\u7248\u3078

    "},{"location":"#1-document-folders","title":"1. Document folders","text":"Folder Description policy/ Our position on what we will and will not do. Each document states our stance on a topic. spec/ Rules to implement: specifications, acceptance tests, security gate, installer CLI. decisions/ Decision records: why we chose one way and not another. demo/ Records of what was actually done: acceptance runs, integration test results. status/ Milestone progress: M1\u2013M5 status, open items, upstream tracking reports. handoff/ Requests to other teams: dated files, named YYYY-MM-DD_.md.</td> </tr> <tr> <td><a href=\"reviews/\">reviews/</a></td> <td>Review records: dated files, named YYYY-MM-DD_<Title>_rN.md.</td> </tr> <tr> <td><a href=\"reference/\">reference/</a></td> <td>External facts: glossary, tool versions, upstream metadata.</td> </tr> </tbody> </table> <h3 id=\"2-how-a-change-flows\">2. How a change flows<a class=\"headerlink\" href=\"#2-how-a-change-flows\" title=\"Permanent link\">\u00b6</a></h3> <pre class=\"mermaid\"><code>flowchart TD A[Demo / Acceptance run] --> B{Pass?} B -- yes --> C[Policy: position on the change] B -- no --> D[Policy: rejection reason] C --> E[Spec / ADR: rules to implement the change] D --> E E --> F[Code: implement the spec / decision] F --> G[Demos: acceptance run with new behavior] G --> H[Status: update milestone progress] H --> I[Hand-off: request review / merge if ready] I --> J[Reviews: independent assessment recorded] J --> K{Decision} K -- accept --> L[Merge to develop] K -- reject --> M[Return for fix]</code></pre> <h3 id=\"3-links\">3. Links<a class=\"headerlink\" href=\"#3-links\" title=\"Permanent link\">\u00b6</a></h3> <ul> <li><a href=\"../README.md\">../README.md</a> \u2014 Root index of the whole repository.</li> <li><a href=\"../site/index.html\">site/index.html</a> \u2014 HTML site built by MkDocs.</li> </ul> <hr /> <p><a id=\"japanese\"></a></p> <h2 id=\"\u65e5\u672c\u8a9e\">\u65e5\u672c\u8a9e<a class=\"headerlink\" href=\"#\u65e5\u672c\u8a9e\" title=\"Permanent link\">\u00b6</a></h2> <p><a href=\"#english\">\u2192 To English</a></p> <h3 id=\"1-\u6587\u66f8\u30d5\u30a9\u30eb\u30c0\">1. \u6587\u66f8\u30d5\u30a9\u30eb\u30c0<a class=\"headerlink\" href=\"#1-\u6587\u66f8\u30d5\u30a9\u30eb\u30c0\" title=\"Permanent link\">\u00b6</a></h3> <table> <thead> <tr> <th>\u30d5\u30a9\u30eb\u30c0</th> <th>\u8aac\u660e</th> </tr> </thead> <tbody> <tr> <td><a href=\"policy/\">policy/</a></td> <td>\u6211\u3005\u304c\u4f55\u3092\u3057\u3001\u4f55\u3092\u3057\u306a\u3044\u304b\u306e\u7acb\u5834\u3002\u5404\u6587\u66f8\u306f\u30c8\u30d4\u30c3\u30af\u306b\u95a2\u3059\u308b\u79c1\u305f\u3061\u306e\u59ff\u52e2\u3092\u8ff0\u3079\u307e\u3059\u3002</td> </tr> <tr> <td><a href=\"spec/\">spec/</a></td> <td>\u5b9f\u88c5\u3059\u308b\u30eb\u30fc\u30eb\uff1a\u4ed5\u69d8\u3001\u53d7\u5165\u8a66\u9a13\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u306e\u9580\u3001\u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u30fc CLI\u3002</td> </tr> <tr> <td><a href=\"decisions/\">decisions/</a></td> <td>\u6c7a\u5b9a\u306e\u8a18\u9332\uff1a\u306a\u305c\u305d\u306e\u9053\u3092\u9078\u3073\u3001\u307b\u304b\u3092\u9078\u3070\u306a\u304b\u3063\u305f\u304b\u3002</td> </tr> <tr> <td><a href=\"demo/\">demo/</a></td> <td>\u5b9f\u969b\u306b\u3084\u3063\u305f\u3053\u3068\u306e\u8a18\u9332\uff1a\u53d7\u5165\u8a66\u9a13\u3001\u7d71\u5408\u8a66\u9a13\u7d50\u679c\u3002</td> </tr> <tr> <td><a href=\"status/\">status/</a></td> <td>\u7bc0\u76ee\u306e\u9032\u884c\u72b6\u6cc1\uff1aM1\u301cM5 \u306e\u9032\u6357\u3001\u672a\u89e3\u6c7a\u9805\u76ee\u3001\u4e0a\u6d41\u8ffd\u5f93\u5831\u544a\u3002</td> </tr> <tr> <td><a href=\"handoff/\">handoff/</a></td> <td>\u4ed6\u306e\u30c1\u30fc\u30e0\u3078\u306e\u4f9d\u983c\uff1a\u65e5\u4ed8\u4ed8\u304d\u30d5\u30a1\u30a4\u30eb\u3001YYYY-MM-DD_<Title>.md \u306e\u5f62\u5f0f\u3002</td> </tr> <tr> <td><a href=\"reviews/\">reviews/</a></td> <td>\u30ec\u30d3\u30e5\u30fc\u8a18\u9332\uff1a\u65e5\u4ed8\u4ed8\u304d\u30d5\u30a1\u30a4\u30eb\u3001YYYY-MM-DD_<Title>_rN \u306e\u5f62\u5f0f\u3002</td> </tr> <tr> <td><a href=\"reference/\">reference/</a></td> <td>\u5916\u90e8\u4e8b\u5b9f\uff1a\u7528\u8a9e\u96c6\u3001\u9053\u5177\u306e\u7248\u3001\u4e0a\u6d41\u30e1\u30bf\u30c7\u30fc\u30bf\u3002</td> </tr> </tbody> </table> <h3 id=\"2-\u5909\u66f4\u304c\u6d41\u308c\u308b\u6d41\u308c\">2. \u5909\u66f4\u304c\u6d41\u308c\u308b\u6d41\u308c<a class=\"headerlink\" href=\"#2-\u5909\u66f4\u304c\u6d41\u308c\u308b\u6d41\u308c\" title=\"Permanent link\">\u00b6</a></h3> <pre class=\"mermaid\"><code>flowchart TD A[\u5b9f\u8a3c\uff0f\u53d7\u5165\u8a66\u9a13] --> B{\u5408\u683c?} B -- \u306f\u3044 --> C[\u65b9\u91dd\uff1a\u5909\u66f4\u306b\u95a2\u3059\u308b\u7acb\u5834] B -- \u3044\u3044\u3048 --> D[\u65b9\u91dd\uff1a\u62d2\u5426\u7406\u7531] C --> E[\u4ed5\u69d8\uff0fADR\uff1a\u5909\u66f4\u3092\u5b9f\u88c5\u3059\u308b\u30eb\u30fc\u30eb] D --> E E --> F[\u30b3\u30fc\u30c9\uff1aspec/ADR \u3092\u5b9f\u88c5] F --> G[\u5b9f\u8a3c\uff1a\u65b0\u3057\u3044\u52d5\u4f5c\u3067\u306e\u53d7\u5165\u8a66\u9a13] G --> H[\u9032\u6357\uff1a\u7bc0\u76ee\u306e\u9032\u884c\u72b6\u6cc1\u3092\u66f4\u65b0] H --> I[\u5f15\u7d99\u304e\uff1a\u30ec\u30d3\u30e5\u30fc\uff0f\u30de\u30fc\u30b8\u306e\u4f9d\u983c] I --> J[\u30ec\u30d3\u30e5\u30fc\uff1a\u72ec\u7acb\u3057\u305f\u8a55\u4fa1\u3092\u8a18\u9332] J --> K{\u6c7a\u5b9a} K -- \u627f\u8a8d --> L[develop \u3078\u30de\u30fc\u30b8] K -- \u62d2\u5426 --> M[\u4fee\u6b63\u306e\u305f\u3081\u306b\u623b\u3059]</code></pre> <h3 id=\"3-\u30ea\u30f3\u30af\">3. \u30ea\u30f3\u30af<a class=\"headerlink\" href=\"#3-\u30ea\u30f3\u30af\" title=\"Permanent link\">\u00b6</a></h3> <ul> <li><a href=\"../README.md\">../README.md</a> \u2014 \u30ea\u30dd\u30b8\u30c8\u30ea\u5168\u4f53\u306e\u30eb\u30fc\u30c8\u7d22\u5f15\u3002</li> <li><a href=\"../site/index.html\">site/index.html</a> \u2014 MkDocs \u304c\u751f\u6210\u3059\u308b HTML \u30b5\u30a4\u30c8\u3002</li> </ul> <hr /> <h2 id=\"glossary--\u7528\u8a9e\">Glossary / \u7528\u8a9e<a class=\"headerlink\" href=\"#glossary--\u7528\u8a9e\" title=\"Permanent link\">\u00b6</a></h2> <table> <thead> <tr> <th>Term</th> <th>English note</th> <th>\u65e5\u672c\u8a9e\u6ce8</th> </tr> </thead> <tbody> <tr> <td>Policy</td> <td>A statement of our position on what we will and will not do.</td> <td>\u6211\u3005\u304c\u4f55\u3092\u3057\u3001\u4f55\u3092\u3057\u306a\u3044\u304b\u306e\u7acb\u5834\u3002</td> </tr> <tr> <td>Specification</td> <td>A rule book that implementers must follow.</td> <td>\u5b9f\u88c5\u3059\u308b\u4eba\u304c\u5b88\u308b\u30eb\u30fc\u30eb\u30d6\u30c3\u30af\u3002</td> </tr> <tr> <td>Decision record (ADR)</td> <td>A note explaining why we chose one way and not another.</td> <td>\u306a\u305c\u305d\u306e\u9053\u3092\u9078\u3073\u3001\u307b\u304b\u3092\u9078\u3070\u306a\u304b\u3063\u305f\u304b\u306e\u30e1\u30e2\u3002</td> </tr> <tr> <td>Demo</td> <td>Records of what was actually done, including acceptance runs.</td> <td>\u5b9f\u969b\u306b\u3084\u3063\u305f\u3053\u3068\u306e\u8a18\u9332\u3001\u53d7\u5165\u8a66\u9a13\u3092\u542b\u3080\u3002</td> </tr> <tr> <td>Milestone</td> <td>A checkpoint with a pass/fail test.</td> <td>\u5408\u5426\u306e\u8a66\u9a13\u304c\u3042\u308b\u95a2\u9580\u3002</td> </tr> <tr> <td>Hand-off</td> <td>A request to another team or agent.</td> <td>\u4ed6\u306e\u30c1\u30fc\u30e0\u30fb\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u3078\u306e\u4f9d\u983c\u3002</td> </tr> <tr> <td>Review</td> <td>An independent assessment of a pull request.</td> <td>\u30d7\u30eb\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u72ec\u7acb\u3057\u305f\u8a55\u4fa1\u3002</td> </tr> <tr> <td>Reference</td> <td>External facts such as glossaries, tool versions.</td> <td>\u7528\u8a9e\u96c6\u3084\u9053\u5177\u306e\u7248\u306a\u3069\u306e\u5916\u90e8\u4e8b\u5b9f\u3002</td> </tr> </tbody> </table>"},{"location":"assets/","title":"Site Assets / \u30b5\u30a4\u30c8\u7528\u306e\u90e8\u54c1","text":"

    Summary: Third-party and local files that the MkDocs site loads. Kept in the repository so the HTML version works without any external network. \u6982\u8981: MkDocs \u306e\u30b5\u30a4\u30c8\u304c\u8aad\u307f\u8fbc\u3080\u5916\u90e8\u30fb\u81ea\u4f5c\u306e\u30d5\u30a1\u30a4\u30eb\u3002\u5916\u90e8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306a\u3057\u3067 HTML \u7248\u304c\u52d5\u304f\u3088\u3046\u3001\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u540c\u68b1\u3059\u308b\u3002

    Jump: English \u00b7 \u65e5\u672c\u8a9e

    • Version / \u7248: 0.1 \u2014 2026-11-05. Learned: loading Mermaid from a CDN made every generated page depend on an external host (Semgrep flagged 43 pages for missing integrity), so the library is vendored here instead. \uff0f Mermaid \u3092 CDN \u304b\u3089\u8aad\u307f\u8fbc\u3080\u3068\u751f\u6210\u30da\u30fc\u30b8\u5168\u90e8\u304c\u5916\u90e8\u30db\u30b9\u30c8\u306b\u4f9d\u5b58\u3059\u308b\uff08Semgrep \u304c 43 \u30da\u30fc\u30b8\u3092 integrity \u6b20\u843d\u3068\u3057\u3066\u691c\u51fa\uff09\u3068\u5206\u304b\u308a\u3001\u3053\u3053\u306b\u540c\u68b1\u306b\u5909\u3048\u305f\u3002
    • Related: docs/README.md \u00b7 SPEC-06 \u00a74

    "},{"location":"assets/#english","title":"English","text":"

    \u2192 \u65e5\u672c\u8a9e\u7248\u3078

    File Origin License Note mermaid.min.js mermaid 11.4.1, https://unpkg.com/mermaid@11.4.1/dist/mermaid.min.js MIT Draws diagrams written as text (Mermaid). Do not edit. Update by replacing the file and this row. mermaid-init.js written here MIT (this repository) Starts Mermaid on page load.

    "},{"location":"assets/#\u65e5\u672c\u8a9e","title":"\u65e5\u672c\u8a9e","text":"

    \u2192 To English

    \u30d5\u30a1\u30a4\u30eb \u51fa\u6240 \u30e9\u30a4\u30bb\u30f3\u30b9 \u5099\u8003 mermaid.min.js mermaid 11.4.1\u3001https://unpkg.com/mermaid@11.4.1/dist/mermaid.min.js MIT \u6587\u5b57\u3067\u66f8\u3044\u305f\u56f3\uff08Mermaid\uff09\u3092\u63cf\u304f\u3002\u7de8\u96c6\u3057\u306a\u3044\u3002\u66f4\u65b0\u306f\u30d5\u30a1\u30a4\u30eb\u3068\u3053\u306e\u884c\u3092\u5dee\u3057\u66ff\u3048\u308b\u3002 mermaid-init.js \u672c\u30ea\u30dd\u30b8\u30c8\u30ea\u3067\u4f5c\u6210 MIT\uff08\u672c\u30ea\u30dd\u30b8\u30c8\u30ea\uff09 \u30da\u30fc\u30b8\u8aad\u307f\u8fbc\u307f\u6642\u306b Mermaid \u3092\u8d77\u52d5\u3059\u308b\u3002"},{"location":"decisions/","title":"Decision Records / \u6c7a\u5b9a\u306e\u8a18\u9332","text":"

    Summary: Documents explaining why we chose one way and not another: integration repository placement, network model, staged security gate, AI autonomy and roles. Each record captures the context, options considered, and final decision. \u6982\u8981: \u306a\u305c\u305d\u306e\u9053\u3092\u9078\u3073\u3001\u307b\u304b\u3092\u9078\u3070\u306a\u304b\u3063\u305f\u304b\u3092\u8aac\u660e\u3059\u308b\u6587\u66f8\uff1a\u7d71\u5408\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u7f6e\u304d\u5834\u3001\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u65b9\u5f0f\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u9580\u306e\u6bb5\u968e\u5316\u3001AI \u306e\u81ea\u5f8b\u5ea6\u3068\u5f79\u5272\u3002\u5404\u8a18\u9332\u306f\u6587\u8108\u3001\u691c\u8a0e\u3057\u305f\u9078\u629e\u80a2\u3001\u6700\u7d42\u6c7a\u5b9a\u3092\u6349\u3048\u307e\u3059\u3002

    Jump: English \u00b7 \u65e5\u672c\u8a9e

    • Version / \u7248: 0.1 \u2014 2026-11-05. Learned: writing decisions as records turned subjective choices into objective, reviewable documents that explain the reasoning behind each rule. \uff0f \u6c7a\u5b9a\u3092\u8a18\u9332\u3068\u3057\u3066\u6b8b\u3059\u3053\u3068\u3067\u3001\u4e3b\u89b3\u7684\u306a\u9078\u629e\u3092\u5ba2\u89b3\u7684\u3067\u30ec\u30d3\u30e5\u30fc\u53ef\u80fd\u306a\u6587\u66f8\u306b\u3057\u3001\u5404\u30eb\u30fc\u30eb\u306e\u80cc\u5f8c\u306b\u3042\u308b\u63a8\u8ad6\u3092\u8aac\u660e\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u3068\u5206\u304b\u3063\u305f\u3002
    • Normative for: ADR-01 Integration Repository Placement through ADR-04 AI Autonomy and Roles.
    • Related: ../README.md \u00b7 policy/ \u00b7 spec/ \u00b7 reference/REF-01_Glossary.md

    "},{"location":"decisions/#english","title":"English","text":"

    \u2192 \u65e5\u672c\u8a9e\u7248\u3078

    "},{"location":"decisions/#1-what-belongs-here","title":"1. What belongs here","text":"

    A decision record (ADR) explains why we chose one way and not another. This folder contains:

    ID File Purpose ADR-01 ADR-01_Integration_Repository_Placement.md Where integration code lives: new private repos, not in this public repo. ADR-02 ADR-02_Network_Model.md Drop loopback alias 192.168.168.167; use Compose internal network and 127.0.0.1 only. ADR-03 ADR-03_Staged_Security_Gate.md Gate starts as report-only at M1, becomes zero CRITICAL/HIGH plus red team pass at M5. ADR-04 ADR-04_AI_Autonomy_and_Roles.md AI detects, fixes, reviews, tests; humans merge and publish.

    Future decision records may cover:

    Topic Description ADR-05 Repository branching strategy ADR-06 Tool version policy (Docker, Python, Node.js) ADR-07 Open source license compatibility"},{"location":"decisions/#2-creating-a-new-decision-record","title":"2. Creating a new decision record","text":"
    1. Name the file ADR-NN_<Title>.md (two-digit number, next available).
    2. Follow SPEC-06 documentation conventions.
    3. Include: context, options considered (use TOON if multiple), decision, rationale.
    4. Link to related policies and specifications.
    5. The owner approves.
    "},{"location":"decisions/#3-how-decision-records-relate-to-other-documents","title":"3. How decision records relate to other documents","text":"
    flowchart TD\n    P[Policy: position] --> A[Decision record: why we chose this]\n    S[Spec: rules to implement] --> A\n    A --> C[Code: implement the rule]
    "},{"location":"decisions/#\u65e5\u672c\u8a9e","title":"\u65e5\u672c\u8a9e","text":"

    \u2192 To English

    "},{"location":"decisions/#1-\u3053\u3053\u306b\u5c5e\u3059\u308b\u3082\u306e","title":"1. \u3053\u3053\u306b\u5c5e\u3059\u308b\u3082\u306e","text":"

    \u300c\u6c7a\u5b9a\u306e\u8a18\u9332\u300d\uff08ADR\uff09\u306f\u3001\u306a\u305c\u305d\u306e\u9053\u3092\u9078\u3073\u3001\u307b\u304b\u3092\u9078\u3070\u306a\u304b\u3063\u305f\u304b\u3092\u8aac\u660e\u3059\u308b\u6587\u66f8\u3067\u3059\u3002\u3053\u306e\u30d5\u30a9\u30eb\u30c0\u306b\u306f\u6b21\u304c\u542b\u307e\u308c\u307e\u3059\uff1a

    ID \u30d5\u30a1\u30a4\u30eb \u76ee\u7684 ADR-01 ADR-01_Integration_Repository_Placement.md \u7d71\u5408\u30b3\u30fc\u30c9\u306e\u7f6e\u304d\u5834\uff1a\u65b0\u8a2d\u975e\u516c\u958b\u30ea\u30dd\u30b8\u30c8\u30ea\u3001\u3053\u306e\u516c\u958b\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u306f\u7f6e\u304b\u306a\u3044\u3002 ADR-02 ADR-02_Network_Model.md \u30eb\u30fc\u30d7\u30d0\u30c3\u30af\u5225\u540d 192.168.168.167 \u3092\u5ec3\u6b62\uff1bCompose \u5185\u90e8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3068 127.0.0.1 \u306e\u307f\u3092\u4f7f\u3046\u3002 ADR-03 ADR-03_Staged_Security_Gate.md \u9580\u306f M1 \u3067\u306f\u5831\u544a\u306e\u307f\u3001M5 \u3067 CRITICAL/HIGH \u30bc\u30ed\uff0b\u30ec\u30c3\u30c9\u30c1\u30fc\u30e0\u5408\u683c\u3078\u3002 ADR-04 ADR-04_AI_Autonomy_and_Roles.md AI \u306f\u691c\u51fa\u30fb\u4fee\u6b63\u30fb\u30ec\u30d3\u30e5\u30fc\u30fb\u8a66\u9a13\uff1b\u4eba\u306f\u30de\u30fc\u30b8\u3068\u516c\u958b\u3002

    \u4eca\u5f8c\u306e\u6c7a\u5b9a\u8a18\u9332\u3068\u3057\u3066\u4ee5\u4e0b\u304c\u8003\u3048\u3089\u308c\u307e\u3059\uff1a

    \u30c8\u30d4\u30c3\u30af \u8aac\u660e ADR-05 \u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u30d6\u30e9\u30f3\u30c1\u6226\u7565 ADR-06 \u9053\u5177\u7248\u65b9\u91dd\uff08Docker\u3001Python\u3001Node.js\uff09 ADR-07 \u30aa\u30fc\u30d7\u30f3\u30bd\u30fc\u30b9\u30e9\u30a4\u30bb\u30f3\u30b9\u306e\u4e92\u63db\u6027"},{"location":"decisions/#2-\u65b0\u3057\u3044\u6c7a\u5b9a\u8a18\u9332\u3092\u3064\u304f\u308b\u306b\u306f","title":"2. \u65b0\u3057\u3044\u6c7a\u5b9a\u8a18\u9332\u3092\u3064\u304f\u308b\u306b\u306f","text":"
    1. \u30d5\u30a1\u30a4\u30eb\u540d\u3092 ADR-NN_<\u984c>.md\uff082 \u6841\u306e\u756a\u53f7\u3001\u6b21\u306b\u7a7a\u3044\u3066\u3044\u308b\u3082\u306e\uff09\u306b\u3059\u308b\u3002
    2. SPEC-06 \u6587\u66f8\u898f\u7d04\u306b\u5f93\u3046\u3002
    3. \u6587\u8108\u3001\u691c\u8a0e\u3057\u305f\u9078\u629e\u80a2\uff08\u8907\u6570\u3042\u308b\u5834\u5408\u306f TOON \u4f7f\u7528\uff09\u3001\u6c7a\u5b9a\u3001\u7406\u7531\u3092\u542b\u3080\u3002
    4. \u95a2\u9023\u3059\u308b\u65b9\u91dd\u3068\u4ed5\u69d8\u3078\u30ea\u30f3\u30af\u3059\u308b\u3002
    5. \u6240\u6709\u8005\u304c\u627f\u8a8d\u3002
    "},{"location":"decisions/#3-\u6c7a\u5b9a\u8a18\u9332\u304c\u4ed6\u306e\u6587\u66f8\u3068\u3069\u3046\u95a2\u4fc2\u3059\u308b\u304b","title":"3. \u6c7a\u5b9a\u8a18\u9332\u304c\u4ed6\u306e\u6587\u66f8\u3068\u3069\u3046\u95a2\u4fc2\u3059\u308b\u304b","text":"
    flowchart TD\n    P[\u65b9\u91dd\uff1a\u7acb\u5834] --> A[\u6c7a\u5b9a\u306e\u8a18\u9332\uff1a\u306a\u305c\u3053\u306e\u9053\u3092\u9078\u3093\u3060\u304b]\n    S[\u4ed5\u69d8\uff1a\u5b9f\u88c5\u3059\u308b\u30eb\u30fc\u30eb] --> A\n    A --> C[\u30b3\u30fc\u30c9\uff1a\u30eb\u30fc\u30eb\u3092\u5b9f\u88c5]
    "},{"location":"decisions/#glossary--\u7528\u8a9e","title":"Glossary / \u7528\u8a9e","text":"Term English note \u65e5\u672c\u8a9e\u6ce8 Decision record (ADR) A note explaining why we chose one way and not another. \u306a\u305c\u305d\u306e\u9053\u3092\u9078\u3073\u3001\u307b\u304b\u3092\u9078\u3070\u306a\u304b\u3063\u305f\u304b\u306e\u30e1\u30e2\u3002 Context The problem or situation that requires a decision. \u6c7a\u5b9a\u3092\u5fc5\u8981\u3068\u3059\u308b\u554f\u984c\u3084\u72b6\u6cc1\u3002 Options considered The alternatives evaluated before choosing one. \u9078\u629e\u3059\u308b\u524d\u306b\u8a55\u4fa1\u3057\u305f\u4ee3\u66ff\u6848\u3002 Rationale The reasoning behind the final decision. \u6700\u7d42\u6c7a\u5b9a\u306e\u80cc\u5f8c\u306b\u3042\u308b\u63a8\u8ad6\u3002 Policy A statement of our position on what we will and will not do. \u6211\u3005\u304c\u4f55\u3092\u3057\u3001\u4f55\u3092\u3057\u306a\u3044\u304b\u306e\u7acb\u5834\u3002"},{"location":"decisions/ADR-01_Integration_Repository_Placement/","title":"ADR-01 Integration Repository Placement / \u7d71\u5408\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u7f6e\u304d\u5834","text":"

    Summary: Where the code that combines the public cores, the -private security versions and the subsystems is kept: new private repositories RDM-<name>-dev2027 inside RCOSDP, with a develop integration branch and upstream/* tracking branches, never in this public repository. \u6982\u8981: \u516c\u958b\u30b3\u30a2\u30fb-private \u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u7248\u30fb\u30b5\u30d6\u30b7\u30b9\u30c6\u30e0\u3092\u91cd\u306d\u305f\u30b3\u30fc\u30c9\u3092\u3069\u3053\u306b\u7f6e\u304f\u304b\u3002RCOSDP \u5185\u306b\u65b0\u8a2d\u3059\u308b\u975e\u516c\u958b\u30ea\u30dd\u30b8\u30c8\u30ea RDM-<name>-dev2027 \u306b\u7f6e\u304d\u3001develop \u3092\u7d71\u5408\u30d6\u30e9\u30f3\u30c1\u3001upstream/* \u3092\u8ffd\u8de1\u30d6\u30e9\u30f3\u30c1\u3068\u3059\u308b\u3002\u516c\u958b\u306e\u3053\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u306f\u7f6e\u304b\u306a\u3044\u3002

    Jump: English \u00b7 \u65e5\u672c\u8a9e

    • Version / \u7248: 0.2 \u2014 2026-11-05. Learned: the first construction of a -dev2027 repository cannot literally replay \"public \u2192 private \u2192 adopted PRs\", so the rule needs a stated bootstrap interpretation; it is proposed in \u00a75 and awaits the owner. \uff0f -dev2027 \u306e\u521d\u56de\u69cb\u7bc9\u3067\u306f\u300c\u516c\u958b \u2192 private \u2192 \u63a1\u7528 PR\u300d\u3092\u6587\u5b57\u3069\u304a\u308a\u518d\u73fe\u3067\u304d\u306a\u3044\u305f\u3081\u3001\u521d\u56de\u69cb\u7bc9\u306e\u89e3\u91c8\u3092\u660e\u6587\u5316\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3068\u5206\u304b\u3063\u305f\u3002\u00a75 \u306b\u63d0\u6848\u3057\u6240\u6709\u8005\u306e\u627f\u8a8d\u3092\u5f85\u3064\u3002 0.1 \u2014 2026-11-05. Learned: GitHub refuses a fork inside the same organization, so \"fork and integrate\" had to become \"new repository with history pushed\", and that in turn made the no-force-push and no-delete rules the only way to keep the pushed history trustworthy. \uff0f GitHub \u306f\u540c\u3058\u7d44\u7e54\u5185\u3078\u306e\u30d5\u30a9\u30fc\u30af\u3092\u8a31\u3055\u306a\u3044\u305f\u3081\u300c\u30d5\u30a9\u30fc\u30af\u3057\u3066\u7d71\u5408\u300d\u306f\u300c\u5c65\u6b74\u3092 push \u3057\u305f\u65b0\u898f\u30ea\u30dd\u30b8\u30c8\u30ea\u300d\u306b\u306a\u308a\u3001\u305d\u306e\u7d50\u679c force push \u7981\u6b62\u3068\u524a\u9664\u7981\u6b62\u304c\u3001push \u3057\u305f\u5c65\u6b74\u3092\u4fe1\u3058\u3089\u308c\u308b\u3082\u306e\u306b\u4fdd\u3064\u552f\u4e00\u306e\u624b\u6bb5\u3060\u3068\u5206\u304b\u3063\u305f\u3002
    • Status: Accepted by the owner, 2026-11-05 (plan-interview).
    • Records a decision for: POL-01 \u00a72 item 5 \u00b7 SPEC-01 Manifest \u00b7 SPEC-05 Upstream Tracking
    • Related: docs/README.md \u00b7 SPEC-00 Overview \u00b7 ADR-02 Network Model \u00b7 ADR-04 AI Autonomy and Roles \u00b7 REF-01 Glossary

    "},{"location":"decisions/ADR-01_Integration_Repository_Placement/#english","title":"English","text":"

    \u2192 \u65e5\u672c\u8a9e\u7248\u3078

    "},{"location":"decisions/ADR-01_Integration_Repository_Placement/#1-context","title":"1. Context","text":"

    A decision record (ADR) explains why we chose one way and not another. This one is about where the integration code lives.

    We must combine, without contradiction, three groups of code kept in GitHub repositories (folders that remember every change):

    • six public cores: RDM-osf.io, RDM-waterbutler, RDM-modular-file-renderer, RDM-ember-osf-web, RDM-cas-overlay, RDM-wiki-frontend;
    • six -private security-verified versions, each of which already contains the history of its public core (so it is a superset, not a rival);
    • five private subsystems: y-websocket, OASys, Shibboleth-SP, rdmcp, aipf_mcp_data_grdm.

    Three constraints shaped the choice:

    1. Same-organization forks are impossible. On GitHub a fork (your own copy of someone's repository that remembers where it came from) cannot be created inside the same organization that owns the original. All these repositories are in RCOSDP, so a plain fork is unavailable.
    2. Write boundary. The agents on this plan may write only to this repository (RDM-developer-guide) and to repositories they create. Existing repositories, including the -private ones, are read-only to us. Deleting a repository or branch and force-pushing (overwriting shared history) are forbidden.
    3. This repository is public. Members abroad read it. Anything derived from -private code \u2014 files, patches, even URLs of private repositories \u2014 must not appear here.
    "},{"location":"decisions/ADR-01_Integration_Repository_Placement/#2-options-considered","title":"2. Options considered","text":"
    options[4]{id,option,keeps_private_code_private,within_write_boundary,upstream_follow_cost,verdict}:\n  A,\"New private repositories RDM-<name>-dev2027 in RCOSDP, history pushed, develop = integration, upstream/* tracking\",yes,yes,low,chosen\n  B,\"Fork to a personal GitHub account\",no,yes,low,rejected\n  C,\"Keep patches inside this public repository and apply at install time\",no,yes,high,rejected\n  D,\"Use the -private repositories directly as the canon and integrate there\",yes,no,low,rejected
    • B puts code derived from private sources under a personal account, outside the organization's access control. Rejected.
    • C keeps a pile of patches (small text files describing changes) that must be re-fitted every time an upstream repository moves; with eleven moving upstreams the conflicts arrive faster than they are solved, and any patch touching -private code would leak it into a public repository. Rejected.
    • D would be the simplest, but we are not allowed to write to the -private repositories, and integrating in them would mix verification work with security verification history. Rejected.
    "},{"location":"decisions/ADR-01_Integration_Repository_Placement/#3-decision","title":"3. Decision","text":"
    1. For each of the eleven upstream repositories, create a private repository in RCOSDP named RDM-<name>-dev2027 (for example RDM-osf.io-dev2027). Push the full history of the public core so that git log remains truthful and SHAs (fingerprints of commits) match upstream.
    2. Branches in each -dev2027 repository:
    3. develop \u2014 the integration branch; the only branch the installer builds from (its SHA is recorded in the manifest, see SPEC-01);
    4. one tracking branch per upstream listed in the manifest, named upstream/<kind>-<branch> where <kind> is public, private, or cos and <branch> is the upstream branch name with / replaced by - (SPEC-01 \u00a74 rule 7);
    5. upstream/public-<branch> \u2014 an exact mirror (identical copy, refreshed automatically) of the public core's default branch: upstream/public-develop for osf.io, waterbutler, mfr, cas-overlay, wiki-frontend; upstream/public-master for ember-osf-web and y-websocket;
    6. upstream/private-<branch> \u2014 a mirror of the -private default branch: upstream/private-develop, upstream/private-master (ember-osf-web, y-websocket), or upstream/private-main (OASys, Shibboleth-SP, rdmcp, aipf_mcp_data_grdm, which have no public upstream and only this branch);
    7. upstream/cos-develop \u2014 a mirror of the CenterForOpenScience original, for reference only (not for wiki-frontend, which has no COS original);
    8. a second upstream of the same kind gets a tag: upstream/private-sec-test-fix-sec-test mirrors RDM-osf.io-private (branch fix/sec-test) as a candidate. Mirrors are refreshed daily (SPEC-05).
    9. Integration order on develop: public develop \u2192 -private \u2192 adopted pull requests (proposed changes waiting for review). Merged upstream changes are taken in full; unmerged PRs are adopted one by one, security and authentication first, and listed as candidates in the manifest.
    10. No force-push, no deletion. Conflicts are solved by new commits in a PR, never by rewriting history. Branches are archived with a tag rather than deleted.
    11. Nothing from a -dev2027 repository is copied into this public repository except names, branch names, SHAs, dates and PR numbers. Image builds from -private code go only to local Docker or to a private registry, never to a public one.
    flowchart TD\n  PUB[\"public core<br/>default branch\"] -->|daily mirror| UP1[\"upstream/public-<branch>\"]\n  PRV[\"-private<br/>default branch\"] -->|daily mirror| UP2[\"upstream/private-<branch>\"]\n  COS[\"CenterForOpenScience<br/>develop\"] -->|daily mirror| UP3[\"upstream/cos-develop\"]\n  UP1 -->|1. merge| DEV[\"develop (integration)\"]\n  UP2 -->|2. merge| DEV\n  PRS[\"adopted PRs<br/>(security, auth first)\"] -->|3. PR, Codex review| DEV\n  UP3 -.->|reference only| DEV\n  DEV -->|\"name + SHA\"| MAN[\"manifest/upstreams.json<br/>(public repository)\"]
    "},{"location":"decisions/ADR-01_Integration_Repository_Placement/#4-consequences","title":"4. Consequences","text":"
    • Good: one place per component where \"public + private + adopted PRs\" is resolved; the installer needs only a name and a SHA; daily mirrors keep diffs small; history is complete and auditable.
    • Good: the write boundary is respected without asking for new permissions on existing repositories.
    • Cost: eleven more repositories to watch. Mitigated by automation in SPEC-05 and the status board.
    • Cost: -dev2027 repositories are private, so GitHub Actions minutes and self-hosted runner usage count against the Team plan. Accepted.
    • Risk \u2014 leakage into this public repository. A single careless copy of a file, a stack trace or a URL from a -dev2027 or -private repository would publish private security work. Controls: secret scanning in CI is mandatory; reviewers check every PR to this repository for private paths and URLs; the manifest schema allows only names, branches, SHAs, dates and PR numbers; documents name private repositories but never link to them (SPEC-06 \u00a75).
    • Risk \u2014 drift between public and private cores. On 2026-11-05 the public RDM-osf.io develop was newer than its -private counterpart. The integration order (public first, then private) and daily mirrors make such drift visible as a merge, not as a silent overwrite.
    • Open: how to treat RDM-osf.io-private (branch fix/sec-test), which is distinct from RDM-osf.io-develop-private. It is mirrored as upstream/private-sec-test-fix-sec-test and listed in the manifest with status: candidate (SPEC-01 \u00a74 rule 6); the owner decides whether it is merged.
    "},{"location":"decisions/ADR-01_Integration_Repository_Placement/#5-bootstrap-interpretation-of-the-integration-order-proposed-awaiting-owner-approval","title":"5. Bootstrap interpretation of the integration order (proposed, awaiting owner approval)","text":"

    Status: proposed on 2026-11-05 after review r1/r2 of RDM-osf.io-dev2027 PR #1 (finding R2). Not yet approved by the owner.

    SPEC-01 \u00a74 fixes the integration order public \u2192 private \u2192 adopted PRs. The first construction of every -dev2027 repository did not replay that recipe: develop was seeded from the -private tip (which already contains the public history) and the newer public tip was then merged in as a normal two-parent merge. We propose to read the rule as follows:

    • Bootstrap (first construction): seeding develop from the -private tip and merging the newer public tip incrementally satisfies the rule, because the -private tip is a verified superset of the public history and the merge preserves both parents.
    • Steady state (weekly integration, SPEC-05): the literal order applies: merge upstream/public-*, then upstream/private-*, then re-apply adopted PRs.
    • Upstream history is never rewritten to make the bootstrap look like a literal replay.

    If the owner rejects this interpretation, the alternative is a strict reconstruction of each develop from the public tip, proposed as a separate change without force-push.

    "},{"location":"decisions/ADR-01_Integration_Repository_Placement/#\u65e5\u672c\u8a9e","title":"\u65e5\u672c\u8a9e","text":"

    \u2192 To English

    "},{"location":"decisions/ADR-01_Integration_Repository_Placement/#1-\u80cc\u666f","title":"1. \u80cc\u666f","text":"

    \u300c\u6c7a\u5b9a\u306e\u8a18\u9332\u300d\uff08ADR\uff09\u306f\u3001\u306a\u305c\u305d\u306e\u9053\u3092\u9078\u3073\u3001\u307b\u304b\u3092\u9078\u3070\u306a\u304b\u3063\u305f\u304b\u3092\u6b8b\u3059\u30e1\u30e2\u3067\u3059\u3002\u3053\u306e\u8a18\u9332\u306f\u3001\u7d71\u5408\u30b3\u30fc\u30c9\u3092\u3069\u3053\u306b\u7f6e\u304f\u304b\u306b\u3064\u3044\u3066\u306e\u3082\u306e\u3067\u3059\u3002

    GitHub \u306e\u300c\u30ea\u30dd\u30b8\u30c8\u30ea\u300d\uff08\u5909\u66f4\u3092\u5168\u90e8\u899a\u3048\u3066\u3044\u308b\u30d5\u30a9\u30eb\u30c0\uff09\u306b\u7f6e\u304b\u308c\u305f\u4e09\u3064\u306e\u7fa4\u306e\u30b3\u30fc\u30c9\u3092\u3001\u77db\u76fe\u306a\u304f\u91cd\u306d\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002

    • \u516c\u958b\u30b3\u30a2 6 \u672c: RDM-osf.io\u3001RDM-waterbutler\u3001RDM-modular-file-renderer\u3001RDM-ember-osf-web\u3001RDM-cas-overlay\u3001RDM-wiki-frontend\u3002
    • -private \u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u691c\u8a3c\u7248 6 \u672c\u3002\u3044\u305a\u308c\u3082\u5bfe\u5fdc\u3059\u308b\u516c\u958b\u30b3\u30a2\u306e\u5c65\u6b74\u3092\u542b\u3093\u3067\u3044\u308b\uff08\u3064\u307e\u308a\u5bfe\u7acb\u3067\u306f\u306a\u304f\u4e0a\u4f4d\u4e92\u63db\uff09\u3002
    • \u975e\u516c\u958b\u30b5\u30d6\u30b7\u30b9\u30c6\u30e0 5 \u672c: y-websocket\u3001OASys\u3001Shibboleth-SP\u3001rdmcp\u3001aipf_mcp_data_grdm\u3002

    \u9078\u629e\u3092\u6c7a\u3081\u305f\u5236\u7d04\u306f\u4e09\u3064\u3067\u3059\u3002

    1. \u540c\u3058\u7d44\u7e54\u5185\u3078\u306e\u30d5\u30a9\u30fc\u30af\u306f\u3067\u304d\u306a\u3044\u3002 GitHub \u306e\u300c\u30d5\u30a9\u30fc\u30af\u300d\uff08\u4ed6\u4eba\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u81ea\u5206\u7528\u306e\u5199\u3057\u3067\u3001\u51fa\u3069\u3053\u308d\u3092\u899a\u3048\u3066\u3044\u308b\u3082\u306e\uff09\u306f\u3001\u5143\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u6301\u3064\u7d44\u7e54\u306e\u4e2d\u306b\u306f\u4f5c\u308c\u307e\u305b\u3093\u3002\u5bfe\u8c61\u306f\u5168\u90e8 RCOSDP \u306b\u3042\u308b\u306e\u3067\u3001\u666e\u901a\u306e\u30d5\u30a9\u30fc\u30af\u306f\u4f7f\u3048\u307e\u305b\u3093\u3002
    2. \u66f8\u8fbc\u306e\u5883\u754c\u3002 \u3053\u306e\u8a08\u753b\u306e\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u304c\u66f8\u304d\u8fbc\u3081\u308b\u306e\u306f\u3001\u3053\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\uff08RDM-developer-guide\uff09\u3068\u81ea\u5206\u3067\u65b0\u8a2d\u3057\u305f\u30ea\u30dd\u30b8\u30c8\u30ea\u3060\u3051\u3067\u3059\u3002-private \u3092\u542b\u3080\u65e2\u5b58\u30ea\u30dd\u30b8\u30c8\u30ea\u306f\u8aad\u307f\u53d6\u308a\u5c02\u7528\u3067\u3059\u3002\u30ea\u30dd\u30b8\u30c8\u30ea\u3084\u30d6\u30e9\u30f3\u30c1\u306e\u524a\u9664\u3068\u300cforce push\u300d\uff08\u5171\u6709\u306e\u5c65\u6b74\u306e\u4e0a\u66f8\u304d\uff09\u306f\u7981\u6b62\u3067\u3059\u3002
    3. \u3053\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u306f\u516c\u958b\u3002 \u6d77\u5916\u306e\u30e1\u30f3\u30d0\u30fc\u304c\u8aad\u307f\u307e\u3059\u3002-private \u7531\u6765\u306e\u3082\u306e \u2014 \u30d5\u30a1\u30a4\u30eb\u3001\u30d1\u30c3\u30c1\u3001\u975e\u516c\u958b\u30ea\u30dd\u30b8\u30c8\u30ea\u306e URL \u307e\u3067 \u2014 \u3092\u3053\u3053\u306b\u51fa\u3057\u3066\u306f\u3044\u3051\u307e\u305b\u3093\u3002
    "},{"location":"decisions/ADR-01_Integration_Repository_Placement/#2-\u691c\u8a0e\u3057\u305f\u9078\u629e\u80a2","title":"2. \u691c\u8a0e\u3057\u305f\u9078\u629e\u80a2","text":"
    options[4]{id,option,keeps_private_code_private,within_write_boundary,upstream_follow_cost,verdict}:\n  A,\"RCOSDP \u5185\u306b\u975e\u516c\u958b\u306e RDM-<name>-dev2027 \u3092\u65b0\u8a2d\u3001\u5c65\u6b74\u3092 push\u3001develop = \u7d71\u5408\u3001upstream/* \u3067\u8ffd\u8de1\",yes,yes,low,\u63a1\u7528\n  B,\"\u500b\u4eba\u306e GitHub \u30a2\u30ab\u30a6\u30f3\u30c8\u3078\u30d5\u30a9\u30fc\u30af\",no,yes,low,\u4e0d\u63a1\u7528\n  C,\"\u516c\u958b\u306e\u3053\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u30d1\u30c3\u30c1\u3092\u540c\u68b1\u3057\u5c0e\u5165\u6642\u306b\u5f53\u3066\u308b\",no,yes,high,\u4e0d\u63a1\u7528\n  D,\"-private \u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u76f4\u63a5\u6b63\u672c\u306b\u3057\u3066\u305d\u3053\u3067\u7d71\u5408\",yes,no,low,\u4e0d\u63a1\u7528
    • B \u306f\u975e\u516c\u958b\u7531\u6765\u306e\u30b3\u30fc\u30c9\u3092\u3001\u7d44\u7e54\u306e\u30a2\u30af\u30bb\u30b9\u7ba1\u7406\u306e\u5916\u306b\u3042\u308b\u500b\u4eba\u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u4e0b\u306b\u51fa\u3057\u307e\u3059\u3002\u4e0d\u63a1\u7528\u3002
    • C \u306f\u300c\u30d1\u30c3\u30c1\u300d\uff08\u5909\u66f4\u5185\u5bb9\u3092\u66f8\u3044\u305f\u5c0f\u3055\u306a\u6587\u5b57\u30d5\u30a1\u30a4\u30eb\uff09\u306e\u5c71\u3092\u6301\u3061\u3001\u4e0a\u6d41\u304c\u52d5\u304f\u305f\u3073\u306b\u5f53\u3066\u76f4\u3059\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u300211 \u672c\u306e\u4e0a\u6d41\u304c\u52d5\u304f\u3068\u3001\u885d\u7a81\u306f\u89e3\u304f\u901f\u3055\u3088\u308a\u65e9\u304f\u5c4a\u304d\u307e\u3059\u3002\u3057\u304b\u3082 -private \u306b\u89e6\u308b\u30d1\u30c3\u30c1\u306f\u516c\u958b\u30ea\u30dd\u30b8\u30c8\u30ea\u3078\u306e\u6f0f\u3048\u3044\u306b\u306a\u308a\u307e\u3059\u3002\u4e0d\u63a1\u7528\u3002
    • D \u306f\u6700\u3082\u5358\u7d14\u3067\u3059\u304c\u3001-private \u30ea\u30dd\u30b8\u30c8\u30ea\u3078\u306e\u66f8\u8fbc\u306f\u8a31\u3055\u308c\u3066\u304a\u3089\u305a\u3001\u305d\u3053\u3067\u7d71\u5408\u3059\u308b\u3068\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u691c\u8a3c\u306e\u5c65\u6b74\u3068\u7d71\u5408\u4f5c\u696d\u304c\u6df7\u3056\u308a\u307e\u3059\u3002\u4e0d\u63a1\u7528\u3002
    "},{"location":"decisions/ADR-01_Integration_Repository_Placement/#3-\u6c7a\u5b9a","title":"3. \u6c7a\u5b9a","text":"
    1. \u4e0a\u6d41 11 \u672c\u305d\u308c\u305e\u308c\u306b\u3001RCOSDP \u5185\u306b \u975e\u516c\u958b \u306e\u30ea\u30dd\u30b8\u30c8\u30ea RDM-<name>-dev2027\uff08\u4f8b: RDM-osf.io-dev2027\uff09\u3092\u65b0\u8a2d\u3057\u307e\u3059\u3002\u516c\u958b\u30b3\u30a2\u306e\u5168\u5c65\u6b74\u3092 push \u3057\u3001git log \u304c\u672c\u5f53\u306e\u3053\u3068\u3092\u793a\u3057\u3001\u300cSHA\u300d\uff08\u30b3\u30df\u30c3\u30c8\u306e\u6307\u7d0b\uff09\u304c\u4e0a\u6d41\u3068\u4e00\u81f4\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002
    2. \u5404 -dev2027 \u306e\u30d6\u30e9\u30f3\u30c1:
    3. develop \u2014 \u7d71\u5408\u30d6\u30e9\u30f3\u30c1\u3002\u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u30fc\u304c\u7d44\u307f\u7acb\u3066\u308b\u552f\u4e00\u306e\u30d6\u30e9\u30f3\u30c1\uff08\u305d\u306e SHA \u3092 manifest \u306b\u8a18\u9332\u3002SPEC-01\uff09\u3002
    4. manifest \u306b\u8f09\u305b\u305f\u4e0a\u6d41\u3054\u3068\u306b\u4e00\u672c\u306e\u8ffd\u8de1\u30d6\u30e9\u30f3\u30c1\u3002\u540d\u524d\u306f upstream/<kind>-<branch> \u3067\u3001<kind> \u306f public\u30fbprivate\u30fbcos\u3001<branch> \u306f\u4e0a\u6d41\u306e\u30d6\u30e9\u30f3\u30c1\u540d\u306e / \u3092 - \u306b\u7f6e\u304d\u63db\u3048\u305f\u3082\u306e\uff08SPEC-01 \u00a74 \u306e\u898f\u5247 7\uff09\u3002
    5. upstream/public-<branch> \u2014 \u516c\u958b\u30b3\u30a2\u306e\u65e2\u5b9a\u30d6\u30e9\u30f3\u30c1\u306e\u6b63\u78ba\u306a\u300c\u30df\u30e9\u30fc\u300d\uff08\u81ea\u52d5\u3067\u66f4\u65b0\u3055\u308c\u308b\u540c\u4e00\u306e\u5199\u3057\uff09\u3002osf.io\u30fbwaterbutler\u30fbmfr\u30fbcas-overlay\u30fbwiki-frontend \u306f upstream/public-develop\u3001ember-osf-web \u3068 y-websocket \u306f upstream/public-master\u3002
    6. upstream/private-<branch> \u2014 -private \u306e\u65e2\u5b9a\u30d6\u30e9\u30f3\u30c1\u306e\u30df\u30e9\u30fc\u3002upstream/private-develop\u3001upstream/private-master\uff08ember-osf-web\u3001y-websocket\uff09\u3001\u307e\u305f\u306f upstream/private-main\uff08OASys\u3001Shibboleth-SP\u3001rdmcp\u3001aipf_mcp_data_grdm\u3002\u516c\u958b\u306e\u4e0a\u6d41\u304c\u306a\u3044\u306e\u3067\u3053\u306e\u4e00\u672c\u3060\u3051\uff09\u3002
    7. upstream/cos-develop \u2014 CenterForOpenScience \u672c\u5bb6\u306e\u30df\u30e9\u30fc\u3002\u53c2\u7167\u306e\u307f\uff08COS \u672c\u5bb6\u306e\u306a\u3044 wiki-frontend \u306b\u306f\u306a\u3044\uff09\u3002
    8. \u540c\u3058 kind \u306e\u4e8c\u3064\u76ee\u306e\u4e0a\u6d41\u306b\u306f\u30bf\u30b0\u3092\u631f\u3080\u3002upstream/private-sec-test-fix-sec-test \u306f RDM-osf.io-private\uff08\u30d6\u30e9\u30f3\u30c1 fix/sec-test\uff09\u3092\u5019\u88dc\u3068\u3057\u3066\u5199\u3057\u305f\u3082\u306e\u3002 \u30df\u30e9\u30fc\u306f\u65e5\u6b21\u3067\u66f4\u65b0\u3057\u307e\u3059\uff08SPEC-05\uff09\u3002
    9. develop \u3078\u306e\u7d71\u5408\u9806: \u516c\u958b develop \u2192 -private \u2192 \u63a1\u7528\u3057\u305f\u300c\u30d7\u30eb\u30ea\u30af\u30a8\u30b9\u30c8\u300d\uff08\u30ec\u30d3\u30e5\u30fc\u5f85\u3061\u306e\u5909\u66f4\u306e\u63d0\u6848\uff09\u3002\u4e0a\u6d41\u3067\u30de\u30fc\u30b8\u6e08\u307f\u306e\u5909\u66f4\u306f\u5168\u4ef6\u53d6\u308a\u8fbc\u307f\u3001\u672a\u30de\u30fc\u30b8 PR \u306f\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30fb\u8a8d\u8a3c\u7cfb\u3092\u5148\u306b\u4e00\u4ef6\u305a\u3064\u63a1\u5426\u3092\u6c7a\u3081\u3001\u5019\u88dc\u306f manifest \u306b\u8f09\u305b\u307e\u3059\u3002
    10. force push \u306a\u3057\u3001\u524a\u9664\u306a\u3057\u3002 \u885d\u7a81\u306f PR \u4e0a\u306e\u65b0\u3057\u3044\u30b3\u30df\u30c3\u30c8\u3067\u89e3\u304d\u3001\u5c65\u6b74\u306f\u66f8\u304d\u63db\u3048\u307e\u305b\u3093\u3002\u30d6\u30e9\u30f3\u30c1\u306f\u524a\u9664\u305b\u305a\u30bf\u30b0\u3067\u4fdd\u7ba1\u3057\u307e\u3059\u3002
    11. -dev2027 \u304b\u3089\u516c\u958b\u306e\u3053\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u3078\u5199\u3059\u306e\u306f\u3001\u540d\u524d\u3001\u30d6\u30e9\u30f3\u30c1\u540d\u3001SHA\u3001\u65e5\u4ed8\u3001PR \u756a\u53f7\u3060\u3051\u3002 -private \u7531\u6765\u306e\u30b3\u30fc\u30c9\u304b\u3089\u4f5c\u308b\u30a4\u30e1\u30fc\u30b8\u306f\u3001\u30ed\u30fc\u30ab\u30eb\u306e Docker \u304b\u975e\u516c\u958b\u30ec\u30b8\u30b9\u30c8\u30ea\u306b\u3060\u3051\u7f6e\u304d\u3001\u516c\u958b\u30ec\u30b8\u30b9\u30c8\u30ea\u306b\u306f\u51fa\u3057\u307e\u305b\u3093\u3002
    flowchart TD\n  PUB[\"\u516c\u958b\u30b3\u30a2<br/>\u65e2\u5b9a\u30d6\u30e9\u30f3\u30c1\"] -->|\u65e5\u6b21\u30df\u30e9\u30fc| UP1[\"upstream/public-<branch>\"]\n  PRV[\"-private<br/>\u65e2\u5b9a\u30d6\u30e9\u30f3\u30c1\"] -->|\u65e5\u6b21\u30df\u30e9\u30fc| UP2[\"upstream/private-<branch>\"]\n  COS[\"CenterForOpenScience<br/>develop\"] -->|\u65e5\u6b21\u30df\u30e9\u30fc| UP3[\"upstream/cos-develop\"]\n  UP1 -->|1. \u30de\u30fc\u30b8| DEV[\"develop\uff08\u7d71\u5408\uff09\"]\n  UP2 -->|2. \u30de\u30fc\u30b8| DEV\n  PRS[\"\u63a1\u7528 PR<br/>\uff08\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30fb\u8a8d\u8a3c\u3092\u5148\u306b\uff09\"] -->|3. PR \u3068 Codex \u30ec\u30d3\u30e5\u30fc| DEV\n  UP3 -.->|\u53c2\u7167\u306e\u307f| DEV\n  DEV -->|\"\u540d\u524d\u3068 SHA\"| MAN[\"manifest/upstreams.json<br/>\uff08\u516c\u958b\u30ea\u30dd\u30b8\u30c8\u30ea\uff09\"]
    "},{"location":"decisions/ADR-01_Integration_Repository_Placement/#4-\u7d50\u679c","title":"4. \u7d50\u679c","text":"
    • \u826f\u3044\u70b9: \u300c\u516c\u958b\uff0b\u975e\u516c\u958b\uff0b\u63a1\u7528 PR\u300d\u3092\u89e3\u304f\u5834\u6240\u304c\u90e8\u54c1\u3054\u3068\u306b\u4e00\u3064\u306b\u306a\u308b\u3002\u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u30fc\u306f\u540d\u524d\u3068 SHA \u3060\u3051\u3067\u8db3\u308a\u308b\u3002\u65e5\u6b21\u30df\u30e9\u30fc\u3067\u5dee\u5206\u304c\u5c0f\u3055\u304f\u4fdd\u305f\u308c\u308b\u3002\u5c65\u6b74\u304c\u5b8c\u5168\u3067\u76e3\u67fb\u3067\u304d\u308b\u3002
    • \u826f\u3044\u70b9: \u65e2\u5b58\u30ea\u30dd\u30b8\u30c8\u30ea\u3078\u306e\u65b0\u3057\u3044\u6a29\u9650\u3092\u6c42\u3081\u305a\u306b\u3001\u66f8\u8fbc\u306e\u5883\u754c\u3092\u5b88\u308c\u308b\u3002
    • \u30b3\u30b9\u30c8: \u898b\u5b88\u308b\u30ea\u30dd\u30b8\u30c8\u30ea\u304c 11 \u672c\u5897\u3048\u308b\u3002SPEC-05 \u306e\u81ea\u52d5\u5316\u3068\u9032\u6357\u30dc\u30fc\u30c9\u3067\u548c\u3089\u3052\u308b\u3002
    • \u30b3\u30b9\u30c8: -dev2027 \u306f\u975e\u516c\u958b\u306e\u305f\u3081\u3001GitHub Actions \u306e\u5b9f\u884c\u6642\u9593\u3068\u30bb\u30eb\u30d5\u30db\u30b9\u30c8\u30e9\u30f3\u30ca\u30fc\u306e\u5229\u7528\u304c Team \u30d7\u30e9\u30f3\u306e\u67a0\u3092\u4f7f\u3046\u3002\u53d7\u3051\u5165\u308c\u308b\u3002
    • \u30ea\u30b9\u30af \u2014 \u516c\u958b\u306e\u3053\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u3078\u306e\u6f0f\u3048\u3044\u3002 -dev2027 \u3084 -private \u304b\u3089\u30d5\u30a1\u30a4\u30eb\u3001\u30b9\u30bf\u30c3\u30af\u30c8\u30ec\u30fc\u30b9\u3001URL \u3092\u4e00\u3064\u4e0d\u6ce8\u610f\u306b\u5199\u3059\u3060\u3051\u3067\u3001\u975e\u516c\u958b\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u4f5c\u696d\u304c\u516c\u958b\u3055\u308c\u307e\u3059\u3002\u5bfe\u7b56: CI \u306e\u79d8\u5bc6\u30b9\u30ad\u30e3\u30f3\u3092\u5fc5\u9808\u306b\u3059\u308b\u3002\u30ec\u30d3\u30e5\u30ef\u306f\u3053\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u3078\u306e\u5168 PR \u3067\u975e\u516c\u958b\u306e\u30d1\u30b9\u3068 URL \u3092\u78ba\u304b\u3081\u308b\u3002manifest \u306e\u30b9\u30ad\u30fc\u30de\u306f\u540d\u524d\u30fb\u30d6\u30e9\u30f3\u30c1\u30fbSHA\u30fb\u65e5\u4ed8\u30fbPR \u756a\u53f7\u3057\u304b\u8a31\u3055\u306a\u3044\u3002\u6587\u66f8\u306f\u975e\u516c\u958b\u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u540d\u524d\u3067\u547c\u3073\u3001\u30ea\u30f3\u30af\u3057\u306a\u3044\uff08SPEC-06 \u00a75\uff09\u3002
    • \u30ea\u30b9\u30af \u2014 \u516c\u958b\u3068\u975e\u516c\u958b\u306e\u305a\u308c\u3002 2026-11-05 \u6642\u70b9\u3067\u516c\u958b RDM-osf.io \u306e develop \u306f -private \u3088\u308a\u65b0\u3057\u304b\u3063\u305f\u3002\u7d71\u5408\u9806\uff08\u516c\u958b\u3092\u5148\u3001\u6b21\u306b\u975e\u516c\u958b\uff09\u3068\u65e5\u6b21\u30df\u30e9\u30fc\u306b\u3088\u308a\u3001\u3053\u3046\u3057\u305f\u305a\u308c\u306f\u9ed9\u3063\u305f\u4e0a\u66f8\u304d\u3067\u306f\u306a\u304f\u30de\u30fc\u30b8\u3068\u3057\u3066\u898b\u3048\u307e\u3059\u3002
    • \u672a\u6c7a: RDM-osf.io-develop-private \u3068\u306f\u5225\u7269\u306e RDM-osf.io-private\uff08\u30d6\u30e9\u30f3\u30c1 fix/sec-test\uff09\u306e\u6271\u3044\u3002upstream/private-sec-test-fix-sec-test \u3068\u3057\u3066\u30df\u30e9\u30fc\u3057\u3001manifest \u306b\u306f status: candidate \u3067\u8f09\u305b\u3066\u3044\u307e\u3059\uff08SPEC-01 \u00a74 \u306e\u898f\u5247 6\uff09\u3002\u30de\u30fc\u30b8\u3059\u308b\u304b\u306f\u6240\u6709\u8005\u304c\u6c7a\u3081\u307e\u3059\u3002
    "},{"location":"decisions/ADR-01_Integration_Repository_Placement/#5-\u7d71\u5408\u9806\u306e\u521d\u56de\u69cb\u7bc9\u306e\u89e3\u91c8\u63d0\u6848\u6240\u6709\u8005\u306e\u627f\u8a8d\u5f85\u3061","title":"5. \u7d71\u5408\u9806\u306e\u300c\u521d\u56de\u69cb\u7bc9\u300d\u306e\u89e3\u91c8\uff08\u63d0\u6848\u3002\u6240\u6709\u8005\u306e\u627f\u8a8d\u5f85\u3061\uff09","text":"

    \u72b6\u614b: 2026-11-05\u3001RDM-osf.io-dev2027 PR #1 \u306e\u30ec\u30d3\u30e5\u30fc r1/r2\uff08\u6307\u6458 R2\uff09\u3092\u53d7\u3051\u3066\u63d0\u6848\u3002\u6240\u6709\u8005\u306f\u307e\u3060\u627f\u8a8d\u3057\u3066\u3044\u306a\u3044\u3002

    SPEC-01 \u00a74 \u306f\u7d71\u5408\u9806\u3092\u300c\u516c\u958b \u2192 private \u2192 \u63a1\u7528 PR\u300d\u3068\u5b9a\u3081\u308b\u3002\u5404 -dev2027 \u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u521d\u56de\u69cb\u7bc9\u306f\u3053\u306e\u624b\u9806\u3092\u6587\u5b57\u3069\u304a\u308a\u306b\u306f\u518d\u73fe\u3057\u3066\u3044\u306a\u3044\u3002develop \u306f -private \u306e\u5148\u7aef\uff08\u516c\u958b\u306e\u5c65\u6b74\u3092\u65e2\u306b\u542b\u3080\uff09\u3092\u8d77\u70b9\u306b\u3057\u3001\u3088\u308a\u65b0\u3057\u3044\u516c\u958b\u306e\u5148\u7aef\u3092\u901a\u5e38\u306e 2 \u89aa\u30de\u30fc\u30b8\u3067\u53d6\u308a\u8fbc\u3093\u3060\u3002\u3053\u306e\u898f\u5247\u3092\u6b21\u306e\u3088\u3046\u306b\u8aad\u3080\u3053\u3068\u3092\u63d0\u6848\u3059\u308b\u3002

    • \u521d\u56de\u69cb\u7bc9: -private \u306e\u5148\u7aef\u3092\u8d77\u70b9\u306b\u3057\u3066\u3001\u3088\u308a\u65b0\u3057\u3044\u516c\u958b\u306e\u5148\u7aef\u3092\u5897\u5206\u3067\u30de\u30fc\u30b8\u3059\u308b\u5f62\u306f\u3001\u898f\u5247\u3092\u6e80\u305f\u3059\u3002-private \u306e\u5148\u7aef\u304c\u516c\u958b\u5c65\u6b74\u306e\u4e0a\u4f4d\u4e92\u63db\u3067\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u6e08\u307f\u3067\u3001\u30de\u30fc\u30b8\u306f\u4e21\u89aa\u3092\u4fdd\u6301\u3059\u308b\u304b\u3089\u3067\u3042\u308b\u3002
    • \u5b9a\u5e38\u904b\u8ee2\uff08\u9031\u6b21\u7d71\u5408\u3001SPEC-05\uff09: \u6587\u5b57\u3069\u304a\u308a\u306e\u9806\u5e8f\u3092\u9069\u7528\u3059\u308b\u3002upstream/public-*\u3001\u6b21\u306b upstream/private-*\u3001\u6700\u5f8c\u306b\u63a1\u7528 PR \u3092\u518d\u9069\u7528\u3059\u308b\u3002
    • \u521d\u56de\u69cb\u7bc9\u3092\u6587\u5b57\u3069\u304a\u308a\u306e\u518d\u73fe\u306b\u898b\u305b\u308b\u305f\u3081\u306b\u4e0a\u6d41\u306e\u5c65\u6b74\u3092\u66f8\u304d\u63db\u3048\u308b\u3053\u3068\u306f\u3057\u306a\u3044\u3002

    \u6240\u6709\u8005\u304c\u3053\u306e\u89e3\u91c8\u3092\u9000\u3051\u308b\u5834\u5408\u306e\u4ee3\u66ff\u306f\u3001\u5404 develop \u3092\u516c\u958b\u306e\u5148\u7aef\u304b\u3089\u53b3\u5bc6\u306b\u518d\u69cb\u7bc9\u3059\u308b\u3053\u3068\u3067\u3001force push \u306a\u3057\u306e\u5225\u306e\u5909\u66f4\u3068\u3057\u3066\u63d0\u6848\u3059\u308b\u3002

    "},{"location":"decisions/ADR-01_Integration_Repository_Placement/#glossary--\u7528\u8a9e","title":"Glossary / \u7528\u8a9e","text":"Term English note \u65e5\u672c\u8a9e\u6ce8 Fork Your own copy of someone's repository that remembers where it came from. \u4ed6\u4eba\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u81ea\u5206\u7528\u306e\u5199\u3057\u3002\u51fa\u3069\u3053\u308d\u3092\u899a\u3048\u3066\u3044\u308b\u3002 Mirror An identical copy that is refreshed automatically. \u81ea\u52d5\u3067\u66f4\u65b0\u3055\u308c\u308b\u3001\u305d\u3063\u304f\u308a\u540c\u3058\u5199\u3057\u3002 Pull request (PR) A proposed change waiting for someone to review and accept it. \u8ab0\u304b\u304c\u898b\u3066\u53d7\u3051\u5165\u308c\u308b\u306e\u3092\u5f85\u3063\u3066\u3044\u308b\u3001\u5909\u66f4\u306e\u63d0\u6848\u3002 Patch A small text file that describes a change to code. \u30b3\u30fc\u30c9\u306e\u5909\u66f4\u5185\u5bb9\u3092\u66f8\u3044\u305f\u5c0f\u3055\u306a\u6587\u5b57\u30d5\u30a1\u30a4\u30eb\u3002 Force push Overwriting shared history; forbidden here. \u5171\u6709\u306e\u5c65\u6b74\u306e\u4e0a\u66f8\u304d\u3002\u3053\u3053\u3067\u306f\u7981\u6b62\u3002

    Full shared glossary: REF-01 Glossary.

    "},{"location":"decisions/ADR-02_Network_Model/","title":"ADR-02 Network Model / \u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u65b9\u5f0f","text":"

    Summary: We drop the upstream loopback alias 192.168.168.167 (which needed sudo and exposed services to the local network) and use the Docker Compose internal network for service-to-service traffic plus 127.0.0.1-only publishing for the browser. \u6982\u8981: \u4e0a\u6d41\u306e\u30eb\u30fc\u30d7\u30d0\u30c3\u30af\u5225\u540d 192.168.168.167\uff08sudo \u304c\u8981\u308a\u3001\u30b5\u30fc\u30d3\u30b9\u3092 LAN \u306b\u9732\u51fa\u3057\u305f\uff09\u3092\u3084\u3081\u3001\u30b5\u30fc\u30d3\u30b9\u9593\u306f Docker Compose \u306e\u5185\u90e8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3001\u30d6\u30e9\u30a6\u30b6\u5411\u3051\u306f 127.0.0.1 \u3060\u3051\u3078\u306e\u516c\u958b\u306b\u3059\u308b\u3002

    Jump: English \u00b7 \u65e5\u672c\u8a9e

    • Version / \u7248: 0.1 \u2014 2026-11-05. Learned: the alias existed only so that one address worked both inside containers and in the browser; once services talk by Compose service name and the browser talks to 127.0.0.1, no shared address is needed and the sudo step disappears with it. \uff0f \u5225\u540d\u306f\u300c\u4e00\u3064\u306e\u30a2\u30c9\u30ec\u30b9\u304c\u30b3\u30f3\u30c6\u30ca\u306e\u4e2d\u3067\u3082\u30d6\u30e9\u30a6\u30b6\u3067\u3082\u901a\u308b\u300d\u305f\u3081\u3060\u3051\u306b\u5b58\u5728\u3057\u3066\u3044\u305f\u3002\u30b5\u30fc\u30d3\u30b9\u9593\u304c Compose \u306e\u30b5\u30fc\u30d3\u30b9\u540d\u3067\u3001\u30d6\u30e9\u30a6\u30b6\u304c 127.0.0.1 \u3067\u8a71\u305b\u3070\u5171\u901a\u30a2\u30c9\u30ec\u30b9\u306f\u4e0d\u8981\u306b\u306a\u308a\u3001sudo \u306e\u624b\u9806\u3082\u4e00\u7dd2\u306b\u6d88\u3048\u308b\u3068\u5206\u304b\u3063\u305f\u3002
    • Status: Accepted by the owner, 2026-11-05 (plan-interview).
    • Records a decision for: POL-01 \u00a75 \u00b7 SPEC-02 Installer CLI \u00b7 SPEC-03 Security Gate
    • Related: docs/README.md \u00b7 SPEC-00 Overview \u00b7 SPEC-04 Acceptance Tests \u00b7 ADR-01 \u00b7 ADR-03 \u00b7 REF-01 Glossary \u00b7 legacy guide docs/guides/environment/README.md (moved from Environment.md)

    "},{"location":"decisions/ADR-02_Network_Model/#english","title":"English","text":"

    \u2192 \u65e5\u672c\u8a9e\u7248\u3078

    "},{"location":"decisions/ADR-02_Network_Model/#1-context","title":"1. Context","text":"

    The upstream docker-compose.yml of RDM-osf.io and its README-docker-compose.md ask the developer to add 192.168.168.167 as an alias (an extra name or address for the same thing) on the loopback interface (the network path that leads back to your own computer; 127.0.0.1 and localhost are its usual names). The alias is configured with administrator rights:

    • macOS: sudo ifconfig lo0 alias 192.168.168.167/24
    • Linux: an interface configuration or ip addr add with sudo
    • Windows: netsh interface ip add address \"Loopback\" 192.168.168.167 255.255.255.0 as administrator

    The reason is a single address that works in two places. Containers (boxes that hold one program and everything it needs) talk to each other \u2014 the web service calls wb (waterbutler), mfr and fakecas; the browser on the host also needs those addresses in redirects and in JavaScript. Giving the host a fixed alias and publishing every port (a numbered door on an address through which one program listens) on 0.0.0.0 made both paths use one address.

    This conflicts with three rules of the 2027 environment (POL-01):

    1. localhost only \u2014 nothing listens on an address reachable from the local network;
    2. no LAN exposure \u2014 0.0.0.0 publishing is not allowed, because a development instance with EOL components must never be reachable by a neighbour on the same Wi-Fi;
    3. no sudo \u2014 the installer runs as an ordinary user, so it is safe to run on a laptop managed by someone else and simple to run in CI.

    The alias also fails in practice: it disappears after reboot on macOS, Windows setups were never confirmed, and port 5000 collides with macOS AirPlay Receiver on macOS 15 and later (the legacy guide already recommends remapping it).

    "},{"location":"decisions/ADR-02_Network_Model/#2-options-considered","title":"2. Options considered","text":"
    options[3]{id,option,needs_sudo,lan_exposure,matches_upstream_docs,test_matrix,verdict}:\n  A,\"Keep the 192.168.168.167 loopback alias as upstream does\",yes,yes,yes,1,rejected\n  B,\"Drop the alias: Compose internal network for services, 127.0.0.1 publishing for the browser\",no,no,no,1,chosen\n  C,\"Support both, selected by --legacy-network\",partly,partly,partly,2,rejected
    • A keeps upstream documents literally true but violates all three rules above. Rejected.
    • C doubles the test matrix (every acceptance test twice) and keeps sudo code paths alive in the installer. Rejected; a developer who really needs the alias can still follow the upstream README by hand, outside the installer.
    "},{"location":"decisions/ADR-02_Network_Model/#3-decision","title":"3. Decision","text":"
    1. Service-to-service traffic uses the Compose internal network. Every service addresses another by its Compose service name (web, api, wb, mfr, fakecas, cas, postgres, elasticsearch, rabbitmq, redis, mongo). Docker's built-in DNS (the phone book that turns a name into an address) resolves them. No fixed IP addresses.
    2. Browser-facing traffic is published on 127.0.0.1 only. The generated Compose file writes 127.0.0.1:<host-port>:<container-port>, never 0.0.0.0 or a bare port. The default host ports are defined once, in the ports table of SPEC-02 \u00a74 (5000 web, 8000 api, 8001 admin, 7777 wb, 7778 mfr, 8080 fakecas, 4200 ember). The installer checks each port is free and remaps on collision (macOS AirPlay on 5000 is the known case), recording the mapping in runtime/.env and the install report.
    3. Settings that differ from upstream documents are rewritten by the installer, not by hand:
    4. website/settings/local.py and api/base/settings/local.py: DOMAIN, API_DOMAIN, WATERBUTLER_URL, MFR_SERVER_URL, CAS_SERVER_URL and similar \u2014 the internal URLs use service names, the external (browser) URLs use http://127.0.0.1:<port>/;
    5. .docker-compose.env, .docker-compose.wb.env, .docker-compose.mfr.env, .docker-compose.sharejs.env: hostnames and ports as above; secrets are random values generated at install time (SPEC-03);
    6. runtime/docker-compose.yml is generated from the manifest and the host profile (SPEC-02 \u00a73); the upstream docker-compose.yml files in the integration repositories are left untouched so upstream diffs stay clean.
    7. grdm-dev health --network fails if any container port is listening on an address other than 127.0.0.1 on the host (SPEC-04).
    8. Browser behaviour: acceptance tests and users open http://127.0.0.1:5000/. localhost is accepted as an equivalent in docs, but the installer writes 127.0.0.1 to avoid IPv6 ::1 surprises in Node-based services.
    flowchart LR\n  subgraph OLD[\"Old: loopback alias (upstream)\"]\n    H1[\"Host: sudo ifconfig lo0 alias<br/>192.168.168.167\"]\n    B1[\"Browser \u2192 192.168.168.167:5000\"]\n    W1[\"web\"] -->|\"192.168.168.167:7777\"| WB1[\"wb\"]\n    W1 -->|\"192.168.168.167:8080\"| FC1[\"fakecas\"]\n    B1 --> W1\n    H1 -. \"0.0.0.0 publishing<br/>reachable from LAN\" .-> W1\n  end\n  subgraph NEW[\"New: internal network + 127.0.0.1 (chosen)\"]\n    B2[\"Browser \u2192 127.0.0.1:5000\"]\n    subgraph NET[\"compose network (private DNS)\"]\n      W2[\"web\"] -->|\"http://wb:7777\"| WB2[\"wb\"]\n      W2 -->|\"http://fakecas:8080\"| FC2[\"fakecas\"]\n    end\n    B2 -->|\"127.0.0.1:5000 \u2192 web\"| W2\n    B2 -->|\"127.0.0.1:7777 \u2192 wb\"| WB2\n  end
    "},{"location":"decisions/ADR-02_Network_Model/#4-consequences","title":"4. Consequences","text":"
    • Good: no sudo, nothing survives a reboot that must be redone, nothing is reachable from the LAN, the same Compose file works on macOS, Ubuntu and WSL2, and CI can run it unmodified.
    • Good: fewer moving parts for the security gate \u2014 the \"listening address\" check in SPEC-03 becomes a one-line rule.
    • Cost \u2014 divergence from upstream documents. README-docker-compose.md in the public cores still describes the alias. Every place where our settings differ is explained in the environment guide at docs/guides/environment/README.md, with a table \"upstream says / we do / why\". Developers who copy commands from upstream must read that table first.
    • Cost \u2014 redirects and absolute URLs. OSF builds absolute URLs from DOMAIN and API_DOMAIN; if a service receives an internal name and echoes it to the browser, the browser cannot resolve it. The installer therefore separates internal and external URL settings, and the acceptance tests include a redirect-chain check (login via fakecas, file download via wb, preview via mfr).
    • Cost \u2014 Chrome cookie sharing. The legacy guide noted that Chrome did not share cookies between fakecas and the web UI under the alias. With everything on 127.0.0.1 and distinct ports, cookies are per host, so the same caution applies; the login scenario of the acceptance tests (Chromium, SPEC-04 \u00a71) catches it.
    • Not provided: access from another machine on the LAN (for example, testing from a phone). If needed later, it is a separate, explicit decision, not a flag.
    "},{"location":"decisions/ADR-02_Network_Model/#\u65e5\u672c\u8a9e","title":"\u65e5\u672c\u8a9e","text":"

    \u2192 To English

    "},{"location":"decisions/ADR-02_Network_Model/#1-\u80cc\u666f","title":"1. \u80cc\u666f","text":"

    RDM-osf.io \u306e\u4e0a\u6d41 docker-compose.yml \u3068 README-docker-compose.md \u306f\u3001\u958b\u767a\u8005\u306b 192.168.168.167 \u3092\u300c\u30eb\u30fc\u30d7\u30d0\u30c3\u30af\u300d\uff08\u81ea\u5206\u306e\u8a08\u7b97\u6a5f\u3078\u623b\u3063\u3066\u304f\u308b\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306e\u9053\u3002\u666e\u6bb5\u306f 127.0.0.1 \u3084 localhost \u3068\u547c\u3076\uff09\u306e\u300c\u5225\u540d\u300d\uff08\u540c\u3058\u3082\u306e\u306b\u4ed8\u3051\u308b\u8ffd\u52a0\u306e\u540d\u524d\u3084\u30a2\u30c9\u30ec\u30b9\uff09\u3068\u3057\u3066\u8db3\u3059\u3088\u3046\u6c42\u3081\u307e\u3059\u3002\u3053\u306e\u8a2d\u5b9a\u306b\u306f\u7ba1\u7406\u8005\u6a29\u9650\u304c\u8981\u308a\u307e\u3059\u3002

    • macOS: sudo ifconfig lo0 alias 192.168.168.167/24
    • Linux: \u30a4\u30f3\u30bf\u30d5\u30a7\u30fc\u30b9\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3001\u307e\u305f\u306f sudo \u4ed8\u304d\u306e ip addr add
    • Windows: \u7ba1\u7406\u8005\u3067 netsh interface ip add address \"Loopback\" 192.168.168.167 255.255.255.0

    \u7406\u7531\u306f\u3001\u4e00\u3064\u306e\u30a2\u30c9\u30ec\u30b9\u3092\u4e8c\u3064\u306e\u5834\u6240\u3067\u901a\u3059\u305f\u3081\u3067\u3059\u3002\u300c\u30b3\u30f3\u30c6\u30ca\u300d\uff08\u4e00\u3064\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3068\u5fc5\u8981\u306a\u3082\u306e\u3092\u5165\u308c\u305f\u7bb1\uff09\u540c\u58eb\u304c\u8a71\u3059 \u2014 web \u304c wb\uff08waterbutler\uff09\u3001mfr\u3001fakecas \u3092\u547c\u3076 \u2014 \u4e00\u65b9\u3067\u3001\u30db\u30b9\u30c8\u306e\u30d6\u30e9\u30a6\u30b6\u3082\u8ee2\u9001\u5148\u3084 JavaScript \u306e\u4e2d\u3067\u305d\u306e\u30a2\u30c9\u30ec\u30b9\u3092\u5fc5\u8981\u3068\u3057\u307e\u3059\u3002\u30db\u30b9\u30c8\u306b\u56fa\u5b9a\u306e\u5225\u540d\u3092\u4ed8\u3051\u3001\u5168\u300c\u30dd\u30fc\u30c8\u300d\uff08\u4e00\u3064\u306e\u30a2\u30c9\u30ec\u30b9\u306b\u4ed8\u3044\u305f\u756a\u53f7\u4ed8\u304d\u306e\u6249\u3002\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u3053\u3053\u3067\u5f85\u3064\uff09\u3092 0.0.0.0 \u3067\u516c\u958b\u3059\u308c\u3070\u3001\u4e21\u65b9\u306e\u9053\u304c\u4e00\u3064\u306e\u30a2\u30c9\u30ec\u30b9\u3067\u6e08\u3093\u3060\u306e\u3067\u3059\u3002

    \u3053\u308c\u306f 2027 \u7248\u306e\u4e09\u3064\u306e\u898f\u5247\uff08POL-01\uff09\u3068\u885d\u7a81\u3057\u307e\u3059\u3002

    1. localhost \u306e\u307f \u2014 LAN \u304b\u3089\u5c4a\u304f\u30a2\u30c9\u30ec\u30b9\u3067\u5f85\u3064\u3082\u306e\u3092\u7f6e\u304b\u306a\u3044\u3002
    2. LAN \u3078\u306e\u9732\u51fa\u306a\u3057 \u2014 0.0.0.0 \u3067\u306e\u516c\u958b\u306f\u8a8d\u3081\u306a\u3044\u3002EOL \u90e8\u54c1\u3092\u542b\u3080\u958b\u767a\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u3001\u540c\u3058 Wi-Fi \u306e\u96a3\u4eba\u304b\u3089\u5c4a\u3044\u3066\u306f\u306a\u3089\u306a\u3044\u3002
    3. sudo \u4e0d\u8981 \u2014 \u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u30fc\u306f\u4e00\u822c\u30e6\u30fc\u30b6\u30fc\u3067\u52d5\u304f\u3002\u4ed6\u4eba\u304c\u7ba1\u7406\u3059\u308b\u30ce\u30fc\u30c8 PC \u3067\u3082\u5b89\u5168\u306b\u3001CI \u3067\u3082\u7c21\u5358\u306b\u52d5\u304b\u305b\u308b\u3002

    \u5225\u540d\u306f\u5b9f\u52d9\u3067\u3082\u3064\u307e\u305a\u304d\u307e\u3059\u3002macOS \u3067\u306f\u518d\u8d77\u52d5\u3067\u6d88\u3048\u3001Windows \u306f\u52d5\u4f5c\u672a\u78ba\u8a8d\u3067\u3001\u30dd\u30fc\u30c8 5000 \u306f macOS 15 \u4ee5\u964d\u306e AirPlay \u30ec\u30b7\u30fc\u30d0\u30fc\u3068\u885d\u7a81\u3057\u307e\u3059\uff08\u65e7\u624b\u5f15\u304d\u304c\u65e2\u306b\u4ed8\u3051\u66ff\u3048\u3092\u52e7\u3081\u3066\u3044\u307e\u3059\uff09\u3002

    "},{"location":"decisions/ADR-02_Network_Model/#2-\u691c\u8a0e\u3057\u305f\u9078\u629e\u80a2","title":"2. \u691c\u8a0e\u3057\u305f\u9078\u629e\u80a2","text":"
    options[3]{id,option,needs_sudo,lan_exposure,matches_upstream_docs,test_matrix,verdict}:\n  A,\"\u4e0a\u6d41\u3069\u304a\u308a 192.168.168.167 \u306e\u30eb\u30fc\u30d7\u30d0\u30c3\u30af\u5225\u540d\u3092\u7dad\u6301\",yes,yes,yes,1,\u4e0d\u63a1\u7528\n  B,\"\u5225\u540d\u3092\u5ec3\u6b62\u3002\u30b5\u30fc\u30d3\u30b9\u9593\u306f Compose \u5185\u90e8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3001\u30d6\u30e9\u30a6\u30b6\u5411\u3051\u306f 127.0.0.1 \u3067\u516c\u958b\",no,no,no,1,\u63a1\u7528\n  C,\"\u4e21\u5bfe\u5fdc\u3002--legacy-network \u3067\u5207\u66ff\",partly,partly,partly,2,\u4e0d\u63a1\u7528
    • A \u306f\u4e0a\u6d41\u6587\u66f8\u3092\u6587\u5b57\u3069\u304a\u308a\u6b63\u3057\u3044\u307e\u307e\u306b\u3057\u307e\u3059\u304c\u3001\u4e0a\u306e\u4e09\u3064\u306e\u898f\u5247\u3092\u3059\u3079\u3066\u7834\u308a\u307e\u3059\u3002\u4e0d\u63a1\u7528\u3002
    • C \u306f\u8a66\u9a13\u306e\u7d44\u307f\u5408\u308f\u305b\u3092\u500d\u306b\u3057\uff08\u5168\u53d7\u5165\u8a66\u9a13\u3092\u4e8c\u5ea6\uff09\u3001\u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u30fc\u306b sudo \u306e\u7d4c\u8def\u3092\u6b8b\u3057\u307e\u3059\u3002\u4e0d\u63a1\u7528\u3002\u672c\u5f53\u306b\u5225\u540d\u304c\u8981\u308b\u958b\u767a\u8005\u306f\u3001\u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u30fc\u306e\u5916\u3067\u4e0a\u6d41 README \u3092\u624b\u3067\u8ffd\u3048\u307e\u3059\u3002
    "},{"location":"decisions/ADR-02_Network_Model/#3-\u6c7a\u5b9a","title":"3. \u6c7a\u5b9a","text":"
    1. \u30b5\u30fc\u30d3\u30b9\u9593\u306e\u901a\u4fe1\u306f Compose \u306e\u5185\u90e8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3092\u4f7f\u3046\u3002 \u5404\u30b5\u30fc\u30d3\u30b9\u306f\u76f8\u624b\u3092 Compose \u306e\u30b5\u30fc\u30d3\u30b9\u540d\uff08web\u3001api\u3001wb\u3001mfr\u3001fakecas\u3001cas\u3001postgres\u3001elasticsearch\u3001rabbitmq\u3001redis\u3001mongo\uff09\u3067\u547c\u3073\u307e\u3059\u3002Docker \u5185\u8535\u306e DNS\uff08\u540d\u524d\u3092\u30a2\u30c9\u30ec\u30b9\u306b\u5909\u3048\u308b\u96fb\u8a71\u5e33\uff09\u304c\u89e3\u6c7a\u3057\u307e\u3059\u3002\u56fa\u5b9a IP \u30a2\u30c9\u30ec\u30b9\u306f\u4f7f\u3044\u307e\u305b\u3093\u3002
    2. \u30d6\u30e9\u30a6\u30b6\u5411\u3051\u306e\u516c\u958b\u306f 127.0.0.1 \u3060\u3051\u3002 \u751f\u6210\u3059\u308b Compose \u30d5\u30a1\u30a4\u30eb\u306b\u306f 127.0.0.1:<\u30db\u30b9\u30c8\u5074\u30dd\u30fc\u30c8>:<\u30b3\u30f3\u30c6\u30ca\u5074\u30dd\u30fc\u30c8> \u3068\u66f8\u304d\u30010.0.0.0 \u3084\u30dd\u30fc\u30c8\u756a\u53f7\u3060\u3051\u306e\u66f8\u304d\u65b9\u306f\u3057\u307e\u305b\u3093\u3002\u65e2\u5b9a\u306e\u30db\u30b9\u30c8\u5074\u30dd\u30fc\u30c8\u306f SPEC-02 \u00a74 \u306e\u30dd\u30fc\u30c8\u8868\u3067\u4e00\u5ea6\u3060\u3051\u5b9a\u3081\u307e\u3059\uff085000 web\u30018000 api\u30018001 admin\u30017777 wb\u30017778 mfr\u30018080 fakecas\u30014200 ember\uff09\u3002\u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u30fc\u306f\u5404\u30dd\u30fc\u30c8\u306e\u7a7a\u304d\u3092\u78ba\u304b\u3081\u3001\u885d\u7a81\u6642\uff08macOS \u306e AirPlay \u3068 5000 \u304c\u65e2\u77e5\uff09\u306f\u4ed8\u3051\u66ff\u3048\u3066 runtime/.env \u3068\u5c0e\u5165\u5831\u544a\u66f8\u306b\u8a18\u9332\u3057\u307e\u3059\u3002
    3. \u4e0a\u6d41\u6587\u66f8\u3068\u7570\u306a\u308b\u8a2d\u5b9a\u306f\u3001\u624b\u3067\u306f\u306a\u304f\u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u30fc\u304c\u66f8\u304d\u63db\u3048\u308b\u3002
    4. website/settings/local.py \u3068 api/base/settings/local.py: DOMAIN\u3001API_DOMAIN\u3001WATERBUTLER_URL\u3001MFR_SERVER_URL\u3001CAS_SERVER_URL \u304a\u3088\u3073\u305d\u306e\u985e\u3002\u300c\u5185\u90e8\u300d\u306e URL \u306f\u30b5\u30fc\u30d3\u30b9\u540d\u3001\u300c\u5916\u90e8\u300d\uff08\u30d6\u30e9\u30a6\u30b6\uff09\u306e URL \u306f http://127.0.0.1:<\u30dd\u30fc\u30c8>/\u3002
    5. .docker-compose.env\u3001.docker-compose.wb.env\u3001.docker-compose.mfr.env\u3001.docker-compose.sharejs.env: \u30db\u30b9\u30c8\u540d\u3068\u30dd\u30fc\u30c8\u306f\u4e0a\u8a18\u306e\u3068\u304a\u308a\u3002\u79d8\u5bc6\u306f\u5c0e\u5165\u6642\u306b\u4e71\u6570\u3067\u751f\u6210\uff08SPEC-03\uff09\u3002
    6. runtime/docker-compose.yml \u306f manifest \u3068\u30db\u30b9\u30c8\u306e\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u751f\u6210\uff08SPEC-02 \u00a73\uff09\u3002\u7d71\u5408\u30ea\u30dd\u30b8\u30c8\u30ea\u5185\u306e\u4e0a\u6d41\u306e docker-compose.yml \u306b\u306f\u89e6\u308c\u305a\u3001\u4e0a\u6d41\u3068\u306e\u5dee\u5206\u3092\u6c5a\u3057\u307e\u305b\u3093\u3002
    7. grdm-dev health --network \u306f\u3001\u30db\u30b9\u30c8\u4e0a\u3067 127.0.0.1 \u4ee5\u5916\u306e\u30a2\u30c9\u30ec\u30b9\u3067\u5f85\u3064\u30b3\u30f3\u30c6\u30ca\u306e\u30dd\u30fc\u30c8\u304c\u3042\u308c\u3070\u4e0d\u5408\u683c\u306b\u3057\u307e\u3059\uff08SPEC-04\uff09\u3002
    8. \u30d6\u30e9\u30a6\u30b6\u306e\u6319\u52d5: \u53d7\u5165\u8a66\u9a13\u3068\u5229\u7528\u8005\u306f http://127.0.0.1:5000/ \u3092\u958b\u304d\u307e\u3059\u3002\u6587\u66f8\u3067\u306f localhost \u3082\u540c\u7fa9\u3068\u3057\u3066\u8a8d\u3081\u307e\u3059\u304c\u3001Node \u7cfb\u30b5\u30fc\u30d3\u30b9\u3067 IPv6 \u306e ::1 \u306b\u5316\u3051\u308b\u4e8b\u6545\u3092\u907f\u3051\u308b\u305f\u3081\u3001\u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u30fc\u306f 127.0.0.1 \u3092\u66f8\u304d\u307e\u3059\u3002
    flowchart LR\n  subgraph OLD[\"\u65e7: \u30eb\u30fc\u30d7\u30d0\u30c3\u30af\u5225\u540d\uff08\u4e0a\u6d41\uff09\"]\n    H1[\"\u30db\u30b9\u30c8: sudo ifconfig lo0 alias<br/>192.168.168.167\"]\n    B1[\"\u30d6\u30e9\u30a6\u30b6 \u2192 192.168.168.167:5000\"]\n    W1[\"web\"] -->|\"192.168.168.167:7777\"| WB1[\"wb\"]\n    W1 -->|\"192.168.168.167:8080\"| FC1[\"fakecas\"]\n    B1 --> W1\n    H1 -. \"0.0.0.0 \u516c\u958b<br/>LAN \u304b\u3089\u5c4a\u304f\" .-> W1\n  end\n  subgraph NEW[\"\u65b0: \u5185\u90e8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\uff0b127.0.0.1\uff08\u63a1\u7528\uff09\"]\n    B2[\"\u30d6\u30e9\u30a6\u30b6 \u2192 127.0.0.1:5000\"]\n    subgraph NET[\"compose \u30cd\u30c3\u30c8\u30ef\u30fc\u30af\uff08\u5185\u90e8 DNS\uff09\"]\n      W2[\"web\"] -->|\"http://wb:7777\"| WB2[\"wb\"]\n      W2 -->|\"http://fakecas:8080\"| FC2[\"fakecas\"]\n    end\n    B2 -->|\"127.0.0.1:5000 \u2192 web\"| W2\n    B2 -->|\"127.0.0.1:7777 \u2192 wb\"| WB2\n  end
    "},{"location":"decisions/ADR-02_Network_Model/#4-\u7d50\u679c","title":"4. \u7d50\u679c","text":"
    • \u826f\u3044\u70b9: sudo \u304c\u4e0d\u8981\u3002\u518d\u8d77\u52d5\u5f8c\u306b\u3084\u308a\u76f4\u3059\u624b\u9806\u304c\u306a\u3044\u3002LAN \u304b\u3089\u5c4a\u304f\u3082\u306e\u304c\u306a\u3044\u3002\u540c\u3058 Compose \u30d5\u30a1\u30a4\u30eb\u304c macOS\u30fbUbuntu\u30fbWSL2 \u3067\u52d5\u304d\u3001CI \u3067\u3082\u305d\u306e\u307e\u307e\u52d5\u304f\u3002
    • \u826f\u3044\u70b9: \u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u9580\u306e\u90e8\u54c1\u304c\u6e1b\u308b\u3002SPEC-03 \u306e\u300c\u5f85\u3061\u53d7\u3051\u30a2\u30c9\u30ec\u30b9\u300d\u306e\u691c\u67fb\u304c\u4e00\u884c\u306e\u898f\u5247\u306b\u306a\u308b\u3002
    • \u30b3\u30b9\u30c8 \u2014 \u4e0a\u6d41\u6587\u66f8\u3068\u306e\u5dee\u3002 \u516c\u958b\u30b3\u30a2\u306e README-docker-compose.md \u306f\u4eca\u3082\u5225\u540d\u3092\u8aac\u660e\u3057\u3066\u3044\u307e\u3059\u3002\u79c1\u305f\u3061\u306e\u8a2d\u5b9a\u304c\u7570\u306a\u308b\u7b87\u6240\u306f\u3059\u3079\u3066 docs/guides/environment/README.md \u306e\u74b0\u5883\u624b\u5f15\u304d\u3067\u3001\u300c\u4e0a\u6d41\u306f\u3053\u3046\uff0f\u79c1\u305f\u3061\u306f\u3053\u3046\uff0f\u7406\u7531\u300d\u306e\u8868\u306b\u3057\u3066\u8aac\u660e\u3057\u307e\u3059\u3002\u4e0a\u6d41\u304b\u3089\u30b3\u30de\u30f3\u30c9\u3092\u5199\u3059\u958b\u767a\u8005\u306f\u3001\u307e\u305a\u305d\u306e\u8868\u3092\u8aad\u307f\u307e\u3059\u3002
    • \u30b3\u30b9\u30c8 \u2014 \u8ee2\u9001\u3068\u7d76\u5bfe URL\u3002 OSF \u306f DOMAIN \u3068 API_DOMAIN \u304b\u3089\u7d76\u5bfe URL \u3092\u4f5c\u308a\u307e\u3059\u3002\u30b5\u30fc\u30d3\u30b9\u304c\u5185\u90e8\u540d\u3092\u53d7\u3051\u53d6\u3063\u3066\u30d6\u30e9\u30a6\u30b6\u3078\u305d\u306e\u307e\u307e\u8fd4\u3059\u3068\u3001\u30d6\u30e9\u30a6\u30b6\u306f\u89e3\u6c7a\u3067\u304d\u307e\u305b\u3093\u3002\u305d\u306e\u305f\u3081\u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u30fc\u306f\u5185\u90e8\u7528\u3068\u5916\u90e8\u7528\u306e URL \u8a2d\u5b9a\u3092\u5206\u3051\u3001\u53d7\u5165\u8a66\u9a13\u306b\u8ee2\u9001\u9023\u9396\u306e\u78ba\u8a8d\uff08fakecas \u3067\u306e\u30ed\u30b0\u30a4\u30f3\u3001wb \u3067\u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3001mfr \u3067\u306e\u30d7\u30ec\u30d3\u30e5\u30fc\uff09\u3092\u542b\u3081\u307e\u3059\u3002
    • \u30b3\u30b9\u30c8 \u2014 Chrome \u306e Cookie \u5171\u6709\u3002 \u65e7\u624b\u5f15\u304d\u306f\u3001\u5225\u540d\u306e\u4e0b\u3067\u306f Chrome \u304c fakecas \u3068 Web UI \u306e\u9593\u3067 Cookie \u3092\u5171\u6709\u3057\u306a\u3044\u3068\u6ce8\u610f\u3057\u3066\u3044\u307e\u3057\u305f\u3002\u3059\u3079\u3066 127.0.0.1 \u3067\u5225\u30dd\u30fc\u30c8\u3067\u3082 Cookie \u306f\u30db\u30b9\u30c8\u5358\u4f4d\u306a\u306e\u3067\u3001\u540c\u3058\u6ce8\u610f\u304c\u6b8b\u308a\u307e\u3059\u3002\u53d7\u5165\u8a66\u9a13\u306e\u30ed\u30b0\u30a4\u30f3\u306e\u30b7\u30ca\u30ea\u30aa\uff08Chromium\u3002SPEC-04 \u00a71\uff09\u304c\u3053\u308c\u3092\u691c\u51fa\u3057\u307e\u3059\u3002
    • \u63d0\u4f9b\u3057\u306a\u3044\u3082\u306e: LAN \u4e0a\u306e\u5225\u306e\u8a08\u7b97\u6a5f\u304b\u3089\u306e\u30a2\u30af\u30bb\u30b9\uff08\u4f8b: \u30b9\u30de\u30fc\u30c8\u30d5\u30a9\u30f3\u304b\u3089\u306e\u78ba\u8a8d\uff09\u3002\u5f8c\u3067\u5fc5\u8981\u306b\u306a\u308c\u3070\u3001\u30d5\u30e9\u30b0\u3067\u306f\u306a\u304f\u5225\u306e\u660e\u793a\u7684\u306a\u6c7a\u5b9a\u306b\u3057\u307e\u3059\u3002
    "},{"location":"decisions/ADR-02_Network_Model/#glossary--\u7528\u8a9e","title":"Glossary / \u7528\u8a9e","text":"Term English note \u65e5\u672c\u8a9e\u6ce8 Loopback / localhost The network path that leads back to your own computer; 127.0.0.1. \u81ea\u5206\u306e\u8a08\u7b97\u6a5f\u3078\u623b\u3063\u3066\u304f\u308b\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306e\u9053\u3002127.0.0.1\u3002 Alias An extra name or address for the same thing. \u540c\u3058\u3082\u306e\u306b\u4ed8\u3051\u308b\u8ffd\u52a0\u306e\u540d\u524d\u3084\u30a2\u30c9\u30ec\u30b9\u3002 Port A numbered door on an address through which one program listens. \u30a2\u30c9\u30ec\u30b9\u306b\u4ed8\u3044\u305f\u756a\u53f7\u4ed8\u304d\u306e\u6249\u3002\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u3053\u3053\u3067\u5f85\u3064\u3002 DNS The phone book that turns a name into an address. \u540d\u524d\u3092\u30a2\u30c9\u30ec\u30b9\u306b\u5909\u3048\u308b\u96fb\u8a71\u5e33\u3002 Docker Compose A tool that starts many containers together from one file. \u4e00\u3064\u306e\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u591a\u304f\u306e\u30b3\u30f3\u30c6\u30ca\u3092\u307e\u3068\u3081\u3066\u8d77\u3053\u3059\u9053\u5177\u3002 sudo Running a command with administrator rights. \u7ba1\u7406\u8005\u306e\u6a29\u9650\u3067\u30b3\u30de\u30f3\u30c9\u3092\u52d5\u304b\u3059\u3053\u3068\u3002

    Full shared glossary: REF-01 Glossary.

    "},{"location":"decisions/ADR-03_Staged_Security_Gate/","title":"ADR-03 Staged Security Gate / \u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u306e\u9580\u306e\u6bb5\u968e\u5316","text":"

    Summary: We want zero vulnerabilities that would resist a top-tier AI attacker, but every current base image is end-of-life. We decided on a gate that starts as \"report plus a shrinking allow-list\" at M1 and becomes \"zero CRITICAL/HIGH plus a passing AI red team\" at M5, instead of enforcing zero from the first day or warning forever. \u6982\u8981: \u6700\u4e0a\u4f4d\u306e AI \u653b\u6483\u8005\u306b\u3082\u8010\u3048\u308b\u8106\u5f31\u6027\u30bc\u30ed\u3092\u76ee\u6307\u3059\u304c\u3001\u73fe\u884c\u306e\u30d9\u30fc\u30b9\u30a4\u30e1\u30fc\u30b8\u306f\u3059\u3079\u3066\u30b5\u30dd\u30fc\u30c8\u7d42\u4e86\u3067\u3042\u308b\u3002\u521d\u65e5\u304b\u3089\u30bc\u30ed\u3092\u5f37\u5236\u3059\u308b\u6848\u3082\u3001\u305a\u3063\u3068\u8b66\u544a\u3060\u3051\u306e\u6848\u3082\u63a1\u3089\u305a\u3001M1 \u3067\u306f\u300c\u5831\u544a\uff0b\u6e1b\u3063\u3066\u3044\u304f\u8a31\u5bb9\u30ea\u30b9\u30c8\u300d\u3001M5 \u3067\u306f\u300cCRITICAL/HIGH \u30bc\u30ed\uff0bAI \u30ec\u30c3\u30c9\u30c1\u30fc\u30e0\u5408\u683c\u300d\u3078\u53b3\u3057\u304f\u306a\u308b\u9580\u3092\u63a1\u3063\u305f\u3002

    Jump: English \u00b7 \u65e5\u672c\u8a9e

    • Version / \u7248: 0.1 \u2014 2026-11-05. Learned: a safety rule that cannot be met on the day it is written is not a rule but a wish; writing the schedule down turns the wish into something we can measure at each milestone. \uff0f \u66f8\u3044\u305f\u65e5\u306b\u5b88\u308c\u306a\u3044\u5b89\u5168\u898f\u5247\u306f\u898f\u5247\u3067\u306f\u306a\u304f\u9858\u3044\u306b\u3059\u304e\u305a\u3001\u4e88\u5b9a\u8868\u3068\u3057\u3066\u66f8\u304f\u3053\u3068\u3067\u3001\u7bc0\u76ee\u3054\u3068\u306b\u6e2c\u308c\u308b\u3082\u306e\u306b\u306a\u308b\u3068\u5206\u304b\u3063\u305f\u3002
    • Status: Accepted (owner, 2026-11-05). Review date: at the start of M4.
    • Related: SPEC-03 Security Gate \u00b7 SPEC-00 Overview \u00b7 SPEC-02 Installer CLI \u00b7 SPEC-05 Upstream Tracking \u00b7 SPEC-06 Documentation Conventions \u00b7 POL-01 Position \u00b7 ADR-01 Integration Repository Placement \u00b7 ADR-02 Network Model \u00b7 ADR-04 AI Autonomy and Roles \u00b7 docs/README.md

    "},{"location":"decisions/ADR-03_Staged_Security_Gate/#english","title":"English","text":"

    \u2192 \u65e5\u672c\u8a9e\u7248\u3078

    "},{"location":"decisions/ADR-03_Staged_Security_Gate/#1-context","title":"1. Context","text":"

    The owner's final goal for the developer environment 2027 (POL-01) is to remove vulnerabilities (known weak spots that an attacker could use) until the system resists even a top-tier AI attacker, and to keep removing them with AI agents even if COS discontinues OSF. A security gate (a checkpoint an install must pass) is the tool that makes this measurable: see SPEC-03.

    The starting point is far from zero. The base images (the ready-made operating system and language layers our containers are built on) used by the six core repositories are all end-of-life (EOL: the maker no longer publishes security fixes):

    base_images_2026_11[9]{service,base,eol_status}:\n  osf.io,\"node:12 + Python 3.6\",EOL\n  waterbutler,\"Python 3.6\",EOL\n  mfr,\"Python 3.5\",EOL\n  ember-osf-web,\"node:8\",EOL\n  cas-overlay,\"JDK 8\",EOL\n  postgres,\"9.6\",EOL\n  mongo,\"3.4\",EOL\n  elasticsearch,\"2.x\",EOL\n  elasticsearch,\"6.3.1\",EOL

    A first Trivy scan of such a stack reports hundreds of CVEs, dozens of them HIGH or CRITICAL, and most of them cannot be fixed without the Python 3.13 port planned for M4 and the middleware consolidation planned for M5. If the gate demanded zero at M1, no install would ever complete, and we would have no running baseline to measure the acceptance tests of SPEC-04 against. On the other hand, a gate that only warns gives nobody a reason to fix anything, and the final goal would never be reached.

    "},{"location":"decisions/ADR-03_Staged_Security_Gate/#2-options-considered","title":"2. Options considered","text":"Option Description Why rejected / chosen A. Enforce zero from M1 grdm-dev install stops on any HIGH or CRITICAL from the first day. Rejected. Every install would fail. There would be no running environment to port against, no regression baseline, and no evidence of what the fixes change. B. Warn only, forever Scan, print the counts, never stop. Rejected. Contradicts the owner's goal. The counts would stay high because nothing forces them down. Overseas distribution (M5) would ship known weaknesses. C. Staged gate with a shrinking allow-list (chosen) M1\u2013M3: baseline controls are mandatory; CVEs are reported and listed in an allow-list whose entry count must never grow between milestones. M4: fail on HIGH/CRITICAL not allow-listed; first AI red team. M5: fail on any CRITICAL/HIGH; AI red team reports zero unresolved intrusion paths. Chosen. Installs run from day one, the direction of travel is enforced by the never-increasing count, and the final state equals the owner's goal.

    A variant of C that counted only CRITICAL at M4 was considered and dropped: the Python 3.13 port removes most HIGH findings at the same time, so splitting the threshold would buy nothing.

    "},{"location":"decisions/ADR-03_Staged_Security_Gate/#3-decision","title":"3. Decision","text":"
    1. The gate follows the schedule in SPEC-03 \u00a75.2. The current milestone is stored in manifest/milestone.json and only the owner changes it.
    2. The baseline controls of SPEC-03 \u00a73 (random secrets with mode 0600, publish only on 127.0.0.1, internal network, non-root, no privileged, resource limits, pinned digests, secret scanning in CI) have no stage and no allow-list. They fail the gate at every milestone, including M1.
    3. The allow-list (manifest/allowlist.json) is the only way to pass a known finding. Every entry carries a CVE id, component, reason, owner, and expiry date. The entry count is compared with the previous milestone's baseline and must never increase. Only the owner approves additions.
    4. From M4, any HIGH or CRITICAL finding not in the allow-list stops grdm-dev install with exit code 50 (SPEC-02).
    5. At M5 and in steady state, CRITICAL and HIGH must be zero, the allow-list may contain no CRITICAL or HIGH entry, and the AI red team (SPEC-03 \u00a76) must report zero unresolved intrusion paths.
    6. The environment is documented as development-only and never exposed outside 127.0.0.1 while any allow-list entry exists (ADR-02).
    flowchart LR\n    M1[M1<br/>report + allow-list created] --> M2[M2<br/>count \u2264 M1]\n    M2 --> M3[M3<br/>count \u2264 M2]\n    M3 --> M4[M4<br/>fail on HIGH/CRITICAL<br/>first AI red team]\n    M4 --> M5[M5<br/>zero CRITICAL/HIGH<br/>red team: zero paths]\n    M5 --> S[steady state<br/>daily scan, auto fix PR]
    "},{"location":"decisions/ADR-03_Staged_Security_Gate/#4-consequences","title":"4. Consequences","text":"

    Positive:

    • Installs work from M1, so acceptance tests and the Python 3.13 port have a running baseline.
    • Every milestone has a number the owner can check: the allow-list count, which may only go down.
    • The final state (M5) is exactly the owner's goal, written in a form that grdm-dev scan can verify.
    • The non-staged baseline controls mean that even an M1 install is not exposed to the LAN and has no default passwords.

    Negative and how we handle them:

    • Between M1 and M3 the environment knowingly runs EOL software. We state this in every report header and in docs/README.md, and we keep the environment on 127.0.0.1 only.
    • The allow-list needs maintenance: expiry dates force re-evaluation at each milestone. AID (AI\u958b\u767a\u62c5\u5f53\u8005) proposes, REV (\u62c5\u5f53\u30ec\u30d3\u30e5\u30ef) and QAE (QA\u62c5\u5f53) check, the owner approves (ADR-04).
    • The jump from M3 to M4 is large. The M4 switch is therefore done only after the Python 3.13 port lands, and this decision is reviewed at the start of M4 (see \u00a75).
    "},{"location":"decisions/ADR-03_Staged_Security_Gate/#5-review","title":"5. Review","text":"

    This decision is reviewed at the start of M4. Questions to answer then: whether the allow-list count has in fact decreased at M2 and M3; whether the M4 threshold should include MEDIUM for network-facing services; and which model and runner the AI red team uses (open item in POL-01).

    "},{"location":"decisions/ADR-03_Staged_Security_Gate/#\u65e5\u672c\u8a9e","title":"\u65e5\u672c\u8a9e","text":"

    \u2192 To English

    "},{"location":"decisions/ADR-03_Staged_Security_Gate/#1-\u80cc\u666f","title":"1. \u80cc\u666f","text":"

    \u958b\u767a\u74b0\u5883 2027 \u7248\u306e\u6240\u6709\u8005\u306e\u6700\u7d42\u30b4\u30fc\u30eb\uff08POL-01\uff09\u306f\u3001\u300c\u8106\u5f31\u6027\u300d\uff08\u653b\u6483\u8005\u304c\u4fb5\u5165\u306b\u4f7f\u3048\u308b\u3068\u5206\u304b\u3063\u3066\u3044\u308b\u5f31\u3044\u6240\uff09\u3092\u6700\u4e0a\u4f4d\u306e AI \u653b\u6483\u8005\u306b\u3082\u8010\u3048\u308b\u307e\u3067\u9664\u53bb\u3057\u3001COS \u304c OSF \u3092\u5ec3\u6b62\u3057\u3066\u3082 AI \u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u3067\u9664\u53bb\u3092\u7d9a\u3051\u308b\u3053\u3068\u3067\u3059\u3002\u300c\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u306e\u9580\u300d\uff08\u5c0e\u5165\u304c\u5fc5\u305a\u901a\u308b\u691c\u554f\u6240\uff09\u306f\u3001\u3053\u308c\u3092\u6e2c\u308c\u308b\u3088\u3046\u306b\u3059\u308b\u9053\u5177\u3067\u3059\uff08SPEC-03\uff09\u3002

    \u51fa\u767a\u70b9\u306f\u30bc\u30ed\u304b\u3089\u9060\u3044\u6240\u306b\u3042\u308a\u307e\u3059\u3002\u30b3\u30a2 6 \u672c\u304c\u4f7f\u3046\u300c\u30d9\u30fc\u30b9\u30a4\u30e1\u30fc\u30b8\u300d\uff08\u30b3\u30f3\u30c6\u30ca\u306e\u571f\u53f0\u306b\u306a\u308b\u3001\u51fa\u6765\u5408\u3044\u306e OS \u3068\u8a00\u8a9e\u306e\u5c64\uff09\u306f\u3001\u3059\u3079\u3066\u300c\u30b5\u30dd\u30fc\u30c8\u7d42\u4e86\u300d\uff08EOL\u3002\u4f5c\u308a\u624b\u304c\u5b89\u5168\u4e0a\u306e\u4fee\u6b63\u3092\u51fa\u3055\u306a\u304f\u306a\u3063\u305f\u72b6\u614b\uff09\u3067\u3059\u3002

    base_images_2026_11[9]{service,base,eol_status}:\n  osf.io,\"node:12 + Python 3.6\",EOL\n  waterbutler,\"Python 3.6\",EOL\n  mfr,\"Python 3.5\",EOL\n  ember-osf-web,\"node:8\",EOL\n  cas-overlay,\"JDK 8\",EOL\n  postgres,\"9.6\",EOL\n  mongo,\"3.4\",EOL\n  elasticsearch,\"2.x\",EOL\n  elasticsearch,\"6.3.1\",EOL

    \u3053\u306e\u69cb\u6210\u3092 Trivy \u3067\u521d\u3081\u3066\u30b9\u30ad\u30e3\u30f3\u3059\u308b\u3068\u6570\u767e\u4ef6\u306e CVE \u304c\u51fa\u3066\u3001\u305d\u306e\u3046\u3061\u6570\u5341\u4ef6\u304c HIGH \u304b CRITICAL \u3067\u3001\u5927\u534a\u306f M4 \u4e88\u5b9a\u306e Python 3.13 \u79fb\u690d\u3068 M5 \u4e88\u5b9a\u306e\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u96c6\u7d04\u306a\u3057\u306b\u306f\u76f4\u305b\u307e\u305b\u3093\u3002\u9580\u304c M1 \u3067\u30bc\u30ed\u3092\u6c42\u3081\u308c\u3070\u3001\u5c0e\u5165\u306f\u4e00\u5ea6\u3082\u5b8c\u4e86\u305b\u305a\u3001SPEC-04 \u306e\u53d7\u5165\u8a66\u9a13\u3092\u6e2c\u308b\u52d5\u304f\u57fa\u6e96\u74b0\u5883\u3082\u5f97\u3089\u308c\u307e\u305b\u3093\u3002\u9006\u306b\u3001\u8b66\u544a\u3060\u3051\u306e\u9580\u3067\u306f\u8ab0\u306b\u3082\u76f4\u3059\u7406\u7531\u304c\u306a\u304f\u3001\u6700\u7d42\u30b4\u30fc\u30eb\u306b\u306f\u6c38\u9060\u306b\u5c4a\u304d\u307e\u305b\u3093\u3002

    "},{"location":"decisions/ADR-03_Staged_Security_Gate/#2-\u691c\u8a0e\u3057\u305f\u9078\u629e\u80a2","title":"2. \u691c\u8a0e\u3057\u305f\u9078\u629e\u80a2","text":"\u9078\u629e\u80a2 \u5185\u5bb9 \u9000\u3051\u305f\u30fb\u63a1\u3063\u305f\u7406\u7531 A. M1 \u304b\u3089\u30bc\u30ed\u3092\u5f37\u5236 \u521d\u65e5\u304b\u3089 HIGH \u304b CRITICAL \u304c\u4e00\u4ef6\u3067\u3082\u3042\u308c\u3070 grdm-dev install \u3092\u6b62\u3081\u308b\u3002 \u9000\u3051\u305f\u3002\u3059\u3079\u3066\u306e\u5c0e\u5165\u304c\u5931\u6557\u3059\u308b\u3002\u79fb\u690d\u306e\u571f\u53f0\u3068\u306a\u308b\u52d5\u304f\u74b0\u5883\u3082\u3001\u56de\u5e30\u306e\u57fa\u6e96\u3082\u3001\u4fee\u6b63\u304c\u4f55\u3092\u5909\u3048\u305f\u304b\u306e\u8a3c\u62e0\u3082\u5f97\u3089\u308c\u306a\u3044\u3002 B. \u305a\u3063\u3068\u8b66\u544a\u306e\u307f \u30b9\u30ad\u30e3\u30f3\u3057\u3066\u4ef6\u6570\u3092\u51fa\u3059\u3060\u3051\u3067\u3001\u6b62\u3081\u306a\u3044\u3002 \u9000\u3051\u305f\u3002\u6240\u6709\u8005\u306e\u30b4\u30fc\u30eb\u3068\u77db\u76fe\u3059\u308b\u3002\u6e1b\u3089\u3059\u529b\u304c\u50cd\u304b\u305a\u4ef6\u6570\u306f\u9ad8\u3044\u307e\u307e\u3002\u6d77\u5916\u914d\u5e03\uff08M5\uff09\u3067\u65e2\u77e5\u306e\u5f31\u70b9\u3092\u51fa\u8377\u3059\u308b\u3053\u3068\u306b\u306a\u308b\u3002 C. \u6e1b\u3063\u3066\u3044\u304f\u8a31\u5bb9\u30ea\u30b9\u30c8\u4ed8\u304d\u306e\u6bb5\u968e\u7684\u306a\u9580\uff08\u63a1\u7528\uff09 M1\u301cM3: \u57fa\u672c\u5bfe\u7b56\u306f\u5fc5\u9808\u3002CVE \u306f\u5831\u544a\u3057\u3001\u7bc0\u76ee\u3092\u307e\u305f\u3044\u3067\u4ef6\u6570\u304c\u5897\u3048\u306a\u3044\u8a31\u5bb9\u30ea\u30b9\u30c8\u306b\u8f09\u305b\u308b\u3002M4: \u8a31\u5bb9\u30ea\u30b9\u30c8\u5916\u306e HIGH/CRITICAL \u3067\u505c\u6b62\u3002\u521d\u56de\u306e AI \u30ec\u30c3\u30c9\u30c1\u30fc\u30e0\u3002M5: CRITICAL/HIGH \u304c\u4e00\u4ef6\u3067\u3082\u3042\u308c\u3070\u505c\u6b62\u3002AI \u30ec\u30c3\u30c9\u30c1\u30fc\u30e0\u304c\u672a\u89e3\u6c7a\u306e\u4fb5\u5165\u7d4c\u8def\u30bc\u30ed\u3092\u5831\u544a\u3002 \u63a1\u7528\u3002\u521d\u65e5\u304b\u3089\u5c0e\u5165\u304c\u52d5\u304d\u3001\u300c\u5897\u3048\u306a\u3044\u4ef6\u6570\u300d\u304c\u9032\u3080\u65b9\u5411\u3092\u5f37\u5236\u3057\u3001\u6700\u7d42\u72b6\u614b\u304c\u6240\u6709\u8005\u306e\u30b4\u30fc\u30eb\u3068\u4e00\u81f4\u3059\u308b\u3002

    C \u306e\u5909\u7a2e\u3068\u3057\u3066\u3001M4 \u3067\u306f CRITICAL \u3060\u3051\u3092\u6570\u3048\u308b\u6848\u3082\u691c\u8a0e\u3057\u3066\u843d\u3068\u3057\u307e\u3057\u305f\u3002Python 3.13 \u79fb\u690d\u304c HIGH \u306e\u5927\u534a\u3082\u540c\u6642\u306b\u53d6\u308a\u9664\u304f\u305f\u3081\u3001\u57fa\u6e96\u3092\u5206\u3051\u3066\u3082\u5f97\u308b\u3082\u306e\u304c\u306a\u3044\u304b\u3089\u3067\u3059\u3002

    "},{"location":"decisions/ADR-03_Staged_Security_Gate/#3-\u6c7a\u5b9a","title":"3. \u6c7a\u5b9a","text":"
    1. \u9580\u306f SPEC-03 \u00a75.2 \u306e\u4e88\u5b9a\u8868\u306b\u5f93\u3046\u3002\u73fe\u5728\u306e\u7bc0\u76ee\u306f manifest/milestone.json \u306b\u7f6e\u304d\u3001\u5909\u66f4\u3067\u304d\u308b\u306e\u306f\u6240\u6709\u8005\u3060\u3051\u3002
    2. SPEC-03 \u00a73 \u306e\u300c\u57fa\u672c\u5bfe\u7b56\u300d\uff08\u4e71\u6570\u306e\u79d8\u5bc6\u3092\u30e2\u30fc\u30c9 0600 \u3067\u3001127.0.0.1 \u306e\u307f\u516c\u958b\u3001\u5185\u90e8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3001\u975e root\u3001privileged \u306a\u3057\u3001\u8cc7\u6e90\u5236\u9650\u3001\u30c0\u30a4\u30b8\u30a7\u30b9\u30c8\u56fa\u5b9a\u3001CI \u3067\u306e\u79d8\u5bc6\u30b9\u30ad\u30e3\u30f3\uff09\u306b\u306f\u6bb5\u968e\u3082\u8a31\u5bb9\u30ea\u30b9\u30c8\u3082\u306a\u3044\u3002M1 \u3092\u542b\u3080\u3059\u3079\u3066\u306e\u7bc0\u76ee\u3067\u9580\u3092\u843d\u3068\u3059\u3002
    3. \u65e2\u77e5\u306e\u691c\u51fa\u3092\u901a\u3059\u552f\u4e00\u306e\u65b9\u6cd5\u306f\u300c\u8a31\u5bb9\u30ea\u30b9\u30c8\u300d\uff08manifest/allowlist.json\uff09\u3002\u5404\u9805\u76ee\u306f CVE \u756a\u53f7\u3001\u90e8\u54c1\u3001\u7406\u7531\u3001\u62c5\u5f53\u3001\u671f\u9650\u3092\u6301\u3064\u3002\u4ef6\u6570\u306f\u524d\u306e\u7bc0\u76ee\u306e\u57fa\u6e96\u3068\u6bd4\u3079\u3001\u6c7a\u3057\u3066\u5897\u3048\u3066\u306f\u306a\u3089\u306a\u3044\u3002\u8ffd\u52a0\u306e\u627f\u8a8d\u306f\u6240\u6709\u8005\u3060\u3051\u3002
    4. M4 \u304b\u3089\u3001\u8a31\u5bb9\u30ea\u30b9\u30c8\u306b\u306a\u3044 HIGH\u30fbCRITICAL \u306e\u691c\u51fa\u306f grdm-dev install \u3092\u7d42\u4e86\u30b3\u30fc\u30c9 50 \u3067\u6b62\u3081\u308b\uff08SPEC-02\uff09\u3002
    5. M5 \u3068\u6052\u5e38\u904b\u7528\u3067\u306f\u3001CRITICAL \u3068 HIGH \u306f\u30bc\u30ed\u3001\u8a31\u5bb9\u30ea\u30b9\u30c8\u306b CRITICAL\u30fbHIGH \u306e\u9805\u76ee\u304c\u3042\u3063\u3066\u306f\u306a\u3089\u305a\u3001AI \u30ec\u30c3\u30c9\u30c1\u30fc\u30e0\uff08SPEC-03 \u00a76\uff09\u304c\u672a\u89e3\u6c7a\u306e\u4fb5\u5165\u7d4c\u8def\u30bc\u30ed\u3092\u5831\u544a\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3002
    6. \u8a31\u5bb9\u30ea\u30b9\u30c8\u306b\u9805\u76ee\u304c\u3042\u308b\u9593\u306f\u3001\u74b0\u5883\u3092\u958b\u767a\u5c02\u7528\u3068\u660e\u8a18\u3057\u3001127.0.0.1 \u306e\u5916\u3078\u51fa\u3055\u306a\u3044\uff08ADR-02\uff09\u3002
    flowchart LR\n    M1[M1<br/>\u5831\u544a\uff0b\u8a31\u5bb9\u30ea\u30b9\u30c8\u4f5c\u6210] --> M2[M2<br/>\u4ef6\u6570 \u2264 M1]\n    M2 --> M3[M3<br/>\u4ef6\u6570 \u2264 M2]\n    M3 --> M4[M4<br/>HIGH/CRITICAL \u3067\u505c\u6b62<br/>\u521d\u56de AI \u30ec\u30c3\u30c9\u30c1\u30fc\u30e0]\n    M4 --> M5[M5<br/>CRITICAL/HIGH \u30bc\u30ed<br/>\u30ec\u30c3\u30c9\u30c1\u30fc\u30e0: \u7d4c\u8def\u30bc\u30ed]\n    M5 --> S[\u6052\u5e38\u904b\u7528<br/>\u65e5\u6b21\u30b9\u30ad\u30e3\u30f3\u30fb\u81ea\u52d5\u4fee\u6b63 PR]
    "},{"location":"decisions/ADR-03_Staged_Security_Gate/#4-\u7d50\u679c","title":"4. \u7d50\u679c","text":"

    \u826f\u3044\u70b9:

    • M1 \u304b\u3089\u5c0e\u5165\u304c\u52d5\u304f\u306e\u3067\u3001\u53d7\u5165\u8a66\u9a13\u3068 Python 3.13 \u79fb\u690d\u306b\u52d5\u304f\u57fa\u6e96\u74b0\u5883\u304c\u3042\u308b\u3002
    • \u5404\u7bc0\u76ee\u306b\u6240\u6709\u8005\u304c\u78ba\u304b\u3081\u3089\u308c\u308b\u6570\u5b57\u304c\u3042\u308b\u3002\u8a31\u5bb9\u30ea\u30b9\u30c8\u306e\u4ef6\u6570\u3067\u3001\u6e1b\u308b\u65b9\u5411\u306b\u3057\u304b\u52d5\u304b\u306a\u3044\u3002
    • \u6700\u7d42\u72b6\u614b\uff08M5\uff09\u306f\u6240\u6709\u8005\u306e\u30b4\u30fc\u30eb\u305d\u306e\u3082\u306e\u3067\u3001grdm-dev scan \u304c\u691c\u8a3c\u3067\u304d\u308b\u5f62\u3067\u66f8\u304b\u308c\u3066\u3044\u308b\u3002
    • \u6bb5\u968e\u306e\u306a\u3044\u57fa\u672c\u5bfe\u7b56\u306b\u3088\u308a\u3001M1 \u306e\u5c0e\u5165\u3067\u3082 LAN \u306b\u9732\u51fa\u305b\u305a\u3001\u65e2\u5b9a\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u3082\u306a\u3044\u3002

    \u60aa\u3044\u70b9\u3068\u305d\u306e\u6271\u3044:

    • M1\u301cM3 \u306e\u9593\u3001\u74b0\u5883\u306f\u627f\u77e5\u306e\u4e0a\u3067\u30b5\u30dd\u30fc\u30c8\u7d42\u4e86\u306e\u30bd\u30d5\u30c8\u3092\u52d5\u304b\u3059\u3002\u3053\u308c\u3092\u5168\u5831\u544a\u306e\u30d8\u30c3\u30c0\u3068 docs/README.md \u306b\u660e\u8a18\u3057\u3001\u74b0\u5883\u3092 127.0.0.1 \u3060\u3051\u306b\u7559\u3081\u308b\u3002
    • \u8a31\u5bb9\u30ea\u30b9\u30c8\u306b\u306f\u624b\u5165\u308c\u304c\u8981\u308b\u3002\u671f\u9650\u304c\u5404\u7bc0\u76ee\u3067\u518d\u8a55\u4fa1\u3092\u5f37\u5236\u3059\u308b\u3002AID\uff08AI\u958b\u767a\u62c5\u5f53\u8005\uff09\u304c\u63d0\u6848\u3057\u3001REV\uff08\u62c5\u5f53\u30ec\u30d3\u30e5\u30ef\uff09\u3068 QAE\uff08QA\u62c5\u5f53\uff09\u304c\u78ba\u8a8d\u3057\u3001\u6240\u6709\u8005\u304c\u627f\u8a8d\u3059\u308b\uff08ADR-04\uff09\u3002
    • M3 \u304b\u3089 M4 \u3078\u306e\u6bb5\u5dee\u304c\u5927\u304d\u3044\u3002\u305d\u306e\u305f\u3081 M4 \u3078\u306e\u5207\u66ff\u306f Python 3.13 \u79fb\u690d\u304c\u5165\u3063\u305f\u5f8c\u306b\u3060\u3051\u884c\u3044\u3001\u3053\u306e\u6c7a\u5b9a\u3092 M4 \u306e\u958b\u59cb\u6642\u306b\u898b\u76f4\u3059\uff08\u00a75\uff09\u3002
    "},{"location":"decisions/ADR-03_Staged_Security_Gate/#5-\u898b\u76f4\u3057","title":"5. \u898b\u76f4\u3057","text":"

    \u3053\u306e\u6c7a\u5b9a\u306f M4 \u306e\u958b\u59cb\u6642\u306b\u898b\u76f4\u3057\u307e\u3059\u3002\u305d\u306e\u3068\u304d\u7b54\u3048\u308b\u554f\u3044: M2\u30fbM3 \u3067\u8a31\u5bb9\u30ea\u30b9\u30c8\u306e\u4ef6\u6570\u304c\u5b9f\u969b\u306b\u6e1b\u3063\u305f\u304b\u3002\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306b\u9762\u3059\u308b\u30b5\u30fc\u30d3\u30b9\u306b\u3064\u3044\u3066 M4 \u306e\u57fa\u6e96\u306b MEDIUM \u3092\u542b\u3081\u308b\u3079\u304d\u304b\u3002AI \u30ec\u30c3\u30c9\u30c1\u30fc\u30e0\u306b\u4f7f\u3046\u30e2\u30c7\u30eb\u3068\u5b9f\u884c\u57fa\u76e4\u3092\u3069\u3046\u3059\u308b\u304b\uff08POL-01 \u306e\u672a\u6c7a\u4e8b\u9805\uff09\u3002

    "},{"location":"decisions/ADR-03_Staged_Security_Gate/#glossary--\u7528\u8a9e","title":"Glossary / \u7528\u8a9e","text":"Term English note \u65e5\u672c\u8a9e\u6ce8 End-of-life (EOL) The maker no longer publishes security fixes for that version. \u4f5c\u308a\u624b\u304c\u305d\u306e\u7248\u306e\u5b89\u5168\u4e0a\u306e\u4fee\u6b63\u3092\u51fa\u3055\u306a\u304f\u306a\u3063\u305f\u72b6\u614b\u3002 Base image The ready-made OS and language layer a container is built on. \u30b3\u30f3\u30c6\u30ca\u306e\u571f\u53f0\u306b\u306a\u308b\u3001\u51fa\u6765\u5408\u3044\u306e OS \u3068\u8a00\u8a9e\u306e\u5c64\u3002 Allow-list Known findings we accept for a limited time, with a reason and an owner. \u7406\u7531\u3068\u62c5\u5f53\u3092\u4ed8\u3051\u3066\u671f\u9650\u4ed8\u304d\u3067\u53d7\u3051\u5165\u308c\u308b\u65e2\u77e5\u306e\u691c\u51fa\u306e\u4e00\u89a7\u3002 Threshold The line that decides pass or fail. \u5408\u683c\u3068\u4e0d\u5408\u683c\u3092\u5206\u3051\u308b\u7dda\u3002 Exit code The number a program returns when it finishes; 0 means success. \u30d7\u30ed\u30b0\u30e9\u30e0\u304c\u7d42\u308f\u308b\u3068\u304d\u306b\u8fd4\u3059\u756a\u53f7\u30020 \u306f\u6210\u529f\u3002"},{"location":"decisions/ADR-04_AI_Autonomy_and_Roles/","title":"ADR-04 AI Autonomy and Roles / AI \u306e\u81ea\u5f8b\u5ea6\u3068\u5f79\u5272","text":"

    Summary: AI agents detect vulnerabilities, write fix pull requests, review them, and run regression and acceptance tests on their own. Humans keep two actions: merge and publish. This record names who plays which role (AID, QAE, REV, owner), what the agents may never do, and the one question left open. \u6982\u8981: AI \u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u306f\u8106\u5f31\u6027\u306e\u691c\u51fa\u3001\u4fee\u6b63 PR \u306e\u4f5c\u6210\u3001\u30ec\u30d3\u30e5\u30fc\u3001\u56de\u5e30\u30fb\u53d7\u5165\u8a66\u9a13\u306e\u5b9f\u884c\u307e\u3067\u3092\u81ea\u5f8b\u7684\u306b\u884c\u3046\u3002\u4eba\u306b\u6b8b\u3059\u306e\u306f\u30de\u30fc\u30b8\u3068\u516c\u958b\u306e\u4e8c\u3064\u3002\u8ab0\u304c\u3069\u306e\u5f79\u5272\uff08AID\u30fbQAE\u30fbREV\u30fb\u6240\u6709\u8005\uff09\u3092\u62c5\u3046\u304b\u3001\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u304c\u6c7a\u3057\u3066\u3057\u3066\u306f\u306a\u3089\u306a\u3044\u3053\u3068\u3001\u6b8b\u3057\u305f\u4e00\u3064\u306e\u672a\u6c7a\u4e8b\u9805\u3092\u8a18\u3059\u3002

    Jump: English \u00b7 \u65e5\u672c\u8a9e

    • Version / \u7248: 0.1 \u2014 2026-11-05. Learned: the line between \"automatic\" and \"human\" is easiest to defend when it sits on two concrete commands, merge and publish, rather than on a judgment such as \"important changes\". \uff0f \u300c\u81ea\u52d5\u300d\u3068\u300c\u4eba\u300d\u306e\u5883\u76ee\u306f\u3001\u300c\u91cd\u8981\u306a\u5909\u66f4\u300d\u306e\u3088\u3046\u306a\u5224\u65ad\u3067\u306f\u306a\u304f\u3001\u30de\u30fc\u30b8\u3068\u516c\u958b\u3068\u3044\u3046\u4e8c\u3064\u306e\u5177\u4f53\u7684\u306a\u64cd\u4f5c\u306b\u7f6e\u304f\u3068\u6700\u3082\u5b88\u308a\u3084\u3059\u3044\u3068\u5206\u304b\u3063\u305f\u3002
    • Status: Accepted (owner, 2026-11-05). Review date: after steady-state operation has run for one month (open question in \u00a75).
    • Related: SPEC-00 Overview \u00b7 SPEC-02 Installer CLI \u00b7 SPEC-03 Security Gate \u00b7 SPEC-04 Acceptance Tests \u00b7 SPEC-05 Upstream Tracking \u00b7 SPEC-06 Documentation Conventions \u00b7 POL-01 Position \u00b7 ADR-01 Integration Repository Placement \u00b7 ADR-02 Network Model \u00b7 ADR-03 Staged Security Gate \u00b7 docs/README.md

    "},{"location":"decisions/ADR-04_AI_Autonomy_and_Roles/#english","title":"English","text":"

    \u2192 \u65e5\u672c\u8a9e\u7248\u3078

    "},{"location":"decisions/ADR-04_AI_Autonomy_and_Roles/#1-context","title":"1. Context","text":"

    The owner's goal (POL-01) is that GRDM keeps being provided even if COS discontinues OSF, through continuous vulnerability remediation (finding and fixing weak spots again and again, every day, not once) done by AI agents (programs that read, write, and test code on their own when given a task). The security gate of SPEC-03 produces a daily list of findings; someone must turn each finding into a fix.

    At the same time, the development policy POL-05 of the GRDM core repository, which this repository inherits, draws two lines that must not move:

    • An author never accepts their own work. The one who wrote a change does not judge whether it passes.
    • Merge and publish are human actions. No agent commits to the main branch or publishes an image or a release.

    The question is how much of the path between \"finding\" and \"merge\" AI agents may walk alone.

    "},{"location":"decisions/ADR-04_AI_Autonomy_and_Roles/#2-options-considered","title":"2. Options considered","text":"Option Description Why rejected / chosen 1. Detect only Agents scan and open issues; humans do everything else. Rejected. Does not scale to daily findings across eleven repositories. The owner would be the bottleneck, and the goal of continued provision without COS would not be met. 2. Detect \u2192 fix PR \u2192 review \u2192 automatic regression and acceptance; humans merge and publish (chosen) Agents do all the work that produces evidence. Humans do the two actions that change what others receive. Chosen. Keeps both POL-05 lines intact. Author (AID), reviewer (REV), and judge (QAE) are three different agents, so no one accepts their own work. The owner sees a PR with review and test evidence attached and only decides. 3. Auto-merge after review Same as 2, but the PR merges itself when review and tests pass. Rejected for now. Conflicts with POL-05 \"merge by humans\". A narrow exception for vulnerability-only fixes is kept as an open question (\u00a75)."},{"location":"decisions/ADR-04_AI_Autonomy_and_Roles/#3-decision","title":"3. Decision","text":""},{"location":"decisions/ADR-04_AI_Autonomy_and_Roles/#31-roles","title":"3.1 Roles","text":"

    Role abbreviations follow the table in AGENTS.md. In records, write the abbreviation with the Japanese role name, for example AID\uff08AI\u958b\u767a\u62c5\u5f53\u8005\uff09.

    roles[4]{abbr,ja_name,who,runs_on,does}:\n  AID,AI\u958b\u767a\u62c5\u5f53\u8005,\"Orca Open Code 2 workers\",\"local LLM Qwen 3 Coder Next (model id lmstudio/qwen3-coder-next-mlx)\",\"implement to spec, write fix PRs, propose allow-list entries\"\n  QAE,QA\u62c5\u5f53,\"Claude Code Fable\",\"Claude Code session on Mac Studio\",\"check implementations, run regression and acceptance (SPEC-04), judge pass/fail, write correction requests\"\n  REV,\u62c5\u5f53\u30ec\u30d3\u30e5\u30ef,\"Codex Astra (model id gpt-6-astra)\",\"Orca worker\",\"independent review of every PR; record in docs/reviews/ and as a PR comment\"\n  owner,\u6240\u6709\u8005,\"Yusuke Komiyama\",\"human\",\"merge, publish, exceptions, milestone changes, red-team approval\"

    The three agent roles are played by three different models on purpose, so that an error habit of one model is not shared by its reviewer or its judge.

    "},{"location":"decisions/ADR-04_AI_Autonomy_and_Roles/#32-flow","title":"3.2 Flow","text":"
    flowchart LR\n    S[grdm-dev scan<br/>daily finding] --> A[AID<br/>fix PR on a branch]\n    A --> R[REV<br/>review \u2192 docs/reviews/ + PR comment]\n    R -- changes requested --> A\n    R -- approved --> Q[QAE<br/>regression + acceptance<br/>SPEC-04]\n    Q -- fail \u2192 correction request --> A\n    Q -- pass --> O[Owner<br/>merge]\n    O --> P[Owner<br/>publish image / release]
    • Every step up to and including QAE's judgment is automatic and may run without a human present.
    • The owner merges with gh pr merge (Japanese subject) or declines. The owner publishes images to ghcr.io/rcosdp and tags releases.
    • Subagents (helper agents an agent starts to split its work) are unlimited in number. The role that started them is responsible for their output.
    "},{"location":"decisions/ADR-04_AI_Autonomy_and_Roles/#33-evidence-trail","title":"3.3 Evidence trail","text":"

    Every PR carries, before the owner sees it:

    1. The finding it fixes (CVE id or scan report path from SPEC-03 \u00a77).
    2. REV's review record in docs/reviews/YYYY-MM-DD_<Title>_rN.md and the same text as a PR comment.
    3. QAE's test record: the grdm-dev accept and grdm-dev scan TOON excerpts, pass or fail, and the commit SHA tested.
    4. A Japanese commit subject with a scoped prefix (fix(security):).

    A PR without all four is not ready for the owner; QAE returns it to AID.

    "},{"location":"decisions/ADR-04_AI_Autonomy_and_Roles/#34-forbidden-for-every-agent","title":"3.4 Forbidden for every agent","text":"
    • git push --force to any branch, ever.
    • Deleting branches, tags, repositories, images, or data of any kind.
    • Writing (push, PR creation, issue creation, comments) to any upstream repository: RCOSDP public cores, RCOSDP -private variants, or CenterForOpenScience. Agents write only to this repository and to the -dev2027 repositories.
    • Merging to develop or any protected branch; enabling auto-merge; changing branch protection.
    • Publishing images, releases, or documentation sites.
    • Copying -private code, secrets, or private repository URLs into this public repository (ADR-01).
    • Running red-team techniques against anything outside the isolated environment (SPEC-03 \u00a76).
    "},{"location":"decisions/ADR-04_AI_Autonomy_and_Roles/#4-consequences","title":"4. Consequences","text":"
    • Remediation keeps pace with daily scans without waiting for human working hours; the owner's work shrinks to reading evidence and clicking merge.
    • Three different models in three roles raise the cost of a shared blind spot and satisfy \"no self-acceptance\" structurally.
    • Local LLM workers (AID) have variable quality. The spec-first rule (specifications in docs/spec/ are written before work is handed to AID) and the QAE check are the compensation. A PR that fails QAE twice is closed and restarted from the spec.
    • Running three agent systems costs Mac Studio resources. Concurrency of Open Code 2 workers is an open item of POL-01.
    • Review time from the owner is the only remaining latency. If it becomes the bottleneck for vulnerability fixes, \u00a75 is revisited.
    "},{"location":"decisions/ADR-04_AI_Autonomy_and_Roles/#5-open-question","title":"5. Open question","text":"

    Should vulnerability-only fixes be allowed to auto-merge after REV approval and QAE pass? Arguments for: faster closure of HIGH findings in steady state. Arguments against: POL-05 keeps merge human; a wrong automatic merge in a security path is the most expensive kind of error. Decision deferred until steady-state operation has run for about one month and the owner has seen the real volume and quality of fix PRs. Until then, option 2 stands as written.

    "},{"location":"decisions/ADR-04_AI_Autonomy_and_Roles/#\u65e5\u672c\u8a9e","title":"\u65e5\u672c\u8a9e","text":"

    \u2192 To English

    "},{"location":"decisions/ADR-04_AI_Autonomy_and_Roles/#1-\u80cc\u666f","title":"1. \u80cc\u666f","text":"

    \u6240\u6709\u8005\u306e\u30b4\u30fc\u30eb\uff08POL-01\uff09\u306f\u3001COS \u304c OSF \u3092\u5ec3\u6b62\u3057\u3066\u3082\u3001\u300cAI \u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u300d\uff08\u8ab2\u984c\u3092\u4e0e\u3048\u308b\u3068\u81ea\u5206\u3067\u30b3\u30fc\u30c9\u3092\u8aad\u307f\u30fb\u66f8\u304d\u30fb\u8a66\u3059\u30d7\u30ed\u30b0\u30e9\u30e0\uff09\u306b\u3088\u308b\u300c\u7d99\u7d9a\u7684\u306a\u8106\u5f31\u6027\u5bfe\u5fdc\u300d\uff08\u5f31\u3044\u6240\u3092\u4e00\u5ea6\u3067\u306a\u304f\u6bce\u65e5\u304f\u308a\u8fd4\u3057\u898b\u3064\u3051\u3066\u76f4\u3059\u3053\u3068\uff09\u3067 GRDM \u306e\u63d0\u4f9b\u3092\u7d9a\u3051\u308b\u3053\u3068\u3067\u3059\u3002SPEC-03 \u306e\u9580\u306f\u6bce\u65e5\u691c\u51fa\u306e\u4e00\u89a7\u3092\u51fa\u3057\u307e\u3059\u3002\u8ab0\u304b\u304c\u305d\u306e\u4e00\u4ef6\u4e00\u4ef6\u3092\u4fee\u6b63\u306b\u5909\u3048\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002

    \u4e00\u65b9\u3067\u3001\u3053\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u304c\u7d99\u627f\u3059\u308b GRDM \u30b3\u30a2\u306e\u958b\u767a\u65b9\u91dd POL-05 \u306f\u3001\u52d5\u304b\u3057\u3066\u306f\u306a\u3089\u306a\u3044\u4e8c\u672c\u306e\u7dda\u3092\u5f15\u3044\u3066\u3044\u307e\u3059\u3002

    • \u4f5c\u8005\u306f\u81ea\u5206\u306e\u6210\u679c\u3092\u53d7\u3051\u5165\u308c\u306a\u3044\u3002 \u5909\u66f4\u3092\u66f8\u3044\u305f\u8005\u304c\u5408\u5426\u3092\u5224\u5b9a\u3057\u306a\u3044\u3002
    • \u30de\u30fc\u30b8\u3068\u516c\u958b\u306f\u4eba\u306e\u64cd\u4f5c\u3002 \u3069\u306e\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u3082\u4e3b\u30d6\u30e9\u30f3\u30c1\u306b\u30b3\u30df\u30c3\u30c8\u305b\u305a\u3001\u30a4\u30e1\u30fc\u30b8\u3084\u30ea\u30ea\u30fc\u30b9\u3092\u516c\u958b\u3057\u306a\u3044\u3002

    \u554f\u3044\u306f\u3001\u300c\u691c\u51fa\u300d\u304b\u3089\u300c\u30de\u30fc\u30b8\u300d\u307e\u3067\u306e\u9053\u306e\u3069\u3053\u307e\u3067\u3092 AI \u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u304c\u4e00\u4eba\u3067\u6b69\u3044\u3066\u3088\u3044\u304b\u3067\u3059\u3002

    "},{"location":"decisions/ADR-04_AI_Autonomy_and_Roles/#2-\u691c\u8a0e\u3057\u305f\u9078\u629e\u80a2","title":"2. \u691c\u8a0e\u3057\u305f\u9078\u629e\u80a2","text":"\u9078\u629e\u80a2 \u5185\u5bb9 \u9000\u3051\u305f\u30fb\u63a1\u3063\u305f\u7406\u7531 1. \u691c\u51fa\u306e\u307f \u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u306f\u30b9\u30ad\u30e3\u30f3\u3057\u3066 issue \u3092\u958b\u304d\u3001\u6b8b\u308a\u306f\u4eba\u304c\u884c\u3046\u3002 \u9000\u3051\u305f\u300211 \u672c\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u3067\u6bce\u65e5\u51fa\u308b\u691c\u51fa\u306b\u8ffd\u3044\u3064\u304b\u306a\u3044\u3002\u6240\u6709\u8005\u304c\u30dc\u30c8\u30eb\u30cd\u30c3\u30af\u306b\u306a\u308a\u3001COS \u306a\u3057\u3067\u63d0\u4f9b\u3092\u7d9a\u3051\u308b\u30b4\u30fc\u30eb\u306b\u5c4a\u304b\u306a\u3044\u3002 2. \u691c\u51fa \u2192 \u4fee\u6b63 PR \u2192 \u30ec\u30d3\u30e5\u30fc \u2192 \u56de\u5e30\u30fb\u53d7\u5165\u306e\u81ea\u52d5\u5b9f\u884c\u3002\u30de\u30fc\u30b8\u3068\u516c\u958b\u306f\u4eba\uff08\u63a1\u7528\uff09 \u8a3c\u62e0\u3092\u4f5c\u308b\u4ed5\u4e8b\u306f\u3059\u3079\u3066\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u304c\u884c\u3046\u3002\u4ed6\u8005\u304c\u53d7\u3051\u53d6\u308b\u3082\u306e\u3092\u5909\u3048\u308b\u4e8c\u3064\u306e\u64cd\u4f5c\u3060\u3051\u3092\u4eba\u304c\u884c\u3046\u3002 \u63a1\u7528\u3002POL-05 \u306e\u4e8c\u672c\u306e\u7dda\u3092\u305d\u306e\u307e\u307e\u5b88\u308c\u308b\u3002\u4f5c\u8005\uff08AID\uff09\u3001\u30ec\u30d3\u30e5\u30ef\uff08REV\uff09\u3001\u5224\u5b9a\u8005\uff08QAE\uff09\u304c\u5225\u3005\u306e\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u306a\u306e\u3067\u3001\u8ab0\u3082\u81ea\u5206\u306e\u6210\u679c\u3092\u53d7\u3051\u5165\u308c\u306a\u3044\u3002\u6240\u6709\u8005\u306f\u30ec\u30d3\u30e5\u30fc\u3068\u8a66\u9a13\u306e\u8a3c\u62e0\u304c\u4ed8\u3044\u305f PR \u3092\u898b\u3066\u3001\u6c7a\u3081\u308b\u3060\u3051\u3067\u3088\u3044\u3002 3. \u30ec\u30d3\u30e5\u30fc\u5f8c\u306b\u81ea\u52d5\u30de\u30fc\u30b8 2 \u3068\u540c\u3058\u3060\u304c\u3001\u30ec\u30d3\u30e5\u30fc\u3068\u8a66\u9a13\u306b\u5408\u683c\u3059\u308b\u3068 PR \u304c\u81ea\u5206\u3067\u30de\u30fc\u30b8\u3055\u308c\u308b\u3002 \u4eca\u306f\u9000\u3051\u305f\u3002POL-05 \u306e\u300c\u30de\u30fc\u30b8\u306f\u4eba\u300d\u3068\u885d\u7a81\u3059\u308b\u3002\u8106\u5f31\u6027\u4fee\u6b63\u3060\u3051\u306e\u72ed\u3044\u4f8b\u5916\u306f\u672a\u6c7a\u4e8b\u9805\u3068\u3057\u3066\u6b8b\u3059\uff08\u00a75\uff09\u3002"},{"location":"decisions/ADR-04_AI_Autonomy_and_Roles/#3-\u6c7a\u5b9a","title":"3. \u6c7a\u5b9a","text":""},{"location":"decisions/ADR-04_AI_Autonomy_and_Roles/#31-\u5f79\u5272","title":"3.1 \u5f79\u5272","text":"

    \u5f79\u5272\u306e\u7565\u79f0\u306f AGENTS.md \u306e\u5bfe\u5fdc\u8868\u306b\u5f93\u3044\u307e\u3059\u3002\u8a18\u9332\u3067\u306f AID\uff08AI\u958b\u767a\u62c5\u5f53\u8005\uff09 \u306e\u3088\u3046\u306b\u7565\u79f0\u3068\u65e5\u672c\u8a9e\u306e\u5f79\u5272\u540d\u3092\u4f75\u8a18\u3057\u307e\u3059\u3002

    roles[4]{abbr,ja_name,who,runs_on,does}:\n  AID,AI\u958b\u767a\u62c5\u5f53\u8005,\"Orca \u306e Open Code 2 \u30ef\u30fc\u30ab\u30fc\",\"\u30ed\u30fc\u30ab\u30eb LLM Qwen 3 Coder Next\uff08\u30e2\u30c7\u30eb ID lmstudio/qwen3-coder-next-mlx\uff09\",\"\u4ed5\u69d8\u3069\u304a\u308a\u306e\u5b9f\u88c5\u3001\u4fee\u6b63 PR \u306e\u4f5c\u6210\u3001\u8a31\u5bb9\u30ea\u30b9\u30c8\u9805\u76ee\u306e\u63d0\u6848\"\n  QAE,QA\u62c5\u5f53,\"Claude Code Fable\",\"Mac Studio \u4e0a\u306e Claude Code \u30bb\u30c3\u30b7\u30e7\u30f3\",\"\u5b9f\u88c5\u306e\u691c\u67fb\u3001\u56de\u5e30\u30fb\u53d7\u5165\u306e\u5b9f\u884c\uff08SPEC-04\uff09\u3001\u5408\u5426\u306e\u5224\u5b9a\u3001\u4fee\u6b63\u6307\u793a\u306e\u4f5c\u6210\"\n  REV,\u62c5\u5f53\u30ec\u30d3\u30e5\u30ef,\"Codex Astra\uff08\u30e2\u30c7\u30eb ID gpt-6-astra\uff09\",\"Orca \u30ef\u30fc\u30ab\u30fc\",\"\u5168 PR \u306e\u72ec\u7acb\u30ec\u30d3\u30e5\u30fc\u3002docs/reviews/ \u3068 PR \u30b3\u30e1\u30f3\u30c8\u306b\u8a18\u9332\"\n  owner,\u6240\u6709\u8005,\"\u8fbc\u5c71\u60a0\u4ecb\",\"\u4eba\",\"\u30de\u30fc\u30b8\u3001\u516c\u958b\u3001\u4f8b\u5916\u3001\u7bc0\u76ee\u306e\u5909\u66f4\u3001\u30ec\u30c3\u30c9\u30c1\u30fc\u30e0\u306e\u627f\u8a8d\"

    \u4e09\u3064\u306e\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u306e\u5f79\u5272\u3092\u4e09\u3064\u306e\u7570\u306a\u308b\u30e2\u30c7\u30eb\u306b\u5272\u308a\u5f53\u3066\u308b\u306e\u306f\u610f\u56f3\u7684\u3067\u3059\u3002\u4e00\u3064\u306e\u30e2\u30c7\u30eb\u306e\u9593\u9055\u3044\u306e\u7656\u3092\u3001\u305d\u306e\u30ec\u30d3\u30e5\u30ef\u3084\u5224\u5b9a\u8005\u304c\u5171\u6709\u3057\u306a\u3044\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u3067\u3059\u3002

    "},{"location":"decisions/ADR-04_AI_Autonomy_and_Roles/#32-\u6d41\u308c","title":"3.2 \u6d41\u308c","text":"
    flowchart LR\n    S[grdm-dev scan<br/>\u65e5\u6b21\u306e\u691c\u51fa] --> A[AID<br/>\u30d6\u30e9\u30f3\u30c1\u306b\u4fee\u6b63 PR]\n    A --> R[REV<br/>\u30ec\u30d3\u30e5\u30fc \u2192 docs/reviews/\uff0bPR \u30b3\u30e1\u30f3\u30c8]\n    R -- \u4fee\u6b63\u8981\u6c42 --> A\n    R -- \u627f\u8a8d --> Q[QAE<br/>\u56de\u5e30\uff0b\u53d7\u5165<br/>SPEC-04]\n    Q -- \u4e0d\u5408\u683c \u2192 \u4fee\u6b63\u6307\u793a --> A\n    Q -- \u5408\u683c --> O[\u6240\u6709\u8005<br/>\u30de\u30fc\u30b8]\n    O --> P[\u6240\u6709\u8005<br/>\u30a4\u30e1\u30fc\u30b8\u30fb\u30ea\u30ea\u30fc\u30b9\u306e\u516c\u958b]
    • QAE \u306e\u5224\u5b9a\u307e\u3067\u306e\u3059\u3079\u3066\u306e\u6bb5\u968e\u306f\u81ea\u52d5\u3067\u3001\u4eba\u304c\u3044\u306a\u304f\u3066\u3082\u52d5\u3044\u3066\u3088\u3044\u3002
    • \u6240\u6709\u8005\u306f gh pr merge\uff08\u65e5\u672c\u8a9e\u306e\u4ef6\u540d\uff09\u3067\u30de\u30fc\u30b8\u3059\u308b\u304b\u3001\u5374\u4e0b\u3059\u308b\u3002\u6240\u6709\u8005\u304c ghcr.io/rcosdp \u306b\u30a4\u30e1\u30fc\u30b8\u3092\u516c\u958b\u3057\u3001\u30ea\u30ea\u30fc\u30b9\u306b\u30bf\u30b0\u3092\u4ed8\u3051\u308b\u3002
    • \u300c\u30b5\u30d6\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u300d\uff08\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u304c\u4ed5\u4e8b\u3092\u5206\u3051\u308b\u305f\u3081\u306b\u8d77\u3053\u3059\u88dc\u52a9\u306e\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\uff09\u306e\u6570\u306b\u5236\u9650\u306f\u306a\u3044\u3002\u8d77\u3053\u3057\u305f\u5f79\u5272\u304c\u305d\u306e\u6210\u679c\u306b\u8cac\u4efb\u3092\u6301\u3064\u3002
    "},{"location":"decisions/ADR-04_AI_Autonomy_and_Roles/#33-\u8a3c\u8de1","title":"3.3 \u8a3c\u8de1","text":"

    \u6240\u6709\u8005\u304c\u898b\u308b\u524d\u306b\u3001\u3059\u3079\u3066\u306e PR \u306f\u6b21\u3092\u6301\u3061\u307e\u3059\u3002

    1. \u76f4\u3059\u691c\u51fa\uff08CVE \u756a\u53f7\u304b\u3001SPEC-03 \u00a77 \u306e\u30b9\u30ad\u30e3\u30f3\u5831\u544a\u306e\u30d1\u30b9\uff09\u3002
    2. REV \u306e\u30ec\u30d3\u30e5\u30fc\u8a18\u9332 docs/reviews/YYYY-MM-DD_<\u984c>_rN.md \u3068\u3001\u540c\u3058\u6587\u306e PR \u30b3\u30e1\u30f3\u30c8\u3002
    3. QAE \u306e\u8a66\u9a13\u8a18\u9332: grdm-dev accept \u3068 grdm-dev scan \u306e TOON \u6284\u9332\u3001\u5408\u5426\u3001\u8a66\u9a13\u3057\u305f\u30b3\u30df\u30c3\u30c8 SHA\u3002
    4. \u63a5\u982d\u8f9e\u4ed8\u304d\u306e\u65e5\u672c\u8a9e\u306e\u30b3\u30df\u30c3\u30c8\u4ef6\u540d\uff08fix(security):\uff09\u3002

    \u56db\u3064\u304c\u305d\u308d\u308f\u306a\u3044 PR \u306f\u6240\u6709\u8005\u306b\u51fa\u3059\u72b6\u614b\u3067\u306f\u306a\u304f\u3001QAE \u304c AID \u3078\u623b\u3057\u307e\u3059\u3002

    "},{"location":"decisions/ADR-04_AI_Autonomy_and_Roles/#34-\u3059\u3079\u3066\u306e\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u306b\u7981\u6b62\u3059\u308b\u3053\u3068","title":"3.4 \u3059\u3079\u3066\u306e\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u306b\u7981\u6b62\u3059\u308b\u3053\u3068","text":"
    • \u3069\u306e\u30d6\u30e9\u30f3\u30c1\u3078\u3082\u3001\u3044\u3064\u3067\u3082\u3001git push --force \u3092\u3057\u306a\u3044\u3002
    • \u30d6\u30e9\u30f3\u30c1\u3001\u30bf\u30b0\u3001\u30ea\u30dd\u30b8\u30c8\u30ea\u3001\u30a4\u30e1\u30fc\u30b8\u3001\u3042\u3089\u3086\u308b\u30c7\u30fc\u30bf\u3092\u524a\u9664\u3057\u306a\u3044\u3002
    • \u4e0a\u6d41\u30ea\u30dd\u30b8\u30c8\u30ea\uff08RCOSDP \u306e\u516c\u958b\u30b3\u30a2\u3001RCOSDP \u306e -private \u7248\u3001CenterForOpenScience\uff09\u3078\u66f8\u304d\u8fbc\u307e\u306a\u3044\uff08push\u3001PR \u4f5c\u6210\u3001issue \u4f5c\u6210\u3001\u30b3\u30e1\u30f3\u30c8\uff09\u3002\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u304c\u66f8\u304f\u306e\u306f\u3053\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u3068 -dev2027 \u7fa4\u3060\u3051\u3002
    • develop \u3084\u4fdd\u8b77\u3055\u308c\u305f\u30d6\u30e9\u30f3\u30c1\u3078\u30de\u30fc\u30b8\u3057\u306a\u3044\u3002\u81ea\u52d5\u30de\u30fc\u30b8\u3092\u6709\u52b9\u306b\u3057\u306a\u3044\u3002\u30d6\u30e9\u30f3\u30c1\u4fdd\u8b77\u3092\u5909\u3048\u306a\u3044\u3002
    • \u30a4\u30e1\u30fc\u30b8\u3001\u30ea\u30ea\u30fc\u30b9\u3001\u6587\u66f8\u30b5\u30a4\u30c8\u3092\u516c\u958b\u3057\u306a\u3044\u3002
    • -private \u306e\u30b3\u30fc\u30c9\u3001\u79d8\u5bc6\u3001\u975e\u516c\u958b\u30ea\u30dd\u30b8\u30c8\u30ea\u306e URL \u3092\u3053\u306e\u516c\u958b\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u5199\u3055\u306a\u3044\uff08ADR-01\uff09\u3002
    • \u9694\u96e2\u74b0\u5883\u306e\u5916\u306e\u3069\u3053\u306b\u3082\u30ec\u30c3\u30c9\u30c1\u30fc\u30e0\u306e\u624b\u6cd5\u3092\u4f7f\u308f\u306a\u3044\uff08SPEC-03 \u00a76\uff09\u3002
    "},{"location":"decisions/ADR-04_AI_Autonomy_and_Roles/#4-\u7d50\u679c","title":"4. \u7d50\u679c","text":"
    • \u4fee\u6b63\u304c\u4eba\u306e\u52e4\u52d9\u6642\u9593\u3092\u5f85\u305f\u305a\u306b\u65e5\u6b21\u30b9\u30ad\u30e3\u30f3\u3068\u540c\u3058\u901f\u3055\u3067\u9032\u3080\u3002\u6240\u6709\u8005\u306e\u4ed5\u4e8b\u306f\u8a3c\u62e0\u3092\u8aad\u3093\u3067\u30de\u30fc\u30b8\u3092\u62bc\u3059\u3053\u3068\u306b\u7e2e\u3080\u3002
    • \u4e09\u3064\u306e\u5f79\u5272\u306b\u4e09\u3064\u306e\u7570\u306a\u308b\u30e2\u30c7\u30eb\u3092\u7f6e\u304f\u3053\u3068\u3067\u3001\u5171\u901a\u306e\u76f2\u70b9\u304c\u751f\u307e\u308c\u306b\u304f\u304f\u306a\u308a\u3001\u300c\u81ea\u5df1\u53d7\u5165\u306e\u7981\u6b62\u300d\u304c\u69cb\u9020\u3068\u3057\u3066\u6e80\u305f\u3055\u308c\u308b\u3002
    • \u30ed\u30fc\u30ab\u30eb LLM \u306e\u30ef\u30fc\u30ab\u30fc\uff08AID\uff09\u306f\u54c1\u8cea\u304c\u3070\u3089\u3064\u304f\u3002\u4ed5\u69d8\u5148\u884c\u306e\u6c7a\u307e\u308a\uff08docs/spec/ \u306e\u4ed5\u69d8\u3092\u66f8\u3044\u3066\u304b\u3089 AID \u306b\u6e21\u3059\uff09\u3068 QAE \u306e\u691c\u67fb\u304c\u305d\u306e\u88dc\u3044\u306b\u306a\u308b\u3002QAE \u306b\u4e8c\u5ea6\u843d\u3061\u305f PR \u306f\u9589\u3058\u3001\u4ed5\u69d8\u304b\u3089\u3084\u308a\u76f4\u3059\u3002
    • \u4e09\u3064\u306e\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u4f53\u7cfb\u3092\u52d5\u304b\u3059\u3068 Mac Studio \u306e\u8cc7\u6e90\u3092\u4f7f\u3046\u3002Open Code 2 \u30ef\u30fc\u30ab\u30fc\u306e\u540c\u6642\u5b9f\u884c\u6570\u306f POL-01 \u306e\u672a\u6c7a\u4e8b\u9805\u3002
    • \u6b8b\u308b\u5f85\u3061\u6642\u9593\u306f\u6240\u6709\u8005\u306e\u30ec\u30d3\u30e5\u30fc\u6642\u9593\u3060\u3051\u3002\u305d\u308c\u304c\u8106\u5f31\u6027\u4fee\u6b63\u306e\u30dc\u30c8\u30eb\u30cd\u30c3\u30af\u306b\u306a\u3063\u305f\u3089 \u00a75 \u3092\u898b\u76f4\u3059\u3002
    "},{"location":"decisions/ADR-04_AI_Autonomy_and_Roles/#5-\u672a\u6c7a\u4e8b\u9805","title":"5. \u672a\u6c7a\u4e8b\u9805","text":"

    \u8106\u5f31\u6027\u4fee\u6b63\u3060\u3051\u306e PR \u306b\u3001REV \u627f\u8a8d\u3068 QAE \u5408\u683c\u306e\u5f8c\u306e\u81ea\u52d5\u30de\u30fc\u30b8\u3092\u8a8d\u3081\u308b\u304b\u3002 \u8cdb\u6210\u306e\u7406\u7531: \u6052\u5e38\u904b\u7528\u3067 HIGH \u306e\u691c\u51fa\u3092\u3088\u308a\u65e9\u304f\u9589\u3058\u3089\u308c\u308b\u3002\u53cd\u5bfe\u306e\u7406\u7531: POL-05 \u306f\u30de\u30fc\u30b8\u3092\u4eba\u306b\u6b8b\u3057\u3066\u3044\u308b\u3002\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u306e\u7d4c\u8def\u3067\u306e\u8aa4\u3063\u305f\u81ea\u52d5\u30de\u30fc\u30b8\u306f\u6700\u3082\u9ad8\u304f\u3064\u304f\u7a2e\u985e\u306e\u8aa4\u308a\u3067\u3042\u308b\u3002\u6052\u5e38\u904b\u7528\u3092\u7d04\u4e00\u304b\u6708\u56de\u3057\u3001\u6240\u6709\u8005\u304c\u4fee\u6b63 PR \u306e\u5b9f\u969b\u306e\u91cf\u3068\u8cea\u3092\u898b\u3066\u304b\u3089\u6c7a\u3081\u308b\u3002\u305d\u308c\u307e\u3067\u306f\u9078\u629e\u80a2 2 \u3092\u66f8\u3044\u305f\u3068\u304a\u308a\u306b\u9069\u7528\u3059\u308b\u3002

    "},{"location":"decisions/ADR-04_AI_Autonomy_and_Roles/#glossary--\u7528\u8a9e","title":"Glossary / \u7528\u8a9e","text":"Term English note \u65e5\u672c\u8a9e\u6ce8 AI agent A program that reads, writes, and tests code on its own when given a task. \u8ab2\u984c\u3092\u4e0e\u3048\u308b\u3068\u81ea\u5206\u3067\u30b3\u30fc\u30c9\u3092\u8aad\u307f\u30fb\u66f8\u304d\u30fb\u8a66\u3059\u30d7\u30ed\u30b0\u30e9\u30e0\u3002 Subagent A helper agent that an agent starts to split its work. \u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u304c\u4ed5\u4e8b\u3092\u5206\u3051\u308b\u305f\u3081\u306b\u8d77\u3053\u3059\u88dc\u52a9\u306e\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u3002 Pull request (PR) A proposed change that others can review before it joins the main code. \u4e3b\u306a\u30b3\u30fc\u30c9\u306b\u5165\u308b\u524d\u306b\u3001\u4ed6\u306e\u4eba\u304c\u78ba\u304b\u3081\u3089\u308c\u308b\u5909\u66f4\u306e\u63d0\u6848\u3002 Merge Joining a reviewed change into the main branch. \u30ec\u30d3\u30e5\u30fc\u6e08\u307f\u306e\u5909\u66f4\u3092\u4e3b\u30d6\u30e9\u30f3\u30c1\u306b\u5165\u308c\u308b\u3053\u3068\u3002 Publish Making an image, release, or site available to others. \u30a4\u30e1\u30fc\u30b8\u3001\u30ea\u30ea\u30fc\u30b9\u3001\u30b5\u30a4\u30c8\u3092\u4ed6\u306e\u4eba\u304c\u4f7f\u3048\u308b\u72b6\u614b\u306b\u3059\u308b\u3053\u3068\u3002 Force push Overwriting shared history on a branch; it can erase other people's work. \u5171\u6709\u3055\u308c\u305f\u5c65\u6b74\u3092\u4e0a\u66f8\u304d\u3059\u308b\u3053\u3068\u3002\u4ed6\u306e\u4eba\u306e\u4f5c\u696d\u3092\u6d88\u3059\u3053\u3068\u304c\u3042\u308b\u3002 Self-acceptance An author judging that their own work passes. \u4f5c\u8005\u304c\u81ea\u5206\u306e\u6210\u679c\u3092\u5408\u683c\u3068\u5224\u5b9a\u3059\u308b\u3053\u3068\u3002"},{"location":"demo/","title":"Demonstration Records / \u5b9f\u8a3c\u8a18\u9332","text":"

    Summary: Records of what was actually done: acceptance runs, integration test results. Each record lives under demo/runs/ and includes results.toon, screenshots, and traces. \u6982\u8981: \u5b9f\u969b\u306b\u3084\u3063\u305f\u3053\u3068\u306e\u8a18\u9332\uff1a\u53d7\u5165\u8a66\u9a13\u3001\u7d71\u5408\u8a66\u9a13\u7d50\u679c\u3002\u5404\u8a18\u9332\u306f demo/runs/ \u306e\u4e0b\u306b\u3042\u308a\u3001results.toon\u3001\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3001\u30c8\u30ec\u30fc\u30b9\u3092\u542b\u307f\u307e\u3059\u3002

    Jump: English \u00b7 \u65e5\u672c\u8a9e

    • Version / \u7248: 0.1 \u2014 2026-11-05. Learned: a milestone can only be called passed if the acceptance run that passed it is recorded with its evidence; this folder is where that evidence lives. \uff0f \u7bc0\u76ee\u3092\u300c\u5408\u683c\u300d\u3068\u547c\u3079\u308b\u306e\u306f\u3001\u5408\u683c\u3057\u305f\u53d7\u5165\u5b9f\u884c\u304c\u8a3c\u8de1\u3068\u3068\u3082\u306b\u8a18\u9332\u3055\u308c\u3066\u3044\u308b\u3068\u304d\u3060\u3051\u3067\u3042\u308a\u3001\u305d\u306e\u7f6e\u304d\u5834\u304c\u3053\u306e\u30d5\u30a9\u30eb\u30c0\u3060\u3068\u5206\u304b\u3063\u305f\u3002
    • Normative for: SPEC-04 Acceptance Tests, SPEC-03 Security Gate.
    • Related: ../README.md \u00b7 status/ \u00b7 demo/runs/

    "},{"location":"demo/#english","title":"English","text":"

    \u2192 \u65e5\u672c\u8a9e\u7248\u3078

    "},{"location":"demo/#1-what-belongs-here","title":"1. What belongs here","text":"

    A demo record documents what was actually done, including acceptance and integration tests. This folder contains:

    Subfolder Purpose runs/ Individual run results: acc-<timestamp>-<6 hex>/ with evidence.

    The record format is defined in SPEC-04 \u00a77:

    evidence:\n  results.toon: one line per test with id, case, status, duration_ms, http_status\n  results.json: same data, canonical\n  junit.xml: for CI and GitHub checks tab\n  screenshots/: <test>_<case>.png, taken only on failure\n  trace/: Playwright trace zip, only on failure, kept 14 days in CI
    "},{"location":"demo/#2-open-items-no-entries-yet--\u307e\u3060\u3042\u308a\u307e\u305b\u3093","title":"2. Open items (no entries yet / \u307e\u3060\u3042\u308a\u307e\u305b\u3093)","text":"Date Title Status \u2014 \u2014 \u2014"},{"location":"demo/#3-creating-a-new-demo-record","title":"3. Creating a new demo record","text":"
    1. Run grdm-dev accept (acceptance) or grdm-dev health --network (integration).
    2. The record is written to docs/demo/runs/<run_id>/.
    3. Link the run folder from status reports or milestone documents.
    "},{"location":"demo/#\u65e5\u672c\u8a9e","title":"\u65e5\u672c\u8a9e","text":"

    \u2192 To English

    "},{"location":"demo/#1-\u3053\u3053\u306b\u5c5e\u3059\u308b\u3082\u306e","title":"1. \u3053\u3053\u306b\u5c5e\u3059\u308b\u3082\u306e","text":"

    \u300c\u5b9f\u8a3c\u300d\u8a18\u9332\u306f\u3001\u5b9f\u969b\u306b\u3084\u3063\u305f\u3053\u3068\uff08\u53d7\u5165\u8a66\u9a13\u3001\u7d71\u5408\u8a66\u9a13\uff09\u3092\u6587\u66f8\u5316\u3057\u307e\u3059\u3002\u3053\u306e\u30d5\u30a9\u30eb\u30c0\u306b\u306f\u6b21\u304c\u542b\u307e\u308c\u307e\u3059\uff1a

    \u30b5\u30d6\u30d5\u30a9\u30eb\u30c0 \u76ee\u7684 runs/ \u500b\u5225\u306e\u5b9f\u884c\u7d50\u679c\uff1aacc-<\u6642\u523b>-<6 \u6841\u306e16\u9032>/ \u306b\u8a3c\u8de1\u304c\u7f6e\u304b\u308c\u308b\u3002

    \u8a18\u9332\u5f62\u5f0f\u306f SPEC-04 \u00a77 \u306b\u5b9a\u3081\u3089\u308c\u3066\u3044\u307e\u3059\uff1a

    \u8a3c\u8de1:\n  results.toon: \u8a66\u9a13\u3054\u3068\u306b\u4e00\u884c\u3002id\u30fbcase\u30fbstatus\u30fbduration_ms\u30fbhttp_status\n  results.json: \u540c\u3058\u30c7\u30fc\u30bf\u306e\u6b63\u672c\n  junit.xml: CI \u3068 GitHub \u306e checks \u30bf\u30d6\u5411\u3051\n  screenshots/: <\u8a66\u9a13>_<\u30b1\u30fc\u30b9>.png\u3002\u5931\u6557\u6642\u3060\u3051\u64ae\u308b\n  trace/: Playwright \u306e\u30c8\u30ec\u30fc\u30b9 zip\u3002\u5931\u6557\u6642\u3060\u3051\u3002CI \u3067\u306f 14 \u65e5\u4fdd\u6301
    "},{"location":"demo/#2-\u672a\u89e3\u6c7a\u9805\u76ee\u307e\u3060\u3042\u308a\u307e\u305b\u3093--no-entries-yet","title":"2. \u672a\u89e3\u6c7a\u9805\u76ee\uff08\u307e\u3060\u3042\u308a\u307e\u305b\u3093 / no entries yet\uff09","text":"\u65e5\u4ed8 \u30bf\u30a4\u30c8\u30eb \u30b9\u30c6\u30fc\u30bf\u30b9 \u2014 \u2014 \u2014"},{"location":"demo/#3-\u65b0\u3057\u3044\u5b9f\u8a3c\u8a18\u9332\u3092\u3064\u304f\u308b\u306b\u306f","title":"3. \u65b0\u3057\u3044\u5b9f\u8a3c\u8a18\u9332\u3092\u3064\u304f\u308b\u306b\u306f","text":"
    1. grdm-dev accept\uff08\u53d7\u5165\uff09\u307e\u305f\u306f grdm-dev health --network\uff08\u7d71\u5408\uff09\u3092\u5b9f\u884c\u3059\u308b\u3002
    2. \u8a18\u9332\u306f docs/demo/runs/<\u5b9f\u884cID>/ \u306b\u66f8\u304b\u308c\u308b\u3002
    3. \u72b6\u6cc1\u5831\u544a\u3084\u7bc0\u76ee\u6587\u66f8\u3078\u5b9f\u884c\u30d5\u30a9\u30eb\u30c0\u306b\u30ea\u30f3\u30af\u3059\u308b\u3002
    "},{"location":"demo/#glossary--\u7528\u8a9e","title":"Glossary / \u7528\u8a9e","text":"Term English note \u65e5\u672c\u8a9e\u6ce8 Demo record A document of what was actually done, including acceptance and integration tests. \u5b9f\u969b\u306b\u3084\u3063\u305f\u3053\u3068\uff08\u53d7\u5165\u8a66\u9a13\u3001\u7d71\u5408\u8a66\u9a13\uff09\u3092\u6587\u66f8\u5316\u3057\u305f\u3082\u306e\u3002 Evidence Files that prove a test run: results, screenshots, traces. \u8a66\u9a13\u5b9f\u884c\u3092\u8a3c\u660e\u3059\u308b\u30d5\u30a1\u30a4\u30eb\uff1a\u7d50\u679c\u3001\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3001\u30c8\u30ec\u30fc\u30b9\u3002 Acceptance test A check that the whole thing does what the user asked for. \u5168\u4f53\u304c\u5229\u7528\u8005\u306e\u671b\u307f\u3069\u304a\u308a\u306b\u52d5\u304f\u304b\u306e\u78ba\u8a8d\u3002 Integration test A check that several pieces work together. \u3044\u304f\u3064\u304b\u306e\u90e8\u54c1\u304c\u4e00\u7dd2\u306b\u52d5\u304f\u304b\u306e\u78ba\u8a8d\u3002"},{"location":"demo/runs/","title":"Acceptance Run Records / \u53d7\u5165\u5b9f\u884c\u306e\u8a18\u9332","text":"

    Summary: Each run of grdm-dev accept writes its evidence into a folder here, named by run id. Nothing is here yet; the first records arrive at milestone M2. \u6982\u8981: grdm-dev accept \u3092\u5b9f\u884c\u3059\u308b\u305f\u3073\u306b\u3001\u305d\u306e\u8a3c\u8de1\u304c\u5b9f\u884c ID \u540d\u306e\u30d5\u30a9\u30eb\u30c0\u3068\u3057\u3066\u3053\u3053\u306b\u66f8\u304b\u308c\u307e\u3059\u3002\u307e\u3060\u8a18\u9332\u306f\u306a\u304f\u3001\u6700\u521d\u306e\u8a18\u9332\u306f\u7bc0\u76ee M2 \u3067\u4f5c\u3089\u308c\u307e\u3059\u3002

    Jump: English \u00b7 \u65e5\u672c\u8a9e

    • Version / \u7248: 0.1 \u2014 2026-11-05. Learned: the evidence folder must exist with a stated layout before the first run, so that SPEC-04 and the demo index can link to it. \uff0f \u6700\u521d\u306e\u5b9f\u884c\u306e\u524d\u306b\u3001\u8a3c\u8de1\u30d5\u30a9\u30eb\u30c0\u3068\u6c7a\u307e\u3063\u305f\u4e2d\u8eab\u3092\u3053\u3053\u306b\u66f8\u3044\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308b\u3068\u5206\u304b\u3063\u305f\u3002SPEC-04 \u3068\u5b9f\u8a3c\u306e\u7d22\u5f15\u304c\u30ea\u30f3\u30af\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u3067\u3042\u308b\u3002
    • Normative source: SPEC-04 Acceptance Tests
    • Related: docs/demo/README.md \u00b7 docs/status/README.md

    "},{"location":"demo/runs/#english","title":"English","text":"

    \u2192 \u65e5\u672c\u8a9e\u7248\u3078

    "},{"location":"demo/runs/#what-is-stored-here","title":"What is stored here","text":"

    Every run of the acceptance tests (automated browser tests that check the environment works, see SPEC-04) creates one folder runs/<run_id>/ with:

    File Meaning results.toon Human- and AI-readable summary (TOON: a compact text form of JSON) results.json The same data for machines (canonical) junit.xml Test results in the format CI tools read screenshots/, trace/ Only when a test failed: what the browser saw

    Records are written by grdm-dev accept; do not edit them by hand. No secrets are ever written here.

    "},{"location":"demo/runs/#current-state","title":"Current state","text":"

    No runs yet. The first records are expected at milestone M2 (core services on Mac Studio).

    "},{"location":"demo/runs/#\u65e5\u672c\u8a9e","title":"\u65e5\u672c\u8a9e","text":"

    \u2192 To English

    "},{"location":"demo/runs/#\u3053\u3053\u306b\u7f6e\u304f\u3082\u306e","title":"\u3053\u3053\u306b\u7f6e\u304f\u3082\u306e","text":"

    \u53d7\u5165\u8a66\u9a13\uff08\u74b0\u5883\u304c\u52d5\u304f\u3053\u3068\u3092\u78ba\u304b\u3081\u308b\u81ea\u52d5\u306e\u30d6\u30e9\u30a6\u30b6\u8a66\u9a13\u3002SPEC-04 \u53c2\u7167\uff09\u3092\u5b9f\u884c\u3059\u308b\u305f\u3073\u306b\u3001runs/<run_id>/ \u3068\u3044\u3046\u30d5\u30a9\u30eb\u30c0\u304c\u4e00\u3064\u4f5c\u3089\u308c\u3001\u6b21\u304c\u5165\u308a\u307e\u3059\u3002

    \u30d5\u30a1\u30a4\u30eb \u610f\u5473 results.toon \u4eba\u3068 AI \u304c\u8aad\u3080\u8981\u7d04\uff08TOON: JSON \u3092\u77ed\u3044\u6587\u5b57\u3067\u8868\u3057\u305f\u5f62\uff09 results.json \u6a5f\u68b0\u304c\u8aad\u3080\u540c\u3058\u30c7\u30fc\u30bf\uff08\u6b63\u672c\uff09 junit.xml CI \u306e\u9053\u5177\u304c\u8aad\u3080\u5f62\u5f0f\u306e\u8a66\u9a13\u7d50\u679c screenshots/, trace/ \u8a66\u9a13\u304c\u5931\u6557\u3057\u305f\u3068\u304d\u3060\u3051: \u30d6\u30e9\u30a6\u30b6\u304c\u898b\u3066\u3044\u305f\u753b\u9762

    \u8a18\u9332\u306f grdm-dev accept \u304c\u66f8\u304d\u307e\u3059\u3002\u624b\u3067\u7de8\u96c6\u3057\u306a\u3044\u3067\u304f\u3060\u3055\u3044\u3002\u79d8\u5bc6\u60c5\u5831\u306f\u3053\u3053\u306b\u66f8\u304b\u308c\u307e\u305b\u3093\u3002

    "},{"location":"demo/runs/#\u3044\u307e\u306e\u72b6\u614b","title":"\u3044\u307e\u306e\u72b6\u614b","text":"

    \u307e\u3060\u5b9f\u884c\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u6700\u521d\u306e\u8a18\u9332\u306f\u7bc0\u76ee M2\uff08Mac Studio \u3067\u30b3\u30a2\u3092\u8d77\u52d5\uff09\u3067\u4f5c\u3089\u308c\u308b\u898b\u8fbc\u307f\u3067\u3059\u3002

    "},{"location":"demo/runs/#glossary--\u7528\u8a9e","title":"Glossary / \u7528\u8a9e","text":"Term English note \u65e5\u672c\u8a9e\u6ce8 Run id A short unique name for one test run, like a receipt number. \u4e00\u56de\u306e\u8a66\u9a13\u5b9f\u884c\u306b\u3064\u3051\u308b\u77ed\u3044\u540d\u524d\u3002\u30ec\u30b7\u30fc\u30c8\u756a\u53f7\u306e\u3088\u3046\u306a\u3082\u306e\u3002 JUnit XML A standard file format that test tools use to report pass/fail. \u8a66\u9a13\u306e\u9053\u5177\u304c\u5408\u5426\u3092\u5831\u544a\u3059\u308b\u3068\u304d\u306e\u6a19\u6e96\u306e\u5f62\u5f0f\u3002"},{"location":"guides/","title":"Guides / \u30ac\u30a4\u30c9","text":"

    Summary: Collection of guides for RDM addon development and environment setup \u6982\u8981: RDM \u30a2\u30c9\u30aa\u30f3\u958b\u767a\u3068\u74b0\u5883\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u306e\u305f\u3081\u306e\u30ac\u30a4\u30c9\u96c6

    Jump: English \u00b7 \u65e5\u672c\u8a9e

    • Version / \u7248: 0.1 \u2014 2026-11-05
    • Normative for: docs/guides/
    • Related: SPEC-06 Documentation Conventions

    "},{"location":"guides/#english","title":"English","text":"

    \u2192 \u65e5\u672c\u8a9e\u7248\u3078

    "},{"location":"guides/#available-guides","title":"Available Guides","text":"Title Description Environment Development environment setup with Docker Compose and the 2027 installer EC2 Setting up RDM on Amazon EC2 Skeleton Creating your first addon using the skeleton template Storage Addon Building storage addons for external services Screen Expansion Adding dashboard widgets and page tabs API Using and exposing APIs in addons Admin Addon Creating administrator-level addons with institutional management"},{"location":"guides/#\u65e5\u672c\u8a9e","title":"\u65e5\u672c\u8a9e","text":"

    \u2192 To English

    "},{"location":"guides/#\u5229\u7528\u53ef\u80fd\u306a\u30ac\u30a4\u30c9","title":"\u5229\u7528\u53ef\u80fd\u306a\u30ac\u30a4\u30c9","text":"\u30bf\u30a4\u30c8\u30eb \u8aac\u660e \u74b0\u5883 Docker Compose \u3068 2027 \u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u30fc\u3067\u306e\u958b\u767a\u74b0\u5883\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7 EC2 Amazon EC2 \u3078\u306e RDM \u30bb\u30c3\u30c8\u30a2\u30c3\u30d7 \u30b9\u30b1\u30eb\u30c8\u30f3 \u30b9\u30b1\u30eb\u30c8\u30f3\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f7f\u7528\u3057\u305f\u6700\u521d\u306e\u30a2\u30c9\u30aa\u30f3\u4f5c\u6210 \u30b9\u30c8\u30ec\u30fc\u30b8\u30a2\u30c9\u30aa\u30f3 \u5916\u90e8\u30b5\u30fc\u30d3\u30b9\u7528\u306e\u30b9\u30c8\u30ec\u30fc\u30b8\u30a2\u30c9\u30aa\u30f3\u69cb\u7bc9 \u753b\u9762\u62e1\u5f35 \u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u3068\u30da\u30fc\u30b8\u30bf\u30d6\u306e\u8ffd\u52a0 API \u30a2\u30c9\u30aa\u30f3\u3067\u306e API \u306e\u4f7f\u7528\u3068\u516c\u958b \u7ba1\u7406\u8005\u30a2\u30c9\u30aa\u30f3 \u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u3092\u6301\u3064\u7ba1\u7406\u8005\u30ec\u30d9\u30eb\u306e\u30a2\u30c9\u30aa\u30f3\u4f5c\u6210"},{"location":"guides/admin-addon/","title":"Admin Addon Guide / \u7ba1\u7406\u8005\u30a2\u30c9\u30aa\u30f3\u30ac\u30a4\u30c9","text":"

    Summary: Guide to creating administrator-level RDM addons with institutional management features \u6982\u8981: \u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u3092\u6301\u3064\u7ba1\u7406\u8005\u30ec\u30d9\u30eb\u306e RDM \u30a2\u30c9\u30aa\u30f3\u3092\u4f5c\u6210\u3059\u308b\u624b\u5f15\u304d

    Jump: English \u00b7 \u65e5\u672c\u8a9e

    • Version / \u7248: 0.1 \u2014 2026-11-05
    • Normative for: docs/guides/admin-addon/
    • Related: SPEC-06 Documentation Conventions \u00b7 Skeleton Guide

    "},{"location":"guides/admin-addon/#english","title":"English","text":"

    \u2192 \u65e5\u672c\u8a9e\u7248\u3078

    "},{"location":"guides/admin-addon/#overview","title":"Overview","text":"

    This guide shows how to create administrator-level RDM addons that include:

    • Institutional management: Control addon availability per institution
    • Admin Notes: Display special messages to users from administrators

    The administrator interface runs on a separate port (default 8001) and allows institutional administrators to manage addon settings.

    "},{"location":"guides/admin-addon/#prerequisites","title":"Prerequisites","text":"
    • Basic understanding of Python, Django, and Django admin interface
    • The development environment set up following the Environment Guide
    • Completed the Skeleton Addon Guide and API Guide
    "},{"location":"guides/admin-addon/#quick-start","title":"Quick start","text":"
    1. Create your addon using the skeleton as a base
    2. Add institutional management features to your addon
    3. Create admin templates and JavaScript configurations
    4. Deploy with admin services (admin, admin_assets)
    5. Configure institutional administrators' access
    "},{"location":"guides/admin-addon/#legacy-content","title":"Legacy content","text":"

    The legacy admin addon instructions are kept verbatim in README.legacy.md for reference and will be rewritten per milestone.

    "},{"location":"guides/admin-addon/#\u65e5\u672c\u8a9e","title":"\u65e5\u672c\u8a9e","text":"

    \u2192 To English

    "},{"location":"guides/admin-addon/#\u6982\u8981","title":"\u6982\u8981","text":"

    \u3053\u306e\u30ac\u30a4\u30c9\u306f\u3001\u4ee5\u4e0b\u306e\u6a5f\u80fd\u3092\u6301\u3064\u7ba1\u7406\u8005\u30ec\u30d9\u30eb\u306e RDM \u30a2\u30c9\u30aa\u30f3\u3092\u4f5c\u6210\u3059\u308b\u65b9\u6cd5\u3092\u793a\u3057\u307e\u3059:

    • \u6a5f\u95a2\u7ba1\u7406: \u6a5f\u95a2\u3054\u3068\u306b\u30a2\u30c9\u30aa\u30f3\u306e\u5229\u7528\u53ef\u5426\u3092\u5236\u5fa1
    • \u7ba1\u7406\u8005\u30ce\u30fc\u30c8: \u7ba1\u7406\u8005\u304b\u3089\u30e6\u30fc\u30b6\u30fc\u306b\u7279\u5225\u306a\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8868\u793a

    \u7ba1\u7406\u8005\u753b\u9762\u306f\u5225\u306e\u30dd\u30fc\u30c8\uff08\u30c7\u30d5\u30a9\u30eb\u30c8 8001\uff09\u3067\u5b9f\u884c\u3055\u308c\u3001\u6a5f\u95a2\u7ba1\u7406\u8005\u304c\u30a2\u30c9\u30aa\u30f3\u8a2d\u5b9a\u3092\u7ba1\u7406\u3067\u304d\u307e\u3059\u3002

    "},{"location":"guides/admin-addon/#\u524d\u63d0\u6761\u4ef6","title":"\u524d\u63d0\u6761\u4ef6","text":"
    • Python, Django, Django \u7ba1\u7406\u753b\u9762\u306e\u57fa\u672c\u7684\u306a\u7406\u89e3
    • \u74b0\u5883\u30ac\u30a4\u30c9\u306b\u5f93\u3063\u3066\u958b\u767a\u74b0\u5883\u3092\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3057\u3066\u3044\u308b\u3053\u3068
    • \u30b9\u30b1\u30eb\u30c8\u30f3\u30a2\u30c9\u30aa\u30f3\u30ac\u30a4\u30c9\u3068 API \u30ac\u30a4\u30c9\u3092\u5b8c\u4e86\u3057\u3066\u3044\u308b\u3053\u3068
    "},{"location":"guides/admin-addon/#\u30af\u30a4\u30c3\u30af\u30b9\u30bf\u30fc\u30c8","title":"\u30af\u30a4\u30c3\u30af\u30b9\u30bf\u30fc\u30c8","text":"
    1. \u30b9\u30b1\u30eb\u30c8\u30f3\u3092\u30d9\u30fc\u30b9\u306b\u30a2\u30c9\u30aa\u30f3\u3092\u4f5c\u6210\u3059\u308b
    2. \u30a2\u30c9\u30aa\u30f3\u306b\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u3092\u8ffd\u52a0\u3059\u308b
    3. \u7ba1\u7406\u8005\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3068 JavaScript \u8a2d\u5b9a\u3092\u4f5c\u6210\u3059\u308b
    4. admin \u30b5\u30fc\u30d3\u30b9\uff08admin, admin_assets\uff09\u3067\u30c7\u30d7\u30ed\u30a4\u3059\u308b
    5. \u6a5f\u95a2\u7ba1\u7406\u8005\u306e\u30a2\u30af\u30bb\u30b9\u3092\u8a2d\u5b9a\u3059\u308b
    "},{"location":"guides/admin-addon/#\u904e\u53bb\u306e\u30b3\u30f3\u30c6\u30f3\u30c4","title":"\u904e\u53bb\u306e\u30b3\u30f3\u30c6\u30f3\u30c4","text":"

    \u904e\u53bb\u306e\u7ba1\u7406\u8005\u30a2\u30c9\u30aa\u30f3\u306e\u624b\u9806\u306f\u3001\u53c2\u8003\u306e\u305f\u3081\u306b README.legacy.md \u306b\u305d\u306e\u307e\u307e\u6b8b\u3057\u3066\u304a\u308a\u3001\u30de\u30a4\u30eb\u30b9\u30c8\u30fc\u30f3\u3054\u3068\u306b\u66f8\u304d\u76f4\u3059\u4e88\u5b9a\u3067\u3059\u3002

    "},{"location":"guides/admin-addon/#glossary--\u7528\u8a9e","title":"Glossary / \u7528\u8a9e","text":"Term English note \u65e5\u672c\u8a9e\u6ce8 Institutional management Controlling which addons are available to each institution. \u5404\u6a5f\u95a2\u306b\u5bfe\u3057\u3066\u3069\u306e\u30a2\u30c9\u30aa\u30f3\u3092\u5229\u7528\u53ef\u80fd\u306b\u3059\u308b\u304b\u3092\u5236\u5fa1\u3059\u308b\u3053\u3068\u3002 Admin interface A separate page where institutional administrators manage settings. \u6a5f\u95a2\u7ba1\u7406\u8005\u304c\u8a2d\u5b9a\u3092\u7ba1\u7406\u3059\u308b\u305f\u3081\u306e\u5225\u306e\u30da\u30fc\u30b8\u3002 Admin Notes Special messages that administrators can display to users. \u7ba1\u7406\u8005\u304c\u30e6\u30fc\u30b6\u30fc\u306b\u8868\u793a\u3067\u304d\u308b\u7279\u5225\u306a\u30e1\u30c3\u30bb\u30fc\u30b8\u3002 Institution An organization (like a university or company) that uses RDM. RDM \u3092\u4f7f\u7528\u3059\u308b\u7d44\u7e54\uff08\u5927\u5b66\u3084\u4f1a\u793e\u306a\u3069\uff09\u3002"},{"location":"guides/admin-addon/README.legacy/","title":"\u30a2\u30c9\u30aa\u30f3\u306e\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u306e\u5229\u7528","text":"

    \u30e6\u30fc\u30b6\u306e\u6240\u5c5e\u6a5f\u95a2\u304c\u7ba1\u7406\u3067\u304d\u308b\u300c\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u300d\u306b\u304a\u3044\u3066\u3001\u30a2\u30c9\u30aa\u30f3\u306b\u95a2\u3059\u308b\u6a5f\u80fd(RDM Addon)\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002

    \u5177\u4f53\u7684\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u65b9\u6cd5\u3092\u8aac\u660e\u3057\u307e\u3059\u3002

    • \u30a2\u30c9\u30aa\u30f3\u306b\u5171\u901a\u3059\u308b\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u3092\u3001\u65b0\u3057\u304f\u8ffd\u52a0\u3057\u305f\u30a2\u30c9\u30aa\u30f3\u3067\u5229\u7528\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u65b9\u6cd5 (\u30b9\u30b1\u30eb\u30c8\u30f3 \u30a2\u30c9\u30aa\u30f3\u306e\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u306e\u5bfe\u5fdc)
    • \u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u306b\u65b0\u3057\u3044\u6a5f\u80fd\u3092\u8ffd\u52a0\u3059\u308b\u65b9\u6cd5 (Admin Notes\u306e\u5b9f\u88c5)

    \u3059\u3079\u3066\u306e\u30a2\u30c9\u30aa\u30f3\u306b\u5171\u901a\u3059\u308b\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u306f\u3001\u73fe\u5728(2021\u5e742\u6708\u57f7\u7b46\u6642\u70b9)\u3001\u30a2\u30c9\u30aa\u30f3\u306e\u7121\u52b9\u5316\u6a5f\u80fd\u306e\u307f\u3067\u3059\u3002\u6a5f\u95a2\u3054\u3068\u306b\u3001\u6307\u5b9a\u3057\u305f\u30a2\u30c9\u30aa\u30f3\u3092\u7121\u52b9\u306b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u7121\u52b9\u306a\u30a2\u30c9\u30aa\u30f3\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u3084\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30a2\u30c9\u30aa\u30f3\u8a2d\u5b9a\u753b\u9762\u306b\u8868\u793a\u3055\u308c\u306a\u304f\u306a\u308a\u3001\u5229\u7528\u3082\u3067\u304d\u306a\u304f\u306a\u308a\u307e\u3059\u3002

    "},{"location":"guides/admin-addon/README.legacy/#\u524d\u63d0\u6761\u4ef6","title":"\u524d\u63d0\u6761\u4ef6","text":"

    \u958b\u767a\u74b0\u5883\u306e\u6e96\u5099 \u306e\u30ac\u30a4\u30c9\u306b\u5f93\u3044\u3001\u958b\u767a\u74b0\u5883\u306b\u3066RDM\u3092\u8d77\u52d5\u3057\u3066\u3044\u308b\u3082\u306e\u3068\u3057\u307e\u3059\u3002

    \u672c\u30ac\u30a4\u30c9\u3067\u306f\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u3092\u5229\u7528\u3059\u308b\u305f\u3081\u3001admin \u3068 admin_assets \u30b5\u30fc\u30d3\u30b9\u3082\u8d77\u52d5\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    \u52d5\u4f5c\u78ba\u8a8d\u306e\u305f\u3081\u306e\u30e6\u30fc\u30b6\u306f\u3001 \u958b\u767a\u74b0\u5883\u306e\u6e96\u5099#\u30e6\u30fc\u30b6\u3092\u6a5f\u95a2\u306b\u6240\u5c5e\u3055\u305b\u308b \u304a\u3088\u3073 \u958b\u767a\u74b0\u5883\u306e\u6e96\u5099#admin\u30a2\u30af\u30bb\u30b9\u53ef\u80fd\u306a\u30e6\u30fc\u30b6\u3078\u3068\u5909\u66f4\u3059\u308b \u306e\u30ac\u30a4\u30c9\u306b\u5f93\u3044\u3001\u4f55\u304b\u3057\u3089\u306e\u6a5f\u95a2\u306b\u6240\u5c5e\u3057\u3001\u305d\u306e\u6a5f\u95a2\u306e\u6a5f\u95a2\u7ba1\u7406\u8005\u3067\u3042\u308b\u3068\u3057\u307e\u3059\u3002

    "},{"location":"guides/admin-addon/README.legacy/#\u30a2\u30c9\u30aa\u30f3\u306e\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u306e\u8a2d\u8a08","title":"\u30a2\u30c9\u30aa\u30f3\u306e\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u306e\u8a2d\u8a08","text":""},{"location":"guides/admin-addon/README.legacy/#\u30d5\u30a1\u30a4\u30eb\u306e\u69cb\u6210","title":"\u30d5\u30a1\u30a4\u30eb\u306e\u69cb\u6210","text":"

    \u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u3082\u30a2\u30c9\u30aa\u30f3\u3068\u540c\u69d8\u306bDjango\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u5f62\u5f0f\u3067\u8a18\u8ff0\u3055\u308c\u307e\u3059\u3002\u305f\u3060\u3057\u3001OSF.io\u672c\u4f53\u3084\u30a2\u30c9\u30aa\u30f3\u3068\u306f\u82e5\u5e72\u4e2d\u8eab\u304c\u7570\u306a\u308a\u307e\u3059\u3002

    \u30a2\u30c9\u30aa\u30f3\u306e\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd(RDM Addon)\u306e\u57fa\u672c\u7684\u306a\u30d5\u30a1\u30a4\u30eb\u914d\u7f6e\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059(Force to use\u306b\u95a2\u3059\u308b\u30d5\u30a1\u30a4\u30eb\u306f\u8a18\u8f09\u3057\u3066\u3044\u307e\u305b\u3093)\u3002

    /admin/\n\u251c\u2500\u2500 rdm_addons ... \u30a2\u30c9\u30aa\u30f3\u306e\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\n\u2502   \u251c\u2500\u2500 api_v1 ... API\u30e2\u30b8\u30e5\u30fc\u30eb\n\u2502   \u2502   \u251c\u2500\u2500 __init__.py ... \u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u5b9a\u7fa9\n\u2502   \u2502   \u251c\u2500\u2500 urls.py ... API\u306eView\u306e\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u5b9a\u7fa9\n\u2502   \u2502   \u2514\u2500\u2500 views.py ... API\u306eView\u306e\u5b9a\u7fa9\n\u2502   \u251c\u2500\u2500 __init__.py ... \u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u5b9a\u7fa9\n\u2502   \u251c\u2500\u2500 decorators.py ... \u30c7\u30b3\u30ec\u30fc\u30bf\u30fc\u306e\u5b9a\u7fa9\n\u2502   \u251c\u2500\u2500 urls.py ... View\u306e\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u5b9a\u7fa9\n\u2502   \u251c\u2500\u2500 utils.py ... \u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u95a2\u6570\u306e\u5b9a\u7fa9\n\u2502   \u2514\u2500\u2500 views.py ... View\u306e\u5b9a\u7fa9\n\u251c\u2500\u2500 static ... Web\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u8aad\u307f\u8fbc\u3080\u3053\u3068\u3092\u60f3\u5b9a\u3057\u305f\u9759\u7684\u30d5\u30a1\u30a4\u30eb\n\u2502   \u251c\u2500\u2500 css/rdm_addons.css ... \u30a2\u30c9\u30aa\u30f3\u306e\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u8a2d\u5b9a\u306eCSS\u30d5\u30a1\u30a4\u30eb\n\u2502   \u2514\u2500\u2500 rdm_addons ... \u30a2\u30c9\u30aa\u30f3\u306e\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u8a2d\u5b9a\u306eJavaScript\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\n\u2502       \u251c\u2500\u2500 \u30a2\u30c9\u30aa\u30f3\u540d ...\u30a2\u30c9\u30aa\u30f3\u3054\u3068\u306eJavaScript\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\n\u2502       \u2502   \u251c\u2500\u2500 \u30a2\u30c9\u30aa\u30f3\u540dRdmConfig.js ... \u30a2\u30c9\u30aa\u30f3\u3054\u3068\u306e\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u8a2d\u5b9a\u306e\u5b9a\u7fa9\n\u2502       \u2502   \u2514\u2500\u2500 rdm-cfg.js ... \u30a2\u30c9\u30aa\u30f3\u3054\u3068\u306e\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u8a2d\u5b9a\u306e\u30a8\u30f3\u30c8\u30ea\u3068\u306a\u308bJavaScript\u30d5\u30a1\u30a4\u30eb\n\u2502       \u251c\u2500\u2500 rdm-addons-page.js ... \u30a2\u30c9\u30aa\u30f3\u306e\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u8a2d\u5b9a\u306e\u30a8\u30f3\u30c8\u30ea\u3068\u306a\u308bJavaScript\u30d5\u30a1\u30a4\u30eb\n\u2502       \u2514\u2500\u2500 rdmAddonSettings.js ... \u30a2\u30c9\u30aa\u30f3\u306e\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u8a2d\u5b9a\u306e\u5b9a\u7fa9\n\u251c\u2500\u2500 templates ... \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\n\u2502   \u2514\u2500\u2500 rdm_addons ... \u30a2\u30c9\u30aa\u30f3\u306e\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u8a2d\u5b9a\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\n\u2502       \u251c\u2500\u2500 addons ... \u30a2\u30c9\u30aa\u30f3\u3054\u3068\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\n\u2502       \u2502   \u2514\u2500\u2500 \u30a2\u30c9\u30aa\u30f3\u540d_institution_settings.html ... \u30a2\u30c9\u30aa\u30f3\u306e\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u8a2d\u5b9a\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\n\u2502       \u251c\u2500\u2500 addon_list.html ... \u30a2\u30c9\u30aa\u30f3\u4e00\u89a7\u753b\u9762\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\n\u2502       \u2514\u2500\u2500 institution_list.html ... \u6a5f\u95a2\u4e00\u89a7\u753b\u9762\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\n\u2514\u2500\u2500 translations ... \u56fd\u969b\u5316\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\n    \u251c\u2500\u2500 en/LC_MESSAGES ... \u82f1\u8a9e\u306e\u56fd\u969b\u5316\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\n    \u2502   \u2514\u2500\u2500 django.po ... \u6a5f\u95a2\u7ba1\u7406\u753b\u9762\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u56fd\u969b\u5316\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\n    \u251c\u2500\u2500 ja/LC_MESSAGES ... \u65e5\u672c\u8a9e\u306e\u56fd\u969b\u5316\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\n    \u2502   \u2514\u2500\u2500 django.po ... \u6a5f\u95a2\u7ba1\u7406\u753b\u9762\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u56fd\u969b\u5316\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\n    \u2514\u2500\u2500 django.pot ... \u6a5f\u95a2\u7ba1\u7406\u753b\u9762\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u56fd\u969b\u5316\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\n

    \u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u306e\u30e2\u30c7\u30eb\u5b9a\u7fa9\u306f /osf/models/ \u4ee5\u4e0b\u306b\u7f6e\u304d\u307e\u3059\u3002

    /osf/models/\n\u2514\u2500\u2500 rdm_addons.py ... \u30a2\u30c9\u30aa\u30f3\u306e\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u8a2d\u5b9a\u306e\u30e2\u30c7\u30eb\u5b9a\u7fa9\n

    JavaScript\u3067\u4f7f\u3046\u56fd\u969b\u5316\u8a2d\u5b9a\u306f /website/translations/ \u4ee5\u4e0b\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002

    /website/translations/\n\u251c\u2500\u2500 en/LC_MESSAGES ... \u82f1\u8a9e\u306e\u56fd\u969b\u5316\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\n\u2502   \u2514\u2500\u2500 js_messages.po ... \u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u306eJavaScript\u3067\u4f7f\u3046\u56fd\u969b\u5316\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\n\u251c\u2500\u2500 ja/LC_MESSAGES ... \u65e5\u672c\u8a9e\u306e\u56fd\u969b\u5316\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\n\u2502   \u2514\u2500\u2500 js_messages.po ... \u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u306eJavaScript\u3067\u4f7f\u3046\u56fd\u969b\u5316\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\n\u2514\u2500\u2500 js_messages.pot ... \u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u306eJavaScript\u3067\u4f7f\u3046\u56fd\u969b\u5316\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\n

    \u30c6\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u306f /admin_tests/ \u4ee5\u4e0b\u306b\u7f6e\u304d\u307e\u3059\u3002

    /admin_tests/\n\u2514\u2500\u2500 rdm_addons ... \u30a2\u30c9\u30aa\u30f3\u306e\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u8a2d\u5b9a\u306e\u30c6\u30b9\u30c8\n    \u251c\u2500\u2500 api_v1\n    \u2502   \u251c\u2500\u2500 __init__.py\n    \u2502   \u2514\u2500\u2500 test_views.py\n    \u251c\u2500\u2500 __init__.py\n    \u251c\u2500\u2500 factories.py\n    \u2514\u2500\u2500 test_views.py\n
    "},{"location":"guides/admin-addon/README.legacy/#\u30a2\u30c9\u30aa\u30f3\u306e\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u69cb\u6210","title":"\u30a2\u30c9\u30aa\u30f3\u306e\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u69cb\u6210","text":"

    \u30a2\u30c9\u30aa\u30f3\u3068\u540c\u69d8\u3001Django\u306e\u4f5c\u6cd5\u306b\u5f93\u3044\u3001Model-View\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u306b\u3088\u308a\u5b9f\u88c5\u3057\u307e\u3059\u3002

    "},{"location":"guides/admin-addon/README.legacy/#model\u306e\u69cb\u6210","title":"Model\u306e\u69cb\u6210","text":"

    \u6a5f\u95a2\u3054\u3068\u306e\u30a2\u30c9\u30aa\u30f3\u306e\u8a2d\u5b9a\u3092\u4fdd\u6301\u3059\u308b RdmAddonOption \u30e2\u30c7\u30eb\u304a\u3088\u3073 RdmAddonNoInstitutionOption \u30e2\u30c7\u30eb\u304c osf/models/rdm_addons.py \u306b\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u8a2d\u5b9a\u9805\u76ee\u3092\u8ffd\u52a0\u3059\u308b\u5834\u5408\u306f\u3001\u3053\u308c\u3089\u30e2\u30c7\u30eb\u3092\u5909\u66f4\u3057\u307e\u3059\u3002

    "},{"location":"guides/admin-addon/README.legacy/#view\u306e\u69cb\u6210","title":"View\u306e\u69cb\u6210","text":"

    View\u306e\u5b9a\u7fa9\u65b9\u6cd5\u306f\u30a2\u30c9\u30aa\u30f3\u3068\u7570\u306a\u3063\u3066\u3044\u308b\u3088\u3046\u306b\u898b\u3048\u307e\u3059\u304c\u3001\u57fa\u672c\u7684\u306a\u8003\u3048\u65b9\u306f\u540c\u3058\u3067\u3059\u3002

    \u30eb\u30fc\u30c6\u30a3\u30f3\u30b0(\u30a2\u30c9\u30aa\u30f3\u306b\u304a\u3051\u308broutes.py)\u306f admin/rdm_addons/urls.py \u306b\u5b9a\u7fa9\u3057\u3001\u5404View\u51e6\u7406\u306f admin/rdm_addons/views.py \u306b\u5b9a\u7fa9\u3057\u307e\u3059\u3002

    API\u306b\u95a2\u3059\u308bView\u5b9a\u7fa9\u306f\u3001 admin/rdm_addons/api_v1/urls.py \u3068 admin/rdm_addons/api_v1/views.py \u306b\u5b9a\u7fa9\u3057\u307e\u3059\u3002

    "},{"location":"guides/admin-addon/README.legacy/#\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306b\u3088\u3063\u3066\u63d0\u4f9b\u3055\u308c\u308bview","title":"\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306b\u3088\u3063\u3066\u63d0\u4f9b\u3055\u308c\u308bView","text":"

    HTML\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3068JavaScript\u306e\u5b9a\u7fa9\u65b9\u6cd5\u3084\u3001\u5229\u7528\u3067\u304d\u308b\u30e9\u30a4\u30d6\u30e9\u30ea\u306f\u3001\u30a2\u30c9\u30aa\u30f3\u3068\u4f3c\u3066\u3044\u307e\u3059\u3002

    HTML\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u306f admin/templates/rdm_addons/ \u4ee5\u4e0b\u306b\u914d\u7f6e\u3057\u307e\u3059\u3002\u62e1\u5f35\u5b50\u304c.html\u3067\u3059\u304c\u3001\u30a2\u30c9\u30aa\u30f3\u3068\u540c\u69d8\u306b\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u8a00\u8a9e mako \u3067\u8a18\u8ff0\u3057\u307e\u3059\u3002 \u5404\u30a2\u30c9\u30aa\u30f3\u306b\u95a2\u3059\u308b\u8a2d\u5b9a\u753b\u9762\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u306f\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u3067 admin/templates/rdm_addons/addons/institution_settings_default.html \u304c\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002\u500b\u5225\u306b\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u6307\u5b9a\u3059\u308b\u65b9\u6cd5\u306f #UI \u306e\u8ffd\u52a0 \u3067\u8aac\u660e\u3057\u307e\u3059\u3002

    \u5404\u753b\u9762\u3067\u8aad\u307f\u8fbc\u3080JavaScript\u30d5\u30a1\u30a4\u30eb\u306f admin/static/js/rdm_addons/ \u4ee5\u4e0b\u306b\u914d\u7f6e\u3057\u307e\u3059\u3002\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u52d5\u7684\u306b\u64cd\u4f5c\u3059\u308b\u305f\u3081\u306eJavaScript\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u306b\u306f Knockout.js \u3092\u5229\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 \u30a2\u30c9\u30aa\u30f3\u3068\u9055\u3044\u3001\u8ffd\u52a0\u3057\u305f\u30a8\u30f3\u30c8\u30ea\u30fc\u30d5\u30a1\u30a4\u30eb\u306f admin/webpack.admin.config.js \u306e entry \u30d7\u30ed\u30d1\u30c6\u30a3\u306b\u8ffd\u52a0\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3053\u3068\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u8a2d\u5b9a\u65b9\u6cd5\u306f #UI \u306e\u8ffd\u52a0 \u3067\u8aac\u660e\u3057\u307e\u3059\u3002

    \u5404\u753b\u9762\u306b\u95a2\u3059\u308b\u30b9\u30bf\u30a4\u30eb\u5b9a\u7fa9\u306f admin/static/css/rdm_addons.css \u306b\u307e\u3068\u3081\u3066\u8a18\u8ff0\u3057\u307e\u3059\u3002

    \u6a5f\u95a2\u7ba1\u7406\u8005\u753b\u9762\u3067\u306f\u3001ember-osf-web\u3067\u5229\u7528\u3067\u304d\u308b\u3088\u3046\u306aUI Component\u306f\u63d0\u4f9b\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u304c\u3001 Bootstrap3 \u306eCSS\u3084\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002

    "},{"location":"guides/admin-addon/README.legacy/#\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9","title":"\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9","text":"

    \u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u306f admin_tests/rdm_addons \u4ee5\u4e0b\u306b\u4f5c\u6210\u3057\u307e\u3059\u3002

    "},{"location":"guides/admin-addon/README.legacy/#migrations\u5b9a\u7fa9","title":"Migrations\u5b9a\u7fa9","text":"

    Migrations\u30d5\u30a1\u30a4\u30eb\u306f osf/migrations \u4ee5\u4e0b\u306b\u4f5c\u6210\u3055\u308c\u307e\u3059\u3002Migrations\u30d5\u30a1\u30a4\u30eb\u306e\u69cb\u9020\u306f\u30a2\u30c9\u30aa\u30f3\u3068\u540c\u69d8\u3067\u3059\u3002

    "},{"location":"guides/admin-addon/README.legacy/#\u56fd\u969b\u5316","title":"\u56fd\u969b\u5316","text":"

    HTML\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3067\u4f7f\u3046\u56fd\u969b\u5316\u8a2d\u5b9a\u306f admin/translations/ \u4ee5\u4e0b\u306e django.pot \u304a\u3088\u3073 django.po \u306b\u5b9a\u7fa9\u3057\u307e\u3059\u3002

    JavaScript\u3067\u4f7f\u3046\u56fd\u969b\u5316\u8a2d\u5b9a\u306f website/translations/ \u4ee5\u4e0b\u306e js_messages.pot \u304a\u3088\u3073 js_messages.po \u306b\u5b9a\u7fa9\u3057\u307e\u3059\u3002

    \u5b9a\u7fa9\u65b9\u6cd5\u3084\u4f7f\u3044\u65b9\u306f\u3001 ScreenExpansion#\u56fd\u969b\u5316 \u3067\u8aac\u660e\u3057\u3066\u3044\u307e\u3059\u3002HTML\u30d5\u30a1\u30a4\u30eb\u5185\u3067\u6587\u5b57\u5217\u3092\u56fd\u969b\u5316\u3059\u308b\u65b9\u6cd5\u306f\u3001mako\u3068\u540c\u69d8\u3067\u3059\u3002

    JavaScript\u3060\u3051\u3001website/translations/ \u4ee5\u4e0b\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u306b\u6c17\u3092\u3064\u3051\u3066\u304f\u3060\u3055\u3044\u3002

    "},{"location":"guides/admin-addon/README.legacy/#\u30b9\u30b1\u30eb\u30c8\u30f3-\u30a2\u30c9\u30aa\u30f3\u306e\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u306e\u5bfe\u5fdc","title":"\u30b9\u30b1\u30eb\u30c8\u30f3 \u30a2\u30c9\u30aa\u30f3\u306e\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u306e\u5bfe\u5fdc","text":"

    myskelton \u3068\u3044\u3046\u8b58\u5225\u540d\u306e\u30a2\u30c9\u30aa\u30f3\u3092\u3001\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u3067\u7ba1\u7406\u3059\u308b\u305f\u3081\u306e\u5b9f\u88c5\u3092\u4f8b\u306b\u8aac\u660e\u3057\u307e\u3059\u3002

    \u30b9\u30b1\u30eb\u30c8\u30f3\u306e\u4f5c\u6210#\u30b9\u30b1\u30eb\u30c8\u30f3 \u30a2\u30c9\u30aa\u30f3\u306e\u5b9f\u88c5 \u306b\u5f93\u3044\u3001\u30b9\u30b1\u30eb\u30c8\u30f3 \u30a2\u30c9\u30aa\u30f3\u306e\u5b9f\u88c5\u304c\u5b8c\u4e86\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u524d\u63d0\u3068\u3057\u307e\u3059\u3002

    "},{"location":"guides/admin-addon/README.legacy/#addonsmyskelton-\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u5909\u66f4","title":"addons.myskelton \u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u5909\u66f4","text":"

    \u30b9\u30c8\u30ec\u30fc\u30b8\u30a2\u30c9\u30aa\u30f3\u306e\u5834\u5408\u3001\u3053\u306e\u5909\u66f4\u306f\u4e0d\u8981\u3067\u3059\u3002

    \u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u3067\u7ba1\u7406\u3059\u308b\u30a2\u30c9\u30aa\u30f3\u306f\u3001AppConfig.config \u306b accounts \u304c\u542b\u307e\u308c\u3066\u3044\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 AppConfig.config \u306b accounts \u304c\u542b\u307e\u308c\u3066\u3044\u308b\u30a2\u30c9\u30aa\u30f3\u306f\u3001\u30e6\u30fc\u30b6\u306e\u30a2\u30c9\u30aa\u30f3\u30a2\u30ab\u30a6\u30f3\u30c8\u69cb\u6210\u753b\u9762\u306b\u8868\u793a\u3055\u308c\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306fOAuth\u306e\u8a8d\u8a3c\u8a2d\u5b9aUI\u3092\u542b\u3080\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u304c\u53c2\u7167\u3055\u308c\u307e\u3059\u3002\u30b9\u30b1\u30eb\u30c8\u30f3 \u30a2\u30c9\u30aa\u30f3\u306f\u8a8d\u8a3c\u8a2d\u5b9a\u304c\u4e0d\u8981\u306a\u306e\u3067\u3001\u30a2\u30c9\u30aa\u30f3\u540d\u3092\u8868\u793a\u3059\u308b\u3060\u3051\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u5b9a\u7fa9\u3057\u3066\u3001\u305d\u308c\u3092\u53c2\u7167\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002

    \u307e\u305a\u306f user_settings.mako \u3092 addons/myskelton/templates/user_settings.mako \u306b\u3001user-cfg.js \u3092 addons/myskelton/static/user-cfg.js \u306b\u30b3\u30d4\u30fc\u3057\u307e\u3059\u3002

    \u6b21\u306b\u3001addons/myskelton/apps.py \u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5909\u66f4\u3057\u307e\u3059\u3002 \u5909\u66f4\u4f8b\u306f\u30b5\u30f3\u30d7\u30eb apps.py \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    class AddonAppConfig(BaseAddonAppConfig):\n\n-    configs = ['node']\n+    configs = ['node', 'accounts']\n\n     node_settings_template = os.path.join(TEMPLATE_PATH, 'node_settings.mako')\n+    user_settings_template = os.path.join(TEMPLATE_PATH, 'user_settings.mako')\n\n     # \u4ed6\u5909\u66f4\u306a\u3057\n
    "},{"location":"guides/admin-addon/README.legacy/#rdm\u30b3\u30fc\u30c9\u306e\u5909\u66f4","title":"RDM\u30b3\u30fc\u30c9\u306e\u5909\u66f4","text":""},{"location":"guides/admin-addon/README.legacy/#adminbasesettingsdefaultspy-\u3078\u306e\u8ffd\u52a0","title":"admin/base/settings/defaults.py \u3078\u306e\u8ffd\u52a0","text":"

    admin/base/settings/defaults.py \u306e INSTALLED_APPS \u306b\u30a2\u30c9\u30aa\u30f3\u540d\u3092\u3001MIGRATION_MODULES \u306b\u30ad\u30fc\u304c\u30a2\u30c9\u30aa\u30f3\u540d\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002

    INSTALLED_APPS \u306b\u8ffd\u52a0\u3059\u308b\u5024\u306f addons.\u30a2\u30c9\u30aa\u30f3\u540d \u3067\u3059\u304c\u3001MIGRATION_MODULES \u306b\u8ffd\u52a0\u3059\u308b\u30ad\u30fc\u540d\u306f addons_\u30a2\u30c9\u30aa\u30f3\u540d \u3067\u3059\u3002. \u3068 _ \u306e\u9055\u3044\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    \u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f\u3001Force to use\u3068\u3044\u3046\u3001\u6a5f\u95a2\u306b\u5c5e\u3059\u308b\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u30a2\u30c9\u30aa\u30f3\u3092\u5f37\u5236\u7684\u306b\u6709\u52b9\u306b\u3059\u308b\u6a5f\u80fd\u304c\u5229\u7528\u3067\u304d\u307e\u3059\u3002\u3057\u304b\u3057\u3001\u3053\u306e\u6a5f\u80fd\u3092\u5229\u7528\u3059\u308b\u305f\u3081\u306b\u306f\u3001\u8a8d\u8a3c\u60c5\u5831\u3092\u4fdd\u5b58\u3059\u308b\u305f\u3081\u306e\u4ed5\u7d44\u307f\u3092\u30a2\u30c9\u30aa\u30f3\u306b\u5b9f\u88c5\u3057\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u30b9\u30b1\u30eb\u30c8\u30f3 \u30a2\u30c9\u30aa\u30f3\u306f\u8a8d\u8a3c\u60c5\u5831\u3092\u6301\u305f\u306a\u3044\u305f\u3081\u3001UNSUPPORTED_FORCE_TO_USE_ADDONS \u306b\u30a2\u30c9\u30aa\u30f3\u540d\u3092\u8ffd\u52a0\u3057\u3001\u3053\u306e\u6a5f\u80fd\u3092\u7121\u52b9\u306b\u3057\u307e\u3059\u3002

    \u5b9f\u88c5\u4f8b\u306f\u30b5\u30f3\u30d7\u30eb defaults.py \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    "},{"location":"guides/admin-addon/README.legacy/#\u30b9\u30b1\u30eb\u30c8\u30f3-\u30a2\u30c9\u30aa\u30f3\u306e\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u306e\u52d5\u4f5c\u78ba\u8a8d","title":"\u30b9\u30b1\u30eb\u30c8\u30f3 \u30a2\u30c9\u30aa\u30f3\u306e\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u306e\u52d5\u4f5c\u78ba\u8a8d","text":"

    \u30b9\u30b1\u30eb\u30c8\u30f3 \u30a2\u30c9\u30aa\u30f3\u3092\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u3067\u7ba1\u7406\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002

    \u5909\u66f4\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u306b\u95a2\u9023\u3059\u308b\u30b5\u30fc\u30d3\u30b9\u3092\u518d\u8d77\u52d5\u3057\u307e\u3059\u3002

    $ docker compose restart web api assets admin\n

    \u3053\u308c\u3067\u30b5\u30fc\u30d3\u30b9\u3078\u306e\u53cd\u6620\u306f\u5b8c\u4e86\u3067\u3059\u3002\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u3067\u30b9\u30b1\u30eb\u30c8\u30f3 \u30a2\u30c9\u30aa\u30f3\u306e\u8a2d\u5b9a\u3092\u5909\u66f4\u3067\u304d\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u64cd\u4f5c\u3092\u5b9f\u65bd\u3057\u307e\u3059\u3002

    1. RDM Web UI\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b http://localhost:5000
    2. \u300c\u30a2\u30c9\u30aa\u30f3\u30a2\u30ab\u30a6\u30f3\u30c8\u69cb\u6210\u300d\u30da\u30fc\u30b8\u3092\u958b\u304f\u3002
    3. My Skelton\u30a2\u30c9\u30aa\u30f3\u304c\u8868\u793a\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b\u3002
    4. \u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u306eWeb UI\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b http://localhost:8001
    5. RDM Addons\u30da\u30fc\u30b8\u3092\u958b\u304f\u3002
    6. \u81ea\u5206\u306e\u6240\u5c5e\u6a5f\u95a2\u306e\u30da\u30fc\u30b8\u3092\u958b\u304f\u3002
    7. My Skelton\u30a2\u30c9\u30aa\u30f3\u306e\u5de6\u306e\u30c1\u30a7\u30c3\u30af\u30dc\u30c3\u30af\u30b9\u3092\u5916\u3057\u3001\u30a2\u30c9\u30aa\u30f3\u3092\u7121\u52b9\u5316\u3059\u308b\u3002
    8. \u518d\u5ea6\u3001RDM Web UI\u3067\u300c\u30a2\u30c9\u30aa\u30f3\u30a2\u30ab\u30a6\u30f3\u30c8\u69cb\u6210\u300d\u30da\u30fc\u30b8\u3092\u958b\u304f\u3002
    9. My Skelton\u30a2\u30c9\u30aa\u30f3\u304c\u8868\u793a\u3055\u308c\u3066\u3044\u306a\u3044\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b\u3002

    \u4ee5\u4e0a\u3067\u30b9\u30b1\u30eb\u30c8\u30f3 \u30a2\u30c9\u30aa\u30f3\u306e\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u306e\u52d5\u4f5c\u78ba\u8a8d\u306f\u5b8c\u4e86\u3067\u3059\uff01

    "},{"location":"guides/admin-addon/README.legacy/#admin-notes\u306e\u5b9f\u88c5","title":"Admin Notes\u306e\u5b9f\u88c5","text":"

    \u3053\u3053\u3067\u306f\u3001\u6a5f\u95a2\u7ba1\u7406\u8005\u304c\u3001\u30b9\u30b1\u30eb\u30c8\u30f3 \u30a2\u30c9\u30aa\u30f3\u306b\u95a2\u3059\u308b\u30e6\u30fc\u30b6\u3078\u306e\u6ce8\u610f\u66f8\u304d\u3092\u8a2d\u5b9a\u3067\u304d\u308b Admin Notes \u3068\u3044\u3046\u6a5f\u80fd\u306e\u5b9f\u88c5\u3092\u4f8b\u306b\u8aac\u660e\u3057\u307e\u3059\u3002

    \u30b9\u30b1\u30eb\u30c8\u30f3 \u30a2\u30c9\u30aa\u30f3\u306e\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u306e\u5bfe\u5fdc \u304c\u5b8c\u4e86\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u524d\u63d0\u3068\u3057\u307e\u3059\u3002

    "},{"location":"guides/admin-addon/README.legacy/#rdm\u30b3\u30fc\u30c9\u306e\u5909\u66f4_1","title":"RDM\u30b3\u30fc\u30c9\u306e\u5909\u66f4","text":""},{"location":"guides/admin-addon/README.legacy/#rdmaddonoption-\u30e2\u30c7\u30eb\u306e\u5909\u66f4","title":"RdmAddonOption \u30e2\u30c7\u30eb\u306e\u5909\u66f4","text":"

    osf/models/rdm_addons.py \u306e RdmAddonOption \u30e2\u30c7\u30eb\u304a\u3088\u3073 RdmAddonNoInstitutionOption \u30e2\u30c7\u30eb\u306b\u3001Admin Notes\u306e\u5185\u5bb9\u3092\u4fdd\u5b58\u3059\u308b admin_notes \u30ab\u30e9\u30e0\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002 \u5909\u66f4\u4f8b\u306f\u30b5\u30f3\u30d7\u30eb rdm_addons.py \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    "},{"location":"guides/admin-addon/README.legacy/#api\u306e\u8ffd\u52a0","title":"API\u306e\u8ffd\u52a0","text":"

    Admin Notes\u3092\u53d6\u5f97\u30fb\u8a2d\u5b9a\u3059\u308b\u305f\u3081\u306eAPI\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002

    admin/rdm_addons/api_v1/views.py \u306b AdminNotesView \u30af\u30e9\u30b9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002 \u5909\u66f4\u4f8b\u306f\u30b5\u30f3\u30d7\u30eb views.py \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    admin/rdm_addons/api_v1/urls.py \u306b AdminNotesView \u3078\u306e\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u8a2d\u5b9a\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002 \u5909\u66f4\u4f8b\u306f\u30b5\u30f3\u30d7\u30eb urls.py \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    "},{"location":"guides/admin-addon/README.legacy/#ui\u306e\u8ffd\u52a0","title":"UI\u306e\u8ffd\u52a0","text":"

    Admin Notes\u3092\u8a2d\u5b9a\u3059\u308b\u305f\u3081\u306eUI\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002 \u4eca\u56de\u306f\u3001\u30b9\u30b1\u30eb\u30c8\u30f3 \u30a2\u30c9\u30aa\u30f3\u306b\u5bfe\u3057\u3066\u306e\u307fAdmin Notes\u3092\u8a2d\u5b9a\u3067\u304d\u308b\u3088\u3046\u306b\u3001\u30b9\u30b1\u30eb\u30c8\u30f3 \u30a2\u30c9\u30aa\u30f3\u7528\u306e\u8a2d\u5b9aUI\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002

    \u4ee5\u4e0b\u306b\u5f93\u3063\u3066\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u3068JavaScript\u30d5\u30a1\u30a4\u30eb\u3092\u30b3\u30d4\u30fc\u3057\u307e\u3059\u3002

    • myskelton_institution_settings.html \u3092 admin/templates/rdm_addons/addons/myskelton_institution_settings.html \u306b\u30b3\u30d4\u30fc\u3059\u308b\u3002
    • myskeltonRdmConfig.js \u3092 admin/static/js/rdm_addons/myskelton/myskeltonRdmConfig.js \u306b\u30b3\u30d4\u30fc\u3059\u308b\u3002
    • rdm-cfg.js \u3092 admin/static/js/rdm_addons/myskelton/rdm-cfg.js \u306b\u30b3\u30d4\u30fc\u3059\u308b\u3002

    \u4f5c\u6210\u3057\u305f\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3080\u3088\u3046\u306b\u3001 admin/rdm_addons/utils.py \u306e get_institusion_settings_template() \u95a2\u6570\u306e\u4e00\u90e8\u3092\u5909\u66f4\u3057\u307e\u3059\u3002 \u5909\u66f4\u4f8b\u306f\u30b5\u30f3\u30d7\u30eb utils.py \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    \u4f5c\u6210\u3057\u305fJavaScript\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3080\u3088\u3046\u306b\u3001 admin/webpack.admin.config.js \u306e entry \u306b rdm-myskelton-cfg \u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002 \u5909\u66f4\u4f8b\u306f\u30b5\u30f3\u30d7\u30eb webpack.admin.config.js \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    \u30a2\u30c9\u30aa\u30f3\u306e\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fdUI\u3067\u8aad\u307f\u8fbc\u307e\u308c\u308bCSS\u30d5\u30a1\u30a4\u30eb admin/static/css/rdm_addons.css \u306b\u3001Admin Notes\u306b\u95a2\u3059\u308bCSS\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002 \u5909\u66f4\u4f8b\u306f\u30b5\u30f3\u30d7\u30eb rdm_addons.css \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    "},{"location":"guides/admin-addon/README.legacy/#addonsmyskelton-\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u5909\u66f4_1","title":"addons.myskelton \u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u5909\u66f4","text":"

    Admin Notes\u306e\u5185\u5bb9\u3092\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u300c\u30a2\u30c9\u30aa\u30f3\u3092\u69cb\u6210\u300d\u30da\u30fc\u30b8\u306b\u8868\u793a\u3059\u308b\u305f\u3081\u306e\u5909\u66f4\u3092\u52a0\u3048\u307e\u3059\u3002

    "},{"location":"guides/admin-addon/README.legacy/#api\u306e\u8ffd\u52a0_1","title":"API\u306e\u8ffd\u52a0","text":"

    Admin Notes\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u306eAPI\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002

    addons/myskelton/views.py \u306b myskelton_get_admin_notes \u95a2\u6570\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002 \u5909\u66f4\u4f8b\u306f\u30b5\u30f3\u30d7\u30eb views.py \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    addons/myskelton/routes.py \u306b myskelton_get_admin_notes \u3078\u306e\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u8a2d\u5b9a\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002 \u5909\u66f4\u4f8b\u306f\u30b5\u30f3\u30d7\u30eb routes.py \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    "},{"location":"guides/admin-addon/README.legacy/#ui\u306e\u8ffd\u52a0_1","title":"UI\u306e\u8ffd\u52a0","text":"

    Admin Notes\u3092\u8868\u793a\u3059\u308b\u305f\u3081\u306eUI\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002

    addons/myskelton/templates/node_settings.mako \u306bAdmin Notes\u3092\u8868\u793a\u3059\u308b\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002 \u5909\u66f4\u4f8b\u306f\u30b5\u30f3\u30d7\u30eb node_settings.mako \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    addons/myskelton/static/node-cfg.js \u306bAdmin Notes\u3092\u8aad\u307f\u8fbc\u3080\u95a2\u6570\u3068Admin Notes\u306e\u5185\u5bb9\u3092\u4fdd\u6301\u3059\u308b\u5909\u6570\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002 \u5909\u66f4\u4f8b\u306f\u30b5\u30f3\u30d7\u30eb node-cfg.js \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    "},{"location":"guides/admin-addon/README.legacy/#\u56fd\u969b\u5316_1","title":"\u56fd\u969b\u5316","text":"

    website/translations/ \u4ee5\u4e0b\u306e\u30d5\u30a1\u30a4\u30eb js_messages.* \u306e\u672b\u5c3e\u306b\u3001Admin Notes\u306b\u95a2\u3059\u308b\u56fd\u969b\u5316\u8a2d\u5b9a\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002 \u5909\u66f4\u4f8b\u306f\u30b5\u30f3\u30d7\u30eb website/translations/ \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    admin/translations/ \u4ee5\u4e0b\u306e\u5404\u30d5\u30a1\u30a4\u30eb\u306e\u672b\u5c3e\u306b\u3001Admin Notes\u306b\u95a2\u3059\u308b\u56fd\u969b\u5316\u8a2d\u5b9a\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002 \u5909\u66f4\u4f8b\u306f\u30b5\u30f3\u30d7\u30eb admin/translations/ \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    "},{"location":"guides/admin-addon/README.legacy/#\u30c6\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u306e\u5909\u66f4","title":"\u30c6\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u306e\u5909\u66f4","text":""},{"location":"guides/admin-addon/README.legacy/#admin_testsrdm_addonsapi_v1test_viewspy-\u306e\u5909\u66f4","title":"admin_tests/rdm_addons/api_v1/test_views.py \u306e\u5909\u66f4","text":"

    \u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u306b\u8ffd\u52a0\u3057\u305fAPI\u306e\u30c6\u30b9\u30c8\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002

    admin_tests/rdm_addons/api_v1/test_views.py \u306b\u3001Admin Notes\u53d6\u5f97\u30fb\u8a2d\u5b9aAPI\u3092\u30c6\u30b9\u30c8\u3059\u308b TestAdminNotesView \u30af\u30e9\u30b9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002 \u5909\u66f4\u4f8b\u306f\u30b5\u30f3\u30d7\u30eb test_views.py \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    "},{"location":"guides/admin-addon/README.legacy/#addonsmyskeltonteststest_viewpy-\u306e\u5909\u66f4","title":"addons/myskelton/tests/test_view.py \u306e\u5909\u66f4","text":"

    \u30b9\u30b1\u30eb\u30c8\u30f3 \u30a2\u30c9\u30aa\u30f3\u306eAdmin Notes\u306e\u53d6\u5f97API\u306e\u30c6\u30b9\u30c8\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002

    addons/myskelton/tests/test_view.py \u306b\u3001Admin Notes\u53d6\u5f97API\u3092\u30c6\u30b9\u30c8\u3059\u308b TestAdminNotesViews \u30af\u30e9\u30b9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002 \u5909\u66f4\u4f8b\u306f\u30b5\u30f3\u30d7\u30eb test_views.py \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    "},{"location":"guides/admin-addon/README.legacy/#migrations\u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210","title":"Migrations\u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210","text":"

    makemigrations \u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u3001Migrations\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002

    $ docker compose run --rm web python3 manage.py makemigrations\n

    \u4e0a\u8a18\u306e\u51fa\u529b\u4e2d\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u51fa\u529b\u304c\u73fe\u308c\u308c\u3070\u6210\u529f\u3067\u3059\u3002

    osf/migrations \u914d\u4e0b\u306b\u4f5c\u6210\u3055\u308c\u308b\u30d5\u30a1\u30a4\u30eb\u540d\u306f\u3001\u4f5c\u6210\u65e5\u6642\u3084RDM\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306b\u3088\u3063\u3066\u7570\u306a\u308a\u307e\u3059\u3002

    Migrations for 'osf':\n  osf/migrations/0214_auto_20210214_1431.py\n    - Add field admin_notes to rdmaddonnoinstitutionoption\n    - Add field admin_notes to rdmaddonoption\n
    "},{"location":"guides/admin-addon/README.legacy/#\u30c6\u30b9\u30c8","title":"\u30c6\u30b9\u30c8","text":"

    \u30a2\u30c9\u30aa\u30f3\u306e\u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u306b\u304a\u3051\u308bAdmin Notes\u306b\u95a2\u3059\u308b\u30e6\u30cb\u30c3\u30c8\u30c6\u30b9\u30c8\u306f\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002

    $ docker compose run --rm web invoke test_module -m admin_tests/rdm_addons/api_v1/test_views.py::TestAdminNotesView\n

    \u30b9\u30b1\u30eb\u30c8\u30f3 \u30a2\u30c9\u30aa\u30f3\u306b\u304a\u3051\u308bAdmin Notes\u306b\u95a2\u3059\u308b\u30e6\u30cb\u30c3\u30c8\u30c6\u30b9\u30c8\u306f\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002

    $ docker compose run --rm web invoke test_module -m addons/myskelton/tests/test_view.py::TestAdminNotesViews\n
    "},{"location":"guides/admin-addon/README.legacy/#admin-notes\u306e\u52d5\u4f5c\u78ba\u8a8d","title":"Admin Notes\u306e\u52d5\u4f5c\u78ba\u8a8d","text":"

    Admin Notes\u306e\u52d5\u4f5c\u3092\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002

    "},{"location":"guides/admin-addon/README.legacy/#db\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3","title":"DB\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3","text":"

    \u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u884c\u3057\u3001Migrations\u5b9a\u7fa9\u3092PostgreSQL\u30b5\u30fc\u30d3\u30b9\u306b\u53cd\u6620\u3057\u307e\u3059\u3002

    $ docker compose run --rm web python3 manage.py migrate\n
    "},{"location":"guides/admin-addon/README.legacy/#\u56fd\u969b\u5316\u306e\u30b3\u30f3\u30d1\u30a4\u30eb","title":"\u56fd\u969b\u5316\u306e\u30b3\u30f3\u30d1\u30a4\u30eb","text":"

    \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u306e\u56fd\u969b\u5316\u8a2d\u5b9a\u3092\u9069\u7528\u3059\u308b\u305f\u3081\u306b\u3001\u56fd\u969b\u5316\u30d5\u30a1\u30a4\u30eb\u3092\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u307e\u3059\u3002

    $ docker compose run --rm web pybabel compile -D django -d ./admin/translations\n
    "},{"location":"guides/admin-addon/README.legacy/#\u30b5\u30fc\u30d3\u30b9\u306e\u518d\u8d77\u52d5","title":"\u30b5\u30fc\u30d3\u30b9\u306e\u518d\u8d77\u52d5","text":"

    \u5909\u66f4\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u306b\u95a2\u3059\u308b\u30b5\u30fc\u30d3\u30b9\u3092\u518d\u8d77\u52d5\u3057\u307e\u3059\u3002

    $ docker compose restart web api assets admin admin_assets\n

    \u3053\u308c\u3067\u30b5\u30fc\u30d3\u30b9\u3078\u306e\u53cd\u6620\u306f\u5b8c\u4e86\u3067\u3059\u3002

    "},{"location":"guides/admin-addon/README.legacy/#admin-notes\u3092\u8a66\u3059","title":"Admin Notes\u3092\u8a66\u3059","text":"

    Admin Notes\u306e\u8a2d\u5b9a\u304a\u3088\u3073\u8868\u793a\u306e\u78ba\u8a8d\u3092\u3059\u308b\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u64cd\u4f5c\u3092\u5b9f\u65bd\u3057\u307e\u3059\u3002

    1. \u6a5f\u95a2\u7ba1\u7406\u6a5f\u80fd\u306eWeb UI\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3002 http://localhost:8001
    2. \u30a2\u30c9\u30aa\u30f3\u5229\u7528\u5236\u5fa1(RDM Addons)\u30da\u30fc\u30b8\u3092\u958b\u304f\u3002
    3. \u81ea\u5206\u306e\u6240\u5c5e\u6a5f\u95a2\u306e\u30da\u30fc\u30b8\u3092\u958b\u304f\u3002
    4. My Skelton\u30a2\u30c9\u30aa\u30f3\u306e\u4e2d\u306e\u7ba1\u7406\u8005\u30ce\u30fc\u30c8(Admin Notes)\u306e\u4e0b\u306b\u3042\u308b\u30c6\u30ad\u30b9\u30c8\u30dc\u30c3\u30af\u30b9\u306b\u4efb\u610f\u306e\u30c6\u30ad\u30b9\u30c8\u3092\u5165\u529b\u3057\u3001\u4fdd\u5b58\u3059\u308b\u3002
    5. RDM Web UI\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3002 http://localhost:5000
    6. \u9069\u5f53\u306a\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3059\u308b\u3002
    7. \u300c\u30a2\u30c9\u30aa\u30f3\u300d\u30da\u30fc\u30b8\u3092\u958b\u304f\u3002
    8. My Skelton\u30a2\u30c9\u30aa\u30f3\u3092\u6709\u52b9\u5316\u3059\u308b\u3002
    9. \u300c\u30a2\u30c9\u30aa\u30f3\u3092\u69cb\u6210\u300d\u306eMy Skelton\u306e\u6b04\u306b\u3001\u8a2d\u5b9a\u3057\u305fAdmin Notes\u304c\u8868\u793a\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b\u3002

    \u4ee5\u4e0a\u3067Admin Notes\u306e\u52d5\u4f5c\u78ba\u8a8d\u306f\u5b8c\u4e86\u3067\u3059\uff01

    "},{"location":"guides/api/","title":"API Guide / API \u30e6\u30fc\u30ac\u30a4\u30c9","text":"

    Summary: Guide to using and exposing APIs in RDM addons \u6982\u8981: RDM \u30a2\u30c9\u30aa\u30f3\u3067 API \u3092\u4f7f\u7528\u304a\u3088\u3073\u516c\u958b\u3059\u308b\u624b\u5f15\u304d

    Jump: English \u00b7 \u65e5\u672c\u8a9e

    • Version / \u7248: 0.1 \u2014 2026-11-05
    • Normative for: docs/guides/api/
    • Related: SPEC-06 Documentation Conventions \u00b7 Skeleton Guide

    "},{"location":"guides/api/#english","title":"English","text":"

    \u2192 \u65e5\u672c\u8a9e\u7248\u3078

    "},{"location":"guides/api/#overview","title":"Overview","text":"

    This guide explains how to:

    • Expose your addon's functionality via API: Allow other systems to access your addon
    • Use existing APIs in your addon: Interact with RDM and other addons

    RDM addons can be accessed via HTTP(S) RESTful APIs, enabling integration with external systems and other RDM addons.

    "},{"location":"guides/api/#prerequisites","title":"Prerequisites","text":"
    • Basic understanding of Python, Django, and REST APIs
    • The development environment set up following the Environment Guide
    • Completed the Skeleton Addon Guide
    "},{"location":"guides/api/#quick-start","title":"Quick start","text":"
    1. Define Routes and Views in your addon to create API endpoints
    2. Use decorators to control access (authentication, permissions)
    3. Test your API with curl or Postman
    4. Integrate with external systems using standard HTTP requests
    "},{"location":"guides/api/#legacy-content","title":"Legacy content","text":"

    The legacy API guide instructions are kept verbatim in README.legacy.md for reference and will be rewritten per milestone.

    "},{"location":"guides/api/#\u65e5\u672c\u8a9e","title":"\u65e5\u672c\u8a9e","text":"

    \u2192 To English

    "},{"location":"guides/api/#\u6982\u8981","title":"\u6982\u8981","text":"

    \u3053\u306e\u30ac\u30a4\u30c9\u3067\u306f\u3001\u4ee5\u4e0b\u306e\u65b9\u6cd5\u3092\u8aac\u660e\u3057\u307e\u3059:

    • \u30a2\u30c9\u30aa\u30f3\u306e\u6a5f\u80fd\u3092 API \u3067\u516c\u958b: \u4ed6\u306e\u30b7\u30b9\u30c6\u30e0\u304c\u30a2\u30c9\u30aa\u30f3\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b
    • \u65e2\u5b58\u306e API \u3092\u30a2\u30c9\u30aa\u30f3\u3067\u4f7f\u7528: RDM \u3084\u4ed6\u306e\u30a2\u30c9\u30aa\u30f3\u3068\u9023\u643a\u3059\u308b

    RDM \u30a2\u30c9\u30aa\u30f3\u306f HTTP(S) RESTful API \u3067\u30a2\u30af\u30bb\u30b9\u53ef\u80fd\u3067\u3001\u5916\u90e8\u30b7\u30b9\u30c6\u30e0\u3084\u4ed6\u306e RDM \u30a2\u30c9\u30aa\u30f3\u3068\u306e\u9023\u643a\u304c\u3067\u304d\u307e\u3059\u3002

    "},{"location":"guides/api/#\u524d\u63d0\u6761\u4ef6","title":"\u524d\u63d0\u6761\u4ef6","text":"
    • Python, Django, REST API \u306e\u57fa\u672c\u7684\u306a\u7406\u89e3
    • \u74b0\u5883\u30ac\u30a4\u30c9\u306b\u5f93\u3063\u3066\u958b\u767a\u74b0\u5883\u3092\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3057\u3066\u3044\u308b\u3053\u3068
    • \u30b9\u30b1\u30eb\u30c8\u30f3\u30a2\u30c9\u30aa\u30f3\u30ac\u30a4\u30c9\u3092\u5b8c\u4e86\u3057\u3066\u3044\u308b\u3053\u3068
    "},{"location":"guides/api/#\u30af\u30a4\u30c3\u30af\u30b9\u30bf\u30fc\u30c8","title":"\u30af\u30a4\u30c3\u30af\u30b9\u30bf\u30fc\u30c8","text":"
    1. \u30a2\u30c9\u30aa\u30f3\u3067\u30eb\u30fc\u30c8\u3068\u30d3\u30e5\u30fc\u3092\u5b9a\u7fa9\u3057\u3066 API \u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3092\u4f5c\u6210\u3059\u308b
    2. \u30c7\u30b3\u30ec\u30fc\u30bf\u30fc\u3092\u4f7f\u7528\u3057\u3066\u30a2\u30af\u30bb\u30b9\u3092\u5236\u5fa1\uff08\u8a8d\u8a3c\u3001\u6a29\u9650\uff09
    3. curl \u3084 Postman \u3067 API \u3092\u30c6\u30b9\u30c8\u3059\u308b
    4. \u6a19\u6e96\u7684\u306a HTTP \u30ea\u30af\u30a8\u30b9\u30c8\u3092\u4f7f\u7528\u3057\u3066\u5916\u90e8\u30b7\u30b9\u30c6\u30e0\u3068\u9023\u643a\u3059\u308b
    "},{"location":"guides/api/#\u904e\u53bb\u306e\u30b3\u30f3\u30c6\u30f3\u30c4","title":"\u904e\u53bb\u306e\u30b3\u30f3\u30c6\u30f3\u30c4","text":"

    \u904e\u53bb\u306e API \u30ac\u30a4\u30c9\u306e\u624b\u9806\u306f\u3001\u53c2\u8003\u306e\u305f\u3081\u306b README.legacy.md \u306b\u305d\u306e\u307e\u307e\u6b8b\u3057\u3066\u304a\u308a\u3001\u30de\u30a4\u30eb\u30b9\u30c8\u30fc\u30f3\u3054\u3068\u306b\u66f8\u304d\u76f4\u3059\u4e88\u5b9a\u3067\u3059\u3002

    "},{"location":"guides/api/#glossary--\u7528\u8a9e","title":"Glossary / \u7528\u8a9e","text":"Term English note \u65e5\u672c\u8a9e\u6ce8 API (Application Programming Interface) A way for programs to talk to each other using HTTP requests. \u30d7\u30ed\u30b0\u30e9\u30e0\u304c HTTP \u30ea\u30af\u30a8\u30b9\u30c8\u3092\u4f7f\u7528\u3057\u3066\u901a\u4fe1\u3059\u308b\u65b9\u6cd5\u3002 RESTful API An API that follows standard HTTP methods (GET, POST, PUT, DELETE). \u6a19\u6e96\u7684\u306a HTTP \u30e1\u30bd\u30c3\u30c9\uff08GET, POST, PUT, DELETE\uff09\u306b\u5f93\u3063\u305f API\u3002 Decorator A special marker that controls who can access an API endpoint. API \u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3078\u306e\u30a2\u30af\u30bb\u30b9\u3092\u5236\u5fa1\u3059\u308b\u7279\u5225\u306a\u30de\u30fc\u30af\u3002 Authentication Verifying who is making the API request (like a username and password). API \u30ea\u30af\u30a8\u30b9\u30c8\u3092\u4f5c\u6210\u3057\u305f\u4eba\u304c\u8ab0\u304b\u3092\u78ba\u8a8d\u3059\u308b\u3053\u3068\uff08\u30e6\u30fc\u30b6\u30fc\u540d\u3068\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u3088\u3046\u306a\u3082\u306e\uff09\u3002 Authorization Checking what the user is allowed to do after logging in. \u30ed\u30b0\u30a4\u30f3\u3057\u305f\u5f8c\u306e\u30e6\u30fc\u30b6\u30fc\u304c\u4f55\u3092\u3067\u304d\u308b\u304b\u3092\u78ba\u8a8d\u3059\u308b\u3053\u3068\u3002"},{"location":"guides/api/Decorators/","title":"View\u51e6\u7406\u3067\u4f7f\u3048\u308bPython\u30c7\u30b3\u30ec\u30fc\u30bf","text":"

    views.py \u3067\u5b9a\u7fa9\u3055\u308c\u308b\u5404View\u51e6\u7406\u306b\u306f\u3001\u305d\u306e\u51e6\u7406\u306e\u5b9f\u884c\u306b\u304a\u3051\u308b\u524d\u63d0\u3092Python\u306e\u30c7\u30b3\u30ec\u30fc\u30bf\u306e\u5f62\u3067\u8a18\u8ff0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002

    \u3053\u3053\u3067\u306f\u3001\u3088\u304f\u4f7f\u308f\u308c\u3066\u3044\u308b\u30c7\u30b3\u30ec\u30fc\u30bf\u3084\u3001\u30ab\u30b9\u30bf\u30e0\u30c7\u30b3\u30ec\u30fc\u30bf\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002

    "},{"location":"guides/api/Decorators/#frameworkauthdecoratorsmust_be_logged_in","title":"framework.auth.decorators.must_be_logged_in","text":"

    \u30e6\u30fc\u30b6\u304c\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u3044\u308b\u72b6\u614b\u3067\u3042\u308b\u5834\u5408\u306b\u306e\u307f\u547c\u3073\u51fa\u3057\u53ef\u80fd\u3067\u3042\u308b\u3053\u3068\u3092\u5ba3\u8a00\u3057\u307e\u3059\u3002

    \u5f15\u6570( **kwargs )\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3059\u3002

    • auth : \u8a8d\u8a3c\u3057\u3066\u3044\u308b\u30e6\u30fc\u30b6\u306b\u95a2\u3059\u308b\u60c5\u5831
    "},{"location":"guides/api/Decorators/#websiteprojectdecoratorsmust_be_valid_project","title":"website.project.decorators.must_be_valid_project","text":"

    \u5bfe\u8c61\u306enode\u304c\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3068\u3057\u3066\u8a8d\u3081\u3089\u308c\u308b\u3082\u306e\u3067\u3042\u308b\u3053\u3068\u3092\u5ba3\u8a00\u3057\u307e\u3059\u3002

    \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3068\u3057\u3066\u8a8d\u3081\u3089\u308c\u306a\u3044node\u3068\u306f\u3001QuickFileNode\u3084\u64a4\u56de\u3055\u308c\u305fRegistration\u306a\u3069\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u73fe\u5728\u3001RDM\u3067\u306f\u4f7f\u7528\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002

    \u5f15\u6570( **kwargs )\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3059\u3002

    • node : \u5bfe\u8c61\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u95a2\u3059\u308b\u60c5\u5831
    "},{"location":"guides/api/Decorators/#websiteprojectdecoratorsmust_have_addonaddon_name-model","title":"website.project.decorators.must_have_addon(addon_name, model)","text":"

    \u30a2\u30c9\u30aa\u30f3\u306b\u95a2\u3059\u308b\u60c5\u5831\u3092\u5fc5\u8981\u3068\u3059\u308b\u3053\u3068\u3092\u5ba3\u8a00\u3057\u307e\u3059\u3002\u7b2c1\u5f15\u6570( addon_name )\u306b\u306f\u30a2\u30c9\u30aa\u30f3\u540d\u3092\u3001\u7b2c2\u5f15\u6570( model )\u306b\u306f 'user' \u304b 'node' \u306e\u3044\u305a\u308c\u304b\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002 'node' \u3092\u6307\u5b9a\u3057\u305f\u5834\u5408\u306f\u3001\u30d1\u30b9\u306f /project/<pid>/ \u304b\u3089\u59cb\u3081\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002

    \u5f15\u6570( **kwargs )\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3059\u3002

    • \u5f15\u6570 model \u306b 'user' \u3092\u6307\u5b9a\u3057\u305f\u5834\u5408
    • auth : \u8a8d\u8a3c\u3057\u3066\u3044\u308b\u30e6\u30fc\u30b6\u306b\u95a2\u3059\u308b\u60c5\u5831
    • user_addon \u6307\u5b9a\u3057\u305f\u30a2\u30c9\u30aa\u30f3\u306eUserSettings
    • \u5f15\u6570 model \u306b 'node' \u3092\u6307\u5b9a\u3057\u305f\u5834\u5408
    • node : \u5bfe\u8c61\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u95a2\u3059\u308b\u60c5\u5831
    • node_addon \u6307\u5b9a\u3057\u305f\u30a2\u30c9\u30aa\u30f3\u306eNodeSettings
    "},{"location":"guides/api/Decorators/#websiteprojectdecoratorsmust_have_permissionpermission","title":"website.project.decorators.must_have_permission(permission)","text":"

    \u5fc5\u8981\u306a\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3( permission )\u3092\u5ba3\u8a00\u3057\u307e\u3059\u3002\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u306f osf.utils.permissions \u306b\u5b9a\u7fa9\u3055\u308c\u3066\u304a\u308a\u3001 'write' , 'read' , 'admin' \u306e\u3044\u305a\u308c\u304b\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002

    \u5f15\u6570( **kwargs )\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3059\u3002

    • auth : \u8a8d\u8a3c\u3057\u3066\u3044\u308b\u30e6\u30fc\u30b6\u306b\u95a2\u3059\u308b\u60c5\u5831
    • node : \u5bfe\u8c61\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u95a2\u3059\u308b\u60c5\u5831
    "},{"location":"guides/api/Decorators/#websiteprojectdecoratorsmust_be_addon_authorizeraddon_name","title":"website.project.decorators.must_be_addon_authorizer(addon_name)","text":"

    \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u30a2\u30c9\u30aa\u30f3\u3092\u8ffd\u52a0\u3057\u305f\u30e6\u30fc\u30b6\u30fc\u306e\u307f\u547c\u3073\u51fa\u3057\u53ef\u80fd\u3067\u3042\u308b\u3053\u3068\u3092\u5ba3\u8a00\u3057\u307e\u3059\u3002\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30a2\u30c9\u30aa\u30f3\u306e\u8a2d\u5b9a\u306b\u306e\u307f\u4f7f\u308f\u308c\u308bView\u51e6\u7406\u306a\u3069\u306b\u5ba3\u8a00\u3057\u307e\u3059\u3002

    \u5f15\u6570( **kwargs )\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3059\u3002

    • node : \u5bfe\u8c61\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u95a2\u3059\u308b\u60c5\u5831
    "},{"location":"guides/api/Decorators/#websiteprojectdecoratorsmust_be_contributor_or_public","title":"website.project.decorators.must_be_contributor_or_public","text":"

    \u30e6\u30fc\u30b6\u30fc\u304cContributor\u3067\u3042\u308b\u304b\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u304c\u516c\u958b\u8a2d\u5b9a\u306b\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u306e\u307f\u547c\u3073\u51fa\u3057\u53ef\u80fd\u3067\u3042\u308b\u3053\u3068\u3092\u5ba3\u8a00\u3057\u307e\u3059\u3002

    \u4f3c\u305f\u3088\u3046\u306a\u30c7\u30b3\u30ec\u30fc\u30bf\u3068\u3057\u3066\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u3082\u306e\u304c\u3042\u308a\u307e\u3059\u3002

    • must_be_contributor
    • must_be_contributor_or_public_but_not_anonymized
    • must_be_contributor_and_not_group_member

    \u5f15\u6570( **kwargs )\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3059\u3002

    • auth : \u8a8d\u8a3c\u3057\u3066\u3044\u308b\u30e6\u30fc\u30b6\u306b\u95a2\u3059\u308b\u60c5\u5831
    • node : \u5bfe\u8c61\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u95a2\u3059\u308b\u60c5\u5831
    "},{"location":"guides/api/Decorators/#adminrdm_addonsdecoratorsmust_be_rdm_addons_allowed","title":"admin.rdm_addons.decorators.must_be_rdm_addons_allowed","text":"

    \u30e6\u30fc\u30b6\u30fc\u304c\u6240\u5c5e\u3059\u308b\u6a5f\u95a2\u304c\u3001\u6307\u5b9a\u3057\u305f\u30a2\u30c9\u30aa\u30f3\u3092\u4f7f\u3046\u3053\u3068\u3092\u8a31\u53ef\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u306b\u306e\u307f\u547c\u3073\u51fa\u3057\u53ef\u80fd\u3067\u3042\u308b\u3053\u3068\u3092\u5ba3\u8a00\u3057\u307e\u3059\u3002\u3053\u306e\u6a5f\u80fd\u306fAdmin\u306eRdm Addons\u6a5f\u80fd\u306b\u3088\u308a\u63d0\u4f9b\u3055\u308c\u3066\u3044\u307e\u3059\u3002

    "},{"location":"guides/api/README.legacy/","title":"API\u306e\u5229\u7528","text":"

    RDM\u304c\u7814\u7a76\u30c7\u30fc\u30bf\u3092\u52b9\u679c\u7684\u306b\u7ba1\u7406\u3059\u308b\u305f\u3081\u306b\u306f\u3001\u5916\u90e8\u30b7\u30b9\u30c6\u30e0\u3068\u306e\u9023\u643a\u3084\u65e2\u5b58\u306eRDM\u30a2\u30c9\u30aa\u30f3\u3068\u306e\u9023\u643a\u3092\u884c\u3046\u5fc5\u8981\u304c\u51fa\u3066\u304f\u308b\u3067\u3057\u3087\u3046\u3002 \u3053\u306e\u3088\u3046\u306a\u6642\u3001\u5916\u90e8\u30b7\u30b9\u30c6\u30e0\u3084RDM\u304a\u3088\u3073\u30a2\u30c9\u30aa\u30f3\u306e\u9593\u306e\u5883\u754c\u9762\u3001\u7279\u306bAPI(Application Programming Interface)\u3092\u610f\u8b58\u3057\u306a\u304c\u3089\u6a5f\u80fd\u3092\u5b9f\u88c5\u3059\u308b\u3053\u3068\u3067\u3001\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u6027\u3092\u7dad\u6301\u3057\u305f\u308a\u3001\u4eca\u5f8c\u306e\u62e1\u5f35\u3092\u5bb9\u6613\u306b\u3057\u305f\u308a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002

    \u672c\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3067\u306f\u30a2\u30c9\u30aa\u30f3\u306b\u304a\u3051\u308b\u5b9f\u88c5\u306b\u7740\u76ee\u3057\u3001\u30a2\u30c9\u30aa\u30f3\u3092\u5916\u90e8\u30b7\u30b9\u30c6\u30e0\u304b\u3089\u64cd\u4f5c\u53ef\u80fd\u306b\u3059\u308b\u65b9\u6cd5(\u30a2\u30c9\u30aa\u30f3API\u306e\u516c\u958b)\u3068\u3001\u30a2\u30c9\u30aa\u30f3\u304b\u3089RDM\u3092\u64cd\u4f5c\u3059\u308b\u65b9\u6cd5(\u65e2\u5b58API\u306b\u3088\u308b\u64cd\u4f5c)\u306e2\u3064\u306e\u89b3\u70b9\u3067\u8aac\u660e\u3057\u307e\u3059\u3002

    "},{"location":"guides/api/README.legacy/#\u30a2\u30c9\u30aa\u30f3api\u306e\u516c\u958b","title":"\u30a2\u30c9\u30aa\u30f3API\u306e\u516c\u958b","text":"

    \u30a2\u30c9\u30aa\u30f3\u306e\u6a5f\u80fd\u306b\u5bfe\u3057\u3066\u3001\u4ed6\u306e\u30b7\u30b9\u30c6\u30e0\u304b\u3089\u30a2\u30af\u30bb\u30b9\u53ef\u80fd\u306b\u3059\u308b\u305f\u3081\u306eAPI\u306e\u8003\u3048\u65b9\u3001\u5b9a\u7fa9\u65b9\u6cd5\u3092\u8aac\u660e\u3057\u307e\u3059\u3002

    "},{"location":"guides/api/README.legacy/#api\u306e\u5b9f\u88c5","title":"API\u306e\u5b9f\u88c5","text":"

    \u5916\u90e8\u30b7\u30b9\u30c6\u30e0\u304c\u30a2\u30c9\u30aa\u30f3\u306e\u6a5f\u80fd\u306b\u5bfe\u3057\u3066\u30a2\u30af\u30bb\u30b9\u3059\u308b\u5834\u5408\u306f\u3001HTTP(S)\u306b\u3088\u308bRESTful API\u547c\u3073\u51fa\u3057\u3092\u5229\u7528\u3059\u308b\u306e\u304c\u4fbf\u5229\u3067\u3059\u3002 RDM\u30a2\u30c9\u30aa\u30f3\u306f \u30b9\u30b1\u30eb\u30c8\u30f3 \u306e\u8ffd\u52a0\u65b9\u6cd5\u3067\u8aac\u660e\u3057\u305f\u3088\u3046\u306b\u3001Django\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u5f62\u3067\u5b9f\u88c5\u3055\u308c\u307e\u3059\u3002 \u305d\u306e\u305f\u3081\u3001Django\u3084RDM\u304c\u63d0\u4f9b\u3059\u308b\u5404\u7a2e\u88dc\u52a9\u6a5f\u80fd\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002

    HTTP(S)\u3067\u547c\u3073\u51fa\u3057\u53ef\u80fd\u306a\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3092\u5b9a\u7fa9\u3059\u308b\u5834\u5408\u3001\u30d3\u30e5\u30fc\u306b\u3088\u308a\u5b9f\u88c5\u3059\u308b\u306e\u304c\u4e00\u822c\u7684\u3067\u3059\u3002 \u30b9\u30b1\u30eb\u30c8\u30f3\u306e\u4f5c\u6210#View\u306e\u69cb\u6210 \u306b\u793a\u3059\u3088\u3046\u306b\u3001\u5b9a\u7fa9\u306f\u4ee5\u4e0b\u306e2\u7a2e\u985e\u304b\u3089\u69cb\u6210\u3055\u308c\u307e\u3059\u3002

    • Routes ... View\u51e6\u7406\u3092\u3069\u306e\u30d1\u30b9\u306b\u30de\u30c3\u30d4\u30f3\u30b0\u3057\u3001\u3069\u306e\u3088\u3046\u306a\u5f62\u5f0f\u3067\u51fa\u529b\u3059\u308b\u304b\u3002\u51fa\u529b\u306b\u306fJSON\u5f62\u5f0f\u3084\u3001HTML\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b
    • Views ... View\u51e6\u7406\u306e\u5185\u5bb9

    Routes\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30d1\u30b9\u3068Method(GET, POST, PUT, DELETE, ...)\u3068\u3001\u305d\u306e\u7d44\u307f\u5408\u308f\u305b\u306b\u5bfe\u3057\u3066\u3069\u306e\u95a2\u6570\u3092\u5b9f\u884c\u3059\u308b\u304b\u3001\u305d\u306e\u5b9f\u884c\u7d50\u679c\u3092\u3069\u306e\u3088\u3046\u306b\u51fa\u529b\u3059\u308b\u304b\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002 \u4f8b\u3048\u3070\u3001\u753b\u9762\u62e1\u5f35\u306e\u4f8b\u3067\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5b9a\u7fa9\u3057\u3066\u3044\u307e\u3059\u3002

    api_routes = {\n    'rules': [\n        ...\n        Rule([ # (1)\n            '/project/<pid>/{}/config'.format(SHORT_NAME),\n            '/project/<pid>/node/<nid>/{}/config'.format(SHORT_NAME),\n        ], 'get', views.myscreen_get_config_ember, json_renderer),\n        Rule([ # (2)\n            '/project/<pid>/{}/config'.format(SHORT_NAME),\n            '/project/<pid>/node/<nid>/{}/config'.format(SHORT_NAME),\n        ], 'patch', views.myscreen_set_config_ember, json_renderer),\n        ...\n    ],\n}\n

    \u30eb\u30fc\u30eb(1)\u306f\u3001/project/<pid>/\u30a2\u30c9\u30aa\u30f3\u540d/config \u3068\u3044\u3046\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3078\u306eGET\u30ea\u30af\u30a8\u30b9\u30c8\u306b\u5bfe\u3059\u308b\u51e6\u7406\u3092\u3001views\u30e2\u30b8\u30e5\u30fc\u30eb\u3067\u5b9a\u7fa9\u3057\u305fmyscreen_get_config_ember\u3068\u3044\u3046\u95a2\u6570\u306b\u884c\u308f\u305b\u308b\u3053\u3068\u3092\u5b9a\u7fa9\u3057\u3066\u3044\u307e\u3059\u3002json_renderer\u306f\u3001\u95a2\u6570\u306e\u623b\u308a\u5024\u3068\u3057\u3066\u8fd4\u3055\u308c\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092 JSON\u306b\u5909\u63db\u3001\u30ec\u30b9\u30dd\u30f3\u30b9\u3068\u3057\u3066\u8fd4\u3059\u3053\u3068\u3092\u5b9a\u7fa9\u3057\u3066\u3044\u307e\u3059\u3002 \u540c\u69d8\u306b\u3001\u30eb\u30fc\u30eb(2)\u306fPATCH\u30ea\u30af\u30a8\u30b9\u30c8\u306b\u5bfe\u3057\u3066\u306fmyscreen_set_config_ember\u3067\u51e6\u7406\u3059\u308b\u3053\u3068\u3092\u793a\u3057\u3066\u3044\u307e\u3059\u3002

    Views\u3067\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u95a2\u6570\u3092\u5b9a\u7fa9\u3057\u3066\u3044\u307e\u3059\u3002

    @must_be_valid_project\n@must_have_permission('admin')\n@must_have_addon(SHORT_NAME, 'node')\ndef myscreen_get_config_ember(**kwargs):\n    node = kwargs['node'] or kwargs['project']\n    addon = node.get_addon(SHORT_NAME)\n    return {'data': {'id': node._id, 'type': 'myscreen-config',\n                     'attributes': {\n                         'param1': addon.get_param_1()\n                     }}}\n\n@must_be_valid_project\n@must_have_permission('admin')\n@must_have_addon(SHORT_NAME, 'node')\ndef myscreen_set_config_ember(**kwargs):\n    node = kwargs['node'] or kwargs['project']\n    addon = node.get_addon(SHORT_NAME)\n    try:\n        config = request.json['data']['attributes']\n        param_1 = config['param1']\n    except KeyError:\n        raise HTTPError(http_status.HTTP_400_BAD_REQUEST)\n\n    addon.set_param_1(param_1)\n    return {'data': {'id': node._id, 'type': 'myscreen-config',\n                     'attributes': {\n                         'param1': param_1\n                     }}}\n

    \u3044\u305a\u308c\u3082\u3001@must_\u304b\u3089\u59cb\u307e\u308b\u30c7\u30b3\u30ec\u30fc\u30bf\u3068\u3001def\u304b\u3089\u59cb\u307e\u308b\u95a2\u6570\u5b9a\u7fa9\u30d6\u30ed\u30c3\u30af\u304b\u3089\u69cb\u6210\u3055\u308c\u307e\u3059\u3002 \u30c7\u30b3\u30ec\u30fc\u30bf\u306f\u3001\u3053\u308c\u3089\u306e\u95a2\u6570\u306b\u95a2\u3059\u308b\u8a8d\u53ef\u306e\u8981\u5426\u3084\u3001\u4f7f\u7528\u53ef\u80fd\u306a\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u6761\u4ef6\u3092\u5b9a\u7fa9\u3057\u3066\u3044\u307e\u3059\u3002 \u307e\u305f\u3001kwargs\u306b\u306f\u95a2\u6570\u306b\u4e0e\u3048\u3089\u308c\u305f\u5f15\u6570\u304c\u683c\u7d0d\u3055\u308c\u307e\u3059\u3002node\u3084project\u306b\u306f\u3001Django Model\u304c\u683c\u7d0d\u3055\u308c\u307e\u3059\u3002 (\u30c7\u30b3\u30ec\u30fc\u30bf\u306e\u5b9a\u7fa9\u306b\u3088\u3063\u3066\u306f\u3001\u683c\u7d0d\u3055\u308c\u306a\u3044\u5834\u5408\u3082\u3042\u308a\u307e\u3059\u3002) \u30a2\u30c9\u30aa\u30f3\u306f\u3053\u308c\u3089\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4ecb\u3057\u3066\u3001RDM\u5185\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u5185\u5bb9\u3092\u64cd\u4f5c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 (\u753b\u9762\u62e1\u5f35\u306e\u4f8b\u3067\u306f\u3001Ember\u3067\u5b9a\u7fa9\u3057\u305f\u753b\u9762\u304b\u3089\u3053\u308c\u3089\u306e\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306b\u5bfe\u3057\u3066\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u51fa\u3057\u3066\u3044\u307e\u3059\u3002)

    \u3053\u308c\u3089\u306e\u30ed\u30b8\u30c3\u30af\u306e\u8a18\u8ff0\u65b9\u6cd5\u306f\u4e00\u822c\u7684\u306aDjango\u306e\u30eb\u30fc\u30eb\u306b\u5247\u3063\u3066\u3044\u307e\u3059\u3002\u3057\u305f\u304c\u3063\u3066\u3001Django\u3084Flask\u306a\u3069\u306ePython\u306e Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306e\u77e5\u8b58\u304c\u3042\u308c\u3070\u6bd4\u8f03\u7684\u7c21\u5358\u306b\u5b9f\u88c5\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3067\u3057\u3087\u3046\u3002 \u307e\u305f\u3001RDM\u3067\u306f\u30a2\u30af\u30bb\u30b9\u5236\u5fa1\u3084\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u5236\u9650\u306b\u4fbf\u5229\u306a\u30c7\u30b3\u30ec\u30fc\u30bf\u3092\u63d0\u4f9b\u3057\u3066\u3044\u307e\u3059\u3002RDM\u304c\u63d0\u4f9b\u3059\u308b\u30c7\u30b3\u30ec\u30fc\u30bf\u4e00\u89a7\u3092\u53c2\u8003\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    "},{"location":"guides/api/README.legacy/#api\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3","title":"API\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3","text":"

    API\u30a2\u30af\u30bb\u30b9\u306f\u9069\u5207\u306a\u30e6\u30fc\u30b6\u3001\u307e\u305f\u306f\u30b7\u30b9\u30c6\u30e0\u304b\u3089\u306e\u307f\u5229\u7528\u53ef\u80fd\u306a\u3088\u3046\u306b\u30a2\u30af\u30bb\u30b9\u5236\u5fa1\u3092\u884c\u3046\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 \u30a2\u30af\u30bb\u30b9\u5236\u5fa1\u65b9\u5f0f\u306e\u5b9f\u73fe\u65b9\u6cd5\u3068\u3057\u3066\u3001\u30e6\u30fc\u30b6\u306b\u3088\u308b\u8a8d\u53ef\u3092\u7d4c\u3066\u30a2\u30af\u30bb\u30b9\u3092\u884c\u3046\u65b9\u5f0f\u3068\u3001\u72ec\u81ea\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u6a5f\u69cb\u3092\u8a2d\u3051\u308b\u65b9\u5f0f\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002

    "},{"location":"guides/api/README.legacy/#\u30e6\u30fc\u30b6\u306b\u3088\u308b\u8a8d\u53ef","title":"\u30e6\u30fc\u30b6\u306b\u3088\u308b\u8a8d\u53ef","text":"

    \u5148\u306eViews\u306e\u4f8b\u3067\u306f\u3001 @must_have_permission('admin') \u3068\u3044\u3046\u5f62\u3067\u3001\u3053\u306e\u64cd\u4f5c\u306fadmin\u6a29\u9650\u3092\u6301\u3063\u3066\u3044\u308b\u30e6\u30fc\u30b6\u306b\u3057\u304b\u5b9f\u65bd\u3067\u304d\u306a\u3044\u3053\u3068\u3092\u5ba3\u8a00\u3057\u3066\u3044\u307e\u3059\u3002 \u4ed6\u306b\u3082\u3001write\u6a29\u9650\u304c\u5fc5\u8981\u3067\u3042\u308b\u3068\u304b\u3001\u69d8\u3005\u306a\u6a29\u9650\u306e\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u304c\u8003\u3048\u3089\u308c\u307e\u3059\u3002

    \u3053\u3053\u3067\u91cd\u8981\u306a\u306e\u306f\u3001\u30e6\u30fc\u30b6\u306b\u3088\u3063\u3066\u3001\u64cd\u4f5c\u53ef\u80fd\u306a\u7bc4\u56f2\u304c\u7570\u306a\u308b\u3068\u3044\u3046\u70b9\u3068\u3001\u30e6\u30fc\u30b6\u306f\u30a2\u30c9\u30aa\u30f3\u3092\u7121\u5236\u9650\u306b\u4fe1\u983c\u3057\u3066\u304f\u308c\u308b\u308f\u3051\u3067\u306f\u306a\u3044\u3068\u3044\u3046\u70b9\u3067\u3059\u3002 \u30e6\u30fc\u30b6\u306e\u8b58\u5225\u306fWeb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u3068\u3063\u3066\u306f\u5f53\u305f\u308a\u524d\u306e\u3053\u3068\u3067\u3059\u304c\u3001API\u306b\u3088\u308b\u64cd\u4f5c\u3092\u8003\u3048\u308b\u5834\u5408\u306b\u3082\u975e\u5e38\u306b\u91cd\u8981\u306a\u70b9\u3068\u306a\u308a\u307e\u3059\u3002 \u305f\u3060\u3001API\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u5074\u306b\u300c\u79c1\u306fxx\u3067\u3059\u300d\u3068\u3044\u3046\u7533\u544a\u3092\u6c42\u3081\u308b\u308f\u3051\u306b\u306f\u3044\u304d\u307e\u305b\u3093\u3002\u8a50\u79f0\u3055\u308c\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u304b\u3089\u3067\u3059\u3002 \u307e\u305f\u3001\u79d8\u5bc6\u306e\u60c5\u5831(\u30d1\u30b9\u30ef\u30fc\u30c9\u30fb\u79d8\u5bc6\u9375\u7b49)\u3067\u64cd\u4f5c\u306e\u4e3b\u304c\u8a8d\u8a3c\u3067\u304d\u305f\u3068\u3057\u3066\u3082\u3001\u305d\u306e\u30e6\u30fc\u30b6\u306f\u3053\u306e\u30a2\u30c9\u30aa\u30f3\u3092\u7121\u5236\u9650\u306b\u4fe1\u983c\u3057\u3066\u304f\u308c\u308b\u3068\u8003\u3048\u308b\u3079\u304d\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002 (RDM\u81ea\u4f53\u306f\u4fe1\u983c\u3057\u3066\u4f7f\u3063\u3066\u3082\u3089\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u304c\u3001RDM\u306eAPI\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u306f\u4fe1\u983c\u3055\u308c\u3066\u3044\u308b\u3068\u306f\u9650\u308a\u307e\u305b\u3093\u3002) \u305d\u306e\u305f\u3081\u3001\u300c\u3053\u306e\u30a2\u30c9\u30aa\u30f3\u306f\u60c5\u5831yy\u306e\u8aad\u307f\u8fbc\u307f\u3060\u3051\u3092\u3057\u307e\u3059\u300d\u3067\u3042\u308b\u3068\u304b\u3001\u300c\u8aad\u307f\u8fbc\u307f\u3068\u66f8\u304d\u8fbc\u307f\u3092\u3057\u307e\u3059\u300d\u3067\u3042\u308b\u3068\u304b\u3001\u7bc4\u56f2\u3092\u9650\u5b9a\u3057\u3066\u30e6\u30fc\u30b6\u3078\u306e\u8a31\u53ef\u3092\u6c42\u3081\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002

    "},{"location":"guides/api/README.legacy/#personal-access-token\u306b\u3088\u308b\u8a8d\u53ef","title":"Personal Access Token\u306b\u3088\u308b\u8a8d\u53ef","text":"

    \u3053\u306e\u3088\u3046\u306a\u3001\u30e6\u30fc\u30b6\u306e\u6a29\u9650\u3092\u884c\u4f7f\u3059\u308b\u305f\u3081\u306e\u6a5f\u69cb\u306e\u4e00\u3064\u304c\u3001Personal Access Token\u3067\u3059\u3002RDM\u306e\u30e6\u30fc\u30b6\u306e [\u8a2d\u5b9a] \u753b\u9762\u304b\u3089\u3001 [\u30d1\u30fc\u30bd\u30ca\u30eb\u30a2\u30af\u30bb\u30b9\u30c8\u30fc\u30af\u30f3] \u3067\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002

    [\u65b0\u898f\u30c8\u30fc\u30af\u30f3] \u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001\u65b0\u898f\u30c8\u30fc\u30af\u30f3\u3092\u767a\u884c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002

    \u65b0\u898f\u30c8\u30fc\u30af\u30f3\u306e\u767a\u884c\u306e\u969b\u306b\u3001\u30b9\u30b3\u30fc\u30d7\u3068\u3044\u3046\u8907\u6570\u306e\u30c1\u30a7\u30c3\u30af\u9805\u76ee\u304c\u73fe\u308c\u307e\u3059\u3002\u3053\u308c\u304c\u8a8d\u53ef\u306e\u7bc4\u56f2\u3092\u793a\u3057\u3066\u3044\u307e\u3059\u3002(\u8a73\u7d30\u306f \u30b9\u30b3\u30fc\u30d7\u306e\u5b9a\u7fa9 \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002) [\u4f5c\u6210] \u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u5f97\u305f\u30c8\u30fc\u30af\u30f3(Access Token)\u306f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306a\u3069\u304b\u3089Authorization: Bearer\u30d8\u30c3\u30c0\u3092\u901a\u3057\u3066\u4e0e\u3048\u308b\u3053\u3068\u3067\u3001API\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\u3053\u306e\u3088\u3046\u306b\u3059\u308b\u3068\u3001\u30c8\u30fc\u30af\u30f3\u306e\u767a\u884c\u4e3b\u306e\u6301\u3064\u6a29\u9650\u3068\u3001(\u5fc5\u8981\u306b\u5fdc\u3058\u3066)\u30b9\u30b3\u30fc\u30d7\u306b\u3088\u308a\u5b9a\u7fa9\u3055\u308c\u305f\u8a8d\u53ef\u7bc4\u56f2\u3001 @must_have_permission \u306a\u3069\u306e\u30c7\u30b3\u30ec\u30fc\u30bf\u306b\u3088\u3063\u3066\u5b9a\u7fa9\u3055\u308c\u305f\u5236\u7d04\u306e\u691c\u8a3c\u304c\u884c\u308f\u308c\u3001\u30a2\u30af\u30bb\u30b9\u306e\u8a31\u53ef\u30fb\u4e0d\u8a31\u53ef\u304c\u6c7a\u5b9a\u3055\u308c\u307e\u3059\u3002

    \u3053\u306e\u65b9\u6cd5\u306f\u5f8c\u8ff0\u3059\u308b OAuth\u306b\u3088\u308b\u8a8d\u53ef \u65b9\u5f0f\u3068\u7570\u306a\u308a\u3001Callback URL\u306a\u3069\u306e\u6e96\u5099\u304c\u4e0d\u8981\u306a\u4e00\u65b9\u3001\u30e6\u30fc\u30b6\u306b\u3088\u308b\u30a2\u30af\u30bb\u30b9\u30c8\u30fc\u30af\u30f3\u767a\u884c\u304c\u5fc5\u8981\u306a\u3053\u3068\u3001\u305d\u306e\u30a2\u30af\u30bb\u30b9\u30c8\u30fc\u30af\u30f3\u304c\u6f0f\u6d29\u3057\u305f\u969b\u306b\u30e6\u30fc\u30b6\u306e\u5354\u529b\u3092\u5f97\u306a\u304c\u3089\u89e3\u6c7a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3053\u3068\u306a\u3069\u304b\u3089\u3001\u958b\u767a\u4e2d\u306b\u5229\u7528\u3067\u304d\u308b\u4fbf\u5229\u306a\u65b9\u5f0f\u7a0b\u5ea6\u306b\u8003\u3048\u308b\u3079\u304d\u3067\u3057\u3087\u3046\u3002

    "},{"location":"guides/api/README.legacy/#oauth\u306b\u3088\u308b\u8a8d\u53ef","title":"OAuth\u306b\u3088\u308b\u8a8d\u53ef","text":"

    Personal Access Token\u306f\u30e6\u30fc\u30b6\u306b\u624b\u52d5\u3067\u30c8\u30fc\u30af\u30f3\u3092\u4f5c\u6210\u3055\u305b\u3001\u30c8\u30fc\u30af\u30f3\u3092\u4f55\u3089\u304b\u306e\u65b9\u5f0f\u3067\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u6e21\u3059\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u304c\u3001RDM\u306fOAuth https://tools.ietf.org/html/rfc6749 \u3092\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u304a\u308a\u3001OAuth\u306b\u3088\u308a\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3068RDM\u306e\u9593\u3067\u8a8d\u53ef\u60c5\u5831\u306e\u3084\u308a\u3068\u308a\u3092\u5b9f\u73fe\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002

    \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304cOAuth\u3092\u901a\u3058\u3066\u30e6\u30fc\u30b6\u304b\u3089\u64cd\u4f5c\u306e\u8a8d\u53ef\u3092\u5f97\u308b\u305f\u3081\u306b\u306f\u3001RDM\u304b\u3089Consumer Key\u3068Consumer Secret\u3068\u3044\u3046\u60c5\u5831\u3092\u5f97\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 \u3053\u306e\u60c5\u5831\u306f\u3001RDM\u306e\u30e6\u30fc\u30b6\u306e [\u8a2d\u5b9a] \u753b\u9762\u304b\u3089\u3001 [\u958b\u767a\u8005\u30a2\u30d7\u30ea] \u3067\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002

    API\u306b\u5bfe\u3057\u3066\u30a2\u30af\u30bb\u30b9\u3059\u308b\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306f\u3001OAuth 2.0\u306b\u5bfe\u5fdc\u3057\u305f\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u7528\u3044\u3066OAuth\u8a8d\u53ef\u30d5\u30ed\u30fc\u3092\u5b9f\u88c5\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306fOAuth\u8a8d\u53ef\u30d5\u30ed\u30fc\u3092\u901a\u3057\u3066\u3001\u30e6\u30fc\u30b6\u306bRDM\u3078\u306e\u30ed\u30b0\u30a4\u30f3\u3068\u8a8d\u53ef\u3092\u6c42\u3081\u3001\u8a8d\u53ef\u3055\u308c\u308b\u3068Access Token(\u307e\u305f\u306f\u3001\u8981\u6c42\u3057\u305faccess_type\u304coffline\u306e\u5834\u5408\u3001Refresh Token\u3068Access Token)\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3042\u3068\u306fPersonal Access Token\u3068\u540c\u69d8\u306b\u3001Authorization: Bearer\u30d8\u30c3\u30c0\u306bAccess Token\u3092\u4e0e\u3048\u308b\u3053\u3068\u3067\u3001API\u30a2\u30af\u30bb\u30b9\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002

    \u983b\u7e41\u306b\u5229\u7528\u3055\u308c\u308b\u53ef\u80fd\u6027\u304c\u3042\u308bAccess Token\u306f\u3001\u60aa\u7528\u3092\u9632\u3050\u305f\u3081\u306b\u77ed\u6642\u9593(1\u6642\u9593)\u3067\u671f\u9650\u5207\u308c\u3068\u306a\u308b\u3088\u3046\u8a2d\u8a08\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u305d\u306e\u305f\u3081\u3001\u8a8d\u53ef\u3092\u53d7\u3051\u3066\u304b\u3089\u3001\u9577\u671f\u9593\u306b\u308f\u305f\u3063\u3066\u305d\u306e\u8a8d\u53ef\u3055\u308c\u305f\u64cd\u4f5c\u3092\u5b9f\u65bd\u3057\u305f\u3044\u5834\u5408\u306f\u3001Refresh Token\u3092\u7528\u3044\u3066Access Token\u3092\u5b9a\u671f\u7684\u306b\u65b0\u898f\u53d6\u5f97\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 \u3053\u308c\u3089\u306e\u51e6\u7406\u306f\u3001\u591a\u304f\u306e\u5834\u5408OAuth\u5bfe\u5fdc\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30e9\u30a4\u30d6\u30e9\u30ea\u306b\u30ed\u30b8\u30c3\u30af\u304c\u7528\u610f\u3055\u308c\u3066\u304a\u308a\u3001RDM\u304c\u63d0\u4f9b\u3059\u308b\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306eURL\u3092\u4e0e\u3048\u308c\u3070\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002 (\u53c2\u8003: \u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306e\u60c5\u5831\u3084\u53ef\u80fd\u306a\u64cd\u4f5c\u306f https://github.com/RCOSDP/RDM-cas-overlay#web-server-authorization \u306b\u8a18\u8f09\u3055\u308c\u3066\u3044\u308b\u3002)

    OAuth\u3092\u7528\u3044\u305fAPI\u306e\u8a8d\u53ef\u3092\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u3067\u8a66\u3059\u305f\u3081\u306b\u306f\u3001\u958b\u767a\u74b0\u5883\u69cb\u7bc9\u6642\u306b cas-overlay\u3092\u542b\u3080\u69cb\u6210\u3067\u8d77\u52d5\u3059\u308b \u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002

    "},{"location":"guides/api/README.legacy/#\u72ec\u81ea\u65b9\u5f0f\u306b\u3088\u308b\u30a2\u30af\u30bb\u30b9\u5236\u5fa1-signing-api-requests\u306e\u4f8b","title":"\u72ec\u81ea\u65b9\u5f0f\u306b\u3088\u308b\u30a2\u30af\u30bb\u30b9\u5236\u5fa1: Signing API requests\u306e\u4f8b","text":"

    RDM\u306f\u30a2\u30c9\u30aa\u30f3\u306b\u95a2\u3057\u3066\u30b5\u30f3\u30c9\u30dc\u30c3\u30af\u30b9\u306e\u3088\u3046\u306a\u9694\u96e2\u30e2\u30c7\u30eb\u306f\u63a1\u7528\u3057\u3066\u304a\u3089\u305a\u3001\u30a2\u30c9\u30aa\u30f3\u304b\u3089RDM\u672c\u4f53\u3068\u540c\u69d8\u306e\u64cd\u4f5c\u304c\u5b9f\u65bd\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 \u3053\u308c\u306f\u3001\u69d8\u3005\u306a\u51e6\u7406\u3092\u30a2\u30c9\u30aa\u30f3\u3068\u3057\u3066\u5b9f\u73fe\u3067\u304d\u308b\u4e00\u65b9\u3001\u305d\u306e\u5f37\u529b\u306a\u81ea\u7531\u5ea6\u3092\u60aa\u7528\u3055\u308c\u306a\u3044\u3088\u3046\u3001\u30a2\u30c9\u30aa\u30f3\u3067\u306f\u9069\u5207\u306a\u6a29\u9650\u5236\u5fa1\u3092\u884c\u3046\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002

    \u5148\u306b\u793a\u3057\u305f\u306e\u306f\u30e6\u30fc\u30b6\u306e\u8a8d\u53ef\u3092\u7d4c\u3066\u51e6\u7406\u3092\u5b9f\u65bd\u3059\u308b\u65b9\u5f0f\u3067\u3059\u304c\u3001\u30a2\u30c9\u30aa\u30f3\u306b\u3088\u3063\u3066\u306f\u3001\u5fc5\u305a\u3057\u3082\u64cd\u4f5c\u4e3b\u4f53\u3068\u306a\u308b\u30e6\u30fc\u30b6\u3092\u9650\u5b9a\u3057\u306a\u3044\u5f62\u3067\u632f\u821e\u3046\u5fc5\u8981\u304c\u3042\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002 \u3053\u306e\u3088\u3046\u306a\u5834\u5408\u306b\u95a2\u3057\u3066RDM\u306f\u7279\u5225\u306a\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u6a5f\u69cb\u3092\u63d0\u4f9b\u3057\u3066\u3044\u306a\u3044\u305f\u3081\u3001\u72ec\u81ea\u306b\u5916\u90e8\u30b7\u30b9\u30c6\u30e0(\u30a2\u30c9\u30aa\u30f3\u547c\u3073\u51fa\u3057\u5143)\u3068\u30a2\u30c9\u30aa\u30f3\u306e\u9593\u3067\u53d6\u308a\u6c7a\u3081\u3092\u3057\u3001\u4e0d\u6b63\u306a\u30e6\u30fc\u30b6\u304c\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u306a\u3044\u3088\u3046\u306b\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u6a5f\u69cb\u3092\u5b9f\u88c5\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002

    \u3053\u306e\u3088\u3046\u306a\u6a5f\u69cb\u3092\u5b9f\u73fe\u3059\u308b\u5834\u5408\u306b\u6700\u3082\u7c21\u5358\u306a\u65b9\u6cd5\u306f\u3001\u7b2c\u4e09\u8005\u304c\u63a8\u6e2c\u3057\u306b\u304f\u3044\u30c8\u30fc\u30af\u30f3\u3092\u5916\u90e8\u30b7\u30b9\u30c6\u30e0\u3068\u30a2\u30c9\u30aa\u30f3\u306e\u9593\u3067\u6c7a\u3081\u3001\u30a2\u30c9\u30aa\u30f3\u306f\u3053\u306e\u30c8\u30fc\u30af\u30f3\u3092\u3068\u3082\u306a\u3046\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u307f\u3092\u8a31\u53ef\u3059\u308b\u65b9\u5f0f\u3067\u3059\u3002 \u3053\u306e\u65b9\u5f0f\u306f\u5b9f\u73fe\u304c\u5bb9\u6613\u306a\u4e00\u65b9\u3001\u4e2d\u9593\u8005\u653b\u6483\u306a\u3069\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u5185\u5bb9\u304c\u596a\u308f\u308c\u3066\u3057\u307e\u3046\u3068\u3053\u306e\u30c8\u30fc\u30af\u30f3\u3082\u6f0f\u6d29\u3057\u3066\u3057\u307e\u3046\u3068\u3044\u3046\u554f\u984c\u304c\u3042\u308a\u307e\u3059\u3002(\u653b\u6483\u8005\u306f\u79d8\u5bc6\u306e\u30c8\u30fc\u30af\u30f3\u3092\u7528\u3044\u3066\u81ea\u7531\u306b\u30a2\u30c9\u30aa\u30f3\u3092\u64cd\u4f5c\u3067\u304d\u3066\u3057\u307e\u3046\u3002)

    \u3053\u306e\u3088\u3046\u306a\u653b\u6483\u3078\u306e\u5bfe\u7b56\u3068\u3057\u3066\u3001\u79d8\u5bc6\u306e\u30c8\u30fc\u30af\u30f3\u305d\u306e\u3082\u306e\u3092\u30ea\u30af\u30a8\u30b9\u30c8\u306b\u542b\u3081\u308b\u306e\u3067\u306f\u306a\u304f\u3001\u79d8\u5bc6\u306e\u30c8\u30fc\u30af\u30f3\u3068\u3001\u305d\u306e\u4ed6\u306e\u60c5\u5831\u3092\u5408\u308f\u305b\u305f\u30cf\u30c3\u30b7\u30e5\u5024\u3092\u8a08\u7b97\u3057\u3001\u305d\u306e\u30cf\u30c3\u30b7\u30e5\u3092\u30ea\u30af\u30a8\u30b9\u30c8\u306b\u542b\u3081\u308b\u3053\u3068\u304c\u8003\u3048\u3089\u308c\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u53d7\u4fe1\u5074\u306f\u540c\u69d8\u306e\u30cf\u30c3\u30b7\u30e5\u8a08\u7b97\u3092\u884c\u306a\u3063\u3066\u9001\u4fe1\u5074\u306e\u30cf\u30c3\u30b7\u30e5\u5024\u3068\u306e\u6bd4\u8f03\u3092\u884c\u3046\u3053\u3068\u3067\u3001\u9001\u4fe1\u5074\u304c\u79d8\u5bc6\u306e\u30c8\u30fc\u30af\u30f3\u3092\u6240\u6301\u3057\u3066\u3044\u308b\u304b\u3092\u691c\u8a3c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002

    \u4f8b\u3068\u3057\u3066\u3001IQB-RIMS\u30a2\u30c9\u30aa\u30f3\u306e\u5834\u5408\u306f\u3001\u30a2\u30c9\u30aa\u30f3\u306e\u8a2d\u5b9a\u60c5\u5831\u306b\u57fa\u3065\u3044\u305f\u30cf\u30c3\u30b7\u30e5\u3092\u751f\u6210\u3057\u3001\u72ec\u81ea\u306eHTTP\u30d8\u30c3\u30c0 X-RDM-Token \u306b\u683c\u7d0d\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002 \u3053\u308c\u306b\u3088\u308a\u3001\u3042\u308b\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u30a2\u30bf\u30c3\u30c1\u3055\u308c\u305f\u30a2\u30c9\u30aa\u30f3\u306b\u304a\u3044\u3066\u30cf\u30c3\u30b7\u30e5\u304c\u6f0f\u6d29\u3057\u305f\u3068\u3057\u3066\u3082\u3001\u5225\u306e\u30a2\u30c9\u30aa\u30f3\u306b\u5bfe\u3057\u3066\u60aa\u7528\u306f\u3067\u304d\u306a\u3044\u3088\u3046\u306b\u914d\u616e\u3057\u3066\u3044\u307e\u3059\u3002 \u30cf\u30c3\u30b7\u30e5\u751f\u6210\u51e6\u7406\u306f\u3001RDM\u304c\u63d0\u4f9b\u3059\u308b\u30c7\u30b3\u30ec\u30fc\u30bf\u4e00\u89a7\u306e\u3088\u3046\u306b\u30c7\u30b3\u30ec\u30fc\u30bf\u3068\u3057\u3066\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u3067\u3001\u518d\u5229\u7528\u6027\u3092\u9ad8\u3081\u3066\u3044\u307e\u3059\u3002

    def must_have_valid_hash():\n    \"\"\"Decorator factory that ensures that a request have valid X-RDM-Token header.\n    :returns: Decorator function\n    \"\"\"\n    def wrapper(func):\n\n        @functools.wraps(func)\n        def wrapped(*args, **kwargs):\n            owner = kwargs['node']\n            addon = owner.get_addon(IQBRIMSAddonConfig.short_name)\n            if addon is None:\n                raise HTTPError(http.BAD_REQUEST)\n            secret = addon.get_secret()\n            process_def_id = addon.get_process_definition_id()\n            valid_hash = hashlib.sha256((secret + process_def_id + owner._id).encode('utf8')).hexdigest()\n            request_hash = request.headers.get('X-RDM-Token', None)\n            logger.debug('must_have_valid_hash: request_hash={}'.format(request_hash))\n            logger.debug('must_have_valid_hash: valid_hash={}'.format(valid_hash))\n            if request_hash != valid_hash:\n                raise HTTPError(\n                    http.FORBIDDEN,\n                    data={'message_long': ('User has restricted access to this page.')}\n                )\n            return func(*args, **kwargs)\n\n        return wrapped\n\n    return wrapper\n
    (\u5f15\u7528: https://github.com/RCOSDP/RDM-osf.io/blob/develop/addons/iqbrims/utils.py#L142)

    \u3053\u306e\u3088\u3046\u306b\u5b9a\u7fa9\u3057\u305f\u72ec\u81ea\u306e addons.iqbrims.utils.must_have_valid_hash \u30c7\u30b3\u30ec\u30fc\u30bf\u3092\u7528\u3044\u3066\u3001 \u500b\u3005\u306eViews\u3078\u306e\u30a2\u30af\u30bb\u30b9\u306e\u969b\u306b\u30cf\u30c3\u30b7\u30e5\u5024\u306e\u8a08\u7b97\u30fb\u8a2d\u5b9a\u304c\u5fc5\u8981\u306a\u3053\u3068\u3092\u660e\u793a\u3057\u3066\u3044\u307e\u3059\u3002

    @must_be_valid_project\n@must_have_addon(SHORT_NAME, 'node')\n@must_have_valid_hash()    # Hash\u306e\u8a2d\u5b9a\u304c\u5fc5\u8981\u306a\u3053\u3068\u3092\u793a\u3059\ndef iqbrims_post_workflow_state(**kwargs):\n    node = kwargs['node'] or kwargs['project']\n    ...    # Views\u306e\u51e6\u7406\n
    (\u5f15\u7528: https://github.com/RCOSDP/RDM-osf.io/blob/develop/addons/iqbrims/views.py#L229)

    \u3053\u308c\u3089\u306e\u30cf\u30c3\u30b7\u30e5\u8a08\u7b97\u306b\u3069\u306e\u7a0b\u5ea6\u306e\u30ea\u30b9\u30af\u3092\u60f3\u5b9a\u3059\u308b\u304b\u306f\u5229\u7528\u5f62\u614b\u306b\u3088\u3063\u3066\u7570\u306a\u308a\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001Amazon S3\u306eSigning and authenticating REST requests https://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html \u3067\u306f\u3001\u9001\u4fe1\u6642\u523b\u3092\u542b\u3080\u30ea\u30af\u30a8\u30b9\u30c8\u30d8\u30c3\u30c0\u3092\u30cf\u30c3\u30b7\u30e5\u8a08\u7b97\u306e\u5bfe\u8c61\u306b\u542b\u3081\u308b\u3053\u3068\u3067\u3001\u30cf\u30c3\u30b7\u30e5\u5024\u3092\u542b\u3080\u30ea\u30af\u30a8\u30b9\u30c8\u304c\u6f0f\u6d29\u3057\u3066\u3082\u3001\u540c\u3058\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u5bfe\u3059\u308b\u30ea\u30af\u30a8\u30b9\u30c8\u306f\u4ee5\u5f8c\u4e0d\u53ef\u80fd\u306a\u3088\u3046\u306b\u914d\u616e\u304c\u306a\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u30cf\u30c3\u30b7\u30e5\u5024\u306e\u8a08\u7b97\u306b\u3069\u306e\u3088\u3046\u306a\u8981\u7d20\u3092\u4f7f\u3046\u304b\u306f\u30a2\u30c9\u30aa\u30f3\u306e\u5b9f\u88c5\u306b\u4f9d\u5b58\u3059\u308b\u90e8\u5206\u3067\u306f\u3042\u308a\u307e\u3059\u304c\u3001\u305f\u3068\u3048\u30ea\u30af\u30a8\u30b9\u30c8\u304c\u6f0f\u6d29\u3057\u305f\u3068\u3057\u3066\u3082\u3001\u305d\u306e\u5f71\u97ff\u7bc4\u56f2\u304c\u3042\u308b\u7a0b\u5ea6\u9650\u5b9a\u7684\u306b\u306a\u308b\u3088\u3046\u914d\u616e\u3057\u3066\u30cf\u30c3\u30b7\u30e5\u8a08\u7b97\u3092\u5b9f\u88c5\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3067\u3057\u3087\u3046\u3002

    "},{"location":"guides/api/README.legacy/#\u65e2\u5b58api\u306b\u3088\u308b\u64cd\u4f5c","title":"\u65e2\u5b58API\u306b\u3088\u308b\u64cd\u4f5c","text":"

    RDM\u306f\u591a\u304f\u306e\u6a5f\u80fd\u3092API\u3068\u3057\u3066\u63d0\u4f9b\u3057\u3066\u3044\u308b\u305f\u3081\u3001\u3059\u3067\u306b\u3042\u308b\u6a5f\u80fd\u306b\u3064\u3044\u3066\u306f\u7a4d\u6975\u7684\u306b\u6d3b\u7528\u3059\u3079\u304d\u3067\u3057\u3087\u3046\u3002\u307e\u305f\u3001\u5185\u90e8\u3067\u306fDjango\u306e\u898f\u5247\u306b\u3057\u305f\u304c\u3063\u3066\u4f5c\u6210\u3055\u308c\u305fDjango Model\u3092\u4ecb\u3057\u3066\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u7ba1\u7406\u3092\u884c\u306a\u3063\u3066\u3044\u308b\u305f\u3081\u3001\u3053\u306e\u672c\u7ae0\u3067\u306f\u3001OSF APIv2\u306b\u3088\u308b\u64cd\u4f5c\u3068Django Model\u306b\u3088\u308b\u30e2\u30c7\u30eb\u306e\u76f4\u63a5\u64cd\u4f5c\u306b\u95a2\u3057\u3066\u8aac\u660e\u3057\u307e\u3059\u3002

    "},{"location":"guides/api/README.legacy/#osf-apiv2-\u306b\u3088\u308b\u5916\u90e8\u304b\u3089\u306e\u64cd\u4f5c","title":"OSF APIv2 \u306b\u3088\u308b\u5916\u90e8\u304b\u3089\u306e\u64cd\u4f5c","text":"

    OSF APIv2\u306fRDM\u304c\u5099\u3048\u308bRESTful API\u3067\u3059\u3002OSF APIv2\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8 https://developer.osf.io/ \u3067\u8aac\u660e\u3055\u308c\u3066\u3044\u308b\u901a\u308a\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u5bfe\u3057\u3066\u69d8\u3005\u306a\u64cd\u4f5c\u3092\u5b9f\u65bd\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002

    \u3053\u308c\u3089\u306eAPI\u306f\u5916\u90e8\u30b7\u30b9\u30c6\u30e0\u304b\u3089\u306e\u547c\u3073\u51fa\u3057\u306b\u5229\u7528\u3055\u308c\u308b\u4ed6\u3001Ember\u30d9\u30fc\u30b9\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304b\u3089\u306e\u64cd\u4f5c\u306b\u3082\u5229\u7528\u3055\u308c\u307e\u3059\u3002\u307e\u305f\u3001JSON-API https://jsonapi.org/format/1.0/ \u306b\u6e96\u62e0\u3057\u305f\u5f62\u5f0f\u3067\u63d0\u4f9b\u3055\u308c\u307e\u3059\u3002

    "},{"location":"guides/api/README.legacy/#\u30b9\u30b3\u30fc\u30d7\u306e\u5b9a\u7fa9","title":"\u30b9\u30b3\u30fc\u30d7\u306e\u5b9a\u7fa9","text":"

    API\u306e\u64cd\u4f5c\u306b\u306fOAuth\u306b\u3066\u8aac\u660e\u3057\u305f\u3088\u3046\u306b\u3001\u9069\u5207\u306a\u30b9\u30b3\u30fc\u30d7\u3092\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 RDM\u306b\u3066\u6307\u5b9a\u53ef\u80fd\u306a\u30b9\u30b3\u30fc\u30d7\u306f oauth_scopes.public_scopes \u3068\u3057\u3066\u5b9a\u7fa9\u3055\u308c\u307e\u3059\u3002

    • https://github.com/RCOSDP/RDM-osf.io/blob/develop/framework/auth/oauth_scopes.py#L291-L363

    \u3053\u308c\u3089\u306e\u30b9\u30b3\u30fc\u30d7\u306fCoreScopes https://github.com/RCOSDP/RDM-osf.io/blob/develop/framework/auth/oauth_scopes.py#L23 \u306e\u7d44\u307f\u5408\u308f\u305b\u3068\u3057\u3066\u8868\u73fe\u3055\u308c\u307e\u3059\u3002 \u305d\u308c\u305e\u308c\u306e\u64cd\u4f5c\u304c\u3069\u306e\u3088\u3046\u306a\u30b9\u30b3\u30fc\u30d7\u3092\u8981\u6c42\u3059\u308b\u304b\u306f\u3001View\u30af\u30e9\u30b9\u306b\u5b9a\u7fa9\u3055\u308c\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001NodeList\u306b\u95a2\u3059\u308b\u64cd\u4f5c ( https://developer.osf.io/#operation/nodes_list \u3084 https://developer.osf.io/#operation/nodes_create ) \u3067\u3042\u308c\u3070\u3001

    class NodeList(JSONAPIBaseView, bulk_views.BulkUpdateJSONAPIView, bulk_views.BulkDestroyJSONAPIView, bulk_views.ListBulkCreateJSONAPIView, NodesFilterMixin, WaterButlerMixin, NodeOptimizationMixin):\n    \"\"\"The documentation for this endpoint can be found [here](https://developer.osf.io/#operation/nodes_list).\n    \"\"\"\n    permission_classes = (\n        drf_permissions.IsAuthenticatedOrReadOnly,\n        base_permissions.TokenHasScope,\n    )\n    required_read_scopes = [CoreScopes.NODE_BASE_READ]\n    required_write_scopes = [CoreScopes.NODE_BASE_WRITE]\n    model_class = apps.get_model('osf.AbstractNode')\n\n    parser_classes = (JSONAPIMultipleRelationshipsParser, JSONAPIMultipleRelationshipsParserForRegularJSON,)\n    serializer_class = NodeSerializer\n    ...\n
    (\u5f15\u7528: https://github.com/RCOSDP/RDM-osf.io/blob/develop/api/nodes/views.py#L228-L229)

    \u306e\u3088\u3046\u306b\u3001 required_read_scopes \u3068 required_write_scopes \u3068\u3057\u3066\u3001\u5fc5\u8981\u306a\u30b9\u30b3\u30fc\u30d7\u304c\u5b9a\u7fa9\u3055\u308c\u307e\u3059\u3002

    "},{"location":"guides/api/README.legacy/#django-model\u306b\u3088\u308b\u5185\u90e8\u304b\u3089\u306e\u64cd\u4f5c","title":"Django Model\u306b\u3088\u308b\u5185\u90e8\u304b\u3089\u306e\u64cd\u4f5c","text":"

    RDM\u306fDjango\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3068\u3057\u3066\u69cb\u6210\u3055\u308c\u3066\u3044\u308b\u305f\u3081\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3078\u306e\u30a2\u30af\u30bb\u30b9\u306fDjango Model\u3092\u4ecb\u3057\u3066\u884c\u3044\u307e\u3059\u3002 \u3053\u306e\u64cd\u4f5c\u306e\u4f8b\u3068\u3057\u3066\u3001django.dispatch.receiver \u306b\u3088\u308b\u30e2\u30c7\u30eb\u5909\u66f4\u691c\u77e5\u3068\u3001 osf.models \u5185\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4ecb\u3057\u305f\u64cd\u4f5c\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002

    from django.dispatch import receiver\n...\nfrom osf.models import Contributor, RdmAddonOption, AbstractNode\n\n...\n\n@receiver(post_save, sender=Node)\ndef add_iqbrims_addon(sender, instance, created, **kwargs):\n    if IQBRIMSAddonConfig.short_name not in ws_settings.ADDONS_AVAILABLE_DICT:\n        return\n\n    inst_ids = instance.affiliated_institutions.values('id')\n    addon_option = RdmAddonOption.objects.filter(\n        provider=IQBRIMSAddonConfig.short_name,\n        institution_id__in=Subquery(inst_ids),\n        management_node__isnull=False,\n        is_allowed=True\n    ).first()\n    if addon_option is None:\n        return\n    if addon_option.organizational_node is not None and \\\n            not addon_option.organizational_node.is_contributor(instance.creator):\n        return\n\n    instance.add_addon(IQBRIMSAddonConfig.short_name, auth=None, log=False)\n
    (\u5f15\u7528: https://github.com/RCOSDP/RDM-osf.io/blob/develop/addons/iqbrims/models.py#L309-L327)

    \u4ee5\u4e0b\u3067\u3001\u6ce8\u76ee\u3059\u3079\u304d\u30b3\u30fc\u30c9\u306b\u3064\u3044\u3066\u305d\u308c\u305e\u308c\u8aac\u660e\u3057\u307e\u3059\u3002

    "},{"location":"guides/api/README.legacy/#receiver\u306b\u3088\u308b\u30e2\u30c7\u30eb\u5909\u66f4\u691c\u77e5","title":"receiver\u306b\u3088\u308b\u30e2\u30c7\u30eb\u5909\u66f4\u691c\u77e5","text":"

    django.dispatch.receiver \u30c7\u30b3\u30ec\u30fc\u30bf\u3092\u7528\u3044\u308b\u3053\u3068\u3067\u3001\u7279\u5b9a\u306eModel\u306b\u5909\u66f4\u304c\u751f\u3058\u305f\u5834\u5408\u306e\u51e6\u7406\u3092\u8a18\u8ff0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002

    @receiver(post_save, sender=Node)\ndef add_iqbrims_addon(sender, instance, created, **kwargs):\n    ...\n

    \u3053\u306e\u4f8b\u306e\u5834\u5408\u306f\u3001post_save\u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u306e\u3067\u3001Node\u578b(\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306f\u3053\u306e\u578b\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3067\u8868\u73fe\u3055\u308c\u307e\u3059)\u3092\u6301\u3064\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u66f4\u65b0\u5f8c\u306b\u3001add_iqbrims_addon\u95a2\u6570\u304c\u547c\u3073\u51fa\u3055\u308c\u307e\u3059\u3002

    post_save\u306e\u307b\u304b\u3001\u691c\u77e5\u53ef\u80fd\u306a\u5909\u66f4\u64cd\u4f5c\u306f\u3001 https://docs.djangoproject.com/en/3.1/ref/signals/ \u306b\u5217\u6319\u3055\u308c\u3066\u3044\u307e\u3059\u3002 RDM\u5185\u3067\u306f\u3001 pre_save, post_save, post_delete, m2m_changed \u304c\u3059\u3067\u306b\u4f7f\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u3002

    "},{"location":"guides/api/README.legacy/#osfmodels\u306b\u3088\u308b\u30e2\u30c7\u30eb\u64cd\u4f5c","title":"osf.models\u306b\u3088\u308b\u30e2\u30c7\u30eb\u64cd\u4f5c","text":"

    django.dispatch.receiver(post_save, sender=Node) \u30c7\u30b3\u30ec\u30fc\u30bf\u306e\u5834\u5408\u306f\u3001\u7b2c2\u5f15\u6570\u306e instance \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306bNode\u3078\u306e\u53c2\u7167\u304c\u683c\u7d0d\u3055\u308c\u307e\u3059\u3002 Django Model\u306f osf.models \u306b\u5b9a\u7fa9\u3057\u3066\u3042\u308a\u307e\u3059\u3002\u4f8b\u3048\u3070 Node Model\u306a\u3089\u3070\u3001 https://github.com/RCOSDP/RDM-osf.io/blob/develop/osf/models/node.py#L2457 \u3067\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u3002

    \u4f8b\u3048\u3070\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u5185\u3067\u7279\u5b9a\u306e\u30a2\u30c9\u30aa\u30f3\u3092\u6709\u52b9\u5316\u3057\u305f\u3044\u5834\u5408\u306f\u3001 add_addon\u95a2\u6570 https://github.com/RCOSDP/RDM-osf.io/blob/develop/osf/models/node.py#L2290 \u3092\u547c\u3073\u51fa\u3059\u3053\u3068\u3067\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002

    @receiver(post_save, sender=Node)\ndef add_iqbrims_addon(sender, instance, created, **kwargs):\n    ...\n\n    instance.add_addon(IQBRIMSAddonConfig.short_name, auth=None, log=False)\n

    \u3053\u306e\u3088\u3046\u306b\u3057\u3066\u3001\u76f4\u63a5Model\u3092\u64cd\u4f5c\u3059\u308b\u3053\u3068\u3067\u3001RDM\u306b\u5bfe\u3057\u3066\u69d8\u3005\u306a\u4f5c\u7528\u3092\u4e0e\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 \u30e2\u30c7\u30eb\u64cd\u4f5c\u306f\u81ea\u7531\u306b\u5909\u66f4\u3092\u884c\u3048\u308b\u4e00\u65b9\u3001\u30e6\u30fc\u30b6\u304c\u3053\u308c\u3089\u306e\u5909\u66f4\u3092\u9069\u5207\u306b\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u914d\u616e\u3092\u884c\u3046\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 \u3055\u3082\u306a\u3044\u3068\u3001\u300c\u4f55\u304b\u304c\u52dd\u624b\u306b\u81ea\u8eab\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u58ca\u3057\u305f\u300d\u3068\u601d\u3063\u3066\u3057\u307e\u3046\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\u30a2\u30c9\u30aa\u30f3\u304c\u3001\u30e6\u30fc\u30b6\u81ea\u8eab\u306b\u8a31\u53ef\u3055\u308c\u305f\u7bc4\u56f2\u3067\u69d8\u3005\u306a\u5909\u66f4\u3092\u5b9f\u65bd\u3057\u3066\u3044\u308b\u3088\u3046\u306b\u3001\u30e6\u30fc\u30b6\u306b\u7406\u89e3\u3057\u3066\u3082\u3089\u3048\u308b\u3088\u3046\u306a\u52d5\u4f5c\u3092\u8a2d\u8a08\u3059\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002

    "},{"location":"guides/ec2/","title":"EC2 Development Environment / EC2 \u3067\u306e\u958b\u767a\u74b0\u5883","text":"

    Summary: Guide to setting up the GakuNin RDM development environment on Amazon EC2 \u6982\u8981: Amazon EC2 \u306b GakuNin RDM \u306e\u958b\u767a\u74b0\u5883\u3092\u69cb\u7bc9\u3059\u308b\u624b\u5f15\u304d

    Jump: English \u00b7 \u65e5\u672c\u8a9e

    • Version / \u7248: 0.1 \u2014 2026-11-05
    • Normative for: docs/guides/ec2/
    • Related: SPEC-06 Documentation Conventions

    "},{"location":"guides/ec2/#english","title":"English","text":"

    \u2192 \u65e5\u672c\u8a9e\u7248\u3078

    "},{"location":"guides/ec2/#overview","title":"Overview","text":"

    This guide shows how to set up the GakuNin RDM development environment on an Amazon EC2 instance.

    "},{"location":"guides/ec2/#prerequisites","title":"Prerequisites","text":"
    • An AWS account
    • Basic familiarity with Linux command-line tools
    • SSH access to your EC2 instance
    "},{"location":"guides/ec2/#quick-start-on-ec2","title":"Quick start on EC2","text":"
    1. Launch an EC2 instance (Ubuntu 22.04 or Amazon Linux 2 recommended)
    2. Install Docker and Docker Compose
    3. Clone this repository
    4. Run ./installer/install.sh --yes
    5. Configure your EC2 security group to allow HTTP (port 80) and SSH (port 22)
    6. Open http://localhost:5000 in your browser

    This command is available from milestone M2.

    "},{"location":"guides/ec2/#legacy-content","title":"Legacy content","text":"

    The legacy EC2 setup instructions are kept verbatim in README.legacy.md for reference and will be rewritten per milestone.

    "},{"location":"guides/ec2/#\u65e5\u672c\u8a9e","title":"\u65e5\u672c\u8a9e","text":"

    \u2192 To English

    "},{"location":"guides/ec2/#\u6982\u8981","title":"\u6982\u8981","text":"

    \u3053\u306e\u30ac\u30a4\u30c9\u306f\u3001Amazon EC2 \u4e0a\u306b GakuNin RDM \u306e\u958b\u767a\u74b0\u5883\u3092\u69cb\u7bc9\u3059\u308b\u65b9\u6cd5\u3092\u793a\u3057\u307e\u3059\u3002

    "},{"location":"guides/ec2/#\u524d\u63d0\u6761\u4ef6","title":"\u524d\u63d0\u6761\u4ef6","text":"
    • AWS \u30a2\u30ab\u30a6\u30f3\u30c8
    • Linux \u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u30c4\u30fc\u30eb\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u306e\u7406\u89e3
    • EC2 \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3078\u306e SSH \u30a2\u30af\u30bb\u30b9
    "},{"location":"guides/ec2/#ec2-\u3067\u306e\u30af\u30a4\u30c3\u30af\u30b9\u30bf\u30fc\u30c8","title":"EC2 \u3067\u306e\u30af\u30a4\u30c3\u30af\u30b9\u30bf\u30fc\u30c8","text":"
    1. EC2 \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u8d77\u52d5\u3059\u308b\uff08Ubuntu 22.04 \u307e\u305f\u306f Amazon Linux 2 \u3092\u63a8\u5968\uff09
    2. Docker \u3068 Docker Compose \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b
    3. \u3053\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u3092 clone \u3059\u308b
    4. ./installer/install.sh --yes \u3092\u5b9f\u884c\u3059\u308b
    5. EC2 \u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u3067 HTTP (\u30dd\u30fc\u30c8 80) \u3068 SSH (\u30dd\u30fc\u30c8 22) \u3092\u8a31\u53ef\u3059\u308b
    6. \u30d6\u30e9\u30a6\u30b6\u3067 http://localhost:5000 \u3092\u958b\u304f

    \u3053\u306e\u30b3\u30de\u30f3\u30c9\u306f M2 \u30de\u30a4\u30eb\u30b9\u30c8\u30fc\u30f3\u304b\u3089\u5229\u7528\u53ef\u80fd\u3067\u3059\u3002

    "},{"location":"guides/ec2/#\u904e\u53bb\u306e\u30b3\u30f3\u30c6\u30f3\u30c4","title":"\u904e\u53bb\u306e\u30b3\u30f3\u30c6\u30f3\u30c4","text":"

    \u904e\u53bb\u306e EC2 \u3078\u306e\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u624b\u9806\u306f\u3001\u53c2\u8003\u306e\u305f\u3081\u306b README.legacy.md \u306b\u305d\u306e\u307e\u307e\u6b8b\u3057\u3066\u304a\u308a\u3001\u30de\u30a4\u30eb\u30b9\u30c8\u30fc\u30f3\u3054\u3068\u306b\u66f8\u304d\u76f4\u3059\u4e88\u5b9a\u3067\u3059\u3002

    "},{"location":"guides/ec2/#glossary--\u7528\u8a9e","title":"Glossary / \u7528\u8a9e","text":"Term English note \u65e5\u672c\u8a9e\u6ce8 EC2 (Elastic Compute Cloud) Amazon's service to run virtual computers on the internet. \u30a2\u30de\u30be\u30f3\u304c\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u4e0a\u3067\u4eee\u60f3\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u3092\u5b9f\u884c\u3059\u308b\u30b5\u30fc\u30d3\u30b9\u3002 Security group A virtual firewall that controls traffic to your EC2 instance. EC2 \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3078\u306e\u30a2\u30af\u30bb\u30b9\u3092\u5236\u5fa1\u3059\u308b\u4eee\u60f3\u306e\u30d5\u30a1\u30a4\u30a2\u30a6\u30a9\u30fc\u30eb\u3002 SSH (Secure Shell) A secure way to log in to your remote computer and run commands. \u30ea\u30e2\u30fc\u30c8\u306e\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u306b\u5b89\u5168\u306b\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u65b9\u6cd5\u3002"},{"location":"guides/ec2/README.legacy/","title":"OSF evaluation on AWS EC2","text":""},{"location":"guides/ec2/README.legacy/#quick-start-guide","title":"Quick Start Guide","text":"

    For setting up this project on your local environment, follow these steps:

    "},{"location":"guides/ec2/README.legacy/#1-change-to-project-directory","title":"1. Change to Project Directory","text":"

    Setup for git:

    git config --global user.name 'Your github account name' \ngit config --global user.email 'Your email address'        \ngit config --global core.editor 'code --wait'\ngit config --global merge.tool 'code --wait \"$MERGED\"'\ngit config --global push.default simple\ngit config --list  # githuconfig confirmation \n

    You need generate and register your github token in your gitconfig.

    link: https://docs.github.com/ja/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens

    Navigate to the project root directory:

    git clone https://github.com/RCOSDP/RDM-osf.io.git\ngit clone -b develop https://github.com/RCOSDP/RDM-ember-osf-web.git\ngit clone https://github.com/RCOSDP/RDM-modular-file-renderer.git\ngit clone https://github.com/RCOSDP/RDM-waterbutler.git\n

    "},{"location":"guides/ec2/README.legacy/#2-docker-build","title":"2. Docker Build","text":"

    setup docker and docker compose.

    link: https://docs.docker.jp/v1.12/compose/install.html

    link: https://docs.docker.com/engine/install/ubuntu/

    Build Docker images for each module:

    sudo docker build RDM-ember-osf-web -t rdm-osf-web:dev\nsudo docker build RDM-modular-file-renderer -t rdm-mfr:dev\nsudo docker build RDM-waterbutler -t rdm-wb:dev\nsudo docker build RDM-osf.io -t rdm-osf:dev\n

    "},{"location":"guides/ec2/README.legacy/#3-setup-loopback-interface","title":"3. Setup Loopback Interface","text":"

    Configure your loopback interface on your machine:

    sudo apt install net-tools\nsudo ifconfig lo:0 192.168.168.167 netmask 255.255.255.255 up\n

    "},{"location":"guides/ec2/README.legacy/#4-change-to-module-directory","title":"4. Change to Module Directory","text":"

    Navigate to the module directory:

    cd RDM-osf.io/\n

    "},{"location":"guides/ec2/README.legacy/#5-copy-and-update-local-settings","title":"5. Copy and Update Local Settings","text":"

    Copy the local settings of the project:

    cp ./website/settings/local-dist.py ./website/settings/local.py\ncp ./api/base/settings/local-dist.py ./api/base/settings/local.py\ncp ./admin/base/settings/local-dist.py ./admin/base/settings/local.py\ncp ./tasks/local-dist.py ./tasks/local.py\n

    Update the local settings of the project: RDM-osf.io/.docker-compose.env

    DOMAIN=http://ec2.compute-1.amazonaws.com:5000\nINTERNAL_DOMAIN=http://web:5000\nAPI_DOMAIN=http://api.ec2.compute-1.amazonaws.com:8000\nELASTIC_URI=elasticsearch:9200\nELASTIC6_URI=elasticsearch6:9201\nOSF_DB_HOST=postgres\nDB_HOST=mongo\nWATERBUTLER_URL=http://files.ec2.compute-1.amazonaws.com:7777\nWATERBUTLER_INTERNAL_URL=http://wb:7777\nCAS_SERVER_URL=http://accounts.ec2.compute-1.amazonaws.com:8080\nMFR_SERVER_URL=http://mfr.ec2.compute-1.amazonaws.com:7778\n#SHARE_URL=http://192.168.168.167:8000\nBROKER_URL=amqp://guest:guest@rabbitmq:5672\nREDIS_URL=redis://192.168.168.167:6379/1\n\nADMIN_URL=http://admin.ec2.compute-1.amazonaws.com:8001\nADMIN_INTERNAL_DOCKER_URL=http://admin:8001\n
    RDM-osf.io/.docker-compose.osf-web.env
    OSF_COOKIE_DOMAIN=.ec2.compute-1.amazonaws.com\nOSF_URL=http://ec2.compute-1.amazonaws.com:5000\nOSF_API_URL=http://api.ec2.compute-1.amazonaws.com:8000\nOSF_MFR_URL=http://mfr.ec2.compute-1.amazonaws.com:7778\nOSF_RENDER_URL=http://mfr.ec2.compute-1.amazonaws.com:7778/render\nOSF_FILE_URL=http://files.ec2.compute-1.amazonaws.com:7777\nOSF_HELP_URL=http://ec2.compute-1.amazonaws.com:5000/help\nOSF_COOKIE_LOGIN_URL=http://accounts.ec2.compute-1.amazonaws.com:8080/login\nOSF_OAUTH_URL=http://accounts.ec2.compute-1.amazonaws.com:8080/oauth2/profile\nSHARE_BASE_URL=https://share.osf.io/\nSHARE_API_URL=https://share.osf.io/api/v2\nSHARE_SEARCH_URL=https://share.osf.io/api/v2/search/creativeworks/_search\nCAS_URL=http://accounts.ec2.compute-1.amazonaws.com:8080\n

    RDM-osf.io/.docker-compose.wb.env

    DEBUG=\nSERVER_CONFIG_DEBUG=\nSERVER_CONFIG_HMAC_SECRET=changeme\nSERVER_CONFIG_ADDRESS=0.0.0.0\nSERVER_CONFIG_DOMAIN=http://ec2.compute-1.amazonaws.com:7777\nOSF_AUTH_CONFIG_API_URL=http://ec2.compute-1.amazonaws.com:5000/api/v1/files/auth/\nOSF_URL=http://ec2.compute-1.amazonaws.com:5000\n\nTASKS_CONFIG_BROKER_URL=amqp://guest:guest@rabbitmq:5672//\n

    RDM-osf.io/.docker-compose.mfr.env

    DEBUG=\nSERVER_CONFIG_DEBUG=\nSERVER_CONFIG_HMAC_SECRET=changeme\n\nSERVER_CONFIG_ADDRESS=0.0.0.0\nSERVER_CONFIG_ALLOWED_PROVIDER_DOMAINS='http://192.168.168.167:5000/ http://192.168.168.167:7777/ http://mfr:7777/ http://ec2.compute-1.amazonaws.com:5000/ http://files.ec2.compute-1.amazonaws.com:7777/'\n\nUNOCONV_PORT_2002_TCP_ADDR=192.168.168.167\nEXTENSION_CONFIG_LOCAL_DEVELOPMENT=1\n

    RDM-osf.io/admin/base/settings/local.py

    SESSION_COOKIE_DOMAIN = 'ec2.compute-1.amazonaws.com'\nfrom .defaults import *\n\nALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', 'localhost,osf.io').split(',')\n

    RDM-osf.io/docker-compose.override.yml

    version: \"3.4\"\n\nservices:\n  mfr_requirements:\n    image: rdm-mfr:dev\n  mfr:\n    image: rdm-mfr:dev\n  wb_requirements:\n    image: rdm-wb:dev\n  wb:\n    image: rdm-wb:dev\n  wb_worker:\n    image: rdm-wb:dev\n  ember_osf_web:\n    image: rdm-osf-web:dev\n    environment:\n      - BACKEND=env\n    env_file:\n      - .docker-compose.osf-web.env\n    volumes:\n      - ../RDM-ember-osf-web:/code:cached\n      - ember_osf_web_dist_vol:/code/dist\n  requirements:\n    image: rdm-osf:dev\n  assets:\n    image: rdm-osf:dev\n  admin_assets:\n    image: rdm-osf:dev\n  worker:\n    image: rdm-osf:dev\n  admin:\n    image: rdm-osf:dev\n  api:\n    image: rdm-osf:dev\n  web:\n    image: rdm-osf:dev\n  preprints:\n    environment:\n      - BACKEND=env\n    env_file:\n      - .docker-compose.osf-web.env\n  fakecas:\n    image: quay.io/centerforopenscience/fakecas:master\n    command: fakecas -host=0.0.0.0:8080 -osfhost=ec2.compute-1.amazonaws.com:5000 -dbaddress=postgres://postgres@postgres:5432/osf?sslmode=disable\n  registries:\n    environment:\n      - BACKEND=env\n    env_file:\n      - .docker-compose.osf-web.env\n  reviews:\n    environment:\n      - BACKEND=env\n    env_file:\n      - .docker-compose.osf-web.env\n

    RDM-osf.io/website/settings/local.py

    DOMAIN = PROTOCOL + 'ec2.compute-1.amazonaws.com:5000/'\nINTERNAL_DOMAIN = DOMAIN\nAPI_DOMAIN = PROTOCOL + 'ec2.compute-1.amazonaws.com:8000/'\nOSF_COOKIE_DOMAIN = 'ec2.compute-1.amazonaws.com'\n

    "},{"location":"guides/ec2/README.legacy/#6-docker-compose-up-requirements","title":"6. Docker Compose Up Requirements","text":"

    Ensure you have the required services running:

    sudo docker compose up requirements wb_requirements mfr_requirements\n

    "},{"location":"guides/ec2/README.legacy/#7-start-core-component-services-detached","title":"7. Start Core Component Services (Detached)","text":"

    Spin up denpent services:

    sudo docker compose up -d elasticsearch elasticsearch6 postgres mongo rabbitmq\n

    "},{"location":"guides/ec2/README.legacy/#8-assets-setup","title":"8. Assets Setup","text":"

    Remove your existing node_modules and start the assets:

    sudo rm -Rf ./node_modules\nsudo rm -Rf ./website/static/vendor/bower_components\nsudo rm -Rf ./admin/node_modules\nsudo rm -Rf ./admin/static/vendor/bower_components\nsudo docker compose up -d assets admin_assets\n

    "},{"location":"guides/ec2/README.legacy/#9-more-services","title":"9. More Services","text":"

    Upgrade dependency RDM-osf.io/requirements/dev.txt

    pytest-xdist==1.34.0\n

    Start additional services:

    sudo docker compose up -d unoconv mfr wb fakecas sharejs\n

    "},{"location":"guides/ec2/README.legacy/#10-database-migration","title":"10. Database Migration","text":"

    When starting with an empty database you will need to run migrations and populate preprint providers. Perform database migrations:

    sudo docker compose run --rm web python3 manage.py migrate\n
    See the Running arbitrary commands section below for instructions.

    "},{"location":"guides/ec2/README.legacy/#11-run-the-project","title":"11. Run the Project","text":"

    Finally start the OSF Web, API Server, and Preprints (Detached):

    sudo docker compose up -d wb_worker worker web api admin preprints ember_osf_web registries reviews\n

    We can see containers and images list.

    sudo docker iamges\nsudo docker ps\n

    We can see the rdm page through browser.

    link : https://EC2-url:5000/

    Once you follow these steps, you should have a local environment up and running for development.

    "},{"location":"guides/ec2/README.legacy/#configuration-guide","title":"Configuration Guide","text":""},{"location":"guides/ec2/README.legacy/#1-lets-encrypt-setup","title":"1. Let's Encrypt Setup","text":"

    Configure AWS Credentials

    Use the AWS CLI Docker image to configure your AWS credentials:

    sudo docker run --rm -it -v \"/root/.aws:/root/.aws\" amazon/aws-cli configure\n
    Verify AWS Credentials Nii has a Certificate Management Service link: https://certs.nii.ac.jp/ . You can contact to them if your service is created on NII infrastructure.

    Verify if your AWS credentials are working and have nominal access to Route 53:

    sudo docker run --rm -it -v \"/root/.aws:/root/.aws\" amazon/aws-cli route53 list-hosted-zones\n
    Request a Let's Encrypt Wildcard Certificate

    Use the certbot/dns-route53 Docker image to request a wildcard certificate, forwarding your AWS credentials:

    certbot certonly --dns-route53 --domain \"your.com\" --domain \"*.your.com\"\n

    Automate Certificate Renewal

    Create systemd timer to automate certificate renewal, then daemon-reload, enable, and start the timer. Create /etc/systemd/system/certbot.service. For the docker command, remove --it for non-interactive execution by systemd, and pass /usr/bin to the container to allow execution of systemctl by --deploy-hook:

    [Unit]\nDescription=Let's Encrypt certificate renewal\n\n[Service]\nType=oneshot\nExecStart=certbot renew --dns-route53 --quiet --agree-tos --deploy-hook \"cd /home/ubuntu/RDM-osf.io && sudo docker compose restart web admin wb fakecas ember_osf_web  preprints registries reviews\"\n

    Then create /etc/systemd/system/certbot.timer:

    [Unit]\nDescription=Monthly renewal of Let's Encrypt certificates\n\n[Timer]\nOnCalendar=monthly\nRandomizedDelaySec=12 hours\nPersistent=true\n\n[Install]\nWantedBy=timers.target\n

    "},{"location":"guides/ec2/README.legacy/#2-user-management","title":"2. User Management","text":"

    Setup SMTPrdm

    We need to setup smtp and mailutils. We can install postfix with local only and deefault hostname

    apt install postfix mailutils\n

    /etc/postfix/main.cf

    mynetworks = 10.0.0.0/0 # your network \ninet_interfaces = all # \n

    Test for sending mail

    echo \"test\" | mail -s test root@ip-1-1-1-1.ap-northeast-1.compute.internal\n

    root@ip-1-1-1-1:/etc/postfix# mail\n\"/var/mail/root\": 1 message 1 new\n>N   1 root               Mon Mar  4 05:29  14/656   test\n? 1  ### input number\nFrom: root <root@ip-1-1-1-1.ap-northeast-1.compute.internal>\ntest\n

    Create User

    Method 1: Create a user via register link: https://EC2-url:5000/register/

    Method 2: Create a user directly through the RDM shell.

    docker compose run --rm web invoke shell\n
    Create an OSF User with python code:
    user = OSFUser.create(username=<your_user@cos.io>,password=<password>,fullname=<full name>)\n

    Note: User's registration status is to be shifted to True by adding user.is_registered = True user.have_email = True and user.date_confirmed = timezone.now(). Due to the lack of an inherited mail server in local environment, the newly created account is unable to send confirmation emails making the account unconfirmed.

    Save your user with user.save() Commit the changes with commit()

    Admin User

    Please refer to RDM-osf.io/admin/README.md for instructions on how to make existing user super admin.

    "},{"location":"guides/environment/","title":"Environment / \u74b0\u5883\u8a2d\u5b9a\u3068\u958b\u767a\u74b0\u5883","text":"

    Summary: Guide to setting up the development environment for GakuNin RDM using Docker Compose and the 2027 installer \u6982\u8981: GakuNin RDM \u306e\u958b\u767a\u74b0\u5883\u3092 Docker Compose \u3068 2027 \u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u30fc\u3067\u69cb\u7bc9\u3059\u308b\u624b\u5f15\u304d

    Jump: English \u00b7 \u65e5\u672c\u8a9e

    • Version / \u7248: 0.1 \u2014 2026-11-05
    • Normative for: docs/guides/environment/
    • Related: SPEC-02 Installer CLI \u00b7 ADR-02 Network Model \u00b7 SPEC-06 Documentation Conventions

    "},{"location":"guides/environment/#english","title":"English","text":"

    \u2192 \u65e5\u672c\u8a9e\u7248\u3078

    "},{"location":"guides/environment/#overview","title":"Overview","text":"

    This guide shows how to set up the GakuNin RDM development environment.

    Warning: The loopback alias 192.168.168.167 and docker-compose.override.yml method described below are the OLD way. The 2027 installer uses a Compose internal network and 127.0.0.1 only. See ADR-02 Network Model and SPEC-02 Installer CLI.

    For the current method, use the 2027 installer (installer/install.sh) which creates a self-contained environment under runtime/ with no host network changes.

    "},{"location":"guides/environment/#docker-compose-services","title":"Docker Compose services","text":"

    The development environment uses Docker Compose to run multiple microservices:

    • Data storage & sharing services: PostgreSQL, Elasticsearch, RabbitMQ, MongoDB
    • Core services: web server, API server, admin interface, worker (RDM-osf.io), WaterButler file storage service
    • UI services: Ember frontend, Modular File Renderer (MFR), Unoconv file converter
    • Test authentication service: FakeCAS or CAS-Overlay for OAuth testing

    In GakuNin RDM, the preprints and registries services are not used.

    "},{"location":"guides/environment/#quick-start","title":"Quick start","text":"
    1. Clone this repository
    2. Run ./installer/install.sh --yes
    3. Open http://127.0.0.1:5000 in your browser

    This command is available from milestone M2.

    "},{"location":"guides/environment/#legacy-content","title":"Legacy content","text":"

    The legacy Docker Compose instructions (loopback alias, manual setup) are kept verbatim in README.legacy.md for reference and will be rewritten per milestone.

    "},{"location":"guides/environment/#\u65e5\u672c\u8a9e","title":"\u65e5\u672c\u8a9e","text":"

    \u2192 To English

    "},{"location":"guides/environment/#\u6982\u8981","title":"\u6982\u8981","text":"

    \u3053\u306e\u30ac\u30a4\u30c9\u306f\u3001GakuNin RDM \u306e\u958b\u767a\u74b0\u5883\u3092\u69cb\u7bc9\u3059\u308b\u65b9\u6cd5\u3092\u793a\u3057\u307e\u3059\u3002

    \u8b66\u544a: \u4ee5\u4e0b\u306b\u8aac\u660e\u3059\u308b \u30eb\u30fc\u30d7\u30d0\u30c3\u30af\u30a8\u30a4\u30ea\u30a2\u30b9 192.168.168.167 \u3068 docker-compose.override.yml \u306e\u65b9\u6cd5\u306f\u3001\u6614\u306e\u65b9\u6cd5\u3067\u3059\u30022027 \u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u30fc\u306f Compose \u306e\u5185\u90e8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3068 127.0.0.1 \u306e\u307f\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002\u8a73\u7d30\u306f ADR-02 \u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30e2\u30c7\u30eb \u3068 SPEC-02 \u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u30fc CLI \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    \u73fe\u5728\u306e\u65b9\u6cd5\u3067\u306f\u3001installer/install.sh \u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u3001\u30db\u30b9\u30c8\u306e\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u8a2d\u5b9a\u3092\u5909\u66f4\u305b\u305a\u306b runtime/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u306b\u81ea\u5df1\u5b8c\u7d50\u578b\u306e\u74b0\u5883\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002

    "},{"location":"guides/environment/#docker-compose-\u30b5\u30fc\u30d3\u30b9","title":"Docker Compose \u30b5\u30fc\u30d3\u30b9","text":"

    \u958b\u767a\u74b0\u5883\u306f\u3001\u8907\u6570\u306e\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u3092 Docker Compose \u3067\u5b9f\u884c\u3057\u307e\u3059:

    • \u30c7\u30fc\u30bf\u4fdd\u5b58\u30fb\u5171\u6709\u30b5\u30fc\u30d3\u30b9: PostgreSQL, Elasticsearch, RabbitMQ, MongoDB
    • \u30b3\u30a2\u30b5\u30fc\u30d3\u30b9: Web\u30b5\u30fc\u30d0\u30fc\u3001API\u30b5\u30fc\u30d0\u30fc\u3001\u7ba1\u7406\u753b\u9762\u3001\u30ef\u30fc\u30ab\u30fc (RDM-osf.io)\u3001WaterButler \u30d5\u30a1\u30a4\u30eb\u30b9\u30c8\u30ec\u30fc\u30b8\u30b5\u30fc\u30d3\u30b9
    • UI \u30b5\u30fc\u30d3\u30b9: Ember \u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3001Modular File Renderer (MFR)\u3001Unoconv \u30d5\u30a1\u30a4\u30eb\u5909\u63db\u30b5\u30fc\u30d3\u30b9
    • \u30c6\u30b9\u30c8\u8a8d\u8a3c\u30b5\u30fc\u30d3\u30b9: FakeCAS \u307e\u305f\u306f CAS-Overlay (OAuth \u30c6\u30b9\u30c8\u7528)

    GakuNin RDM \u3067\u306f\u3001preprints \u3068 registries \u30b5\u30fc\u30d3\u30b9\u306f\u4f7f\u7528\u3057\u307e\u305b\u3093\u3002

    "},{"location":"guides/environment/#\u30af\u30a4\u30c3\u30af\u30b9\u30bf\u30fc\u30c8","title":"\u30af\u30a4\u30c3\u30af\u30b9\u30bf\u30fc\u30c8","text":"
    1. \u3053\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u3092 clone \u3059\u308b
    2. ./installer/install.sh --yes \u3092\u5b9f\u884c\u3059\u308b
    3. \u30d6\u30e9\u30a6\u30b6\u3067 http://127.0.0.1:5000 \u3092\u958b\u304f

    \u3053\u306e\u30b3\u30de\u30f3\u30c9\u306f M2 \u30de\u30a4\u30eb\u30b9\u30c8\u30fc\u30f3\u304b\u3089\u5229\u7528\u53ef\u80fd\u3067\u3059\u3002

    "},{"location":"guides/environment/#\u904e\u53bb\u306e\u30b3\u30f3\u30c6\u30f3\u30c4","title":"\u904e\u53bb\u306e\u30b3\u30f3\u30c6\u30f3\u30c4","text":"

    \u904e\u53bb\u306e Docker Compose \u306e\u624b\u9806\uff08\u30eb\u30fc\u30d7\u30d0\u30c3\u30af\u30a8\u30a4\u30ea\u30a2\u30b9\u3001\u624b\u52d5\u8a2d\u5b9a\uff09\u306f\u3001\u53c2\u8003\u306e\u305f\u3081\u306b README.legacy.md \u306b\u305d\u306e\u307e\u307e\u6b8b\u3057\u3066\u304a\u308a\u3001\u30de\u30a4\u30eb\u30b9\u30c8\u30fc\u30f3\u3054\u3068\u306b\u66f8\u304d\u76f4\u3059\u4e88\u5b9a\u3067\u3059\u3002

    "},{"location":"guides/environment/#glossary--\u7528\u8a9e","title":"Glossary / \u7528\u8a9e","text":"Term English note \u65e5\u672c\u8a9e\u6ce8 Docker Compose A tool that runs multiple containers together using one configuration file. 1\u3064\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3067\u8907\u6570\u306e\u30b3\u30f3\u30c6\u30ca\u3092\u4e00\u7dd2\u306b\u5b9f\u884c\u3059\u308b\u30c4\u30fc\u30eb\u3002 Microservice A small program that does one job and works with other programs over the network. 1\u3064\u306e\u4ed5\u4e8b\u3092\u3059\u308b\u5c0f\u3055\u306a\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u3001\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u7d4c\u7531\u3067\u4ed6\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3068\u9023\u643a\u3057\u307e\u3059\u3002 Loopback alias A fake IP address added to your computer so programs can talk to each other. \u30d7\u30ed\u30b0\u30e9\u30e0\u540c\u58eb\u304c\u901a\u4fe1\u3067\u304d\u308b\u3088\u3046\u306b\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u306b\u8ffd\u52a0\u3059\u308b\u4eee\u306e IP \u30a2\u30c9\u30ec\u30b9\u3002 Compose internal network A private network created by Docker Compose so containers can talk without changing your computer. Docker Compose \u304c\u4f5c\u308b\u30d7\u30e9\u30a4\u30d9\u30fc\u30c8\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3067\u3001\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u3092\u5909\u66f4\u305b\u305a\u306b\u30b3\u30f3\u30c6\u30ca\u540c\u58eb\u304c\u901a\u4fe1\u3067\u304d\u307e\u3059\u3002"},{"location":"guides/environment/README.legacy/","title":"\u958b\u767a\u74b0\u5883\u306e\u6e96\u5099","text":"

    RDM\u306f\u8907\u6570\u306e\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u304b\u3089\u69cb\u6210\u3055\u308c\u307e\u3059\u3002\u958b\u767a\u6642\u306b\u3082\u3053\u308c\u3089\u306e\u30b5\u30fc\u30d3\u30b9\u3092\u52d5\u4f5c\u3055\u305b\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u304c\u3001 1\u30641\u3064\u306e\u30b5\u30fc\u30d3\u30b9\u3092\u81ea\u8eab\u306eOS\u306b\u5408\u308f\u305b\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u975e\u5e38\u306b\u624b\u9593\u304c\u304b\u304b\u308a\u307e\u3059\u3002

    \u305d\u306e\u305f\u3081\u3001Docker Compose \u3092\u7528\u3044\u3066\u958b\u767a\u74b0\u5883\u3092\u69cb\u7bc9\u3059\u308b\u65b9\u6cd5\u304c RDM-osf.io\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8 \u306b\u3066\u8aac\u660e\u3055\u308c\u3066\u3044\u307e\u3059\u3002

    Docker\u3092\u7528\u3044\u308b\u3053\u3068\u3067\u3001OS\u7b49\u306e\u74b0\u5883\u306e\u5dee\u7570\u3092\u30b3\u30f3\u30c6\u30ca\u306b\u3088\u308a\u5438\u53ce\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u672c\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3067\u306f README-docker-compose.md \u306b\u88dc\u52a9\u7684\u306a\u8aac\u660e\u3092\u52a0\u3048\u3066\u3044\u304d\u307e\u3059\u3002

    "},{"location":"guides/environment/README.legacy/#\u30b5\u30fc\u30d3\u30b9\u306e\u69cb\u6210","title":"\u30b5\u30fc\u30d3\u30b9\u306e\u69cb\u6210","text":"

    docker-compose.yml\u306b\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308b\u30b5\u30fc\u30d3\u30b9\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002

    (Generated by https://github.com/pmsipilot/docker-compose-viz)

    \u56f3\u4e2d\u306e\u5186\u306f\u30dd\u30fc\u30c8\u756a\u53f7, \u77e9\u5f62\u306f\u30b5\u30fc\u30d3\u30b9\u3092\u793a\u3057\u3066\u3044\u307e\u3059\u3002 \u30b5\u30fc\u30d3\u30b9\u306f\u5927\u304d\u304f\u5206\u3051\u3066\u4ee5\u4e0b\u306e5\u7a2e\u985e\u306b\u5206\u985e\u3067\u304d\u307e\u3059\u3002(\u62ec\u5f27\u306f\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u308bRCOSDP\u5185\u30ea\u30dd\u30b8\u30c8\u30ea)

    • \u30c7\u30fc\u30bf\u4fdd\u5b58\u30fb\u5171\u6709\u30b5\u30fc\u30d3\u30b9: postgres, elasticsearch, elasticsearch6, rabbitmq, mongo
    • \u57fa\u672c\u30b5\u30fc\u30d3\u30b9: web, api, admin, worker (RDM-osf.io), wb, wb_worker (RDM-waterbutler)
    • UI\u30b5\u30fc\u30d3\u30b9: ember_osf_web (RDM-ember-osf-web), mfr (RDM-modular-file-renderer), unoconv, registries, preprints, reviews, sharejs
    • \u30c6\u30b9\u30c8\u7528\u8a8d\u8a3c\u30b5\u30fc\u30d3\u30b9: fakecas
    • \u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u30b5\u30fc\u30d3\u30b9: requirements (RDM-osf.io), mfr_requirements (RDM-modular-file-renderer), wb_requirements (RDM-waterbutler), assets, admin_assets (RDM-osf.io)

    GRDM\u3067\u306f preprints, registries \u306f\u4f7f\u7528\u3057\u307e\u305b\u3093\u3002

    "},{"location":"guides/environment/README.legacy/#\u57fa\u672c\u7684\u306a\u6d41\u308c","title":"\u57fa\u672c\u7684\u306a\u6d41\u308c","text":"
    1. Docker\u3068OS\u306e\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7 - https://github.com/RCOSDP/RDM-osf.io/blob/develop/README-docker-compose.md#docker-and-os-setup
    2. Docker Compose\u3092\u5229\u7528\u53ef\u80fd\u306b\u3059\u308b\u305f\u3081\u306bDocker Engine\u3092\u81ea\u8eab\u306e\u74b0\u5883\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002
    3. RDM\u306e\u30b5\u30fc\u30d3\u30b9\u540c\u58eb\u304c\u4e92\u3044\u306b\u901a\u4fe1\u3067\u304d\u308b\u3088\u3046\u306b\u3001\u30eb\u30fc\u30d7\u30d0\u30c3\u30af\u30c7\u30d0\u30a4\u30b9\u3068\u3057\u3066 192.168.168.167 \u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002
    4. \u203b\u6ce8\u610f: OSX \u306a\u3089\u3073\u306b Ubuntu \u306b\u3064\u3044\u3066\u306f\u52d5\u4f5c\u5b9f\u7e3e\u304c\u3042\u308a\u307e\u3059\u304c\u3001Windows \u306b\u3064\u3044\u3066\u306f\u52d5\u4f5c\u304c\u78ba\u8a8d\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002
    5. \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u8a2d\u5b9a - https://github.com/RCOSDP/RDM-osf.io/blob/develop/README-docker-compose.md#application-configuration
    6. Web\u30b5\u30fc\u30d0\u3068API\u30b5\u30fc\u30d0\u306b\u95a2\u3059\u308b\u3001Django\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb local.py \u3092\u6e96\u5099\u3057\u307e\u3059\u3002\u7279\u306b\u5909\u66f4\u306e\u5fc5\u8981\u304c\u306a\u3051\u308c\u3070\u3001\u305d\u308c\u305e\u308c\u306e local-dist.py \u3092\u30b3\u30d4\u30fc\u3057\u3066\u4f7f\u7528\u3057\u307e\u3059\u3002
    7. RDM-osf.io, RDM-waterbutler\u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u4f7f\u7528\u3059\u308b\u3088\u3046\u3001Docker Compose\u30b5\u30fc\u30d3\u30b9\u5b9a\u7fa9\u30d5\u30a1\u30a4\u30eb\u3092\u5909\u66f4\u3057\u307e\u3059\u3002docker-compose.yml \u3092\u76f4\u63a5\u5909\u66f4\u3059\u308b\u306e\u3067\u306f\u306a\u304f\u3001 docker-compose.override.yml \u3092\u5909\u66f4\u3059\u308b\u3053\u3068\u3067\u3001\u8aa4\u3063\u3066\u958b\u767a\u74b0\u5883\u56fa\u6709\u306e\u60c5\u5831\u3092\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u30b3\u30df\u30c3\u30c8\u3059\u308b\u3053\u3068\u3092\u9632\u6b62\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002
    8. \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u5b9f\u884c - https://github.com/RCOSDP/RDM-osf.io/blob/develop/README-docker-compose.md#application-runtime
    9. \u3053\u306eDocker Compose\u74b0\u5883\u306f\u3001Docker\u30a4\u30e1\u30fc\u30b8\u3092\u30d9\u30fc\u30b9\u306b\u5404\u30b5\u30fc\u30d3\u30b9\u3092\u8d77\u52d5\u3057\u307e\u3059\u304c\u3001Python\u30e2\u30b8\u30e5\u30fc\u30eb\u3084Node\u30e2\u30b8\u30e5\u30fc\u30eb\u306f\u30a4\u30e1\u30fc\u30b8\u3068\u306f\u7570\u306a\u308b\u30dc\u30ea\u30e5\u30fc\u30e0\u306b\u4fdd\u6301\u3057\u307e\u3059\u3002(\u958b\u767a\u4e2d\u306b\u66f4\u65b0\u3055\u308c\u308b\u53ef\u80fd\u6027\u3092\u60f3\u5b9a\u3057\u3066\u3044\u308b\u3082\u306e\u3068\u601d\u308f\u308c\u307e\u3059\u3002) \u305d\u306e\u305f\u3081\u3001\u30b5\u30fc\u30d3\u30b9\u5b9f\u884c\u524d\u306b docker compose up requirements mfr_requirements wb_requirements \u3092\u5b9f\u65bd\u3059\u308b\u3053\u3068\u3067\u3001\u5fc5\u8981\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u5404\u30b3\u30f3\u30c6\u30ca\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002
    10. \u30c4\u30fc\u30eb\u306e\u5229\u7528 - https://github.com/RCOSDP/RDM-osf.io/blob/develop/README-docker-compose.md#running-arbitrary-commands
    11. Django\u306eMigration\u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210\u3084\u3001RDM\u304c\u4fdd\u6301\u3059\u308bModel\u306e\u78ba\u8a8d\u3001\u30c6\u30b9\u30c8\u306e\u5b9f\u884c\u306a\u3069\u3001Docker Compose\u7d4c\u7531\u3067\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u3067\u3001\u5bb9\u6613\u306b\u3053\u308c\u3089\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002
    12. \u74b0\u5883\u306e\u30ea\u30bb\u30c3\u30c8 - https://github.com/RCOSDP/RDM-osf.io/blob/develop/README-docker-compose.md#cleanup--docker-reset
    13. Docker\u3092\u4f7f\u3046\u3053\u3068\u3067\u5f97\u3089\u308c\u308b\u6069\u6075\u306e1\u3064\u306f\u3001\u958b\u767a\u74b0\u5883\u3092\u3044\u3064\u3067\u3082\u30ea\u30bb\u30c3\u30c8\u3067\u304d\u308b\u3068\u3044\u3046\u70b9\u3067\u3059\u3002\u958b\u767a\u6642\u306e\u8a66\u884c\u932f\u8aa4\u306e\u526f\u4f5c\u7528\u306e\u84c4\u7a4d\u3092\u7c21\u5358\u306b\u30ea\u30bb\u30c3\u30c8\u3057\u3001\u52d5\u4f5c\u78ba\u8a8d\u3092\u78ba\u5b9f\u306b\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002
    "},{"location":"guides/environment/README.legacy/#\u958b\u767a\u74b0\u5883\u306e\u30ab\u30b9\u30bf\u30de\u30a4\u30ba","title":"\u958b\u767a\u74b0\u5883\u306e\u30ab\u30b9\u30bf\u30de\u30a4\u30ba","text":"

    \u521d\u671f\u72b6\u614b\u3067\u306f docker-compose.yml \u306f quay.io/centerforopenscience/ \u304b\u3089\u30a4\u30e1\u30fc\u30b8\u3092\u53d6\u5f97\u3059\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002

    GakuNin RDM\u306e\u6700\u65b0Docker Image\u3092\u30d9\u30fc\u30b9\u306b\u958b\u767a\u3092\u884c\u3046\u306b\u306f\u3001\u3053\u308c\u3089\u306e\u30a4\u30e1\u30fc\u30b8\u3092\u5dee\u3057\u66ff\u3048\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u5185\u5bb9\u3092 docker-compose.override.yml \u306b\u8a18\u8ff0\u3057\u3066\u304f\u3060\u3055\u3044\u3002 (docker-compose.yml \u3068\u540c\u3058\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002)

    # Apple Silicon\u642d\u8f09Mac\u306e\u5834\u5408\u3001platform\u6307\u5b9a\u306e\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u90e8\u5206\u3092\u5916\u3057\u3066ARM\u7248\u30a4\u30e1\u30fc\u30b8\u3092\u4f7f\u7528\u3057\u3066\u304f\u3060\u3055\u3044\u3002\nservices:\n  fakecas:\n    image: niicloudoperation/rdm-fakecas:latest\n    # platform: linux/arm64\n  # Apple Silicon\u642d\u8f09Mac\u306e\u5834\u5408\u3001\u4ee5\u4e0b\u306e\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u90e8\u5206\u3092\u5916\u3057\u3066ARM\u7248Elasticsearch\u30a4\u30e1\u30fc\u30b8\u3092\u4f7f\u7528\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n  # elasticsearch:\n  #   image: quay.io/centerforopenscience/elasticsearch:es6-arm-6.3.1\n  #   platform: linux/arm64\n  admin:\n    image: niicloudoperation/rdm-osf.io:latest\n    # platform: linux/arm64\n    environment:\n      AWS_EC2_METADATA_DISABLED: \"true\"\n  admin_assets:\n    image: niicloudoperation/rdm-osf.io:latest\n    # platform: linux/arm64\n  api:\n    image: niicloudoperation/rdm-osf.io:latest\n    # platform: linux/arm64\n  assets:\n    image: niicloudoperation/rdm-osf.io:latest\n    # platform: linux/arm64\n  requirements:\n    image: niicloudoperation/rdm-osf.io:latest\n    # platform: linux/arm64\n    command:\n      - /bin/bash\n      - -c\n      - apk add --no-cache --virtual .build-deps build-base linux-headers python3-dev musl-dev libxml2-dev libxslt-dev postgresql-dev libffi-dev libpng-dev freetype-dev jpeg-dev &&\n        invoke requirements --all &&\n        (python3 -m compileall /usr/lib/python3.6 || true) &&\n        rm -Rf /python3.6/* &&\n        cp -Rf -p /usr/lib/python3.6 /\n  web:\n    image: niicloudoperation/rdm-osf.io:latest\n    # platform: linux/arm64\n    environment:\n      OAUTHLIB_INSECURE_TRANSPORT: '1'\n    # macOS 15.1.1\u4ee5\u964d\u306e\u5834\u5408\u30015000\u30dd\u30fc\u30c8\u304c\u4f7f\u7528\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002\u305d\u306e\u5834\u5408\u306f\u4ee5\u4e0b\u306e\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3092\u306f\u305a\u3057\u3066\u30dd\u30fc\u30c8\u3092\u5909\u66f4\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n    # \u307e\u305f\u3001 `.docker-compose.env`, `.docker-compose.mfr.env`, `.docker-compose.wb.env` \u306e\u30dd\u30fc\u30c8\u6307\u5b9a `:5000` \u306b\u3082\u540c\u69d8\u306e\n    # \u5909\u66f4\u3092\u884c\u3063\u3066\u304f\u3060\u3055\u3044\u3002\n    # ports: !override\n    #   - 5001:5000\n  worker:\n    image: niicloudoperation/rdm-osf.io:latest\n    # platform: linux/arm64\n  ember_osf_web:\n    image: niicloudoperation/rdm-ember-osf-web:latest\n    # platform: linux/amd64\n  cas:\n    image: niicloudoperation/rdm-cas-overlay:latest\n    # platform: linux/amd64\n  mfr:\n    image: niicloudoperation/rdm-modular-file-renderer:latest\n    # platform: linux/amd64\n    # \u30ed\u30fc\u30ab\u30eb\u306eRDM-modular-file-renderer\u3092\u8a66\u3057\u305f\u3044\u5834\u5408\n    # volumes:\n    #   - ../RDM-modular-file-renderer:/code\n  mfr_requirements:\n    image: niicloudoperation/rdm-modular-file-renderer:latest\n    # platform: linux/amd64\n    # \u30ed\u30fc\u30ab\u30eb\u306eRDM-modular-file-renderer\u3092\u8a66\u3057\u305f\u3044\u5834\u5408\n    # volumes:\n    #   - ../RDM-modular-file-renderer:/code\n  wb:\n    image: niicloudoperation/rdm-waterbutler:latest\n    # platform: linux/arm64\n    # \u30ed\u30fc\u30ab\u30eb\u306eRDM-waterbutler\u3092\u8a66\u3057\u305f\u3044\u5834\u5408\n    # volumes:\n    #   - ../RDM-waterbutler:/code\n  wb_worker:\n    image: niicloudoperation/rdm-waterbutler:latest\n    # platform: linux/arm64\n    # \u30ed\u30fc\u30ab\u30eb\u306eRDM-waterbutler\u3092\u8a66\u3057\u305f\u3044\u5834\u5408\n    # volumes:\n    #   - ../RDM-waterbutler:/code\n  wb_requirements:\n    image: niicloudoperation/rdm-waterbutler:latest\n    # platform: linux/arm64\n    # \u30ed\u30fc\u30ab\u30eb\u306eRDM-waterbutler\u3092\u8a66\u3057\u305f\u3044\u5834\u5408\n    # volumes:\n    #   - ../RDM-waterbutler:/code\n

    Apple Silicon\u642d\u8f09Mac\u306e\u5834\u5408\u3001docker-compose.yml\u306eelasticsearch\u306e\u5236\u9650\u306b\u95a2\u3059\u308b\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u90e8\u5206\u3092\u5916\u3057\u3066\u304f\u3060\u3055\u3044\u3002 Elasticsearch \u306f\u4e26\u5217\u5206\u6563\u51e6\u7406\u304c\u3067\u304d\u308b\u30af\u30e9\u30b9\u30bf\u8a2d\u8a08\u3055\u308c\u3066\u304a\u308a\u3001\u8907\u6570\u30ce\u30fc\u30c9\u3067\u306e\u9023\u643a\u3092\u524d\u63d0\u3068\u3057\u3066\u3044\u307e\u3059\u3002\u958b\u767a\u74b0\u5883\u306e\u3088\u3046\u306a\u5358\u4e00\u30ce\u30fc\u30c9\u3067\u306e\u5229\u7528\u306e\u5834\u5408\u306f\u30af\u30e9\u30b9\u30bf\u6a5f\u80fd\u3092\u4f7f\u3046\u5fc5\u8981\u304c\u306a\u3044\u305f\u3081\u3001\u3053\u306e\u8a2d\u5b9a\u3092\u884c\u3046\u3053\u3068\u3067\u300c\u30b7\u30f3\u30b0\u30eb\u30ce\u30fc\u30c9\u30e2\u30fc\u30c9\u300d\u3067\u52d5\u4f5c\u3055\u305b\u308b\u3088\u3046\u306b\u6307\u5b9a\u3057\u307e\u3059\u3002\u307e\u305fElasticsearch \u306f\u8d77\u52d5\u6642\u306b\u300cbootstrap \u30c1\u30a7\u30c3\u30af\u300d\u3068\u3044\u3046\u4e00\u9023\u306e\u30b7\u30b9\u30c6\u30e0\u74b0\u5883\u306e\u691c\u8a3c\u3092\u884c\u3044\u307e\u3059\u3002\u305d\u306e\u4e00\u90e8\u306b system call filter \u306e\u8a2d\u5b9a\u78ba\u8a8d\u304c\u542b\u307e\u308c\u3066\u304a\u308a\u3001\u3053\u308c\u306f\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u5411\u4e0a\u306e\u305f\u3081\u306b OS \u30ec\u30d9\u30eb\u306e\u5236\u9650\uff08\u30b7\u30b9\u30c6\u30e0\u30b3\u30fc\u30eb\u306e\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\uff09\u3092\u5229\u7528\u3059\u308b\u6a5f\u80fd\u3067\u3059\u3002\u3057\u304b\u3057\u3001Docker \u3084\u4ed6\u306e\u30b3\u30f3\u30c6\u30ca\u74b0\u5883\u3067\u306f\u3053\u306e\u30c1\u30a7\u30c3\u30af\u304c\u539f\u56e0\u3067\u8d77\u52d5\u30a8\u30e9\u30fc\u3068\u306a\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002 \u30db\u30b9\u30c8\u5074\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306eulimit\u5024\u304c\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u8981\u4ef6\u3092\u6e80\u305f\u3055\u306a\u3044\u5834\u5408\u304c\u3042\u308b\u305f\u3081\u3001\u30b3\u30f3\u30c6\u30ca\u5185\u3067\u306e\u30ea\u30bd\u30fc\u30b9\u5236\u9650\u3092\u660e\u793a\u7684\u306b\u89e3\u9664\u3057\u307e\u3059\u3002

      elasticsearch:\n    image: elasticsearch:2\n    ports:\n      - 9200:9200\n    volumes:\n      - elasticsearch_data_vol:/usr/share/elasticsearch/data\n#    environment:\n#      - \"ES_JAVA_OPTS=-Des.bootstrap.system_call_filter=false\"\n#    ulimits:\n#      memlock:\n#        soft: -1\n#        hard: -1\n    stdin_open: true\n\n  # Temporary: Remove when we've upgraded to ES6\n  elasticsearch6:\n    image: docker.elastic.co/elasticsearch/elasticsearch:6.3.1\n    ports:\n      - 9201:9200\n    volumes:\n      - elasticsearch6_data_vol:/usr/share/elasticsearch/data\n #   environment:\n #     - \"discovery.type=single-node\"\n #     - \"ES_JAVA_OPTS=-Des.bootstrap.system_call_filter=false\"\n #   ulimits:\n #     memlock:\n #       soft: -1\n #       hard: -1\n    stdin_open: true\n
    "},{"location":"guides/environment/README.legacy/#\u958b\u767a\u74b0\u5883\u3067rdm\u3092\u8d77\u52d5\u3059\u308b","title":"\u958b\u767a\u74b0\u5883\u3067RDM\u3092\u8d77\u52d5\u3059\u308b","text":""},{"location":"guides/environment/README.legacy/#\u30b5\u30fc\u30d3\u30b9\u3092\u8d77\u52d5\u3059\u308b","title":"\u30b5\u30fc\u30d3\u30b9\u3092\u8d77\u52d5\u3059\u308b","text":"

    Quickstart: Running all OSF services in the background \u306b\u793a\u3055\u308c\u3066\u3044\u308b\u3088\u3046\u306b\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u30b5\u30fc\u30d3\u30b9\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002

    # \u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb - \u521d\u56de/\u30e9\u30a4\u30d6\u30e9\u30ea\u5b9a\u7fa9\u5909\u66f4\u6642\u3060\u3051\u5fc5\u8981\n$ docker compose up requirements mfr_requirements wb_requirements\n# DB\u306e\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3 - \u521d\u56de/DB\u5b9a\u7fa9\u5909\u66f4\u6642\u3060\u3051\u5fc5\u8981\n$ docker compose run --rm web python3 manage.py migrate\n\n$ docker compose up -d assets admin_assets mfr wb wb_worker fakecas sharejs worker web api admin ember_osf_web\n

    https://github.com/RCOSDP/RDM-osf.io/blob/develop/README-docker-compose.md \u3067\u306f preprints, registries \u306e\u8d77\u52d5\u306b\u3064\u3044\u3066\u7d39\u4ecb\u3057\u3066\u3044\u307e\u3059\u304c\u3001GRDM\u3067\u306f preprints, registries \u306f\u63d0\u4f9b\u3057\u306a\u3044\u305f\u3081\u7121\u8996\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    "},{"location":"guides/environment/README.legacy/#\u30b7\u30f3\u30d7\u30eb\u306a\u69cb\u6210\u3067\u8d77\u52d5\u3059\u308b","title":"\u30b7\u30f3\u30d7\u30eb\u306a\u69cb\u6210\u3067\u8d77\u52d5\u3059\u308b","text":"

    \u52d5\u4f5c\u78ba\u8a8d\u3057\u305f\u3044\u5185\u5bb9\u306b\u5fdc\u3058\u3066\u3001 mfr, admin_assets, admin, sharejs \u3092\u9664\u5916\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002 \u4f8b\u3048\u3070\u3001fakecas\u3067\u8a8d\u8a3c\u3057\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u4f5c\u6210\u3001\u30d5\u30a1\u30a4\u30eb\u7ba1\u7406\u3092\u78ba\u8a8d\u3057\u305f\u3044\u3060\u3051\u3067\u3042\u308c\u3070\u3001

    # \u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb - \u521d\u56de/\u30e9\u30a4\u30d6\u30e9\u30ea\u5b9a\u7fa9\u5909\u66f4\u6642\u3060\u3051\u5fc5\u8981\n$ docker compose up requirements wb_requirements\n# DB\u306e\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3 - \u521d\u56de/DB\u5b9a\u7fa9\u5909\u66f4\u6642\u3060\u3051\u5fc5\u8981\n$ docker compose run --rm web python3 manage.py migrate\n\n$ docker compose up -d assets wb wb_worker fakecas worker web api ember_osf_web\n

    \u3067\u3082\u5341\u5206\u3067\u3057\u3087\u3046\u3002docker compose ps\u3067\u7570\u5e38\u7d42\u4e86\u3057\u3066\u3044\u308b\u30b5\u30fc\u30d3\u30b9\u304c\u3044\u306a\u3044\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002 docker compose ps\u306e\u51fa\u529b\u4f8b\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002docker compose up -d\u3067\u6307\u5b9a\u3057\u305f\u30b5\u30fc\u30d3\u30b9\u304cUp\u3067\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002

    $ docker compose ps\n            Name                          Command               State                                              Ports                                           \n-------------------------------------------------------------------------------------------------------------------------------------------------------------------\nrdm2-osfio_api_1               docker-entrypoint.sh invok ...   Up       0.0.0.0:8000->8000/tcp                                                                    \nrdm2-osfio_assets_1            docker-entrypoint.sh invok ...   Up                                                                                                 \nrdm2-osfio_elasticsearch_1     /docker-entrypoint.sh elas ...   Up       0.0.0.0:9200->9200/tcp, 9300/tcp                                                          \nrdm2-osfio_ember_osf_web_1     docker-entrypoint.sh /bin/ ...   Up       0.0.0.0:41953->41953/tcp, 0.0.0.0:4200->4200/tcp                                          \nrdm2-osfio_fakecas_1           fakecas -host=0.0.0.0:8080 ...   Up       0.0.0.0:8080->8080/tcp                                                                    \nrdm2-osfio_postgres_1          docker-entrypoint.sh /bin/ ...   Up       0.0.0.0:5432->5432/tcp                                                                    \nrdm2-osfio_rabbitmq_1          docker-entrypoint.sh rabbi ...   Up       15671/tcp, 0.0.0.0:15672->15672/tcp, 25672/tcp, 4369/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp\nrdm2-osfio_requirements_1      docker-entrypoint.sh /bin/ ...   Exit 0                                                                                             \nrdm2-osfio_wb_1                invoke server                    Up       0.0.0.0:7777->7777/tcp                                                                    \nrdm2-osfio_wb_requirements_1   /bin/bash -c invoke instal ...   Exit 0                                                                                             \nrdm2-osfio_wb_worker_1         invoke celery                    Up       7777/tcp                                                                                  \nrdm2-osfio_web_1               docker-entrypoint.sh invok ...   Up       0.0.0.0:5000->5000/tcp                                                                    \nrdm2-osfio_worker_1            docker-entrypoint.sh invok ...   Up\n
    "},{"location":"guides/environment/README.legacy/#cas-overlay\u3092\u542b\u3080\u69cb\u6210\u3067\u8d77\u52d5\u3059\u308b","title":"cas-overlay\u3092\u542b\u3080\u69cb\u6210\u3067\u8d77\u52d5\u3059\u308b","text":"

    fakecas\u306f\u624b\u8efd\u306bRDM\u306e\u52d5\u4f5c\u78ba\u8a8d\u3092\u884c\u3048\u307e\u3059\u304c\u3001OAuth\u306e\u52d5\u4f5c\u78ba\u8a8d\u306a\u3069\u306f\u3067\u304d\u307e\u305b\u3093\u3002OAuth\u3092\u7528\u3044\u305f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u958b\u767a\u6642\u306b\u306f\u3001fakecas\u3067\u306f\u306a\u304fcas-overlay\u3092\u4f7f\u3063\u305f\u30c6\u30b9\u30c8\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002\u3053\u306e\u3088\u3046\u306a\u5834\u5408\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306bfakecas\u306e\u4ee3\u308f\u308a\u306b cas \u30b5\u30fc\u30d3\u30b9\u3092\u8d77\u52d5\u3057\u307e\u3059\u3002

    # \u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb - \u521d\u56de/\u30e9\u30a4\u30d6\u30e9\u30ea\u5b9a\u7fa9\u5909\u66f4\u6642\u3060\u3051\u5fc5\u8981\n$ docker compose up requirements wb_requirements\n# DB\u306e\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3 - \u521d\u56de/DB\u5b9a\u7fa9\u5909\u66f4\u6642\u3060\u3051\u5fc5\u8981\n$ docker compose run --rm web python3 manage.py migrate\n\n# fakecas\u3067\u306f\u306a\u304fcas\u3092\u30b5\u30fc\u30d3\u30b9\u306b\u6307\u5b9a\u3059\u308b\n$ docker compose up -d assets wb wb_worker cas worker web api ember_osf_web\n\n# OAuth\u306e\u30b9\u30b3\u30fc\u30d7\u3092\u767b\u9332\u3059\u308b\n$ docker compose run --rm web python3 -m scripts.register_oauth_scopes\n

    cas\u306ffakecas\u3068\u306f\u7570\u306a\u308a\u3001\u30ed\u30b0\u30a4\u30f3\u6642\u306b \u30e6\u30fc\u30b6\u4f5c\u6210\u624b\u9806(\u5f8c\u8ff0) \u306b\u304a\u3044\u3066\u5165\u529b\u3057\u305f\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002\u4ed6\u306e\u64cd\u4f5c\u65b9\u6cd5\u306ffakecas\u3068\u540c\u69d8\u3067\u3059\u3002

    "},{"location":"guides/environment/README.legacy/#web-ui\u3092\u958b\u304f","title":"Web UI\u3092\u958b\u304f","text":"

    \u30b5\u30fc\u30d3\u30b9\u304c\u8d77\u52d5\u3057\u305f\u3053\u3068\u3092\u78ba\u8a8d\u3057\u305f\u3089\u3001 http://localhost:5000 \u306b\u30a2\u30af\u30bb\u30b9\u3057\u52d5\u4f5c\u3092\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002

    \u30ed\u30b0\u306f docker compose logs \u30b3\u30de\u30f3\u30c9\u3067\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002ember_osf_web\u30b3\u30f3\u30c6\u30ca\u306f\u8d77\u52d5\u306b\u3042\u308b\u7a0b\u5ea6\u6642\u9593\u304c\u304b\u304b\u308a\u307e\u3059\u304c\u3001\u3053\u306e\u72b6\u614b\u3092\u78ba\u8a8d\u3059\u308b\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5165\u529b\u3057\u307e\u3059\u3002

    $ docker compose logs -f ember_osf_web\n...\nBuild successful (xxxxxms) \u2013 Serving on http://0.0.0.0:4200/\n
    "},{"location":"guides/environment/README.legacy/#\u30c6\u30b9\u30c8\u7528\u30e6\u30fc\u30b6\u3092\u4f5c\u6210\u3059\u308b","title":"\u30c6\u30b9\u30c8\u7528\u30e6\u30fc\u30b6\u3092\u4f5c\u6210\u3059\u308b","text":"

    http://localhost:5000 \u304c\u6b63\u5e38\u306b\u53c2\u7167\u3067\u304d\u305f\u3089\u3001Sign Up\u3092\u884c\u3044\u307e\u3057\u3087\u3046\u3002\u4ee5\u4e0b\u306e\u624b\u9806\u3067\u884c\u3044\u307e\u3059\u3002

    1. Sign Up\u30dc\u30bf\u30f3\u3092\u62bc\u3057\u3001\u30e6\u30fc\u30b6\u767b\u9332\u753b\u9762\u3092\u958b\u304f
    2. \u30e6\u30fc\u30b6\u767b\u9332\u753b\u9762\u306b\u9069\u5f53\u306a\u30e6\u30fc\u30b6\u540d\u3001E\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3068\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u5165\u529b\u3059\u308b
    3. \u30c7\u30d0\u30c3\u30b0\u30ed\u30b0\u306bE\u30e1\u30fc\u30eb\u5230\u9054\u78ba\u8a8d\u7528\u306eURL(http://localhost:5000/confirm/xxxxx/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/)\u304c\u51fa\u529b\u3055\u308c\u308b\u306e\u3067\u3001 docker compose logs web \u3067\u78ba\u8a8d\u3059\u308b

    \u672c\u756a\u74b0\u5883\u306e\u5834\u5408\u306f\u3053\u3053\u3067E\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u5b9b\u306b\u5230\u9054\u78ba\u8a8d\u7528\u306eURL\u3092\u542b\u3080\u30e1\u30fc\u30eb\u304c\u5c4a\u304d\u307e\u3059\u304c\u3001SMTP\u30b5\u30fc\u30d0\u3092\u6307\u5b9a\u3057\u3066\u3044\u306a\u3044\u306e\u3067\u30e1\u30fc\u30eb\u306f\u9001\u4fe1\u3055\u308c\u307e\u305b\u3093\u3002

    1. \u5230\u9054\u78ba\u8a8d\u7528\u306eURL\u3092\u30d6\u30e9\u30a6\u30b6\u3067\u30a2\u30af\u30bb\u30b9\u3059\u308b

    \u30d6\u30e9\u30a6\u30b6\u306fFirefox\u3092\u4f7f\u7528\u3057\u3066\u304f\u3060\u3055\u3044\u3002Chrome\u306e\u5834\u5408\u306f\u3001FakeCAS\u3068Web UI\u306e\u9593\u3067Cookie\u304c\u5171\u6709\u3055\u308c\u305a\u6b63\u5e38\u52d5\u4f5c\u3057\u306a\u3044\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002

    "},{"location":"guides/environment/README.legacy/#\u52d5\u4f5c\u78ba\u8a8d\u3092\u5b9f\u65bd\u3059\u308b","title":"\u52d5\u4f5c\u78ba\u8a8d\u3092\u5b9f\u65bd\u3059\u308b","text":"

    \u3053\u308c\u3067\u30e6\u30fc\u30b6\u306e\u4f5c\u6210\u306f\u5b8c\u4e86\u3067\u3059\u3002\u4ee5\u964d\u306f\u3001\u30ed\u30b0\u30a4\u30f3\u753b\u9762\u304b\u3089\u3001\u767b\u9332\u3057\u305fE\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306e\u307f\u3067\u30ed\u30b0\u30a4\u30f3\u3067\u304d\u307e\u3059\u3002(\u958b\u767a\u7528\u9014\u306b\u9650\u5b9a\u3057\u3066\u5229\u7528\u3057\u3066\u304f\u3060\u3055\u3044\u3002)

    "},{"location":"guides/environment/README.legacy/#\u30b3\u30de\u30f3\u30c9\u306e\u5b9f\u884c\u4f8b","title":"\u30b3\u30de\u30f3\u30c9\u306e\u5b9f\u884c\u4f8b","text":""},{"location":"guides/environment/README.legacy/#\u30e6\u30cb\u30c3\u30c8\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b","title":"\u30e6\u30cb\u30c3\u30c8\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b","text":"

    \u5168\u3066\u306e\u30e6\u30cb\u30c3\u30c8\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30b3\u30de\u30f3\u30c9\u3092\u5165\u529b\u3057\u307e\u3059\u3002 requirements \u30b5\u30fc\u30d3\u30b9\u306b\u3088\u308a\u30c6\u30b9\u30c8\u306b\u5fc5\u8981\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3001invoke test\u3067\u30c6\u30b9\u30c8\u304c\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002

    # \u521d\u56de\u3060\u3051\u5fc5\u8981\n$ docker compose up requirements\n\n$ docker compose run --rm web invoke test\n

    \u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u3092\u9650\u5b9a\u3059\u308b\u65b9\u6cd5\u306f https://github.com/RCOSDP/RDM-osf.io/blob/develop/README-docker-compose.md#application-tests \u306b\u8a18\u8f09\u3055\u308c\u3066\u3044\u307e\u3059\u3002

    "},{"location":"guides/environment/README.legacy/#migration\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3059\u308b","title":"Migration\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3059\u308b","text":"

    RDM-osf.io\u306fDjango\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3068\u3057\u3066\u5b9f\u88c5\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u30e2\u30c7\u30eb\u306e\u5909\u66f4\u3092\u884c\u3063\u305f\u5834\u5408\u3001\u9069\u5207\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30b9\u30ad\u30fc\u30de\u306b\u5909\u66f4\u304c\u53cd\u6620\u3055\u308c\u308b\u3088\u3046\u3001Migrations\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 \u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5165\u529b\u3059\u308b\u3053\u3068\u3067\u3001Django\u306e\u7ba1\u7406\u30b3\u30de\u30f3\u30c9 makemigrations \u3092\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002

    $ docker compose run --rm web python3 manage.py makemigrations\n

    \u4f5c\u6210\u3057\u305fMigrations\u30d5\u30a1\u30a4\u30eb\u306f\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067 postgres\u30b5\u30fc\u30d3\u30b9\u306b\u53cd\u6620\u3067\u304d\u307e\u3059\u3002

    $ docker compose run --rm web python3 manage.py migrate\n
    "},{"location":"guides/environment/README.legacy/#\u30e6\u30fc\u30b6\u3092\u6a5f\u95a2\u306b\u6240\u5c5e\u3055\u305b\u308b","title":"\u30e6\u30fc\u30b6\u3092\u6a5f\u95a2\u306b\u6240\u5c5e\u3055\u305b\u308b","text":"

    \u6a5f\u95a2\u306b\u95a2\u3059\u308b\u6a5f\u80fd\u3092\u8a66\u3059\u305f\u3081\u306b\u306f\u3001\u30e6\u30fc\u30b6\u3092\u6a5f\u95a2\u306b\u6240\u5c5e\u3055\u305b\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 \u3053\u306e\u3088\u3046\u306a\u5834\u5408\u306f\u3001\u4ee5\u4e0b\u306e\u624b\u9806\u3092\u5b9f\u65bd\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    \u307e\u305a\u3001\u5b9f\u884c\u4e2d\u306eRDM\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u6a5f\u95a2\u306e\u60c5\u5831\u3092\u767b\u9332\u3057\u307e\u3059\u3002\u3053\u308c\u306f\u521d\u56de\u3060\u3051\u5fc5\u8981\u3067\u3059\u3002

    $ docker compose run --rm web python3 -m scripts.populate_institutions -e test -a\n

    \u4e0a\u8a18\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001Virginia Tech [Test] \u306a\u3069\u306e\u6a5f\u95a2\u540d\u3092\u6301\u3064\u6a5f\u95a2\u304c\u767b\u9332\u3055\u308c\u307e\u3059\u3002

    \u6b21\u306b\u3001shell\u6a5f\u80fd\u3092\u4f7f\u3063\u3066\u3001\u30e6\u30fc\u30b6\u306b\u6a5f\u95a2\u3092\u7d10\u4ed8\u3051\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002

    $ docker compose run --rm web invoke shell\n

    \u4e0a\u8a18\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30d7\u30ed\u30f3\u30d7\u30c8\u304c\u73fe\u308c\u307e\u3059\u306e\u3067\u3001Python\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u51e6\u7406\u3092\u6307\u793a\u3057\u307e\u3059\u3002\u4e0b\u8a18\u306e\u3088\u3046\u306b\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u6307\u5b9a\u3057\u305fEmail\u30a2\u30c9\u30ec\u30b9\u3092\u6301\u3064\u30e6\u30fc\u30b6\u306e\u30e2\u30c7\u30eb\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002

    In[1]: user = OSFUser.objects.get(username='\u767b\u9332\u3057\u305fEmail\u30a2\u30c9\u30ec\u30b9')\n\nIn [2]: user\nOut[2]: <OSFUser('\u767b\u9332\u3057\u305fEmail\u30a2\u30c9\u30ec\u30b9') with guid '\u767b\u9332\u3055\u308c\u305f\u30e6\u30fc\u30b6ID'>\n

    \u30e6\u30fc\u30b6\u304c\u6240\u5c5e\u3059\u308b\u6a5f\u95a2\u306e\u30ea\u30b9\u30c8\u306f\u3001user.affiliated_institutions\u3067\u7ba1\u7406\u3055\u308c\u307e\u3059\u3002\u3053\u306e\u30ea\u30b9\u30c8\u306b\u3001\u5148\u306b\u767b\u9332\u3057\u305f\u6a5f\u95a2\u306b\u5bfe\u5fdc\u3059\u308bInstitution\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u8ffd\u52a0\u3059\u308b\u3068\u3001\u30e6\u30fc\u30b6\u3092\u6a5f\u95a2\u306b\u6240\u5c5e\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002

    # \u6a5f\u95a2\u540d\u306f\u4f8b\u3048\u3070 Virginia Tech [Test] \u7b49: [i.name for i in Institution.objects.all()] \u3067\u78ba\u8a8d\u3067\u304d\u308b\nIn [4]: user.affiliated_institutions.add(Institution.objects.get(name='\u6a5f\u95a2\u540d'))\n

    \u5909\u6570\u3092\u7de8\u96c6\u3057\u305f\u3089\u3001\u30e2\u30c7\u30eb\u306b\u5bfe\u3057\u3066save\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3057\u3001commit\u3082\u5fd8\u308c\u306a\u3044\u3088\u3046\u306b\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002

    In [5]: user.save()\n\nIn [6]: commit()\nTransaction committed.\nNew transaction opened.\n

    \u3053\u308c\u3067\u30e6\u30fc\u30b6\u3092\u6a5f\u95a2\u306b\u6240\u5c5e\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002\u8a66\u3057\u306b\u3001New Project\u304b\u3089\u65b0\u898f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u4f5c\u6210\u3092\u5b9f\u65bd\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u6240\u5c5e\u306e\u3068\u3053\u308d\u306b\u3001Institution\u3067\u6307\u5b9a\u3057\u305f\u6a5f\u95a2\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002

    "},{"location":"guides/environment/README.legacy/#admin\u30a2\u30af\u30bb\u30b9\u53ef\u80fd\u306a\u30e6\u30fc\u30b6\u3078\u3068\u5909\u66f4\u3059\u308b","title":"admin\u30a2\u30af\u30bb\u30b9\u53ef\u80fd\u306a\u30e6\u30fc\u30b6\u3078\u3068\u5909\u66f4\u3059\u308b","text":"

    \u7ba1\u7406\u8005\u6a5f\u80fd\u306f http://localhost:8001/ \u304b\u3089\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 \u30e6\u30fc\u30b6\u304cadmin\u30a2\u30af\u30bb\u30b9\u53ef\u80fd\u304b\u3069\u3046\u304b\u306f is_staff \u30d7\u30ed\u30d1\u30c6\u30a3\u3067\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002

    is_staff\u306e\u7de8\u96c6\u306b\u306f\u3001shell\u6a5f\u80fd\u3092\u4f7f\u3044\u307e\u3059\u3002

    $ docker compose run --rm web invoke shell\n

    shell\u304b\u3089\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u3067\u3001\u6307\u5b9a\u3057\u305f\u30e6\u30fc\u30b6\u306e is_staff \u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u5909\u66f4\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002

    In[1]: user = OSFUser.objects.get(username='\u767b\u9332\u3057\u305fEmail\u30a2\u30c9\u30ec\u30b9')\n\nIn [2]: user\nOut[2]: <OSFUser('\u767b\u9332\u3057\u305fEmail\u30a2\u30c9\u30ec\u30b9') with guid '\u767b\u9332\u3055\u308c\u305f\u30e6\u30fc\u30b6ID'>\n\nIn [3]: user.is_staff = True\n\nIn [4]: user.save()\n\nIn [5]: commit()\nTransaction committed.\nNew transaction opened.\n
    "},{"location":"guides/screen-expansion/","title":"Screen Expansion Addon / \u753b\u9762\u62e1\u5f35\u30a2\u30c9\u30aa\u30f3","text":"

    Summary: Guide to creating RDM screen expansion addons with dashboard widgets and page tabs \u6982\u8981: \u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u3068\u30da\u30fc\u30b8\u30bf\u30d6\u3092\u6301\u3064 RDM \u753b\u9762\u62e1\u5f35\u30a2\u30c9\u30aa\u30f3\u3092\u4f5c\u6210\u3059\u308b\u624b\u5f15\u304d

    Jump: English \u00b7 \u65e5\u672c\u8a9e

    • Version / \u7248: 0.1 \u2014 2026-11-05
    • Normative for: docs/guides/screen-expansion/
    • Related: SPEC-06 Documentation Conventions \u00b7 Skeleton Guide

    "},{"location":"guides/screen-expansion/#english","title":"English","text":"

    \u2192 \u65e5\u672c\u8a9e\u7248\u3078

    "},{"location":"guides/screen-expansion/#overview","title":"Overview","text":"

    This guide shows how to create RDM screen expansion addons that add:

    • Dashboard widgets: Small UI elements on the project dashboard
    • Page tabs: New pages accessible from the project navigation bar

    Screen expansion addons use Ember.js for the frontend and Django for the backend.

    "},{"location":"guides/screen-expansion/#prerequisites","title":"Prerequisites","text":"
    • Basic understanding of Python, Django, and JavaScript
    • The development environment set up following the Environment Guide
    • Completed the Skeleton Addon Guide
    "},{"location":"guides/screen-expansion/#quick-start","title":"Quick start","text":"
    1. Create your addon using the skeleton as a base
    2. Add widget template and configuration files
    3. Add Ember.js page tab (route, controller, template)
    4. Configure RDM to display your widget and tab
    5. Test both the widget and page tab
    "},{"location":"guides/screen-expansion/#legacy-content","title":"Legacy content","text":"

    The legacy screen expansion addon instructions are kept verbatim in README.legacy.md for reference and will be rewritten per milestone.

    "},{"location":"guides/screen-expansion/#\u65e5\u672c\u8a9e","title":"\u65e5\u672c\u8a9e","text":"

    \u2192 To English

    "},{"location":"guides/screen-expansion/#\u6982\u8981","title":"\u6982\u8981","text":"

    \u3053\u306e\u30ac\u30a4\u30c9\u306f\u3001\u4ee5\u4e0b\u306e\u6a5f\u80fd\u3092\u6301\u3064 RDM \u753b\u9762\u62e1\u5f35\u30a2\u30c9\u30aa\u30f3\u3092\u4f5c\u6210\u3059\u308b\u65b9\u6cd5\u3092\u793a\u3057\u307e\u3059:

    • \u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u30a6\u30a3\u30b8\u30a7\u30c3\u30c8: \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u4e0a\u306e\u5c0f\u3055\u306a UI \u8981\u7d20
    • \u30da\u30fc\u30b8\u30bf\u30d6: \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u30d0\u30fc\u304b\u3089\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u65b0\u3057\u3044\u30da\u30fc\u30b8

    \u753b\u9762\u62e1\u5f35\u30a2\u30c9\u30aa\u30f3\u306f\u3001\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u306b Ember.js\u3001\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u306b Django \u3092\u4f7f\u7528\u3057\u307e\u3059\u3002

    "},{"location":"guides/screen-expansion/#\u524d\u63d0\u6761\u4ef6","title":"\u524d\u63d0\u6761\u4ef6","text":"
    • Python, Django, JavaScript \u306e\u57fa\u672c\u7684\u306a\u7406\u89e3
    • \u74b0\u5883\u30ac\u30a4\u30c9\u306b\u5f93\u3063\u3066\u958b\u767a\u74b0\u5883\u3092\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3057\u3066\u3044\u308b\u3053\u3068
    • \u30b9\u30b1\u30eb\u30c8\u30f3\u30a2\u30c9\u30aa\u30f3\u30ac\u30a4\u30c9\u3092\u5b8c\u4e86\u3057\u3066\u3044\u308b\u3053\u3068
    "},{"location":"guides/screen-expansion/#\u30af\u30a4\u30c3\u30af\u30b9\u30bf\u30fc\u30c8","title":"\u30af\u30a4\u30c3\u30af\u30b9\u30bf\u30fc\u30c8","text":"
    1. \u30b9\u30b1\u30eb\u30c8\u30f3\u3092\u30d9\u30fc\u30b9\u306b\u30a2\u30c9\u30aa\u30f3\u3092\u4f5c\u6210\u3059\u308b
    2. \u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3068\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u8ffd\u52a0\u3059\u308b
    3. Ember.js \u306e\u30da\u30fc\u30b8\u30bf\u30d6\uff08\u30eb\u30fc\u30c8\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\uff09\u3092\u8ffd\u52a0\u3059\u308b
    4. RDM \u3092\u8a2d\u5b9a\u3057\u3066\u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u3068\u30bf\u30d6\u3092\u8868\u793a\u3059\u308b
    5. \u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u3068\u30da\u30fc\u30b8\u30bf\u30d6\u306e\u4e21\u65b9\u3092\u30c6\u30b9\u30c8\u3059\u308b
    "},{"location":"guides/screen-expansion/#\u904e\u53bb\u306e\u30b3\u30f3\u30c6\u30f3\u30c4","title":"\u904e\u53bb\u306e\u30b3\u30f3\u30c6\u30f3\u30c4","text":"

    \u904e\u53bb\u306e\u753b\u9762\u62e1\u5f35\u30a2\u30c9\u30aa\u30f3\u306e\u624b\u9806\u306f\u3001\u53c2\u8003\u306e\u305f\u3081\u306b README.legacy.md \u306b\u305d\u306e\u307e\u307e\u6b8b\u3057\u3066\u304a\u308a\u3001\u30de\u30a4\u30eb\u30b9\u30c8\u30fc\u30f3\u3054\u3068\u306b\u66f8\u304d\u76f4\u3059\u4e88\u5b9a\u3067\u3059\u3002

    "},{"location":"guides/screen-expansion/#glossary--\u7528\u8a9e","title":"Glossary / \u7528\u8a9e","text":"Term English note \u65e5\u672c\u8a9e\u6ce8 Screen expansion addon An addon that adds new UI elements and pages to RDM. RDM \u306b\u65b0\u3057\u3044 UI \u8981\u7d20\u3068\u30da\u30fc\u30b8\u3092\u8ffd\u52a0\u3059\u308b\u30a2\u30c9\u30aa\u30f3\u3002 Dashboard widget A small UI element displayed on the project dashboard. \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u306b\u8868\u793a\u3055\u308c\u308b\u5c0f\u3055\u306a UI \u8981\u7d20\u3002 Page tab A new page accessible from the project navigation bar. \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u30d0\u30fc\u304b\u3089\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u65b0\u3057\u3044\u30da\u30fc\u30b8\u3002 Ember.js A JavaScript framework for building interactive web applications. \u30a4\u30f3\u30bf\u30e9\u30af\u30c6\u30a3\u30d6\u306a\u30a6\u30a7\u30d6\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u69cb\u7bc9\u3059\u308b\u305f\u3081\u306e JavaScript \u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3002"},{"location":"guides/screen-expansion/README.legacy/","title":"\u753b\u9762\u62e1\u5f35\u30a2\u30c9\u30aa\u30f3\u306e\u4f5c\u6210","text":"

    \u4ee5\u4e0b\u306e\u6a5f\u80fd\u3092\u6301\u3064\u753b\u9762\u62e1\u5f35\u30a2\u30c9\u30aa\u30f3\u3092\u5b9f\u88c5\u3057\u307e\u3059\u3002

    • \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u4e0a\u306e\u30a2\u30c9\u30aa\u30f3\u306e\u30a6\u30a3\u30b8\u30a7\u30c3\u30c9
    • \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u30d0\u30fc\u304b\u3089\u9077\u79fb\u3067\u304d\u308b\u30a2\u30c9\u30aa\u30f3\u306e\u753b\u9762\u30bf\u30d6(Ember\u3092\u5229\u7528)

    \u57fa\u672c\u7684\u306a\u30a2\u30c9\u30aa\u30f3\u306e\u6982\u8981\u306f\u30b9\u30b1\u30eb\u30c8\u30f3\u306e\u4f5c\u6210\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    "},{"location":"guides/screen-expansion/README.legacy/#\u524d\u63d0\u6761\u4ef6","title":"\u524d\u63d0\u6761\u4ef6","text":"

    \u958b\u767a\u74b0\u5883\u306e\u6e96\u5099\u306e\u30ac\u30a4\u30c9\u306b\u5f93\u3044\u3001\u958b\u767a\u74b0\u5883\u306b\u3066RDM\u3092\u8d77\u52d5\u3057\u3066\u3044\u308b\u3082\u306e\u3068\u3057\u307e\u3059\u3002

    "},{"location":"guides/screen-expansion/README.legacy/#\u753b\u9762\u62e1\u5f35\u30a2\u30c9\u30aa\u30f3\u306e\u8a2d\u8a08","title":"\u753b\u9762\u62e1\u5f35\u30a2\u30c9\u30aa\u30f3\u306e\u8a2d\u8a08","text":""},{"location":"guides/screen-expansion/README.legacy/#\u30b5\u30fc\u30d3\u30b9\u306e\u69cb\u6210","title":"\u30b5\u30fc\u30d3\u30b9\u306e\u69cb\u6210","text":"

    \u753b\u9762\u62e1\u5f35\u30a2\u30c9\u30aa\u30f3\u306f\u4ee5\u4e0b\u306e2\u3064\u306e\u8981\u7d20\u304b\u3089\u69cb\u6210\u3055\u308c\u307e\u3059\u3002

    • OSF.io\u30b5\u30fc\u30d3\u30b9\u3067\u52d5\u4f5c\u3059\u308bAddon: \u30e6\u30fc\u30b6\u30fb\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u8a2d\u5b9a\u306e\u7ba1\u7406
    • ember-osf-web\u30b5\u30fc\u30d3\u30b9\u3067\u52d5\u4f5c\u3059\u308b\u753b\u9762\u30bf\u30d6\u30e2\u30b8\u30e5\u30fc\u30eb: \u753b\u9762\u30bf\u30d6\u306eView\u5b9a\u7fa9

    ember-osf-web\u306f\u3001 Ember.js \u3092\u30d9\u30fc\u30b9\u3068\u3057\u305fOSF\u306e\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9UI\u306e\u5b9f\u88c5\u3067\u3059\u3002\u3082\u3068\u3082\u3068\u3001OSF.io\u304c\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3082\u62c5\u5f53\u3057\u3066\u3044\u307e\u3057\u305f\u304c\u3001COS\u306fEmber.js\u30d9\u30fc\u30b9\u306e\u30b3\u30fc\u30c9\u306b\u79fb\u884c\u3092\u9032\u3081\u3066\u3044\u307e\u3059\u3002

    \u73fe\u5728\u306fosf-web(OSF.io)\u304c\u5916\u90e8\u304b\u3089\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u53d7\u3051\u3001\u8981\u6c42\u3055\u308c\u305f\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3092ember-osf-web\u304c\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u3044\u308b\u3068\u5224\u65ad\u3055\u308c\u308b\u5834\u5408\u306f\u3001osf-web\u304cember-osf-web\u306b\u5bfe\u3057\u3066\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u8ee2\u9001\u3059\u308b\u5f62\u5f0f\u3092\u53d6\u3063\u3066\u3044\u307e\u3059\u3002\u5b9f\u969b\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u5bfe\u3059\u308b\u64cd\u4f5c\u306f\u3001\u5f93\u6765\u306eosf-api(OSF.io apiserver)\u304c\u62c5\u3044\u307e\u3059\u3002ember-osf\u95a2\u9023\u306e\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u306f\u3001\u5fc5\u8981\u306b\u5fdc\u3058\u3066API\u30b5\u30fc\u30d0\u3078\u306e\u554f\u3044\u5408\u308f\u305b\u3092\u884c\u3046\u3053\u3068\u3067\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u5bfe\u3059\u308b\u5909\u66f4\u3084\u30b9\u30c8\u30ec\u30fc\u30b8\u306b\u5bfe\u3059\u308b\u64cd\u4f5c\u3092\u5b9f\u65bd\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002

    "},{"location":"guides/screen-expansion/README.legacy/#\u30d5\u30a1\u30a4\u30eb\u306e\u69cb\u6210","title":"\u30d5\u30a1\u30a4\u30eb\u306e\u69cb\u6210","text":"

    \u5178\u578b\u7684\u306a\u30d5\u30a1\u30a4\u30eb\u914d\u7f6e\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002

    "},{"location":"guides/screen-expansion/README.legacy/#osfio-addon\u306e\u30d5\u30a1\u30a4\u30eb\u69cb\u6210","title":"OSF.io Addon\u306e\u30d5\u30a1\u30a4\u30eb\u69cb\u6210","text":"

    \u30af\u30e9\u30b9\u69cb\u6210\u306f\u30b9\u30b1\u30eb\u30c8\u30f3 \u30a2\u30c9\u30aa\u30f3\u3068\u540c\u69d8\u3067\u3059\u3002

    /addons/\u30a2\u30c9\u30aa\u30f3\u540d/\n\u251c\u2500\u2500 __init__.py ... \u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u5b9a\u7fa9\n\u251c\u2500\u2500 apps.py ... (**) \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u5b9a\u7fa9\n\u251c\u2500\u2500 models.py ... \u30e2\u30c7\u30eb\u306e\u5b9a\u7fa9\n\u251c\u2500\u2500 requirements.txt ... \u5229\u7528\u3059\u308bPython\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u5b9a\u7fa9\n\u251c\u2500\u2500 routes.py ... (**) View(Routes)\u306e\u5b9a\u7fa9\n\u251c\u2500\u2500 settings ... \u8a2d\u5b9a\u3092\u5b9a\u7fa9\u3059\u308b\u30e2\u30b8\u30e5\u30fc\u30eb\n\u2502   \u251c\u2500\u2500 defaults.py ... \u30c7\u30d5\u30a9\u30eb\u30c8\u8a2d\u5b9a\u306e\u5b9a\u7fa9\n\u2502   \u2514\u2500\u2500 __init__.py ... \u8a2d\u5b9a\u306e\u5b9a\u7fa9\n\u251c\u2500\u2500 static ... Web\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u8aad\u307f\u8fbc\u3080\u3053\u3068\u3092\u60f3\u5b9a\u3057\u305f\u9759\u7684\u30d5\u30a1\u30a4\u30eb\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 comicon.png ... \u30a2\u30c9\u30aa\u30f3\u306e\u30a2\u30a4\u30b3\u30f3\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 \u30a2\u30c9\u30aa\u30f3\u540d.css ... (*) \u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u306eCSS\u30d5\u30a1\u30a4\u30eb\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 node-cfg.js ... Node\u8a2d\u5b9a\u306e\u30a8\u30f3\u30c8\u30ea\u3068\u306a\u308bJavaScript\u30d5\u30a1\u30a4\u30eb\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 widget-cfg.js ... (*) \u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u306eJavaScript\u30d5\u30a1\u30a4\u30eb\n\u251c\u2500\u2500 templates ... \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 node_settings.mako ... Node\u8a2d\u5b9a\u30d1\u30cd\u30eb\n\u251c\u2500\u2500 tests ... \u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.py\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 conftest.py\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 factories.py\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 test_model.py\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 (**) test_view.py\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 utils.py\n\u251c\u2500\u2500 utils.py ... (*) \u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u95a2\u6570\u306e\u5b9a\u7fa9\n\u2514\u2500\u2500 views.py ... (**) View(Views)\u306e\u5b9a\u7fa9\n

    (*)\u304c\u4ed8\u3044\u3066\u3044\u308b\u30d5\u30a1\u30a4\u30eb\u306f\u30b9\u30b1\u30eb\u30c8\u30f3 \u30a2\u30c9\u30aa\u30f3\u306b\u306f\u5b58\u5728\u3057\u306a\u3044\u30d5\u30a1\u30a4\u30eb\u3067\u3059\u3002 (**)\u304c\u4ed8\u3044\u3066\u3044\u308b\u30d5\u30a1\u30a4\u30eb\u306f\u30b9\u30b1\u30eb\u30c8\u30f3 \u30a2\u30c9\u30aa\u30f3\u306b\u5b58\u5728\u3057\u307e\u3059\u304c\u3001\u5909\u66f4\u304c\u52a0\u3048\u3089\u308c\u3066\u3044\u308b\u30d5\u30a1\u30a4\u30eb\u3067\u3059\u3002

    "},{"location":"guides/screen-expansion/README.legacy/#ember-osf-web-\u753b\u9762\u30bf\u30d6\u306e\u30d5\u30a1\u30a4\u30eb\u69cb\u6210","title":"ember-osf-web \u753b\u9762\u30bf\u30d6\u306e\u30d5\u30a1\u30a4\u30eb\u69cb\u6210","text":"
    app\n\u251c\u2500\u2500 guid-node/\u30a2\u30c9\u30aa\u30f3\u540d ... \u30a2\u30c9\u30aa\u30f3\u306e\u753b\u9762\u30bf\u30d6\u30e2\u30b8\u30e5\u30fc\u30eb\u5b9a\u7fa9\n\u2502   \u251c\u2500\u2500 controller.ts ... \u753b\u9762\u30bf\u30d6\u306e\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u5b9a\u7fa9\n\u2502   \u251c\u2500\u2500 route.ts ... \u753b\u9762\u30bf\u30d6\u306e\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u5b9a\u7fa9\n\u2502   \u251c\u2500\u2500 styles.scss ... \u753b\u9762\u30bf\u30d6\u306eCSS(SCSS)\u5b9a\u7fa9\n\u2502   \u2514\u2500\u2500 template.hbs ... \u753b\u9762\u30bf\u30d6\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\n\u251c\u2500\u2500 models/\u30e2\u30c7\u30eb\u540d.ts ... \u753b\u9762\u30bf\u30d6\u3067\u4f7f\u3046\u30e2\u30c7\u30eb\u5b9a\u7fa9\n\u251c\u2500\u2500 adapters/\u30e2\u30c7\u30eb\u540d.ts ... \u753b\u9762\u30bf\u30d6\u3067\u4f7f\u3046\u30e2\u30c7\u30eb\u306e\u30a2\u30c0\u30d7\u30bf\u5b9a\u7fa9\n\u2514\u2500\u2500 serializers/\u30e2\u30c7\u30eb\u540d.ts ... \u753b\u9762\u30bf\u30d6\u3067\u4f7f\u3046\u30e2\u30c7\u30eb\u306e\u30b7\u30ea\u30a2\u30e9\u30a4\u30b6\u5b9a\u7fa9\n\ntests ... \u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\n\u251c\u2500\u2500 acceptance/guid-node/\u30a2\u30c9\u30aa\u30f3\u540d-test.ts\n\u2514\u2500\u2500 unit/guid-node/\u30a2\u30c9\u30aa\u30f3\u540d/controller-test.ts\n\nmirage ... \u30a2\u30c0\u30d7\u30bf\u63a5\u7d9a\u5148API\u306e\u30c6\u30b9\u30c8\u7528\u30e2\u30c3\u30af\u5b9a\u7fa9\n\u251c\u2500\u2500 factories/\u30e2\u30c7\u30eb\u540d.ts\n\u2514\u2500\u2500 views/\u30e2\u30c7\u30eb\u540d.ts\n
    "},{"location":"guides/screen-expansion/README.legacy/#osfio-addon\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u69cb\u6210","title":"OSF.io Addon\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u69cb\u6210","text":"

    \u30b9\u30b1\u30eb\u30c8\u30f3 \u30a2\u30c9\u30aa\u30f3\u3068\u5927\u304d\u306a\u9055\u3044\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u30b9\u30b1\u30eb\u30c8\u30f3 \u30a2\u30c9\u30aa\u30f3\u3068\u306e\u9055\u3044\u3092\u4e2d\u5fc3\u306b\u8aac\u660e\u3057\u3066\u3044\u304d\u307e\u3059\u3002

    "},{"location":"guides/screen-expansion/README.legacy/#model\u306e\u69cb\u6210","title":"Model\u306e\u69cb\u6210","text":"

    Model\u306e\u69cb\u6210\u306f\u30b9\u30b1\u30eb\u30c8\u30f3 \u30a2\u30c9\u30aa\u30f3\u3068\u540c\u3058\u3067\u3059\u3002

    "},{"location":"guides/screen-expansion/README.legacy/#view\u306e\u69cb\u6210","title":"View\u306e\u69cb\u6210","text":"

    \u30b9\u30b1\u30eb\u30c8\u30f3 \u30a2\u30c9\u30aa\u30f3\u306eViews\u304a\u3088\u3073Routes\u306e\u5b9a\u7fa9\u306b\u3001\u753b\u9762\u30bf\u30d6\u7528\u306e\u5b9a\u7fa9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002

    \u753b\u9762\u30bf\u30d6\u3067\u30a2\u30c9\u30aa\u30f3\u306e\u30c7\u30fc\u30bf\u3092\u3084\u308a\u53d6\u308a\u3059\u308b\u306b\u306f\u3001ember-osf-web\u306b\u65b0\u3057\u304f\u30e2\u30c7\u30eb\u3092\u5b9a\u7fa9\u3057\u3001\u305d\u306e\u30e2\u30c7\u30eb\u306b\u5bfe\u5fdc\u3059\u308bJSON API\u3092OSF.io\u5074\u306b\u5b9a\u7fa9\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 \u30c7\u30fc\u30bf\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a JSON:API \u3067\u5b9a\u3081\u3089\u308c\u305f\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3067\u3084\u308a\u53d6\u308a\u3057\u307e\u3059\u3002

    {\n  \"data\": {\n    \"id\": node\u306eID\n    \"type\": \"\u30e2\u30c7\u30eb\u540d\",\n    \"attributes\": \u30c7\u30fc\u30bf\u306eDictionary\n  }\n}\n

    My Screen\u30a2\u30c9\u30aa\u30f3\u306e\u5834\u5408\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306bRoutes\u3068Views\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002

    • routes.py
    • views.py
    "},{"location":"guides/screen-expansion/README.legacy/#\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306b\u3088\u3063\u3066\u63d0\u4f9b\u3055\u308c\u308bview","title":"\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306b\u3088\u3063\u3066\u63d0\u4f9b\u3055\u308c\u308bView","text":"

    \u30a2\u30c9\u30aa\u30f3\u306e\u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u5b9a\u7fa9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002

    \u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306f website/templates/util/render_addon_widget.mako \u306b\u5b9a\u7fa9\u3057\u307e\u3059\u3002 \u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u8a2d\u5b9a\u306f website/project/views/node.py \u306b\u5b9a\u7fa9\u3057\u307e\u3059\u3002

    \u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u3067\u4f7f\u3046JavaScript\u306f /addons/\u30a2\u30c9\u30aa\u30f3\u540d/static/widget-cfg.js \u3067\u3001CSS\u306f /addons/\u30a2\u30c9\u30aa\u30f3\u540d/static/\u30a2\u30c9\u30aa\u30f3\u540d.css \u3067\u5b9a\u7fa9\u3057\u307e\u3059\u3002CSS\u306fJavaScript\u30d5\u30a1\u30a4\u30eb\u304b\u3089 require() \u3092\u4f7f\u3063\u3066\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002

    My Screen\u30a2\u30c9\u30aa\u30f3\u306e\u5834\u5408\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5b9a\u7fa9\u3057\u307e\u3059\u3002

    • render_addon_widget.mako
    • node.py
    • widget-cfg.js
    • myscreen.css
    "},{"location":"guides/screen-expansion/README.legacy/#\u56fd\u969b\u5316","title":"\u56fd\u969b\u5316","text":"

    \u56fd\u969b\u5316\u306e\u8a2d\u5b9a\u306f website/translations/ \u4ee5\u4e0b\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5b9a\u7fa9\u3057\u307e\u3059\u3002

    msgid \u30e1\u30c3\u30bb\u30fc\u30b8ID\nmsgstr \u56fd\u969b\u5316\u5f8c\u306e\u6587\u5b57\u5217\n

    *.pot \u30d5\u30a1\u30a4\u30eb\u306b\u306f msgstr \u3092 \"\" (\u7a7a\u6587\u5b57)\u306b\u3057\u3066\u5b9a\u7fa9\u3057\u307e\u3059\u3002 messages.* \u306b\u306fmako\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u3067\u4f7f\u3046\u56fd\u969b\u5316\u8a2d\u5b9a\u3092\u3001 js_messages.* \u306b\u306fJavaScript\u3067\u4f7f\u3046\u56fd\u969b\u5316\u8a2d\u5b9a\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002

    JavaScript\u3067\u6587\u5b57\u5217\u3092\u56fd\u969b\u5316\u3059\u308b\u306e\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u66f8\u304d\u307e\u3059\u3002

    var _ = require('js/rdmGettext')._;\nconst localizedStr = _('\u30e1\u30c3\u30bb\u30fc\u30b8ID');\n

    mako\u3067\u6587\u5b57\u5217\u3092\u56fd\u969b\u5316\u3059\u308b\u306e\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u66f8\u304d\u307e\u3059\u3002

    ${_(\"\u30e1\u30c3\u30bb\u30fc\u30b8ID\")}\n
    "},{"location":"guides/screen-expansion/README.legacy/#\u8a2d\u5b9a\u30e2\u30b8\u30e5\u30fc\u30eb","title":"\u8a2d\u5b9a\u30e2\u30b8\u30e5\u30fc\u30eb","text":"

    \u8a2d\u5b9a\u30e2\u30b8\u30e5\u30fc\u30eb\u306f\u30b9\u30b1\u30eb\u30c8\u30f3 \u30a2\u30c9\u30aa\u30f3\u3068\u540c\u3058\u3067\u3059\u3002

    "},{"location":"guides/screen-expansion/README.legacy/#addonappconfig\u306e\u5b9a\u7fa9","title":"AddonAppConfig\u306e\u5b9a\u7fa9","text":"

    \u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u3068\u753b\u9762\u30bf\u30d6\u3092\u6709\u52b9\u306b\u3059\u308b\u305f\u3081\u306b\u3001 /addons/\u30a2\u30c9\u30aa\u30f3\u540d/app.py \u306e AddonAppConfig.views \u306b\u3001'widget' \u3068 'page' \u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002

    class AddonAppConfig(BaseAddonAppConfig):\n    # \u4e2d\u7565\n    views = ['widget', 'page']\n    # \u4e2d\u7565\n

    My Screen\u30a2\u30c9\u30aa\u30f3\u306e\u5834\u5408\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5b9a\u7fa9\u3057\u307e\u3059\u3002

    • apps.py
    "},{"location":"guides/screen-expansion/README.legacy/#\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9","title":"\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9","text":"

    \u30b9\u30b1\u30eb\u30c8\u30f3 \u30a2\u30c9\u30aa\u30f3\u3068\u540c\u69d8\u306b\u3001\u30e6\u30cb\u30c3\u30c8\u30c6\u30b9\u30c8\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002 My Screen\u30a2\u30c9\u30aa\u30f3\u306e\u5834\u5408\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5b9a\u7fa9\u3057\u307e\u3059\u3002

    • tests/
    "},{"location":"guides/screen-expansion/README.legacy/#ember-osf-web-\u753b\u9762\u30bf\u30d6\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u69cb\u6210","title":"ember-osf-web \u753b\u9762\u30bf\u30d6\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u69cb\u6210","text":"

    ember-osf-web\u306f TypeScript \u306b\u3088\u3063\u3066\u5b9f\u88c5\u3055\u308c\u307e\u3059\u3002 \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30b3\u30fc\u30c9\u306f app/ \u306b\u5b9f\u88c5\u3055\u308c\u307e\u3059\u3002

    ember-osf-web\u306f\u3001OSF\u306e\u753b\u9762\u3092\u69cb\u6210\u3059\u308b\u30da\u30fc\u30b8\u3092\u5358\u4f4d\u3068\u3057\u3066\u30e2\u30b8\u30e5\u30fc\u30eb\u5206\u5272\u3055\u308c\u3066\u3044\u307e\u3059\u3002

    "},{"location":"guides/screen-expansion/README.legacy/#routerts","title":"router.ts","text":"

    router.ts \u306f\u3001\u30da\u30fc\u30b8\u5168\u4f53\u3092\u675f\u306d\u308b\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u5b9a\u7fa9\u30d5\u30a1\u30a4\u30eb\u3067\u3059\u3002

    \u4f8b\u3048\u3070\u3001 /\u30d7\u30ed\u30b8\u30a7\u30af\u30c8ID/\u30a2\u30c9\u30aa\u30f3\u540d \u3068\u3044\u3046\u30d1\u30b9\u3092\u8ffd\u52a0\u3059\u308b\u5834\u5408\u306f\u3001 Router.map \u306b\u6e21\u3059\u95a2\u6570\u306b\u4ee5\u4e0b\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002

    this.route('guid-node', { path: '--node/:guid' }, function() {\n    this.route('\u30a2\u30c9\u30aa\u30f3\u540d');\n});\n

    \u3053\u306e\u30d1\u30b9\u306b\u30ea\u30af\u30a8\u30b9\u30c8\u304c\u4e0e\u3048\u3089\u308c\u308b\u3068\u3001 app/guid-node/\u30a2\u30c9\u30aa\u30f3\u540d \u3067\u5b9a\u7fa9\u3055\u308c\u305f\u30da\u30fc\u30b8\u306b\u51e6\u7406\u304c\u79fb\u884c\u3057\u307e\u3059\u3002

    "},{"location":"guides/screen-expansion/README.legacy/#\u30da\u30fc\u30b8\u306e\u5b9f\u88c5","title":"\u30da\u30fc\u30b8\u306e\u5b9f\u88c5","text":""},{"location":"guides/screen-expansion/README.legacy/#\u753b\u9762\u306e\u5b9f\u88c5","title":"\u753b\u9762\u306e\u5b9f\u88c5","text":"

    \u753b\u9762\u306e\u5b9f\u88c5\u306f Handlebars templating library \u3092\u4f7f\u7528\u3057\u3066\u3001 template.hbs \u30d5\u30a1\u30a4\u30eb\u306b\u5b9a\u7fa9\u3057\u307e\u3059\u3002

    \u753b\u9762\u4e0a\u306e\u6587\u5b57\u5217\u306f\u5168\u3066\u56fd\u969b\u5316\u3092\u8003\u616e\u3057\u3001 translations/en-us.yml \u306b\u5b9a\u7fa9\u3055\u308c\u305f\u5024\u3092\u57cb\u3081\u8fbc\u3080\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002

    My Screen\u30a2\u30c9\u30aa\u30f3\u306e\u5834\u5408\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5b9a\u7fa9\u3057\u307e\u3059\u3002

    • template.hbs
    • translations/en-us.yml

    \u30dc\u30bf\u30f3 \u3084 DatePicker \u3001 \u30c0\u30a4\u30a2\u30ed\u30b0\u30dc\u30c3\u30af\u30b9 \u306a\u3069\u306f\u3001\u5225\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3068\u3057\u3066\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u3067\u518d\u5229\u7528\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002 lib/osf-components \u306e\u30b3\u30fc\u30c9\u3092\u78ba\u8a8d\u3057\u3066\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u5229\u7528\u3057\u307e\u3057\u3087\u3046\u3002

    "},{"location":"guides/screen-expansion/README.legacy/#\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u306e\u5b9a\u7fa9","title":"\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u306e\u5b9a\u7fa9","text":"

    \u753b\u9762\u306b\u57cb\u3081\u8fbc\u3080\u5909\u6570\u3084\u30cf\u30f3\u30c9\u30e9\u306e\u5236\u5fa1\u306f\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u304c\u62c5\u3044\u307e\u3059\u3002 \u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u306b\u306f template.hbs \u306b\u57cb\u3081\u8fbc\u307e\u308c\u308b\u5909\u6570\u3084\u30a4\u30d9\u30f3\u30c8\u306b\u5bfe\u3059\u308b\u51e6\u7406\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002

    My Screen\u30a2\u30c9\u30aa\u30f3\u306e\u5834\u5408\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5b9a\u7fa9\u3057\u307e\u3059\u3002

    • controller.ts

    \u307e\u305f\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u3068\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u306e\u3084\u308a\u53d6\u308a\u306f\u3001Ember Data\u304c\u63d0\u4f9b\u3059\u308b DS.Store \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u7d4c\u7531\u3057\u3066\u884c\u308f\u308c\u307e\u3059\u3002 DS.Store\u3067\u64cd\u4f5c\u53ef\u80fd\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306f models \u306b\u5b9a\u7fa9\u3055\u308c\u3001 adapters \u306b\u5b9a\u7fa9\u3055\u308c\u305f\u30eb\u30fc\u30eb\u306b\u57fa\u3065\u304d\u3001API\u30b5\u30fc\u30d0\u3092\u4ecb\u3057\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u64cd\u4f5c\u3092\u884c\u3044\u307e\u3059\u3002

    \u306a\u304a\u3001API\u30b5\u30fc\u30d0\u306f JSON:API \u306b\u5247\u3063\u3066\u3044\u308b\u3053\u3068\u3092\u524d\u63d0\u3068\u3059\u308b\u3053\u3068\u3067\u3001adapter\u306f\u7d30\u304b\u306a\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u751f\u6210\u51e6\u7406\u3092\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u306a\u304f\u3001API\u30b5\u30fc\u30d0\u3068\u306e\u9023\u643a\u3092\u5b9f\u73fe\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 \u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u751f\u6210\u51e6\u7406\u3092\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3057\u305f\u3044\u5834\u5408\u306f\u3001 serializers \u306b\u5b9a\u7fa9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002

    My Screen\u30a2\u30c9\u30aa\u30f3\u306e\u5834\u5408\u3001myscreen-config \u3068\u3044\u3046model\u3068\u3001\u5bfe\u5fdc\u3059\u308badapter\u304a\u3088\u3073serializer\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5b9a\u7fa9\u3057\u307e\u3059\u3002

    • models/myscreen-config.ts
    • adapters/myscreen-config.ts
    • serializers/myscreen-config.ts
    "},{"location":"guides/screen-expansion/README.legacy/#\u30b9\u30bf\u30a4\u30eb\u306e\u5b9a\u7fa9","title":"\u30b9\u30bf\u30a4\u30eb\u306e\u5b9a\u7fa9","text":"

    \u30b9\u30bf\u30a4\u30eb\u306f Sass(SCSS) \u3092\u4f7f\u7528\u3057\u3066\u3001 styles.scss \u30d5\u30a1\u30a4\u30eb\u306b\u5b9a\u7fa9\u3057\u307e\u3059\u3002 My Screen\u30a2\u30c9\u30aa\u30f3\u306e\u5834\u5408\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5b9a\u7fa9\u3057\u307e\u3059\u3002

    • styles.scss
    "},{"location":"guides/screen-expansion/README.legacy/#\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306e\u5b9a\u7fa9","title":"\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306e\u5b9a\u7fa9","text":"

    \u30e2\u30b8\u30e5\u30fc\u30eb\u306b\u95a2\u3059\u308b\u8ffd\u52a0\u306e\u7d4c\u8def\u5b9a\u7fa9\u3092 route.ts \u306b\u5b9a\u7fa9\u3057\u307e\u3059\u3002 My Screen\u30a2\u30c9\u30aa\u30f3\u306e\u5834\u5408\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5b9a\u7fa9\u3057\u307e\u3059\u3002

    • route.ts
    "},{"location":"guides/screen-expansion/README.legacy/#\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9_1","title":"\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9","text":"

    \u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u306f tests/ \u306b\u5b9a\u7fa9\u3057\u307e\u3059\u3002 \u30c6\u30b9\u30c8\u306b\u4f7f\u3046API\u306e\u30e2\u30c3\u30af\u306f\u3001 Mirage \u3092\u4f7f\u7528\u3057\u3066 mirage/ \u306b\u5b9a\u7fa9\u3057\u307e\u3059\u3002

    My Screen\u30a2\u30c9\u30aa\u30f3\u306e\u5834\u5408\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5b9a\u7fa9\u3057\u307e\u3059\u3002

    • tests/
    • mirage/
    "},{"location":"guides/screen-expansion/README.legacy/#my-screen\u30a2\u30c9\u30aa\u30f3\u306e\u5b9f\u88c5","title":"My Screen\u30a2\u30c9\u30aa\u30f3\u306e\u5b9f\u88c5","text":"

    \u3053\u3053\u3067\u306f\u3001 myscreen \u3068\u3044\u3046\u8b58\u5225\u540d\u306e\u30a2\u30c9\u30aa\u30f3\u306e\u5b9f\u88c5\u3092\u4f8b\u306b\u8aac\u660e\u3057\u307e\u3059\u3002\u30a2\u30c9\u30aa\u30f3\u306e\u5b8c\u5168\u540d\u306f My Screen \u3068\u3057\u307e\u3059\u3002

    \u30a2\u30c9\u30aa\u30f3\u540d\u306f\u69d8\u3005\u306a\u5834\u6240\u306b\u57cb\u3081\u8fbc\u307e\u308c\u3066\u3044\u307e\u3059\u3002\u30a2\u30c9\u30aa\u30f3\u540d\u3092\u5909\u66f4\u3057\u305f\u3044\u5834\u5408\u306f\u3001\u4ee5\u964d\u3067\u8ffd\u52a0\u30fb\u5909\u66f4\u3059\u308b\u30d5\u30a1\u30a4\u30eb\u540d\u3084\u30b3\u30fc\u30c9\u306e myscreen \u3001 My Screen \u3001 MyScreen \u3068\u3044\u3046\u6587\u5b57\u5217\u3092\u5909\u66f4\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    "},{"location":"guides/screen-expansion/README.legacy/#osfio\u3078\u306e\u5b9f\u88c5","title":"OSF.io\u3078\u306e\u5b9f\u88c5","text":""},{"location":"guides/screen-expansion/README.legacy/#addonsmyscreen-\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u5b9a\u7fa9","title":"addons.myscreen \u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u5b9a\u7fa9","text":"

    \u30b9\u30b1\u30eb\u30c8\u30f3 \u30a2\u30c9\u30aa\u30f3\u3068\u540c\u69d8\u306b\u3001\u30a2\u30c9\u30aa\u30f3\u306e\u5b9f\u88c5\u4f8b(osf.io/addon/)\u3092 addons/myscreen \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u30b3\u30d4\u30fc\u3057\u307e\u3059\u3002

    "},{"location":"guides/screen-expansion/README.legacy/#rdm\u30b3\u30fc\u30c9\u306e\u5909\u66f4","title":"RDM\u30b3\u30fc\u30c9\u306e\u5909\u66f4","text":"

    \u30b9\u30b1\u30eb\u30c8\u30f3 \u30a2\u30c9\u30aa\u30f3\u3068\u540c\u69d8\u306b\u3001RDM\u306e\u30b3\u30fc\u30c9\u3092\u3044\u304f\u3064\u304b\u5909\u66f4\u3057\u307e\u3059\u3002

    • addons.json
    • \u5909\u66f4\u4f8b\u306e\u30b5\u30f3\u30d7\u30eb: addons.json
    • framework/addons/data/addons.json
    • \u5909\u66f4\u4f8b\u306e\u30b5\u30f3\u30d7\u30eb: addons.json
    • Dockerfile
    • \u5909\u66f4\u4f8b\u306e\u30b5\u30f3\u30d7\u30eb: Dockerfile
    • api/base/settings/defaults.py
    • \u5909\u66f4\u4f8b\u306e\u30b5\u30f3\u30d7\u30eb: defaults.py
    "},{"location":"guides/screen-expansion/README.legacy/#\u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u5909\u66f4","title":"\u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u5909\u66f4","text":"

    website/templates/util/render_addon_widget.mako \u306b\u3001\u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5b9a\u7fa9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002

    % if addon_name == 'myscreen':\n    <div id=\"myscreen-content\" class=\"scripted\">\n        <!-- ko if: loading -->\n        <div>${_(\"Loading\")}</div>\n        <!-- /ko -->\n        <!-- ko if: loadFailed -->\n        <div class=\"text-danger\">${_(\"Error occurred\")}</div>\n        <!-- /ko -->\n        <!-- ko if: loadCompleted -->\n        <h5 style=\"padding: 0.2em;\">${_(\"My Screen Test\")}</h5>\n        <div>\n            <label data-bind=\"text: param_1_label\"></label>\n            <p data-bind=\"text: param_1\"></p>\n        </div>\n        <!-- /ko -->\n    </div>\n% endif\n

    website/project/views/node.py \u306e view_project() \u95a2\u6570\u306b\u3001My Screen\u30a2\u30c9\u30aa\u30f3\u306e\u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u30c7\u30fc\u30bf\u3092\u8aad\u307f\u8fbc\u3080\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002

    def view_project(auth, node, **kwargs):\n    # \u4e2d\u7565\n    addons_widget_data = {\n        # \u4e2d\u7565\n        'myscreen': None\n    }\n\n    if 'myscreen' in ret['addons']:\n        addons_widget_data['myscreen'] = serialize_myscreen_widget(node)\n    # \u4e2d\u7565\n

    \u305d\u308c\u305e\u308c\u306e\u5909\u66f4\u4f8b\u306f\u3001\u30b5\u30f3\u30d7\u30eb render_addon_widget.mako \u3068 node.py \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    "},{"location":"guides/screen-expansion/README.legacy/#\u56fd\u969b\u5316\u30d5\u30a1\u30a4\u30eb\u306e\u5909\u66f4","title":"\u56fd\u969b\u5316\u30d5\u30a1\u30a4\u30eb\u306e\u5909\u66f4","text":"

    website/translations/ \u4ee5\u4e0b\u306e\u5404\u56fd\u969b\u5316\u30d5\u30a1\u30a4\u30eb\u306b\u3001\u30a2\u30c9\u30aa\u30f3\u3067\u8868\u793a\u3059\u308b\u6587\u5b57\u5217\u306e\u56fd\u969b\u5316\u8a2d\u5b9a\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002

    website/translations/messages.pot \u3068 website/translations/en/LC_MESSAGES/messages.po:

    #: website/templates/util/render_addon_widget.mako:245\nmsgid \"My Screen Test\"\nmsgstr \"\"\n

    website/translations/ja/LC_MESSAGES/messages.po:

    #: website/templates/util/render_addon_widget.mako:245\nmsgid \"My Screen Test\"\nmsgstr \"My Screen \u30c6\u30b9\u30c8\"\n

    website/translations/js_messages.pot \u3068 website/translations/en/LC_MESSAGES/js_messages.po:

    #: addons/myscreen/static/widget-cfg.js:22\nmsgid \"My Screen Param1 Label\"\nmsgstr \"\"\n

    website/translations/ja/LC_MESSAGES/js_messages.po:

    #: addons/myscreen/static/widget-cfg.js:22\nmsgid \"My Screen Param1 Label\"\nmsgstr \"\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc1\"\n

    \u5909\u66f4\u4f8b\u306f\u3001\u30b5\u30f3\u30d7\u30eb translations/ \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    "},{"location":"guides/screen-expansion/README.legacy/#migrations\u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210","title":"Migrations\u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210","text":"

    makemigrations \u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u3001Migrations\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002

    $ docker compose run --rm web python3 manage.py makemigrations\n

    \u4e0a\u8a18\u306e\u51fa\u529b\u4e2d\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u51fa\u529b\u304c\u73fe\u308c\u308c\u3070\u6210\u529f\u3067\u3059\u3002

    Migrations for 'addons_myscreen':\n  addons/myscreen/migrations/0001_initial.py\n    - Create model NodeSettings\n    - Add field user_settings to nodesettings\n
    "},{"location":"guides/screen-expansion/README.legacy/#widget\u306e\u8868\u793a\u4f4d\u7f6e\u306e\u30ab\u30b9\u30bf\u30de\u30a4\u30ba","title":"Widget\u306e\u8868\u793a\u4f4d\u7f6e\u306e\u30ab\u30b9\u30bf\u30de\u30a4\u30ba","text":"

    \u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f\u3001\u30a2\u30c9\u30aa\u30f3\u306eWidget\u306f\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u306e\u5de6\u30ab\u30e9\u30e0\u306e\u4e0b\u90e8(FileViewer\u306e\u4e0b)\u306b\u3001\u30a2\u30c9\u30aa\u30f3\u306e\u540d\u524d\u9806\u3067\u8868\u793a\u3055\u308c\u307e\u3059\u3002\u8868\u793a\u4f4d\u7f6e\u3092\u5909\u66f4\u3059\u308b\u5834\u5408\u306f\u3001 website/templates/project/project.mako \u30d5\u30a1\u30a4\u30eb\u3092\u7de8\u96c6\u3057\u307e\u3059\u3002

    \u4eca\u5f8c\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u306e\u8868\u793a\u3082Ember\u5316\u3055\u308c\u308b\u3053\u3068\u304c\u8003\u3048\u3089\u308c\u307e\u3059\u3002\u305d\u306e\u5834\u5408\u306f\u3001Ember\u5074\u3082\u5408\u308f\u305b\u3066\u5909\u66f4\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002

    \u5de6\u30ab\u30e9\u30e0\u306e\u4e00\u756a\u4e0a(Wiki\u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u306e\u4e0a)\u306b\u8868\u793a\u3057\u305f\u3044\u5834\u5408\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u4fee\u6b63\u3057\u307e\u3059\u3002

    @@ -431,6 +431,10 @@\n\n     <div class=\"col-sm-12 col-md-6 osf-dash-col\">\n\n+        % if 'myscreen' in addons_enabled and addons['myscreen']['has_widget']:\n+            ${ render_addon_widget.render_addon_widget('myscreen', addons_widget_data['myscreen']) }\n+        % endif\n+\n         %if user['show_wiki_widget']:\n             ${ render_addon_widget.render_addon_widget('wiki', addons_widget_data['wiki']) }\n         %endif\n@@ -470,7 +474,7 @@\n             <!-- Show widgets in left column if present -->\n             % for addon in addons_enabled:\n                 % if addons[addon]['has_widget']:\n-                    %if addon != 'wiki' and addon != 'iqbrims': ## We already show the wiki widget at the top\n+                    %if addon != 'wiki' and addon != 'iqbrims' and addon != 'myscreen': ## We already show the wiki widget at the top\n                         ${ render_addon_widget.render_addon_widget(addon, addons_widget_data[addon]) }\n                     %endif\n                 % endif\n

    \u53f3\u30ab\u30e9\u30e0\u306e\u4e00\u756a\u4e0a\u306b\u8868\u793a\u3057\u305f\u3044\u5834\u5408\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u4fee\u6b63\u3057\u307e\u3059\u3002

    @@ -470,7 +470,7 @@\n             <!-- Show widgets in left column if present -->\n             % for addon in addons_enabled:\n                 % if addons[addon]['has_widget']:\n-                    %if addon != 'wiki' and addon != 'iqbrims': ## We already show the wiki widget at the top\n+                    %if addon != 'wiki' and addon != 'iqbrims' and addon != 'myscreen': ## We already show the wiki widget at the top\n                         ${ render_addon_widget.render_addon_widget(addon, addons_widget_data[addon]) }\n                     %endif\n                 % endif\n             % endfor\n         % else:\n             <!-- If no widgets, show components -->\n             ${children()}\n         % endif\n\n     </div>\n\n     <div class=\"col-sm-12 col-md-6 osf-dash-col\">\n+        % if 'myscreen' in addons_enabled and addons['myscreen']['has_widget']:\n+            ${ render_addon_widget.render_addon_widget('myscreen', addons_widget_data['myscreen']) }\n+        % endif\n+\n         % if addons:\n             <!-- Show IQB-RIMS widgets in right column if present -->\n             % for addon in addons_enabled:\n

    \u5909\u66f4\u4f8b\u306f\u3001\u30b5\u30f3\u30d7\u30eb project.mako \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    "},{"location":"guides/screen-expansion/README.legacy/#\u753b\u9762\u30bf\u30d6\u30ea\u30f3\u30af\u306e\u8868\u793a\u4f4d\u7f6e\u306e\u30ab\u30b9\u30bf\u30de\u30a4\u30ba","title":"\u753b\u9762\u30bf\u30d6\u30ea\u30f3\u30af\u306e\u8868\u793a\u4f4d\u7f6e\u306e\u30ab\u30b9\u30bf\u30de\u30a4\u30ba","text":"

    \u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f\u3001\u30a2\u30c9\u30aa\u30f3\u753b\u9762\u30bf\u30d6\u306e\u30ea\u30f3\u30af\u306f\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u30d0\u30fc\u306eFiles(\u30d5\u30a1\u30a4\u30eb)\u30bf\u30d6\u306e\u53f3\u306b\u3001\u30a2\u30c9\u30aa\u30f3\u306e\u540d\u524d\u9806\u3067\u8868\u793a\u3055\u308c\u307e\u3059\u3002\u8868\u793a\u4f4d\u7f6e\u3092\u5909\u66f4\u3059\u308b\u5834\u5408\u306f\u3001website/templates/project/project_header.mako \u30d5\u30a1\u30a4\u30eb\u3092\u7de8\u96c6\u3057\u307e\u3059\u3002

    \u30a2\u30c9\u30aa\u30f3\u753b\u9762\u30bf\u30d6\u306a\u3069\u306eember-osf-web\u304c\u63d0\u4f9b\u3059\u308bView\u3092\u958b\u3044\u3066\u3044\u308b\u3068\u304d\u306f\u3001ember-osf-web\u3067\u5b9a\u7fa9\u3057\u305f node-navbar \u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8(\u5f8c\u8ff0)\u306b\u5f93\u3063\u3066\u8868\u793a\u3055\u308c\u307e\u3059\u3002

    \u30a2\u30c9\u30aa\u30f3\u30ea\u30b9\u30c8\u306e\u6700\u5f8c\uff08Analytics\uff08\u5206\u6790\uff09\u306e\u524d\uff09\u306b\u8868\u793a\u3059\u308b\u5834\u5408\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u4fee\u6b63\u3057\u307e\u3059\u3002

    @@ -43,7 +43,7 @@\n                         <!-- Add-on tabs  -->\n                         % for addon in addons_enabled:\n\n-                            % if addons[addon]['has_page']:\n+                            % if addon != 'myscreen' and addons[addon]['has_page']:\n                                 <li>\n                                     <a href=\"${node['url']}${addons[addon]['short_name']}\">\n\n                                         % if addons[addon]['icon'] and addons[addon]['has_page_icon']:\n                                             <img src=\"${addons[addon]['icon']}\" class=\"addon-logo\"/>\n                                         % endif\n                                         ${addons[addon]['full_name']}\n                                     </a>\n                                 </li>\n                             % endif\n                         % endfor\n\n+                        % if 'myscreen' in addons_enabled and addons['myscreen']['has_page']:\n+                            <li>\n+                                <a href=\"${node['url']}${addons['myscreen']['short_name']}\">\n+\n+                                    % if addons['myscreen']['icon'] and addons['myscreen']['has_page_icon']:\n+                                        <img src=\"${addons['myscreen']['icon']}\" class=\"addon-logo\"/>\n+                                    % endif\n+                                    ${addons['myscreen']['full_name']}\n+                                </a>\n+                            </li>\n+                        % endif\n+\n                         % if project_analytics:\n                         % if node['is_public'] or user['is_contributor_or_group_member']:\n                             <li><a href=\"${node['url']}analytics/\">${ _(\"Analytics\") }</a></li>\n

    \u5909\u66f4\u4f8b\u306f\u3001\u30b5\u30f3\u30d7\u30eb project_header.mako \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    "},{"location":"guides/screen-expansion/README.legacy/#\u30a2\u30c9\u30aa\u30f3\u306e\u30c6\u30b9\u30c8","title":"\u30a2\u30c9\u30aa\u30f3\u306e\u30c6\u30b9\u30c8","text":"

    \u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u3001OSF.io\u306b\u8ffd\u52a0\u3057\u305fMy Screen\u30a2\u30c9\u30aa\u30f3\u306e\u30e6\u30cb\u30c3\u30c8\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002

    $ docker compose run --rm web invoke test_module -m addons/myscreen/tests/\n
    "},{"location":"guides/screen-expansion/README.legacy/#ember-osf-web\u3078\u306e\u5b9f\u88c5","title":"ember-osf-web\u3078\u306e\u5b9f\u88c5","text":""},{"location":"guides/screen-expansion/README.legacy/#\u753b\u9762\u30bf\u30d6\u306e\u5b9f\u88c5","title":"\u753b\u9762\u30bf\u30d6\u306e\u5b9f\u88c5","text":"

    \u753b\u9762\u30bf\u30d6\u306e\u5b9f\u88c5\u4f8b(ember-osf-web/app/guid-node/myscreen/) \u3092 app/guid-node/myscreen \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u30b3\u30d4\u30fc\u3057\u307e\u3059\u3002

    "},{"location":"guides/screen-expansion/README.legacy/#myscreen-config-\u30e2\u30c7\u30eb\u306e\u5b9a\u7fa9","title":"myscreen-config \u30e2\u30c7\u30eb\u306e\u5b9a\u7fa9","text":"

    My Screen\u30a2\u30c9\u30aa\u30f3\u306e\u753b\u9762\u30bf\u30d6\u3067\u306f\u3001NodeSettings\u306e param_1 \u30d7\u30ed\u30d1\u30c6\u30a3\u306b\u5bfe\u5fdc\u3059\u308b param1 \u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u6301\u3064\u3001 MyScreenConfig \u30e2\u30c7\u30eb\u3092\u5b9a\u7fa9\u3057\u3066\u6271\u3044\u307e\u3059\u3002MyScreenConfig \u30e2\u30c7\u30eb\u3068\u3001\u30a2\u30c0\u30d7\u30bf\u3001\u30b7\u30ea\u30a2\u30e9\u30a4\u30b6\u3092\u3001\u305d\u308c\u305e\u308c\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30b3\u30d4\u30fc\u3057\u307e\u3059\u3002

    • MyScreenConfig\u30e2\u30c7\u30eb\u306e\u5b9f\u88c5\u4f8b \u3092 app/models/myscreen-config.ts \u306b\u30b3\u30d4\u30fc\u3057\u307e\u3059\u3002
    • MyScreenConfig\u30a2\u30c0\u30d7\u30bf\u306e\u5b9f\u88c5\u4f8b \u3092 app/adapters/myscreen-config.ts \u306b\u30b3\u30d4\u30fc\u3057\u307e\u3059\u3002
    • MyScreenConfig\u30b7\u30ea\u30a2\u30e9\u30a4\u30b6\u306e\u5b9f\u88c5\u4f8b \u3092 app/serializers/myscreen-config.ts \u306b\u30b3\u30d4\u30fc\u3057\u307e\u3059\u3002
    "},{"location":"guides/screen-expansion/README.legacy/#\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u306e\u5b9a\u7fa9","title":"\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u306e\u5b9a\u7fa9","text":"

    \u753b\u9762\u30bf\u30d6\u306b\u95a2\u3059\u308b\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u4f8b\u3068\u3001\u30c6\u30b9\u30c8\u306b\u5229\u7528\u3059\u308bMirage\u306e\u30b3\u30fc\u30c9\u4f8b\u3092\u3001\u305d\u308c\u305e\u308c\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30b3\u30d4\u30fc\u3057\u307e\u3059\u3002

    • \u753b\u9762\u30bf\u30d6\u306e\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u306e\u5358\u4f53\u30c6\u30b9\u30c8\u306e\u30b3\u30fc\u30c9\u4f8b \u3092 tests/acceptance/guid-node/myscreen-test.ts \u306b\u30b3\u30d4\u30fc\u3057\u307e\u3059\u3002
    • \u753b\u9762\u30bf\u30d6\u306e\u53d7\u3051\u5165\u308c\u30c6\u30b9\u30c8\u306e\u30b3\u30fc\u30c9\u4f8b \u3092 tests/unit/guid-node/myscreen/controller-test.ts \u306b\u30b3\u30d4\u30fc\u3057\u307e\u3059\u3002
    • MyScreenConfig\u306eMirage Factory\u30b3\u30fc\u30c9\u4f8b \u3092 mirage/factories/myscreen-config.ts \u306b\u30b3\u30d4\u30fc\u3057\u307e\u3059\u3002
    • MyScreenConfig\u306eMirage Views\u30b3\u30fc\u30c9\u4f8b \u3092 mirage/views/myscreen-config.ts \u306b\u30b3\u30d4\u30fc\u3057\u307e\u3059\u3002
    "},{"location":"guides/screen-expansion/README.legacy/#rdm\u30b3\u30fc\u30c9\u306e\u5909\u66f4_1","title":"RDM\u30b3\u30fc\u30c9\u306e\u5909\u66f4","text":""},{"location":"guides/screen-expansion/README.legacy/#\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306e\u8a2d\u5b9a","title":"\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306e\u8a2d\u5b9a","text":"

    app/router.ts \u306b\u3001\u30a2\u30c9\u30aa\u30f3\u306e\u753b\u9762\u30bf\u30d6\u30da\u30fc\u30b8\u3078\u306e\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u8a2d\u5b9a\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002

    this.route('guid-node', { path: '--node/:guid' }, function() {\n    this.mount('analytics-page', { as: 'analytics' });\n    this.route('forks');\n    this.route('iqbrims');\n    this.route('myscreen');  // \u8ffd\u52a0\n    this.route('registrations');\n    this.route('drafts', { path: '/drafts/:draftId' }, function() {\n        this.route('register');\n    });\n});\n

    \u5909\u66f4\u4f8b\u306f\u3001\u30b5\u30f3\u30d7\u30eb router.ts \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    "},{"location":"guides/screen-expansion/README.legacy/#\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u30d0\u30fc\u5b9a\u7fa9\u306e\u5909\u66f4","title":"\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u30d0\u30fc\u5b9a\u7fa9\u306e\u5909\u66f4","text":"

    ember-osf-web\u304c\u63d0\u4f9b\u3059\u308bView\u304b\u3089\u898b\u3048\u308b\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u30d0\u30fc\u3067\u3001\u753b\u9762\u30bf\u30d6\u306e\u30ea\u30f3\u30af\u3092\u8868\u793a\u3059\u308b\u305f\u3081\u306b\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb lib/osf-components/addon/components/node-navbar/template.hbs \u306b\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002

    {{#if this.myscreenEnabled }}\n    {{node-navbar/link node=@node useLinkTo=false destination='myscreen'}}\n{{/if}}\n

    RDM\u3067My Screen\u30a2\u30c9\u30aa\u30f3\u304c\u6709\u52b9\u3067\u306a\u3044\u3068\u304d\u306f\u30ea\u30f3\u30af\u3092\u8868\u793a\u3057\u306a\u3044\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u306b\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u5b9a\u7fa9\u30d5\u30a1\u30a4\u30eb lib/osf-components/addon/components/node-navbar/component.ts \u306b myscreenEnabled \u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002

    @computed('node.addons.[]')\nget myscreenEnabled(): Promise<boolean> | null {\n    if (!this.node) {\n        return null;\n    }\n    const node = this.node;\n    return (async () => {\n        const addons = await node.addons;\n        if (!addons) {\n            return false;\n        }\n        const myscreen = addons.filter(addon => addon.id === 'myscreen');\n        return myscreen.length > 0;\n    })();\n}\n

    \u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u30d0\u30fc\u306e\u30c6\u30b9\u30c8 tests/integration/components/node-navbar/component-test.ts \u3082\u4fee\u6b63\u3057\u307e\u3059\u3002

    \u305d\u308c\u305e\u308c\u306e\u5909\u66f4\u4f8b\u306f\u3001\u30b5\u30f3\u30d7\u30eb template.hbs \u3001 component.ts \u3001 component-test.ts \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    "},{"location":"guides/screen-expansion/README.legacy/#\u56fd\u969b\u5316\u30d5\u30a1\u30a4\u30eb\u306e\u5909\u66f4_1","title":"\u56fd\u969b\u5316\u30d5\u30a1\u30a4\u30eb\u306e\u5909\u66f4","text":"

    translations/en-us.yml \u306b\u3001My Screen\u30a2\u30c9\u30aa\u30f3\u306e\u753b\u9762\u30bf\u30d6\u3067\u8868\u793a\u3059\u308b\u6587\u5b57\u5217\u306e\u56fd\u969b\u5316\u8a2d\u5b9a\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002

    myscreen:\n  page_title: '{nodeTitle} My Screen'\n  header: 'My Screen'\n  loading: 'Loading My Screen config...'\n  param1: 'Param 1'\n  save_button: 'Save'\n  failed_to_submit: 'Failed to save'\n  placeholders:\n      param1: 'anything'\n

    \u5909\u66f4\u4f8b\u306f\u3001\u30b5\u30f3\u30d7\u30eb en-us.yml \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    "},{"location":"guides/screen-expansion/README.legacy/#mirage\u5b9a\u7fa9\u306e\u5909\u66f4","title":"Mirage\u5b9a\u7fa9\u306e\u5909\u66f4","text":"

    \u8ffd\u52a0\u3057\u305fMirage\u30b3\u30fc\u30c9\u3092\u5229\u7528\u3057\u3066API\u3092\u30e2\u30c3\u30af\u3059\u308b\u3088\u3046\u306b\u3001 mirage/config.ts \u306b\u4ee5\u4e0b\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002

    this.get('/project/:id/myscreen/config', myscreenConfig);\n

    \u5909\u66f4\u4f8b\u306f\u3001\u30b5\u30f3\u30d7\u30eb config.ts \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002

    "},{"location":"guides/screen-expansion/README.legacy/#docker-composeoverrideyml-\u306e\u8ffd\u52a0","title":"docker-compose.override.yml \u306e\u8ffd\u52a0","text":"

    \u5909\u66f4\u3057\u305f\u30b3\u30fc\u30c9\u3092\u4f7f\u3046\u3088\u3046\u306b\u3001RDM\u306e docker-compose.override.yml \u3067 osf-ember-web \u30b5\u30fc\u30d3\u30b9\u306e volumes \u3092\u6307\u5b9a\u3057\u307e\u3059\u3002

    \u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u968e\u5c64\u306e\u5834\u5408\u306f\u3001

    .\n\u251c\u2500\u2500 RDM-osf.io\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 docker-compose.override.yml\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 docker-compose.yml\n\u2514\u2500\u2500 RDM-ember-osf-web\n

    RDM-osf.io/docker-compose.override.yml \u306e\u5185\u5bb9\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u307e\u3059\u3002

    version: \"3.4\"\n\nservices:\n  ember_osf_web:\n    volumes:\n      - ../RDM-ember-osf-web:/code\n
    "},{"location":"guides/screen-expansion/README.legacy/#\u753b\u9762\u30bf\u30d6\u306e\u30c6\u30b9\u30c8","title":"\u753b\u9762\u30bf\u30d6\u306e\u30c6\u30b9\u30c8","text":"

    \u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u3001ember-osf-web\u306b\u8ffd\u52a0\u3057\u305fMy Screen \u753b\u9762\u30bf\u30d6\u306e\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002

    \u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u306e\u5358\u4f53\u30c6\u30b9\u30c8:

    $ docker compose run --rm ember_osf_web yarn test --module 'Unit | Controller | guid-node/myscreen'\n

    \u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u30d0\u30fc\u306e\u7d50\u5408\u30c6\u30b9\u30c8:

    $ docker compose run --rm ember_osf_web yarn test --module 'Integration | Component | node-navbar'\n

    \u753b\u9762\u30bf\u30d6\u306e\u53d7\u3051\u5165\u308c\u30c6\u30b9\u30c8:

    $ docker compose run --rm ember_osf_web yarn test --module 'Acceptance | guid-node/myscreen'\n

    \u30d5\u30a1\u30a4\u30eb\u3092\u6307\u5b9a\u3057\u3066lint\u3092\u5b9f\u884c\u3059\u308b\u306e\u306f\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002

    $ docker compose run --rm ember_osf_web node_modules/.bin/eslint --ext js,ts --max-warnings=0 'app/guid-node/myscreen' 'app/**/myscreen-config.ts' 'app/router.ts' 'lib/osf-components/addon/components/node-navbar/component.ts' 'tests/integration/components/node-navbar/component-test.ts' 'mirage/config.ts'\n$ docker compose run --rm ember_osf_web node_modules/.bin/tslint -p . 'app/guid-node/myscreen/**/*.ts' 'app/**/myscreen-config.ts' 'app/router.ts' 'lib/osf-components/addon/components/node-navbar/component.ts' 'tests/integration/components/node-navbar/component-test.ts' 'mirage/config.ts'\n$ docker compose run --rm ember_osf_web node_modules/.bin/stylelint 'app/guid-node/myscreen/**/*.scss'\n$ docker compose run --rm ember_osf_web node_modules/.bin/ember-template-lint 'app/guid-node/myscreen/**/*.hbs' 'lib/osf-components/addon/components/node-navbar/template.hbs'\n
    "},{"location":"guides/screen-expansion/README.legacy/#my-screen\u30a2\u30c9\u30aa\u30f3\u306e\u52d5\u4f5c\u78ba\u8a8d","title":"My Screen\u30a2\u30c9\u30aa\u30f3\u306e\u52d5\u4f5c\u78ba\u8a8d","text":"

    My Screen\u30a2\u30c9\u30aa\u30f3\u306e\u52d5\u4f5c\u78ba\u8a8d\u3092\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002

    "},{"location":"guides/screen-expansion/README.legacy/#db\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3","title":"DB\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3","text":"

    \u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u884c\u3057\u3001Migrations\u5b9a\u7fa9\u3092PostgreSQL\u30b5\u30fc\u30d3\u30b9\u306b\u53cd\u6620\u3057\u307e\u3059\u3002

    $ docker compose run --rm web python3 manage.py migrate\n
    "},{"location":"guides/screen-expansion/README.legacy/#\u56fd\u969b\u5316\u306e\u30b3\u30f3\u30d1\u30a4\u30eb","title":"\u56fd\u969b\u5316\u306e\u30b3\u30f3\u30d1\u30a4\u30eb","text":"

    .mako \u30d5\u30a1\u30a4\u30eb\u306e\u56fd\u969b\u5316\u8a2d\u5b9a\u3092\u9069\u7528\u3059\u308b\u305f\u3081\u306b\u3001\u56fd\u969b\u5316\u30d5\u30a1\u30a4\u30eb\u3092\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u307e\u3059\u3002

    $ docker compose run --rm web pybabel compile -d ./website/translations\n

    .js \u30d5\u30a1\u30a4\u30eb\u306e\u56fd\u969b\u5316\u8a2d\u5b9a\u306f\u3001 assets \u30b5\u30fc\u30d3\u30b9\u306e\u518d\u8d77\u52d5\u6642\u306b\u9069\u7528\u3055\u308c\u307e\u3059\u3002

    "},{"location":"guides/screen-expansion/README.legacy/#\u30b5\u30fc\u30d3\u30b9\u306e\u518d\u8d77\u52d5","title":"\u30b5\u30fc\u30d3\u30b9\u306e\u518d\u8d77\u52d5","text":"

    \u5909\u66f4\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u306b\u95a2\u9023\u3059\u308b\u30b5\u30fc\u30d3\u30b9\u3092\u518d\u8d77\u52d5\u3057\u307e\u3059\u3002

    $ docker compose restart assets web api ember_osf_web\n

    \u3053\u308c\u3067\u30b5\u30fc\u30d3\u30b9\u3078\u306e\u53cd\u6620\u306f\u5b8c\u4e86\u3067\u3059\u3002

    "},{"location":"guides/screen-expansion/README.legacy/#\u30b9\u30c8\u30ec\u30fc\u30b8\u30a2\u30c9\u30aa\u30f3\u3092\u8a66\u3059","title":"\u30b9\u30c8\u30ec\u30fc\u30b8\u30a2\u30c9\u30aa\u30f3\u3092\u8a66\u3059","text":"

    My Screen\u30a2\u30c9\u30aa\u30f3\u306e\u6709\u52b9\u5316\u624b\u9806\u306f\u3001\u30b9\u30b1\u30eb\u30c8\u30f3 \u30a2\u30c9\u30aa\u30f3\u3068\u540c\u69d8\u3067\u3059\u3002 My Screen\u30a2\u30c9\u30aa\u30f3\u3092\u6709\u52b9\u5316\u3059\u308b\u3068\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u306b\u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u304c\u8868\u793a\u3055\u308c\u3001\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\u30d0\u30fc\u306b\u753b\u9762\u30bf\u30d6\u306e\u30ea\u30f3\u30af\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002

    \u753b\u9762\u30bf\u30d6\u306e\u30ea\u30f3\u30af\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001\u753b\u9762\u30bf\u30d6\u306e\u30da\u30fc\u30b8\u3092\u8868\u793a\u3067\u304d\u307e\u3059\u3002

    \u3053\u3053\u3067\u8a2d\u5b9a\u3057\u305f param_1 \u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u5024\u304c\u3001\u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u306b\u8868\u793a\u3055\u308c\u307e\u3059\u3002

    \u4ee5\u4e0a\u3067My Screen\u30a2\u30c9\u30aa\u30f3\u306e\u52d5\u4f5c\u78ba\u8a8d\u306f\u5b8c\u4e86\u3067\u3059\uff01

    "},{"location":"guides/skeleton/","title":"Skeleton Addon / \u30b9\u30b1\u30eb\u30c8\u30f3\u30a2\u30c9\u30aa\u30f3","text":"

    Summary: Guide to creating your first RDM addon using the skeleton template \u6982\u8981: \u30b9\u30b1\u30eb\u30c8\u30f3\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f7f\u7528\u3057\u3066\u6700\u521d\u306e RDM \u30a2\u30c9\u30aa\u30f3\u3092\u4f5c\u6210\u3059\u308b\u624b\u5f15\u304d

    Jump: English \u00b7 \u65e5\u672c\u8a9e

    • Version / \u7248: 0.1 \u2014 2026-11-05
    • Normative for: docs/guides/skeleton/
    • Related: SPEC-06 Documentation Conventions \u00b7 Environment Guide

    "},{"location":"guides/skeleton/#english","title":"English","text":"

    \u2192 \u65e5\u672c\u8a9e\u7248\u3078

    "},{"location":"guides/skeleton/#overview","title":"Overview","text":"

    This guide shows how to create your first RDM addon using the skeleton template. A skeleton addon is a simple addon with basic features that you can customize to build your own functionality.

    The skeleton addon has the following capabilities:

    • Can be enabled in any project
    • Has a parameter param_1 that can be set differently for each project
    • The param_1 parameter can be configured in the project's addon settings page
    "},{"location":"guides/skeleton/#prerequisites","title":"Prerequisites","text":"
    • A fork of the RDM-osf.io repository
    • The development environment set up following the Environment Guide
    "},{"location":"guides/skeleton/#quick-start","title":"Quick start","text":"
    1. Copy the skeleton code to addons/your-addon-name
    2. Update the addon name in all required files
    3. Modify RDM code to register your addon (addons.json, Dockerfile, etc.)
    4. Run migrations and restart services
    5. Enable your addon in a project and test it
    "},{"location":"guides/skeleton/#legacy-content","title":"Legacy content","text":"

    The legacy skeleton addon instructions are kept verbatim in README.legacy.md for reference and will be rewritten per milestone.

    "},{"location":"guides/skeleton/#\u65e5\u672c\u8a9e","title":"\u65e5\u672c\u8a9e","text":"

    \u2192 To English

    "},{"location":"guides/skeleton/#\u6982\u8981","title":"\u6982\u8981","text":"

    \u3053\u306e\u30ac\u30a4\u30c9\u306f\u3001\u30b9\u30b1\u30eb\u30c8\u30f3\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f7f\u7528\u3057\u3066\u6700\u521d\u306e RDM \u30a2\u30c9\u30aa\u30f3\u3092\u4f5c\u6210\u3059\u308b\u65b9\u6cd5\u3092\u793a\u3057\u307e\u3059\u3002\u30b9\u30b1\u30eb\u30c8\u30f3\u30a2\u30c9\u30aa\u30f3\u306f\u3001\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3057\u3066\u72ec\u81ea\u306e\u6a5f\u80fd\u3092\u69cb\u7bc9\u3067\u304d\u308b\u57fa\u672c\u7684\u306a\u6a5f\u80fd\u3092\u6301\u3064\u30b7\u30f3\u30d7\u30eb\u306a\u30a2\u30c9\u30aa\u30f3\u3067\u3059\u3002

    \u30b9\u30b1\u30eb\u30c8\u30f3\u306e\u6a5f\u80fd\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059:

    • \u4efb\u610f\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u6709\u52b9\u5316\u53ef\u80fd
    • param_1 \u3068\u3044\u3046\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u6301\u3061\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3054\u3068\u306b\u7570\u306a\u308b\u5024\u3092\u8a2d\u5b9a\u53ef\u80fd
    • param_1 \u30d1\u30e9\u30e1\u30fc\u30bf\u306f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30a2\u30c9\u30aa\u30f3\u8a2d\u5b9a\u753b\u9762\u3067\u8a2d\u5b9a\u53ef\u80fd
    "},{"location":"guides/skeleton/#\u524d\u63d0\u6761\u4ef6","title":"\u524d\u63d0\u6761\u4ef6","text":"
    • RDM-osf.io \u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u30d5\u30a9\u30fc\u30af\u3057\u3066\u3044\u308b\u3053\u3068
    • \u74b0\u5883\u30ac\u30a4\u30c9\u306b\u5f93\u3063\u3066\u958b\u767a\u74b0\u5883\u3092\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3057\u3066\u3044\u308b\u3053\u3068
    "},{"location":"guides/skeleton/#\u30af\u30a4\u30c3\u30af\u30b9\u30bf\u30fc\u30c8","title":"\u30af\u30a4\u30c3\u30af\u30b9\u30bf\u30fc\u30c8","text":"
    1. \u30b9\u30b1\u30eb\u30c8\u30f3\u30b3\u30fc\u30c9\u3092 addons/\u30a2\u30c9\u30aa\u30f3\u540d \u306b\u30b3\u30d4\u30fc\u3059\u308b
    2. \u3059\u3079\u3066\u306e\u5fc5\u8981\u306a\u30d5\u30a1\u30a4\u30eb\u3067\u30a2\u30c9\u30aa\u30f3\u540d\u3092\u66f4\u65b0\u3059\u308b
    3. RDM \u306e\u30b3\u30fc\u30c9\u3092\u4fee\u6b63\u3057\u3066\u30a2\u30c9\u30aa\u30f3\u3092\u767b\u9332\u3059\u308b\uff08addons.json, Dockerfile \u306a\u3069\uff09
    4. \u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u884c\u3057\u3066\u30b5\u30fc\u30d3\u30b9\u3092\u518d\u8d77\u52d5\u3059\u308b
    5. \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u30a2\u30c9\u30aa\u30f3\u3092\u6709\u52b9\u5316\u3057\u3066\u30c6\u30b9\u30c8\u3059\u308b
    "},{"location":"guides/skeleton/#\u904e\u53bb\u306e\u30b3\u30f3\u30c6\u30f3\u30c4","title":"\u904e\u53bb\u306e\u30b3\u30f3\u30c6\u30f3\u30c4","text":"

    \u904e\u53bb\u306e\u30b9\u30b1\u30eb\u30c8\u30f3\u30a2\u30c9\u30aa\u30f3\u306e\u624b\u9806\u306f\u3001\u53c2\u8003\u306e\u305f\u3081\u306b README.legacy.md \u306b\u305d\u306e\u307e\u307e\u6b8b\u3057\u3066\u304a\u308a\u3001\u30de\u30a4\u30eb\u30b9\u30c8\u30fc\u30f3\u3054\u3068\u306b\u66f8\u304d\u76f4\u3059\u4e88\u5b9a\u3067\u3059\u3002

    "},{"location":"guides/skeleton/#glossary--\u7528\u8a9e","title":"Glossary / \u7528\u8a9e","text":"Term English note \u65e5\u672c\u8a9e\u6ce8 Addon A small program that adds new features to RDM. RDM \u306b\u65b0\u3057\u3044\u6a5f\u80fd\u3092\u8ffd\u52a0\u3059\u308b\u5c0f\u3055\u306a\u30d7\u30ed\u30b0\u30e9\u30e0\u3002 Skeleton A template or sample code that you can customize to build your own program. \u72ec\u81ea\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u69cb\u7bc9\u3059\u308b\u305f\u3081\u306b\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3067\u304d\u308b\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3084\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3002 Parameter A value that you can change to modify how the addon works. \u30a2\u30c9\u30aa\u30f3\u306e\u52d5\u4f5c\u3092\u5909\u66f4\u3059\u308b\u305f\u3081\u306b\u5909\u66f4\u3067\u304d\u308b\u5024\u3002 Migration A script that updates the database when you change the data structure. \u30c7\u30fc\u30bf\u69cb\u9020\u3092\u5909\u66f4\u3057\u305f\u3068\u304d\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u66f4\u65b0\u3059\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u3002"},{"location":"guides/skeleton/README.legacy/","title":"\u30b9\u30b1\u30eb\u30c8\u30f3\u306e\u4f5c\u6210","text":"

    \u30a2\u30c9\u30aa\u30f3\u958b\u767a\u306e\u7b2c\u4e00\u6b69\u3068\u3057\u3066\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5358\u7d14\u306a\u6a5f\u80fd\u3092\u6301\u3064\u300c\u30b9\u30b1\u30eb\u30c8\u30f3\u300d\u30a2\u30c9\u30aa\u30f3\u3092\u5b9f\u88c5\u3057\u307e\u3059\u3002

    \u30b9\u30b1\u30eb\u30c8\u30f3\u306f\u4ee5\u4e0b\u306e\u6a5f\u80fd\u3092\u6301\u3064\u3082\u306e\u3068\u3057\u307e\u3059\u3002

    • \u4efb\u610f\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u3066\u30b9\u30b1\u30eb\u30c8\u30f3\u3092\u6709\u52b9\u5316\u53ef\u80fd
    • \u30b9\u30b1\u30eb\u30c8\u30f3\u306f param_1 \u3068\u3044\u3046\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u6301\u3061\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3054\u3068\u306b\u7570\u306a\u308b\u5024\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b
    • param_1 \u30d1\u30e9\u30e1\u30fc\u30bf\u306f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30a2\u30c9\u30aa\u30f3\u8a2d\u5b9a\u753b\u9762\u3067\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b
    "},{"location":"guides/skeleton/README.legacy/#\u524d\u63d0\u6761\u4ef6","title":"\u524d\u63d0\u6761\u4ef6","text":"

    \u672c\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306e\u5b9f\u65bd\u306b\u3042\u305f\u308a\u3001\u4ee5\u4e0b\u306e\u524d\u63d0\u6761\u4ef6\u3092\u6e80\u305f\u3057\u3066\u3044\u308b\u3082\u306e\u3068\u3057\u307e\u3059\u3002

    • RDM-osf.io\u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u30d5\u30a9\u30fc\u30af\u3057\u3001\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u306bclone\u3057\u3066\u3044\u308b\u3053\u3068
    • \u7279\u306b\u6307\u5b9a\u304c\u306a\u3044\u9650\u308a\u306fdevelop\u30d6\u30e9\u30f3\u30c1\u304b\u3089\u30a2\u30c9\u30aa\u30f3\u958b\u767a\u7528\u30d6\u30e9\u30f3\u30c1(\u4f8b\u3048\u3070\u3001 feature/myskelton-addon)\u3092\u4f5c\u6210\u3057\u4f5c\u696d\u3059\u308b
    • \u30a2\u30c9\u30aa\u30f3\u958b\u767a\u7528\u30d6\u30e9\u30f3\u30c1\u306b\u306f\u5b9a\u671f\u7684\u306bdevelop\u30d6\u30e9\u30f3\u30c1\u3092pull\u3057\u3066\u5909\u66f4\u3092\u53d6\u308a\u8fbc\u3080
    • clone\u3057\u305f\u30a2\u30c9\u30aa\u30f3\u958b\u767a\u7528\u30d6\u30e9\u30f3\u30c1\u3067\u3001 \u958b\u767a\u74b0\u5883\u306e\u6e96\u5099 \u306e\u30ac\u30a4\u30c9\u306b\u5f93\u3044\u3001\u958b\u767a\u7528RDM\u3092\u8d77\u52d5\u3057\u3066\u3044\u308b\u3053\u3068
    "},{"location":"guides/skeleton/README.legacy/#rdm\u30a2\u30c9\u30aa\u30f3\u306e\u8a2d\u8a08","title":"RDM\u30a2\u30c9\u30aa\u30f3\u306e\u8a2d\u8a08","text":""},{"location":"guides/skeleton/README.legacy/#\u30d5\u30a1\u30a4\u30eb\u306e\u69cb\u6210","title":"\u30d5\u30a1\u30a4\u30eb\u306e\u69cb\u6210","text":"

    RDM\u306b\u304a\u3044\u3066\u30a2\u30c9\u30aa\u30f3\u306fDjango\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u5f62\u5f0f\u3067\u8a18\u8ff0\u3055\u308c\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30d5\u30a1\u30a4\u30eb\u304a\u3088\u3073\u30af\u30e9\u30b9\u304b\u3089\u69cb\u6210\u3055\u308c\u307e\u3059\u3002

    \u5178\u578b\u7684\u306a\u30d5\u30a1\u30a4\u30eb\u914d\u7f6e\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002

    /addons/\u30a2\u30c9\u30aa\u30f3\u540d/\n\u251c\u2500\u2500 __init__.py ... \u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u5b9a\u7fa9\n\u251c\u2500\u2500 apps.py ... \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u5b9a\u7fa9\n\u251c\u2500\u2500 models.py ... \u30e2\u30c7\u30eb\u306e\u5b9a\u7fa9\n\u251c\u2500\u2500 requirements.txt ... \u5229\u7528\u3059\u308bPython\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u5b9a\u7fa9\n\u251c\u2500\u2500 routes.py ... View(Routes)\u306e\u5b9a\u7fa9\n\u251c\u2500\u2500 settings ... \u8a2d\u5b9a\u3092\u5b9a\u7fa9\u3059\u308b\u30e2\u30b8\u30e5\u30fc\u30eb\u3002\u3053\u3053\u306blocal.py\u3092\u914d\u7f6e\u3059\u308b\u3053\u3068\u3067\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3067\u304d\u308b\u3002\n\u2502   \u251c\u2500\u2500 defaults.py ... \u30c7\u30d5\u30a9\u30eb\u30c8\u8a2d\u5b9a\u306e\u5b9a\u7fa9\n\u2502   \u2514\u2500\u2500 __init__.py ... \u8a2d\u5b9a\u306e\u5b9a\u7fa9\n\u251c\u2500\u2500 static ... Web\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u8aad\u307f\u8fbc\u3080\u3053\u3068\u3092\u60f3\u5b9a\u3057\u305f\u9759\u7684\u30d5\u30a1\u30a4\u30eb\n\u2502   \u251c\u2500\u2500 comicon.png ... \u30a2\u30c9\u30aa\u30f3\u306e\u30a2\u30a4\u30b3\u30f3\n\u2502   \u2514\u2500\u2500 node-cfg.js ... Node\u8a2d\u5b9a\u3092\u5b9a\u7fa9\u3059\u308bJavaScript\u30d5\u30a1\u30a4\u30eb\n\u251c\u2500\u2500 templates ... \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\n\u2502   \u2514\u2500\u2500 node_settings.mako ... Node\u8a2d\u5b9a\u30d1\u30cd\u30eb\n\u251c\u2500\u2500 tests ... \u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\n\u2502   \u251c\u2500\u2500 conftest.py\n\u2502   \u251c\u2500\u2500 factories.py\n\u2502   \u251c\u2500\u2500 test_model.py\n\u2502   \u251c\u2500\u2500 test_view.py\n\u2502   \u2514\u2500\u2500 utils.py\n\u2514\u2500\u2500 views.py ... View(Views)\u306e\u5b9a\u7fa9\n
    "},{"location":"guides/skeleton/README.legacy/#\u30a2\u30c9\u30aa\u30f3\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u69cb\u6210","title":"\u30a2\u30c9\u30aa\u30f3\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u69cb\u6210","text":"

    \u30a2\u30c9\u30aa\u30f3\u306fDjango\u306e\u4f5c\u6cd5\u306b\u5f93\u3044\u3001Model-View\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u306b\u3088\u308a\u5b9f\u88c5\u3057\u307e\u3059\u3002\u305d\u308c\u305e\u308c\u306e\u8cac\u52d9\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5206\u62c5\u3055\u308c\u307e\u3059\u3002

    • Model ... \u30e6\u30fc\u30b6\u3068Node(\u30d7\u30ed\u30b8\u30a7\u30af\u30c8)\u305d\u308c\u305e\u308c\u306b\u5bfe\u5fdc\u3057\u305f\u30e2\u30c7\u30eb\u3092\u5b9f\u88c5\u3059\u308b\u3002\u305d\u308c\u305e\u308c\u306e\u30e2\u30c7\u30eb\u306b\u306f\u8a8d\u8a3c\u60c5\u5831\u3084\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u56fa\u6709\u306e\u60c5\u5831\u3092\u683c\u7d0d\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b
    • View ... \u30a2\u30c9\u30aa\u30f3\u306b\u5fdc\u3058\u305f\u8a2d\u5b9a\u3001\u30c7\u30fc\u30bf\u53d6\u5f97\u3001\u4fdd\u5b58\u51e6\u7406\u306a\u3069\u3001HTTP\u4e0a\u306e\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8(\u30d1\u30b9)\u3092\u5b9a\u7fa9\u3059\u308b

    Model\u306f\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306b\u3088\u308a\u81ea\u52d5\u7684\u306b\u305d\u308c\u305e\u308c\u306e\u5229\u7528\u8005\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u5bfe\u5fdc\u3057\u3066\u751f\u6210\u3001\u7ba1\u7406\u3055\u308c\u3001\u6c38\u7d9a\u5316\u3055\u308c\u308b\u306e\u306b\u5bfe\u3057\u3001View\u306f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304c\u30ed\u30fc\u30c9\u3055\u308c\u308b\u969b\u306b\u69cb\u7bc9\u3055\u308c\u307e\u3059\u3002 \u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306b\u3088\u308a\u305d\u308c\u305e\u308c\u306e\u30e9\u30a4\u30d5\u30b5\u30a4\u30af\u30eb\u304c\u9069\u5207\u306b\u7ba1\u7406\u3055\u308c\u308b\u306e\u3067\u3001\u30a2\u30c9\u30aa\u30f3\u958b\u767a\u8005\u306f\u6a5f\u80fd\u9762\u306e\u5b9f\u88c5\u306b\u6ce8\u529b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002

    "},{"location":"guides/skeleton/README.legacy/#model\u306e\u69cb\u6210","title":"Model\u306e\u69cb\u6210","text":"

    Node(\u30d7\u30ed\u30b8\u30a7\u30af\u30c8)\u306b\u95a2\u3059\u308b\u60c5\u5831\u3084\u3001\u30e6\u30fc\u30b6\u3054\u3068\u306e\u60c5\u5831(\u8a8d\u8a3c\u60c5\u5831\u7b49)\u3092\u8a18\u9332\u3001\u7ba1\u7406\u3057\u305f\u3044\u5834\u5408\u3001Model\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002

    UserSettings\u306f\u5229\u7528\u8005\u3054\u3068\u306b\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u751f\u6210\u3055\u308c\u3001\u6c38\u7d9a\u5316\u3055\u308c\u307e\u3059\u3002\u307e\u305f\u3001NodeSettings\u306f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3054\u3068\u306b\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u751f\u6210\u3001\u6c38\u7d9a\u5316\u3055\u308c\u307e\u3059\u3002\u3053\u308c\u3089\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u751f\u6210\u3084\u7834\u68c4\u3092\u30a2\u30c9\u30aa\u30f3\u306e\u30b3\u30fc\u30c9\u304c\u884c\u3046\u3053\u3068\u306f\u539f\u5247\u3068\u3057\u3066\u3042\u308a\u307e\u305b\u3093\u3002

    \u30b9\u30b1\u30eb\u30c8\u30f3\u306e\u5834\u5408\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306bNode\u306b\u95a2\u3059\u308bModel\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002

    • addons.myskelton.NodeSettings

    NodeSettings\u306f\u6c38\u7d9a\u5316\u3059\u3079\u304d\u30d7\u30ed\u30d1\u30c6\u30a3\u3068\u3001\u5404\u7a2esetter\u3068getter\u3092\u5b9a\u7fa9\u3057\u3066\u3044\u307e\u3059\u3002

    "},{"location":"guides/skeleton/README.legacy/#view\u306e\u69cb\u6210","title":"View\u306e\u69cb\u6210","text":"

    View\u306fFlask\u306ePluggable Views\u306e\u3088\u3046\u306b\u3001\u30b5\u30fc\u30d3\u30b9\u4e0a\u306e\u30d1\u30b9\u3068\u51e6\u7406\u306e\u95a2\u4fc2\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002\u5b9a\u7fa9\u306fRoutes\u3068Views\u306e2\u7a2e\u985e\u306e\u8981\u7d20\u304b\u3089\u69cb\u6210\u3055\u308c\u307e\u3059\u3002

    • Routes ... View\u51e6\u7406\u3092\u3069\u306e\u30d1\u30b9\u306b\u30de\u30c3\u30d4\u30f3\u30b0\u3057\u3001\u3069\u306e\u3088\u3046\u306a\u5f62\u5f0f\u3067\u51fa\u529b\u3059\u308b\u304b\u3002\u51fa\u529b\u306b\u306fJSON\u5f62\u5f0f\u3084\u3001HTML\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b
    • Views ... View\u51e6\u7406\u306e\u5185\u5bb9

    Routes\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30d1\u30b9\u3068Method(GET, POST, PUT, DELETE, ...)\u3068\u3001\u305d\u306e\u7d44\u307f\u5408\u308f\u305b\u306b\u5bfe\u3057\u3066\u3069\u306e\u95a2\u6570\u3092\u5b9f\u884c\u3059\u308b\u304b\u3001\u305d\u306e\u5b9f\u884c\u7d50\u679c\u3092\u3069\u306e\u3088\u3046\u306b\u51fa\u529b\u3059\u308b\u304b\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002

    \u5404View\u51e6\u7406\u306b\u306f\u3001\u305d\u306e\u51e6\u7406\u306e\u5b9f\u884c\u306b\u304a\u3051\u308b\u524d\u63d0\u3092Python\u306e\u30c7\u30b3\u30ec\u30fc\u30bf\u306e\u5f62\u3067\u8a18\u8ff0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u6307\u5b9a\u53ef\u80fd\u306a\u30c7\u30b3\u30ec\u30fc\u30bf\u306b\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u3082\u306e\u304c\u3042\u308a\u307e\u3059\u3002