specgate/docs v1.8.0

Domain packs, de principio a fin#

Un recorrido por toda la vida de un pack en un proyecto: instalarlo, ver lo que te dio, actualizarlo a una versión más nueva y volver a quitarlo. Usa el pack de demostración público parking-management-specops, que tiene dos tags, v0.1.0 y v0.2.0. Cada comando de abajo se ejecutó contra ese repositorio con Specgate 1.5.0.

Para saber qué es un pack y cuáles existen, lee Domain packs. Si partes de tu propio plan en lugar de un pack, empieza por Primeros pasos.

Upgrading a domain pack: a three-way merge with your project First, specgate specops diff --pack-version v0.2.0 previews the upgrade: the files sync would add and modify, writing nothing. v0.2.0 requires four variables v0.1.0 did not, so diff and sync both take --var STACK, API_STYLE, TESTING and LANG. Then three versions meet. The merge base is the pack's previous version, v0.1.0, as it was rendered into your project — the baseline specops add recorded under .specops/baseline: REQ-001 to REQ-005, REQ-002's row Draft, and no REQ-006. Yours is the project with your work: REQ-002 Implemented in the matrix, written there by apply, and REQ-020, a requirement of your own. The pack's new version, v0.2.0, leaves REQ-001 to REQ-005 as they were and adds REQ-006, Join Capacity Waitlist: its feature file, its use case and its matrix row. specgate specops sync --pack-version v0.2.0, with the same four variables, merges them three ways. What the new version changes arrives: REQ-006. What you wrote stays: REQ-002 Implemented, and REQ-020. A line both changed is a conflict: the file gets conflict markers, or is left untouched with --abort-on-conflict, and sync stops naming the conflicting files. An id you already use — had your own requirement been REQ-006 — is such a conflict: sync stops naming docs/specs/traceability.md, and keeping both rows makes check fail with Duplicate Requirement ID REQ-006. You give yours a free id, rename it in its spec, tests and features, and run specgate check. specgate specops diff --pack-version v0.2.0 --var STACK=… --var API_STYLE=… --var TESTING=… --var LANG=… first, a preview: the files sync would add (+) and modify (~) — it writes nothing; v0.2.0 needs the four --var THE MERGE BASE YOURS THE PACK'S NEW VERSION v0.1.0, as rendered the baseline specops add recorded .specops/baseline/backend REQ-001 … REQ-005 REQ-002 Draft no REQ-006 yet Your project with your work REQ-002 Implemented in the matrix — apply wrote it REQ-020 a requirement of yours v0.2.0 the version you move to REQ-001 … REQ-005 unchanged + REQ-006 Join Capacity Waitlist its feature, use case and matrix row A three-way merge specgate specops sync --pack-version v0.2.0 --var … Arrives — what v0.2.0 changes: REQ-006 Stays — what you wrote: REQ-002 Implemented, and REQ-020 Conflict — a line both changed: the file gets conflict markers, or is left untouched with --abort-on-conflict; either way sync stops, naming the conflicting files An id you already use Had yours been REQ-006, both matrix rows conflict: sync stops, docs/specs/traceability.md Both kept, check fails: Duplicate Requirement ID REQ-006. Give yours a free id, rename it in its spec, tests and features, then run specgate check id clash
A pack upgrade merges the pack's old version, your project and the pack's new version three ways: the pack's changes arrive, yours stay, and only a line both changed — or an id both use — stops it.

1. Crea el esqueleto de un proyecto para el pack#

Un pack trae sus propios requisitos, así que el proyecto debería empezar sin ninguno. Descríbelo en un archivo de configuración corto y crea el esqueleto con --no-sample-req:

bash
cat > smart-parking.yaml <<'EOF'
PROJECT_NAME: Smart Parking
PROJECT_SLUG: smart-parking
PROJECT_TYPE: backend
DOMAIN: parking operations
STACK: Quarkus 3.x, Java 21, PostgreSQL
API_STYLE: REST with DTO boundaries
TESTING: JUnit 5, Cucumber
EOF

specgate init --config smart-parking.yaml --no-sample-req
cd smart-parking

Note

Añadir un pack a un proyecto que adoptó init. En un repositorio que ya tiene código, init lo adopta y siembra REQ-001 — Existing behaviour is preserved. Un pack cuyos ids empiezan en REQ-001 choca con él, y el gate entonces informa de la baseline de adopción como un feature huérfano. Elige un pack cuyos ids no se solapen —los packs probados usan cada uno su propio rango— o crea el esqueleto como arriba.

2. Instala el pack, fijado a una versión#

bash
specgate specops add \
  --pack-repo https://github.com/rsaglobaltech/parking-management-specops.git \
  --pack-version v0.1.0 \
  --pack backend \
  --var PROJECT_NAME="Smart Parking" \
  --var PROJECT_SLUG=smart-parking \
  --var DOMAIN="parking operations"
text
  ℹ  Resolving remote pack https://github.com/rsaglobaltech/parking-management-specops.git@v0.1.0…
  ℹ  Wrote …/smart-parking/.specops.lock
  ℹ  Recorded baseline for 13 file(s) under .specops/baseline/backend
  ℹ  Generated 5 scenario file(s).
  ℹ  Domain pack expansion completed.

add clona el tag una vez en la caché de packs, escribe los requisitos y escenarios en el proyecto, y registra la fuente, la versión y cada --var en .specops.lock, para que los comandos posteriores los recuerden.

3. Mira lo que te dio#

bash
specgate status
text
  ◆ specgate · status   smart-parking

  Requirements  ░░░░░░░░░░░░░░░░░░░░  0 of 5 done

  To do ──────────────────────────────────────────────────
    ○ REQ-001  Monitor Capacity Threshold  a test and code
    ○ REQ-002  Register Vehicle Entry      a test and code
    ○ REQ-003  Calculate Parking Fee       a test and code
    ○ REQ-004  Detect Overstay             a test and code
    ○ REQ-005  Send Payment Receipt        a test and code

  Packs ──────────────────────────────────────────────────
    backend  @ v0.1.0

specgate check pasa: los requisitos están en Draft, así que aún no deben nada. Desde aquí el bucle diario es el habitual —status, un test que nombra el requisito, apply, check—, descrito en Construye el primer requisito y Demuéstralo.

4. Previsualiza una actualización antes de aplicarla#

v0.2.0 de este pack exige cuatro variables que v0.1.0 no exigía: STACK, API_STYLE, TESTING y LANG. Pásalas una vez con --var; se escriben de vuelta en el lockfile.

bash
specgate specops diff --pack-version v0.2.0 \
  --var STACK="Quarkus 3.x, Java 21" --var API_STYLE="REST with DTO boundaries" \
  --var TESTING="JUnit 5, Cucumber" --var LANG=en
text
── backend @ v0.2.0 (current: v0.1.0) ──
  + features/waitlist/capacity_waitlist.feature
  ~ AI_RULES.md
  ~ docs/specs/commands.md
  ~ docs/specs/domain-model.md
  ~ docs/specs/events.md
  ~ docs/specs/traceability.md
  ~ docs/specs/use-cases.md

  1 added · 6 modified · 7 unchanged

Sin las variables nuevas, diff y sync se detienen con Missing required variable 'STACK'. Provide it using --var STACK=...: el pack declara lo que necesita en variables.required. diff no escribe nada; --json da el mismo informe a un agente, y --as-change convierte la subida en una carpeta de change que puedes revisar como cualquier otra.

5. Aplica la actualización#

bash
specgate specops sync --pack-version v0.2.0 \
  --var STACK="Quarkus 3.x, Java 21" --var API_STYLE="REST with DTO boundaries" \
  --var TESTING="JUnit 5, Cucumber" --var LANG=en
text
  ℹ  Syncing backend @ v0.2.0 (was v0.1.0)

── backend @ v0.2.0 ──
  1 added · 6 unchanged · 6 updated
  ℹ  Sync completed for 1 pack(s) with no conflicts.

sync es un merge a tres bandas contra la baseline que registró add: un archivo que editaste conserva tus cambios, y un conflicto real recibe marcadores (--abort-on-conflict lo deja intacto en su lugar); en ambos casos sync sale con un código distinto de cero y nombra los archivos en conflicto. v0.2.0 añade REQ-006 —su archivo feature, su caso de uso y su fila de la matriz— y deja REQ-001 a REQ-005 como estaban, así que un estado que apply escribió en la fila de REQ-002 se queda. specgate status muestra ahora 0 of 6 done —el nuevo REQ-006 Join Capacity Waitlist— y backend @ v0.2.0.

Un id que ya usas es uno de esos conflictos. Si hubieras añadido un requisito propio como REQ-006 antes de la actualización, ambas versiones escriben una fila REQ-006 en docs/specs/traceability.md: sync informa docs/specs/traceability.md — CONFLICT (markers written) y se detiene. Conservar ambas filas hace que check falle con Duplicate Requirement ID in traceability.md: REQ-006. Da al tuyo un id libre, renómbralo en su spec, sus tests y sus features, y ejecuta specgate check.

6. Quita el pack#

El id es el que registra .specops.lock —aquí backend, no la ruta de --pack-repo—:

bash
specgate specops remove backend --dry-run   # what it would remove
specgate specops remove backend
text
✔  Removed backend from .specops.lock (1 entry).
   Generated files were not deleted. Inspect with `git status` and remove anything unwanted.

remove olvida el pack; no borra los requisitos, escenarios y tests que ahora son del proyecto. Revísalos con git status y borra a mano lo que ya no quieras.

Siguiente#

  • Domain packs — los packs probados, los ejemplos de partida y cómo escribir los tuyos.
  • Cadena de suministro — la caché de packs, el fijado y el trabajo sin conexión.