コンテンツにスキップ

code コレクション

概要

Des2Code が使う canonical current source-code projection です。code-import は backend code record ごとに strict document 1 件を replace します。rendered Storybook state、resolved dependency、project readiness はそれぞれ code_variation, code_graph, code_index に分離します。

テーブル定義

論理名 物理名 カラム名 データ型 主キー リレーション ユニーク NULL許容 デフォルト値 備考
コード情報 code _id string ◯ stable backend code UUID
organization_id number tenant owner、positive integer
project_id number project:id project scope、positive integer
name string component/page name
type number 0: page
1: component
based_on number 0: imported
1: design
2: wireframe
source_code string current source。matched code detail で返却
css_code string ◯ present の場合 current CSS
visual.metadata.name string display name
visual.metadata.image_url string ◯ optional preview URL。code visual vector は保存しない
semantics.metadata.words string[] non-empty semantic vocabulary
semantics.vector_embedding float[512] Des2Code semantic vector
context.metadata.component_level string page/atom/molecule/organism などの parsed level
context.metadata.family string parsed implementation family
context.metadata.variant string ◯ parsed source-level variant
context.metadata.imports object[] [] {source, specifiers, default_import, namespace_import}
context.metadata.exports string[] [] exported symbol
context.metadata.referenced_components string[] [] resolved source reference name
context.metadata.class_names string[] [] parsed CSS/class name
context.metadata.source_tokens string[] [] normalized source token
context.metadata.text string retrieval 用 deterministic source-context text
context.vector_embedding float[512] Des2Code source-context vector
processing.hash string 64-character SHA-256 idempotency fingerprint

リレーション

  • project_id → PostgreSQL project.id(logical。application scope check で enforcement)
  • code_variation.code_id → 同一 organization/project の code._id
  • code_graph.source_code_id / target_code_id → 同一 scope の code._id
  • code_index.profile.components[].code_id → 同一 scope の code._id
  • DocumentDB は foreign key を enforcement しないため import/index worker が validate する。

インデックス

  • PRIMARY KEY (_id)
  • INDEX code_scope_catalog (organization_id, project_id, type, name)
  • VECTOR INDEX codeSemanticVectorIndex (semantics.vector_embedding)
  • VECTOR INDEX codeContextVectorIndex (context.vector_embedding)

Atlas vector index は organization_id / project_id を filter path に含めます。 DocumentDB は exact vector search 前に scoped $match を使います。

ベクトルインデックスオプション

  • dimensions: 512
  • similarity: cosine
  • m: 16
  • efConstruction: 64

種別コード

  • 0: Page
  • 1: Component

由来コード (based_on)

  • 0: Imported
  • 1: Design
  • 2: Wireframe

注記

  • code-import が code replace を所有し、undeclared legacy field は reject する。
  • index_schema_version、top-level code_context、visual embedding、variation inventory、model/encoder metadata、profile pin、history field は存在しない。
  • effective code write は scoped code_index を stale にする。
  • code_variation は successfully rendered Storybook state 1 件を _id, scope, variation_id, code_id, name, image metadata/description, visual.vector_embedding, processing.hash で保存する。unique index は (organization_id, project_id, variation_id)。scoped code_id index と variationVisualVectorIndex も持つ。
  • code_graph は current resolved edge を _id, scope, source_code_id, source_name, nullable target_code_id, target_name, relation=references で保存する。scoped source/target index を持つ。
  • code_index は organization/project ごとに stable current document 1 件を持つ。 field は status (ready/stale)、context.terms、 profile.components[{code_id, variation_mode}]、nullable processing.rebuild{token, expires_at}。unique scope index が singleton を enforcement し、_id は scope-derived で content version ではない。
  • explicit code-index worker は current code/variation input 全体を validate 後、 code_graph と ready code_index を transaction 内で publish する。