Models¶
Ports, nodes, workflows, traces and scores.
models
¶
Canonical data models for a Science ADK research project.
Every model here maps 1:1 onto a durable file on disk. There is no hidden state
or external database dependency: the files in research/ represent the
complete empirical truth.
Port
dataclass
¶
A single typed input or output port of an agent.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The unique name of the port on this agent. |
type |
str
|
Data type of the port (must be one of PORT_TYPES). |
description |
str
|
Explanation of what this port carries. |
required |
bool
|
Whether a value is strictly required on this port. |
from_dict
classmethod
¶
Constructs a Port from a dictionary or string shorthand.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any] | str
|
Dictionary containing port specification or string port name. |
required |
Returns:
| Type | Description |
|---|---|
Port
|
A new Port instance. |
Source code in python/src/science_adk/models.py
Ports
dataclass
¶
The complete input and output port surface of an agent.
Attributes:
| Name | Type | Description |
|---|---|---|
inputs |
list[Port]
|
List of declared input ports. |
outputs |
list[Port]
|
List of declared output ports. |
input
¶
output
¶
from_dict
classmethod
¶
Constructs Ports from dictionary data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any] | None
|
Dictionary with 'inputs' and 'outputs' lists. |
required |
Returns:
| Type | Description |
|---|---|
Ports
|
A new Ports instance. |
Source code in python/src/science_adk/models.py
to_dict
¶
Serializes the Ports instance to a dictionary.
Node
dataclass
¶
Node(id, name, kind='algorithm', purpose='', ports=Ports(), module='', tools=list(), params=dict(), workflow='')
One step of an experiment: a named agent with a typed port surface.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
Unique identifier of the node within the workflow DAG. |
name |
str
|
Human-readable name for the node. |
kind |
str
|
The primitive agent kind (must be one of AGENT_KINDS). |
purpose |
str
|
Description of what this node does and why. |
ports |
Ports
|
Declared input and output ports. |
module |
str
|
Path to the Python file implementing the agent. |
tools |
list[str]
|
Advisory list of tools this agent may call. |
params |
dict[str, Any]
|
Static parameters passed to the agent. |
workflow |
str
|
For composite agents, the path to the nested workflow. |
from_dict
classmethod
¶
Constructs a Node from dictionary data.
Source code in python/src/science_adk/models.py
to_dict
¶
Serializes the Node instance to a dictionary.
Source code in python/src/science_adk/models.py
Edge
dataclass
¶
A typed connection carrying an output port into an input port.
Attributes:
| Name | Type | Description |
|---|---|---|
source |
str
|
Source node id. |
source_port |
str
|
Name of the output port on the source node. |
target |
str
|
Target node id. |
target_port |
str
|
Name of the input port on the target node. |
from_dict
classmethod
¶
Constructs an Edge from dictionary data.
Source code in python/src/science_adk/models.py
Workflow
dataclass
¶
Workflow(name='', description='', nodes=list(), edges=list(), created_at=utcnow())
The experiment DAG: what runs, in what order, carrying what data.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Descriptive name of the workflow. |
description |
str
|
Summary of the experiment pipeline. |
nodes |
list[Node]
|
List of nodes in the DAG. |
edges |
list[Edge]
|
List of edges connecting nodes. |
created_at |
str
|
ISO-8601 creation timestamp. |
node
¶
parents
¶
Returns sorted list of parent node IDs that precede node_id.
children
¶
Returns sorted list of child node IDs that consume output from node_id.
descendants
¶
Returns all node IDs transitively downstream of node_id.
Source code in python/src/science_adk/models.py
terminal_nodes
¶
from_dict
classmethod
¶
Constructs a Workflow from dictionary data.
Source code in python/src/science_adk/models.py
to_dict
¶
Serializes the Workflow to a dictionary.
Source code in python/src/science_adk/models.py
NodeRun
dataclass
¶
NodeRun(node_id, state='pending', started_at='', finished_at='', duration_s=0.0, outputs=dict(), logs=list(), error='', traceback='', provenance=dict(), fingerprint='')
The execution record of one node.
Attributes:
| Name | Type | Description |
|---|---|---|
node_id |
str
|
Identifier of the executing node. |
state |
str
|
Execution status (pending, running, passed, failed, cached). |
started_at |
str
|
ISO-8601 execution start timestamp. |
finished_at |
str
|
ISO-8601 execution finish timestamp. |
duration_s |
float
|
Total run duration in seconds. |
outputs |
dict[str, Any]
|
Map of output port names to values or dataset references. |
logs |
list[str]
|
Informational log messages recorded during execution. |
error |
str
|
Error message string if execution failed. |
traceback |
str
|
Exception traceback if execution failed. |
provenance |
dict[str, list[dict[str, Any]]]
|
Machine-recorded ingress and tool-call evidence. |
fingerprint |
str
|
Execution cache hash (code + inputs + parameters). |
from_dict
classmethod
¶
Constructs a NodeRun from dictionary data.
Source code in python/src/science_adk/models.py
Trace
dataclass
¶
Trace(run_id, experiment='', state='pending', started_at=utcnow(), finished_at='', duration_s=0.0, nodes=list(), error='')
The complete record of one workflow execution run.
Attributes:
| Name | Type | Description |
|---|---|---|
run_id |
str
|
Unique run identifier. |
experiment |
str
|
Experiment identifier. |
state |
str
|
Overall workflow state. |
started_at |
str
|
ISO-8601 start timestamp. |
finished_at |
str
|
ISO-8601 finish timestamp. |
duration_s |
float
|
Total execution duration in seconds. |
nodes |
list[NodeRun]
|
List of NodeRun records. |
error |
str
|
Top-level error message if run aborted. |
node
¶
from_dict
classmethod
¶
Constructs a Trace from dictionary data.
Source code in python/src/science_adk/models.py
to_dict
¶
Serializes the Trace to a dictionary.
Source code in python/src/science_adk/models.py
Gate
dataclass
¶
Score
dataclass
¶
Score(run_id, gates=list(), pillars=dict(), rationale='', target_metric='', target_value=None, observed_value=None, audited_at='')
The evaluation verdict on one run.
Attributes:
| Name | Type | Description |
|---|---|---|
run_id |
str
|
Unique run identifier. |
gates |
list[Gate]
|
List of deterministic Gate results. |
pillars |
dict[str, float]
|
Judgement pillar scores (in [0, 1]). |
rationale |
str
|
Written audit rationale. |
target_metric |
str
|
Name of the target metric. |
target_value |
float | None
|
Goal threshold target. |
observed_value |
float | None
|
Empirically measured value. |
audited_at |
str
|
ISO-8601 audit timestamp. |
from_dict
classmethod
¶
Constructs a Score from dictionary data.
Source code in python/src/science_adk/models.py
to_dict
¶
Serializes the Score to a dictionary.
Source code in python/src/science_adk/models.py
Goal
dataclass
¶
Goal(question='', background='', target_metric='', target_value=None, constraints=list(), created_at=utcnow())
The overarching research question, success metric, and constraints.
Attributes:
| Name | Type | Description |
|---|---|---|
question |
str
|
The scientific question under investigation. |
background |
str
|
Contextual background and motivation. |
target_metric |
str
|
Quantitative evaluation metric name. |
target_value |
float | None
|
Success threshold for the target metric. |
constraints |
list[str]
|
List of experimental or methodological constraints. |
created_at |
str
|
ISO-8601 creation timestamp. |
from_dict
classmethod
¶
Constructs a Goal from dictionary data.
Source code in python/src/science_adk/models.py
Experiment
dataclass
¶
Experiment(id, hypothesis='', rationale='', parent='', generation=0, status='draft', best_run='', best_score=None, created_at=utcnow())
One testable hypothesis and its lineage.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
Unique experiment identifier (e.g., '001-nonlinear-oscillator'). |
hypothesis |
str
|
Precise testable claim. |
rationale |
str
|
Empirical justification for why this hypothesis was chosen. |
parent |
str
|
Parent experiment ID in the hypothesis tree. |
generation |
int
|
Tree depth level of this experiment. |
status |
str
|
Current status (draft, ready, run, superseded, abandoned). |
best_run |
str
|
Run ID of the highest scoring run. |
best_score |
float | None
|
Highest score achieved. |
created_at |
str
|
ISO-8601 creation timestamp. |
from_dict
classmethod
¶
Constructs an Experiment from dictionary data.
Source code in python/src/science_adk/models.py
Learning
dataclass
¶
Learning(insight, evidence='', experiment='', run_id='', created_at=utcnow())
An empirically validated insight backed by run evidence.
Attributes:
| Name | Type | Description |
|---|---|---|
insight |
str
|
The empirical finding or generalization. |
evidence |
str
|
Specific runs or measurements demonstrating the finding. |
experiment |
str
|
Experiment identifier where the finding was made. |
run_id |
str
|
Run identifier of the supporting run. |
created_at |
str
|
ISO-8601 creation timestamp. |
from_dict
classmethod
¶
Constructs a Learning from dictionary data.
Source code in python/src/science_adk/models.py
utcnow
¶
slugify
¶
Transforms text into a filesystem- and git-friendly slug.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The source text string. |
required |
max_length
|
int
|
Maximum allowed length of the slug. |
48
|
Returns:
| Type | Description |
|---|---|
str
|
A normalized lowercase slug string. |
Source code in python/src/science_adk/models.py
types_compatible
¶
Determines whether a value produced as source can be passed into target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
Source port data type. |
required |
target
|
str
|
Target port data type. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the types are compatible; False otherwise. |