AIMFP

v1.71.0
io.github.aryanduntley/aimfp Checked 3 days ago Published 22 days ago

Database-driven directives and project tracking for modular functional-procedural AI coding

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

acknowledge_notice

Mark a notice as delivered so it never fires again for this project. Writes to acknowledged_notices in user_preferences.db; the notice text itself lives in the read-only core database and is untouched. Call only AFTER acting on the notice — for an action_required notice that means after the user has actually answered, not merely been asked.

ParameterTypeDescription
notice_key *stringNotice identifier from get_pending_notices (e.g. 'backup_interval_intro')
outcomestringShort record of what the user decided (e.g. 'set backup_interval_days=14'). Kept for audit and worth filling in.

activate_user_directive

Set directive status to 'active' and record activated_at timestamp, only for a directive a person approved and that is unchanged since (approval content hash). Does NOT deploy services - AI handles deployment via directive workflow.

ParameterTypeDescription
directive_id *integerID of the directive to activate

add_completion_path

Add completion path stage

ParameterTypeDescription
name *stringCompletion path name (e.g., 'setup', 'core dev', 'finish')
descriptionstringDescription
order_indexintegerOrder position (1, 2, 3...)
statusstring'pending', 'in_progress', 'completed'
theme_idsarrayThemes (stable project areas) this path advances. Optional here; link later with add_path_themes.

add_directive_preference

Add/update user preference for directive

ParameterTypeDescription
directive_name *stringDirective name
preference_key *stringPreference key
preference_value *stringPreference value
activebooleanWhether preference is active
descriptionstringOptional note on what this preference does, stored with it in directive_preferences

add_file_flows

Batch-assign multiple files to flows. Skips existing links silently. More efficient than multiple add_file_to_flow calls.

ParameterTypeDescription
links *arrayArray of [file_id, flow_id] tuples to create

add_file_to_flow

Assign a finalized file to an architectural flow. Every finalized file needs at least one flow assignment to stay architecturally connected.

ParameterTypeDescription
file_id *integerFile ID (from reserve_file/finalize_file)
flow_id *integerFlow ID (from add_flow or get_all_flows)

add_file_to_module

Assign a file to a module. Creates module_files junction entry. Same pattern as add_file_to_flow.

ParameterTypeDescription
file_id *integerFile ID to assign
module_id *integerModule ID to assign to

add_files_to_module

Batch assign multiple files to modules. More efficient than multiple add_file_to_module calls. Skips duplicates silently, fails fast on missing entities.

ParameterTypeDescription
links *arrayList of [file_id, module_id] tuples to assign

add_flow

Add a project flow (evolving behaviour/architecture description) linked to at least one theme. theme_ids is required: a flow never exists without a theme.

ParameterTypeDescription
name *stringFlow name
theme_ids *arrayIDs of the theme(s) this flow belongs to — at least one. Every flow belongs to a theme; pick from get_all_themes() or add_theme() first.
ai_generatedbooleanTrue if AI-generated
confidence_scorenumberConfidence score 0-1
descriptionstringFlow description

add_flow_themes

Batch-link flows to themes (flow_themes). Every flow must belong to at least one theme; use this to fix theme-less flows or give a flow a second theme.

ParameterTypeDescription
links *arrayArray of [flow_id, theme_id] pairs. One pair links one; many pairs (any mix of flow_ids) apply atomically.

add_interaction

Record a dependency between two functions by name (call, chain, borrow, compose, pipe). Interactions are how the AI traces dependency graphs. An edge already tracked is not duplicated (already_existed=true).

ParameterTypeDescription
interaction_type *stringInteraction type ('call', 'chain', 'borrow', 'compose', 'pipe')
source *stringSource function name
target *stringTarget function name
descriptionstringWhat the dependency is (optional)
is_indirectbooleanTrue for a deliberate edge the code makes indirectly (dispatch through a tuple/table of functions, a chain data-flow link): audit_interactions never reports it as stale.

add_interactions

Batch-record function dependencies by ID. More efficient than multiple add_interaction calls for tracking all cross-function dependencies. Edges already tracked (same source, target, type) are skipped and counted in skipped_count; ids stay in input order.

ParameterTypeDescription
interactions *arrayArray of tuples [(source_function_id, target_function_id, interaction_type, description[, is_indirect]), ...] - type: 'call', 'chain', 'borrow', 'compose', 'pipe'. Optional 5th element is_indirect (bo…

add_item

Create a single work item under a task, subtask, or sidequest. Items are the smallest trackable units of work.

ParameterTypeDescription
name *stringItem name
reference_id *integerID of the parent task, subtask, or sidequest
reference_table *string'tasks', 'subtasks', or 'sidequests'
descriptionstringItem description
statusstring'pending', 'in_progress', 'completed' (default: pending)

add_items

Batch-create multiple work items under a single parent in one call. All items created with status 'pending'.

ParameterTypeDescription
items *arrayArray of {name: string, description?: string} objects
reference_id *integerID of the parent task, subtask, or sidequest
reference_table *string'tasks', 'subtasks', or 'sidequests'

add_milestone

Add milestone to completion path

ParameterTypeDescription
completion_path_id *integerCompletion path ID this milestone belongs to
name *stringMilestone name
descriptionstringMilestone description
flow_idsarrayFlows this milestone builds or changes. Optional here; link later with add_milestone_flows.
statusstring'pending', 'in_progress', 'completed', 'blocked'

add_milestone_flows

Batch-link milestones to the flows (evolving behaviour) they build or change (milestone_flows). A milestone that introduces new behaviour should get a NEW flow (add_flow) rather than growing an existing flow's description.

ParameterTypeDescription
links *arrayArray of [milestone_id, flow_id] pairs. One pair links one; many pairs (any mix of milestone_ids) apply atomically.

add_module

Create a new module (reusable code boundary). A module maps to a directory. Files are assigned explicitly via add_file_to_module. Use external_dependencies to record wrapped libraries.

ParameterTypeDescription
name *stringModule name (e.g., 'wallet_connection', 'validation')
path *stringDirectory path relative to source root (e.g., 'src/wallet_connection/')
descriptionstringWhat this module does
external_dependenciesarrayLibraries/services this module wraps (e.g., ['walletconnect', 'stripe'])
purposestringDomain concern this module owns (one sentence)

add_note

Record a decision, architecture change, or context event in the project's audit trail. Supports typed notes with optional directive linking.

ParameterTypeDescription
content *stringNote content/message
note_type *string'clarification', 'pivot', 'research', 'entry_deletion', 'warning', 'error', 'info', 'auto_summary', 'decision', 'evolution', 'analysis', 'task_context', 'external', 'summary'
directive_namestringOptional directive context for note
reference_idintegerID of the referenced table entry
reference_tablestringproject.db table this note is attached to (e.g. 'files', 'tasks', 'flows', 'completion_path'). Must be an existing project.db table name, exactly: unknown names are refused, because the getters that s…
send_with_directivebooleanIf true and directive_name set, note is included when that directive is retrieved. Turns notes into contextual reminders that travel with their directive.
severitystring'info', 'warning', 'error' (default 'info')
sourcestring'ai', 'user', or 'directive' (default 'ai')

add_path_themes

Batch-link completion paths to the themes (stable project areas) they advance (completion_path_themes). Themes change rarely, like paths.

ParameterTypeDescription
links *arrayArray of [completion_path_id, theme_id] pairs. One pair links one; many pairs (any mix of completion_path_ids) apply atomically.

add_project_entry

Add new entry to project database

ParameterTypeDescription
data *objectField-value pairs
table *stringTable name

add_settings_entry

Add entry to user settings database

ParameterTypeDescription
data *objectField-value pairs
table *stringTable name

add_sidequest

Create an urgent interruption that pauses the current task. Use for bug fixes, blockers, or unexpected work discovered mid-task.

ParameterTypeDescription
name *stringSidequest name
paused_task_id *integerID of the task being paused for this sidequest
descriptionstringSidequest description
flow_idsarrayJSON array of flow IDs
paused_subtask_idintegerIf sidequest during subtask
prioritystringSidequest priority (default: critical)
statusstringSidequest status (default: pending)

add_subtask

Create a focused sub-unit of work under a parent task. The parent is paused until all subtasks complete.

ParameterTypeDescription
name *stringSubtask name
parent_task_id *integerParent task ID
descriptionstringSubtask description
prioritystring'low', 'medium', 'high', 'critical'
statusstring'pending', 'in_progress', 'completed', 'blocked'

add_task

Create a task under a milestone with flow associations. Tasks are created ONE at a time as work progresses, not all at once.

ParameterTypeDescription
milestone_id *integerID of the milestone this task belongs to
name *stringTask name
descriptionstringTask description
flow_idsarrayJSON array of flow IDs
prioritystringTask priority (default: medium)
statusstringTask status (default: pending)

add_theme

Add project theme

ParameterTypeDescription
name *stringTheme name
ai_generatedbooleanTrue if AI-generated, False if user-created
confidence_scorenumberConfidence score 0-1
descriptionstringTheme description

add_tracking_note

Add tracking note to user_preferences.db (only when tracking enabled)

ParameterTypeDescription
content *stringNote content/message
note_type *string'fp_analysis', 'user_interaction', 'validation', 'performance', 'debug'
directive_namestringDirective that created this note
metadata_jsonstringAdditional context as JSON string
reference_idintegerOptional ID if referencing project.db entity
reference_namestringName of referenced entity (e.g., function name, file path)
reference_typestringType of reference (e.g., 'function', 'file', 'directive')
severitystring'info', 'warning', 'error' (default 'info')

add_types_functions

Link tracked types to the functions that use them with a role (factory, transformer, validator, etc.). Enables 'what functions use TypeX?' queries. Links already tracked are skipped and counted in skipped_count instead of failing the batch.

ParameterTypeDescription
relationships *arrayArray of tuples [(type_id, function_id, role), ...] - role: 'factory', 'transformer', 'operator', 'pattern_matcher', 'accessor', 'validator', 'combinator'

add_user_custom_entry

Add entry to user_directives.db table. Returns inserted record with ID. Every key must be a column of the table; on user_directives the approval columns and status='active' are refused, so a new directive always starts unapproved.

ParameterTypeDescription
data *objectField-value pairs to insert
table *stringTable name in user_directives.db

add_user_directive_note

Add note to user_directives.db notes table for AI record-keeping

ParameterTypeDescription
content *stringNote content/message
note_type *string'implementation', 'validation', 'execution', 'dependency', 'error', 'optimization', 'user_feedback', 'lifecycle', 'testing', 'general', 'deferred', 'completed', 'obsolete', 'entry_deletion'
metadata_jsonstringAdditional context as JSON string
reference_idintegerOptional ID linking to user_directives, helper_functions, etc.
reference_namestringName of referenced entity (e.g., directive name, helper name, file path)
reference_typestringType of reference: 'directive', 'helper', 'dependency', 'file'
severitystring'info', 'warning', 'error' (default 'info')

add_user_setting

Add new project-wide user setting to user_settings table

ParameterTypeDescription
setting_key *stringSetting key (must be unique)
setting_value *stringSetting value
descriptionstringDescription of the setting
scopestringSetting scope (default 'project')

aimfp_end

Session termination orchestrator. Gathers session audit data: reads watchdog state and final reminders, queries all files and functions from DB for AI to cross-reference, reads recent notes and task state. Stops watchdog process if running. Returns structured audit data for AI to interpret and act on. No analysis logic — AI determines what is stale or missing. Also runs the tracking audit (functions, interactions, descriptions) over the session's uncommitted changes (or the in-progress work item's files without git) and returns data.audit with counts, verdict and report_path.

aimfp_init

Phase 1 mechanical setup orchestrator for project initialization. Atomically creates directories, databases with schemas, and templates. No deep logic - pure mechanical operations.

ParameterTypeDescription
project_root *stringPath to project root directory

aimfp_run

Main entry point orchestrator. Called on session start (is_new_session=true) for full context bundle, and at work checkpoints (is_new_session=false) for watchdog alerts only.

ParameterTypeDescription
is_new_sessionbooleanWhether this is a new session start. Use true for first interaction, new session, or after long breaks. Use false (default) for continuation work.

aimfp_status

Project status in three tiers. Default 'quick' is the cheap position check for completion loops; 'summary' is the reload after lost or compacted context. Structure (themes/flows/modules) is attached to the work and files shown, never listed whole.

ParameterTypeDescription
typestringTier: 'quick' (default) = position only (path, milestone, focused work with item names, their flows/themes, other open work, structure gap count), for completion loops and 'where am I' checks. 'summar…

apply_audit_fixes

Apply audit findings in ONE call and ONE transaction, with a restore manifest written in the same transaction. Name report categories (report + apply) so thousands of IDs never pass through the conversation, hold back reviewed false positives for this call with exclude={category: [ids]} or for good with exempt=[...], and/or pass explicit changes. Every report finding is re-checked against its row first: an edge whose endpoints changed since the audit, or an entity already gone or renamed, is skipped with a reason. One entry_deletion note lists every deleted row (cascaded edges and type links i…

ParameterTypeDescription
reason *stringWhy these changes are made; recorded in the restore-manifest note.
add_interactionsarrayEdges to add (interaction_type defaults to 'call').
add_type_linksarraytypes_functions links to add.
applyarrayFinding categories of the report to apply. missing_interactions=add, stale_interactions=delete (indirect edges kept), repoint_interactions=move source/target, stale_functions/stale_types=delete (casca…
baseline_hash_function_idsarrayFunctions whose current code hash is recorded as matching their description. Only after reviewing purpose/parameters/returns.
cleanupbooleanDelete the report file after a successful real run.
delete_function_idsarrayFunctions to delete; their interactions and type links cascade and are recorded in the manifest.
delete_interaction_idsarrayInteractions to delete.
delete_type_idsarrayTypes to delete; their type links cascade and are recorded in the manifest.
dry_runbooleanDo everything, then roll back: the result is exactly what a real run does.
excludeobjectFindings of applied categories to hold back (reviewed false positives), as {category: [ids]}: interaction_id for stale/repoint_interactions, function_id for stale_functions/param_mismatch/unbaselined_…
exemptarrayReviewed findings that are NOT drift (schema 1.16): [{category, function_id | type_id, reason?}], reason defaulting to the call's. Audits list them under 'exempted' (info) instead of the category, so…
mark_indirect_idsarrayInteractions to mark is_indirect: deliberate edges the code makes indirectly. Audits never flag them; report deletes skip them.
refresh_signature_function_idsarrayFunctions whose parameters are re-read from the source (names, order, types, required/default), keeping each surviving parameter's description.
repoint_interactionsarrayEdges to move to a new source and/or target.
reportstringreport_path returned by an audit tool (project-relative path, absolute path, or bare file name in the audit folder).
unexempt_idsarrayaudit_exemptions ids (exemption_id in an audit's 'exempted' list) to remove; the finding is reported again. Removed rows go into the manifest.
unmark_indirect_idsarrayInteractions to clear is_indirect on.

apply_state_changeset

(For use with InterCommAIMFP) Apply a semantic changeset onto the current-main project.db as a 3-way merge (base@base_main_commit vs branch intent vs current main). Accepts EITHER the inline changeset object OR a changeset_id handle (loaded server-side). Auto-applies non-overlapping changes, mints canonical IDs for genuinely new entities, rewrites all references to canonical IDs, and returns EVERY conflict as structured data for the master/AI to review — it never guesses on a conflict. Refuses to run on a main DB that fails an integrity/core-table check. Mutates the working .aimfp-project/pr…

ParameterTypeDescription
changesetobjectThe changeset object produced by export_state_changeset (provenance, entities[], references[]). Optional when changeset_id is given.
changeset_idstringHandle returned by export_state_changeset; loads the persisted changeset from .aimfp-project/changesets/ so you never re-transcribe the full object. Used only when changeset is omitted.

audit_descriptions

Audit function and type descriptions for drift from the code. Read-only. stale_descriptions: the function's code changed after its purpose/parameters/returns were written (functions.source_hash, recorded on every prose write, differs from the current code hash; formatting, comments and docstrings never change the hash). dangling_mentions: a description names a callable that exists nowhere — 'name()' or 'snake_name(...)' not defined, imported or called anywhere in the tracked Python files, not tracked, not a builtin or Python keyword, and not vocabulary the code writes in its string literals…

ParameterTypeDescription
file_idsarrayTracked file IDs to audit.
module_pathstringAudit every file under this project-relative directory.
pathsarrayProject-relative file paths to audit (tracked or not).
since_commitstringAudit files changed since this git ref ('HEAD' = uncommitted work, or a branch/commit): committed, staged, unstaged and new untracked files.
task_idintegerAudit the files linked to this task (a task includes its subtasks' files).
task_typestring'task' (default), 'subtask' or 'sidequest' — the kind of work item task_id names.

audit_functions

Audit tracked files, functions and types against the source. Read-only. Python files (full fidelity): missing_functions (public, untracked), stale_functions (tracked, gone from the source; a module-level `f = partial(...)`, lambda or alias binding of the name counts as defined), incomplete_functions (purpose/parameters/returns empty), malformed_json (not one JSON encoding of a list/object; double-encoded is fixable), reserved_functions (never finalized), param_mismatch (recorded parameters vs the signature: names, order, required vs default), missing_types, stale_types (name defined nowhere in…

ParameterTypeDescription
file_idsarrayTracked file IDs to audit.
module_pathstringAudit every file under this project-relative directory.
pathsarrayProject-relative file paths to audit (tracked or not).
since_commitstringAudit files changed since this git ref ('HEAD' = uncommitted work, or a branch/commit): committed, staged, unstaged and new untracked files.
task_idintegerAudit the files linked to this task (a task includes its subtasks' files).
task_typestring'task' (default), 'subtask' or 'sidequest' — the kind of work item task_id names.

audit_interactions

Audit tracked interactions against the call graph the code makes, for the callers in scope. Read-only. Expected edges: calls AND functions used as values (map(fn, xs), partial, dispatch dicts built in the body), credited through untracked same-file helpers, resolved through imports, aliases and re-exports. Categories: missing_interactions (code makes it, DB lacks it), stale_interactions (provably gone: every use of the target's name in the caller resolves to something else — another function, a local or loop variable, a method on a value — or there is none), repoint_interactions (a stale e…

ParameterTypeDescription
file_idsarrayTracked file IDs to audit.
module_pathstringAudit every file under this project-relative directory.
pathsarrayProject-relative file paths to audit (tracked or not).
since_commitstringAudit files changed since this git ref ('HEAD' = uncommitted work, or a branch/commit): committed, staged, unstaged and new untracked files.
task_idintegerAudit the files linked to this task (a task includes its subtasks' files).
task_typestring'task' (default), 'subtask' or 'sidequest' — the kind of work item task_id names.

audit_tracking

Run EVERY tracking audit over one scope with one code index and one report: files, functions, types, parameters, JSON encoding, type links (audit_functions), interactions with repoints (audit_interactions), stale prose and dangling mentions (audit_descriptions), plus modularity gaps (structure_gaps). Read-only. The same audit gates task/subtask/sidequest completion (over the item's linked files), runs in aimfp_end over uncommitted work, runs per changed file in the watchdog, and runs in CI as `aimfp audit`. Scope selectors combine as a union; with none, the whole project (tracked files plus un…

ParameterTypeDescription
file_idsarrayTracked file IDs to audit.
fullarrayFinding categories to return inline in full, whatever sample_limit says (e.g. ['stale_descriptions']). Unknown category names are an error.
includearrayAudits to run (default all): functions (files, functions, types, parameters, JSON, type links), interactions (missing/stale/repoint edges), descriptions (stale prose, dangling mentions), structure (mo…
module_pathstringAudit every file under this project-relative directory.
pathsarrayProject-relative file paths to audit (tracked or not).
sample_limitintegerFindings shown inline per category (default 5; 0 = counts only). The report file always has every finding.
since_commitstringAudit files changed since this git ref ('HEAD' = uncommitted work, or a branch/commit): committed, staged, unstaged and new untracked files.
task_idintegerAudit the files linked to this task (a task includes its subtasks' files).
task_typestring'task' (default), 'subtask' or 'sidequest' — the kind of work item task_id names.

backfill_semantic_keys

(For use with InterCommAIMFP) Mint stable identity keys for any rows that lack one: slugs on work-hierarchy rows (milestones, tasks, subtasks, sidequests, items) and entity_key on functions/types — e.g. rows that predate those columns. OPTIONAL one-time prep: run once on main (and commit) only when a pre-v1.11 project is about to start multi-agent parallel work, so every clone inherits stable baseline keys that export_state_changeset can match. Unnecessary for solo projects (keys never read) and for projects started fresh on v1.11+ (keys minted at creation — no-op). Idempotent.

batch_update_progress

Update multiple project items atomically. Used after code generation or bulk operations to ensure consistency.

ParameterTypeDescription
updates *arrayList of update objects: [{target_type, target_id, action, data}, ...] data.audit_override_reason completes a task/subtask/sidequest despite blocking tracking-audit findings (recorded as a warning note…
continue_on_errorbooleanStop on first error or continue processing remaining updates
transactionbooleanAll-or-nothing commit vs independent updates

blueprint_has_changed

Check if ProjectBlueprint.md has changed using Git or filesystem timestamp

ParameterTypeDescription
blueprint_path *stringAbsolute path to ProjectBlueprint.md file

catalog_files

Register existing files in project.db in a single phase. For code already on disk: rows are written finalized (is_reserved=0) with ID naming off, because existing filenames are fixed and cannot carry an _id_ suffix. Use INSTEAD OF reserve_files/finalize_files when adopting an existing codebase. Idempotent on path; re-cataloging keeps a stored name or language that is omitted.

ParameterTypeDescription
files *arrayArray of {name, path, language} objects. 'path' is project-relative and is the identity key.

catalog_functions

Register existing functions in project.db in a single phase. Use INSTEAD OF reserve_functions/finalize_functions when adopting an existing codebase. Idempotent on (file_id, name), so a re-scan after source changes refreshes signatures instead of duplicating them. Only supplied fields are overwritten: an omitted or blank purpose, parameters or returns keeps the stored value, so a refresh never erases prose.

ParameterTypeDescription
functions *arrayArray of {name, file_id, purpose, parameters, returns} objects. 'parameters' is a list of param dicts and 'returns' a dict; both are JSON-encoded on write.

catalog_types

Register existing type definitions in project.db in a single phase. Use INSTEAD OF reserve_types/finalize_types when adopting an existing codebase. Idempotent on (file_id, name); definition is always refreshed, an omitted description keeps the stored one.

ParameterTypeDescription
types *arrayArray of {name, file_id, definition, description} objects. 'definition' is a dict describing the type shape and is JSON-encoded on write.

check_directive_health

Assess every user directive and report which need attention. The health states, in the order they are checked: 'unapproved' (status is active but no person approved it, so dispatch withholds it); 'needs_reapproval' (approved, but the trigger, action or implementation file changed since, or it was approved before schema 1.5 without a content hash; dispatch and activation refuse it until the user approves again); 'error' (the directive's own status is error); 'overdue' (next_scheduled_time is in the past, meaning the runner said when it would next fire and did not); 'skipping' (consecutive_skip_…

ParameterTypeDescription
error_rate_thresholdnumberError rate at or above which a directive is reported degraded
project_rootstringProject root; defaults to the session root
skip_thresholdintegerConsecutive skipped occurrences at or above which a directive is reported skipping

check_scheduled_backup_due

Check whether a scheduled backup is overdue, measured from the LAST BACKUP. Distinct from the inactivity rule (backup_duration), which measures time since the last project change and therefore only ever fires on dormant projects — an actively developed project would otherwise never be backed up. Governed by backup_interval_days; 0 disables scheduling. Called automatically by aimfp_run(is_new_session=true); available standalone for hosts that want the check on demand.

clear_watchdog

Clear watchdog reminders after they have been reviewed and handled. Reminders persist in .aimfp-project/watchdog/reminders.json until this is called. Call after addressing all watchdog findings (file deletions, unregistered files, etc.).

core_allowed_check_constraints

Returns list of allowed values for CHECK constraint enum fields in aimfp_core.db. Parses schema to extract CHECK(field IN (...)) constraints.

ParameterTypeDescription
field *stringField name to get allowed values for
table *stringTable name to check for CHECK constraints

create_project

Initialize project entry (one per database)

ParameterTypeDescription
goals *arrayArray of goal strings (e.g., ['Fast computation', 'No OOP'])
name *stringProject name (e.g., 'MatrixCalculator')
purpose *stringProject purpose (e.g., 'Build a pure functional matrix math library')
statusstring'active', 'paused', 'completed', 'abandoned'
user_directives_statusstringNULL (Case 1), 'pending_discovery', 'pending_parse', 'in_progress', 'active', 'disabled'
versionintegerTracks idea evolution (starts at 1)

create_project_backup

Create a backup of .aimfp-project/ right now, ignoring any threshold. Zips everything except backups/ and watchdog/, adds a generated backup_summary.md, and rotates old archives per the backup_count setting, naming every archive it deletes (rotated, plus a warning sentence). The on-demand counterpart to the automatic inactivity check — call this when aimfp_run reports a scheduled backup due, or before any risky operation.

create_state_database

Create per-project state database (.state/runtime.db) from SQL schema. FP-compliant replacement for mutable global variables.

ParameterTypeDescription
source_directory *stringAbsolute path to project source directory (from infrastructure.source_directory)

create_user_branch

Create work branch following aimfp-{user}-{number} convention

ParameterTypeDescription
purpose *stringBranch purpose description
user *stringUsername

deactivate_user_directive

Set directive status to 'paused'. Does NOT stop services - AI handles service shutdown via directive workflow.

ParameterTypeDescription
directive_id *integerID of the directive to deactivate

delete_completion_path

Delete completion path with milestone validation

ParameterTypeDescription
id *integerCompletion path ID
note_reason *stringDeletion reason
note_severity *string'info', 'warning', 'error'
note_source *string'ai' or 'user'
note_typestring'entry_deletion'

delete_custom_return_statement

Delete custom return statement(s) for a helper function. By ID, by text, or all for a helper.

ParameterTypeDescription
helper_name *stringHelper function name
statementstringSpecific statement text to delete (optional)
statement_idintegerSpecific row ID to delete (optional)

delete_file

Delete file with comprehensive cross-reference validation

ParameterTypeDescription
file_id *integerFile ID to delete
note_reason *stringDeletion reason
note_severity *string'info', 'warning', 'error'
note_source *string'ai' or 'user'
note_typestring'entry_deletion'

delete_flow

Delete flow with file validation

ParameterTypeDescription
flow_id *integerFlow ID to delete
note_reason *stringDeletion reason
note_severity *string'info', 'warning', 'error'
note_source *string'ai' or 'user'
note_typestring'entry_deletion'

delete_function

Delete a function, deciding explicitly what happens to its interactions: refused (with the edges listed) unless repoint_to moves them to the function that took over its job, or confirm_cascade removes them. Every moved or removed edge is recorded in the deletion note so it can be undone. Type relationships must be unlinked first.

ParameterTypeDescription
function_id *integerFunction ID to delete
note_reason *stringDeletion reason
note_severity *string'info', 'warning', 'error'
note_source *string'ai' or 'user'
confirm_cascadebooleanDelete the function's interactions with it. Without repoint_to or confirm_cascade, a function with interactions is refused and the edges are listed.
note_typestring'entry_deletion'
repoint_tointegerFunction ID that takes over this function's interactions (the split/move case). Edges that would become self-edges or duplicates are dropped. Every moved or dropped edge is written into the deletion n…

delete_interaction

Delete interaction

ParameterTypeDescription
interaction_id *integerInteraction ID to delete
note_reason *stringDeletion reason
note_severity *string'info', 'warning', 'error'
note_source *string'ai' or 'user'
note_typestring'entry_deletion'

delete_item

Delete item with status validation

ParameterTypeDescription
id *integerItem ID
note_reason *stringDeletion reason
note_severity *string'info', 'warning', 'error'
note_source *string'ai' or 'user'
note_typestring'entry_deletion'

delete_milestone

Delete milestone with task validation

ParameterTypeDescription
id *integerMilestone ID
note_reason *stringDeletion reason
note_severity *string'info', 'warning', 'error'
note_source *string'ai' or 'user'
note_typestring'entry_deletion'

delete_module

Delete a module. CASCADE removes module_files junction entries. Files themselves are NOT deleted.

ParameterTypeDescription
module_id *integerModule ID to delete

delete_note

Delete note (discouraged)

ParameterTypeDescription
id *integerNote ID to delete

delete_project_entry

Smart delete with automatic routing to specialized functions when needed

ParameterTypeDescription
id *integerRecord ID
note_reason *stringDeletion reason
note_severity *string"info", "warning", "error"
note_source *string"ai" or "user"
note_type *string"entry_deletion"
table *stringTable name

delete_reserved

Delete abandoned reserved entries (escape hatch for cancelled reserve operations)

ParameterTypeDescription
id *integerReserved record ID to delete
note_reason *stringDeletion reason (e.g., 'User cancelled operation', 'Correcting reservation error')
note_severity *string'info', 'warning', 'error'
note_source *string'ai' or 'user'
table *stringTable name (must be 'files', 'functions', or 'types')
note_typestring'entry_deletion'

delete_settings_entry

Delete entry from user_preferences.db table

ParameterTypeDescription
record_id *integerRecord ID to delete
table *stringTable name in user_preferences.db

delete_sidequest

Delete sidequest with item validation (same logic as delete_task)

ParameterTypeDescription
id *integerSidequest ID
note_reason *stringDeletion reason
note_severity *string'info', 'warning', 'error'
note_source *string'ai' or 'user'
note_typestring'entry_deletion'

delete_subtask

Delete subtask with item validation (same logic as delete_task)

ParameterTypeDescription
id *integerSubtask ID
note_reason *stringDeletion reason
note_severity *string'info', 'warning', 'error'
note_source *string'ai' or 'user'
note_typestring'entry_deletion'

delete_task

Delete task with item validation

ParameterTypeDescription
id *integerTask ID
note_reason *stringDeletion reason
note_severity *string'info', 'warning', 'error'
note_source *string'ai' or 'user'
note_typestring'entry_deletion'

delete_theme

Delete theme with flow validation

ParameterTypeDescription
note_reason *stringDeletion reason
note_severity *string'info', 'warning', 'error'
note_source *string'ai' or 'user'
theme_id *integerTheme ID to delete
note_typestring'entry_deletion'

delete_type

Delete type with relationship validation

ParameterTypeDescription
note_reason *stringDeletion reason
note_severity *string'info', 'warning', 'error'
note_source *string'ai' or 'user'
type_id *integerType ID to delete
note_typestring'entry_deletion'

delete_type_function

Remove type-function relationship

ParameterTypeDescription
id *integertypes_functions junction table ID
note_reason *stringDeletion reason
note_severity *string'info', 'warning', 'error'
note_source *string'ai' or 'user'
note_typestring'entry_deletion'

delete_user_custom_entry

Delete entry from user_directives.db table, writing an entry_deletion note in the same transaction

ParameterTypeDescription
record_id *integerRecord ID to delete
table *stringTable name in user_directives.db
note_reasonstringWhy the row was deleted; recorded in the entry_deletion note ('no reason given' when omitted)
note_sourcestringWho deleted it: 'ai', 'user', or 'directive' (default 'ai'); stored in the note's metadata_json

detect_conflicts_before_merge

Dry-run merge analysis - retrieves potential conflict data for AI to evaluate

ParameterTypeDescription
source_branch *stringBranch to merge from

detect_external_changes

Compare current Git HEAD with project.last_known_git_hash

detect_state_conflicts

(For use with InterCommAIMFP) OPTIONAL pre-apply planning aid: export each pending worker branch and report where two or more branches touch the SAME semantic entity or edge, so the master can re-partition or deliberately order integration BEFORE applying any changeset. Pure read (built entirely from export_state_changeset). An overlap is a heuristic warning, not a verdict — the authoritative 3-way resolution still happens in apply_state_changeset.

ParameterTypeDescription
branches *arrayList of {branch, base_commit, worker_id?} objects to cross-reference for semantic-key overlap

execute_merge

Execute git merge and return result. Updates work_branches table on success.

ParameterTypeDescription
source_branch *stringBranch to merge from

export_state_changeset

(For use with InterCommAIMFP) Export a semantic changeset of project.db between two committed git states (branch point -> branch tip), expressed entirely in stable semantic keys (file path, file+function/type name, module/theme/flow/path name, and work-hierarchy slugs) with branch-local integer PKs stripped. Each entity is classified add/modify/delete and each edge add/remove. This is the integer-free artifact the master applies to merge a worker's project-state into main without binary-blob conflicts or PK collisions. The changeset is ALSO persisted server-side under .aimfp-project/changesets…

ParameterTypeDescription
base_commit *stringGit commit the branch was based on (the 3-way base / branch point)
branch *stringGit ref (branch name or commit) whose committed project.db is the branch intent
worker_idstringOptional InterCommAIMFP worker identity; the master supplies it

file_has_changed

Check if file changed using Git (if available) or filesystem timestamp

ParameterTypeDescription
file_id *integerFile ID to check

finalize_file

Mark a reserved file as tracked after writing it to disk. The path must be a regular file relative to the project root: '.', a directory, or a path leaving the project is refused. Triggers flow assignment and function/type tracking checks.

ParameterTypeDescription
file_id *integerReserved ID
language *stringLanguage
name *stringFinal name with _id_xx suffix
path *stringFile path
skip_id_namingbooleanIf true, skip _id_XX pattern validation (for files where ID naming was skipped during reservation)

finalize_files

Batch-finalize multiple reserved files after writing them to disk. All-or-nothing operation. Each path must be a regular file relative to the project root ('.' or a directory is refused).

ParameterTypeDescription
files *arrayArray of file objects [{file_id, name, path, language, skip_id_naming?}, ...]

finalize_function

Mark a reserved function as tracked after writing it. Triggers interaction and type-function relationship checks.

ParameterTypeDescription
file_id *integerFile ID
function_id *integerReserved function ID
name *stringFinal name with _idxx suffix
parametersarrayFunction parameters
purposestringFunction purpose
returnsobjectReturn value specification
skip_id_namingbooleanIf true, skip _id_XX pattern validation (for functions where ID naming was skipped during reservation)

finalize_functions

Batch-finalize multiple reserved functions after writing them. Triggers interaction and type-function checks for all.

ParameterTypeDescription
functions *arrayArray of function objects [{function_id, name, file_id, purpose, parameters, returns, skip_id_naming?}, ...]

finalize_type

Finalize reserved type after creation

ParameterTypeDescription
definition_json *objectADT definition
name *stringFinal name with _idxx suffix
type_id *integerReserved type ID
descriptionstringType description
file_idintegerFile ID where type is defined
linksobjectLinks to related functions
skip_id_namingbooleanIf true, skip _id_XX pattern validation (for types where ID naming was skipped during reservation)

finalize_types

Finalize multiple reserved types

ParameterTypeDescription
types *arrayArray of type objects [{type_id, name, definition_json, description, links, file_id, skip_id_naming?}, ...]

find_directive_by_intent

Match a natural-language user request to the most relevant directive(s). Use when the user describes what they want and you need to find which directive handles it.

ParameterTypeDescription
user_request *stringUser's natural language request describing behavior to change
thresholdnumberConfidence threshold

find_directives_by_intent_keyword

Find directive IDs matching one or more intent keywords (direct keyword lookup)

ParameterTypeDescription
keywords *Single keyword string or array of keywords
match_modestring"any" for OR logic, "all" for AND logic

get_active_user_directives

Get all user directives with status='active'. Convenience query for checking active directive count.

get_all_completion_paths

Get the project's ordered completion roadmap (stages from setup through completion). Each path contains milestones which contain tasks.

get_all_directive_keywords

Get list of all unique intent keywords available for searching (simple list)

get_all_directive_names

Get list of all directive names (or filtered by types). Returns names only, NOT full directive data. AI queries by name when needs details.

ParameterTypeDescription
typesarrayOptional array of directive types to filter: ['fp', 'project', 'git', 'user_preferences', 'user_system']. If not provided, returns ALL directive names.

get_all_directives

Load all directives for caching (special orchestrator)

get_all_flows

Get project flows (architectural groupings describing intended behavior): all of them, or the ones in flow_ids. Lean by default (descriptions null); detail_level='full' for descriptions. Check BEFORE starting any task to understand the architecture.

ParameterTypeDescription
detail_levelstring'lean' (default): descriptions are null. 'full': descriptions included.
flow_idsarrayOnly these flows, ordered by ID. IDs with no flow are named in return_statements. Omit for every flow.

get_all_infrastructure

Get all infrastructure entries including standard fields (even if empty). Returns complete infrastructure table for session bundling and status reports.

get_all_intent_keywords_with_counts

Get all unique intent keywords with usage counts for analytics

get_all_modules

Get all modules in the project. Returns list of all module records sorted by name.

get_all_themes

Get all project themes (high-level architectural areas). Use to orient on project structure before starting work.

get_categories

Get all directive categories

get_category_by_name

Get category by name (fairly frequent)

ParameterTypeDescription
category_name *stringCategory name

get_claude_permissions

Returns the Claude Code allowlist (.claude/settings.local.json contents) that pre-approves every AIMFP MCP tool, so the user is not prompted once per tool on first use. Allowlist is derived live from the tool registry so it can never drift. Does NOT write any file — returns ready-to-write JSON + target path; the AI writes/merges it, keeping AIMFP's 'never write outside .aimfp-project/' guarantee intact. Call when the user asks to set up AIMFP permissions or skip approval prompts.

ParameterTypeDescription
existing_settingsstringCurrent text of the project's .claude/settings.local.json if it already exists (read it and pass it in). When given, the result is a merge that preserves all non-AIMFP permissions and other top-level…

get_completion_loop_target

Get where to loop back after completing directive

ParameterTypeDescription
from_directive *stringDirective name

get_completion_paths_by_status

Get completion paths filtered by status

ParameterTypeDescription
status *string'pending', 'in_progress', 'completed'

get_core_fields

Get field names and types for a specific table

ParameterTypeDescription
table *stringTable name

get_core_schema

Get complete schema for core database (all tables and fields)

get_core_tables

List all tables in core database

get_current_branch

Get current Git branch name

get_current_commit_hash

Get current Git HEAD commit hash

get_current_progress

Single entry point for scoped project status queries. Replaces 5-10 separate helper calls with one flexible query.

ParameterTypeDescription
detail_levelstring'minimal' (counts), 'lean' (default: key columns, open work first, 50 rows), 'full' (every column, every row). 'standard' is accepted as 'lean'.
filtersobjectWHERE-like conditions: {field: value} or {field: {operator: value}}
scopestringWhat to retrieve: 'tasks', 'milestones', 'completion_paths', 'files', 'functions', 'flows', 'themes', 'infrastructure', 'all'

get_databases

Get list of all available databases with metadata

get_directive_by_name

Load a directive's workflow steps, preferences, and linked notes by name. ALWAYS call BEFORE executing any workflow — directives are the authoritative source, not memory.

ParameterTypeDescription
directive_name *stringDirective name to look up
project_rootstringProject root directory. When provided, also retrieves directive preferences from user_preferences.db and linked notes (send_with_directive=1) from project.db.

get_directive_content

Read and return the full MD documentation file for a directive. Resolves the md_file_path from aimfp_core.db to an absolute path within the installed package, reads the file, and returns content + absolute path + token estimate.

ParameterTypeDescription
directive_name *stringDirective name (e.g., 'fp_purity', 'aimfp_init', 'project_file_write')

get_directive_execution_stats

Read execution statistics from directive_executions joined to directive names and statuses, for one user directive or all of them. Includes a derived error_rate per row. This is how the AI sees what the user's automation did while no session was open — executions, successes, errors, average and maximum duration, and the last recorded error. On a database at schema 1.3 or later, each row also carries skip_count, consecutive_skip_count, last_skip_time, last_skip_reason, condition_latched and last_condition_eval_time.

ParameterTypeDescription
directive_idintegerOne directive, or omit for all
project_rootstringProject root; defaults to the session root

get_directive_flows

General-purpose query for directive flows by category, type, or directive names. Complements the navigation helpers (get_flows_from_directive, get_flows_to_directive, get_wildcard_flows), which answer where a specific directive routes.

ParameterTypeDescription
flow_categorystringFilter by category: 'project', 'fp', 'user_preferences', 'git'
flow_typestringFilter by type: 'status_branch', 'completion_loop', 'conditional', 'error'
from_directivestringFilter by source directive name
to_directivestringFilter by target directive name

get_directive_keywords

Get all intent keywords for a specific directive

ParameterTypeDescription
directive_id *integerDirective ID

get_directives_by_category

Get all directives in a category

ParameterTypeDescription
category_name *stringCategory name

get_directives_by_type

Get all directives filtered by type (orchestration vs reference)

ParameterTypeDescription
type *stringOne of: 'fp', 'project', 'git', 'user_system', 'user_preference'
include_md_contentbooleanInclude full MD file content

get_directives_for_helper

Get all directives that use a helper (reciprocal lookup)

ParameterTypeDescription
helper_name *stringHelper name

get_directives_with_intent_keywords

Search directives by intent keywords and return full directive objects

ParameterTypeDescription
keywords *Single keyword or array of keywords
include_keyword_matchesbooleanInclude which keywords matched
match_modestring"any" for OR logic, "all" for AND logic

get_file_by_name

Look up a tracked file by name — use BEFORE reading source files. Returns metadata, path, and ID for follow-up queries.

ParameterTypeDescription
file_name *stringFile name to look up (e.g., 'calculator_id_42.py')

get_file_by_path

Look up a tracked file by path — use BEFORE reading source files. Returns file metadata and ID for follow-up queries.

ParameterTypeDescription
file_path *stringFile path to look up (e.g., 'src/calculator.py')

get_file_ids_from_flows

Get all file IDs associated with flows

ParameterTypeDescription
flow_ids *arrayArray of flow IDs [1, 3, 5]

get_files_by_flow

Get all files for a flow

ParameterTypeDescription
flow_id *integerFlow ID

get_files_by_flow_context

Get all files for a flow with functions embedded in each file dict.

ParameterTypeDescription
flow_id *integerFlow ID to get files for

get_flow_by_name

Get flow by name (fairly frequent)

ParameterTypeDescription
flow_name *stringFlow name to look up

get_flows_for_file

Get all flows for a file

ParameterTypeDescription
file_id *integerFile ID

get_flows_for_milestone

Get the flows a milestone builds or changes (id, name, description). Use for task flow_ids and before starting milestone work.

ParameterTypeDescription
milestone_id *integerMilestone ID

get_flows_for_theme

Get all flows for a theme

ParameterTypeDescription
theme_id *integerTheme ID

get_flows_from_directive

Get all flows originating from a directive (what comes next?). Returns raw flow data - AI evaluates conditions.

ParameterTypeDescription
from_directive *stringSource directive name

get_flows_to_directive

Get all directive flows leading to a directive (what leads here?). Useful for understanding directive prerequisites.

ParameterTypeDescription
to_directive *stringTarget directive name

get_fp_directive_index

Get lightweight FP directive index grouped by category (names only, not full definitions)

get_from_core

Get records by ID(s), or all records if empty array

ParameterTypeDescription
id_array *arrayArray of integer IDs to fetch, **empty array [] returns ALL records**
table *stringTable name

get_from_core_where

Flexible filtering with structured JSON conditions

ParameterTypeDescription
conditions *objectField-value pairs (AND logic), e.g., `{"type": "fp", "category": "purity"}`
table *stringTable name
limitintegerMaximum rows to return
orderbystringSort order, e.g., "name ASC" or "id DESC"

get_from_project

Get records by ID(s) - **EMPTY ARRAY NOT ALLOWED**

ParameterTypeDescription
id_array *arrayArray of integer IDs - **MUST contain at least one ID**
table *stringTable name

get_from_project_where

Flexible filtering with structured JSON conditions

ParameterTypeDescription
conditions *objectField-value pairs (AND logic)
table *stringTable name
limitintegerMaximum rows to return
orderbystringSort order

get_from_settings

Get records by ID(s) - **EMPTY ARRAY NOT ALLOWED**

ParameterTypeDescription
id_array *arrayArray of integer IDs - **MUST contain at least one ID**
table *stringTable name

get_from_settings_where

Flexible filtering with structured JSON conditions

ParameterTypeDescription
conditions *objectField-value pairs (AND logic)
table *stringTable name in user_preferences.db

get_from_user_custom

Get records by ID(s) from user_directives.db - **EMPTY ARRAY NOT ALLOWED**

ParameterTypeDescription
id_array *arrayArray of integer IDs - **MUST contain at least one ID**
table *stringTable name in user_directives.db

get_from_user_custom_where

Flexible filtering with structured JSON conditions on user_directives.db tables

ParameterTypeDescription
conditions *objectField-value pairs combined with AND logic
table *stringTable name in user_directives.db

get_function_by_name

Look up a tracked function by name with file location — use BEFORE reading source files. Returns purpose, parameters, returns, and file path.

ParameterTypeDescription
function_name *stringFunction name to look up
details_onlybooleanIf true, return only id/name + purpose/parameters/returns (when AI already has the rest)
file_idintegerOnly the function defined in this tracked file.
file_pathstringOnly the function defined in this project-relative file (names are not unique across files).
include_detailsbooleanIf false, omit purpose/parameters/returns for lightweight listing

get_functions_by_file

Get all tracked function signatures for a file — use BEFORE reading source code. Often provides everything needed without opening the file.

ParameterTypeDescription
file_id *integerFile ID to get functions for
details_onlybooleanIf true, return only id/name + purpose/parameters/returns (when AI already has the rest)
include_detailsbooleanIf false, omit purpose/parameters/returns for lightweight listing

get_git_status

Get comprehensive Git state snapshot (orchestrator)

get_helper_by_name

Get specific helper function details (high-frequency)

ParameterTypeDescription
helper_name *stringHelper name to look up

get_helpers_are_sub

Get all sub-helpers (is_sub_helper=true)

get_helpers_are_tool

Get all MCP tools (is_tool=true)

get_helpers_by_database

Get all helpers for a specific database

ParameterTypeDescription
target_database *stringDatabase name ('core', 'project', 'settings', 'user_custom')

get_helpers_for_directive

Get the list of MCP tools available for a directive workflow. Use to discover which tools to call when executing a directive's steps.

ParameterTypeDescription
directive_name *stringName of the directive to get helpers for
include_helpers_databooleanIf true, includes full helper_functions data

get_hooks

Get AIMFP's library surface for code running OUTSIDE AIMFP (src/aimfp/hooks/). Hooks are NOT MCP tools and you cannot call them — they are imported by code that is not AIMFP, such as a generated Use Case 2 automation runner firing from cron or systemd with no AI session open. Your relationship to a hook is that you WRITE CODE CALLING IT during user_directive_implement. Queries is_hook=1 affirmatively; it replaced get_helpers_not_tool_not_sub, which described hooks as the absence of two other flags and so returned an empty list silently for as long as nothing populated that gap.

get_incomplete_completion_paths

Get all non-completed paths

get_incomplete_items

Get incomplete items for any parent type

ParameterTypeDescription
for_id *integerParent ID
for_table *string"tasks", "subtasks", "sidequests" (accepts singular)

get_incomplete_milestones

Get all non-completed milestones

ParameterTypeDescription
detail_levelstring'lean' (default): descriptions are null. 'full': descriptions included.
include_task_countsbooleanAttach task_counts to each milestone: {pending, in_progress, blocked, completed, total} (zeros included), from one grouped query.

get_incomplete_sidequests

Get all non-completed sidequests

get_incomplete_subtasks

Get all non-completed subtasks

get_incomplete_subtasks_by_task

Get incomplete subtasks for specific task

ParameterTypeDescription
task_id *integerTask ID

get_incomplete_tasks

Get all unfinished tasks (pending, in_progress, blocked) as flat task rows. Does NOT include subtasks, sidequests or items: use get_open_work for the whole open tree (tasks with their open items and subtasks, plus sidequests) in one call.

ParameterTypeDescription
detail_levelstring'lean' (default): descriptions are null. 'full': descriptions included.

get_incomplete_tasks_by_milestone

Get open tasks for a milestone with related subtasks/sidequests

ParameterTypeDescription
milestone_id *integerID of the milestone to query tasks for
skip_pendingbooleanIf true, excludes pending tasks

get_infrastructure_by_type

Get all infrastructure of specific type

ParameterTypeDescription
type *stringInfrastructure type (e.g., 'language', 'package', 'testing', 'database', 'build_tool')

get_interactions_by_file

Get all interactions involving functions in a file or a set of files (file_ids), each with source and target function names and file paths — one call for a feature's whole dependency picture.

ParameterTypeDescription
file_idintegerFile ID to look up interactions for
file_idsarraySeveral file IDs at once (combined with file_id): every edge touching any of them, each once, with source/target names and paths.

get_interactions_by_function

Get all interactions for a function (both as source and target) — trace dependency graphs

ParameterTypeDescription
file_pathstringWith function_name: only the function defined in this project-relative file.
function_idintegerExact function ID (takes precedence over function_name).
function_namestringFunction name to look up (all functions with that name unless file_path narrows it).

get_items_for_sidequest

Get items for sidequest

ParameterTypeDescription
sidequest_id *integerSidequest ID
statusstring'pending', 'in_progress', 'completed' (NULL = all)

get_items_for_subtask

Get items for subtask

ParameterTypeDescription
subtask_id *integerSubtask ID
statusstring'pending', 'in_progress', 'completed' (NULL = all)

get_items_for_task

Get items for task, optionally filtered by status

ParameterTypeDescription
task_id *integerTask ID
statusstring'pending', 'in_progress', 'completed' (NULL = all)

get_merge_history

(For use with InterCommAIMFP) Read tool over the existing merge_history and work_branches tables: which branches were integrated, when, with how many conflicts, by whom. Lets the master answer 'has this branch already been applied?' (idempotency / resume after interruption) and gives a human an audit trail. Pure read; small surface over data merge_worker_branch records.

ParameterTypeDescription
branchstringOptional source-branch filter (exact match on merge_history.source_branch and work_branches.branch_name)
sincestringOptional ISO timestamp lower bound on merge_history.merge_timestamp (e.g. '2026-06-26')

get_milestones_by_path

Get all milestones for a completion path

ParameterTypeDescription
completion_path_id *integerCompletion path ID
detail_levelstring'lean' (default): descriptions are null. 'full': descriptions included.
include_task_countsbooleanAttach task_counts to each milestone: {pending, in_progress, blocked, completed, total} (zeros included), from one grouped query.

get_milestones_by_status

Get milestones filtered by status

ParameterTypeDescription
status *string'pending', 'in_progress', 'completed', 'blocked'
detail_levelstring'lean' (default): descriptions are null. 'full': descriptions included.
include_task_countsbooleanAttach task_counts to each milestone: {pending, in_progress, blocked, completed, total} (zeros included), from one grouped query.

get_module_by_name

Get module by name. Returns module record with path, purpose, and external_dependencies.

ParameterTypeDescription
name *stringModule name to look up

get_module_by_path

Get module by directory path.

ParameterTypeDescription
path *stringDirectory path to look up

get_module_dependencies

Get cross-module dependencies. Finds interactions where a function in this module calls a function in a different module via module_files junction. Returns aggregated counts per target module.

ParameterTypeDescription
module_id *integerModule ID

get_module_files

Get all files assigned to a module via module_files junction table.

ParameterTypeDescription
module_id *integerModule ID

get_module_for_file

Find which module a file belongs to. Reverse lookup via module_files junction table.

ParameterTypeDescription
file_id *integerFile ID to look up

get_module_functions

Get all functions in module files. Joins through module_files junction to files to functions.

ParameterTypeDescription
module_id *integerModule ID

get_module_types

Get all types in module files. Joins through module_files junction to files to types.

ParameterTypeDescription
module_id *integerModule ID

get_next_completion_path

Get lowest order_index with status != completed

get_notes_comprehensive

Query notes with structured filters (id, type, reference, source, severity, directive). Use note_id to read one note in full, e.g. after search_notes returned a preview.

ParameterTypeDescription
directive_namestringFilter by directive name
exclude_note_typesarrayList of note_type values to exclude from results (e.g., ['completed', 'obsolete'])
limitintegerMaximum notes returned, newest first (default: all)
note_idintegerExact note ID — returns that single note with full content. Errors if not found or excluded by other filters
note_typestringFilter by note_type
preview_charsintegerCap each note's content at this many characters (default: full content)
reference_idintegerFilter by reference ID
reference_tablestringFilter by reference table
severitystringFilter by severity ('info', 'warning', 'error')
sourcestringFilter by source ('ai', 'user', 'directive')

get_open_work

Every open task (pending, in_progress, blocked) with its open items and open subtasks (each with open items), plus open sidequests with their open items, in one read-only call. Ordered in_progress first, then by priority. Replaces get_incomplete_tasks followed by one get_items_for_task per task.

ParameterTypeDescription
include_descriptionsbooleanAdd truncated descriptions to each task, subtask and sidequest. Off keeps the payload small.
milestone_idintegerLimit to tasks of one milestone (and their subtasks and sidequests). Omit for all open work.

get_pending_notices

Get one-time release notices this project has not yet been shown. Returns ONLY unacknowledged notices, already filtered for applicability — a notice pinned to a schema version stays hidden until that database has actually reached it. An empty result is the normal steady state. Called automatically by aimfp_run(is_new_session=true), which puts the result in data.notices and omits the key entirely when nothing is pending, so you never need to call this yourself in a normal session.

get_project

Get project metadata (single entry)

get_project_fields

Get field names and types for a specific table

ParameterTypeDescription
table *stringTable name to get fields for

get_project_json_parameters

Get available fields for table to use with generic add/update operations

ParameterTypeDescription
table *stringTable name to get available fields for

get_project_root

Get project root directory from infrastructure table

get_project_schema

Get complete schema for project database

get_project_tables

List all tables in project database

get_recent_directive_errors

Tail the JSON-lines directive error log, newest first, optionally filtered to one directive. Each record carries directive_id, error_type, message, timestamp, and a full traceback when the failure came from a handler exception. The database keeps only the last error per directive (store_last_error_only defaults to 1), so this file is the only place error history survives.

ParameterTypeDescription
directive_idintegerFilter to one directive, or omit for all
limitintegerMaximum records to return, newest first
project_rootstringProject root; defaults to the session root

get_settings_fields

Get field names and types for a specific table

ParameterTypeDescription
table *stringTable name to get fields for

get_settings_json_parameters

Get available fields for table to use with generic add/update operations

ParameterTypeDescription
table *stringTable name to get available fields for

get_settings_schema

Get complete schema for user settings database

get_settings_tables

List all tables in user settings database

get_sidequest_files

Get the files worked on for a sidequest (task_files junction). Files are linked automatically when reserved, finalized, cataloged, or updated (and when their functions/types are finalized, cataloged, or updated) while a work item is in_progress — the most recent in_progress sidequest, else subtask, else task.

ParameterTypeDescription
sidequest_id *integerSidequest ID

get_sidequest_flows

Get flow IDs for a sidequest

ParameterTypeDescription
sidequest_id *integerSidequest ID

get_sidequests_comprehensive

Advanced sidequest search

ParameterTypeDescription
date_range_createdarray[start_date, end_date]
date_range_updatedarray[start_date, end_date]
limitintegerMaximum results
prioritystring'low', 'medium', 'high', 'critical'
statusstring'pending', 'in_progress', 'completed', 'blocked' (NULL = all)
subtask_idintegerFilter by paused subtask
task_idintegerFilter by paused task

get_source_directory

Get project source directory from infrastructure table

get_state_operations_template

Return the Python state_operations.py template content for AI to adapt to the project's language. Use this to retrieve the CRUD helper template for .state/runtime.db.

get_structure_health

Report the project's modularity layer and every gap in it: themes -> flows -> files, open paths -> themes, open milestones -> flows, module membership. Gaps: flows without theme, themes without flows, files without flow (and no no_flow_reason), files under a module path but in no module, open paths without themes, open milestones without flows, oversized flow descriptions (split candidates). The same report appears in aimfp_status, aimfp_end and watchdog reminders.

ParameterTypeDescription
include_summarybooleanAlso return the themes/flows/paths/milestones map (default true)

get_subtasks_by_task

Get subtasks for task, optionally filtered by status

ParameterTypeDescription
task_id *integerTask ID
statusstring'pending', 'in_progress', 'completed', 'blocked' (NULL = all)

get_subtasks_comprehensive

Advanced subtask search

ParameterTypeDescription
date_range_createdarray[start_date, end_date]
date_range_updatedarray[start_date, end_date]
limitintegerMaximum results
prioritystring'low', 'medium', 'high', 'critical'
statusstring'pending', 'in_progress', 'completed', 'blocked' (NULL = all)
task_idintegerFilter by task

get_supportive_context

Returns supportive context reference documents by variant. All variants auto-provided: core + coding by aimfp_run(is_new_session=true) for initialized projects, case2 by aimfp_run when Case 2 active, init by aimfp_init(). Also callable on demand to reload stale context.

ParameterTypeDescription
variantstringWhich context to load: 'core' (workflow, routing, edge cases — default), 'init' (discovery depth, initialization), 'coding' (file loop, DRY, interactions, types), 'case2' (Use Case 2 pipeline)

get_system_prompt

Returns the AIMFP system prompt (AIMFP's record-keeping backbone) plus where and how to place it. The user's FIRST move — especially for plugin installs where nothing was downloaded — is to ask the AI to add the AIMFP system prompt; the AI calls this and writes the file. Does NOT write anything: returns the prompt text + target path + placement policy; the AI does the write, keeping AIMFP's 'never write outside .aimfp-project/' guarantee. AIMFP content is always placed FIRST; if the existing instructions file is extensive the AI must review/consolidate with the user instead of blindly prep…

ParameterTypeDescription
existing_contentstringCurrent text of the target instructions file (e.g. CLAUDE.md) if it already exists — read it and pass it in so the placement guidance can account for size/consolidation. Omit/empty if there is no ex…

get_task_context

Get complete context for resuming work on a specific task/subtask/sidequest. Single call retrieves item + associated items + linked files + their functions and modules + flows + optionally interactions and notes. Files are linked automatically when reserved, finalized, cataloged, or updated (and when their functions/types are finalized, cataloged, or updated) while a work item is in_progress — the most recent in_progress sidequest, else subtask, else task. A task's context includes its subtasks' files. Uses cached project root internally.

ParameterTypeDescription
task_id *integerID of the task/subtask/sidequest
detail_levelstring'lean' (default): the work item in full; items with descriptions only while open; flows id/name; files with their functions as id/name; modules id/name/path/purpose. 'full': every record as stored (fu…
include_historybooleanInclude note history for task
include_interactionsbooleanInclude function dependency interactions
task_typestringType of task: 'task', 'subtask', 'sidequest'. Auto-detected from task_id if omitted.

get_task_files

Get the files worked on for a task, including files linked to its subtasks (task_files junction). Files are linked automatically when reserved, finalized, cataloged, or updated (and when their functions/types are finalized, cataloged, or updated) while a work item is in_progress — the most recent in_progress sidequest, else subtask, else task.

ParameterTypeDescription
task_id *integerTask ID

get_task_flows

Get the architectural flow IDs for a task. Use to understand which part of the codebase a task touches and find relevant files.

ParameterTypeDescription
task_id *integerTask ID

get_tasks_by_milestone

Get the tasks of a milestone (any status, or one status with status=...). Lean by default: descriptions null.

ParameterTypeDescription
milestone_id *integerMilestone ID
detail_levelstring'lean' (default): descriptions are null. 'full': descriptions included.
statusstringOnly tasks with this status. Omit for every status.

get_tasks_comprehensive

Advanced task search with multiple filters

ParameterTypeDescription
date_range_createdarray[start_date, end_date]
date_range_updatedarray[start_date, end_date]
limitintegerMaximum results
milestone_idintegerFilter by milestone
prioritystring'low', 'medium', 'high', 'critical'
statusstring'pending', 'in_progress', 'completed', 'blocked' (NULL = all)

get_theme_by_name

Get theme by name (fairly frequent)

ParameterTypeDescription
theme_name *stringTheme name to look up

get_themes_for_flow

Get all themes for a flow

ParameterTypeDescription
flow_id *integerFlow ID

get_themes_for_path

Get the themes a completion path advances (id, name, description).

ParameterTypeDescription
completion_path_id *integerCompletion path ID

get_tracking_notes

Get tracking notes with optional filters

ParameterTypeDescription
directive_namestringFilter by directive_name
note_typestringFilter by note_type
reference_namestringFilter by reference_name
reference_typestringFilter by reference_type
severitystringFilter by severity

get_tracking_settings

Get all tracking feature flags

get_type_by_name

Look up a tracked type by name with full definition and file location — use BEFORE reading source files. Returns definition_json and description.

ParameterTypeDescription
type_name *stringType name to look up
details_onlybooleanIf true, return only id/name + definition_json/description/links (when AI already has the rest)
include_detailsbooleanIf false, omit definition_json/description/links for lightweight listing

get_unassigned_files

Find files not assigned to any module. Useful for identifying tracking gaps — domain logic files that should belong to a module but haven't been assigned.

get_user_custom_fields

Get field names and types for a specific table in user_directives.db

ParameterTypeDescription
table *stringTable name to get fields for

get_user_custom_json_parameters

Get available fields for table to use with generic add/update operations. Returns field names, types, and whether required.

ParameterTypeDescription
table *stringTable name to get available fields for

get_user_custom_schema

Get complete schema SQL for user directives database

get_user_custom_tables

List all tables in user directives database

get_user_directive_by_name

Get a single user directive by its unique name

ParameterTypeDescription
name *stringDirective name (exact match)

get_user_directive_notes

Get notes from user_directives.db with optional filters. All filters are AND logic. No filters returns all notes.

ParameterTypeDescription
exclude_note_typesarrayList of note_type values to exclude from results (e.g., ['completed', 'obsolete'])
limitintegerMaximum number of notes to return (default 100)
note_typestringFilter by note_type
reference_idintegerFilter by reference_id
reference_namestringFilter by reference_name
reference_typestringFilter by reference_type
severitystringFilter by severity

get_user_setting

Get project-wide user setting by key (fairly frequent)

ParameterTypeDescription
setting_key *stringSetting key to retrieve

get_user_settings

Get all user settings from user_settings table (complements get_user_setting which gets one setting by key)

get_wildcard_flows

Get all directive flows from wildcard '*' source (available from ANY context). Includes FP references, utilities, cross-cutting concerns.

ParameterTypeDescription
flow_typestringOptional filter: 'reference_consultation', 'utility', 'conditional', etc.

init_user_directives_db

Initialize user_directives.db for Case 2 (custom directive automation) projects. Creates the database from schema. Call when project transitions to Case 2.

list_active_branches

List all AIMFP work branches from work_branches table

list_project_backups

List available backup archives, newest first, with size, modification time, and which targets each one actually contains. Read-only. Call BEFORE restore_project_backup: a backup only holds databases that existed when it was taken, so an older archive may not carry every target you want.

load_directive_preferences

Load all active preferences for a directive (high-frequency)

ParameterTypeDescription
directive_name *stringDirective name to load preferences for

merge_worker_branch

(For use with InterCommAIMFP) ONE-CALL branch-ref merge orchestrator: takes a branch name and runs the whole documented sequence internally — export_state_changeset, optional source text-merge (keeping main's project.db, never blob-merging it), then apply_state_changeset — returning only a small result/conflict summary. The ~8k-token changeset never crosses the agent boundary, so a real fan-out stops serializing on the master hand-carrying blobs. Idempotent like apply; records a merge_history row; conflicts are still returned as structured data (never guessed). Mutates the working project.…

ParameterTypeDescription
branch *stringGit ref of the worker branch to integrate, e.g. 'aimfp-alice-001'
base_commitstring3-way base / branch point. Default = git merge-base(HEAD, branch)
on_conflictstring'report' to apply DB state even if the source merge conflicts, or 'abort' to stop before applying
sourcestring'auto' to also text-merge the branch's SOURCE into main (keeping main's project.db), or 'skip' to merge only DB state
worker_idstringOptional InterCommAIMFP worker identity (provenance + status hint)

merge_worker_branches

(For use with InterCommAIMFP) Batch wrapper over merge_worker_branch: integrate a list of worker branches one at a time, each moving main forward and re-minting against the prior. 'additive-first' ordering lands the low-risk purely-additive branches before any structural/deleting ones. Each branch goes through the full export->source-merge->apply sequence; conflicts are surfaced per branch, never guessed.

ParameterTypeDescription
branches *arrayList of branch names (strings) or {branch, base_commit?, worker_id?} objects to integrate one at a time
on_conflictstring'stop' to halt the batch on the first branch that returns conflicts, or 'continue' to integrate the rest
orderstring'as-listed' or 'additive-first' (branches with no delete/remove ops integrate first)

migrate_databases

Migrate all pending project databases to current schema versions, in place. Per database: refuses if another connection has it open, write-locks it, keeps a pre-migration copy at <project folder>/backups/<db>_pre_migration_v<old>_<YYYYMMDD>.db (never overwriting an earlier copy), rebuilds it from the new schema SQL (shared columns via ATTACH), verifies row counts and atomically swaps the rebuilt file in. A count mismatch or any error leaves the original untouched (placed=false, error). Nothing is left in temp folders.

ParameterTypeDescription
aimfp_folderstringAIMFP project directory name

move_files_to_flow

Re-point many files from one flow to another in one transaction — the tool for splitting an oversized flow or retiring one. Moves links only; files are never touched. Files not in the source flow are skipped.

ParameterTypeDescription
file_ids *arrayFiles to move
from_flow_id *integerFlow they leave
to_flow_id *integerFlow they join

move_flows_to_theme

Re-point many flows from one theme to another in one transaction (e.g. when a theme is split or merged). Flows not in the source theme are skipped.

ParameterTypeDescription
flow_ids *arrayFlows to move
from_theme_id *integerTheme they leave
to_theme_id *integerTheme they join

plan_disjoint_partitions

(For use with InterCommAIMFP) Compute DISJOINT file/module partitions so parallel workers don't overlap — the cheap complexity lever that converts most semantic conflicts into non-events. Only AIMFP can compute this well because it owns the function->function interaction graph and type-usage edges that define real dependency boundaries. Builds an undirected file-coupling graph (interaction edges + type-usage edges + module co-membership), takes connected components as atomic ownership units (never split), and bin-packs whole components into n_workers balanced partitions. Returns proposed per…

ParameterTypeDescription
n_workersintegerNumber of partitions to pack components into. Omit for one partition per connected component.
targetsarrayFile paths, module names, or task/milestone slugs to partition. Omit to partition every tracked file.

project_allowed_check_constraints

Returns list of allowed values for CHECK constraint enum fields in project.db. Parses schema to extract CHECK(field IN (...)) constraints.

ParameterTypeDescription
field *stringField name to get allowed values for
table *stringTable name to check for CHECK constraints

query_core

Execute complex SQL WHERE clause (advanced, rare use)

ParameterTypeDescription
query *stringWHERE clause without "WHERE" keyword
table *stringTable name

query_project

Execute complex SQL WHERE clause (advanced, rare use)

ParameterTypeDescription
query *stringWHERE clause without "WHERE" keyword
table *stringTable name

query_project_state

Flexible SQL-like query interface for complex project queries. Provides powerful filtering and joining capabilities without writing raw SQL.

ParameterTypeDescription
entity *stringPrimary table to query: 'tasks', 'subtasks', 'sidequests', 'milestones', 'files', 'functions', 'flows', 'themes', etc.
filtersobjectWHERE-like conditions with operators: {field: value} or {field: {op: 'gt', value: 5}}
joinsarrayRelations to include via LEFT JOIN: ['milestones', 'files']
limitintegerMaximum results (pagination)
offsetintegerSkip first N results (pagination)
sortstringORDER BY clause: 'field ASC' or 'field DESC'

query_settings

Execute complex SQL WHERE clause (advanced, rare use)

ParameterTypeDescription
table *stringTable name in user_preferences.db
where_clausestringSQL WHERE clause for filtering

query_user_custom

Execute complex SQL WHERE clause on user_directives.db (advanced, rare use)

ParameterTypeDescription
table *stringTable name in user_directives.db
where_clausestringWHERE clause without 'WHERE' keyword

reconcile_paths

Bring the tracking of changed files up to date in ONE call and one transaction (after a git pull, external edits, or edits made outside reserve/finalize). Per path: an untracked file is cataloged with its functions and types; a tracked file gets functions/types newly present in its source cataloged (existing rows and their prose are never touched) and those no longer in the source reported; a tracked file gone from disk is renamed as declared in renames, else to the one untracked path in the call with the same file name, else reported missing; a legacy row recorded at a folder path ('.' or a d…

ParameterTypeDescription
paths *arrayProject-relative paths of files that changed (e.g. from git diff --name-only, or the files you just edited).
dry_runbooleanDo everything, then roll back: the report is exactly what a real run would do.
include_privatebooleanAlso catalog _private functions and types (default true, like scan_source_tree).
renamesarrayMoves to apply first, as [{from, to}] project-relative paths. Needed when a file was renamed as well as moved; take them from git diff -M --name-status (R lines). Both paths are reconciled.

remove_file_from_flow

Remove a file-flow link from the file_flows junction table. Use when reassigning a file to a different flow or preparing for file deletion.

ParameterTypeDescription
file_id *integerFile ID to unlink
flow_id *integerFlow ID to unlink from

remove_file_from_module

Remove a file from a module. Deletes module_files junction entry. File itself is not deleted.

ParameterTypeDescription
file_id *integerFile ID to remove
module_id *integerModule ID to remove from

remove_files_from_module

Batch remove multiple files from modules. More efficient than multiple remove_file_from_module calls. Skips non-existent entries, reports modules left empty.

ParameterTypeDescription
links *arrayList of [file_id, module_id] tuples to remove

remove_flow_themes

Batch-unlink flows from themes. A note is required. Refused (whole batch) if any flow would be left with no theme — link the replacement first, or use move_flows_to_theme.

ParameterTypeDescription
links *arrayArray of [flow_id, theme_id] pairs. One pair links one; many pairs (any mix of flow_ids) apply atomically.
note_reason *stringWhy the links are removed (required; written as an entry_deletion note on each owner row)
note_severity *string'info', 'warning', 'error'
note_source *string'ai', 'user', or 'directive'

remove_milestone_flows

Batch-unlink milestones from flows. A note is required. Refused (whole batch) while an open task or sidequest of that milestone still lists the flow in its flow_ids — update those first.

ParameterTypeDescription
links *arrayArray of [milestone_id, flow_id] pairs. One pair links one; many pairs (any mix of milestone_ids) apply atomically.
note_reason *stringWhy the links are removed (required; written as an entry_deletion note on each owner row)
note_severity *string'info', 'warning', 'error'
note_source *string'ai', 'user', or 'directive'

remove_path_themes

Batch-unlink completion paths from themes. A note is required.

ParameterTypeDescription
links *arrayArray of [completion_path_id, theme_id] pairs. One pair links one; many pairs (any mix of completion_path_ids) apply atomically.
note_reason *stringWhy the links are removed (required; written as an entry_deletion note on each owner row)
note_severity *string'info', 'warning', 'error'
note_source *string'ai', 'user', or 'directive'

reorder_all_completion_paths

Fix gaps and duplicates in order_index

reorder_completion_path

Change order_index for a completion path

ParameterTypeDescription
id *integerCompletion path ID
new_order_index *integerNew order position

reserve_file

Reserve a file ID before writing code, declaring the flow(s) it implements — part of the mandatory reserve-write-finalize tracking flow. flow_ids is required: a list of flows, or an explicit null for a file with no flow. Returns ID to embed in filename.

ParameterTypeDescription
flow_ids *REQUIRED. Flow ID(s) this file implements (get_all_flows / get_task_flows / get_flows_for_milestone). Pass null EXPLICITLY only for a file that belongs to no flow (config, data, fixtures, package mark…
language *stringProgramming language (e.g., 'python', 'javascript', 'typescript')
name *stringPreliminary file name (will have _id_xxx appended)
path *stringFile path relative to project root
no_flow_reasonstringWhy the file belongs to no flow (only with flow_ids=null), e.g. 'build config'. Recorded on the file so structure checks skip it.
skip_id_namingbooleanIf true, skip ID embedding in name (for __init__.py, .db files, MCP tools, or user preference). Sets id_in_name=0 in database.

reserve_files

Batch-reserve file IDs before writing code, each declaring the flow(s) it implements (flow_ids list, or explicit null for no flow). Atomic: all reserve or none.

ParameterTypeDescription
files *arrayArray of file objects [{name, path, language, flow_ids, skip_id_naming?, no_flow_reason?}, ...]. flow_ids is required per file: a list of flow IDs, or null explicitly for a file with no flow (config,…

reserve_function

Reserve a function ID before writing code. Include purpose, parameters, and returns — null fields make functions invisible to future sessions.

ParameterTypeDescription
name *stringFunction name (will have _idxxx appended)
file_idintegerFile ID where the function will be defined (or pass file_path)
file_pathstringProject-relative path of the tracked file, instead of file_id (both given must agree)
parametersarrayFunction parameters
purposestringFunction purpose
returnsobjectReturn value specification
skip_id_namingbooleanIf true, skip ID embedding in name (for MCP tools, private functions excluded). Sets id_in_name=0 in database.

reserve_functions

Batch-reserve function IDs before writing multiple functions. Include purpose/parameters/returns for every function.

ParameterTypeDescription
functions *arrayArray of function objects [{name, file_id | file_path, purpose, parameters, returns, skip_id_naming?}, ...]

reserve_type

Reserve a type ID before writing the definition. Include definition_json and description — null fields force full file reads in future sessions.

ParameterTypeDescription
definition_json *objectADT definition (e.g., {'type': 'enum', 'variants': ['A', 'B']})
name *stringType name (will have _idxxx appended)
descriptionstringType description
file_idintegerFile ID where type is defined
linksobjectLinks to related functions
skip_id_namingbooleanIf true, skip ID embedding in name. Sets id_in_name=0 in database.

reserve_types

Batch-reserve type IDs before writing multiple type definitions. Include definition_json and description for every type.

ParameterTypeDescription
types *arrayArray of type objects [{name, definition_json, description, links, file_id, skip_id_naming?}, ...]

restore_project_backup

Restore selected databases from a backup archive, side-by-side rather than in place. Every requested member is extracted to a temporary file FIRST; only once all extractions succeed is anything live touched. The current file is then moved into backups/ as 'replaced-<timestamp>-<filename>' and the restored copy moved into position. Nothing is ever deleted, so the displaced state remains recoverable.

ParameterTypeDescription
backup_namestringArchive to restore from (e.g. 'aimfp-backup-2026-08-09.zip'). Defaults to the most recent. Get valid names from list_project_backups.
databasesWhich members to restore: any of 'project', 'user_preferences', 'user_directives', 'blueprint', or 'all'. Accepts a list or comma-separated string. Defaults to everything the archive contains. Be spec…

scan_call_graph

Build the interaction graph for already-cataloged functions: which tracked function calls which. Read-only — returns tuples shaped for add_interactions, which does the writing. Run AFTER catalog_files and catalog_functions. Resolution is conservative and strictest-first (explicit import, then same-file, then module alias, then project-wide unique name), following re-export chains through modules that define no functions of their own. Ambiguous targets are dropped and counted rather than guessed at, because a wrong edge sends future refactors chasing dependencies that do not exist.

ParameterTypeDescription
module_pathstringProject-relative subtree to limit analysis to. Only the CALLING side is narrowed — functions outside it still resolve as targets, so cross-module edges are never lost.

scan_source_tree

Read-only inventory of an existing codebase for adoption into AIMFP tracking. Walks source_directory applying the watchdog's exact exclusion stack (built-in exclusions + watchdog_excluded_* settings + .watchdogignore), extracts signatures, and reports tracked vs untracked. Writes nothing — review the inventory, then register with catalog_files/catalog_functions/catalog_types.

ParameterTypeDescription
include_nestedbooleanInclude functions defined inside other functions
include_privatebooleanInclude underscore-prefixed functions and types
module_pathstringProject-relative subtree to narrow the scan to (e.g. 'src/aimfp/helpers/project'). Defaults to the whole source_directory. Use this to adopt a large codebase one module at a time.
untracked_onlybooleanReport only files with no existing database record. Use on re-scans to see just what is new.

search_directives

Find directives by type, category, or keyword when you know the domain but not the exact directive name. Multi-word input is split into words; a row matches if ANY word prefix-matches ("disk space free" finds get_free_disk_space). Rows matching more words rank first. Punctuation is ignored, so no FTS syntax is needed or honored. Common stopwords (the, of, and, ...) are ignored unless the query is nothing but stopwords. Keyword results are ordered by name/description relevance.

ParameterTypeDescription
categorystringDirective category filter (e.g., 'purity', 'error_handling', 'task_management')
keywordstringFree-text search over directive names, descriptions, and intent keywords, one or more words (e.g. 'task decomposition')
typestringDirective type filter: 'fp', 'project', 'user-system', 'user-pref', 'git'

search_functions

Search tracked functions by name or purpose with relevance ranking. Multi-word input is split into words; a row matches if ANY word prefix-matches ("disk space free" finds get_free_disk_space). Rows matching more words rank first. Punctuation is ignored, so no FTS syntax is needed or honored. Common stopwords (the, of, and, ...) are ignored unless the query is nothing but stopwords. Results are capped by limit; total_count reports all matches.

ParameterTypeDescription
search_string *stringFree-text search over function name and purpose, one or more words (e.g. 'disk space free')
details_onlybooleanIf true, return only id/name + purpose/parameters/returns
include_detailsbooleanIf false, omit purpose/parameters/returns for lightweight listing
limitintegerMaximum functions returned, best matches first (default 20)

search_modules

Search modules by name, purpose, or description with relevance ranking. Multi-word input is split into words; a row matches if ANY word prefix-matches ("disk space free" finds get_free_disk_space). Rows matching more words rank first. Punctuation is ignored, so no FTS syntax is needed or honored. Common stopwords (the, of, and, ...) are ignored unless the query is nothing but stopwords. Results are capped by limit; total_count reports all matches.

ParameterTypeDescription
search_string *stringFree-text search over module name, purpose, and description, one or more words
detail_levelstring'lean' (default): description is null, purpose kept. 'full': description included.
limitintegerMaximum modules returned, best matches first (default 20)

search_notes

Search past decisions and context by keyword. Multi-word input is split into words; a row matches if ANY word prefix-matches ("disk space free" finds get_free_disk_space). Rows matching more words rank first. Punctuation is ignored, so no FTS syntax is needed or honored. Common stopwords (the, of, and, ...) are ignored unless the query is nothing but stopwords. Returns capped previews by default; read a note in full with get_notes_comprehensive(note_id=X).

ParameterTypeDescription
search_string *stringFree-text search over note content, one or more words (e.g. 'hash digest')
directive_namestringOptional filter by directive name
exclude_note_typesarrayList of note_type values to exclude from results (e.g., ['completed', 'obsolete'])
limitintegerMaximum notes returned, best matches first (default 20)
note_typestringOptional filter by note_type
preview_charsintegerCap each note's content at this many characters (default 300; 0 = full content)
reference_idintegerOptional filter by reference ID
reference_tablestringOptional filter by reference table
severitystringOptional filter by severity
sourcestringOptional filter by source

search_tracking_notes

Search tracking note content with optional filters

ParameterTypeDescription
search_string *stringSearch string for note content
directive_namestringOptional filter by directive_name
note_typestringOptional filter by note_type
reference_typestringOptional filter by reference_type

search_types

Search tracked types by name or description with relevance ranking. Multi-word input is split into words; a row matches if ANY word prefix-matches ("disk space free" finds get_free_disk_space). Rows matching more words rank first. Punctuation is ignored, so no FTS syntax is needed or honored. Common stopwords (the, of, and, ...) are ignored unless the query is nothing but stopwords. Results are capped by limit; total_count reports all matches.

ParameterTypeDescription
search_string *stringFree-text search over type name and description, one or more words
details_onlybooleanIf true, return only id/name + definition_json/description/links
include_detailsbooleanIf false, omit definition_json/description/links for lightweight listing
limitintegerMaximum types returned, best matches first (default 20)

search_user_directive_notes

Search note content in user_directives.db with optional additional filters

ParameterTypeDescription
search_string *stringSearch string for note content (case-insensitive LIKE match)
exclude_note_typesarrayList of note_type values to exclude from results (e.g., ['completed', 'obsolete'])
limitintegerMaximum number of notes to return (default 100)
note_typestringOptional filter by note_type
reference_typestringOptional filter by reference_type
severitystringOptional filter by severity

search_user_directives

Search user directives with optional filters. At least one filter required.

ParameterTypeDescription
domainstringFilter by domain (exact match, e.g. 'home_automation', 'aws_infrastructure')
namestringFilter by directive name (LIKE match, case-insensitive)
source_filestringFilter by source_file path (LIKE match)
statusstringFilter by status (exact match)
trigger_typestringFilter by trigger_type (exact match)

set_custom_return_statement

Add a custom return statement for a helper function. Extends core return_statements with user-defined guidance, context, or preferences. To modify: delete first, then set new statement.

ParameterTypeDescription
helper_name *stringHelper function name (should match aimfp_core.db helper_functions.name)
statement *stringCustom return statement text
activebooleanWhether statement is active (default true)
descriptionstringWhy this was added (optional context)

summarize_state_changeset

(For use with InterCommAIMFP) Cheap, low-token counts summary of ONE branch's changeset — add/modify/delete per entity kind, add/remove per reference kind, touched files/modules, and warning count — WITHOUT returning the full ~8k-token object. Affordable to read for every pending branch before deciding apply order. Identify the changeset by changeset_id (loads the persisted artifact) or by branch+base_commit (re-exports). Pure read.

ParameterTypeDescription
base_commitstring3-way base / branch point (used with branch)
branchstringGit ref whose changeset to summarize (requires base_commit)
changeset_idstringHandle from a prior export_state_changeset (loads the persisted artifact, no git work)

swap_completion_paths_order

Swap order_index of two completion paths

ParameterTypeDescription
id1 *integerFirst completion path ID
id2 *integerSecond completion path ID

sync_git_state

Update project.last_known_git_hash with current Git HEAD

toggle_tracking_feature

Enable/disable tracking feature

ParameterTypeDescription
enabled *booleanEnable or disable
feature_name *stringTracking feature name

update_completion_path

Update completion path

ParameterTypeDescription
id *integerCompletion path ID
descriptionstringNew description (NULL = don't update)
namestringNew name (NULL = don't update)
statusstring'pending', 'in_progress', 'completed' (NULL = don't update)

update_directive_preference

Update existing directive preference in directive_preferences table

ParameterTypeDescription
directive_name *stringDirective name
preference_key *stringPreference key to update (must exist)
activebooleanUpdate active status
descriptionstringUpdate description
preference_valuestringNew preference value

update_file

Update file metadata

ParameterTypeDescription
file_id *integerFile ID to update
languagestringLanguage (NULL = don't update)
namestringNew file name (NULL = don't update)
no_flow_reasonstringMark the file as belonging to no flow, with why (config, data) — structure checks then skip it. Empty string clears it (NULL = don't update).
pathstringNew file path (NULL = don't update)

update_flow

Update flow metadata

ParameterTypeDescription
flow_id *integerFlow ID to update
confidence_scorenumberNew confidence score (NULL = don't update)
descriptionstringWhat the flow does now; replaces the old text. Not an evolution log: history goes in add_note(note_type='evolution') (NULL = don't update)
namestringNew name (NULL = don't update)

update_function

Update function metadata

ParameterTypeDescription
function_id *integerFunction ID to update
namestringNew function name (NULL = don't update)
parametersarrayNew parameters (NULL = don't update)
purposestringNew purpose (NULL = don't update)
returnsobjectNew return specification (NULL = don't update)

update_function_file_location

Move function to different file (rarely used)

ParameterTypeDescription
function_id *integerFunction ID to move
new_file_id *integerNew file ID
old_file_id *integerCurrent file ID

update_functions_for_file

Update multiple functions in a single file

ParameterTypeDescription
file_id *integerFile ID
functions *arrayArray of function update objects [{function_id, name, purpose, parameters, returns}, ...]

update_interaction

Update interaction metadata

ParameterTypeDescription
interaction_id *integerInteraction ID to update
descriptionstringNew description (NULL = don't update)
interaction_typestring'call', 'chain', 'borrow', 'compose', 'pipe' (NULL = don't update)
is_indirectbooleanMark (true) or clear (false) the deliberate-indirect flag (NULL = don't update). True for a deliberate edge the code makes indirectly (dispatch through a tuple/table of functions, a chain data-flow li…
source_function_idintegerNew source (NULL = don't update)
target_function_idintegerNew target (NULL = don't update)

update_item

Update a single item's status, name, or description. Primary use: marking items in_progress or completed as work progresses.

ParameterTypeDescription
id *integerItem ID
descriptionstringNew description (NULL = don't update)
namestringNew name (NULL = don't update)
statusstring'pending', 'in_progress', 'completed' (NULL = don't update)

update_items

Batch-update multiple items with the same field values. Primary use: marking multiple items completed at once when parent completes.

ParameterTypeDescription
data *objectField-value pairs to apply to all items (e.g., {status: 'completed'})
ids *arrayArray of item IDs to update
reference_id *integerID of the parent task, subtask, or sidequest that owns every item in ids
reference_table *stringParent the items must belong to: 'tasks', 'subtasks', or 'sidequests'

update_milestone

Update milestone status, name, or description. When completing, check if all milestones in the path are done to cascade completion.

ParameterTypeDescription
id *integerMilestone ID
completion_path_idintegerNew completion path ID (NULL = don't update)
descriptionstringNew description (NULL = don't update)
namestringNew name (NULL = don't update)
statusstring'pending', 'in_progress', 'completed', 'blocked' (NULL = don't update)

update_module

Update module metadata. Only non-None fields are updated.

ParameterTypeDescription
module_id *integerModule ID to update
descriptionstringNew description
external_dependenciesarrayNew dependencies list
namestringNew name
pathstringNew path
purposestringNew purpose

update_note

Update note metadata

ParameterTypeDescription
id *integerNote ID to update
contentstringUpdate note content
directive_namestringUpdate directive name
note_typestringUpdate note_type
reference_idintegerUpdate reference ID
reference_tablestringNew reference table (NULL = don't update). The project.db table the note is attached to (e.g. 'files', 'tasks', 'flows', 'completion_path'). Must be an existing project.db table name, exactly: unknown…
send_with_directivebooleanUpdate send_with_directive flag. If true and directive_name set, note is included when that directive is retrieved.
severitystringUpdate severity
sourcestringUpdate source

update_project

Update project metadata

ParameterTypeDescription
goalsarrayArray of goal strings (NULL = don't update)
namestringProject name (NULL = don't update)
purposestringProject purpose (NULL = don't update)
statusstring'active', 'paused', 'completed', 'abandoned' (NULL = don't update)
user_directives_statusstringNULL, 'pending_discovery', 'pending_parse', 'in_progress', 'active', 'disabled' (NULL = don't update)
versionintegerVersion number (NULL = don't update)

update_project_entry

Update existing entry

ParameterTypeDescription
data *objectField-value pairs to update
id *integerRecord ID
table *stringTable name

update_project_root

Update project root in infrastructure table. Failsafe: Inserts if not exists (should never happen, initialized by SQL).

ParameterTypeDescription
new_project_root *stringNew project root path (absolute path)

update_project_state

Orchestrated state change for tasks, milestones, and paths. Maps actions (start_task, complete_task, block_task, etc.) to correct status updates and note creation.

ParameterTypeDescription
action *stringOperation: 'start_task', 'complete_task', 'pause_task', 'resume_task', 'block_task', 'unblock_task', 'start_subtask', 'complete_subtask', etc.
target_id *integerID of target entity
target_type *stringEntity type: 'task', 'subtask', 'sidequest', 'milestone', 'completion_path'
create_notebooleanAuto-log action as note in notes table
dataobjectAction-specific data (e.g., blocked_by, completion_notes) data.audit_override_reason completes a task/subtask/sidequest despite blocking tracking-audit findings (recorded as a warning note); completio…

update_settings_entry

Update entry in user settings database

ParameterTypeDescription
data *objectField-value pairs to update
record_id *integerRecord ID to update
table *stringTable name in user_preferences.db

update_sidequest

Update sidequest metadata

ParameterTypeDescription
id *integerSidequest ID
audit_override_reasonstringComplete despite blocking tracking-audit findings in the linked files. Recorded as a warning note with the outstanding counts; use only when the drift is understood and will be fixed in follow-up work…
descriptionstringNew description (NULL = don't update)
flow_idsarrayArray of flow IDs (NULL = don't update)
namestringNew name (NULL = don't update)
paused_subtask_idintegerNew paused subtask ID (NULL = don't update)
paused_task_idintegerNew paused task ID (NULL = don't update)
prioritystring'low', 'medium', 'high', 'critical' (NULL = don't update)
statusstring'pending', 'in_progress', 'completed', 'blocked' (NULL = don't update)

update_source_directory

Update existing source directory in infrastructure table

ParameterTypeDescription
new_source_dir *stringNew source directory path

update_subtask

Update subtask metadata

ParameterTypeDescription
id *integerSubtask ID
audit_override_reasonstringComplete despite blocking tracking-audit findings in the linked files. Recorded as a warning note with the outstanding counts; use only when the drift is understood and will be fixed in follow-up work…
descriptionstringNew description (NULL = don't update)
namestringNew name (NULL = don't update)
prioritystring'low', 'medium', 'high', 'critical' (NULL = don't update)
statusstring'pending', 'in_progress', 'completed', 'blocked' (NULL = don't update)
task_idintegerNew task ID (NULL = don't update)

update_task

Update task metadata

ParameterTypeDescription
id *integerTask ID
audit_override_reasonstringComplete despite blocking tracking-audit findings in the linked files. Recorded as a warning note with the outstanding counts; use only when the drift is understood and will be fixed in follow-up work…
descriptionstringNew description (NULL = don't update)
flow_idsarrayArray of flow IDs [1, 3, 5] (NULL = don't update)
milestone_idintegerNew milestone ID (NULL = don't update)
namestringNew name (NULL = don't update)
prioritystring'low', 'medium', 'high', 'critical' (NULL = don't update)
statusstring'pending', 'in_progress', 'completed', 'blocked' (NULL = don't update)

update_theme

Update theme metadata

ParameterTypeDescription
theme_id *integerTheme ID to update
confidence_scorenumberNew confidence score (NULL = don't update)
descriptionstringNew description (NULL = don't update)
namestringNew name (NULL = don't update)

update_type

Update type metadata

ParameterTypeDescription
type_id *integerType ID to update
definition_jsonobjectNew definition (NULL = don't update)
descriptionstringNew description (NULL = don't update)
file_idintegerNew file_id (NULL = don't update)
namestringNew name (NULL = don't update)

update_type_function_role

Update relationship role only

ParameterTypeDescription
function_id *integerFunction ID
role *string'factory', 'transformer', 'operator', 'pattern_matcher', 'accessor', 'validator', 'combinator'
type_id *integerType ID

update_user_custom_entry

Update entry in user_directives.db table. Every key must be a column of the table (compared without case). On user_directives the approval columns (approved, approved_at, approved_by, approval_hash) and status='active' are refused: approval is a person's decision, recorded by the user's own path (`aimfp directives approve`, or a host calling aimfp.hooks.approval), and activation goes through activate_user_directive.

ParameterTypeDescription
data *objectField-value pairs to update
record_id *integerRecord ID to update
table *stringTable name in user_directives.db

update_user_setting

Update existing project-wide user setting in user_settings table

ParameterTypeDescription
setting_key *stringSetting key to update (must exist)
descriptionstringNew description (optional)
scopestringNew scope (optional)
setting_valuestringNew setting value

user_directives_allowed_check_constraints

Returns list of allowed values for CHECK constraint enum fields in user_directives.db. Parses schema to extract CHECK(field IN (...)) constraints.

ParameterTypeDescription
field *stringField name to get allowed values for
table *stringTable name to check for CHECK constraints

user_preferences_allowed_check_constraints

Returns list of allowed values for CHECK constraint enum fields in user_preferences.db. Parses schema to extract CHECK(field IN (...)) constraints.

ParameterTypeDescription
field *stringField name to get allowed values for
table *stringTable name to check for CHECK constraints

validate_action_config

Checks an action_config against AIMFP's envelope for its action_type BEFORE the row is written; add_user_custom_entry and update_user_custom_entry refuse a non-conforming config. AIMFP validates the ENVELOPE ONLY. api_call, script_execution and notification are generic, so AIMFP can specify them fully. function_call and command name a target that exists in the caller's own project, so AIMFP checks that a target is named and well-formed but never that it resolves - caller_resolved=true marks exactly that, and means 'the shape is right, now check it resolves'. Unknown keys are errors, not ignore…

ParameterTypeDescription
action_config *objectThe config to check, as an object or a JSON string
action_type *string'api_call', 'script_execution', 'function_call', 'command', or 'notification'

validate_trigger_config

Checks a trigger_config against AIMFP's grammar for its trigger_type BEFORE the row is written. add_user_custom_entry and update_user_custom_entry refuse a non-conforming config, so calling this first turns a rejected insert into a fixed config. Time triggers are a discriminated union on 'kind' (interval/daily/weekly/monthly); event, condition and manual have fixed shapes. Unknown keys are errors, not ignored - a typo'd schedule key is the silent failure this exists to surface, because a schedule that never fires produces no log line and no recorded error. On failure, errors names every offend…

ParameterTypeDescription
trigger_config *objectThe config to check, as an object or a JSON string
trigger_type *string'time', 'event', 'condition', or 'manual'

verify_fanout_ready

(For use with InterCommAIMFP) Pre-fan-out preflight on current main: cheap insurance against silent fan-out corruption. Asserts (a) every relevant row has a stable identity key (hierarchy slugs + function/type entity_key — i.e. backfill_semantic_keys has nothing left to do), (b) .aimfp-project/project.db is committed (clean working tree for that path) so every clone shares the same base, and (c) no schema migration is pending. Returns {ready, blockers}. Run on main BEFORE spawning workers. Pure read.