Skip to content

Detailed atom trace 2#134

Open
ColtonPayne wants to merge 3 commits intomainfrom
detailed-atom-trace-2
Open

Detailed atom trace 2#134
ColtonPayne wants to merge 3 commits intomainfrom
detailed-atom-trace-2

Conversation

@ColtonPayne
Copy link
Collaborator

No description provided.

@ColtonPayne
Copy link
Collaborator Author

Bug: get_dict() not updated for new 9-field trace tuples

The trace tuples were expanded from 5 fields to 9 fields in this PR, but get_dict() was not updated to handle the new format. This causes a ValueError at runtime when any code calls interpretation.get_dict().

Error

File "pyreason/scripts/interpretation/interpretation.py", line 698, in get_dict
    time, _, node, l, bnd = change
ValueError: too many values to unpack (expected 5)

Affected locations (all 3 interpretation variants)

interpretation.py line 698:

time, _, node, l, bnd = change  # expects 5, gets 9

interpretation.py line 708:

time, _, edge, l, bnd, = change  # expects 5, gets 9

Same pattern in interpretation_fp.py and interpretation_parallel.py.

Suggested fix

Update the unpacking to only grab the first 5 fields:

time, _, node, l, bnd = change[:5]

or use indexing:

time = change[0]
node = change[2]
l = change[3]
bnd = change[4]

This affects anyone calling interp.get_dict() after reasoning — which is a common pattern in downstream consumers.

@ColtonPayne
Copy link
Collaborator Author

Correction to suggested fix

The proper fix should unpack all 9 fields, not slice to 5. This keeps get_dict() consistent with the new tuple format and allows it to use any of the new fields if needed in the future.

For nodes (line 698):

time, _, node, l, bnd, consistent, triggered_by, name, inconsistency_msg = change

For edges (line 708):

time, _, edge, l, bnd, consistent, triggered_by, name, inconsistency_msg = change

The rest of the method body can remain the same since it only uses time, node/edge, l, and bnd — but unpacking all 9 makes the code self-documenting and future-proof.

@ColtonPayne
Copy link
Collaborator Author

Broader issue: get_dict() return value should include new metadata

Just unpacking 9 fields fixes the crash, but it still discards the 4 new fields (consistent, triggered_by, name, inconsistency_msg) — meaning downstream consumers calling get_dict() have no way to access the detailed atom trace data this PR adds.

The return structure should be updated to include the new metadata. For example, instead of:

interpretations[time][node][l._value] = (bnd.lower, bnd.upper)

It could return:

interpretations[time][node][l._value] = {
    'bounds': (bnd.lower, bnd.upper),
    'consistent': consistent,
    'triggered_by': triggered_by,
    'name': name,
    'inconsistency_message': inconsistency_msg
}

Otherwise the whole point of this PR (richer trace explainability) is only accessible through the raw trace tuples or CSV output, but not through the get_dict() API that downstream code actually uses.

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.

1 participant