orchestrata_ultimate.refactor.codemod.observability.events

Reference › orchestrata_ultimate › refactor › codemod › observability › events

The event vocabulary of the codemod engine, on top of the observer pattern in core.patterns.observer. CodemodEventType enumerates the lifecycle events: workspace loaded, index built, pass started and completed, file mutated, review started and completed, finding emitted, commit started, completed and aborted, rollback triggered, and error. A CodemodEvent carries a type, a timestamp, a data dictionary and a correlation id that ties together all events of one operation. The workspace and the transaction layer emit them, report and the five observers consume or reference the types, and the facade re-exports them.

At a glance

Source src/orchestrata_ultimate/refactor/codemod/observability/events.py
Lines of code 54
Classes 2
Functions 0
Imports (internal) orchestrata_ultimate.core.base.traces, orchestrata_ultimate.core.patterns.observer
Imported by orchestrata_ultimate.refactor.codemod, orchestrata_ultimate.refactor.codemod.observability, orchestrata_ultimate.refactor.codemod.observability.debug_panel, orchestrata_ultimate.refactor.codemod.observability.error_detector, orchestrata_ultimate.refactor.codemod.observability.graph_writer, orchestrata_ultimate.refactor.codemod.observability.metrics, orchestrata_ultimate.refactor.codemod.observability.tracing, orchestrata_ultimate.refactor.codemod.report, orchestrata_ultimate.refactor.codemod.txn, orchestrata_ultimate.refactor.codemod.workspace
Tests that import it tests/refactor/codemod/test_observability.py, tests/refactor/codemod/test_observability_wiring.py, tests/refactor/codemod/test_review_engine.py, tests/refactor/codemod/test_review_engine_commit_wiring.py, tests/refactor/codemod/test_transactional_writeback.py

Class diagram

Class diagram orchestrata_ultimate.refactor.codemod.observability.events

Dependency diagram

Dependency diagram orchestrata_ultimate.refactor.codemod.observability.events

API

Classes

CodemodEventType (enum)

Bases: Enum · Decorators: traces(spec='110', story='US-110-005', reqs=['REQ-110-025']) · Line 14

The 13 lifecycle event kinds REQ-110-025 names.

Member Value
WORKSPACE_LOADED 'workspace_loaded'
INDEX_BUILT 'index_built'
PASS_STARTED 'pass_started'
PASS_COMPLETED 'pass_completed'
FILE_MUTATED 'file_mutated'
REVIEW_STARTED 'review_started'
REVIEW_COMPLETED 'review_completed'
FINDING_EMITTED 'finding_emitted'
COMMIT_STARTED 'commit_started'
COMMIT_COMPLETED 'commit_completed'
COMMIT_ABORTED 'commit_aborted'
ROLLBACK_TRIGGERED 'rollback_triggered'
ERROR_DETECTED 'error'
ERROR 'error'

CodemodEvent

Line 37

Codemod event.

Method Signature Summary
__init__ __init__(type: CodemodEventType, timestamp: float, data: dict, correlation_id: str) -> None Wire CodemodEvent's composed collaborators.

Source

Permalink: https://gitlab.com/MSamy/orchestrata-ultimate-architecture/-/blob/a4cbc2bdf/src/orchestrata_ultimate/refactor/codemod/observability/events.py

"""SPEC-110 codemod engine module."""

from __future__ import annotations

from enum import Enum

from orchestrata_ultimate.core.base.traces import traces
from orchestrata_ultimate.core.patterns.observer import Observer

__all__ = ["CodemodEvent", "CodemodEventType", "Observer"]


@traces(spec="110", story="US-110-005", reqs=["REQ-110-025"])
class CodemodEventType(Enum):
    """The 13 lifecycle event kinds REQ-110-025 names.

    ``ERROR`` is kept as an alias of ``ERROR_DETECTED`` (same value) so the
    observers and callers written against the original name keep working.
    """

    WORKSPACE_LOADED = "workspace_loaded"
    INDEX_BUILT = "index_built"
    PASS_STARTED = "pass_started"
    PASS_COMPLETED = "pass_completed"
    FILE_MUTATED = "file_mutated"
    REVIEW_STARTED = "review_started"
    REVIEW_COMPLETED = "review_completed"
    FINDING_EMITTED = "finding_emitted"
    COMMIT_STARTED = "commit_started"
    COMMIT_COMPLETED = "commit_completed"
    COMMIT_ABORTED = "commit_aborted"
    ROLLBACK_TRIGGERED = "rollback_triggered"
    ERROR_DETECTED = "error"
    ERROR = "error"


class CodemodEvent:
    """Codemod event."""

    def __init__(
        self, type: CodemodEventType, timestamp: float, data: dict, correlation_id: str
    ) -> None:
        """Wire CodemodEvent's composed collaborators.

        Args:
            type: Field value for ``type``.
            timestamp: Field value for ``timestamp``.
            data: Field value for ``data``.
            correlation_id: Field value for ``correlation_id``.
        """
        self.type = type
        self.timestamp = timestamp
        self.data = data
        self.correlation_id = correlation_id