Logo BCDDLogo CSC
BCDDBehavioural Contract-Driven Design
version 1.0-beta
ITEN

7. Approved lines and lines pending approval

Section 7.1 defines the status of every contractual line. Sections 7.2-7.4 state how a CSC changes over time: a new version, the levels of details, a replaced line.

7.1 The effective status of a line

Every contractual line (a GUARANTEE or ASSUME with a recognised line header) has an effective status: approved or pending approval. It is decided as follows, in this order:

  1. if the line is in a block, CSC or entity, whose header is not valid (it does not respect G1 or G31: error E09), it is pending approval, whatever STATUS the line and the header have;
  2. if the line has its own valid STATUS RATIFIED BY D-nnn, it is approved;
  3. if the line has its own STATUS HYPOTHESIS, or a STATUS RATIFIED without a valid decision (error E04), it is pending approval;
  4. if the line has no STATUS and is a detail (DETAILS), it is pending approval: a detail does not inherit the approval of the CSC;
  5. otherwise the STATUS of the CSC header applies: approved if it is a valid RATIFIED BY D-nnn; pending approval in every other case, including when there is no STATUS. (After point 0 the header here is always valid.)

Point 3 exists so that a detail added after the approval of a CSC does not silently become approved.

A profile pending approval. Point 0a applies before point 1: a contractual line that uses an extension of a profile that is found and pending approval (its STATUS is not a valid RATIFIED BY D-nnn) is pending approval, whatever STATUS the line and the header have. The meaning of the extension has not been approved, and therefore neither has the line that uses it. Once the profile is approved, the line returns to the status given by points 1-4. In the JSON the stato_di of this line is profilo: the status does not come from the line, from the detail or from the header.

The other lines with a status. The same rules apply to:

The lines pending approval are in section 4 of the report (HYPOTHESIS, NOT CONTRACT). check never approves: it only reads.

The invalid header (point 0). A header that does not respect G1 or G31 (error E09, for example CSC Rotta VERSIONE 0.1, CSC Rotta 0.1 or ENTITY Rotta VERSIONE 0.1) does not state which CSC or entity, nor which version: no line of the block is approved, neither those that follow the header nor those with their own STATUS RATIFIED BY D-nnn. The block is opened all the same (section 5) and the STATUS lines remain recognised and written as they are: once the header is corrected, every line returns to the status given by points 1-4. The rule looks at the block of the line, not at the file. The edge cases:

Case Effective status Reason
CSC with E09, then STATUS RATIFIED BY D-1: line without STATUS and without DETAILS pending approval: in section 4 of the report, stato ipotesi and decisione null in the JSON point 0
the same CSC, line with its own STATUS RATIFIED BY D-2 pending approval, in section 4; decisione null point 0
the same CSC, line with STATUS HYPOTHESIS, or a detail without STATUS pending approval point 0 (they would also be so by points 2 and 3)
CSC with E09, then STATUS RATIFIED without BY (E04) all pending approval; E09 and E04 remain point 0
CSC with E09, without STATUS or with STATUS HYPOTHESIS all pending approval point 0
entity with E09 (ENTITY Rotta VERSIONE 0.1), even with STATUS RATIFIED BY D-1 all pending approval, including the guarantee with its own STATUS RATIFIED BY point 0; the lines without STATUS would be so in any case (in an entity point 4 always gives “pending approval”)
two blocks: the first with E09 and STATUS RATIFIED BY D-1, the second valid with STATUS RATIFIED BY D-5 all pending approval in the first; in the second points 1-4 apply the rule looks at the header of the block of the line
valid header with the name already used by another block (E01), then STATUS RATIFIED BY approved E01 is not an invalid header: G1 is respected. Point 0 applies only to E09
--strict the code remains 1 (E09 is an error) and section 4 is the one without --strict the effective status does not depend on --strict (section 9.2, “Rest of the report with --strict”; section 10, “What prevails”)

Point 0 does not change: the block line in the report (line N: CSC (invalid header), STATUS RATIFIED BY D-1) and, in the JSON, the stato and the decisione of the block, which report the STATUS written in the header and not the effective status of the lines; the number of errors, the outcome line and the exit code; sections 2, 3, 5, 6, 7 and 8; the levels of DETAILS (7.3). In the JSON the field stato_di of every line of a block with E09 is intestazione_non_valida, whatever is written in the line. ratify and refine do not work on a file with errors, so they never see a line of this kind.

The remaining case (declared limitation, like that of 7.2). If the author corrects an invalid header by hand, the lines that were approved before the header was damaged become approved again without ratify, with their STATUS RATIFIED BY and that of the header: “once the header is corrected, the line is approved again”. check reads one file at a time and does not know what was there before; the case is covered by comparing the file with the previous version.

The guarantees of an entity. Points 0, 1, 2 and 3 apply as in the CSC. Point 4 in an entity always gives “pending approval”: the header of an entity is never approved (STATUS RATIFIED is unrecognised there, section 5). Therefore an entity guarantee is approved if and only if it has its own valid STATUS RATIFIED BY D-nnn, and it becomes approved with bcdd ratify (section 12), only if the boundaries of the entity have been read. Example: in an entity Ratificata with STATUS RATIFIED BY D-1 as its first declaration, the status of the block is without STATUS and the STATUS line is in section 5; r1 (without STATUS) is pending approval; r2 (STATUS RATIFIED BY D-2) is approved; r3 (STATUS RATIFIED without a decision) gives E04 and is pending approval.

As in the CSC, check does not know who wrote a STATUS RATIFIED BY: written by hand, it makes an entity guarantee approved even if one of its boundaries is not found (the search does not change the outcome). The rule is that STATUS RATIFIED BY is not written by hand (section 7.2); ratify enforces it by checking the boundaries (section 12.2, step 7). Declared limitation.

A linear example (the file is valid: check --strict gives code 0):

CSC LuceScale VERSION 0.1
  STATUS RATIFIED BY D-135
  ...
  GUARANTEE g1: VERBAL "A press switches the light on"
  GUARANTEE g1a DETAILS g1: VERBAL "Within 1 second of a press the light is on"
  GUARANTEE g2 STATUS HYPOTHESIS: VERBAL "The light switches off by itself after DURATA_LUCE"
  GUARANTEE g2a DETAILS g2 STATUS RATIFIED BY D-200: VERBAL "A press while the light is on restarts the time"

(the VERIFY lines are omitted here for brevity; they are present in the file; D-135 and D-200 are example references).

Line What it has Point Effective status
g1 no STATUS, no DETAILS 4: inherits from the header, which is RATIFIED BY D-135 approved
g1a no STATUS, but DETAILS g1 3: a detail does not inherit pending approval
g2 its own STATUS HYPOTHESIS 2 pending approval, even though the header is approved
g2a its own STATUS RATIFIED BY D-200 1 approved, even though it details a line pending approval

With the header STATUS HYPOTHESIS, or without STATUS, g1 would also be pending approval (point 4); g2a would remain approved (point 1).

Who uses the effective status (the rule is the same for all):

Command What it does with it Where
bcdd check lists the lines pending approval in section 4 of the report section 9
bcdd ratify FILE ID D-nnn refuses a line that is already approved, even if it is so because it inherits (point 4); in an entity, a guarantee with its own STATUS RATIFIED BY. A file with an invalid header has E09 and ratify refuses it before looking at the line (section 12.2): point 0 does not change ratify section 12
bcdd ratify FILE --all D-nnn changes only the header, if it is pending approval, and the lines that remain pending approval afterwards (points 2 and 3): the lines of point 4 follow the header and are not touched section 12
bcdd refine can propose replacing only a line pending approval; an approved line is never replaced section 7.4

7.2 A new version of an approved CSC

  1. An approved CSC is not modified. To change it, the author writes a new VERSION in the same file, in place of the old one (the same name twice in the same file is E01), with STATUS HYPOTHESIS in the header and a leading comment stating what changes and on the basis of which decisions.

  2. In the new version:

    • a line whose text does not change keeps its STATUS RATIFIED BY D-mmm, if it had one: it remains approved, with the earlier decision;
    • a line whose text changes returns to pending approval: if it had its own STATUS RATIFIED BY D-mmm, the author changes it to STATUS HYPOTHESIS. A line without STATUS and without DETAILS is already pending approval, because it follows the header (section 7.1, point 4), and STATUS need not be added. It follows the status of the header, like the other lines that follow it, including when the header is approved;
    • a new line is pending approval: with STATUS HYPOTHESIS, or without STATUS (section 7.1, points 3 and 4).

    Until the new version is approved, the contract in force remains the previously approved version; of the new version only the lines that have not changed and have their own STATUS RATIFIED BY are approved.

  3. The new version becomes approved only with bcdd ratify FILE D-nnn or bcdd ratify FILE --all D-nnn, with the decision reference of the approval. STATUS RATIFIED BY is not written by hand.

Example: the approved staircase light is VERSION 0.1. To add flashing, the following is written:

-- VERSION 0.2 (D-nnn): flashing before switch-off. Pending approval.
CSC LuceScale VERSION 0.2
  STATUS HYPOTHESIS
  ...

What check sees: the header STATUS HYPOTHESIS, and in section 4 of the report the lines without STATUS (point 4 of 7.1), the details without STATUS and the lines with STATUS HYPOTHESIS. A line with its own STATUS RATIFIED BY remains approved in the new version too (point 1 of 7.1): this is point 2 above. Example: a staircase light approved with --all, with four base lines g1, g2, g3, a1 without STATUS and six details (g1a…g1c, g3a…g3c) with their own STATUS RATIFIED BY, brought to VERSION 0.2, STATUS HYPOTHESIS without changing anything else: section 4 of the report contains the four base lines, which follow the header; the six details remain approved.

The remaining risk. If the author changes the text of a line and forgets to set it to STATUS HYPOTHESIS, the line remains approved with a text that the approver has not seen, and check does not notice (section 14). This is covered by the comparison with the previous version before approval, not by bcdd. bcdd refine does not create this case: it never replaces an approved line (section 7.4).

A comment is not contract. The rule “an approved CSC is not modified” applies to what is approved: header, declarations, contractual lines. A comment (-- …) can be corrected without a new VERSION, if no recognised line changes.

check reads one file at a time and does not know the previous version: it cannot tell whether a VERSION is new, nor what has changed. The comparison between two versions is made with file version-control tools, not with bcdd.

7.3 The levels of DETAILS

Example, under g2 of the staircase light (the file is valid):

GUARANTEE g2: …                      -- level 0, base line
GUARANTEE g2a DETAILS g2: …          -- level 1
GUARANTEE g2a1 DETAILS g2a: …        -- level 2
GUARANTEE g2a1a DETAILS g2a1: …      -- level 3
Command What it does with the levels
bcdd check nothing: it accepts DETAILS at any depth, without errors or warnings, and the report does not show the levels. A file with lines at level 3 or 4 passes check --strict with code 0
bcdd refine proposes at most two levels: a proposal that details a line already at level 2 or deeper is discarded; therefore a line added by refine reaches at most level 2. Replacements (section 7.4) apply at every level. Lines already deeper remain: refine does not touch them and does not detail them
bcdd ratify nothing: it approves a line at any level

The level is counted only in a file without E02 or E05, where every chain of DETAILS ends in a base line. This is the case of refine, which works only on files without errors.

7.4 The replaced line

bcdd refine can propose to replace a line pending approval (section 7.1) written in words; the person sees the current line and the new one, and accepts or discards.

What remains and what changes when the person accepts:

Example, g2 of the staircase light, a base line under a STATUS HYPOTHESIS header:

before:
  GUARANTEE g2: VERBAL "The light switches off by itself after a while"
                VERIFY BY JUDGEMENT "the operator, with a clock"
after:
  GUARANTEE g2: VERBAL "The light switches off by itself between 59 and 61 seconds after the last press"
                VERIFY BY JUDGEMENT "the operator, with a stopwatch"

What remains is GUARANTEE g2:. Since the STATUS does not change, the line remains pending approval: g2 continues to inherit from the header, and if the header is then approved the line follows it like the other lines. A detail g2a DETAILS g2 remains valid, because the short name g2 does not change; refine lists it as “to be re-read”. For check the replaced line is a line like any other: it does not know that it has been replaced.