| 1 | package wire |
| 2 | |
| 3 | // The Research specialist's sources, card and scheduling (Research spec |
| 4 | // §2, slice R2). The coordinator's research tool only requests a run; the |
| 5 | // instance starts it at the task's next fixed point (task start, or the |
| 6 | // boundary before the next Engineering round), holds that Engineering |
| 7 | // round while Research is pending or running, and releases it when |
| 8 | // Research ends, however it ends. |
| 9 | |
| 10 | // ToolResearch requests a Research run on the person's task: question |
| 11 | // (what to look for) and urls (the coordinator's proposals). One per |
| 12 | // fixed point, at most MaxResearchRuns per task. |
| 13 | const ToolResearch = "research" |
| 14 | |
| 15 | // SpecialistResearch is the Research step: on the primary only, with no |
| 16 | // repository, branch or SHA. |
| 17 | const SpecialistResearch = "research" |
| 18 | |
| 19 | // CardResearchSources asks the task's creator whether the proposed URLs |
| 20 | // may be requested ("Look at these pages?"): ChoiceAllow approves those |
| 21 | // exact URLs, ChoiceSkip drops them. |
| 22 | const ( |
| 23 | CardResearchSources = "research_sources" |
| 24 | ChoiceAllow = "allow" |
| 25 | ChoiceSkip = "skip" |
| 26 | ) |
| 27 | |
| 28 | // A source's origin: the task creator's own words on the task, or the |
| 29 | // coordinator's proposal (only fetched after Allow). The spec calls the |
| 30 | // first "paul"; the code names no person. |
| 31 | const ( |
| 32 | ResearchOriginPerson = "person" |
| 33 | ResearchOriginProposed = "proposed" |
| 34 | ) |
| 35 | |
| 36 | // Waiting states (Step.Placement) of a Research step that has not been |
| 37 | // dispatched, and of the Engineering step it holds. |
| 38 | const ( |
| 39 | // PlacementBoundary: requested, waiting for the task's next fixed |
| 40 | // point. |
| 41 | PlacementBoundary = "waiting_boundary" |
| 42 | // PlacementSources: at its fixed point, waiting for the answer on its |
| 43 | // sources card. |
| 44 | PlacementSources = "waiting_sources" |
| 45 | // PlacementInventory: waiting until the primary's site inventory is |
| 46 | // confirmed (slice R3). |
| 47 | PlacementInventory = "waiting_inventory" |
| 48 | // PlacementResearch: an Engineering step held while the task's |
| 49 | // Research is pending or running. |
| 50 | PlacementResearch = "waiting_research" |
| 51 | ) |
| 52 | |
| 53 | // Reasons a Research step ends without running: nothing left to read |
| 54 | // after Skip (done, a gap); Research is not approved now (cancelled); the |
| 55 | // primary speaks below ProtocolResearch (it never gets the dispatch); the |
| 56 | // primary has no address at all for a site inventory (failed: its hello |
| 57 | // says it has no public address and none was observed, so there is |
| 58 | // nothing an owner could confirm). |
| 59 | const ( |
| 60 | ReasonResearchNoSources = "research_no_sources" |
| 61 | ReasonResearchNoGrant = "research_no_grant" |
| 62 | ReasonResearchUnsupported = "research_unsupported" |
| 63 | ReasonResearchNoInventory = "research_no_inventory" |
| 64 | ) |
| 65 | |
| 66 | // Bounds of a research request. |
| 67 | const ( |
| 68 | MaxResearchRuns = 3 |
| 69 | MaxResearchQuestion = 1000 |
| 70 | MaxResearchProposals = 10 |
| 71 | // MaxResearchPersonSources bounds the sources taken from the person's |
| 72 | // own words, in the order they wrote them. |
| 73 | MaxResearchPersonSources = 20 |
| 74 | ) |
| 75 | |
| 76 | // ResearchDispatch is a Research step's inputs (protocol 13): the |
| 77 | // coordinator's question, the person's own words on the task verbatim, |
| 78 | // the approved sources in canonical form, the primary's confirmed site |
| 79 | // inventory (prefixes; slice R3 fills it, and a step whose inventory is |
| 80 | // not confirmed is never dispatched; a family with no prefix is a family |
| 81 | // whose egress is unknown, and the fetcher refuses it), and the approved |
| 82 | // specialist's brief at the revision the step was dispatched under (at |
| 83 | // most specialist.MaxBrief bytes; a labelled input of Research's prompt). |
| 84 | type ResearchDispatch struct { |
| 85 | Question string `json:"question"` |
| 86 | PersonWords []string `json:"person_words"` |
| 87 | Sources []ResearchSource `json:"sources"` |
| 88 | Inventory []string `json:"inventory"` |
| 89 | SpecialistBrief string `json:"specialist_brief"` |
| 90 | SpecialistRevision int64 `json:"specialist_revision"` |
| 91 | } |
| 92 | |
| 93 | // ResearchSource is one approved source: its id within the step, its |
| 94 | // canonical URL (websource.URL.String) and its origin. |
| 95 | type ResearchSource struct { |
| 96 | ID string `json:"id"` |
| 97 | URL string `json:"url"` |
| 98 | Origin string `json:"origin"` |
| 99 | } |
| 100 | |
| 101 | // CardResearchView is what a sources card shows: the step it is bound to, |
| 102 | // what Research is asked to look for, and every proposed URL in full. |
| 103 | type CardResearchView struct { |
| 104 | StepID string `json:"step_id"` |
| 105 | Question string `json:"question"` |
| 106 | URLs []string `json:"urls"` |
| 107 | } |
| 108 | |