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

Chapter 10 — Changing a CSC already approved

The building manager decides that 60 seconds are too few to climb to the top floor: the on-time goes up to 90 seconds. The CSC of the light is approved, and an approved contract is not modified. The chapter describes how to write a new version of it and what, in the new version, must be approved again and what remains approved.

The new version

To change an approved CSC a new version of it is written, in the same file, in place of the previous one:

  1. the number after VERSION changes, for example from 0.1 to 0.2;
  2. the STATUS of the header goes back to HYPOTHESIS;
  3. a comment at the top of the file states what changes;
  4. every contractual line whose text changes and which has a STATUS RATIFIED BY of its own changes to STATUS HYPOTHESIS;
  5. the lines whose text does not change remain as they are.

Until the new version is approved, the contract in force remains the previous approved version, which can be found in the version history or in the document archive.

What remains approved

In the new version the state of each contractual line follows the rules of chapter 7:

Version 0.2 of the light, opened in chapter 9 to add the scenarios, is already an example. Its report shows, in section 4:

4. PENDING APPROVAL, NOT CONTRACT: 8
  line 15: GUARANTEE g1
  line 17: GUARANTEE g2
  line 23: GUARANTEE g3
  line 25: GUARANTEE g4
  line 27: GUARANTEE g5
  line 29: GUARANTEE g6
  line 31: GUARANTEE g7
  line 33: ASSUME a1

The eight lines approved in chapter 7 with decision D-7 do not have a STATUS of their own: they took that of the header, and with the header they have gone back to pending approval. The details g2a and g2b do not appear, because they have a STATUS RATIFIED BY D-9 of their own and their text has not changed: they remain approved.

The change from 60 to 90 seconds

In the same version 0.2 the new on-time is written. The text of the two details and the comment at the top change:

-- The staircase light, as seen by the person on the stairs and by the caretaker.
-- VERSION 0.2: scenarios s1-s4 added; on-time from 60 s to 90 s. Pending approval.
  GUARANTEE g2a DETAILS g2 STATUS HYPOTHESIS: VERBAL "The light switches off 90 s after the last press, with a tolerance of 5 s"
                                                VERIFY BY JUDGEMENT "a person who measures with a stopwatch the time between the last press and switch-off"
  GUARANTEE g2b DETAILS g2 STATUS HYPOTHESIS: VERBAL "A press while the light is on restarts the count of 90 s from the beginning"
                                                VERIFY BY JUDGEMENT "a person who presses the button again while the light is on and measures with a stopwatch the time until switch-off"

The two lines had a STATUS RATIFIED BY D-9 of their own; since their text changes, they switch to STATUS HYPOTHESIS.

The change also concerns scenario s1, which with 90 seconds would no longer be admitted: the light cannot switch off at 60 seconds. Its instants are updated:

  SCENARIO s1 EXPECT ADMITTED
    @0 s     premuto    modo = accesa
    @85 s    avviso
    @90 s    modo = spenta
    @100 s   premuto    modo = accesa

Scenario s2, with the switch-off at 30 seconds, remains rejected with the new time as well.

The report of version 0.2 now shows all ten contractual lines pending approval:

$ bcdd check --strict UsoLuce.csc
bcdd check --strict UsoLuce.csc
…
blocks: 1
  line 4: CSC UsoLuce VERSION 0.2, STATUS HYPOTHESIS

1. ERRORS: 0
…
4. PENDING APPROVAL, NOT CONTRACT: 10
  line 15: GUARANTEE g1
  line 17: GUARANTEE g2
  line 19: GUARANTEE g2a
  line 21: GUARANTEE g2b
  line 23: GUARANTEE g3
  line 25: GUARANTEE g4
  line 27: GUARANTEE g5
  line 29: GUARANTEE g6
  line 31: GUARANTEE g7
  line 33: ASSUME a1
…
outcome: no errors

Approving the new version

The building manager approves version 0.2 with decision D-12:

$ bcdd ratify UsoLuce.csc --all D-12
approved with D-12 in CSC UsoLuce: 3 lines
  line 5: CSC UsoLuce
  line 19: GUARANTEE g2a
  line 21: GUARANTEE g2b
contract: 10

The command modifies three lines: the header and the two details that had a STATUS HYPOTHESIS of their own. The other eight contractual lines take the STATUS of the header and are approved with it. In the report section 4 is empty again:

blocks: 1
  line 4: CSC UsoLuce VERSION 0.2, STATUS RATIFIED BY D-12
…
4. PENDING APPROVAL, NOT CONTRACT: 0

Version 0.2 is now the contract in force and replaces 0.1.

What can be modified without a new version

Comments are not part of the contract: they can be corrected at any time, without a new version, provided that no other line changes.

bcdd reads one file at a time and has no access to the previous version: it therefore cannot state what has changed between two versions. The comparison is made with a version control system, for example git diff, before approving.

Summary

Special cases

Text changed without STATUS HYPOTHESIS. If the text of g2a changes to 90 seconds but the line keeps STATUS RATIFIED BY D-9, the line remains approved with a text that nobody has approved. bcdd check does not detect this: g2a does not appear in section 4 of the report.

4. PENDING APPROVAL, NOT CONTRACT: 8
  line 15: GUARANTEE g1
  line 17: GUARANTEE g2
  line 23: GUARANTEE g3
  line 25: GUARANTEE g4
  line 27: GUARANTEE g5
  line 29: GUARANTEE g6
  line 31: GUARANTEE g7
  line 33: ASSUME a1

This defect can be detected only by comparing the new version with the previous one, before approving it.

Two versions in the same file. The new version replaces the previous one in the file. If the two versions remain one after the other, the second repeats a name already declared:

1. ERRORS: 1
  line 34: [E01] name already used at line 3: UsoLuce

Undecided number in an approved CSC. To replace UNDECIDED with a value in an approved CSC a new version is written, as for any other change; in a CSC pending approval the line is modified directly.