@plasius/ai-rag
v0.1.13
Published
Retrieval, context packing, provenance, and prompt-injection guard contracts for Plasius AI RAG.
Maintainers
Readme
@plasius/ai-rag
Retrieval, context packing, provenance, and prompt-injection guard contracts for Plasius AI RAG.
Scope
This package is part of the layered @plasius/ai-* package family. It defines the external contracts for retrieval provenance, context packing, trust-aware truncation, and prompt-injection guard behavior.
Install
npm install @plasius/ai-ragContracts
AI_RAG_FEATURE_FLAGSdeclares the feature flags for RAG, provenance, and injection guard behavior.resolveAiRagContextbuilds deterministic packed contexts from scored chunks and emits trust/provenance reason codes.isAiRagChunkSafeprovides a simple trust utility for non-blocking callers.packageDescriptorexposes package name, primary flag, env prefix, and summary.
Usage
import {
AI_RAG_FEATURE_FLAGS,
resolveAiRagContext,
} from "@plasius/ai-rag";
const result = resolveAiRagContext({
query: "What happened in the last hour?",
chunks: [
{
chunkId: "chunk-1",
sourceScope: "knowledge-base",
sourceId: "kb-2026",
text: "A major weather event was recorded near the delta.",
trust: 0.93,
citation: "https://knowledge-base/docs/delta",
},
],
featureFlags: {
[AI_RAG_FEATURE_FLAGS.rag]: true,
[AI_RAG_FEATURE_FLAGS.provenance]: true,
[AI_RAG_FEATURE_FLAGS.injectionGuard]: true,
},
maxContextChars: 1200,
});
console.log(result.packedContext);
console.log(result.status);Development
npm install
npm run build
npm test
npm run test:coverage
npm run pack:checkRelease Workflow
Protected main releases use a two-step flow:
- Run
.github/workflows/cd.ymlwithbump=patch|minor|majorto open or refresh arelease/vX.Y.Zprep PR. - Merge that PR to
main. - Rerun
.github/workflows/cd.ymlonmainwithbump=noneto tag, draft the GitHub release, and publish to npm.
Governance
- Security policy: SECURITY.md
- Code of conduct: CODE_OF_CONDUCT.md
- ADRs: docs/adrs
- CLA and legal docs: legal
License
Apache-2.0
Release integrity
Production package publication runs only from .github/workflows/cd.yml on
protected main. The job verifies that the prepared commit is still the
current main commit and has an exact successful ci.yml push result before it
mutates release state. Public package CI runs on GitHub-hosted capacity so it
cannot execute on company-managed runners. npm publication runs on
GitHub-hosted Node.js 24 with pinned npm 11.6.2, uses the protected production environment and
short-lived npm OIDC with provenance, and has no long-lived npm write-token
fallback. Rollback disables CD; it never rewrites published package history.
