Entropic 2.14.3
Local-first agentic inference engine
Loading...
Searching...
No Matches
manager.h File Reference

Prompt manager — frontmatter parsing, identity loading, assembly. More...

#include <entropic/entropic_export.h>
#include <entropic/types/config.h>
#include <filesystem>
#include <optional>
#include <string>
#include <unordered_map>
#include <vector>
Include dependency graph for manager.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  entropic::prompts::BenchmarkPrompt
 A single benchmark prompt with quality checks. More...
 
struct  entropic::prompts::BenchmarkSpec
 Benchmark definition for an identity. More...
 
struct  entropic::prompts::IdentityFrontmatter
 Identity frontmatter — full tier identity metadata. More...
 
struct  entropic::prompts::ParsedPrompt
 Parsed prompt file result: type + version + body. More...
 
struct  entropic::prompts::ParsedIdentity
 Parsed identity file: frontmatter + body. More...
 

Namespaces

namespace  entropic
 Activate model on GPU (WARM → ACTIVE).
 

Typedefs

using entropic::prompts::PhaseConfig = entropic::PhaseConfig
 Alias for PhaseConfig from types/ (canonical location).
 

Enumerations

enum class  entropic::prompts::PromptType { CONSTITUTION , APP_CONTEXT , IDENTITY }
 Prompt file type (frontmatter "type" field). More...
 
enum class  entropic::prompts::AppContextState { NOT_CONFIGURED , DISABLED , INLINE , FROM_PATH }
 Which app_context spelling a config is using (gh#163). More...
 

Functions

ENTROPIC_EXPORT const char * entropic::prompts::prompt_type_to_string (PromptType type)
 Convert PromptType to string.
 
ENTROPIC_EXPORT std::string entropic::prompts::parse_prompt_file (const std::filesystem::path &path, PromptType expected_type, ParsedPrompt &result)
 Parse a prompt file: validate frontmatter, return body.
 
ENTROPIC_EXPORT std::string entropic::prompts::load_identity (const std::filesystem::path &path, ParsedIdentity &identity)
 Load an identity file: parse frontmatter + body.
 
ENTROPIC_EXPORT AppContextState entropic::prompts::classify_app_context (const std::optional< std::filesystem::path > &app_context_path, const std::optional< std::string > &app_context_content, bool disabled)
 Classify the app_context configuration.
 
ENTROPIC_EXPORT const char * entropic::prompts::app_context_state_message (AppContextState state)
 The log message describing one app_context state.
 
ENTROPIC_EXPORT std::string entropic::prompts::load_constitution (const std::optional< std::filesystem::path > &constitution_path, bool disabled, const std::filesystem::path &data_dir, std::string &body)
 Load constitution prompt with tri-state resolution.
 
ENTROPIC_EXPORT std::string entropic::prompts::load_app_context (const std::optional< std::filesystem::path > &app_context_path, const std::optional< std::string > &app_context_content, bool disabled, const std::filesystem::path &data_dir, std::string &body)
 Load app_context prompt with tri-state resolution.
 
ENTROPIC_EXPORT void entropic::prompts::load_shared_prompt_sources (const entropic::ParsedConfig &config, const std::filesystem::path &data_dir, std::string &constitution, std::string &app_context)
 Load constitution + app_context, logging any failure.
 
ENTROPIC_EXPORT std::string entropic::prompts::validate_configured_prompts (const entropic::ParsedConfig &config, const std::filesystem::path &data_dir)
 Check that every CONFIGURED prompt source can actually be loaded.
 
ENTROPIC_EXPORT std::string entropic::prompts::resolve_tier_identity (const entropic::TierConfig &tier_config, const std::string &tier_name, const std::filesystem::path &data_dir)
 Resolve the system prompt body for a named tier.
 
ENTROPIC_EXPORT ParsedIdentity entropic::prompts::resolve_tier_identity_full (const entropic::TierConfig &tier_config, const std::string &tier_name, const std::filesystem::path &data_dir)
 Resolve full parsed identity (body + frontmatter) for a tier.
 
ENTROPIC_EXPORT std::string entropic::prompts::assemble (const entropic::ParsedConfig &config, const std::filesystem::path &data_dir)
 Assemble the full system prompt from config.
 

Detailed Description

Prompt manager — frontmatter parsing, identity loading, assembly.

Ports Python's PromptManager and parse_prompt_file(). Handles constitution, app_context, and per-tier identity prompt files.

Version
1.8.1

Definition in file manager.h.

Typedef Documentation

◆ PhaseConfig

Alias for PhaseConfig from types/ (canonical location).

Version
1.9.6

Definition at line 27 of file manager.h.

Enumeration Type Documentation

◆ AppContextState

Which app_context spelling a config is using (gh#163).

Four spellings, and until v2.13.0 three of them produced the SAME log line — App context disabled (not configured) — so a consumer whose path was rejected was told it had never been configured. The state is named here so the message can differ per state and a test can pin that it does.

Version
2.13.0
Enumerator
NOT_CONFIGURED 

No app_context key at all.

DISABLED 

app_context: false — an explicit opt-out.

INLINE 

app_context: {content: ...} (gh#141).

FROM_PATH 

app_context: <path>.

Definition at line 167 of file manager.h.

◆ PromptType

enum class entropic::prompts::PromptType
strong

Prompt file type (frontmatter "type" field).

Version
1.8.1
Enumerator
CONSTITUTION 

Constitution prompt.

APP_CONTEXT 

Application context prompt.

IDENTITY 

Tier identity prompt.

Definition at line 33 of file manager.h.

Function Documentation

◆ app_context_state_message()

const char * entropic::prompts::app_context_state_message ( AppContextState  state)

The log message describing one app_context state.

For every state but INLINE this is why app_context contributed no body; for FROM_PATH it is the prefix used when the named path was rejected, since a path that loads needs no explanation.

Parameters
stateState to describe.
Returns
A static, null-terminated message. Distinct per state.
Version
2.13.0
Parameters
stateState to describe.
Returns
A static message, distinct per state. @req REQ-TYPE-005
Version
2.13.0

Definition at line 513 of file manager.cpp.

◆ assemble()

std::string entropic::prompts::assemble ( const entropic::ParsedConfig &  config,
const std::filesystem::path &  data_dir 
)

Assemble the full system prompt from config.

Loads constitution, app_context, and default tier identity, then concatenates them. Used by the facade during configure.

Parameters
configParsed engine config.
data_dirBundled data directory.
Returns
Assembled system prompt string (may be empty if all disabled).
Version
2.0.1

Loads constitution, app_context, and default tier identity, then concatenates. The data_dir is used for bundled fallback paths.

Parameters
configParsed engine config.
data_dirBundled data directory.
Returns
Assembled system prompt string. @dg_internal
Version
2.13.0

Definition at line 761 of file manager.cpp.

◆ classify_app_context()

AppContextState entropic::prompts::classify_app_context ( const std::optional< std::filesystem::path > &  app_context_path,
const std::optional< std::string > &  app_context_content,
bool  disabled 
)

Classify the app_context configuration.

An explicit opt-out wins over everything, then inline content, then a path — the same precedence load_app_context() applies.

Parameters
app_context_pathConfigured path (nullopt = none).
app_context_contentInline text (nullopt = none).
disabledtrue when app_context: false.
Returns
The state this configuration is in.
Version
2.13.0
Parameters
app_context_pathConfigured path (nullopt = none).
app_context_contentInline text (nullopt = none).
disabledtrue when app_context: false.
Returns
The state this configuration is in. @req REQ-TYPE-005
Version
2.13.0

Definition at line 488 of file manager.cpp.

◆ load_app_context()

std::string entropic::prompts::load_app_context ( const std::optional< std::filesystem::path > &  app_context_path,
const std::optional< std::string > &  app_context_content,
bool  disabled,
const std::filesystem::path &  data_dir,
std::string &  body 
)

Load app_context prompt with tri-state resolution.

Load app_context from inline content or a path, with tri-state resolution.

Resolution order: if disabled or app_context_path is nullopt, body is left empty (no bundled fallback — app_context is opt-in). If a path is provided and is a bare filename, it is resolved relative to data_dir/prompts/. Absolute paths and paths with directory components are used as-is.

Parameters
app_context_pathCustom path (nullopt = disabled by default).
disabledtrue if app_context explicitly disabled.
data_dirBundled data directory used to resolve bare filenames.
[out]bodyOutput app_context text (empty if disabled or nullopt).
Returns
Empty string on success, error on failure.
Version
1.8.1

Resolution order (gh#141): an explicit opt-out wins over everything; then inline content, which is used without touching the filesystem; then a path. The state that produced no body is named in the log (gh#163).

Parameters
app_context_pathCustom path (nullopt = none configured).
app_context_contentInline text (nullopt = none supplied).
disabledtrue if app_context explicitly disabled.
data_dirBundled data directory.
[out]bodyOutput app_context text; cleared whenever no body loads.
Returns
Empty string on success, error on failure. @req REQ-TYPE-005
Version
2.13.0 @utility

Definition at line 546 of file manager.cpp.

◆ load_constitution()

std::string entropic::prompts::load_constitution ( const std::optional< std::filesystem::path > &  constitution_path,
bool  disabled,
const std::filesystem::path &  data_dir,
std::string &  body 
)

Load constitution prompt with tri-state resolution.

Parameters
constitution_pathCustom path (nullopt = bundled).
disabledtrue if constitution explicitly disabled.
data_dirBundled data directory for fallback.
[out]bodyOutput constitution text (empty if disabled).
Returns
Empty string on success, error on failure.
Version
1.8.1
Parameters
constitution_pathCustom path (nullopt = bundled).
disabledtrue if constitution explicitly disabled.
data_dirBundled data directory.
[out]bodyOutput constitution text.
Returns
Empty string on success, error on failure.
Version
2.13.0 @utility

Definition at line 394 of file manager.cpp.

◆ load_identity()

std::string entropic::prompts::load_identity ( const std::filesystem::path &  path,
ParsedIdentity &  identity 
)

Load an identity file: parse frontmatter + body.

Convenience wrapper that additionally parses all IdentityFrontmatter fields.

Parameters
pathPath to identity .md file.
[out]identityOutput parsed identity.
Returns
Empty string on success, error on failure.
Version
1.8.1
Parameters
pathPath to identity .md file.
[out]identityOutput parsed identity.
Returns
Empty string on success, error on failure.
Version
1.8.2 @utility

Definition at line 340 of file manager.cpp.

◆ load_shared_prompt_sources()

void entropic::prompts::load_shared_prompt_sources ( const entropic::ParsedConfig &  config,
const std::filesystem::path &  data_dir,
std::string &  constitution,
std::string &  app_context 
)

Load constitution + app_context, logging any failure.

Load both shared prompt sources, logging rather than discarding.

gh#156: every one of the three callers that needed both bodies called the two loaders and DISCARDED their error strings, so a prompt file the engine could not parse showed up only as a false in the assembly line. This is the shared entry point those callers use.

gh#163 moved the logging INTO each loader, which is the only layer that knows which state the config was in; a failure is therefore reported whoever calls, and the corresponding body is left empty. The fatal decision belongs to validate_configured_prompts(), which runs at configure time before anything expensive happens.

Parameters
configParsed engine config.
data_dirBundled data directory.
[out]constitutionReceives the constitution body (empty on failure).
[out]app_contextReceives the app_context body (empty on failure).
Version
2.13.0
Parameters
configParsed engine config.
data_dirBundled data directory.
[out]constitutionConstitution body (empty when it failed).
[out]app_contextApp context body (empty when it failed). @req REQ-TYPE-005
Version
2.13.0 [reviewed]

Definition at line 586 of file manager.cpp.

◆ parse_prompt_file()

std::string entropic::prompts::parse_prompt_file ( const std::filesystem::path &  path,
PromptType  expected_type,
ParsedPrompt &  result 
)

Parse a prompt file: validate frontmatter, return body.

File format: YAML frontmatter between — delimiters, followed by markdown body.

Parameters
pathPath to .md prompt file.
expected_typeExpected frontmatter type.
[out]resultOutput: type, version, body.
Returns
Empty string on success, error on failure.
Version
1.8.1
Parameters
pathPath to .md prompt file.
expected_typeExpected frontmatter type.
[out]resultOutput: type, version, body.
Returns
Empty string on success, error on failure.
Version
2.3.7 @utility

Definition at line 134 of file manager.cpp.

◆ prompt_type_to_string()

const char * entropic::prompts::prompt_type_to_string ( PromptType  type)

Convert PromptType to string.

Parameters
typePrompt type.
Returns
String representation.
Version
1.8.1
Parameters
typePrompt type.
Returns
String representation.
Version
1.8.2 @utility

Definition at line 92 of file manager.cpp.

◆ resolve_tier_identity()

std::string entropic::prompts::resolve_tier_identity ( const entropic::TierConfig &  tier_config,
const std::string &  tier_name,
const std::filesystem::path &  data_dir 
)

Resolve the system prompt body for a named tier.

Body-only wrapper around resolve_tier_identity_full.

Looks up the tier in config, resolves the identity file path (explicit, bundled convention, or disabled), loads it, and returns the markdown body. Encapsulates the path convention "identity_{tier_name}.md" in one place.

Parameters
tier_configTier configuration.
tier_nameTier name (for default path convention).
data_dirBundled data directory.
Returns
Identity body string (empty if disabled or not found).
Version
2.0.1
Parameters
tier_configTier configuration.
tier_nameTier name (for default path convention).
data_dirBundled data directory.
Returns
Identity body string (empty if disabled or not found). @utility
Version
2.0.6-rc18

Definition at line 740 of file manager.cpp.

◆ resolve_tier_identity_full()

ParsedIdentity entropic::prompts::resolve_tier_identity_full ( const entropic::TierConfig &  tier_config,
const std::string &  tier_name,
const std::filesystem::path &  data_dir 
)

Resolve full parsed identity (body + frontmatter) for a tier.

Resolve a full parsed identity (body + frontmatter) for a tier.

Same resolution rules as resolve_tier_identity() but returns the full ParsedIdentity so callers can read frontmatter fields (max_iterations, max_tool_calls_per_turn, etc.) that are discarded by the body-only variant. Returns an empty-body ParsedIdentity if no identity file is found. (E6, 2.0.6-rc18)

Parameters
tier_configTier configuration.
tier_nameTier name (for default path convention).
data_dirBundled data directory.
Returns
ParsedIdentity; body is empty if disabled or not found.
Version
2.0.6-rc18

Path convention:

  1. If tier has explicit identity path → use it
  2. If identity not disabled → data_dir/prompts/identity_{tier_name}.md
  3. If disabled or not found → empty ParsedIdentity
Parameters
tier_configTier configuration.
tier_nameTier name (for default path convention).
data_dirBundled data directory.
Returns
ParsedIdentity; body empty when no identity resolved. @utility
Version
2.0.6-rc18

Definition at line 704 of file manager.cpp.

◆ validate_configured_prompts()

std::string entropic::prompts::validate_configured_prompts ( const entropic::ParsedConfig &  config,
const std::filesystem::path &  data_dir 
)

Check that every CONFIGURED prompt source can actually be loaded.

Check every configured prompt source can be loaded.

gh#156: a consumer who names a path wanted that document. Silently running with a 17 KB smaller system prompt is not an acceptable outcome, so an unreadable / unparseable constitution or app_context path is a config error. Only explicitly configured sources are checked — the bundled constitution fallback, app_context: false, inline app_context: {content: ...} and an absent key all pass.

Parameters
configParsed engine config.
data_dirBundled data directory.
Returns
Empty string when every configured source loads, else an actionable message naming the path and the supported form.
Version
2.13.0
Parameters
configParsed engine config.
data_dirBundled data directory.
Returns
Empty string on success, an actionable message otherwise. @req REQ-TYPE-005
Version
2.13.0

Definition at line 678 of file manager.cpp.