author-entity-projection
v4 sub-skill #2. Adds the `entities:` block to the brief and emits a per-domain projection function at `api/server/services/entity_projections/<workflow_type_snake>.py`. Validates entity kinds + relations against the Phase 1 `_NODE_TABLES` / `_REL_TABLES` schema in `api/server/services/entity_graph.py`.
- License 许可
- MIT
- 最近更新
- 2026-09-28
- Stars
- ★ 1
- Forks
- 2
01 前言 Front Matter
- name
- author-entity-projection
- inputs
- [ "brief.domain (from author-domain-skeleton)", "brief.phases", "the live orchestrator file at `api/functions/workflows/<prefix>_<workflow_type_snake>.py` (so ref_field paths can be AST-walked against the emitted payload)" ]
- outputs
- [ "brief.entities", "<sandbox>/api/server/services/entity_projections/<wt_snake>.py" ]
- audience
- design-time-only
- description
- v4 sub-skill #2. Adds the `entities:` block to the brief and emits a per-domain projection function at `api/server/services/entity_projections/<workflow_type_snake>.py`. Validates entity kinds + relations against the Phase 1 `_NODE_TABLES` / `_REL_TABLES` schema in `api/server/services/entity_graph.py`.
- hands_off_to
- author-decision-mapping
- forbidden-runtime
- true
02 资源文件 3
- 脚本__init__.py—
- 脚本codegen.py6.3 KB
- 脚本validator.py7.2 KB
03 SKILL.md 正文
author-entity-projection
This sub-skill is responsible for one thing: declaring which graph
entities and relationships this workflow projects, then emitting a
single Python projection module that Phase 1's
api.server.services.entity_projections.PROJECTIONS registry binds.
Procedure
-
Read the orchestrator at
api/functions/workflows/<prefix>_<workflow_type_snake>.py. Walk its AST to enumerate every dotted path the orchestrator stamps on thepayloadit emits. Use that as the universe of permissibleref_fieldandattributepaths. -
Propose the
entities:block. Each entity declares:kind— must be one of the seven Phase 1 node tables (Person,Organisation,Asset,Money,Decision,Place,Period).Workflowis reflector-managed; do not project it.ref_field— dotted path insidepayload(e.g.payload.vendor.id) holding the entity id.source(optional) — sub-kind label landing on the node'skindattr (e.g.vendor,agency,joiner,campaign).attributes(optional) — map of Kuzu column → dotted payload ref.relations(optional) — list of{kind, target_ref}entries wherekindis one of_REL_TABLESandtarget_refis another entity'sref_field.
-
Validate. Run
validator.py:validate(brief, orchestrator_path). OnSchemaError(unknown kind / unresolved ref / bad rel), STOP and print the structured failure. -
Render the projection. Call
codegen.render_projection(brief). Write(filename, body)into the sandbox attools/scratch/compose-domain/<run-id>/api/server/services/entity_projections/<filename>. -
Hand off to
author-decision-mapping.
Output shape (one Python module per domain)
The codegen emits a module that mirrors the twelve hand-written Phase 1 projection modules:
"""Projection: <workflow-type> (compose-domain v4 codegen)."""
from __future__ import annotations
import json
from api.server.services.entity_projections import (
DecisionWrite, EntityWrite, RelWrite, build_decision, slug,
)
from api.shared.types import Workflow
WORKFLOW_TYPE = "<workflow-type>"
def project(workflow: Workflow) -> list[EntityWrite | RelWrite | DecisionWrite]:
p = workflow.payload or {}
sw = (workflow.id,)
ops: list[EntityWrite | RelWrite | DecisionWrite] = []
# --- Entity 0 ---
<kind>_id = f"<PREFIX>-<source>-{slug(str(<ref_field>))}"
ops.append(EntityWrite(
kind="<Kind>", id=<kind>_id,
attrs={"kind": "<source>", ...},
source_workflows=sw,
))
# ...
return ops
build_decision(...) is appended downstream by
author-decision-mapping — this codegen produces only EntityWrite
RelWrite.
Constraints
- The function MUST be named
project(Phase 1 PAT-005). The module MUST exposeWORKFLOW_TYPE = "<workflow-type>"so the registry can bind it. - Imports MUST be limited to the allow-list above; the validator enforces this on the rendered output.
- ID prefix convention (matches Phase 1):
Person → PERSON-,Organisation → ORG-,Asset → ASSET-,Money → MONEY-,Decision → DEC-,Place → PLACE-,Period → PERIOD-.
Failure handling
Validation failure aborts the pipeline. Re-author the brief.
04 同仓库更多 Skills
proactive-customer-care
Proactively notifies and, where warranted, extends a small bounded goodwill gesture to a customer whose itinerary materially changed.
payment-exception
Resolves a failed balance payment by retrying it to complete the booking, or releasing the booking's inventory when retry is not viable.
hotel-supplier-recovery
Restores accommodation for a shortfall-hit hotel allotment by moving contracted rooms from a donor allotment with headroom, resolving the reported supplier shortfall.
holiday-sales-booking
暂无简介
flight-disruption-recovery
暂无简介
destination-operations
Dispatches a replacement resort transfer when an arrival is at risk, rebinding any travellers on the at-risk transfer to the replacement.