StructOp Handbook
Contents Examples Commands
Handbook / What is StructOp?

How StructOp works

StructOp operates as a declarative layer above C and Rust. It reads declarations, checks them, plans the change and generates source through providers, then hands that source to the target’s own compiler. It does not replace those compilers or their ecosystems.

On this page

The architecture#

How StructOp turns declarations into an executable applicationA human developer or an AI development agent writes declarations. The StructOp engine reads them with the providers' schemas and templates, then parses and validates, resolves types and references, the run order and the providers, plans the change against recorded state, generates the execution graph, manages build state and generates native source for the C or the Rust target. The C compiler or Cargo compiles that source into the executable application.Human developerAI development agentDeclarationsintent.st · *.st filesProvidersschemas andtemplatesStructOp engine1 Parsing and validation2 Type and reference resolution3 Dependency resolution (run order)4 Provider resolution5 Change planning against state6 Execution graph generation7 Build state management8 Native source generationC targetmain.cRust targetmain.rsC compilerccCargocargo buildExecutable application.structop/build/app
One project builds for one target at a time, selected in intent.st.
  1. A human developer, an AI development agent or both write the declarations: intent.st and other .st files.
  2. Providers define the ability kinds a project can use and supply the C or Rust code for each.
  3. The StructOp engine checks, plans and generates, as the table below shows.
  4. The result is one generated source file, main.c or main.rs.
  5. The C compiler or Cargo compiles it.
  6. The executable application is written to .structop/build/app.

What goes in#

A project is a folder. StructOp reads every file in it whose name ends in .st, in name order, and the variable values in variables.stvars. Tests in tests/*.sttest are read only by structop test.

InputWhat it holds
intent.stThe structop block: the target language and standard, the providers and any exports. This is the intent of the project.
Other .st filesThe declarations: ability, data, constant, variable, parameter and module blocks.
Module foldersReusable groups of declarations, called with inputs and read through outputs.
ProvidersInstalled into .structop/providers/ by structop init and locked in .structop/providers.lock.

What the engine does#

StepWhat StructOp doesWhere you see it
CheckReads every file and checks the syntax, the types, the references and each ability against its provider.structop validate
OrderWorks out the run order from the declarations and what they depend on.structop plan, structop graph
PlanShows what would change since the last apply, before anything is built.structop plan
VisualiseDraws the application as a graph of run order, calls, dependencies and data flow.structop graph
Generate and buildWrites one C or Rust source file and has the target’s own compiler build it.structop apply
RecordRemembers what was built, so that the next plan explains the next change.structop state

What comes out#

PathWhat it holds
.structop/build/main.c or main.rsThe generated source for the selected target
.structop/build/appThe compiled program
.structop/state.jsonWhat the last apply built, keyed by resource address
Export pathsCopies of the program placed where export blocks say

How the parts relate#

PartRelationship
Application declarationsDescribe the application. They name ability kinds from providers and refer to each other by address.
Intentintent.st chooses the target and the providers for every other declaration.
Abilitiesability "KIND" "NAME" is the unit of data and behaviour. Its kind and attributes come from a provider.
ProvidersDefine ability kinds and supply the target-language code for each.
ModulesGroup declarations in a folder so that a project can use them more than once, with different inputs.
Native source generationTurns the declarations, in run order, into C or Rust through the providers.
Build stateRecords what was built, so the next plan can explain a change.
Target toolchainsThe C compiler (cc, or STRUCTOP_CC) or Cargo compile the generated source.
Generated application artefactsThe source file, the program and any exports.

Works with your toolchain#

StructOp works with the native toolchain you already have: the C compiler, Cargo and the libraries a project binds are the ones installed on your machine. The generated source is ordinary C or Rust, so the target’s debuggers, profilers and analysis tools work on it as they do on any other program.