tenseleyflow/loader / 81934c3

Browse files

Ignore nested reference paths

Authored by espadonne
SHA
81934c30ac494d019427a6abdb8039214de6be74
Parents
3719f44
Tree
a85dad9

2 changed files

StatusFile+-
M src/loader/runtime/dod.py 8 2
M tests/test_dod.py 33 0
src/loader/runtime/dod.pymodified
@@ -1093,13 +1093,19 @@ def _extract_file_change_path_literals(lines: list[str]) -> list[str]:
10931093
     paths: list[str] = []
10941094
     seen: set[str] = set()
10951095
     directory_stack: list[tuple[int, str]] = []
1096
+    read_only_stack: list[int] = []
10961097
 
10971098
     for line in lines:
1098
-        if _line_describes_read_only_file_change(line):
1099
-            continue
11001099
         indent = len(line) - len(line.lstrip(" "))
1100
+        while read_only_stack and indent <= read_only_stack[-1]:
1101
+            read_only_stack.pop()
11011102
         while directory_stack and indent <= directory_stack[-1][0]:
11021103
             directory_stack.pop()
1104
+        if _line_describes_read_only_file_change(line):
1105
+            read_only_stack.append(indent)
1106
+            continue
1107
+        if read_only_stack:
1108
+            continue
11031109
 
11041110
         backticked = re.findall(r"`([^`]+)`", line)
11051111
         if backticked:
tests/test_dod.pymodified
@@ -398,6 +398,39 @@ def test_collect_planned_artifact_targets_ignores_read_only_reference_paths(
398398
     ]
399399
 
400400
 
401
+def test_collect_planned_artifact_targets_ignores_nested_read_only_reference_paths(
402
+    tmp_path: Path,
403
+) -> None:
404
+    implementation_plan = tmp_path / "implementation.md"
405
+    implementation_plan.write_text(
406
+        "\n".join(
407
+            [
408
+                "# Implementation Plan",
409
+                "",
410
+                "## File Changes",
411
+                "1. Create directory structure for nginx guide:",
412
+                f"   - `{tmp_path / 'Loader' / 'guides' / 'nginx' / 'index.html'}`",
413
+                f"   - `{tmp_path / 'Loader' / 'guides' / 'nginx' / 'chapters'}/`",
414
+                "2. Analyze existing fortran guide structure to understand the format:",
415
+                "   - `~/Loader/guides/fortran/`",
416
+                "   - `~/Loader/guides/fortran/chapters/`",
417
+                "3. Create nginx guide content following the same structure and cadence as the fortran guide",
418
+                "",
419
+            ]
420
+        )
421
+    )
422
+
423
+    dod = create_definition_of_done("Create an nginx guide from a Fortran reference.")
424
+    dod.implementation_plan = str(implementation_plan)
425
+
426
+    targets = collect_planned_artifact_targets(dod, project_root=tmp_path)
427
+
428
+    assert targets == [
429
+        (tmp_path / "Loader" / "guides" / "nginx" / "index.html", False),
430
+        (tmp_path / "Loader" / "guides" / "nginx" / "chapters", True),
431
+    ]
432
+
433
+
401434
 def test_all_planned_artifacts_exist_requires_file_contents_for_planned_output_directory(
402435
     tmp_path: Path,
403436
 ) -> None: