Built-in templates reference
Use these names with pyfcstm generate --template <name>. Do not use a
repository templates/ path as the ordinary built-in entry point; that path is
maintainer source.
All current built-in templates are marked experimental: true in packaged
metadata. In this reference, experimental means the generated output has the
current repository’s test and smoke evidence, but it is not presented as a
production certification or every-platform guarantee.
The hidden template-ref-profile markers above include a core value used
only by the documentation drift checker. It is a docs-internal derived field
from generated files and template tests, not a public metadata key in
template.json or index.json.
Metadata matrix
The table combines pyfcstm/template/index.json with
templates/<name>/template.json. archive and root_dir come from the
packaged index; the remaining visible metadata is mirrored by the source
template.json files.
Name |
Title |
Language |
Archive / root |
Experimental |
Description |
|---|---|---|---|---|---|
|
Python |
|
|
|
Native Python built-in template with embedded runtime logic. |
|
C99 |
|
|
|
Native C99 built-in template with embedded runtime logic and abstract hook callbacks. |
|
C Poll |
|
|
|
Native C99 / C++98 built-in template with hook-polled events and embedded runtime logic. |
|
C++ Wrapper |
|
|
|
Early-stage first-class C++ template that reuses the C99 runtime core and emits C++ wrapper files. |
|
C++ Poll Wrapper |
|
|
|
Early-stage first-class C++ poll template that reuses the C poll runtime core and emits C++ wrapper files. |
Discovery API
The public package API in pyfcstm.template is intentionally small:
Function |
Use |
Boundary |
|---|---|---|
|
Return installed built-in template names in packaged-index order. |
Discovery only; it does not render or validate a model. |
|
Check whether one name is present. |
Raises index load errors if package metadata is missing or invalid. |
|
Return a shallow copy of one metadata entry. |
Raises |
|
Extract the packaged archive into a normal directory for the renderer. |
In a development checkout, may copy repository source if the archive is absent. |
Generated README contract
Every built-in template emits README.md and README_zh.md. Those files
are generated from the model and should be treated as the concrete integration
contract for that generated machine. They provide names and ids that cannot be
fully known in this generic reference: class names, C prefixes, hook names,
event ids, state ids, hot-start examples, and target build snippets.
Template contracts
python
Generated files:
machine.py,README.md, andREADME_zh.md.Entry point: import the generated machine class from
machine.py. For the tutorial model this class isSimpleMachineMachine.Event model:
cycle(events=None)accepts no event, one event string, or a collection of event strings.Extension point: subclass the generated class and override protected abstract hook methods listed in the generated README.
Lifecycle concepts: construction, initial
cycle(), latercycle(...)calls, hot start through constructor arguments, current-state and variable snapshots.Target boundary: Python 3.7+ standard library runtime; generated code should not import
pyfcstm.Evidence boundary: Python template tests and semantic-alignment tests cover the supported generated-runtime behavior; one tutorial smoke check is only a first-success signal.
c
Generated files:
machine.h,machine.c,README.md, andREADME_zh.md.Entry point: include
machine.hand call generated C functions such as..._init(...),..._cycle(machine, event_ids, event_count),..._vars(...), and..._destroy(...)when heap helpers are enabled.Event model: the application passes generated integer event ids to each cycle.
Extension point: install an abstract-hook table whose callback signatures are described in the generated header and README.
Lifecycle concepts: caller-owned or heap-allocated machine object, initialization, hot start, cycle, variable reads, state reads, and destroy.
Target boundary: C99 core, C++98-compatible public header use, standard library only by default, fixed-width generated integer profile for integer variables.
Evidence boundary: native smoke and template alignment checks are toolchain evidence, not certification for every compiler or deployment profile.
c_poll
Generated files:
machine.h,machine.c,README.md, andREADME_zh.md.Entry point: include
machine.h, initialize the machine, install hooks and a completeEventCheckstable, then call the polling cycle API.Event model: the runtime calls installed event-check functions during a cycle; it does not accept per-cycle external event-id arrays.
Extension point: abstract hooks use
Hooks; event truth comes fromEventCheckscallbacks.Lifecycle concepts: initialization, event-check installation, hot start, cycle, variable reads, state reads, and destroy.
Target boundary: same C-family profile as
c, with event polling added to the public surface.Evidence boundary: native and alignment evidence must include event-check behavior; a callback result should behave as a read-only probe for one cycle.
cpp
Generated files:
machine.h,machine.c,machine.hpp,machine.cpp,README.md, andREADME_zh.md.Entry point: include
machine.hppand usepyfcstm_generated::<Machine>_cpp::MachineWrapper. The C core is included, but C++ user code should not bypass the wrapper as its main surface.Event model: wrapper cycle methods submit generated event ids to the reused C core.
Extension point: the wrapper exposes C hook registration through C++ aliases; runtime behavior remains in the generated C core.
Lifecycle concepts: wrapper construction, hook registration, cycle overloads, variable/state reads, hot start through the public C core where documented, and wrapper-owned initialization.
Target boundary: C99 execution core plus C++98-compatible, exception-free, RTTI-free wrapper with no STL container requirement.
Evidence boundary: C++ smoke tests must exercise
machine.hpp/machine.cppwrapper entry points, even though the final executable links the generated C core.
cpp_poll
Generated files:
machine.h,machine.c,machine.hpp,machine.cpp,README.md, andREADME_zh.md.Entry point: include
machine.hppand constructpyfcstm_generated::<Machine>_cpp::MachineWrapper; install wrapper hooks and wrapper event checks, then callcycle().Event model: the reused C polling core calls installed event-check functions; the C++ wrapper exposes aliases and setter methods for those checks.
Extension point: abstract hooks and event checks are both installed through wrapper-facing APIs.
Lifecycle concepts: wrapper construction, hook/event-check installation, cycle, variable/state reads, hot start through the underlying public surface where documented, and wrapper-owned initialization.
Target boundary: C polling core plus C++98-compatible wrapper; not a fully independent C++ runtime.
Evidence boundary: smoke and alignment tests must cover the wrapper and the polling event model, not just the reused C core.
Target-profile notes
C-family templates use fixed-width generated integer storage in the default
profile. Numeric deployment warnings therefore apply to c, c_poll,
cpp, and cpp_poll targets. They should not be presented as proof that a
Python generated runtime has the same fixed-width integer carrying risk.
C++ templates reuse C cores by design. cpp reuses the C99 core; cpp_poll
reuses the C polling core. Their C++ value is the wrapper integration surface,
not a separate execution semantics implementation.
Selection and misuse matrix
Template |
Good first use |
Misuse to avoid |
First verification |
|---|---|---|---|
|
Application or test code can import a Python module and call |
Treating Python smoke success as evidence for C-family integer storage or compiler behavior. |
Import |
|
A C host collects events and submits generated event ids each cycle. |
Expecting polling callbacks to be queried by the explicit-event API. |
Compile |
|
A C host wants event truth queried from callbacks at cycle time. |
Leaving an |
Compile and run a driver that installs the full event-check table. |
|
A C++ host wants wrapper methods while accepting a generated C core. |
Calling it a fully independent C++ runtime or testing only the C core. |
Compile a consumer that includes |
|
A C++ host wants wrapper-facing polling callbacks. |
Mixing explicit event ids with the polling wrapper and expecting both APIs to be equivalent. |
Compile a wrapper consumer that installs event checks and calls |
Per-template evidence cards
Template |
Source facts |
Runtime evidence |
Boundary evidence |
|---|---|---|---|
|
Packaged metadata, Python template config, generated README templates, Python template tests. |
Import/cycle smoke and simulator-alignment tests for the supported Python generated runtime. |
No native compiler proof; generated code should be self-contained Python standard-library code. |
|
C template config, C runtime helpers from |
C compiler smoke and semantic-alignment coverage for explicit event ids. |
Fixed-width integer profile and toolchain-specific native evidence must remain visible. |
|
C polling template config, event-check generated files, C runtime helper source facts. |
Native smoke that exercises polling callbacks and alignment coverage for the polling event model. |
Polling changes event input, not FCSTM lifecycle semantics. |
|
C core template facts plus wrapper |
C++ wrapper smoke, not merely C core compile success. |
Wrapper integration surface is C++98-compatible and reuses the generated C core. |
|
C polling core facts plus polling wrapper templates. |
Wrapper smoke with event checks installed through the wrapper-facing surface. |
Not an independent C++ polling runtime; it is a C polling core plus wrapper. |
Generic example snippets
The exact names are model-specific. Treat these snippets as shape examples and read the generated README for the concrete symbols.
Template |
Shape example |
What the generated README supplies |
|---|---|---|
|
|
Class name, event strings, hook method names, state and variable readers. |
|
|
C prefix, type names, event ids, hook table fields, init/cycle/destroy names. |
|
Initialize the machine, install hooks, install |
Event-check table fields, callback signatures, lifecycle function names. |
|
|
Namespace, wrapper class name, hook aliases, cycle overloads. |
|
Construct the wrapper, install wrapper hooks and event checks, then call |
Wrapper event-check aliases, setter names, and polling lifecycle snippets. |
Unsupported or risky assumptions
Assumption |
Why it is wrong |
Safer wording |
|---|---|---|
“All built-in templates are production certified.” |
Metadata currently marks all five templates as experimental. |
They have current repository tests and smoke evidence, not every-platform certification. |
“The repository |
Ordinary users should use packaged assets through |
Repository template source is a maintainer input and packaging source. |
“C++ templates do not need the C generated core.” |
|
C++ templates provide wrapper integration surfaces over the generated C core. |
“Polling templates change state-machine semantics.” |
Polling changes how event truth is supplied. |
Lifecycle and transition semantics should remain aligned with the simulator, within documented exclusions. |
“A generated file tree proves runtime correctness.” |
Rendering success proves file creation only. |
Runtime, native and semantic claims need matching smoke or alignment evidence. |
When reviewing an integration claim with this table, first ask which evidence layer the claim needs. File existence needs only a generation command; importing a Python class needs a consumer smoke check; compiling C-family output needs a native toolchain; semantic equivalence needs simulator-alignment fixtures.
That is why this page does not turn “a built-in template exists” into “the target platform is certified.” The template contract states what this repository can prove; release, embedded-porting, or safety-critical deployment still needs project-specific evidence from the target environment.
Source-fact audit map
A reviewer can audit this page without guessing by checking these sources:
package list and archive names:
pyfcstm/template/index.json;per-template title, language, description and experimental status:
templates/<name>/template.json;generated files and integration snippets: generated
README.mdandREADME_zh.mdfrom each template;event input models: generated README files, runtime templates and template tests;
C-family helper and fixed-width body facts:
pyfcstm/render/c_runtime.py;wrapper facts:
templates/cppandtemplates/cpp_pollsource templates plus wrapper smoke tests;current evidence boundary: template unit tests, semantic-alignment tests, formatter checks and native smoke checks when the host toolchain is available.