Rerender single functionality#216
Conversation
|
|
||
| terminal_frid = ( | ||
| list(plain_spec.get_frids(self.plain_source_tree))[-1] if self.is_rerender else ctx.frid_being_implemented | ||
| ) |
There was a problem hiding this comment.
I changed this in order to run the whole collection of conformance tests.
e.g.: if you have a project with 4 FRs and you rerender FR 2 it will run the conformance tests like 2, 1, 3, 4. When not rerendering it still only runs the tests up to the one that is currently being implemented.
| self._setup_test_specifications() | ||
| if not ctx.current_conformance_tests_exist(): | ||
| return | ||
|
|
There was a problem hiding this comment.
This is here in order to skip the tests for FR 2 (if we take the example from the comment above). The conformance tests for FR 2 have already passed at this point.
| ), | ||
| f"{States.IMPLEMENTING_FRID.value}_{States.PROCESSING_CONFORMANCE_TESTS.value}_{States.POSTPROCESSING_CONFORMANCE_TESTS.value}_{States.CONFORMANCE_TESTS_READY_FOR_AMBIGUITY_ANALYSIS.value}": AnalyzeSpecificationAmbiguity(), | ||
| f"{States.IMPLEMENTING_FRID.value}_{States.FRID_FULLY_IMPLEMENTED.value}": FinishFunctionalRequirement( | ||
| git_utils.FUNCTIONAL_REQUIREMENT_FINISHED_COMMIT_MESSAGE |
There was a problem hiding this comment.
Not needed anymore since the action now constructs its own commit message (because it needs render_context.is_rerender to construct it)
| .coverage | ||
| logging_config.yaml | ||
|
|
||
| .claude/worktrees/ No newline at end of file |
There was a problem hiding this comment.
Unrelated change: was wokring in a worktree and this directory kept popping up in the changes and I think we should ignore it if you're using worktrees.
| os.makedirs(codeplain_folder, exist_ok=True) | ||
| with open(self.module_metadata_path(), "w", encoding="utf-8") as f: | ||
| json.dump(metadata, f, indent=4) | ||
|
|
There was a problem hiding this comment.
This causes the JSON's content to be out of order but I don't think that's important because JSON by standards doesn't need to have ordered keys.
e.g.: if you render a project with FRs 1, 2, 3 and then rerender 2, you would get the content of the module_metadata.json file as: { "1": {...}, "3": {...}, "2": {...},}
24d6304 to
820cc30
Compare
4d34831 to
81b94d5
Compare
- New `--rerender N` CLI flag renders a single FRID on top of current HEAD without reverting the build repo, unlike `--render-range`/`--render-from` - PrepareRepositories validates the target FRID and loads the old spec text from module_metadata.json so the LLM can produce a targeted patch - Stale conformance tests for the FRID are deleted (uncommitted) before rendering so CommitConformanceTestsChanges picks them up naturally - FinishFunctionalRequirement and CommitConformanceTestsChanges select FUNCTIONAL_REQUIREMENT_REIMPLEMENTED_COMMIT_MESSAGE at runtime via render_context.is_rerender, keeping --render-range revert logic intact - get_last_rendered_functionality searches both "implemented" and "reimplemented" patterns and returns the more recent match
update_frid_in_module_metadata writes the spec text for the just-finished FRID into .codeplain/module_metadata.json before the FRID checkpoint commit, so every git commit in the build repo contains an up-to-date functionalities array. This makes old spec text available to --rerender even after git clean. For a rerender it updates the existing slot in-place rather than appending.
820cc30 to
a3d6131
Compare
This adds a way to rerender a single functionality in a project that has been completely rendered before.
Usage:
codeplain --rerender 2 project.plainHow it works:
render_functional_requirementcall. It also instructs the model to do a rerender and that code related to old specs must be removed (see https://github.com/Codeplain-ai/plain2code_rest_api/pull/105)Example
Example run on a project with 4 FRs:
Then I changed number 3 to:
and I ran it with
--rerender 3.This are the logs:
codeplain.log
The commits in the rendered module:
Commits in the conformance_tests:
The conformance tests:
And the implementation code was changed too and the stuff related to the old spec was removed.
80cf5ee7-bcb5-4094-b293-e0d73a57f45cAdditional notes:
--render-from Non a project that has had--rerenderused on it will still make the tool render the range from N-1. The "reimplementation" commits will get discarded anyway.impr/state-machine-cleanupbranch, I will rebase this once that's merged