Skip to content

TASK-033: support deterministic CEG outcome replay - #179

Merged
cryptoxdog merged 2 commits into
mainfrom
l9/w8/task-033
Aug 2, 2026
Merged

TASK-033: support deterministic CEG outcome replay#179
cryptoxdog merged 2 commits into
mainfrom
l9/w8/task-033

Conversation

@cryptoxdog

Copy link
Copy Markdown
Collaborator

Generated under L9 controlled autonomy.

Task: TASK-033
Program: sha256:9cd1a79f948dac419913c134396e58359e4df82862bb3901bdd327684a37cb52
Contract: sha256:f4d768907ad10db24c9398dd6eceaa073896eaf96210c24bdc6853458df78cfc
Verification: sha256:6539f1c0469c852d11c4ff83a5d978840660bb008d93adbdca2f72a363cc990e

This PR is draft only. The controller cannot mark ready, approve, merge, tag, release, or deploy.

Copilot AI review requested due to automatic review settings August 2, 2026 20:53
@cryptoxdog
cryptoxdog marked this pull request as ready for review August 2, 2026 20:53
@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown

L9 Audit Harness Report

  • Generated: 2026-08-02T20:56:11.038019+00:00
  • Repo root: /home/runner/work/Cognitive.Engine.Graphs/Cognitive.Engine.Graphs
  • Overall result: ✅ PASSED
  • Exit code: 0

Step Results

Step Status Exit Code Notes
Architecture Audit ✅ Passed 0
Spec Coverage ✅ Passed 0
Contract Wiring ✅ Passed 0

Architecture Audit Findings

Severity Count
🔴 CRITICAL 0
🟠 HIGH 0
🟡 MEDIUM 25
🔵 LOW 0

See artifacts/audit_report.md for full details.

Spec Coverage

  • ✅ Implemented: 37
  • ⚠️ Partial: 9
  • ❌ Missing: 0
  • Total features: 46
Category Implemented Partial Missing Total
gates 10 0 0 10
scoring 7 0 0 7
v1.1_node 2 0 0 2
v1.1_edge 2 0 0 2
v1.1_action 0 2 0 2
v1.1_scoring 1 1 0 2
action_handler 0 6 0 6
gds_algorithm 5 0 0 5
research_pattern 10 0 0 10

See artifacts/coverage_report.md for full details.

Next Steps

All checks passed. Safe to merge.

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown

⚠️ Large PR Warning
Reviewable lines changed: 332
Warning threshold: 300 lines
Consider splitting for easier review

📋 Best Practices for Large Changes

  1. Refactoring + Features: Separate into 2 PRs
  2. Multiple Features: One PR per feature
  3. Database + Code: Separate migration from logic
  4. Generated Code: Exclude it from reviewable-size accounting

This PR passes the blocking limit but is larger than recommended.

@sonarqubecloud

sonarqubecloud Bot commented Aug 2, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Not ready to approve

Input normalization currently has a determinism edge case and the new unit test file likely fails formatting/lint checks due to overlong lines.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

Adds an offline, deterministic “outcome replay” facility to the CEG engine so Odoo-exported fixtures can be reprocessed into stable per-event and aggregate hashes without invoking Gate/Neo4j/network paths.

Changes:

  • Introduces engine.replay pure functions to validate Odoo replay inputs and deterministically compute outcome_hash / outcome_set_hash.
  • Adds a CLI tool (tools/outcome_replay.py) to run the replay and emit a JSON artifact.
  • Adds unit tests plus an ADR and runbook documenting the workflow and guarantees.
File summaries
File Description
tools/outcome_replay.py New CLI wrapper for running offline replay and writing deterministic JSON output.
engine/replay/outcome.py Core deterministic normalization + hashing logic for replay inputs/outputs.
engine/replay/init.py Exposes replay API surface (replay_outcomes, schemas, error type).
tests/unit/test_outcome_replay.py Unit tests for determinism, schema rejection, and CLI behavior.
docs/runbooks/CEG_OUTCOME_REPLAY.md Operator runbook for executing replay and expected guarantees.
docs/adr/ADR-111-ceg-outcome-replay.md ADR capturing schema constraints and offline-only design decision.
Review details

Suppressed comments (1)

tests/unit/test_outcome_replay.py:79

  • This spec_from_file_location call is very long and is likely to fail formatting checks; wrap it across lines for consistency with other tests (e.g. test_payload_contract_compiler.py).
    spec = importlib.util.spec_from_file_location("ceg_outcome_replay_cli", ROOT / "tools" / "outcome_replay.py")
  • Files reviewed: 8/8 changed files
  • Comments generated: 3
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Comment on lines +58 to +60
doc = _fixture()
doc["events"] = list(reversed(doc["events"]))
assert replay_outcomes(doc)["outcome_set_hash"] == replay_outcomes(_fixture())["outcome_set_hash"]
Comment thread engine/replay/outcome.py
if isinstance(raw.get("payload"), dict):
event["payload"] = raw["payload"]
normalized.append(event)
normalized.sort(key=lambda e: (e["packet_id"], e["action"], e["tenant"]))
Comment thread engine/replay/outcome.py
Comment on lines +32 to +36
if document.get("gate_mutation") is True:
raise ReplayError("gate_mutation=true is forbidden in replay mode")
events = document.get("events")
if not isinstance(events, list):
raise ReplayError("events must be a list")
Copilot AI review requested due to automatic review settings August 2, 2026 20:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Not ready to approve

Determinism and repo metadata conventions have gaps (notably outcome ordering under duplicate event keys and missing L9_META in new entrypoints) that should be fixed before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details

Suppressed comments (5)

tools/outcome_replay.py:16

  • sys.path.insert(0, ...) runs at import time, which means importing this module in unit tests mutates global interpreter state and can affect import resolution order. Prefer making the insertion idempotent (at minimum) so repeated imports don’t keep reordering sys.path.
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT))

engine/replay/outcome.py:103

  • Event order independence is not fully guaranteed when there are multiple events with the same (packet_id, action, tenant) (the current normalization sort key), because stable sorting will preserve input order among ties and the returned outcomes list is hashed as-is. Sorting the computed outcomes by a tie-free key (including outcome_hash) makes outcome_set_hash invariant to input ordering even under duplicates.
                "packet_id": event["packet_id"],
                "tenant": event["tenant"],
            }
        )
    result: dict[str, Any] = {
        "event_count": len(outcomes),

tests/unit/test_outcome_replay.py:60

  • This assertion line is very long and is likely to be reformatted (or rejected) by the repo’s Ruff formatting/line-length conventions, which can cause avoidable CI churn. Splitting it improves readability and keeps formatting stable.
    assert replay_outcomes(doc)["outcome_set_hash"] == replay_outcomes(_fixture())["outcome_set_hash"]

engine/replay/init.py:1

  • engine/ subpackage __init__.py files typically include an L9_META header (e.g., engine/intake/__init__.py:1 and engine/gates/__init__.py:1). This new engine/replay/__init__.py is missing it, which can break contract/metadata tooling expectations.
"""Deterministic CEG outcome replay from Odoo/fixture inputs (TASK-033)."""

tools/outcome_replay.py:5

  • Most tools/*.py entrypoints include an L9_META header (for example tools/payload_contract_compiler.py:2 and tools/contract_scanner.py:2). This new CLI tool doesn’t include it, which can cause it to be missed by metadata/contract scanners.

This issue also appears on line 14 of the same file.

"""CLI: deterministic CEG outcome replay from Odoo fixtures (TASK-033).

No Gate / Neo4j / network calls.
"""
  • Files reviewed: 8/8 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@cryptoxdog
cryptoxdog merged commit 7827d98 into main Aug 2, 2026
53 of 54 checks passed
@cryptoxdog
cryptoxdog deleted the l9/w8/task-033 branch August 2, 2026 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants