@jinn-network/plugin 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/eligibility.d.ts +12 -0
- package/dist/eligibility.js +12 -0
- package/dist/history.d.ts +35 -0
- package/dist/history.js +140 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +15 -0
- package/dist/outcome.d.ts +26 -0
- package/dist/outcome.js +23 -0
- package/dist/pickup.d.ts +101 -0
- package/dist/pickup.js +354 -0
- package/dist/plugin.d.ts +157 -0
- package/dist/plugin.js +586 -0
- package/dist/ports/contribution-port.d.ts +53 -0
- package/dist/ports/contribution-port.js +14 -0
- package/dist/ports/corpus-port.d.ts +63 -0
- package/dist/ports/corpus-port.js +1 -0
- package/dist/ports/evidence-port.d.ts +17 -0
- package/dist/ports/evidence-port.js +1 -0
- package/dist/ports/local-learning-port.d.ts +22 -0
- package/dist/ports/local-learning-port.js +1 -0
- package/dist/ports/skills-port.d.ts +12 -0
- package/dist/ports/skills-port.js +1 -0
- package/dist/schemas/contribution-candidate.d.ts +116 -0
- package/dist/schemas/contribution-candidate.js +63 -0
- package/dist/schemas/eligibility-verdict.d.ts +8 -0
- package/dist/schemas/eligibility-verdict.js +7 -0
- package/dist/schemas/episode.d.ts +432 -0
- package/dist/schemas/episode.js +452 -0
- package/dist/schemas/history-entry.d.ts +40 -0
- package/dist/schemas/history-entry.js +30 -0
- package/dist/schemas/knowledge-hit.d.ts +27 -0
- package/dist/schemas/knowledge-hit.js +23 -0
- package/dist/schemas/knowledge-packet.d.ts +79 -0
- package/dist/schemas/knowledge-packet.js +213 -0
- package/dist/schemas/pickup-config.d.ts +20 -0
- package/dist/schemas/pickup-config.js +34 -0
- package/dist/schemas/session-summary.d.ts +17 -0
- package/dist/schemas/session-summary.js +19 -0
- package/dist/testing/contract-kits.d.ts +12 -0
- package/dist/testing/contract-kits.js +201 -0
- package/dist/testing/in-memory-contribution.d.ts +93 -0
- package/dist/testing/in-memory-contribution.js +104 -0
- package/dist/testing/in-memory-corpus.d.ts +47 -0
- package/dist/testing/in-memory-corpus.js +54 -0
- package/dist/testing/in-memory-evidence.d.ts +335 -0
- package/dist/testing/in-memory-evidence.js +23 -0
- package/dist/testing/in-memory-local-learning.d.ts +25 -0
- package/dist/testing/in-memory-local-learning.js +30 -0
- package/dist/testing/in-memory-skills.d.ts +9 -0
- package/dist/testing/in-memory-skills.js +16 -0
- package/dist/testing.d.ts +6 -0
- package/dist/testing.js +8 -0
- package/dist/visibility.d.ts +7 -0
- package/dist/visibility.js +9 -0
- package/package.json +48 -0
- package/process-contract.json +8 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { PortResult } from '../outcome.js';
|
|
2
|
+
import type { KnowledgeHit } from '../schemas/knowledge-hit.js';
|
|
3
|
+
/**
|
|
4
|
+
* One decoded trace step — a light structural echo of the frozen
|
|
5
|
+
* `jinn.trace-envelope.v0` step shape (`spanId`/timing/redaction bookkeeping
|
|
6
|
+
* dropped; array order is the step order). `attributes` follows the existing
|
|
7
|
+
* capture convention (`tool.args`/`tool.result`/`tool.exitCode`; see
|
|
8
|
+
* `projectKnowledgePacket`'s excerpt selection in `schemas/knowledge-packet.ts`).
|
|
9
|
+
*/
|
|
10
|
+
export interface CorpusRecordStep {
|
|
11
|
+
name: string;
|
|
12
|
+
attributes: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A content-bearing corpus record — the `KnowledgeHit` metadata plus decoded
|
|
16
|
+
* evidence content (rescope design §3.1/§3.2): everything
|
|
17
|
+
* `projectKnowledgePacket` needs to build a `KnowledgePacket` without any
|
|
18
|
+
* further I/O. Replaces the pre-rescope metadata-only `get()` return.
|
|
19
|
+
*/
|
|
20
|
+
export interface CorpusRecord {
|
|
21
|
+
ref: string;
|
|
22
|
+
task: {
|
|
23
|
+
summary: string;
|
|
24
|
+
repositorySlug?: string;
|
|
25
|
+
};
|
|
26
|
+
outcome: {
|
|
27
|
+
status: 'completed' | 'failed' | 'abandoned';
|
|
28
|
+
verifiabilityTier: 'user-accepted' | 'tests-passed' | 'evaluator-verified';
|
|
29
|
+
};
|
|
30
|
+
/** The record's own concise how-it-was-solved text, authored at capture/seed
|
|
31
|
+
* time — never generated at retrieval time. */
|
|
32
|
+
synthesis?: string;
|
|
33
|
+
steps: CorpusRecordStep[];
|
|
34
|
+
tags: string[];
|
|
35
|
+
provenance: 'imported' | 'contributed' | 'derived-from-history';
|
|
36
|
+
/** Display attribution for the rendered packet. The adapter may fall back
|
|
37
|
+
* to safeAddress here because cross-record dedup already happened on the
|
|
38
|
+
* search hit's trustworthy `origin`. */
|
|
39
|
+
origin: string;
|
|
40
|
+
capturedAt: string;
|
|
41
|
+
/**
|
|
42
|
+
* True when the adapter's decode determined the record's payload is a
|
|
43
|
+
* skill package — a step carrying a string `skill.md` attribute (legacy
|
|
44
|
+
* pre-#1394 seed shape) or the record backed by a `jinn.skill.v1` artifact
|
|
45
|
+
* (first-class shape) — regardless of the search hit's wire `kind`/
|
|
46
|
+
* `payloadKind` (mono #1782: a legacy skill-shaped record classifies as
|
|
47
|
+
* `kind: 'trace'` on the wire and slips the selection-time filter).
|
|
48
|
+
* Adapter-computed fact; the core (`plugin.ts` `firstTurnPickup`) enforces
|
|
49
|
+
* exclusion — keeps the core the policy owner, the adapter the fact
|
|
50
|
+
* provider. Undefined when undetermined, including when the adapter's own
|
|
51
|
+
* detection errors — the guard fails open, exactly like an ordinary trace
|
|
52
|
+
* record.
|
|
53
|
+
*/
|
|
54
|
+
isSkillPayload?: boolean;
|
|
55
|
+
/** Computed in decodeRecord from the envelope's own distributionTags (issue
|
|
56
|
+
* #1824) — content is the truth, hit metadata is only a hint. Post-fetch
|
|
57
|
+
* guard in firstTurnPickup drops a record whose content lacks the mark. */
|
|
58
|
+
retrievalVisible?: boolean;
|
|
59
|
+
}
|
|
60
|
+
export interface CorpusPort {
|
|
61
|
+
search(query: string): Promise<PortResult<KnowledgeHit[]>>;
|
|
62
|
+
get(ref: string): Promise<PortResult<CorpusRecord | null>>;
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PortResult } from '../outcome.js';
|
|
2
|
+
import type { EpisodeV1 } from '../schemas/episode.js';
|
|
3
|
+
export interface EvidenceListQuery {
|
|
4
|
+
limit?: number;
|
|
5
|
+
}
|
|
6
|
+
export interface EvidenceRetentionPolicy {
|
|
7
|
+
policy: 'local-private' | 'contribution-eligible';
|
|
8
|
+
maxEpisodes: number;
|
|
9
|
+
}
|
|
10
|
+
export interface EvidencePort {
|
|
11
|
+
put(episode: EpisodeV1): Promise<PortResult<{
|
|
12
|
+
episodeId: string;
|
|
13
|
+
}>>;
|
|
14
|
+
get(episodeId: string): Promise<PortResult<EpisodeV1 | null>>;
|
|
15
|
+
list(query?: EvidenceListQuery): Promise<PortResult<EpisodeV1[]>>;
|
|
16
|
+
retention(): Promise<PortResult<EvidenceRetentionPolicy>>;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PortResult } from '../outcome.js';
|
|
2
|
+
export interface LocalLearningRun {
|
|
3
|
+
runId: string;
|
|
4
|
+
state: 'pending' | 'running' | 'done' | 'failed';
|
|
5
|
+
}
|
|
6
|
+
/** One locally distilled skill plus the sessions recorded in its provenance. */
|
|
7
|
+
export interface LocalLearningSkill {
|
|
8
|
+
ref: string;
|
|
9
|
+
sourceSessionIds: string[];
|
|
10
|
+
state: 'staged' | 'installed';
|
|
11
|
+
}
|
|
12
|
+
export interface LocalLearningPort {
|
|
13
|
+
run(input: {
|
|
14
|
+
episodeIds: string[];
|
|
15
|
+
}): Promise<PortResult<{
|
|
16
|
+
runId: string;
|
|
17
|
+
}>>;
|
|
18
|
+
status(runId: string): Promise<PortResult<LocalLearningRun>>;
|
|
19
|
+
list(): Promise<PortResult<LocalLearningRun[]>>;
|
|
20
|
+
/** Optional for older adapters; history reports unavailable when absent. */
|
|
21
|
+
skills?(): Promise<PortResult<LocalLearningSkill[]>>;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PortResult } from '../outcome.js';
|
|
2
|
+
export interface SkillRecord {
|
|
3
|
+
ref: string;
|
|
4
|
+
installedAt: string;
|
|
5
|
+
}
|
|
6
|
+
export interface SkillsPort {
|
|
7
|
+
install(ref: string): Promise<PortResult<SkillRecord>>;
|
|
8
|
+
list(): Promise<PortResult<SkillRecord[]>>;
|
|
9
|
+
uninstall(ref: string): Promise<PortResult<{
|
|
10
|
+
ref: string;
|
|
11
|
+
}>>;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const CONTRIBUTION_CANDIDATE_SCHEMA_VERSION: "jinn.contribution-candidate.v1";
|
|
3
|
+
/**
|
|
4
|
+
* The complete local input to contribution mining. Timestamps are required
|
|
5
|
+
* caller inputs so assembling or parsing a candidate never reads the clock.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ContributionCandidateV1Schema: z.ZodObject<{
|
|
8
|
+
testRuns: z.ZodArray<z.ZodObject<{
|
|
9
|
+
command: z.ZodString;
|
|
10
|
+
exitCode: z.ZodNumber;
|
|
11
|
+
at: z.ZodISODateTime;
|
|
12
|
+
}, z.core.$strict>>;
|
|
13
|
+
skillEvents: z.ZodArray<z.ZodObject<{
|
|
14
|
+
skillRef: z.ZodString;
|
|
15
|
+
action: z.ZodEnum<{
|
|
16
|
+
loaded: "loaded";
|
|
17
|
+
invoked: "invoked";
|
|
18
|
+
}>;
|
|
19
|
+
}, z.core.$strict>>;
|
|
20
|
+
schemaVersion: z.ZodLiteral<"jinn.contribution-candidate.v1">;
|
|
21
|
+
sourceId: z.ZodString;
|
|
22
|
+
repositorySlug: z.ZodString;
|
|
23
|
+
baseCommit: z.ZodString;
|
|
24
|
+
acceptedDiff: z.ZodString;
|
|
25
|
+
intermediateFailureDiffs: z.ZodArray<z.ZodString>;
|
|
26
|
+
publishMinedTasksConsent: z.ZodBoolean;
|
|
27
|
+
createdAt: z.ZodISODateTime;
|
|
28
|
+
}, z.core.$strict>;
|
|
29
|
+
/** Additive reader used only inside canonical local EpisodeV1 records. */
|
|
30
|
+
export declare const ContributionCandidateV1ReadSchema: z.ZodObject<{
|
|
31
|
+
testRuns: z.ZodArray<z.ZodObject<{
|
|
32
|
+
command: z.ZodString;
|
|
33
|
+
exitCode: z.ZodNumber;
|
|
34
|
+
at: z.ZodISODateTime;
|
|
35
|
+
}, z.core.$loose>>;
|
|
36
|
+
skillEvents: z.ZodArray<z.ZodObject<{
|
|
37
|
+
skillRef: z.ZodString;
|
|
38
|
+
action: z.ZodEnum<{
|
|
39
|
+
loaded: "loaded";
|
|
40
|
+
invoked: "invoked";
|
|
41
|
+
}>;
|
|
42
|
+
}, z.core.$loose>>;
|
|
43
|
+
schemaVersion: z.ZodLiteral<"jinn.contribution-candidate.v1">;
|
|
44
|
+
sourceId: z.ZodString;
|
|
45
|
+
repositorySlug: z.ZodString;
|
|
46
|
+
baseCommit: z.ZodString;
|
|
47
|
+
acceptedDiff: z.ZodString;
|
|
48
|
+
intermediateFailureDiffs: z.ZodArray<z.ZodString>;
|
|
49
|
+
publishMinedTasksConsent: z.ZodBoolean;
|
|
50
|
+
createdAt: z.ZodISODateTime;
|
|
51
|
+
}, z.core.$loose>;
|
|
52
|
+
export type ContributionCandidateV1 = z.infer<typeof ContributionCandidateV1Schema>;
|
|
53
|
+
/** Resolve a forward-additive candidate from a canonical Episode into the
|
|
54
|
+
* current v1 fields. Unknown future fields stay in the Episode but never make
|
|
55
|
+
* an otherwise valid local reference look unresolved to an older reader. */
|
|
56
|
+
export declare const ContributionCandidateV1ProjectionSchema: z.ZodPipe<z.ZodObject<{
|
|
57
|
+
testRuns: z.ZodArray<z.ZodObject<{
|
|
58
|
+
command: z.ZodString;
|
|
59
|
+
exitCode: z.ZodNumber;
|
|
60
|
+
at: z.ZodISODateTime;
|
|
61
|
+
}, z.core.$loose>>;
|
|
62
|
+
skillEvents: z.ZodArray<z.ZodObject<{
|
|
63
|
+
skillRef: z.ZodString;
|
|
64
|
+
action: z.ZodEnum<{
|
|
65
|
+
loaded: "loaded";
|
|
66
|
+
invoked: "invoked";
|
|
67
|
+
}>;
|
|
68
|
+
}, z.core.$loose>>;
|
|
69
|
+
schemaVersion: z.ZodLiteral<"jinn.contribution-candidate.v1">;
|
|
70
|
+
sourceId: z.ZodString;
|
|
71
|
+
repositorySlug: z.ZodString;
|
|
72
|
+
baseCommit: z.ZodString;
|
|
73
|
+
acceptedDiff: z.ZodString;
|
|
74
|
+
intermediateFailureDiffs: z.ZodArray<z.ZodString>;
|
|
75
|
+
publishMinedTasksConsent: z.ZodBoolean;
|
|
76
|
+
createdAt: z.ZodISODateTime;
|
|
77
|
+
}, z.core.$loose>, z.ZodTransform<{
|
|
78
|
+
testRuns: {
|
|
79
|
+
command: string;
|
|
80
|
+
exitCode: number;
|
|
81
|
+
at: string;
|
|
82
|
+
}[];
|
|
83
|
+
skillEvents: {
|
|
84
|
+
skillRef: string;
|
|
85
|
+
action: "loaded" | "invoked";
|
|
86
|
+
}[];
|
|
87
|
+
schemaVersion: "jinn.contribution-candidate.v1";
|
|
88
|
+
sourceId: string;
|
|
89
|
+
repositorySlug: string;
|
|
90
|
+
baseCommit: string;
|
|
91
|
+
acceptedDiff: string;
|
|
92
|
+
intermediateFailureDiffs: string[];
|
|
93
|
+
publishMinedTasksConsent: boolean;
|
|
94
|
+
createdAt: string;
|
|
95
|
+
}, {
|
|
96
|
+
[x: string]: unknown;
|
|
97
|
+
testRuns: {
|
|
98
|
+
[x: string]: unknown;
|
|
99
|
+
command: string;
|
|
100
|
+
exitCode: number;
|
|
101
|
+
at: string;
|
|
102
|
+
}[];
|
|
103
|
+
skillEvents: {
|
|
104
|
+
[x: string]: unknown;
|
|
105
|
+
skillRef: string;
|
|
106
|
+
action: "loaded" | "invoked";
|
|
107
|
+
}[];
|
|
108
|
+
schemaVersion: "jinn.contribution-candidate.v1";
|
|
109
|
+
sourceId: string;
|
|
110
|
+
repositorySlug: string;
|
|
111
|
+
baseCommit: string;
|
|
112
|
+
acceptedDiff: string;
|
|
113
|
+
intermediateFailureDiffs: string[];
|
|
114
|
+
publishMinedTasksConsent: boolean;
|
|
115
|
+
createdAt: string;
|
|
116
|
+
}>>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const CONTRIBUTION_CANDIDATE_SCHEMA_VERSION = 'jinn.contribution-candidate.v1';
|
|
3
|
+
const ContributionTestRunShape = {
|
|
4
|
+
command: z.string().min(1),
|
|
5
|
+
exitCode: z.number().int(),
|
|
6
|
+
at: z.iso.datetime(),
|
|
7
|
+
};
|
|
8
|
+
const ContributionTestRunSchema = z.strictObject(ContributionTestRunShape);
|
|
9
|
+
const ContributionTestRunReadSchema = z.looseObject(ContributionTestRunShape);
|
|
10
|
+
const ContributionSkillEventShape = {
|
|
11
|
+
skillRef: z.string().min(1),
|
|
12
|
+
action: z.enum(['loaded', 'invoked']),
|
|
13
|
+
};
|
|
14
|
+
const ContributionSkillEventSchema = z.strictObject(ContributionSkillEventShape);
|
|
15
|
+
const ContributionSkillEventReadSchema = z.looseObject(ContributionSkillEventShape);
|
|
16
|
+
const ContributionCandidateShape = {
|
|
17
|
+
schemaVersion: z.literal(CONTRIBUTION_CANDIDATE_SCHEMA_VERSION),
|
|
18
|
+
sourceId: z.string().min(1),
|
|
19
|
+
repositorySlug: z.string().min(1),
|
|
20
|
+
baseCommit: z.string().min(1),
|
|
21
|
+
acceptedDiff: z.string().min(1),
|
|
22
|
+
intermediateFailureDiffs: z.array(z.string().min(1)),
|
|
23
|
+
publishMinedTasksConsent: z.boolean(),
|
|
24
|
+
createdAt: z.iso.datetime(),
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* The complete local input to contribution mining. Timestamps are required
|
|
28
|
+
* caller inputs so assembling or parsing a candidate never reads the clock.
|
|
29
|
+
*/
|
|
30
|
+
export const ContributionCandidateV1Schema = z.strictObject({
|
|
31
|
+
...ContributionCandidateShape,
|
|
32
|
+
testRuns: z.array(ContributionTestRunSchema),
|
|
33
|
+
skillEvents: z.array(ContributionSkillEventSchema),
|
|
34
|
+
});
|
|
35
|
+
/** Additive reader used only inside canonical local EpisodeV1 records. */
|
|
36
|
+
export const ContributionCandidateV1ReadSchema = z.looseObject({
|
|
37
|
+
...ContributionCandidateShape,
|
|
38
|
+
testRuns: z.array(ContributionTestRunReadSchema),
|
|
39
|
+
skillEvents: z.array(ContributionSkillEventReadSchema),
|
|
40
|
+
});
|
|
41
|
+
/** Resolve a forward-additive candidate from a canonical Episode into the
|
|
42
|
+
* current v1 fields. Unknown future fields stay in the Episode but never make
|
|
43
|
+
* an otherwise valid local reference look unresolved to an older reader. */
|
|
44
|
+
export const ContributionCandidateV1ProjectionSchema = ContributionCandidateV1ReadSchema
|
|
45
|
+
.transform((candidate) => ({
|
|
46
|
+
schemaVersion: candidate.schemaVersion,
|
|
47
|
+
sourceId: candidate.sourceId,
|
|
48
|
+
repositorySlug: candidate.repositorySlug,
|
|
49
|
+
baseCommit: candidate.baseCommit,
|
|
50
|
+
acceptedDiff: candidate.acceptedDiff,
|
|
51
|
+
testRuns: candidate.testRuns.map((run) => ({
|
|
52
|
+
command: run.command,
|
|
53
|
+
exitCode: run.exitCode,
|
|
54
|
+
at: run.at,
|
|
55
|
+
})),
|
|
56
|
+
intermediateFailureDiffs: candidate.intermediateFailureDiffs,
|
|
57
|
+
skillEvents: candidate.skillEvents.map((event) => ({
|
|
58
|
+
skillRef: event.skillRef,
|
|
59
|
+
action: event.action,
|
|
60
|
+
})),
|
|
61
|
+
publishMinedTasksConsent: candidate.publishMinedTasksConsent,
|
|
62
|
+
createdAt: candidate.createdAt,
|
|
63
|
+
}));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Cheap candidate verdict (architecture spec §5). Authoritative validation is sidecar-side. */
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const EligibilityVerdictSchema: z.ZodObject<{
|
|
4
|
+
eligible: z.ZodBoolean;
|
|
5
|
+
reason: z.ZodString;
|
|
6
|
+
checkedAt: z.ZodISODateTime;
|
|
7
|
+
}, z.core.$strict>;
|
|
8
|
+
export type EligibilityVerdict = z.infer<typeof EligibilityVerdictSchema>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Cheap candidate verdict (architecture spec §5). Authoritative validation is sidecar-side. */
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export const EligibilityVerdictSchema = z.strictObject({
|
|
4
|
+
eligible: z.boolean(),
|
|
5
|
+
reason: z.string().min(1),
|
|
6
|
+
checkedAt: z.iso.datetime(),
|
|
7
|
+
});
|