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.9
to
0.2.10
+55
-1
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, 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 { 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, ActiveDecisionApply, 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';

@@ -207,2 +207,3 @@

findProjectByRootHash(rootCommitHash: string, userId?: string | null): Promise<Project | null>;
findProjectById(id: string, userId?: string | null): Promise<Project | null>;
listProjects(filter?: ProjectFilter): Promise<Project[]>;

@@ -468,4 +469,55 @@ updateProject(id: string, updates: UpdateProject): Promise<Project>;

updateActiveDecision(id: string, body: string, cycleNumber?: number, action?: 'confidence_change' | 'modify' | 'resolve' | 'supersede' | 'new' | 'delete'): Promise<void>;
/**
* `updateActiveDecision`, parameterised by the SQL handle so it can run either
* standalone (`this.sql`) or inside an open transaction (`applyActiveDecisionUpdates`).
*/
private updateActiveDecisionOn;
/**
* task-3039 (C357): allocate the next `AD-N` and INSERT the decision in ONE
* statement, so two concurrent captures cannot both compute the same number.
*
* The old path read `MAX(display_id)` in the service, added one, and handed the
* result to `upsertActiveDecision` — whose `ON CONFLICT DO UPDATE` then quietly
* overwrote whichever decision got there first. An Active Decision was
* destroyed with no error, against the project's "NEVER overwrite an AD" rule.
*
* The body embeds its own display id (`### AD-12: …`) and the id is not known
* until the row lands, hence `{{AD_ID}}`: the caller passes a template and
* Postgres substitutes the id the INSERT actually won. A unique violation on
* (project_id, display_id) means a concurrent writer took the number in the
* gap — recompute and retry rather than clobber.
*
* @returns the allocated display id (e.g. `AD-91`).
*/
allocateActiveDecision(bodyTemplate: string, title: string, confidence: string, cycleNumber: number): Promise<string>;
upsertActiveDecision(id: string, body: string, title: string, confidence: string, cycleNumber: number): Promise<void>;
private upsertActiveDecisionOn;
deleteActiveDecision(id: string): Promise<void>;
private deleteActiveDecisionOn;
/**
* Apply a whole strategy review's Active-Decision writes in ONE transaction
* (task-1745).
*
* The bug this closes: the service applied AD updates with `Promise.all` over
* independent adapter calls. The strategy_review row committed first, then a
* failure part-way through (a constraint violation, a dropped connection) left
* SOME decisions rewritten and the rest silently skipped, with the review
* itself claiming all of them landed. There is no way to tell afterwards which
* half applied — for any external user running `strategy_review`.
*
* Now: all of the decision writes commit, or none do.
*
* Sequential, not parallel, INSIDE the transaction — a transaction is a single
* connection, and postgres.js pipelines on one connection, so interleaving
* buys nothing and makes failure attribution harder. AD counts are single
* digits per review.
*
* Ledger events keep their pre-existing best-effort semantics via a SAVEPOINT:
* a failed `decision_events` insert rolls back to just before that insert
* rather than aborting the whole transaction (in Postgres, an error inside a
* transaction poisons every later statement, so a bare try/catch would NOT
* have been enough here). An audit-trail hiccup must not destroy the decision
* writes it was describing.
*/
applyActiveDecisionUpdates(applies: ActiveDecisionApply[], cycleNumber: number): Promise<void>;
confirmPendingActiveDecisions(cycleNumber: number): Promise<void>;

@@ -721,2 +773,4 @@ queryBoard(options?: BoardQueryOptions): Promise<CycleTask[]>;

appendDecisionEvent(event: Omit<DecisionEvent, 'id' | 'createdAt'>): Promise<DecisionEvent>;
/** `appendDecisionEvent`, parameterised by the SQL handle so it can join an open transaction. */
private appendDecisionEventOn;
getDecisionEvents(decisionId: string, limit?: number): Promise<DecisionEvent[]>;

@@ -723,0 +777,0 @@ getDecisionEventsSince(cycle: number): Promise<DecisionEvent[]>;

+1
-1
{
"name": "@papi-ai/adapter-pg",
"version": "0.2.9",
"version": "0.2.10",
"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