jig-harness/jig

Needs and structured answers

provisional · Version 1 · Plan item 50

Some of the work on Jig’s line waits on a person: a decision only a person may take, a merge, a step by hand. Each such wait is a need. Without a shared form for it, a person reads each one in a different place and answers in their own words, and the next session works out which option they meant: no program can tell which option was chosen, and nothing ties an answer to the question it answers. So a need carries a framed decision: one record with the question, the options, what each changes and costs, and the option recommended. A person answers it in a word, as a structured answer, and every reader finds the same option in that word.

This chapter lists:

  • The decision record (parked-decision/v1), and its JSON Schema, schemas/parked-decision.json.
  • The answer: the lines it is written in, its forms, how its text is normalized before it is compared, and the limits on it.
  • What a need asks of a person: the act of each decision class Jig knows.
  • The dispatcher’s own framings: the key each kind of need it frames is answered by, and the options the tick carries out.

Besides Jig’s own scripts (a drive’s re-arm and the dispatcher’s tick, which read the answers), the dispatch dashboard, jig ask, jig send and a workspace app’s panel read these values to show a decision, offer its options and write an answer. How the forms came about and why: design/structured-answers.md.

The decision record

A decision record is a JSON document. These write it:

  • a drive’s pass that parks an item for a person (drive-state.ts park); the drive keeps it with the parked item, and its ledger publishes it on the pull request;
  • a dispatched follow-up’s or pickup’s pass that stops for a person (jig dispatch result … failed --decision <file>, or the decision of its closing report); the dispatcher keeps it with the launch record;
  • the dispatcher’s tick, which frames a decision of its own for a cause it finds (below).

Each is kept with its decision digest, computed once, when it is stored, and published beside it; no reader computes it again. A writer’s record passes a strict check that refuses a field this chapter does not list, an empty text, a question that is not one line ending with ?, an option id that is not one to eight letters or digits or is used twice, fewer than two options, a recommendation that names no option, and option names that are the same once normalized or that redaction would change. A stored record is read more loosely: its text may have been redacted since, so a reader checks only the fields’ presence and types, and reads past a field it does not know. The schema states that reading. A reader that meets a record the schema refuses does not read it as a decision, and never guesses what it meant.

The decision sheets of /jig:decide share the option’s fields with the record.

FieldTypeCarriedMeaning
schemastringalwaysAlways parked-decision/v1: a reader that meets another value does not read the record as a decision.
classstringalwaysThe decision class the decision falls in: a class of the repository’s human-in-the-loop registry, or one of the dispatcher’s own framings. Its act is in the classes table below; a class that table does not list asks a person to decide.
callobjectalwaysThe question, its options and the recommended option.
call.idstringalwaysThe call’s id: one to eight letters or digits.
call.questionstringalwaysThe question a person answers: one line, ending with ?.
call.optionsobject[]alwaysThe options a person chooses from, at least two, in the order the decision gives them. A refusal or a wait is an option of its own.
call.options[].idstringalwaysThe option’s id, one to eight letters or digits, unique within the call: call.recommended names an option by it.
call.options[].namestringalwaysThe option’s name on one line: what choose <option> names. No two options’ names are the same once normalized, so a choose never names two options.
call.options[].summarystringalwaysWhat choosing the option changes.
call.options[].paystring[]alwaysWhat choosing the option costs, at least one entry.
call.options[].tagstringsometimesA short label shown with the option.
call.options[].keepstring[]sometimesWhat the option keeps as it is.
call.options[].rightWhenstringsometimesWhen the option is the right one.
call.options[].obligationstringsometimesWhat choosing the option obliges someone to do afterwards.
call.options[].reversiblebooleansometimesWhether what the option does can be undone. A card asks for a second step before it commits a pick of an option marked false.
call.recommendedstringalwaysThe id of the option the decision recommends: the option approve chooses.
call.whystringalwaysWhy the decision recommends that option.
stepsstring[]alwaysWhat a person must do by hand whichever option is chosen; empty when there is nothing.
alreadyDonestringalwaysWhat the session that framed the decision already did about it.
factsobject[]sometimesFacts the decision rests on, each with where it was found.
facts[].textstringalwaysThe fact.
facts[].sourcestringalwaysWhere the fact was found: a file and line, a link, a command.
interplayobject[]sometimesHow this decision bears on others, entry by entry: what settling one means for another.
interplay[].fromstringalwaysWhat the entry starts from, in free text: a call’s id, another decision, an issue or a decision record.
interplay[].tostringalwaysWhat the entry bears on, in the same free text as from.
interplay[].textstringalwaysHow the one shrinks or sharpens the other.
sheetstringsometimesThe address of a decision sheet that sets the decision out at length: an https URL.

Answering a decision

A person answers in a comment on the pull request, or on the item when the need is an item’s, from an author the forge or tracker trusts, written later than the decision was framed. Each line answer <key>: <text> outside a code block answers the decision parked under <key>; in a reply on a parked review thread, the reply’s one line may be the text alone.

LineWrittenMeaning
answeranswer <key>: <text>Answers the decision parked under <key> with <text>: a structured answer when the comment holds nothing but answer and note lines (and blank lines, jig send’s record and quotes of the notification), and the text is one of the forms; otherwise a free answer.
notenote <key>: <text>Adds the person’s own words to the structured answer to <key> beside it, which may narrow the option chosen or set a condition on it, never widen it. A note with no answer beside it answers nothing.

The text is a structured answer when, its trailing digest taken off and normalized, it is exactly one of these forms. Anything else is a free answer, read in the person’s own words by the session the answer goes to: approve, but keep the old flag, a choose that names no option, a comment with a line of prose beside its answer lines. jig ask and the dashboard label it free, so a person who meant a structured answer sees it was not read as one. There is no form that declines: refusing what one option allows is choosing another, and a decision whose act is Authorize offers its refusal as an option of its own.

FormWrittenMeaning
approveapproveChooses the option the decision recommends. On a decision that recommends no option it is a free answer.
choosechoose <option>Chooses the option whose normalized name is <option>. A name no option of the decision has makes it a free answer.

A structured answer ends with the digest of the framing the person read, in square brackets: answer drive: approve [3fa9c2d1e0b4]. A reader takes a trailing digest off before it reads the form. An answer naming a digest that is not the decision’s current one is stale: it settles nothing and the decision waits, so an approval of an earlier framing never settles the one that replaced it. An answer naming no digest is bound by its time alone on a parked question; on a dispatcher need, a structured answer naming no digest is stale and settles nothing. Every line Jig offers to copy, and every answer jig send writes, carries the digest. On the forge, and on a tracker’s item when the sender may be the user the dispatcher’s own tracker credential acts as, jig send also writes a hidden record beside the line, listed in the hidden comment markers’ chapter as drive-answer. A dispatcher reads a comment by its own forge login or tracker user as an answer to a need’s decision only with that record, naming that identity, the decision’s key and digest and the option the line chooses.

Each person’s latest answer counts, its time being when its comment was last edited. When every person’s latest answer chooses the same option with the same note, that option is chosen; when all are free, every one is handed on; any other mix leaves the decision disputed, and it waits for the people answering to agree.

A person’s answer and every option’s name are normalized the same way before they are compared, in this order, so a phone’s typography still matches:

StepNameMeaning
1compatibilityApplies Unicode’s compatibility normalization (NFKC): full-width letters and other compatibility forms become their plain forms.
2caseFolds every letter to lower case.
3quotesTurns typographic single quotes (U+2018 to U+201B) into ' and double quotes (U+201C to U+201F) into ".
4dashesTurns hyphens and dashes (U+2010 to U+2015) and the minus sign (U+2212) into -.
5marksRemoves backticks and the bold marks ** and __, which a pasted or formatted answer may carry.
6white-spaceReads every run of white space as one space, and drops white space at either end.
7final-stopDrops one full stop or exclamation mark at the end, which a phone’s keyboard may add, and the space before it.
LimitValueUnitMeaning
answer-text500charactersThe longest an answer’s or a note’s text may be. A longer one, or one with a line break, another control character or a hidden marker (<!--), is not a structured answer, and jig send refuses to send it.
digest12hexadecimal charactersThe length of a decision digest: the first characters of the SHA-256 of the decision record as stored, in canonical JSON, kept with the decision. An answer ends with its framing’s digest in square brackets, approve [3fa9c2d1e0b4]; an answer naming another digest is stale and settles nothing, and one naming none is bound by its time alone.
decision-bytes8192bytesThe largest a decision record may be, as UTF-8 JSON. A park, a dispatched session’s result and its closing report refuse a larger one.

What a need asks of a person

Every need opens with one act, from a closed list, so a reader sees what it asks before reading it. A decision’s act is its class’s; a class this chapter does not list (a repository may add classes of its own to its human-in-the-loop registry) asks a person to decide.

ActMeaning
MergeMerge the pull request: only a person merges.
DecideChoose among the options the decision frames.
AuthorizeAllow, or refuse, what only a person may allow; refusing is an option of the decision’s own.
ReplyAnswer a person’s review thread.
DoPerform steps by hand, outside the line.
InvestigateLook into what went wrong: a failure or a stall nobody framed as a decision.
ClassActMeaning
scopeDecideExpand a pull request’s scope.
next-itemDecidePick the next item from the computed ranking.
reopen-or-waiveDecideReopen an item on a rejecting verdict, or waive a missing acceptance review.
escalatedDecideA review thread the review arbiter escalated with no recorded person’s decision behind it.
human-decisionDecideA fix that would change what the pull request records as a person’s decision, or a decision only a person can take; a pass that cannot read the repository’s policy parks every decision under it.
mergeMergeMerge a pull request.
readyAuthorizeMark a pull request ready for review.
releaseAuthorizeRelease or promote to production.
destructiveAuthorizeA destructive operation: data loss or a history rewrite.
legalAuthorizeA legal or data-protection sign-off.
copyAuthorizePublish customer-facing copy.
dark-dialAuthorizeFlip a dial that is off by default.
rulesAuthorizeChange the rules the agents follow: instructions and scaffolding.
reviewer-postureAuthorizePromote an automated reviewer to blocking, or waive a failing advisory check.
human-threadReplyA person’s review thread an agent may not overrule on its own, or a person’s reversal of a provisional decision.
structural-churnDecideThe drive’s own park: the same files keep drawing non-blocking findings round after round, or a file returned to an earlier content; choose how the pull request goes on.
followup-recoveryDecideThe dispatcher’s framing: how a follow-up that failed or whose claim went stale goes on.
pickup-recoveryDecideThe dispatcher’s framing: how a pickup that stalled, stopped on a question or ended without moving its item goes on.
checkout-recoveryDecideThe dispatcher’s framing: how a checkout another tree holds is freed for a launch.
drive-recoveryDecideThe dispatcher’s framing: how a drive that handed its pull request to a person goes on.
launch-recoveryDecideThe dispatcher’s framing: how a launch record no tick launches again is settled.

A pick under a class whose act is not Decide, or of an option marked as one that cannot be undone, takes a second step on the dashboard’s card before it is committed.

The dispatcher’s own framings

For a cause the dispatcher finds itself, its tick frames the decision from the facts that identify that cause, never from a clock or a count, so its digest stays the same while the facts do. It frames it under one of the keys below, with a fixed set of options, and carries out the option a person chooses once. Each set ends with hold, which does nothing and hides the need until its facts change. An answer naming Leave it to me, the name hold had before, still chooses it.

KeyClassOptionsMeaning
followupfollowup-recoveryrerun, done, holdA merged pull request’s follow-up whose pass ended without recording done, or whose claim no session is joined to.
releasereleasegates, inspect, tagAn untagged release, or the untagged releases of a repository that share a remedy, answered on one tracker item. It recommends re-running the failed gates unless a re-run was already requested (then it recommends investigating), or no failed gate is left to re-run: the version’s follow-up recorded that every required check passed or that the version is outside automatic tagging, the repository disables re-runs (changelog.release.rerun_failed_gates: 0), or it leaves the tag to a person (then it recommends a person’s tag). In both cases it offers only the other two options.
pickuppickup-recoveryrelease, holdA pickup that stalled, stopped on a question it did not frame, or ended without moving its item on.
checkoutcheckout-recoverydetach, holdA launch that waits because a checkout the workspace runtime does not list holds its branch and is in use.
drivedrive-recoveryrearm, holdA drive that stopped and handed its pull request to a person.
launchlaunch-recoveryclear, holdA pending launch record that no tick launches again, or one of unknown process that holds a drive.
OptionNameCan be undoneMeaning
rerunRun it again—The dispatcher releases the follow-up’s claim (its marker comment), and a later tick starts the follow-up again once, with your note, when you add one, as a person’s answer in its prompt.
doneRecord it done—The dispatcher marks the follow-up’s marker done and sets the pull request’s followed-up label; nothing runs again.
releaseRelease the claim—The dispatcher moves the item back to the state a pickup starts from, so a later tick picks it up afresh in a new session.
detachDetach the checkoutyesThe dispatcher detaches the checkout from its branch (its files and commits stay where they are), so the launch can take the branch.
rearmRe-arm the drive—The dispatcher re-arms the drive once on the pull request’s current head, as the rearm label does.
clearClear the record—The dispatcher clears the stuck launch record, as jig dispatch clear does, which frees its slot; a later tick may start its stage again.
gatesRe-run the failed gates—The dispatcher requests another run of the failed jobs on the releasing commit once.
inspectInvestigate—Take the tracker item and determine what is holding back the tag.
tagTag it by hand—Take the tracker item and create the tag by hand after checking it is safe to release.
holdI’ll handle it — hide this card—Nothing is done; the work stays where it is. The dispatcher hides this card for these facts and lists it again when they change.

Not yet in this chapter

  • The causes of a need and their classes. The causes the dispatcher finds waiting on a person (a failed follow-up, a stalled pickup, a host fault, …), the act each asks for, and the classes of need they group into are being settled by plan item 50 (design/need-classes.md), which still adds and regroups causes. They join this chapter once their table settles.
  • How often a recommendation is approved. The answer outcome event and the counts by decision class are outside this chapter.
  • An answer as jig ask shows it. The JSON jig ask prints for a decision’s answers has no schema yet.

Machine-readable files

Source: plugin/protocol/needs-and-answers.md