\clearpage \section{Planned Transaction Design}\label{Section:TransactionDesign} \index{transaction}\index{undo and redo} The agreed behavior is defined by the category registers in \ChapterRef{Requirements}: Functional (Table~\ref{Table:FunctionalRequirements}), Data (Table~\ref{Table:DataRequirements}), Interface (Table~\ref{Table:InterfaceRequirements}), and Architectural (Table~\ref{Table:ArchitecturalRequirements}). The undo/redo behavior and architectural responsibilities are agreed; the representations and operation names below are implementation sketches. For the prototype, Vincent approved unbounded session snapshots on November 24; a measured memory budget, eviction and provider-dependent retained work remain future decisions in \ChapterRef{OpenDesignDecisions}. Agreed design does not mean implemented code. The current code implements coordinate batches, whole-element moves and rectangle resizing; session history now supports these coordinate edits; generic transactions remain unimplemented. Rectangle plugin loading is recorded in Section~\ref{Section:CurrentPlugin}. The current class diagrams remain source-based. The bounded implemented \texttt{tkrEditService} is described in Section~\ref{Section:ClassEditService}; its future generic transaction contract below remains proposed. Figure~\ref{Figure:TransactionActivity} is a separately labelled planned activity. Collaborator ownership and provider role boundaries were reviewed in October; November provider decisions are controlled in Section~\ref{Section:PluginContract}; detailed mechanisms and preview scheduling remain open. \subsection{Proposed Data Records} These are proposed representations of the requirements, not C++ declarations or a frozen plugin ABI. \RequirementRef{REQ-D-008} defines proposal contents; \RequirementRef{REQ-F-012} and \RequirementRef{REQ-D-004}--\RequirementRef{REQ-D-007} define restoration, revision and saved-state behavior. Exact before/after snapshots with an operation description are the proposed initial history storage, now used by the bounded implementation without automatic eviction. Memory limits and optimization await measurements. The current \texttt{CoordinateEdit} remains unchanged in code. % Local table size keeps the caption and final rows together. \begingroup\small \begin{tabularx}{\linewidth}{@{}L{3.5cm}Y@{}} \caption{Planned Transaction Records\label{Table:TransactionRecords}}\\ \toprule\textbf{Record} & \textbf{Planned contents and contract}\\ \midrule\endhead\bottomrule\endfoot \texttt{SourceEdit} & Original byte range, expected original bytes, replacement bytes. Supports insertion/deletion/replacement; carries no graphics-item pointer.\\ \texttt{EditTransaction} & Document identity, base revision, operation description and a collection of source edits, all using the same original source revision.\\ History entry & Exact before/after source bytes and operation description. The entry's history position is distinct from the monotonically advancing document revision and the saved-source baseline.\\ \end{tabularx} \endgroup The previous team's TikZiT-based MGB-UML source provides a core parser plus plugins for palette metadata, Qt node drawing and TikZ output, with an SDK and starter template~\cite{MgbPluginSdk}. Its graph/export approach is a reference, not evidence that the source-preserving contract is implemented. The reviewed interface has no syntax-provider parsing hook. Source inspection did not include building or running that application; no reference code was imported into TikZRefinery. \clearpage \subsection{Planned Class Collaboration}\label{Section:PlannedTransactionClasses} The October 27--30 review settled the planned ownership: the main window continues to own document/controller; the document owns history; the controller owns the edit service and file store. Owning services supports coordination, not coordinate arithmetic, history bookkeeping or filesystem logic in the controller. The bounded edit service and document-owned history exist; file-store extraction and the generic transaction extension remain unimplemented. Current source-based diagrams distinguish thirteen host classes (ten core plus three sidebar UI classes) from the provider interface/module; see Figures~\ref{Figure:CurrentClasses} and~\ref{Figure:CurrentSidebarClasses}. The document calls history methods to record changes and retrieve restoration targets. Candidate source and history storage must be prepared before either is published; all required state changes succeed together. History supplies restoration bytes and advances its position only with successful restoration. The file store returns read/write results to the controller, which requests document load or saved-baseline updates only after successful I/O. Requirements \RequirementRef{REQ-A-012}--\RequirementRef{REQ-A-014} and \RequirementRef{REQ-D-002} control these boundaries. \begin{figure}[htbp] \centering \resizebox{\linewidth}{!}{\input{../assets/design-diagrams/transaction-classes.tex}} \caption[Planned generic transaction collaborators]{Planned transaction collaborators. Explicit labels identify planned roles; diamonds show reviewed planned ownership. Current source classes remain as shown in Figure~\ref{Figure:CurrentClasses}. \label{Figure:PlannedTransactionClasses}} \end{figure} \clearpage \subsection{Responsibility and Design Review}\label{Section:ResponsibilityReview} Vincent requested periodic whole-design review and asked that findings from the separate chat \emph{Research class size guidelines} inform it. Prefer one coherent responsibility; accept closely related work when justified and review independent growth before adding another concern. A diagram's bullet count is not a responsibility count: origin/scale validation and forward/inverse conversion all support coordinate mapping. Martin's explanation groups work by reasons for change~\cite{MartinSRP}. That investigation proposed a practical target below 300 code lines, review at 500, and refactoring or an explicit exception at 1,000. These remain proposed project review thresholds, not universal limits or approved hard coding rules. Count nonblank, non-comment-only lines across the header/implementation for a class and also inspect supporting helpers; monitor physical file length separately. The earlier observed controller/scene pairs contained 369/308 physical lines including comments, blanks and helpers; these dated totals are not current code-line counts after the history increment. The controller merits review because persistence, edit planning and UI coordination have different reasons for changing, independent of its length. \begin{tabularx}{\linewidth}{@{}L{4.4cm}Y@{}} \caption{Responsibility Review Directions\label{Table:ResponsibilityReviewDirections}}\\ \toprule\textbf{Component} & \textbf{Review direction}\\ \midrule\endhead\bottomrule\endfoot Controller & Coordinate requests and notifications; delegate editing/history and persistence through explicit collaborators.\\ Document and history & Keep authoritative source/revision/saved state separate from history bookkeeping; publish accepted changes consistently.\\ Scene and mapper & Retain scene interaction and one coordinate mapping. Review extraction of rendering as plugin geometry grows.\\ Plugin infrastructure & Separate module loading/lifetime from provider registration/selection as needed; do not grow one manager into all editor roles.\\ \end{tabularx} Completed review now covers transaction collaborators, label/source-binding separation, attachment/local edits, overlap selection and provider boundaries. Reviewed registration, operation and lifecycle policy is now in Section~\ref{Section:PluginContract}. Detailed syntax ambiguity, loader wiring and preview scheduling remain subsequent implementation review. Update requirements, tests, diagrams and traceability as decisions settle. Existing source-based diagrams remain current until refactoring is implemented. \TestCaseRef{TC-034}--\TestCaseRef{TC-043} are planned checks, not new results. \clearpage \subsection{Reviewed Operation Contracts}\label{Section:ReviewedOperations} Names below are interface sketches, not current C++ declarations or a frozen ABI. All proposal ranges refer to one original revision. \RequirementRef{REQ-I-006} distinguishes Applied, Unchanged and Rejected; rejection carries a reason. Cancellation is intentional and does not create an error/history entry. \begingroup \small \begin{tabularx}{\linewidth}{@{}L{4.4cm}L{4.2cm}Y@{}} \caption{Reviewed Planned Operations\label{Table:ReviewedOperations}}\\ \toprule \textbf{Component} & \textbf{Operation sketch} & \textbf{Contract}\\ \midrule\endfirsthead \toprule \textbf{Component} & \textbf{Operation sketch} & \textbf{Contract}\\ \midrule\endhead\bottomrule\endfoot \texttt{tkrEditService} & \texttt{prepareEdit}\newline\texttt{(snapshot, request)} & Read-only snapshot and semantic intent in document coordinates; prepare candidate and supported-operation checks; return transaction or rejection. No live model/UI mutation.\\ \texttt{tkrTikzDocument} & \texttt{applyTransaction}\newline\texttt{(transaction)} & Final identity/revision/range/byte checks; atomically publish accepted source and history. No-op preserves history and redo.\\ \texttt{tkrTikzDocument} & \texttt{undo(), redo()} & Retrieve history target, prepare restoration and coordinate source/position update. Advance revision; do not append another edit entry.\\ \texttt{tkrTikzDocument} & \texttt{loadSource(), markSaved(snapshot)} & Successful replacement resets history. Successful save records the actual written bytes as baseline and retains history. A preceding explicit successful Save remains effective if Open later fails.\\ \texttt{tkrEditHistory} & Record change; retrieve target; complete restoration; reset & Own exact before/after bytes, descriptions and cursor in memory. Calls that mutate history are coordinated through the document; no scene/file access.\\ \texttt{tkrDocumentFileStore} & \texttt{read(path), write(path, bytes, baseline)} & Read source or perform guarded write; return bytes/results to controller. External-change comparison retains its concurrent-write race limitation. No history logic.\\ \end{tabularx} \endgroup \clearpage \subsection{Planned Collaborator Class Details} The diagram shows planned extensions of the existing document and edit service, plus two new collaborators: history and the extracted file store. Arrows in Figure~\ref{Figure:PlannedTransactionClasses} give their dependencies; these are reviewed future contracts, not claims of refactoring already performed. \begin{landscape} \begin{figure}[ht] \centering \resizebox{!}{13.4cm}{\input{../assets/design-diagrams/transaction-details.tex}} \caption[Planned generic collaborator contracts]{Reviewed planned document, service, history and file-store contracts. Visibility is UML-style; exact C++ signatures and storage mechanisms remain implementation details.\label{Figure:TransactionDetails}} \end{figure} \end{landscape} \clearpage \subsection{Elements, Source Bindings and Attachments}\label{Section:ElementContracts} The current two-point \texttt{ElementRecord} remains unchanged in code. The reviewed design separates information needed for display from source rewriting and per-binding operations (\RequirementRef{REQ-D-009}--\RequirementRef{REQ-D-012}). Record names below are sketches. Interpreted positions use document coordinates; screen/zoom coordinates remain a presentation concern. IDs and host references are valid only in their document revision and are rebuilt after acceptance. \begingroup \small \begin{tabularx}{\linewidth}{@{}L{5.0cm}Y@{}} \caption{Reviewed Shared Element Information\label{Table:ElementInformation}}\\ \toprule \textbf{Record} & \textbf{Reviewed information boundary}\\ \midrule\endfirsthead \toprule \textbf{Record} & \textbf{Reviewed information boundary}\\ \midrule\endhead\bottomrule\endfoot \texttt{ElementDescription} & Document/revision/element identity, element type, interpreted geometry, relevant text and appearance. Type/schema versions must be documented; exact schema remains open.\\ \texttt{SourceBinding} & Responsible syntax-provider identity, original byte ranges and provider information needed for edits; no graphics-item pointer. Equivalent display may have different bindings.\\ \texttt{AttachmentRecord} & Host reference and relative placement rule, including supported along-host position and offset. Calculated canvas position is derived; attachment is not C++ ownership.\\ \texttt{PresentationDescription} & Drawing description, selection geometry and readable element description; scene creates/owns graphics items. Selection bounds are not editable coordinate pairs.\\ \texttt{AvailableOperations} & Per-element/binding supported intents and constraints; display support does not imply edit support. Label movement requires a supported syntax route.\\ \end{tabularx} \endgroup \clearpage \begin{figure}[ht] \centering \resizebox{\linewidth}{!}{\input{../assets/design-diagrams/element-contracts.tex}} \caption[Planned shared element contracts]{Planned record and provider boundaries. Provider boxes describe reviewed roles rather than additional implemented classes. Records contain data; document acceptance remains authoritative.\label{Figure:ElementContracts}} \end{figure} \clearpage \subsection{Reviewed Label and Selection Interaction}\label{Section:LabelSelectionDesign} \UseCaseRef{UC-005} and \UseCaseRef{UC-006} define the author goals; their requirements and planned checks are authoritative. A label can move along and away from its host while preserving attachment and unrequested text, style, rotation and anchor/alignment. The host geometry is unchanged during label movement; moving the host carries the label. A local edit preserves shared coordinates/styles/macros; if no supported independent adjustment exists, movement is unavailable with a reason. Detachment is explicit later work, requiring a supported structural rewrite in one transaction. Normal hit selection prioritizes the label. A direct right-click lists all selection geometries intersecting a 6-logical-screen-pixel radius circle, including obscured hosts. This is an initial user-review setting, not a measured usability threshold. The radius stays constant on screen under zoom. Readable menu entries highlight their candidates. An empty-canvas left drag draws a retained rectangle; the Select area tool permits starting over objects. Right-clicking inside lists partial/full intersections; choosing an entry selects one object. Region creation never edits source or automatically selects a group; Escape clears it. Selection of an obscured host must survive the subsequent drag-start hit test rather than being replaced by the top label. One rejected completed edit shows a nonmodal bottom strip with bright red icon, red accent and readable reason, until dismissed or the next completed operation. Pointer previews produce no repeated rejection messages. Applied edits are visible; unchanged/cancelled gestures create no error or history entry. \subsection{Reviewed Provider Boundary}\label{Section:ProviderBoundary} \RequirementRef{REQ-A-015}--\RequirementRef{REQ-A-017} control the shape/syntax distinction, stable routing and capability intersection. Shape providers return interpreted proposals; syntax providers retain original source bindings and prepare rewrites. The host validates and the document accepts. The scene creates/owns graphics items. Section~\ref{Section:PluginContract} defines the reviewed data/operation contracts and lifecycle policy; detailed mechanisms still appear in \ChapterRef{OpenDesignDecisions}. \clearpage \subsection{Rectangle Resize and Shape Plugin}\label{Section:RectanglePluginPlan} On November 3, Vincent reported the instructor's direction: implement scaling for the existing box, then turn the box into a shape plugin. For this increment, scaling means changing rectangle dimensions in the source. Canvas zoom changes only the view. \RequirementRef{REQ-F-025} and \RequirementRef{REQ-A-018} record the planned behavior; \TestCaseRef{TC-060} and \TestCaseRef{TC-061} define its baseline and plugin checks. Vincent approved corner resizing on November 5 and refined crossing, minima and boundary handling on November 12. The implemented baseline preserves the opposite corner, allows crossing, retains independent $0.01$ cm dimensions and clamps to the furthest stroke-aware valid geometry. Exact coincidence and insufficient crossing space retain the nearest feasible side. Preview is temporary; release applies one guarded batch. See \RequirementRef{REQ-F-025}, \RequirementRef{REQ-I-013} and \TestCaseRef{TC-060} for the controlled rules. Aspect-ratio locking and edge handles remain deferred. \begingroup \small \begin{tabularx}{\linewidth}{@{}L{3.6cm}Y@{}} \caption{First Shape Plugin Design Decisions\label{Table:RectanglePluginDesign}}\\ \toprule \textbf{Concern} & \textbf{Decision}\\ \midrule\endhead\bottomrule\endfoot Order of work & Establish resize behavior on the current box fixture. Extract the rectangle provider and verify the same display, move, resize and save/reopen behavior with the separately loaded plugin. Keep the explicit-coordinate parser for this bounded increment.\\ Shape API & One versioned interface for shape geometry, presentation and supported editing operations. A provider can compute resize geometry and propose a change; source bindings still determine valid rewrites, and the document remains the final authority over source and history.\\ Strategy & The host delegates shape-specific behavior through the common interface. The rectangle provider can supply those operations directly; different shapes or resize behaviors can supply other implementations~\cite{ShapeStrategy}.\\ Abstract Factory & Optional inside a provider that needs to construct matching components. A provider can create and reuse a renderer, hit tester and resize handler internally without requiring factory calls in the editor API~\cite{ShapeAbstractFactory}.\\ Interaction cost & Reuse providers and their components across gestures. Pointer updates change temporary geometry; source edit preparation and validation occur on release. Measure responsiveness in the working prototype.\\ Loading & Qt's application-plugin interface and \texttt{QPluginLoader} are the candidate loading mechanism~\cite{QtShapePlugins}. The reviewed compatibility policy is in Section~\ref{Section:PluginLifecycle}; exact ABI, build wiring and any TikZ-only import format remain open.\\ \end{tabularx} \endgroup Resize evidence is scoped in Section~\ref{Section:RectangleResizeCheck}. The bounded rectangle plugin is loaded in the current package; broader provider management and product acceptance remain pending.