Documentation is available in Japanese and English; some sections are in Japanese only.

docs/storage-and-state-model.md · c995b6b5673e2220501daa3f0997d0876277be82
Original reading view · Source commit and manifest

Storage And State Model / 保存先と状態モデル

English companion: This document explains where state is stored across the existing-DB-to-output journey. It separates durable metadata, disposable runtime output, shared artifacts, and resume checkpoints so operators know what persists and what can be thrown away.

この文書は、existing DB -> canonical metadata -> output の journey で、何がどこに保存されるかを 1 枚で説明するための恒久文書です。
「既存 DB をつないだら何が永続化されるのか」「どこが disposable なのか」「どこが share lane なのか」を current rule で固定します。

導線の正本は existing-db-to-output.md (Mtool原本: existing-db-to-output.md) を参照してください。

1 枚で見る flow

existing DB / lab_db
  -> import preview / apply
  -> config_db canonical metadata
  -> sync_project_data_classes.php
  -> sync_project_db_access.php
  -> create_project_output.php --publish
  -> work/artifacts/... + work/source-outputs/...
  -> lab viewer / admin artifact download

state map

place主な役割何が入るか誰が書くかdurable reading
config_dbcanonical storeproject, dbtable*, dataclass*, project_db_access_*, project_source_outputs, database_sourcesadmin UI、import apply、sync CLI、bundle importcurrent source of truth
existing DBimport source / runtime source既存 schema と dataDB owner、自分の migration、運用 jobcanonical store ではない
db-lablocal rehearsal sourceeditable schema / sample datalab-db-ui、lab 側の手操作canonical store ではない
work/artifacts/source-outputs/{project_key}/{artifact_key}/bundle/...artifact history生成済み source output bundlecreate_project_output.phpregenerate できる artifact
work/source-outputs/{project_key}/{source_output_key}current raw output最新 publish の materialized outputcreate_project_output.php --publish次回 publish で上書きされる
bundle dir (/tmp/...)transport packageexport 済み metadata bundleexport_project_metadata.php配布用。live store ではない
database-source-secrets*.jsonsecret sidecardatabase source password または password_envoperatorcommit しない
mtool/reference/legacy-*curated legacy reference旧生成 DB class、旧 build ロジック、旧テンプレートの参照人の調査作業だけruntime input ではない

よくある質問

既存 DB に接続したら、その DB 自体に書き込みますか

current mainline では、import_project_tables.php、sync_project_data_classes.php、sync_project_db_access.php、create_project_output.php --publish は canonical metadata と output artifact を更新します。
既存 DB を直接 canonical store に置き換えたり、schema/data をそのまま書き換えたりする前提ではありません。

例外は、自分で lab-db-ui や DB client から既存 DB / db-lab を編集した時だけです。
その変更を canonical metadata へ反映するには、改めて import preview / apply を流します。

設計はどこに永続化されますか

config_db です。

つまり、既存 DB から取り込んだあとに設計として残る正本は config_db 側です。

output はどこに出ますか

create_project_output.php はまず artifact bundle を work/artifacts/source-outputs/{project_key}/{artifact_key}/bundle/... に作ります。
--publish を付けた時だけ、current raw output として work/source-outputs/{project_key}/{source_output_key} も更新します。

この current raw output は便利な materialization ですが、永続正本ではありません。
次の publish で置き換わるので、再現可能な正本は config_db と artifact history だと考えます。

Swagger viewer / published proxy はどの DB を読みますか

runtime DB source は db_source_key で選びます。

つまり、existing DB を runtime read にも使いたいなら、named source 登録時に supports_proxy_runtime_read=1 が必要です。

OpenAPI は public file として配られますか

いいえ。current supported share lane は次だけです。

spec_visibility=internal-only が default で、disabled なら viewer からも隠れます。
raw openapi.json を public static file として配る前提にはしません。

durable / disposable の読み方

durable と読むもの:

disposable と読むもの:

補足:

resume / handoff でどこを見るか

resume 時は、existing DB や db-lab の中身そのものより、まず config_db と artifact / bundle 側に残った state を確認します。
existing DB、db-lab、work/source-outputs/... は便利でも canonical store ではありません。

secrets の current rule

current boundary

関連文書