codeplain 0.3.13.dev49__py3-none-any.whl → 0.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. change_detection.py +65 -94
  2. cli_output/dry_run.py +7 -3
  3. {codeplain-0.3.13.dev49.dist-info → codeplain-0.4.0.dist-info}/METADATA +1 -1
  4. {codeplain-0.3.13.dev49.dist-info → codeplain-0.4.0.dist-info}/RECORD +49 -43
  5. codeplain_REST_api.py +9 -14
  6. docs/generate_cli.py +3 -2
  7. partial_rendering.py +32 -2
  8. plain2code.py +42 -14
  9. plain2code_arguments.py +69 -12
  10. plain2code_telemetry.py +2 -1
  11. plain2code_utils.py +14 -0
  12. plain_modules.py +73 -14
  13. render_machine/actions/analyze_specification_ambiguity.py +5 -3
  14. render_machine/actions/distill_conformance_test_memory.py +3 -1
  15. render_machine/actions/fix_conformance_test.py +4 -4
  16. render_machine/actions/fix_unit_tests.py +3 -1
  17. render_machine/actions/refactor_code.py +6 -1
  18. render_machine/actions/render_conformance_tests.py +52 -20
  19. render_machine/actions/render_functional_requirement.py +5 -2
  20. render_machine/actions/run_conformance_tests.py +3 -2
  21. render_machine/actions/summarize_conformance_tests.py +3 -1
  22. render_machine/render_context.py +59 -20
  23. render_machine/render_types.py +6 -15
  24. standard_template_library/typescript-react-app-boilerplate.plain +2 -1
  25. tests/test_acceptance_scenario_rendered_once.py +169 -0
  26. tests/test_acceptance_scenarios_after_a_code_fix.py +110 -0
  27. tests/test_change_detection.py +138 -127
  28. tests/test_conformance_fix_journal.py +46 -46
  29. tests/test_dry_run_link_validation.py +2 -1
  30. tests/test_fix_unit_tests_action.py +1 -1
  31. tests/test_frid_arguments.py +40 -0
  32. tests/test_functionality_without_scenarios.py +88 -0
  33. tests/test_git_utils.py +13 -13
  34. tests/test_partial_rendering.py +82 -47
  35. tests/test_plain2code.py +39 -41
  36. tests/test_plain2code_utils.py +12 -1
  37. tests/test_plain_modules.py +50 -44
  38. tests/test_render_finished_report.py +2 -0
  39. tests/test_render_range.py +18 -9
  40. tests/test_render_stop_reason.py +5 -5
  41. tests/test_telemetry.py +2 -2
  42. tests/test_terminal_attachment.py +2 -1
  43. tests/test_tests_folders.py +91 -0
  44. tests/test_traceability_warnings.py +69 -0
  45. tui/plain_module_render_choice_tui.py +4 -6
  46. tui/state_handlers.py +19 -28
  47. {codeplain-0.3.13.dev49.dist-info → codeplain-0.4.0.dist-info}/WHEEL +0 -0
  48. {codeplain-0.3.13.dev49.dist-info → codeplain-0.4.0.dist-info}/entry_points.txt +0 -0
  49. {codeplain-0.3.13.dev49.dist-info → codeplain-0.4.0.dist-info}/licenses/LICENSE +0 -0
plain2code.py CHANGED
@@ -272,29 +272,53 @@ def report_render_finished(
272
272
  pass
273
273
 
274
274
 
275
- def warn_if_acceptance_tests_without_conformance_script(plain_module, args) -> None:
276
- """Warn when any loaded module (including required modules) defines acceptance tests
277
- but no conformance tests script is configured.
275
+ def _has_scenarios(plain_source_tree) -> bool:
276
+ """Whether a test plain file bound a scenario to any functionality of the module."""
277
+ for functionality in plain_source_tree.get(plain_spec.FUNCTIONAL_REQUIREMENTS) or []:
278
+ if functionality.get(plain_spec.CONFORMANCE_TESTS) or functionality.get(plain_spec.ACCEPTANCE_TESTS):
279
+ return True
280
+ return False
278
281
 
279
- Acceptance tests are treated as conformance tests, so a conformance tests script is required
280
- to actually run them. Without it, the acceptance tests cannot be executed.
282
+
283
+ def warn_about_functionalities_without_scenarios(plain_module) -> None:
284
+ """Warn about every functionality whose test plain file holds no conformance scenario.
285
+
286
+ Such a functionality is rendered, but no conformance test is rendered or run for it.
287
+ """
288
+ functionalities = [
289
+ f"{module_name}:{func_id}" for module_name, func_id in plain_module.functionalities_without_scenarios
290
+ ]
291
+ if not functionalities:
292
+ return
293
+
294
+ console.warning(
295
+ f"No conformance scenario is written for {', '.join(functionalities)}, "
296
+ "so each one is rendered without conformance tests."
297
+ )
298
+
299
+
300
+ def warn_if_scenarios_without_conformance_script(plain_module, args) -> None:
301
+ """Warn when a test plain file was found but conformance tests are disabled.
302
+
303
+ The scenarios are rendered as conformance tests, so without a conformance tests script
304
+ none of them is rendered.
281
305
  """
282
306
  if args.conformance_tests_script:
283
307
  return
284
308
 
285
- module_names_with_acceptance_tests = [
309
+ module_names_with_scenarios = [
286
310
  module.module_name
287
311
  for module in plain_module.all_required_modules + [plain_module]
288
- if plain_spec.has_acceptance_tests(module.plain_source)
312
+ if _has_scenarios(module.plain_source)
289
313
  ]
290
- if not module_names_with_acceptance_tests:
314
+ if not module_names_with_scenarios:
291
315
  return
292
316
 
293
- module_names = ", ".join(module_names_with_acceptance_tests)
317
+ module_names = ", ".join(module_names_with_scenarios)
294
318
  console.warning(
295
- f"Acceptance tests were found ({module_names}) but no conformance tests script is configured. "
296
- "Acceptance tests are treated as conformance tests and require a conformance tests script "
297
- "(--conformance-tests-script or 'conformance_tests_script' in config) to be executed."
319
+ f"Test scenarios were found ({module_names}) but no conformance tests script is configured, "
320
+ "so no scenario is rendered. Set --conformance-tests-script or 'conformance_tests_script' "
321
+ "in the config file to render them."
298
322
  )
299
323
 
300
324
 
@@ -326,7 +350,8 @@ def render( # noqa: C901
326
350
  enter_pause_event = threading.Event()
327
351
  signal.signal(signal.SIGTERM, lambda _signum, _frame: stop_event.set())
328
352
 
329
- warn_if_acceptance_tests_without_conformance_script(plain_module, args)
353
+ warn_if_scenarios_without_conformance_script(plain_module, args)
354
+ warn_about_functionalities_without_scenarios(plain_module)
330
355
 
331
356
  # A built module can be distributed as a "<module>.module" zip archive instead of an unpacked directory.
332
357
  # Extract any such module to a scratch location up front. Scratch dirs are removed in main()'s finally.
@@ -488,6 +513,8 @@ def main(): # noqa: C901
488
513
  os.path.basename(args.filename),
489
514
  args.build_folder,
490
515
  template_dirs,
516
+ args.tests_folder,
517
+ args.render_conformance_tests,
491
518
  )
492
519
  except Exception as e:
493
520
  console.error(f"Error: {user_error_message(e)}")
@@ -503,7 +530,8 @@ def main(): # noqa: C901
503
530
  console.info("Printing dry run output...\n")
504
531
  render_range = plain_spec.compute_render_range(args, plain_module.plain_source)
505
532
  print_dry_run_output(plain_module.plain_source, render_range)
506
- warn_if_acceptance_tests_without_conformance_script(plain_module, args)
533
+ warn_if_scenarios_without_conformance_script(plain_module, args)
534
+ warn_about_functionalities_without_scenarios(plain_module)
507
535
  return
508
536
 
509
537
  event_bus = EventBus()
plain2code_arguments.py CHANGED
@@ -2,6 +2,8 @@ import argparse
2
2
  import os
3
3
  from typing import Optional, Sequence
4
4
 
5
+ from plain_parser.plain_spec import is_semantic_id
6
+
5
7
  from path_resolution import resolve_path
6
8
  from plain2code_console import console
7
9
  from plain2code_exceptions import AmbiguousConfigFileError
@@ -17,6 +19,7 @@ CODEPLAIN_API_KEY = os.getenv("CODEPLAIN_API_KEY")
17
19
 
18
20
 
19
21
  DEFAULT_BUILD_FOLDER = "plain_modules"
22
+ DEFAULT_TESTS_FOLDER = "tests"
20
23
  DEFAULT_BUILD_DEST = "dist"
21
24
  DEFAULT_CONFORMANCE_TESTS_DEST = "dist_conformance_tests"
22
25
  MAX_JOB_TAG_LENGTH = 300
@@ -48,6 +51,50 @@ def _resolve_path_arg(
48
51
  return resolved
49
52
 
50
53
 
54
+ def _resolve_path_list_arg(
55
+ arg_name: str,
56
+ args,
57
+ cwd: str,
58
+ config_dir: Optional[str],
59
+ spec_dir: str,
60
+ ) -> None:
61
+ """Resolve a repeatable path-valued argument on ``args`` in-place.
62
+
63
+ A single string (as config.yaml may give it) is read as a one-item list.
64
+ """
65
+ original_value = getattr(args, arg_name, None)
66
+ if original_value is None:
67
+ return
68
+
69
+ if isinstance(original_value, str):
70
+ original_value = [original_value]
71
+
72
+ source = getattr(args, ARGUMENT_SOURCES, {}).get(arg_name, "default")
73
+ setattr(
74
+ args,
75
+ arg_name,
76
+ [resolve_path(value, source, cwd=cwd, config_dir=config_dir, spec_dir=spec_dir) for value in original_value],
77
+ )
78
+
79
+
80
+ def _resolve_path_arguments(
81
+ parser: argparse.ArgumentParser,
82
+ args,
83
+ cwd: str,
84
+ config_dir: Optional[str],
85
+ spec_dir: str,
86
+ ) -> None:
87
+ """Resolve every path-valued argument on ``args`` in-place and apply the tests-folder default."""
88
+ for action in parser._actions:
89
+ if getattr(action, "_is_path", False):
90
+ _resolve_path_arg(action.dest, args, cwd, config_dir, spec_dir)
91
+ elif getattr(action, "_is_path_list", False):
92
+ _resolve_path_list_arg(action.dest, args, cwd, config_dir, spec_dir)
93
+
94
+ if args.tests_folder is None:
95
+ args.tests_folder = [os.path.join(spec_dir, DEFAULT_TESTS_FOLDER)]
96
+
97
+
51
98
  def _resolve_script_path(
52
99
  script_arg_name: str,
53
100
  args,
@@ -87,14 +134,14 @@ def job_tag_string(s):
87
134
 
88
135
 
89
136
  def frid_string(s):
90
- """Validate that the FRID is an integer."""
137
+ """Validate that the functionality ID is a func-id."""
91
138
  if not s:
92
139
  raise argparse.ArgumentTypeError("The functionality ID cannot be empty.")
93
140
 
94
- try:
95
- int(s)
96
- except ValueError:
97
- raise argparse.ArgumentTypeError("Functionality ID string must be a number.")
141
+ if not is_semantic_id(s):
142
+ raise argparse.ArgumentTypeError(
143
+ f"Invalid functionality ID '{s}'. A functionality ID holds lowercase letters, digits and hyphens."
144
+ )
98
145
  return s
99
146
 
100
147
 
@@ -204,11 +251,14 @@ def update_args_with_config(args, parser, cli_provided: set[str]):
204
251
  return args
205
252
 
206
253
 
207
- def _add_arg(parser, *args, path=False, **kwargs):
208
- """Add an argument; tag as path-valued when ``path=True`` so ``parse_arguments`` resolves it."""
254
+ def _add_arg(parser, *args, path=False, path_list=False, **kwargs):
255
+ """Add an argument; tag as path-valued when ``path=True`` (or ``path_list=True`` when it is
256
+ repeatable) so ``parse_arguments`` resolves it."""
209
257
  action = parser.add_argument(*args, **kwargs)
210
258
  if path:
211
259
  action._is_path = True
260
+ if path_list:
261
+ action._is_path_list = True
212
262
 
213
263
 
214
264
  def create_parser():
@@ -285,7 +335,7 @@ def create_parser():
285
335
  render_range_group,
286
336
  "--render-range",
287
337
  type=frid_range_string,
288
- help="Specify a range of functionalities to render (e.g. `1` , `2`, `3`). "
338
+ help="Specify a range of functionalities to render (e.g. `add-task`, `add-task,list-tasks`). "
289
339
  "Use comma to separate start and end IDs. If only one functionality ID is provided, only that functionality is rendered. "
290
340
  "Range is inclusive of both start and end IDs.",
291
341
  )
@@ -293,7 +343,7 @@ def create_parser():
293
343
  render_range_group,
294
344
  "--render-from",
295
345
  type=frid_string,
296
- help="Continue generation starting from this specific functionality (e.g. `2`). "
346
+ help="Continue generation starting from this specific functionality (e.g. `add-task`). "
297
347
  "The functionality with this ID will be included in the output. The functionality ID must match one of the functionalities in your plain file.",
298
348
  )
299
349
 
@@ -393,6 +443,15 @@ def create_parser():
393
443
  "3) Built-in standard_template_library directory",
394
444
  path=True,
395
445
  )
446
+ _add_arg(
447
+ parser,
448
+ "--tests-folder",
449
+ action="append",
450
+ default=None,
451
+ help="Folder scanned for test plain files; repeat the option for more than one. "
452
+ f"Defaults to '{DEFAULT_TESTS_FOLDER}' next to the plain file.",
453
+ path_list=True,
454
+ )
396
455
  _add_arg(
397
456
  parser,
398
457
  "--copy-build",
@@ -507,9 +566,7 @@ def parse_arguments(command_line: Optional[Sequence[str]] = None):
507
566
  # otherwise it is still just the lookup name (e.g. "config.yaml").
508
567
  config_dir = os.path.dirname(args.config_name) if os.path.isabs(args.config_name) else None
509
568
 
510
- for action in parser._actions:
511
- if getattr(action, "_is_path", False):
512
- _resolve_path_arg(action.dest, args, cwd, config_dir, spec_dir)
569
+ _resolve_path_arguments(parser, args, cwd, config_dir, spec_dir)
513
570
 
514
571
  if args.build_folder == args.build_dest:
515
572
  parser.error("--build-folder and --build-dest cannot be the same")
plain2code_telemetry.py CHANGED
@@ -17,6 +17,7 @@ from sentry_sdk.integrations.modules import ModulesIntegration
17
17
  from sentry_sdk.scrubber import DEFAULT_DENYLIST, EventScrubber
18
18
 
19
19
  from plain2code_state import RunState
20
+ from plain2code_utils import qualified_frid
20
21
  from system_config import system_config
21
22
 
22
23
  SENTRY_DSN = "https://64d0d86b50b34e2dede3e4eaf5142282@o4510793955934208.ingest.us.sentry.io/4511540621213696"
@@ -103,7 +104,7 @@ def capture_crash(exc_info, run_state: Optional[RunState], args) -> bool:
103
104
  scope.set_tag("render_id", run_state.render_id)
104
105
  scope.set_tag("render_state", run_state.current_render_state)
105
106
  scope.set_tag("current_module", run_state.current_module)
106
- scope.set_tag("current_frid", run_state.current_frid)
107
+ scope.set_tag("current_frid", qualified_frid(run_state.current_module, run_state.current_frid))
107
108
  if run_state.user_email:
108
109
  scope.set_user({"email": run_state.user_email})
109
110
  scope.set_tag("headless", bool(getattr(args, "headless", False)))
plain2code_utils.py CHANGED
@@ -1,3 +1,5 @@
1
+ from typing import Optional
2
+
1
3
  from plain_parser.loaders import MAX_BASE64_BLOB_LENGTH, find_large_base64_blob # noqa: F401
2
4
 
3
5
 
@@ -27,3 +29,15 @@ AMBIGUITY_CAUSES = {
27
29
  "functional_requirement_ambiguity": "Ambiguity is in the functionality",
28
30
  "other": "Ambiguity in the other parts of the specification",
29
31
  }
32
+
33
+
34
+ def qualified_frid(module_name: Optional[str], frid: Optional[str]) -> Optional[str]:
35
+ """A functionality named as `<module>:<func-id>`.
36
+
37
+ A func-id is unique only within its module, so this is the form to use wherever the
38
+ module is not already named next to it. Returns the func-id alone when the module is
39
+ unknown, and None when there is no functionality to name.
40
+ """
41
+ if frid is None:
42
+ return None
43
+ return f"{module_name}:{frid}" if module_name else frid
plain_modules.py CHANGED
@@ -18,6 +18,7 @@ require_git()
18
18
 
19
19
  from git import Repo
20
20
  from git.exc import NoSuchPathError
21
+ from plain_parser import project
21
22
 
22
23
  import file_utils
23
24
  import git_utils
@@ -133,8 +134,28 @@ def _strip_functional_requirements(plain_source_tree: dict) -> dict:
133
134
  return stripped
134
135
 
135
136
 
137
+ def _functionalities_without_scenarios(chain: list[tuple[str, dict]]) -> list[tuple[str, str]]:
138
+ """The functionalities whose test plain file holds no conformance scenario.
139
+
140
+ Each one is rendered without conformance tests.
141
+ """
142
+ return [
143
+ (module_name, functionality["id"])
144
+ for module_name, tree in chain
145
+ for functionality in tree.get(plain_spec.FUNCTIONAL_REQUIREMENTS) or []
146
+ if not functionality[plain_spec.CONFORMANCE_TESTS]
147
+ ]
148
+
149
+
136
150
  class PlainModule:
137
- def __init__(self, filename: str, build_folder: str, template_dirs: list[str]):
151
+ def __init__(
152
+ self,
153
+ filename: str,
154
+ build_folder: str,
155
+ template_dirs: list[str],
156
+ tests_folders: list[str] | None = None,
157
+ conformance_tests_enabled: bool = False,
158
+ ):
138
159
  self.filename = filename
139
160
  self.build_folder = build_folder
140
161
  self.template_dirs = template_dirs
@@ -151,6 +172,7 @@ class PlainModule:
151
172
  self.required_modules_names = required_modules_names
152
173
  plain_spec.collect_linked_resources(plain_source, resources_list, None, True)
153
174
  self.resources_list = resources_list
175
+ self.functionalities_without_scenarios: list[tuple[str, str]] = []
154
176
  self.required_modules = []
155
177
  if len(required_modules_names) > 0:
156
178
  self.required_modules = [
@@ -161,6 +183,21 @@ class PlainModule:
161
183
  )
162
184
  for module_name in required_modules_names
163
185
  ]
186
+ if tests_folders is not None:
187
+ self._bind_test_scenarios(tests_folders, conformance_tests_enabled)
188
+
189
+ def _bind_test_scenarios(self, tests_folders: list[str], conformance_tests_enabled: bool) -> None:
190
+ """Add the scenarios of the test plain files under ``tests_folders`` to the functionalities of the chain.
191
+
192
+ With conformance tests enabled, a functionality with no test plain file stops the run here. A
193
+ functionality whose test plain file holds no scenario is recorded instead, so the run can warn
194
+ about it and go on without conformance tests for it.
195
+ """
196
+ chain = self._unique_chain()
197
+ bound = project.bind_test_plain_files(chain, tests_folders, self.template_dirs, self.template_dirs[0])
198
+ if conformance_tests_enabled:
199
+ project.check_test_plain_files(chain, bound)
200
+ self.functionalities_without_scenarios = _functionalities_without_scenarios(chain)
164
201
 
165
202
  @cached_property
166
203
  def all_required_modules(self) -> list[PlainModule]:
@@ -314,16 +351,34 @@ class PlainModule:
314
351
  # for every code-variable FR after a partial/interrupted render.
315
352
  metadata = self.load_module_metadata() or {}
316
353
  functionalities = metadata.get(MODULE_FUNCTIONALITIES, [])
317
- frid_index = int(frid) - 1
318
- frid_text = self._get_module_functional_requirements()[frid_index]
319
- if frid_index < len(functionalities):
320
- functionalities[frid_index] = frid_text
354
+ functionality = next(item for item in self._get_module_functional_requirements() if item["id"] == frid)
355
+ for position, stored in enumerate(functionalities):
356
+ if stored["id"] == frid:
357
+ functionalities[position] = functionality
358
+ break
321
359
  else:
322
- functionalities.append(frid_text)
360
+ functionalities.append(functionality)
323
361
  metadata[MODULE_FUNCTIONALITIES] = functionalities
324
362
 
325
363
  metadata_utils.write_metadata(self.module_metadata_path(), metadata)
326
364
 
365
+ def _unique_chain(self) -> list[tuple[str, dict]]:
366
+ """The chain as one entry per module, every module holding the one tree of its name.
367
+
368
+ A module reached through more than one `requires` path is parsed once per path, so the chain
369
+ would otherwise carry two equal trees for it. Only one of them would get the scenarios of the
370
+ test plain files, and which one the renderer then reads is a matter of which path it took.
371
+ """
372
+ chain: list[tuple[str, dict]] = []
373
+ trees: dict[str, dict] = {}
374
+ for module in self.all_required_modules + [self]:
375
+ if module.module_name in trees:
376
+ module.plain_source = trees[module.module_name]
377
+ continue
378
+ trees[module.module_name] = module.plain_source
379
+ chain.append((module.module_name, module.plain_source))
380
+ return chain
381
+
327
382
  def get_module_source_hash(self) -> str:
328
383
  return plain_spec.get_hash_value([self.plain_source] + self.resources_list)
329
384
 
@@ -361,15 +416,18 @@ class PlainModule:
361
416
 
362
417
  return module_metadata["source_hash"] != self.get_module_source_hash()
363
418
 
364
- def _get_module_functional_requirements(self) -> list[str]:
419
+ def _get_module_functional_requirements(self) -> list[dict[str, str]]:
420
+ """The functionalities of the module as `id` / `markdown` entries, in file order."""
365
421
  module_functional_requirements = []
366
422
 
367
423
  for functional_requirement in self.plain_source[plain_spec.FUNCTIONAL_REQUIREMENTS]:
368
- module_functional_requirements.append(functional_requirement["markdown"])
424
+ module_functional_requirements.append(
425
+ {"id": functional_requirement["id"], "markdown": functional_requirement["markdown"]}
426
+ )
369
427
 
370
428
  return module_functional_requirements
371
429
 
372
- def get_functionalities(self) -> dict[str, list[str]]:
430
+ def get_functionalities(self) -> dict[str, list[dict[str, str]]]:
373
431
  functionalities = {}
374
432
  for required_module in self.required_modules:
375
433
  functionalities.update(required_module.get_functionalities())
@@ -399,18 +457,19 @@ class PlainModule:
399
457
  metadata_utils.write_metadata(self.module_metadata_path(), self.get_hashes())
400
458
 
401
459
  def truncate_metadata_functionalities(self, frid: str | None) -> None:
402
- """Trim the stored functionalities list to the first int(frid) entries.
460
+ """Trim the stored functionalities list to end at the functionality ``frid``.
403
461
 
404
462
  The metadata file is not tracked in the module's git repo, so when the
405
463
  code repo is reverted to an earlier functionality the stored list must
406
- be trimmed to match the reverted code. A frid of None means no
407
- functionality is implemented (empty list).
464
+ be trimmed to match the reverted code. A frid of None, or one the module
465
+ no longer has, means no functionality is implemented (empty list).
408
466
  """
409
467
  metadata = self.load_module_metadata()
410
468
  if metadata is None:
411
469
  return
412
470
 
413
- keep_count = int(frid) if frid is not None else 0
471
+ frids = list(plain_spec.get_frids(self.plain_source))
472
+ keep_count = frids.index(frid) + 1 if frid in frids else 0
414
473
  if metadata_utils.truncate_functionalities(metadata, keep_count):
415
474
  metadata_utils.write_metadata(self.module_metadata_path(), metadata)
416
475
 
@@ -574,7 +633,7 @@ class PlainModule:
574
633
  last_rendered_module_name is not None
575
634
  and last_rendered_module_name == self.module_name
576
635
  and last_rendered_frid is not None
577
- and int(last_rendered_frid) >= int(frids[-1])
636
+ and last_rendered_frid == frids[-1]
578
637
  ):
579
638
  return True
580
639
 
@@ -5,7 +5,7 @@ import git_utils
5
5
  import plain_spec
6
6
  from plain2code_console import console
7
7
  from plain2code_exceptions import InternalClientError
8
- from plain2code_utils import AMBIGUITY_CAUSES
8
+ from plain2code_utils import AMBIGUITY_CAUSES, qualified_frid
9
9
  from render_machine.actions.base_action import BaseAction
10
10
  from render_machine.implementation_code_helpers import ImplementationCodeHelpers
11
11
  from render_machine.render_context import RenderContext
@@ -43,12 +43,14 @@ class AnalyzeSpecificationAmbiguity(BaseAction):
43
43
  fixed_implementation_code_diff,
44
44
  run_state=render_context.run_state,
45
45
  )
46
+ functionality = qualified_frid(render_context.module_name, render_context.frid_context.frid)
46
47
  if rendering_analysis:
47
48
  # TODO: Before this output is exposed to the user, we should check the 'guidance' field using LLM in the same way as we do conflicting requirements.
48
49
  console.info(
49
- f"Specification ambiguity detected! {AMBIGUITY_CAUSES[rendering_analysis['cause']]} of the functionality {render_context.frid_context.frid}."
50
+ f"Specification ambiguity detected! {AMBIGUITY_CAUSES[rendering_analysis['cause']]} "
51
+ f"of the functionality {functionality}."
50
52
  )
51
53
  console.info(rendering_analysis["guidance"])
52
54
  else:
53
- console.debug(f"No specification ambiguity detected for functionality {render_context.frid_context.frid}.")
55
+ console.debug(f"No specification ambiguity detected for functionality {functionality}.")
54
56
  return self.SUCCESSFUL_OUTCOME, None
@@ -1,6 +1,7 @@
1
1
  from typing import Any
2
2
 
3
3
  from plain2code_console import console
4
+ from plain2code_utils import qualified_frid
4
5
  from render_machine.actions.base_action import BaseAction
5
6
  from render_machine.implementation_code_helpers import ImplementationCodeHelpers
6
7
  from render_machine.render_context import RenderContext
@@ -26,7 +27,8 @@ class DistillConformanceTestMemory(BaseAction):
26
27
  if not fix_journals:
27
28
  return self.SUCCESSFUL_OUTCOME, None
28
29
 
29
- console.info(f"Distilling conformance test fix learnings for functionality {render_context.frid_context.frid}.")
30
+ functionality = qualified_frid(render_context.module_name, render_context.frid_context.frid)
31
+ console.info(f"Distilling conformance test fix learnings for functionality {functionality}.")
30
32
 
31
33
  try:
32
34
  _, existing_files_content = ImplementationCodeHelpers.fetch_existing_files(render_context.build_folder)
@@ -6,6 +6,7 @@ import plain_spec
6
6
  from memory_management import MemoryManager
7
7
  from plain2code_console import RETRY_COLOR, console
8
8
  from plain2code_exceptions import InternalClientError
9
+ from plain2code_utils import qualified_frid
9
10
  from render_machine.actions.base_action import BaseAction
10
11
  from render_machine.implementation_code_helpers import ImplementationCodeHelpers
11
12
  from render_machine.render_context import RenderContext
@@ -45,7 +46,8 @@ class FixConformanceTest(BaseAction):
45
46
  console.info(f"Running conformance tests attempt {ctx.fix_attempts + 1}.")
46
47
 
47
48
  console.info(
48
- f"Fixing conformance test for functionality {render_context.conformance_tests_running_context.current_testing_frid} in module {render_context.conformance_tests_running_context.current_testing_module_name}."
49
+ f"Fixing conformance test for functionality "
50
+ f"{qualified_frid(ctx.current_testing_module_name, ctx.current_testing_frid)}."
49
51
  )
50
52
 
51
53
  if not previous_action_payload.get("previous_conformance_tests_issue"):
@@ -126,11 +128,9 @@ class FixConformanceTest(BaseAction):
126
128
  render_context.get_required_modules_functionalities(),
127
129
  previous_frid_code_diff,
128
130
  existing_conformance_test_files_content,
129
- render_context.conformance_tests_running_context.get_current_acceptance_tests(),
130
131
  previous_conformance_tests_issue,
131
132
  render_context.conformance_tests_running_context.fix_attempts,
132
133
  render_context.conformance_tests_running_context.get_current_conformance_test_folder_name(),
133
- render_context.conformance_tests_running_context.current_testing_frid_high_level_implementation_plan,
134
134
  render_context.conformance_tests_running_context.conflicting_requirement_count,
135
135
  journal.build_digest(ctx.current_testing_module_name, ctx.current_testing_frid),
136
136
  run_state=render_context.run_state,
@@ -147,7 +147,7 @@ class FixConformanceTest(BaseAction):
147
147
  render_context.conformance_tests_running_context.conflicting_frid = current_testing_frid
148
148
  console.info(
149
149
  f"↻ Potential conflicting functionalities detected while fixing conformance tests "
150
- f"for functionality {current_testing_frid} in module {current_testing_module_name}.",
150
+ f"for functionality {qualified_frid(current_testing_module_name, current_testing_frid)}.",
151
151
  color=RETRY_COLOR,
152
152
  )
153
153
 
@@ -232,8 +232,10 @@ class FixUnitTests(BaseAction):
232
232
  def _functional_requirements_section(render_context: RenderContext, specifications: dict) -> str:
233
233
  sections = []
234
234
  for module_name, functionalities in render_context.get_required_modules_functionalities().items():
235
+ # A functionality of a required module is an `id` / `markdown` entry, not bare markdown.
235
236
  sections.append(
236
- f"### Module: {module_name} (Already Implemented, for context)\n" + "\n".join(functionalities)
237
+ f"### Module: {module_name} (Already Implemented, for context)\n"
238
+ + "\n".join(functionality["markdown"] for functionality in functionalities)
237
239
  )
238
240
  current = specifications.get(plain_spec.FUNCTIONAL_REQUIREMENTS, [])
239
241
  if len(current) > 1:
@@ -2,6 +2,7 @@ from typing import Any
2
2
 
3
3
  import file_utils
4
4
  from plain2code_console import console
5
+ from plain2code_utils import qualified_frid
5
6
  from render_machine.actions.base_action import BaseAction
6
7
  from render_machine.implementation_code_helpers import ImplementationCodeHelpers
7
8
  from render_machine.render_context import RenderContext
@@ -22,7 +23,11 @@ class RefactorCode(BaseAction):
22
23
  render_context.frid_context.refactoring_iteration += 1
23
24
 
24
25
  if render_context.frid_context.refactoring_iteration >= MAX_REFACTORING_ITERATIONS:
25
- error_message = "Refactoring iterations limit of {MAX_REFACTORING_ITERATIONS} reached for functionality {render_context.frid_context.frid}."
26
+ functionality = qualified_frid(render_context.module_name, render_context.frid_context.frid)
27
+ error_message = (
28
+ f"Refactoring iterations limit of {MAX_REFACTORING_ITERATIONS} reached "
29
+ f"for functionality {functionality}."
30
+ )
26
31
  render_context.last_error_message = error_message
27
32
 
28
33
  return (