Skip to content
SheetForge

Authoring kernel

The authoring kernel is the engine behind the Data Studio. This page names the public types you drive to build your own editing tool on that engine, such as a node-graph canvas.

Before you build an editing tool

This page is advanced. It is for asset and tool authors who want their own editing tool on top of the SheetForge engine. Game teams that use the Data Studio do not need it.

Before you build a whole editing tool, check whether an extension point already covers the need. A plugin can add verbs, panels, badges and cell widgets to the Data Studio without owning a window at all. They are described as data, so they render in the editor and in the browser. See Authoring surfaces.

Read on if you want your own canvas.

The kernel and its consumers

The Data Studio is not the engine itself. The Data Studio and the browser app beside it are both consumers of a window-agnostic authoring kernel.

Everything they do runs through public types: staging, validation, reflect orchestration, undo boundaries and re-import. How an edit reaches the sheet shows that cycle from the user's side. A third editing tool can drive those types the same way. Two editing tools already do.

The executable specification

SheetForge.Tests.Consumer is a consumer-simulation test assembly. It has no InternalsVisibleTo access into Core or Editor. It implements a virtual editing tool end to end against the public API alone.

If any member it needs were internal, that assembly would fail to compile (CS0122). So it serves as the executable specification for the public API described on this page.

The three-object engine

┌─────────────────────┐     ┌──────────────────────────┐     ┌───────────────┐
│  AuthoringSession   │────▶│   AuthoringDispatcher    │────▶│ BaselineStore │
│  (staging state)    │     │   .Reflect()             │     │ (round-trip   │
│                     │     │   (the full cycle)       │     │  snapshots)   │
└─────────────────────┘     └────────────┬─────────────┘     └───────────────┘
                                         │ binds
                            ┌────────────▼─────────────┐
                            │ AuthoringDispatchCallbacks│
                            │ (view concerns — YOUR UI) │
                            └──────────────────────────┘
ObjectRole
AuthoringSessionThe staging state
AuthoringDispatcherThe reflect orchestration
AuthoringDispatchCallbacksThe contract your UI binds

The dispatcher also takes a BaselineStore, which holds the round-trip snapshots.

AuthoringSession

AuthoringSession holds the staging state. It is a [Serializable] plain class, deliberately not a ScriptableObject (SO).

Hold the session in a [SerializeField] field of your EditorWindow. That field gives you Unity-native Undo snapshots and domain-reload survival. The Data Studio's Ctrl+Z runs on the same mechanism.

Staged state

The session owns all staged state.

MemberStaged state
EditsCell edits
NewRowsNew rows
StructOpsStructure ops
ReordersPer-tab reorders
TabRenamesTab renames

The session also owns the baseline anchors and the isolated edits. On top of that state, it exposes the mutation and query API described in the next sections.

Stage a cell edit

SetStaged(...) stages a cell edit.

An edit carries a logical address: tab, RecordId and field. The physical row ordinal is a derived cache. It is re-resolved just before reflect.

Re-anchor edits to the baseline

ResolveBaselineEdits(provider) re-anchors all edits against the current baseline. Resolvable edits proceed.

An edit that cannot be resolved moves to IsolatedEdits. An isolated edit is excluded from reflect and badged. It is never silently dropped, and it never blocks the session.

Isolated edits lists the sheet changes that leave an edit unresolvable.

Read the baseline

TabNames and TryGetBaselineTable(tab, out SheetTable) are the baseline read surface. They give typed schema access without touching the parser yourself. The schema covers TypeToken, @desc and @overlap.

Other session members

MemberRole
EffectiveStructOps(), PendingStructCount()The composed, canonical structure-op view
RemapFieldName, RemapRecordId, RemapTabRemap hooks
LastProjectionResultCaches the latest projection

The remap hooks keep staged state coherent across renames.

AuthoringDispatcher

AuthoringDispatcher orchestrates the reflect. One call runs the entire cycle.

var dispatcher = new AuthoringDispatcher(session, callbacks, baselineStore);
dispatcher.Reflect();   // the entire cycle, one call

The reflect cycle

Reflect() runs the whole cycle, in this order:

  1. Pre-flight validation
  2. Per-source reflect
  3. Retained-state cleanup
  4. The ClearUndo confirm boundary
  5. Automatic re-import with report

The per-source reflect depends on the source.

SourceReflect
LocalSurgical writes
GoogleSafe rewrite
Custom providerYour own target

Project the staged state

BuildProjectionResult() returns a projection of the current staged state as an ImportResult. A projection is the baseline with your staged edits applied. The projection validates the staged state as if it were reflected. It has no side effects.

Use it for live error badges.

Public members for providers

Session, Callbacks and Baselines are public. Custom source providers use them to assemble their reflect targets.

AuthoringDispatchCallbacks

AuthoringDispatchCallbacks is the contract your UI binds. It is a bundle of 13 general delegates. The dispatcher calls them for every view concern. The engine never draws UI itself.

The bundle includes these delegates, among others:

  • ResolveSettings
  • Confirmation dialogs, such as ConfirmKeyRenames and ConfirmTabRenames
  • RenderReport
  • PushApprover
  • TriggerReimport
  • ClearUndo
  • Rebuild

RenderReport is an Action<ImportReport>. It is observational, so a null value is tolerated.

What your editing tool binds

The Data Studio binds defaults that show dialogs. Your canvas binds its own delegates, or no-ops.

Built-in source dialogs

The 14 dialog delegates specific to the built-in local-file and Google sources live in a separate bundle, BuiltInSourceDialogs. That bundle is opt-in. An external editing tool or provider never needs to bind it.

Types that build the graph

These types serve a graph view where node = record and edge = reference ∪ declaration.

TypeAssemblyRole
ReferenceScannerCoreEnumerates reference occurrences
IEdgeContributor, EdgeSpec, EdgeContributorRegistryCoreEdges the scanner cannot see
ReferenceIndex, RecordEdgeCoreThe assembled snapshot
IRecordCanvasAugmenter, CanvasAugmentBuilderCoreThe per-tab override contract
ProjectionErrorMapperEditor, purePhysical coordinate to logical address

Reference scanner

ReferenceScanner is the single source of truth for enumerating reference occurrences across all tables. It covers scalars, list elements and explicit defaults.

The reference validator uses the same enumeration, so your graph and the validation always agree.

Its members are Scan(tables), ScanTable, ScanField and IsReferenceField.

Edge contributors

Through IEdgeContributor, EdgeSpec and EdgeContributorRegistry, domain plugins declare edges the scanner cannot see:

  • Edges inside custom-type values
  • type-column links
  • Record-edges with a payload record

Collect the contributors through the Editor PluginRegistry.BuildEdgeContributors.

Reference index

ReferenceIndex and RecordEdge are the assembled snapshot that the Data Studio's own record canvas runs on.

Build(...) merges the scanned references with the contributor edges once. After that, OutEdges, InEdges and InCount answer in O(1) per record.

The full member list is in ReferenceIndex in the API reference.

Canvas overrides

IRecordCanvasAugmenter and CanvasAugmentBuilder are the per-tab override contract. Use them if you want domain plugins to extend your canvas the same way they extend the Data Studio's record canvas: with virtual nodes, extra edges, and layer and display hints.

Projection error mapper

ProjectionErrorMapper maps the physical coordinate of a projection error to a logical address.

CoordinateParts
Physicaltab, row, field
Logicaltab, RecordId, field

With the logical address you can pin error badges to nodes rather than row numbers.

Supporting types

TypeWhat your editing tool uses it for
ImportEventsHear that an import finished or a sheet snapshot was saved
IPipelineObserverThe lighter path when the listener is a plugin
RecordIdMinterSuggest ids for new records
EphemeralSoApplyPreview staged values on baked SOs
KeyRenamePlannerPlan key renames
SourceProviderRegistryResolve the active source provider the same way the settings UI does

Import events

ImportEvents has two buses. Both are public contracts.

EventArgsArgs carryFires
ImportCompletedImportCompletedArgsTabs, BakeFolderWhen the auto-chain has run all the way through bake
BaselineUpdatedBaselineUpdatedArgsTabs, QuarantinedWhenever a sheet snapshot was saved

After ImportCompleted, a subscriber may read the baked assets.

BaselineUpdated also fires for a run that failed validation. Subscribe to it if your editing tool shows the failed sheets and lets people fix them.

If your view shows sheets and baked values, subscribe to both. Unsubscribe symmetrically in OnDisable.

Workbook identity in notices

Both args types also carry SettingsGuid and SettingsPath. They name the workbook a notice is about. When no workbook is named, they are empty, never null.

With them, a subscriber can tell apart workbooks that finish one after another in a joint import or a Pull every workbook run.

Pipeline observer

If the thing that needs to know is a plugin rather than a window, IPipelineObserver is the lighter path.

Register an observer. It receives an immutable PipelineRunView at the end of each import cycle. The observer has no editor dependency at all, so it works in the browser host too.

See Watch the pipeline.

Record id suggestions

RecordIdMinter suggests ids for new records. It detects the prefix and makes the id unique in a collision-safe way.

It is a suggestion API, deliberately not automatic numbering.

Preview on baked assets

EphemeralSoApply previews staged values onto baked SOs temporarily. A re-import restores them.

It applies the computable subset. It returns skip reasons for pending columns and parse failures.

Nothing in the shipped UI drives it. An editing tool that wants this preview owns the button for it.

Key rename planning

KeyRenamePlanner plans key renames the same way the Data Studio does. The plan has three stages: extraction, propagation and the surgical write.

Tab-rename confirmations do not use the planner. They flow through the public ConfirmTabRenames callback.

Ground rules

The kernel enforces these rules, and your editing tool inherits them.

  • The sheet stays canonical. Your editing tool stages and reflects. It never writes SOs.
  • Validate, then reflect. Reflect() writes nothing if pre-flight fails.
  • No silent loss. Unresolvable edits isolate with a reason. Confirmations pass through your callbacks.
  • Undo integrates natively. Keep the session in a serialized field and register undo snapshots on your window. ClearUndo marks the reflect boundary.
  • The kernel is domain-agnostic. It contains zero domain vocabulary, and SheetForge's own tests check that. Your domain arrives through the plugin contracts, not through kernel edits.

Next steps