Sign In

@papi-ai/adapter-pg

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@papi-ai/adapter-pg - npm Package Compare versions

Comparing version
0.2.8
to
0.2.9
+81
-27
dist/index.d.ts
import * as _papi_ai_adapter_md from '@papi-ai/adapter-md';
import { AcknowledgementStatus, ConflictAlertStatus, ConflictType, ConflictRaisedBy, SharedDecisionConfidence, Project, SharedDecision, SharedDecisionStatus, Acknowledgement, SharedMilestone, SharedMilestoneStatus, MilestoneDependency, ProjectContribution, ProjectContributionStatus, NorthStar, ConflictAlert, PapiAdapter, PlanningLog, CycleHealth, ActiveDecision, SiblingRepoTask, CycleLogEntry, StrategyReviewEntry, DocRegistryEntry, DocSearchInput, DocDeletionResult, DogfoodEntry, HarnessInventoryEntry, HarnessState, BoardQueryOptions, CycleTask, UpdateTaskOptions, MoveTaskResult, TaskStatus, BuildReport, CycleLearning, CycleLearningPattern, DecisionScorePattern, HumanReview, Phase, ToolCallMetric, CostSummary, CostSnapshot, CycleMetricsSnapshot, Cycle, Horizon, Stage, Registries, StrategyRecommendation, AgendaTopic, DecisionEvent, DecisionScore, PlanContextSummary, ContributorEntry, ContributorReleasePr, ProjectSummary, ProjectLifecycleResult, PlanRunEntry, BugReport, ResolvedFeedbackNotice, MyBugReport, EntityReference, DecisionUsageSummary, ContextUtilisationSummary, PlanWriteBackPayload, PlanWriteBackResult, OwnerActionInput, OwnerActionRow, ProgressStepInput } from '@papi-ai/adapter-md';
import { AcknowledgementStatus, ConflictAlertStatus, ConflictType, ConflictRaisedBy, SharedDecisionConfidence, Project, SharedDecision, SharedDecisionStatus, Acknowledgement, SharedMilestone, SharedMilestoneStatus, MilestoneDependency, ProjectContribution, ProjectContributionStatus, NorthStar, ConflictAlert, PapiAdapter, PlanningLog, CycleHealth, ActiveDecision, SiblingRepoTask, CycleLogEntry, StrategyReviewEntry, DocRegistryEntry, DocVisibility, DocSearchInput, DocDeletionResult, DogfoodEntry, HarnessInventoryEntry, HarnessState, BoardQueryOptions, CycleTask, UpdateTaskOptions, MoveTaskResult, TaskStatus, BuildReport, CycleLearning, AppendedLearning, CycleLearningPattern, DecisionScorePattern, HumanReview, Phase, ToolCallMetric, CostSummary, CostSnapshot, CycleMetricsSnapshot, Cycle, Horizon, Stage, Registries, StrategyRecommendation, AgendaTopic, DecisionEvent, DecisionScore, PlanContextSummary, ContributorEntry, ContributorReleasePr, ProjectSummary, ProjectLifecycleResult, PlanRunEntry, ToolRunEntry, BugReport, ResolvedFeedbackNotice, MyBugReport, EntityReference, DecisionUsageSummary, ContextUtilisationSummary, PlanWriteBackPayload, PlanWriteBackResult, OwnerActionInput, OwnerActionRow, ProgressStepInput } from '@papi-ai/adapter-md';
import postgres from 'postgres';

@@ -384,2 +384,48 @@

registerDoc(entry: Omit<DocRegistryEntry, 'id' | 'createdAt' | 'updatedAt'>): Promise<DocRegistryEntry>;
/**
* Store a document body (task-3017, C356).
*
* The three denormalised columns are written in the SAME statement as the body,
* every time — doc_bodies' RLS policy is a predicate on them alone, so a stale
* visibility here silently mis-classifies a private doc. This is the reason the
* table carries a COMMENT saying so.
*
* project_id comes from the adapter's bound context and owner_user_id from
* resolveOwnerUserId — never from a caller payload. A caller-supplied owner would
* let one user write a body attributed to another, defeating both the storage cap
* and the private-tier policy at once.
*
* Skips the write when content_hash is unchanged, so re-registering an untouched
* doc (which build_execute does routinely) costs one cheap comparison.
*/
storeDocBody(input: {
docId: string;
body: string;
visibility: DocVisibility;
ownerUserId?: string | null;
}): Promise<{
stored: boolean;
byteSize: number;
}>;
/**
* Read a stored body back (task-3019, C356).
*
* The tier rule is NOT applied here — it is applied by `doc_body_for_reader`,
* which mirrors the `user_read_doc_bodies` policy and lives next to it. This
* connection is the `postgres` superuser and therefore bypasses RLS, so a plain
* SELECT on doc_bodies would hand any local caller the owner's private body;
* the function is where that policy binds for this path. See the migration
* header (20260809020000) for why there is a function rather than a CASE here.
*/
getDocBody(docId: string, requesterUserId?: string | null): Promise<{
permitted: boolean;
body: string | null;
byteSize: number;
updatedAt: string;
} | null>;
/** Caller's stored-body usage across ALL their projects, for the tier cap. */
getDocBodyUsage(): Promise<{
totalBytes: number;
docCount: number;
} | null>;
searchDocs(input: DocSearchInput): Promise<DocRegistryEntry[]>;

@@ -504,4 +550,30 @@ getDoc(idOrPath: string): Promise<DocRegistryEntry | null>;

getBuildReportCountForTask(taskId: string): Promise<number>;
/**
* task-2933: how many times has this task been BUILT AND FAILED?
*
* A failed attempt is a build report recorded with completed 'No' or 'Partial'
* — the builder ran and said so. Deliberately NOT total report count
* (getBuildReportCountForTask), which counts successes too and would gate a
* task that simply took three honest passes.
*
* UNDERCOUNTS BY DESIGN: an ABANDONED attempt (build_execute start, never
* completed) writes no report at all, so it is invisible here. The gate is
* therefore conservative — it fires on demonstrated failure, never on silence.
*/
getFailedBuildAttemptsForTask(taskId: string): Promise<number>;
getBuildReportsSince(cycleNumber: number): Promise<BuildReport[]>;
appendCycleLearnings(learnings: CycleLearning[]): Promise<void>;
/**
* Append one row per FINDING via the append_cycle_learnings RPC (task-2999, C356).
*
* This replaced a bare per-row INSERT loop. The loop could not be fixed in place:
* dedup lives on a PARTIAL unique index (open findings only) and neither PostgREST
* nor a plain INSERT can target one, so `occurrences` would never increment and the
* whole point of per-finding rows — recurrence being visible — would be silently lost.
* One SQL definition now serves this path and the hosted edge.
*
* The RPC owns finding_key (via papi_finding_key) and the fixed_now resolved
* stamping, so those cannot be forgotten or computed differently per call site.
* project_id comes from the adapter's bound context, never from the payload.
*/
appendCycleLearnings(learnings: CycleLearning[]): Promise<AppendedLearning[]>;
getCycleLearnings(opts?: {

@@ -526,27 +598,2 @@ cycleNumber?: number;

markCycleLearningResolved(learningId: string, resolvedBy?: string): Promise<void>;
/**
* Auto-resolve stale discovered-issues (cycle_learnings category='issue') whose
* linked task is already Done/Cancelled (task-2079, C291). Sets resolved_at = now()
* and resolved_by = 'auto:linked-task-done' so default reads exclude them.
*
* The prior in-memory filtering in orient hid these rows from one surface but never
* wrote the DB, so the 2k-deep clog never drained and every other consumer (planner,
* build_list) still saw resolved-in-reality issues. This is the persisting fix.
*
* - No `taskDisplayId`: full sweep across all Done/Cancelled-linked open issues.
* Idempotent — only touches rows with resolved_at IS NULL.
* - With `taskDisplayId`: resolve only issues linked to that one task (the task→Done
* transition path). Multiple issues can link to one task, so this is set-based too.
*
* Scoped to the bound project_id; cross-tenant writes are impossible. Restricted to
* category='issue' — friction/methodology/signal learnings are dogfood signal owned by
* the task-2082 promotion loop and must NOT be auto-closed here.
*
* Overwrite contract (hub polish, 2026-07): this sweep keeps its resolved_at IS NULL
* guard, so it can never downgrade a genuine fix — while markCycleLearningResolved may
* upgrade this sweep's `auto:%` stamp to a genuine one. Order-independent either way.
*
* @returns number of rows resolved.
*/
resolveLearningsForDoneTasks(taskDisplayId?: string): Promise<number>;
getCycleLearningPatterns(): Promise<CycleLearningPattern[]>;

@@ -641,2 +688,3 @@ getDecisionScorePatterns(): Promise<DecisionScorePattern[]>;

updateStageExitCriteria(stageId: string, exitCriteria: string[]): Promise<void>;
setCriterionMet(stageId: string, criterionId: string, met: boolean, evidence?: string | null): Promise<void>;
updateHorizonStatus(horizonId: string, status: string): Promise<void>;

@@ -726,2 +774,8 @@ updatePhaseStatus(phaseId: string, status: string): Promise<void>;

insertPlanRun(entry: PlanRunEntry): Promise<void>;
/** task-2940: cross-tool telemetry. SIZES AND DURATIONS ONLY — this insert
* deliberately has no column for tool arguments or result bodies.
* SECURITY: multi-tenant table — project_id is bound to THIS adapter's
* projectId, never to a caller-supplied value (same rule as every other
* write here). */
insertToolRun(entry: ToolRunEntry): Promise<void>;
/** task-2860: count plan_runs for a cycle, scoped to this project. The

@@ -728,0 +782,0 @@ * auto-release guard uses this to refuse to auto-close a cycle nobody planned

{
"name": "@papi-ai/adapter-pg",
"version": "0.2.8",
"version": "0.2.9",
"description": "PAPI PostgreSQL adapter — read/write shared layer entities in PostgreSQL",

@@ -5,0 +5,0 @@ "license": "Elastic-2.0",

Sorry, the diff of this file is too big to display