Skip to content

[From PR #75] Test runner regenerates random data causing validation inconsistency #76

@andreasronge

Description

@andreasronge

Context

From PR #75 review - the demo's test runner has an architectural issue with data consistency.

Problem

PtcDemo.TestRunner.get_last_result/0 (lines 226-230) regenerates fresh random data by calling SampleData functions.

However, the Agent already has datasets loaded in state at init time (agent.ex:70-75) and executes programs against those datasets (agent.ex:110).

This means test validation runs against DIFFERENT data than what the program was executed against, potentially causing false positives/negatives in test results.

Suggested Fix

  1. Add last_result field to Agent state struct
  2. Store the execution result alongside last_program in agent.ex:146
  3. Change get_last_result/0 to fetch the stored result from Agent state instead of re-executing
  4. Or alternatively, add a public API like Agent.last_result/0 to retrieve the stored result

Impact

  • Low severity (tests use constraint-based assertions which are somewhat resilient)
  • Affects demo reliability and test accuracy
  • Could cause confusing test failures when random data diverges

Files Affected

  • demo/lib/ptc_demo/agent.ex (state management)
  • demo/lib/ptc_demo/test_runner.ex (get_last_result/0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfrom-pr-reviewIssue created from PR review feedbackready-for-implementationIssue is approved and ready to implementtech-debtTechnical debt or refactoring

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions