Author: Thor Thor Email: codethor@gmail.com GitHub: https://github.com/codethor0 Project: creativity-exploit-engine
Immutable dataclass representing a threat scenario.
Fields:
asset: str- Target assetentry_point: str- Attack entry pointtechnique: str- Attack techniqueconstraint: str- Operational constraint
Methods:
to_text() -> str- Structured natural language descriptionto_dict() -> dict[str, str]- Serialize to dictionaryfrom_dict(data: dict[str, str]) -> Artifact- Deserialize from dictionary
Validation: All fields must be non-empty strings (after stripping).
Protocol for embedders that convert text to normalized vectors.
Methods:
embed(text: str) -> np.ndarray- Embed text into 1D float32 vector with L2 norm 1
Embedder using sentence-transformers. Uses all-MiniLM-L6-v2 by default, overridable via CRE_ENGINE_MODEL_NAME environment variable.
Constructor:
model_name: str | None- Model name (default from env or all-MiniLM-L6-v2)device: str | None- Device for inference (cuda/cpu, auto-detected if None)
Deterministic embedder for tests. Hash-based, no external model. Produces fixed-size normalized vectors.
Constructor:
dim: int- Vector dimension (default 32)
Main engine for scoring and searching threat scenarios.
Constructor:
embedder: BaseEmbedder- Embedder instancealpha: float- Novelty weight (default 0.5)beta: float- Value weight (default 0.5)gamma: float- Surprise weight (default 0.0)k_neighbors: int- Neighbors for novelty (default 5)max_elements: int- HNSW index capacity (default 10000)hnsw_m: int- HNSW M parameter (default 16)ef_construction: int- HNSW ef_construction (default 200)ef_search: int- HNSW ef_search (default 100)
Methods:
add_to_archive(artifact: Artifact) -> None- Add artifact to archive and indexcompute_novelty(artifact: Artifact) -> float- Novelty scorecompute_value(artifact: Artifact) -> float- Value heuristic scorecompute_surprise(artifact: Artifact, generative_model=None) -> float- Surprise (0 if no model)score(artifact: Artifact, generative_model=None) -> dict- Full score dictmutate(artifact: Artifact, mutation_prob=0.4, rng=None) -> Artifact- Combinational mutationsearch(seed_artifacts, rounds, candidates_per_round, archive_top_k, novelty_threshold=0.1, random_seed=None) -> list[tuple[Artifact, dict]]- Evolutionary search