Skip to content

C13: Add deterministic Backend seed and fixture generator - #1047

Merged
Maneesh-Kumar-Maddini merged 9 commits into
mainfrom
EB/TP/C13-Seed-Fixture-Generator
Sep 20, 2026
Merged

Maneesh-Kumar-Maddini merged 9 commits into
mainfrom
EB/TP/C13-Seed-Fixture-Generator

Conversation

@thomas-pham101

Copy link
Copy Markdown
Collaborator

Summary

Implements Sprint 2 C13 - Backend Seed and Fixture Generator CLI.

The generator creates deterministic, schema-valid Project Echo detection
fixtures for local development, integration testing and downstream Sprint 2
tasks.

Changes

  • Added tools/seed_detections.py
  • Uses the real DetectionCreate schema for validation
  • Supports:
    • count
    • date range
    • species
    • sensor IDs
    • deterministic random seed
    • run ID
    • events/detections collection selection
    • dry-run
    • safe fixture cleanup
  • Adds fixture metadata for safe identification and cleanup
  • Prevents production cleanup
  • Reuses the existing Project Echo MongoDB configuration
  • Added automated C13 test coverage

Validation

Automated tests: 15 passed

Manual MongoDB integration evidence:

  • 12 fixtures inserted successfully
  • deterministic species distribution verified:
    • Sus Scrofa: 4
    • Dingo: 4
    • Crimson Rosella: 4
  • sensor distribution:
    • Sensor 2: 6
    • Sensor 3: 6
  • cleanup dry-run identified 12 fixtures without deleting them
  • targeted cleanup removed exactly 12 fixtures
  • final fixture count: 0

Safety

Cleanup only targets records marked with C13 fixture metadata.

Explicit database/environment/confirmation arguments are required for
destructive cleanup, and production cleanup is rejected.

Related Sprint 2 Work

The fixture generator is reused by B2.4 analytics validation.

@Maneesh-Kumar-Maddini Maneesh-Kumar-Maddini left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The 15 focused generator tests passed during review, and the deterministic generation, fixture tagging, validation, and cleanup safeguards are present. However, the branch does not include the latest main changes. Please update it against current main and rerun the generator tests and a controlled seed/cleanup verification against an isolated test database. Confirm that unrelated records remain untouched. Approval is pending this final integration evidence, after which the dependent #1051 can proceed.

@thomas-pham101

Copy link
Copy Markdown
Collaborator Author

Hi Maneesh, I’ve now reconciled C13 with the latest main and completed the final isolated integration verification you requested.

Verification completed:

15 passed for tests/test_seed_detections.py
Used isolated database C13ReviewTest
Started with 1 unrelated control record
Seeded 12 C13 fixtures successfully, resulting in 13 total records
Cleanup dry-run identified exactly 12 C13 fixtures and removed none
After dry-run: 13 total records, unrelated control record still present
Confirmed cleanup removed exactly 12 C13 fixtures
Final state: 1 record remaining, which is the unrelated control record

This confirms that targeted C13 cleanup only removes C13-tagged fixtures and leaves unrelated records untouched.

Could you please re-review the latest branch when you have a chance? Thank you.

@Maneesh-Kumar-Maddini Maneesh-Kumar-Maddini left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed commit c9063e8 and the supplied integration evidence. The earlier update and cleanup-verification requirements are satisfied. All 15 generator tests passed, and the isolated seed/cleanup check removed exactly 12 fixtures while preserving the unrelated control record.

One integration issue remains: the generator defaults to the events collection but validates and generates only DetectionCreate documents. These omit sourceType and use location arrays, whereas the current EventSchema requires sourceType and structured location objects. The generated fixtures fail EventSchema validation and are excluded from both real and simulator source-type filters.

Please generate and validate fixtures against the schema appropriate to the selected collection. Add coverage confirming that event fixtures appear through the intended filtered reads, while detections fixtures and cleanup protections continue to work.

Approval remains pending this correction and its regression tests.

@thomas-pham101

Copy link
Copy Markdown
Collaborator Author

Hi Maneesh, I’ve addressed the remaining C13 integration issue and reconciled the branch with the latest remote changes.

The generator now handles collection-specific fixtures for both events and detections, with the appropriate schema/structure for each path. I also added regression coverage for the event fixtures and filtered read behaviour.

Verification completed:

+) pytest tests/test_seed_detections.py -q
+) 19 passed
+) Working tree clean before push
+) Latest branch successfully pushed to EB/TP/C13-Seed-Fixture-Generator

Could you please re-review the latest changes when you have a chance? Thank you.

@Maneesh-Kumar-Maddini Maneesh-Kumar-Maddini left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed commit 8d97337. The remaining collection-schema issue is resolved: event fixtures now include sourceType and structured location objects validated against EventSchema, while detection fixtures retain the DetectionCreate format.
All 19 supplied tests passed in isolation. Additional mock-database checks verified real/simulator filtering, event-response validation, deterministic generation, and cleanup for both collections. Each cleanup removed exactly 12 generated fixtures while preserving an unrelated control record.
The branch includes current main, and all four GitHub checks pass. All review points have been addressed. This PR is ready to merge.

@Maneesh-Kumar-Maddini
Maneesh-Kumar-Maddini merged commit 1443fe1 into main Sep 20, 2026
4 checks passed
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