Version Chains
What is a Version Chain?
Section titled “What is a Version Chain?”A version chain is the ordered sequence of prompt versions connected by follows relations:
prompt-template (root) ↑ followsprompt-version v1 ↑ followsprompt-version v2 ← latestThe follows relation is directional: the sourceId is the newer version, and targetId is the older version. This allows traversal backward to the root.
PromptChain API
Section titled “PromptChain API”The PromptChain class traverses the graph for you:
import { PromptChain } from 'minions-prompts';
const chain = new PromptChain(storage);
// All versions, oldest firstconst all = await chain.getVersionChain(promptId);
// The most recent leaf versionconst latest = await chain.getLatestVersion(promptId);
// The version active on January 1, 2024const historical = await chain.getVersionAtDate(promptId, new Date('2024-01-01'));from minions_prompts import PromptChainfrom datetime import datetime
chain = PromptChain(storage)
# All versions, oldest firstall_versions = chain.get_version_chain(prompt_id)
# The most recent leaf versionlatest = chain.get_latest_version(prompt_id)
# The version active on January 1, 2024historical = chain.get_version_at_date(prompt_id, datetime(2024, 1, 1))Branching
Section titled “Branching”A version chain can branch — multiple versions can follow the same predecessor. The “latest” version is the leaf with the most recent createdAt timestamp.
This is useful for maintaining different variations (e.g., one for GPT-4, one for Claude) from the same base.