7.7 KiB
05 — Domain and data model
Domain boundaries
Identity and workspace
Owns users, workspaces, memberships and authorization. The MVP may expose one personal workspace per user while retaining workspace IDs in the model for future team support.
Playbook registry
Owns playbook identity, immutable versions, lifecycle, source, compatibility, content digest and publication state.
Repository intelligence
Owns repository identities, manual profiles, source observations, profile snapshots, commands, protected paths and health findings.
Composition
Owns drafts, normalized inputs, resolved policies, prompt blocks, lint findings, rendered output and generated runs.
Artifacts
Owns exported Markdown, Run Packs, manifests, digests, retention and download authorization.
Integrations
Owns forge connections, encrypted credentials, capability snapshots, synchronization jobs and health.
Quality
Owns lint rules, evaluation cases, fixture references, evaluation results and quality status.
Audit and operations
Owns audit events, job state, operational metrics and retention.
Conceptual relationships
erDiagram
USER ||--o{ WORKSPACE_MEMBERSHIP : has
WORKSPACE ||--o{ WORKSPACE_MEMBERSHIP : contains
WORKSPACE ||--o{ REPOSITORY : owns
WORKSPACE ||--o{ COMPOSITION_DRAFT : owns
WORKSPACE ||--o{ GENERATED_RUN : owns
WORKSPACE ||--o{ INTEGRATION : owns
PLAYBOOK ||--o{ PLAYBOOK_VERSION : versions
PLAYBOOK_VERSION ||--o{ PLAYBOOK_EVALUATION : evaluated_by
PLAYBOOK_VERSION ||--o{ COMPOSITION_DRAFT : selected_by
PLAYBOOK_VERSION ||--o{ GENERATED_RUN : frozen_in
REPOSITORY ||--o{ REPOSITORY_PROFILE_REVISION : profile_versions
REPOSITORY ||--o{ REPOSITORY_SNAPSHOT : observed_as
REPOSITORY_SNAPSHOT ||--o{ REPOSITORY_FINDING : produces
REPOSITORY_PROFILE_REVISION ||--o{ COMPOSITION_DRAFT : used_by
REPOSITORY_PROFILE_REVISION ||--o{ GENERATED_RUN : frozen_in
COMPOSITION_DRAFT ||--o{ DRAFT_INPUT : contains
COMPOSITION_DRAFT ||--o{ PROMPT_LINT_FINDING : reports
GENERATED_RUN ||--o{ GENERATED_ARTIFACT : exports
GENERATED_RUN ||--o{ RUN_FEEDBACK : receives
INTEGRATION ||--o{ INTEGRATION_SECRET : references
INTEGRATION ||--o{ SYNC_JOB : runs
Core records
The complete relational contract and deletion behavior are defined in docs/27-database-reference.md and database/reference-schema.sql. The records below summarize the domain-facing fields.
user
id- normalized unique email
- display name
- password hash managed by the authentication implementation
- instance role and account status
- password/session timestamps
workspace and workspace_membership
- workspace identity, type and lifecycle timestamps
- membership user, role and creation timestamp
- every private resource is authorized through workspace membership
auth_session, invitation and password_reset_token
Revocable session and single-use token records store hashes, never bearer values. Expiry, use and revocation are explicit.
playbook
Mutable identity record.
idUUIDslugglobally unique stable slugnamespacesuch asbuiltin,private.<workspace>or future registry namespacesource_typebuilt_in, private, imported, remote_registrycreated_at,updated_at
playbook_version
Immutable published content or mutable draft revision.
idUUIDplaybook_idsemantic_versionstatusdraft, reviewed, validated, battle_tested, deprecatedpackage_api_versiontitle,summary,categoryrisk_tierpackage_jsonnormalized canonical documenttemplate_textcontent_digestpublished_atsupersedes_version_idcreated_by
Unique: (playbook_id, semantic_version) and content_digest within source namespace as appropriate.
Published rows are immutable at the application layer and protected by tests. A correction creates a new version.
repository
idworkspace_iddisplay_namesource_typemanual, giteaexternal_owner,external_name,external_idintegration_idnullabledefault_brancharchived- timestamps
repository_profile_revision
An immutable normalized profile used for composition.
idrepository_idrevision_numberprofile_jsonsource_snapshot_idnullablecontent_digestcreated_bycreated_at
repository_snapshot
Evidence captured from an integration.
idrepository_idintegration_idcaptured_atcapability_snapshot_jsonevidence_jsonevidence_digestsync_job_id
repository_finding
idsnapshot_idrule_idseverityinfo, low, medium, hightitlerationaleevidence_pointerrecommended_playbook_slugstatusopen, dismissed, resolved
composition_draft
Mutable user workspace.
idworkspace_idplaybook_version_idrepository_profile_revision_idnullableinput_jsonautonomy_levelwork_modelast_render_digestupdated_atcreated_by
generated_run
Immutable generation record. “Run” does not imply that Codex executed it.
idworkspace_idsource_draft_idnullableplaybook_version_idplaybook_snapshot_jsonrepository_profile_snapshot_jsonnullablenormalized_input_jsonpolicy_snapshot_jsonrendered_promptrender_digestlint_result_jsongenerated_atgenerated_by
generated_artifact
idrun_idartifact_typeprompt_text, markdown, run_pack_zip, agents_suggestionstorage_keyfilenamesize_bytessha256expires_atnullablecreated_at
integration
idworkspace_idtypegiteadisplay_namebase_urlstatusconfigured, healthy, degraded, disabledcapabilities_jsonlast_checked_at- timestamps
integration_secret
The database stores encrypted material and metadata, never a retrievable plaintext response.
idintegration_idsecret_kindencrypted_valuekey_versionlast_fouroptional safe identifiercreated_at,rotated_at
playbook_evaluation
idplaybook_version_idcase_idfixture_versionenvironment_jsonresult_statusdimension_scores_jsonevidence_artifact_keyexecuted_atexecuted_by
Additional operational records
The reference schema also defines:
- favorites, collections and collection items;
- invitations, password resets and sessions;
- run feedback;
- evaluation cases and immutable results;
- PostgreSQL-backed jobs with leases and retries;
- append-only audit events;
- singleton instance setup/configuration state.
The application may store draft lint findings inside draft JSON, but final lint results and provenance are frozen in generated_run. Do not create a second contradictory source of truth.
Indexing strategy
- GIN full-text index over playbook title, summary, category, tags and intent fields;
- B-tree indexes on workspace ownership, lifecycle, category, risk and update timestamps;
- unique digest indexes for immutable package and run content;
- trigram index for tolerant title/tag matching if extension support is available;
- partial indexes for active playbook versions and pending jobs.
Retention
- playbook versions: retained indefinitely unless legally required otherwise;
- generated runs: operator-configurable, default indefinite for personal self-hosting;
- generated binary artifacts: default 90 days while immutable run text remains;
- integration snapshots: default latest 20 per repository plus referenced snapshots;
- audit events: default 180 days;
- operational logs: default 14–30 days.
Deleting a repository may anonymize or detach historical runs rather than destroying their frozen profile snapshot, depending on user selection and legal requirements.