feat(research): reopen original hypothesis revisions (RP29)
This commit is contained in:
parent
bbcec1c439
commit
fa78b6a791
4 changed files with 391 additions and 0 deletions
|
|
@ -109,6 +109,21 @@ const hypothesisRecord = z.object({
|
|||
validationState: z.literal('unvalidated'),
|
||||
}),
|
||||
});
|
||||
// Reopening history preserves its actual author; creation still requires an AI acknowledgement.
|
||||
const hypothesisRevisionRecord = hypothesisRecord.shape.latestRevision.extend({
|
||||
hypothesisId: uuid,
|
||||
submittedBy: researchActorSchema,
|
||||
contentOrigin: z.enum(['human', 'ai', 'unknown']),
|
||||
createdAt: z.string().min(1),
|
||||
});
|
||||
const retainedHypothesisRecord = hypothesisRecord.extend({
|
||||
ownerPrincipal: researchActorSchema,
|
||||
updatedBy: researchActorSchema,
|
||||
archived: z.boolean(),
|
||||
createdAt: z.string().min(1),
|
||||
updatedAt: z.string().min(1),
|
||||
latestRevision: hypothesisRevisionRecord,
|
||||
});
|
||||
const availabilityMatches = (
|
||||
metric: Pick<ResearchEvidence, 'availability' | 'value' | 'unavailableReason'>
|
||||
) =>
|
||||
|
|
@ -792,6 +807,45 @@ export class ResearchClient {
|
|||
signal
|
||||
);
|
||||
}
|
||||
hypothesis(hypothesisId: string, signal?: AbortSignal) {
|
||||
hypothesisId = uuid.parse(hypothesisId);
|
||||
return this.#request(
|
||||
`hypotheses/${id(hypothesisId)}`,
|
||||
'GET',
|
||||
200,
|
||||
value => {
|
||||
const saved = retainedHypothesisRecord.parse(envelope(value, 'hypothesis'));
|
||||
expect(saved.id === hypothesisId && saved.latestRevision.hypothesisId === hypothesisId);
|
||||
return saved;
|
||||
},
|
||||
undefined,
|
||||
undefined,
|
||||
signal
|
||||
);
|
||||
}
|
||||
hypothesisRevisions(hypothesisId: string, signal?: AbortSignal) {
|
||||
hypothesisId = uuid.parse(hypothesisId);
|
||||
return this.#request(
|
||||
`hypotheses/${id(hypothesisId)}/revisions`,
|
||||
'GET',
|
||||
200,
|
||||
value => {
|
||||
const revisions = z
|
||||
.array(hypothesisRevisionRecord)
|
||||
.min(1)
|
||||
.parse(envelope(value, 'revisions'));
|
||||
expect(
|
||||
revisions.every(revision => revision.hypothesisId === hypothesisId) &&
|
||||
new Set(revisions.map(revision => revision.id)).size === revisions.length &&
|
||||
new Set(revisions.map(revision => revision.ordinal)).size === revisions.length
|
||||
);
|
||||
return revisions;
|
||||
},
|
||||
undefined,
|
||||
undefined,
|
||||
signal
|
||||
);
|
||||
}
|
||||
artifact(artifactId: string, signal?: AbortSignal) {
|
||||
artifactId = uuid.parse(artifactId);
|
||||
return this.#request(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue