Editing
I decided it is time to start writing tests for the editing functions using the JobQueue, and DocCache. In other words, it was time to wire up the components into a the beginnings of a real editor service.
I described the design in the README.md in the services directory
I first wrote a test for DocumentHydrator, then prompted it to make the DocumentHydrator class:
read @src/dockb/services/README.md and implement the DocumentHydrator class so it matches
@tests/dockb/services/semantics/test_document_hydrator.py
This worked perfectly, and it shows how well TDD works with an LLM. I then went on to do the same to make the other hydrators.
Now I need to create the equivalent of the AsyncSentenceReconstructor, and the SyncSentenceReconstructor, for Document, Chapter, and Paragraph. I wrote the design document and the tests.
Then I realised that the 4 Sync... and 4 Async... classes, and the 3 Hydrators and the SentenceTokenizer were so similar, I could combine them. I ended up with:
- DocumentHydrator
- ChapterHydrator
- ParagraphHydrator
- SentenceTokenizer
- Reconstructor (abstract)
- SyncReconstructor (implements Reconstructor) - really only used in tests...
- AsyncReconstructor (implements Reconstructor)
Now the thing is, that when a model's set_text() method is called, I really want the AsyncReconstructor to be automatically triggered, but its constructor must be passed a DocCache, and JobQueue, which the models are ignorant of, and I don't want to have to pass them to the set_text() function. That would be really awkward and would cause a dependency nightmare.
Therefore, the models need to optionally trigger a listener.
The models need to use the DockbCollection
class (which I'd created a day or so ago, but not used) rather than just a simple List.
I can make this collection class help to auto-parent models that are added to it, and the
models can maintain a reference to their own parent.
The editing functions in DockbBase are not needed either... so I instructed
the LLM to remove them and clean up their associated tests.
Then I designed the automatic parenting (documented in the README.md) made a test
and told the LLM to implement it.
At this stage now, I need to design how the editing will work.
By the way... I was talking to a colleague, complaining about how OpenCode is inclined to go ahead
rather than wait for me to instruct it to write code, and he said, "It has a plan mode,
you push TAB."
Embarrassing! Yes that helps a lot!