Skip to content

[Initiative] Git Event Publication and Admission Integration #169

@juliuskrah

Description

@juliuskrah

Summary

Define a complete event taxonomy and publication contract for gitstore-git-service to emit so that the API control plane (admission controller, policy engine, and controller manager) can reconcile catalog state and enforce policies consistently.

This initiative clarifies which Git operations trigger which control-plane workflows and how draft vs. published state transitions are governed.

Scope

In Scope

  • Define canonical Git event types across standard operations (push, branch lifecycle, tag lifecycle, rejection).
  • Define catalog-specific events: resource parsed, validation failed, namespace target detected, admission policy evaluation.
  • Define event payload contract (ref details, commit SHA, actor identity, policy metadata).
  • Define which events are fire-and-forget vs. require acknowledgement/blocking.
  • Define how pre-receive events feed into admission validation vs. post-receive events trigger reconciliation.
  • Define the draft-vs-published lifecycle: when tags or special branches gate state transitions.
  • Document when admission checks run for Git-originated mutations vs. API-originated mutations (should be identical paths).
  • Add integration tests covering event emission, event ordering, and duplicate suppression.

Out of Scope

  • Webhook delivery to external systems (that's event subscription).
  • Real-time metrics/dashboards on event rate.
  • Event retention/archival beyond what Git history provides.
  • Mutating webhook controllers (that's admission controller scope).

Acceptance Criteria

  • Event type taxonomy is documented with clear semantics for each event.
  • Payload schema is defined for each event type (ref, commit, actor, policy metadata).
  • Pre-receive vs. post-receive event flow is documented (blocking vs. asynchronous).
  • Draft-vs-published state transitions are tied to specific events (e.g., tag creation for releases).
  • Admission controller integration is documented: how Git events trigger the same validation as API mutations.
  • Controller manager integration is documented: which events trigger reconciliation start.
  • Integration tests cover all event types, ordering, and duplicate suppression.
  • Runbooks document troubleshooting stale/missing events and replay scenarios.

Implementation Notes

Event Classification

Standard Git Ref Events (always fire post-receive):

  • branch-created: ref moved from 0000000 to commit_sha, refs/heads/*
  • branch-updated: ref moved commit_a → commit_b (fast-forward)
  • branch-force-pushed: ref moved commit_a → commit_b (non-fast-forward, history rewrite)
  • branch-deleted: ref moved commit_sha → 0000000, refs/heads/*
  • tag-created: ref moved 0000000 to object_sha, refs/tags/*
  • tag-updated: ref moved old_object → new_object, refs/tags/*
  • tag-deleted: ref moved object_sha → 0000000, refs/tags/*
  • push-rejected: push failed pre-receive hook (includes failure reason)

Catalog-Specific Events (post-receive, async):

  • catalog-resource-parsed: A .md file was parsed into a resource object (Product/Category/Collection/etc).
  • catalog-resource-validation-failed: A parsed resource failed schema or admission policy validation.
  • catalog-namespace-target: Detected which namespace owns the repository or affected resource.

State Transition Events:

  • release-created: A tag matching the release pattern (e.g., release/* or v*) was created AND admission checks passed.
  • draft-published: A release tag or special marker moved a draft resource into published state (visibility to storefront).

Draft vs. Published Lifecycle

Draft state:

  • Commits on main or draft branch create/update resources that are draft (.status.phase == draft).
  • Draft resources are visible to admins but not storefront.
  • Draft resources reconcile independently (e.g., inventory controller tracks draft inventory separately).

Publishing:

  • Admins (or CI/CD policy) create a release tag (release/v1.0.0) pointing to a commit.
  • Tag creation triggers post-receive hook, which:
    1. Emits tag-created event.
    2. Runs the target commit's resources through admission (same validation as Git push).
    3. If admission passes, emits release-created event.
    4. Controller manager observes release-created → transitions .status.phase to published.
    5. KV layer updates so storefront sees published state.

Admission Control Integration

Git-originated mutations (push) and API-originated mutations (GraphQL) must follow the same admission path:

  • Pre-receive hook: syntax/auth checks only (fast-fail rejections).
  • Post-receive hook (async): parse resources → run admission policies → write .status via API.
  • Admission response: structured errors, policy metadata, resource version for optimistic concurrency.

If admission rejects on post-receive, the commit is persisted but marked in .status.admissionFailure. The operator sees the commit in Git history (audit) but the resource is not visible to controllers/storefront.

Dependencies

Tracking

  • Area: infra
  • Priority: p2 - high
  • Target Milestone / Release: TBD

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions