ShtukbaseStandard
FC-R02/norms/rules/code-functional-core/FC-R02.md

Dependencies point inward

SHOULDobservessensoractive
A core file imports only core files and third-party libraries, not the project's shell files.
Why: A core that calls the shell stops being pure through a single link. Dependencies must go from the outside in.
Page fields (16)
ruleIdFC-R02
requirementA core file imports only core files and third-party libraries, not the project's shell files.
levelSHOULD
floorfalse
statusactive
spherecode
appliesTocode of the project: TypeScript, JavaScript, Python, Rust (roots and exclusions are in /norms/code.md)
enforcers.shtukbase/packages/code-functional-core/checks/core_imports.ts
enforcerKindsensor
modeobserve
becauseA core that calls the shell stops being pure through a single link. Dependencies must go from the outside in.
evidenceGary Bernhardt, "Functional Core, Imperative Shell" (Destroy All Software, 2012) and the talk "Boundaries" (2012) - impureim sandwich; ports and adapters
baseline0
reviewBy2027-05-28
packcode-functional-core
railThe core does not import the shell: pass what is needed as a value.

A core file imports only core files and third-party libraries, not the project's shell files.

Why. A core that calls the shell stops being pure through a single link. Dependencies must go from the outside in.

Where it comes from. Gary Bernhardt; Mark Seemann: impureim sandwich; ports and adapters. Source: Gary Bernhardt, "Functional Core, Imperative Shell" (Destroy All Software, 2012) and the talk "Boundaries" (2012); Mark Seemann, "Impureim sandwich" (blog.ploeh.dk, 2020) and the book "Code That Fits in Your Head" (2021).

How it is checked. Relative imports in TypeScript and JavaScript, relative imports in Python. Rust is not read: there the core is a separate crate, and what it may call is stated by its Cargo.toml.

Thresholds are on the settings page /norms/code/code-functional-core.md: core. Exclusions are a path list on the same page (exclude) or the shared list in /norms/code.md. One place can be released by the comment code-allow: core-imports on its line or the line above.

How to fix. Move what is needed into the core or pass it to the core as a value; the shell calls the core, not the other way round.

Run. shtuk run code-functional-core core-imports [paths]: without paths it reads the roots from /norms/code.md. A finding is a line file:line: what is wrong. Mode observe: findings are printed and the check passes. The owner moves the norm to mode: enforce, and then a finding fails shtuk check.

The enforcer is the core-imports check of the code-functional-core package, a heuristic; what it does not see is looked at by the reviewer using the prompt shtuk run code-functional-core review.

The package Code: a pure core, effects at the edges puts this page at /norms/rules/code-functional-core/FC-R02.md.Source text