crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

Example proposal: optional causal audit for agent action traces

Open safal207 opened this issue 5 months ago • 30 comments

Hi CrewAI maintainers,

I’m exploring a small optional integration idea around agent workflow auditability.

I maintain causal-memory-layer, a small Python package for checking causal validity in structured action traces:

  • PyPI: https://pypi.org/project/causal-memory-layer/
  • GitHub: https://github.com/safal207/Causal-Memory-Layer
  • Install: pip install causal-memory-layer
  • Release: https://github.com/safal207/Causal-Memory-Layer/releases/tag/v0.4.0

The narrow use case is not policy enforcement, production safety certification, or compliance. It is a lightweight audit primitive:

Given a sequence of agent/tool actions, can we detect actions that succeeded operationally but lack a valid parent cause, approval, or responsibility lineage?

Example failure mode:

  1. A crew/task/tool action is recorded as completed.
  2. The action references a parent cause, approval id, or upstream responsibility claim.
  3. That referenced parent cause is missing or malformed.
  4. CML reports broken causal lineage.

This is different from observability/tracing: tracing can show what happened, while CML checks whether the action had a valid causal permission/responsibility path.

Would you be open to a small docs/example PR showing how to convert a simple CrewAI-style workflow trace into CML records and run a causal audit over it?

I would keep it:

  • optional,
  • dependency-light,
  • outside CrewAI core,
  • framed as an example only,
  • with explicit non-claims.

If this is better suited for Discussions rather than Issues, I’m happy to move it there.

Note: this issue was drafted with AI assistance, so it should be labeled llm-generated according to the CrewAI contribution guidelines.

safal207 avatar Jun 07 '26 19:06 safal207

This is a useful primitive and the scope is right — lightweight causal audit, not policy enforcement. I want to sketch how this maps to session-scoped episodic memory, because the data model for causal audit and agent memory are structurally the same, and building on that connection makes the audit layer cheaper to implement and richer in what it captures.

Each agent action naturally produces an episodic memory record: (action, input, output, parent_action_id, timestamp, importance). The parent_action_id field is the causal link — it points to the action that triggered this one. Within a single session, this creates a linear causal chain. Your CML package checks exactly this: does the referenced parent cause exist and is it well-formed? The memory-based framing adds two things. First, importance scoring — not all actions in the chain are equally significant for audit purposes, and decay-weighted importance lets you surface the high-value causal paths without drowning in noise from routine operations. Second, cross-session causality. Within a session, parent_action_id gives you a linear trace. But agents often act based on memories recalled from previous sessions. The causal link in that case is not a parent action but a memory association — the agent recalled memory X from session 3 while executing in session 7, and that recall informed its decision. Storing the association (current_action_id, recalled_memory_id, recall_score) alongside the causal chain gives you a graph rather than a tree, and that graph is what you need for multi-session audit.

The broken-lineage detection your package focuses on — an action that references a missing or malformed parent — maps to a specific failure mode in memory systems: orphaned episodic memories. These are records that claim to be caused by something that either never existed or was deleted during consolidation. A periodic sweep that checks referential integrity on parent_action_id and memory associations catches this class of problem and produces a clean audit signal. The key is that consolidation (summarizing, deduplicating, clustering old memories) must preserve the causal links even when it compresses the content. If you summarize ten episodic memories into one cluster summary, the summary must carry all ten parent_action_ids so the audit chain remains intact.

For the CrewAI integration specifically: the natural hook point is wherever task outputs are persisted. Each task completion writes an episodic memory with the parent set to the task that triggered it (or the crew kickoff for root tasks). That gives you causal traceability through the crew's task graph without any changes to the task execution logic itself.

ferhimedamine avatar Jun 11 '26 21:06 ferhimedamine

Thanks a lot — this framing makes a lot of sense.

I agree that the audit layer and session-scoped episodic memory share the same underlying structure. The distinction between parent_action_id for intra-session causality and recalled memory associations for cross-session causality is especially useful.

For the initial MVP, I’d probably keep the scope intentionally narrow:

  1. Capture action-level causal links through parent_action_id
  2. Detect missing or malformed parent references
  3. Report broken lineage as a lightweight audit signal
  4. Avoid policy enforcement or runtime blocking

Then a second layer could extend this into memory-aware audit by adding:

  • importance scoring
  • recalled memory associations
  • cross-session causal graphs
  • preservation of causal links during memory consolidation

I also like your suggested CrewAI hook point: persisting the causal record when task outputs are saved, without changing task execution logic itself. That keeps the integration low-risk and optional.

So maybe the first step is to define a minimal causal trace schema for CrewAI tasks, then later expand it into memory-based audit if the primitive proves useful.

safal207 avatar Jun 12 '26 13:06 safal207

I prepared a minimal standalone CML example for the CrewAI-style trace-audit idea here:

  • Example script: https://github.com/safal207/Causal-Memory-Layer/blob/main/examples/crewai_style_causal_audit.py
  • Integration note: https://github.com/safal207/Causal-Memory-Layer/blob/main/docs/integrations/CREWAI_STYLE_CAUSAL_AUDIT.md

The example does not import CrewAI or change CrewAI execution behavior. It only demonstrates the small MVP discussed above:

  1. represent a multi-agent task/tool trace as structured records,
  2. map upstream task / approval IDs to parent_cause,
  3. run CML as a lightweight audit pass,
  4. detect a broken lineage case with CML-AUDIT-R1-MISSING_PARENT.

The narrow claim is only that this can provide a lightweight causal-validity audit over structured agent action traces. It is not policy enforcement, runtime blocking, compliance, or safety certification.

If this direction looks useful, I can adapt the example into a small CrewAI docs/example PR with the same non-claims and dependency-light framing.

safal207 avatar Jun 14 '26 08:06 safal207

Thanks — this framing is very helpful.

I agree that the causal-audit layer and session-scoped episodic memory share the same structural backbone: action records, parent links, timestamps, and provenance metadata. The way I would keep the first version safe and maintainable is to make the causal trace primitive independent from any specific memory implementation, but compatible with it.

A minimal event model could look like:

  • action_id
  • parent_action_id | null
  • session_id
  • task_id | null
  • input_ref / output_ref, preferably hashed or minimized
  • timestamp
  • metadata
  • recalled_memory_refs, optional for cross-session causality

Then CML can focus on a small set of integrity checks:

  1. parent_action_id exists or the event is explicitly marked as a root;
  2. the chain is acyclic;
  3. cross-session memory references are resolvable;
  4. consolidation/summarization preserves provenance links;
  5. missing or malformed parents are reported as orphaned causal records.

That keeps the package lightweight: it does not enforce policy, judge correctness, or own memory storage. It only verifies that the causal graph is structurally sound.

For CrewAI specifically, I like your suggested hook point: task-output persistence. Each task completion could emit one causal event with the parent set to the triggering task, crew kickoff, or recalled memory association. That would give auditability through the existing task graph without changing execution semantics.

I can sketch a small follow-up contract for this: a CausalTraceEvent schema plus 3–4 deterministic fixtures for valid chain, missing parent, cycle, and cross-session recalled-memory reference. That may be a clean bridge between the CML proposal and CrewAI’s memory/task abstractions.

safal207 avatar Jun 14 '26 09:06 safal207

We've been running causal audit traces in production across ~20 agents for a few months, and one thing the parent_action_id model alone doesn't cover is verifiability by a third party. The causal chain is structurally correct, but nothing in the trace proves agent A actually authorized action B — the graph is correct, but it's not signed.

What we ended up building: each agent action emits a wallet-signed receipt containing (action_id, parent_action_id, task_id, agent_id, timestamp, SHA-256(input||output)). The signing wallet is derived deterministically from the agent's identity keypair (stored in /llms.txt, ETH/SOL/BTC compatible). Now any downstream auditor can verify two things independently: (1) the causal chain is structurally intact (parent_action_id exists, acyclic), and (2) each link was actually authored by the claiming agent — not just recorded.

This also solves a problem that came up in this thread: cross-session causality. With wallet-signed receipts, a recalled memory from session 2 carries the original session 1 agent's signature, so the receiving agent can verify it wasn't fabricated or tampered with during recall. We've open-sourced the whole setup at github.com/sunfishloop/sunfishloop — the agent wallet layer and receipt schema are in src/protocol/.

sunfishloop avatar Jun 15 '26 04:06 sunfishloop

Thanks — this is a very useful distinction.

I agree that parent_action_id alone gives structural causality, but not third-party verifiability. In other words, it can answer:

is the causal graph internally well-formed?

but not necessarily:

did the claimed agent actually author this causal link?

That suggests a clean layering for a future version of this idea:

  1. Structural causality — action_id, parent_action_id, acyclic chain, missing-parent detection.
  2. Content integrity — stable hash over minimized input/output references.
  3. Authorship proof — signature over the causal receipt by the claimed agent identity.
  4. Cross-session provenance — recalled memories carry the original author/signature rather than only a local reference.

For CML specifically, I would probably keep the core lightweight and make this an optional receipt envelope rather than a required wallet model. Something like:

CausalReceipt {
  action_id
  parent_action_id | null
  task_id | null
  agent_id
  timestamp
  payload_hash
  hash_alg
  signer_ref | null
  signature | null
  signature_alg | null
}

That keeps the first integration useful for simple audit traces, while allowing stronger deployments to add signed receipts when they need independent verification.

This also creates a nice bridge to the evidence-bundle direction: a portable bundle can contain both the structural causal graph and the signed receipts, so a downstream reviewer can verify lineage, authorship, and tamper evidence offline.

I would still keep the initial CrewAI-facing proposal dependency-light and non-blocking, but I think signed causal receipts are a strong follow-up extension for production or multi-organization audit settings.

safal207 avatar Jun 15 '26 09:06 safal207

Thanks, this is a very useful production-shaped distinction.

I agree that parent_action_id only proves structural lineage, not authorship. In other words:

  1. causal graph integrity: does the referenced parent exist, is the chain acyclic, and is the action connected to an upstream task / approval / memory?
  2. authorship / verifiability: can a third party independently verify that the claimed agent actually authored or authorized that link?

For CML, I would keep the first layer intentionally small and deterministic: validate the causal graph, detect missing parents, cycles, orphaned records, and broken cross-session references.

Then a signed-receipt layer could be added as an optional extension on top of that, with a receipt shape similar to what you described:

action_id
parent_action_id | null
task_id | null
agent_id
timestamp
input_hash
output_hash
signature
signature_scheme | key_ref

That would keep the base audit primitive dependency-light, while allowing stronger third-party verification for deployments that need it.

So the split I’m taking from your comment is:

  • CML core: structural causal validity
  • optional receipts: signed authorship / tamper evidence
  • future bridge: cross-session memory references that preserve the original authoring signature

I think that boundary is cleaner than trying to make the first CrewAI-style example handle signing, identity, and key management immediately. A minimal docs/example PR could start with the structural checks, and a later example could demonstrate signed receipts as an advanced audit mode.

safal207 avatar Jun 16 '26 21:06 safal207

Follow-up from the signed-receipt discussion: I added a small optional signed-receipt sidecar demo to CML.

Example: https://github.com/safal207/Causal-Memory-Layer/blob/main/examples/crewai_signed_receipt_sidecar.py

Boundary note: https://github.com/safal207/Causal-Memory-Layer/blob/main/docs/integrations/SIGNED_RECEIPT_SIDECAR.md

The split is intentionally narrow:

  • CML core: structural causal validity
  • optional receipt sidecar: receipt-shaped authorship / tamper-evidence path
  • future advanced mode: real signatures / key management

This does not claim production cryptographic signing, wallet identity, compliance, or safety certification. It only demonstrates how integrity metadata can attach through the existing record.integrity field while keeping the base audit primitive dependency-light.

So the first CrewAI-style proof path can stay small and reproducible, while still leaving a clean upgrade path for signed receipts later.

safal207 avatar Jun 16 '26 22:06 safal207

The CML thread has been useful for naming the structural layer. The gap sunfishloop identified is slightly different: structural causality (does the parent exist?) vs. external verifiability (can a third party reproduce the same identifier for this action, without trusting the trace backend?)

The specific problem with any signed-receipt or parent-id approach is that the identifier is generated by the same system that executes the action. An external auditor has to trust that the trace was not altered after the fact.

action_ref addresses this by deriving the identifier deterministically from the action's own metadata before any storage occurs:

action_ref = SHA-256(JCS({
    action_type: "tool_call",
    agent_id:    event.agent_id,
    scope:       event.tool_name + ":" + event.task_id,
    timestamp:   event.finished_at.isoformat()
}))

CrewAI's ToolUsageFinishedEvent already emits exactly these four fields. A listener in events/listeners/ can compute the ref at emission time — before it reaches any backend, proprietary or otherwise. The result is a portable handle any party can reproduce from the same inputs.

The derivation spec is an IETF Internet-Draft: draft-giskard-aeoess-action-ref, with AEOESS (Agent Passport System) as a referenced contributor. Hosted at kenneives/draft-giskard-aeoess-action-ref. Three independent implementations have cross-verified the four-field preimage byte-identical against the spec (AEOESS/APS, presidio-v/presidio-hardened-x402, TKCollective/AgentOracle).

This composes with CML rather than replacing it: CML checks whether the causal graph is well-formed; action_ref gives each node in that graph a verifiable identity.

Happy to sketch the listener implementation if useful.

giskard09 avatar Jun 18 '26 12:06 giskard09

Thanks — this is a useful distinction, and I agree that action_ref composes naturally with CML rather than replacing it.

A clean separation could be:

  • CML: validates structural causality (parent_action_id / parent_action_ref exists, roots are explicit, graph is acyclic);
  • action_ref: gives each action a deterministic, portable identity derived from canonical event metadata;
  • optional signatures or external anchoring: prove authorship and/or make post-hoc alteration detectable.

One nuance: reproducibility of a hash alone does not prove that a trace backend was not rewritten after the fact if the auditor only receives the rewritten preimage and recomputed reference. That stronger property needs an independently observed receipt, signature, transparency log, or other anchor. I think keeping those guarantees separate would make the integration easier to reason about and avoid over-claiming.

For the initial CrewAI/CML contract, I would keep action_ref optional and versioned, for example:

action_id
action_ref | null
action_ref_scheme | null   # e.g. draft-giskard-aeoess-action-ref-v1
parent_action_id | null
parent_action_ref | null
session_id
task_id | null
timestamp
metadata

Then CML can remain identity-scheme-agnostic while validating references produced by this draft or another deterministic scheme.

A listener sketch around ToolUsageFinishedEvent would be very useful. If you share it, I can adapt the standalone CML example and add deterministic fixtures for:

  1. identical canonical metadata → identical action_ref;
  2. changed metadata → different action_ref;
  3. unresolved parent_action_ref → broken lineage;
  4. signatures/anchoring present or absent without changing the structural audit result.

That would give us a small, testable bridge between CrewAI events, deterministic action identity, and causal graph integrity without changing execution semantics.

safal207 avatar Jun 18 '26 12:06 safal207

The tamper-resistance distinction is exactly right and worth keeping explicit in the spec. Hash reproducibility gives you identity stability — the same action always produces the same handle. Independent observability (signature, transparency log, on-chain anchor) is what gives you integrity against a rewriting adversary. Those are separate guarantees and should stay separate in the schema. Your proposed split captures it cleanly.

On action_ref_scheme: good idea. Makes CML identity-scheme-agnostic while leaving room for this draft and future schemes. The field doubles as a version signal if the derivation ever needs to change.

Listener sketch over ToolUsageFinishedEvent:

import hashlib
import json
from typing import Any
from crewai.events.base_event_listener import BaseEventListener
from crewai.events.event_bus import CrewAIEventsBus
from crewai.events.types.tool_usage_events import ToolUsageFinishedEvent


def derive_action_ref(agent_id: str, action_type: str, scope: str, timestamp_ms: int) -> str:
    """SHA-256(RFC 8785 JCS({agent_id, action_type, scope, timestamp_ms})) per action-ref-v1.

    For production use the `jcs` package (PyPI). This snippet is correct for
    string/int fields (no floats, no unicode escapes).
    """
    preimage = json.dumps(
        {"action_type": action_type, "agent_id": agent_id,
         "scope": scope, "timestamp_ms": timestamp_ms},
        sort_keys=True, separators=(",", ":"),
    )
    return hashlib.sha256(preimage.encode()).hexdigest()


class ActionRefListener(BaseEventListener):
    """Derives action_ref at the ToolUsageFinishedEvent boundary."""

    def setup_listeners(self, crewai_event_bus: CrewAIEventsBus) -> None:
        @crewai_event_bus.on(ToolUsageFinishedEvent)
        def on_tool_finished(source: Any, event: ToolUsageFinishedEvent) -> None:
            action_ref = derive_action_ref(
                agent_id=event.agent_id or event.agent_role or "unknown",
                action_type=event.tool_name,
                scope=event.task_id or "default",
                timestamp_ms=int(event.started_at.timestamp() * 1000),
            )
            cml_record = {
                "action_id":         str(id(event)),   # replace with stable id if available
                "action_ref":        action_ref,
                "action_ref_scheme": "draft-giskard-aeoess-action-ref-v1",
                "parent_action_id":  None,
                "parent_action_ref": None,
                "session_id":        None,             # wire from crew context if available
                "task_id":           event.task_id,
                "timestamp":         event.started_at.isoformat(),
                "metadata": {
                    "tool_name":   event.tool_name,
                    "finished_at": event.finished_at.isoformat(),
                    "from_cache":  event.from_cache,
                },
            }
            # hand off to CML graph / emit to audit backend
            print(cml_record)   # replace with your CML ingestion call

started_at is used for timestamp_ms because it anchors the intent at dispatch time, before execution — that is the field a verifier recomputes from. finished_at goes to metadata.

The four fixture cases you outlined map directly to the conformance suite already in argentum-core/examples/conformance/ — specifically action-ref-v1-baseline.fixture.json (case 1) and near-miss-v1/ (cases 2–3). Happy to add a CML-specific fixture set there once you have adapted the standalone example, so the two suites stay in sync.

giskard09 avatar Jun 18 '26 12:06 giskard09

Implemented the first CML-side bridge based on the listener sketch and the guarantee split discussed above:

  • deterministic helper + structural validator: https://github.com/safal207/Causal-Memory-Layer/blob/main/cml/integrations/action_ref.py
  • optional ToolUsageFinishedEvent listener: https://github.com/safal207/Causal-Memory-Layer/blob/main/examples/crewai_action_ref_listener.py
  • four deterministic contract tests: https://github.com/safal207/Causal-Memory-Layer/blob/main/tests/test_action_ref.py
  • integration note and explicit non-claims: https://github.com/safal207/Causal-Memory-Layer/blob/main/docs/integrations/CREWAI_ACTION_REF.md

The current contract keeps these guarantees independent:

  1. CML validates uniqueness, parent resolution, and acyclicity;
  2. action_ref provides deterministic identity stability;
  3. optional signatures / external anchors remain sidecars and do not alter the structural audit result.

The four tests cover:

  • identical canonical metadata -> identical reference;
  • changed metadata -> different reference;
  • unresolved parent_action_ref -> broken lineage;
  • integrity sidecars present/absent -> identical structural result.

Local focused run: 4 passed.

One deliberate limitation: the dependency-free implementation uses compact sorted UTF-8 JSON for the restricted v1 preimage (three strings + one integer). The documentation does not claim full RFC 8785 conformance until it is cross-verified against the external JCS/conformance vectors.

@giskard09, a byte-level comparison with your action-ref-v1-baseline.fixture.json would be very useful. If the preimage matches the draft exactly, I can pin the shared expected digest in the CML suite; if not, we can adjust the mapping before treating it as interoperable.

safal207 avatar Jun 18 '26 13:06 safal207

The architecture is right: separation of structural validation (CML), identity stability (action_ref), and sidecars (signatures/anchors) is exactly the layering the spec is designed for. The serialization approach — compact sorted UTF-8 JSON — is equivalent to JCS/RFC 8785 for all-ASCII keys and will produce the same byte output.

Two divergences from the baseline fixture prevent byte-identical cross-verification today:

1. Field name: your preimage uses timestamp_ms; the v1 spec uses timestamp.

2. Value type: your timestamp_ms is an integer (epoch-ms); the spec uses an RFC 3339 string ("2026-06-18T10:40:00.123Z").

Running your test vector through the baseline derivation as-is:

# your current preimage
{"action_type": "tool_call", "agent_id": "researcher-agent",
 "scope": "search:task-42", "timestamp_ms": 1781779200123}
# → SHA-256: 5edab291cd8221c86c69ffe61b19243836842a3945dd53ee34d13ca0f1765645

That digest won't appear in the conformance fixture because the field names differ.

To align, replace timestamp_ms: int with timestamp: str (RFC 3339, millisecond precision, UTC):

# aligned preimage
{"action_type": "tool_call", "agent_id": "researcher-agent",
 "scope": "search:task-42", "timestamp": "2026-06-18T10:40:00.123Z"}

The serialization and hash algorithm stay identical; only the field name and value type change.

Once aligned, I can add a CML conformance set under examples/conformance/cml/ in argentum-core — the four tests you wrote (identical/changed metadata, broken lineage, sidecar invariance) are exactly the shape we use for external implementers.

giskard09 avatar Jun 18 '26 13:06 giskard09

Aligned the CML-side implementation with the v1 timestamp contract you described.

Changes now in main:

  • timestamp_ms: int was replaced with timestamp: str;
  • the accepted form is RFC 3339 UTC with exactly millisecond precision, e.g. 2026-06-18T10:40:00.123Z;
  • the CrewAI listener normalizes started_at to that representation before deriving the reference;
  • the baseline digest is pinned in the CML test suite.

Implementation: https://github.com/safal207/Causal-Memory-Layer/blob/main/cml/integrations/action_ref.py

Listener: https://github.com/safal207/Causal-Memory-Layer/blob/main/examples/crewai_action_ref_listener.py

Tests: https://github.com/safal207/Causal-Memory-Layer/blob/main/tests/test_action_ref.py

Documentation: https://github.com/safal207/Causal-Memory-Layer/blob/main/docs/integrations/CREWAI_ACTION_REF.md

Pinned vector:

agent_id      = researcher-agent
action_type   = tool_call
scope         = search:task-42
timestamp     = 2026-06-18T10:40:00.123Z
expected hash = c6fb63e34b2d61446745d86dd90ececf4c321f15e5023f8ffb897e5b0a32a16b

Focused local result: 4 passed.

@giskard09, could you confirm this digest against action-ref-v1-baseline.fixture.json? If it matches, the CML side is ready for the proposed examples/conformance/cml/ external set in argentum-core.

safal207 avatar Jun 18 '26 13:06 safal207

Confirmed. The digest matches:

SHA-256({"action_type":"tool_call","agent_id":"researcher-agent","scope":"search:task-42","timestamp":"2026-06-18T10:40:00.123Z"})
→ c6fb63e34b2d61446745d86dd90ececf4c321f15e5023f8ffb897e5b0a32a16b ✓

CML conformance set is now live: examples/conformance/cml/vectors.json

giskard09 avatar Jun 18 '26 14:06 giskard09

Confirmed — thank you. I’ve recorded the cross-implementation result as a reviewer-facing external validation note in CML and linked the live Argentum conformance vector from the integration docs.

Evidence note: https://github.com/safal207/Causal-Memory-Layer/blob/main/docs/evidence/external_validation/2026-06-18-argentum-action-ref-conformance.md

Updated integration documentation: https://github.com/safal207/Causal-Memory-Layer/blob/main/docs/integrations/CREWAI_ACTION_REF.md

External vector: https://github.com/giskard09/argentum-core/blob/main/examples/conformance/cml/vectors.json

The claim remains deliberately narrow: byte-identical deterministic identity derivation for the pinned v1 vector, separate from structural causality and from signature/anchor guarantees.

safal207 avatar Jun 18 '26 15:06 safal207

Following the episodic-memory discussion, CML now includes an experimental Causal Equilibrium Point as a separate read-only audit layer.

Merged implementation: https://github.com/safal207/Causal-Memory-Layer/pull/152

Research note: https://github.com/safal207/Causal-Memory-Layer/blob/main/docs/research/CAUSAL_EQUILIBRIUM_POINT.md

Example: https://github.com/safal207/Causal-Memory-Layer/blob/main/examples/causal_equilibrium_point.py

The checkpoint classifies a declared causal context as:

  • BALANCED
  • UNSTABLE
  • INDETERMINATE

It evaluates whether supporting references, counterevidence, recalled-memory influence, unresolved references, and consolidation provenance are explicit and resolvable.

Current deterministic findings cover:

  • missing required counterevidence;
  • unresolved recalled-memory influence;
  • provenance loss during memory consolidation;
  • insufficient material for a determinate checkpoint.

The claim is intentionally narrow: this does not judge whether a decision is true or correct, does not require numerical symmetry between evidence, and does not enforce policy or block actions. BALANCED only means the declared audit conditions were satisfied.

safal207 avatar Jun 18 '26 15:06 safal207

The Causal Equilibrium follow-up is now split into three small, reviewable tasks:

  1. Versioned conformance fixtures — 10+ deterministic BALANCED / UNSTABLE / INDETERMINATE cases: https://github.com/safal207/Causal-Memory-Layer/issues/153

  2. Machine-readable benchmark runner with deterministic JSON and Markdown reports: https://github.com/safal207/Causal-Memory-Layer/issues/154

  3. Independent clean-checkout reproduction with a report SHA-256 and semantic review: https://github.com/safal207/Causal-Memory-Layer/issues/155

The dependency chain is intentionally:

fixtures → deterministic report → external reproduction

@ferhimedamine, feedback would be especially valuable on the memory semantics: whether unresolved recalled-memory influence should remain UNSTABLE, whether consolidation provenance loss should remain a FAIL, and whether missing required counterevidence should remain INDETERMINATE.

@giskard09, feedback would be especially valuable on whether the fixture/report shape is sufficiently deterministic and portable for a second implementation.

These remain experimental, read-only audit semantics; they do not judge decision correctness or enforce policy.

safal207 avatar Jun 18 '26 15:06 safal207

The fixture shape in #153 looks portable — snapshot + known_refs + expected_state + expected_findings is sufficient for a second implementation to reproduce without calling back to CML internals.

One gap: the acceptance criterion says "deterministic ordering" for multiple simultaneous findings, but doesn't specify the ordering rule. A second implementer needs that pinned before writing the evaluator — otherwise two correct implementations diverge on cases like fixture 10. Alphabetical by code, or by severity, or by referenced_id?

If you add that to the fixture schema (e.g. "findings_order": "code_asc"), the fixture set becomes fully portable.

giskard09 avatar Jun 18 '26 18:06 giskard09

Thanks — both reviews exposed exactly the right next steps.

@ferhimedamine: agreed on the memory mapping. I’m keeping the causal primitive storage-independent, while preserving explicit hooks for recalled_memory_refs and consolidation provenance. That keeps the audit layer lightweight but still able to detect orphaned cross-session influence and provenance loss after summarization.

@giskard09: good catch on ordering. I’ve now pinned the v1 canonical finding order as:

(code, severity_rank, refs_lexicographic, message)

with:

FAIL = 0
WARN = 1

Refs inside each finding are normalized lexicographically before comparison, and the fixture contract now declares:

"findings_order": "code_asc,severity_fail_before_warn,refs_lexicographic_asc,message_asc"

The code, tests, and research note were updated and merged here: https://github.com/safal207/Causal-Memory-Layer/pull/159

The conformance-fixture issue has also been updated to require this exact ordering: https://github.com/safal207/Causal-Memory-Layer/issues/153

No equilibrium state semantics changed; this only makes the existing behavior explicit and portable for a second implementation.

safal207 avatar Jun 18 '26 18:06 safal207