Skip to content

conveyor-engine: queue_compile duplicates ~9 conveyor_compile helpers verbatim despite a shared pub(crate) seam #877

Description

@bpowers

Found by branch review of conveyor-engine before merge (the in-flight XMILE conveyor+queue implementation; specs docs/design/conveyors.md + docs/design/queues.md). Filed from a review report that exceeded its 15-finding cap.

Summary

queue_compile.rs re-implements conveyor_compile helper-for-helper instead of sharing through the already-established pub(crate) seam it imports 8 items from. Byte-identical (or identical bar an ErrorCode/noun) copies:

  • canon (queue_compile.rs:70 vs conveyor_compile.rs:341)
  • placeholder_zero_equation (:197 vs :1479)
  • equation_dims (:207 vs :1490)
  • equation_scalar_strings (:218 vs :937; its own doc admits "Mirrors the private helper")
  • the driven-flow-read rejection scan (:426-453 vs :768-795)
  • the container rewrite/attach/apply loops (:469-526 vs :817-902)
  • resolve_plans' per-element flattening core with byte-identical n_queues/n_belts and eoff closures (:571-628 vs :1559-1658)
  • the emit_queue_ltm_degraded_warnings twin (db/diagnostic.rs:248 vs :194)

Cost

~9 hand-maintained copies across two sibling stock types. A corrective edit to one copy silently skips its sibling: teaching the driven-read scan a new equation-reference position, or preserving Arrayed shape in placeholder_zero_equation, fixes conveyors but leaves queues (or vice versa) unpatched -- and for the scan and placeholder that is silent mis-simulation of the untouched stock type, the exact loud-rejection contract both modules document. A third discrete stock type would triple every copy.

Evidence

  • the seam already exists: use crate::conveyor_compile::{ContainerMeta, ContainerNaming, ContainerPlan, ContainerVarSpec, container_value_from_slice, element_subscripts_for_dims, make_container_stock, rewrite_container_equation}; (queue_compile.rs:64-67)
  • placeholder_zero_equation queue:198-203 == conveyor:1480-1485
  • equation_scalar_strings doc at queue:218 says "Mirrors the private helper of the same name in crate::conveyor_compile"; body queue:219-235 == conveyor:938-954
  • driven-read scan queue:433-450 == conveyor:775-792, differing only in ErrorCode::QueueDrivenFlowRead vs ConveyorDrivenFlowRead
  • resolve_plans eoff queue:583-589 == conveyor:1580-1586; n_queues queue:555-557 == n_belts conveyor:1542-1544
  • db/diagnostic.rs:198-204 (conveyor) vs :252-258 (queue): identical scan/sort/one-Warning-per-name, differing only in ErrorCode::{Conveyor,Queue}LtmDegraded + message noun

Suggested direction

Hoist these into conveyor_compile (or a shared discrete-stock module) exactly as the 8 already-shared items were, parameterizing the scan/warning on ErrorCode + noun.

Metadata

Metadata

Assignees

No one assigned

    Labels

    engineIssues with the rust-based simulation enginehygieneToil, but its useful to get get too behind on ittech debt

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions