/ rules / D-FILES-01.py
D-FILES-01.py
 1  """
 2  Rule: D-FILES-01 - file path and size
 3  Type: semantic | Output: binary
 4  Description: Reject when any file is missing path or size or has negative size.
 5  Spec reference: 8.1.1
 6  """
 7  
 8  # TODO: Implement file path and size validation
 9  # Input: NIP-35 event dict with tags field
10  # Output: {"passed": bool}
11  #
12  # Steps:
13  #   1. Extract all 'file' tags from tags
14  #   2. If no file tags exist, consider it valid (single-file torrent may omit file tags)
15  #   3. Validate each file tag
16  #   4. File tag must have exactly 3 elements: ["file", "path", "size"]
17  #   5. Path must be non-empty
18  #   6. Size must be present and parseable as non-negative integer
19  #
20  # Edge cases:
21  #   - Single-file torrents without file tags
22  #   - Negative sizes
23  #   - Invalid size strings
24  #
25  # Dependencies: None (stdlib only)
26  # Estimated complexity: Low (20-25) lines
27  # Priority: High (foundational validation)
28  
29  from simple_types import BinaryRuleResult, Nip35Kind2003Event
30  
31  
32  def main(entry: Nip35Kind2003Event) -> BinaryRuleResult:
33      """Placeholder: deterministic pass-through."""
34      return {"passed": True}