12. The bcdd ratify command
bcdd ratify records the approval of one line, or of all, by modifying or adding only STATUS indications. It works on
CSCs, on the guarantees of an entity, on BINDINGs and on profiles; a VERIFICATION is not approved. The examples are
on the staircase light.
12.1 Form
bcdd ratify FILE [--csc NAME] [--dir FOLDER]... [ID | --all] D-nnn
ratify works on CSCs and on the guarantees of an entity: in an entity it approves, with ID, one guarantee, with
--all all those still pending approval; never the header, the OFFERS and USES lines or the parts of the entity. An
entity guarantee is approved only if every CSC that the entity provides or uses has been found, in the requested version, in
a file without errors (section 12.2, step 7).
In a CSC ID can also be the name of a detail of a DEFINE or the short name of a detail of a scenario (G12,
G19 with DETAILS), which are approved like contractual lines. A BINDING is approved like a CSC, with
the header or with --all; BIND lines have no short name and are not approved one by one. A profile is
approved only as a whole, with the header or with --all (which for a profile does the same): extensions have
no status of their own.
| Command | What it approves | Example |
|---|---|---|
bcdd ratify FILE D-nnn |
the header of the CSC; the lines that inherit (section 7.1, point 4) become approved with it | bcdd ratify LuceScale.csc D-135 |
bcdd ratify FILE ID D-nnn |
the line ID, which must be pending approval |
bcdd ratify LuceScale.csc g2 D-135 |
bcdd ratify FILE --all D-nnn |
the header and every line that would remain pending approval, in a single write | bcdd ratify LuceScale.csc --all D-135 |
- The arguments that do not begin with
-are positional: 2 (FILE D-nnn) or 3 (FILE ID D-nnn); with--allthere must be 2. - The last positional argument is the decision reference: rule L9 (
D-followed by digits only). - With 3 positional arguments, the middle one is the ID, the short name of the line: rule L8.
--csc NAMEchooses the block (CSC, entity,BINDINGor profile) when the file contains more than one;NAMEmust respect rule L7. The option is written in any position, only once, andNAMEis the argument that follows it.--allis written in any position, only once, and has no argument.--dir FOLDERas incheck(section 10): in any position, also several times; the argument that follows--diris always the folder, even if it begins with-, and does not count among the positional arguments; the same string after two--diroptions,--diras the last argument and--dir=Xare incorrect usage. The folders serve for the search of the citations, in step 4 and in step 7 of 12.2.- A file whose name begins with
-is indicated with its path, for example./-x.csc, as incheck.
12.2 Order of the checks
The first check that fails decides the message and the code; the file is not touched.
-
Arguments, in this order: number of positional arguments and options (
usage: …), decision, ID, name after--csc(the rows with code 2 of section 12.5). -
Reading of the file: the same cases as
bcdd check(section 10), with the prefixbcdd ratify:in place ofbcdd check:. -
The
--dirfolders, one at a time in the written order, with the cases and messages of section 10 and the prefixbcdd ratify:(for examplebcdd ratify: folder not found: ARG), code 2. -
The file passes
bcdd check --strict: no errors and no unrecognised lines, in the whole file. Only whatbcddhas read in full is approved. The check searches for the citations of the entities ascheckdoes: in the same file, in its folder and in the--dirfolders. An E14, an E04 or an unrecognised line in an entity prevents the approval of every block of the file. The entries of sections 12-15 of the report are not errors and do not stop step 4. -
Choice of the block (also applies to
refine):The file Without --cscWith --csc NAMEat least one CSC among the CSCs, wherever the other blocks are: a single one is the one; more than one, the file contains N CSCs: …the block NAME(see below)no CSC, a single entity the entity the block NAMEno CSC, several entities the file contains N ENTITYs: say which with --csc NAME, code 2the block NAMEno CSC or entity, a single block among BINDINGandPROFILEthat block the block NAMEno CSC or entity, several blocks among BINDINGandPROFILEthe file contains N blocks to approve: say which with --csc NAME, code 2the block NAMEno block NAME— no block to approve with the name NAME in the file, code 1no CSC, entity, BINDINGorPROFILE(onlyVERIFICATION)the file contains no block to approve: a VERIFICATION is not approved, code 1as without --cscWith
--csc NAMEthe block is, in order: the CSC, the entity or the profileNAME; otherwise theBINDINGwith the distinguishing nameNAME(AS NAME); otherwise the onlyBINDINGwithout a distinguishing name bound to the CSCNAME. ABINDINGwithout a distinguishing name in the same file as its CSC is not chosen by name, because the name is that of the CSC: it is chosen on its own when the file has no CSC or entity, or it is given a name withAS. The name of aVERIFICATIONnever chooses a block.A file with a
REFINEMENT VIEWhas E15 and stops at step 4. -
The target. In a CSC: the header, the line
ID(which must be pending approval: a contractual line or a detail of aDEFINEor of a scenario), or with--allthe set of lines to be changed, which must not be empty. In aBINDING: the header, or with--allthe header and theBINDlines with their ownSTATUSpending approval; withIDit is a refusal. In a profile: the header, with or without--all; withIDit is a refusal. In an entity: withoutIDor--allit is a refusal; withID, a guarantee of the entity pending approval; with--all, all the guarantees of the entity pending approval, which must be at least one (the messages are in section 12.5). -
The boundaries read, only if the chosen block is an entity. For every
OFFERSandUSESline of the entity, in line order, the search of step 4 must have found it; if the line declaresVERSION w, the block found hasVERSION w(same text); the file of the block found has 0 errors (its unrecognised lines do not count). The first line that does not satisfy this decides the message (section 12.5), code 1. The parts do not count; an entity withoutOFFERSorUSESpasses. For a CSC the step does not exist: a CSC is approved even if an entity of the same file has a missing boundary. -
Composition of the new text (section 12.3) and its check, with the same folders: no errors, no unrecognised lines, the target approved; with
--all, the header and all the contractual lines of the CSC approved, or in an entity all its guarantees. If not, it is an internal error and the file is not touched. It is a safeguard: it should never happen. -
Safe write: all or nothing (section 12.6).
A part not found suspends E14 and does not count for step 7. Therefore without --dir an entity guarantee is
approved even if, with --dir indicating the folder where the part is located, the file would have an E14. For this
reason the approver must indicate the folders in which the parts are located.
12.3 Changes to the file
The minimum changes: without --all a single line changes, or a single line is added; every other byte
remains identical, including the BOM and the line endings. “D-nnn” is the decision as it was written in the command.
For the header, the recognised STATUS of the header zone is considered (section 4.2: the first, wherever it
is among the header lines). In case c2 the line is added immediately after CSC …, even if the zone has
IMPORT PROFILE lines. For a line, the first line of the GUARANTEE or ASSUME declaration, or of the detail
of a DEFINE or of a scenario, is considered. In a detail of a DEFINE case r2 inserts STATUS RATIFIED BY D-nnn immediately after the
short name that follows DETAILS, before :=; in a detail of a scenario, immediately after the short name that follows DETAILS,
before GIVEN or EXPECT. The header of a BINDING and of a profile changes with cases c1 and c2; in case c2
the indentation is that of the first declaration after the header, and if that is the END of the block, the indentation
of the END followed by two spaces. A BIND line with its own STATUS HYPOTHESIS changes with case r1; a BIND
line without STATUS follows the header and is not touched.
| Case | Target | What it does | Before | After |
|---|---|---|---|---|
| c1 | header with STATUS HYPOTHESIS |
only the word HYPOTHESIS becomes RATIFIED BY D-nnn; indentation, spaces, comment and line ending remain |
STATUS HYPOTHESIS |
STATUS RATIFIED BY D-135 |
| c2 | header without STATUS |
a line is added immediately after CSC …: the indentation of the first declaration line after the header (the first that is neither blank nor a comment; there always is one, because the file has a PURPOSE), copied byte for byte, then STATUS RATIFIED BY D-nnn, then the line ending of the CSC … line (CR LF if that ends with CR LF, otherwise LF) |
CSC LuceScale VERSION 0.1 / PURPOSE "…" |
CSC LuceScale VERSION 0.1 / STATUS RATIFIED BY D-135 / PURPOSE "…" |
| c3 | header already RATIFIED BY D-mmm |
refusal, code 1 | ||
| r1 | line with its own STATUS HYPOTHESIS |
only the word HYPOTHESIS becomes RATIFIED BY D-nnn |
GUARANTEE g2a DETAILS g2 STATUS HYPOTHESIS: VERBAL … |
GUARANTEE g2a DETAILS g2 STATUS RATIFIED BY D-135: VERBAL … |
| r2 | line without STATUS |
STATUS RATIFIED BY D-nnn (with a space in front) is inserted immediately after the last character of the last token before the colon (the short name, or the short name after DETAILS); the spaces before the colon remain after the inserted text |
GUARANTEE g2: VERBAL …; GUARANTEE g3 : VERBAL … |
GUARANTEE g2 STATUS RATIFIED BY D-135: VERBAL …; GUARANTEE g3 STATUS RATIFIED BY D-135 : VERBAL … |
| r3 | line already approved, through its own STATUS RATIFIED BY or because it inherits (section 7.1, point 4) |
refusal, code 1 |
The header of a contractual line is always on a single line (rule U2), so ratify always changes a single
line for each target. A line that details a line pending approval can be approved. Approving
the header does not change the lines that have their own STATUS HYPOTHESIS nor the details without STATUS: they remain pending
approval, and the command says so.
An interruption with Ctrl-C before the safe write ends the command without touching the file; during the write it is deferred until the write ends (section 12.6).
With --all: after the command the header and every GUARANTEE and ASSUME of the CSC are approved, with the
minimum change:
| What | If it is pending approval | If it is already approved |
|---|---|---|
| the header | case c1 or c2 | does not change, and keeps its decision |
a line with its own STATUS HYPOTHESIS |
case r1 | — |
a detail without STATUS |
case r2 | — |
a line without STATUS and without DETAILS |
— | inherits the approval of the header: does not change |
a line with its own STATUS RATIFIED BY D-mmm |
— | does not change, and keeps its decision |
The other CSCs of the file do not change, and the lines of the entities remain identical byte for byte.
The guarantees of an entity change with cases r1 (with their own STATUS HYPOTHESIS) and r2 (without STATUS,
base or detail), one line per guarantee; with --all all the guarantees of the entity pending approval, and never
the header. The VERIFY lines are not realigned, even when case r2 shifts VERBAL to the right. Example: in an entity Scale with a base guarantee without
STATUS at line 5, a detail with STATUS HYPOTHESIS at line 7 and a detail already approved at line 9,
--all D-200 changes line 5 (r2) and line 7 (r1); line 9 does not change. A single write, all or nothing: bcdd
composes the whole new text in memory, checks it once (step 8 of section 12.2) and writes it with a
single safe write (section 12.6); if the write fails, or the command is interrupted before, the file is
as it was: a file with only some of the lines approved never exists.
Example: on a staircase light with a HYPOTHESIS header and four base lines without STATUS, --all D-201
changes only line 4; the four lines inherit. If the same CSC also has six details with STATUS HYPOTHESIS
(for example added by refine, which always writes STATUS HYPOTHESIS), --all also changes those (case r1):
after the command the header and the six details have STATUS RATIFIED BY, the four base lines have no
STATUS and inherit. For check all ten are approved.
12.4 Output on success
Code 0, nothing on standard error. On standard output, with the line numbers of the file after the modification.
Examples on a staircase light (D-200, D-201 and D-202 are example references):
$ bcdd ratify LuceScale.csc D-200
approved CSC LuceScale (line 3) with D-200
contract: 4
lines still pending approval: 0
contract counts the GUARANTEEs and ASSUMEs of the CSC that are approved after the modification. Then lines still pending approval: K follows, with K the number of lines still pending approval, and if K is not 0 those lines, one per line ( line N: GUARANTEE id), in file order. With lines that remain pending approval:
$ bcdd ratify R03_righe.csc D-130
approved CSC Righe (line 3) with D-130
contract: 2
lines still pending approval: 2
line 8: GUARANTEE g1a
line 11: ASSUME a1
$ bcdd ratify LuceScale.csc g2 D-200
approved line 12: GUARANTEE g2 with D-200
$ bcdd ratify LuceScale.csc --all D-201
approved with D-201 in CSC LuceScale: 1 line
line 4: CSC LuceScale
contract: 4
In an entity, with ID: approved line N: GUARANTEE ID with D-nnn. With --all:
$ bcdd ratify Scale.csc --all D-200
approved with D-200 in ENTITY Scale: 2 lines
line 5: GUARANTEE g1
line 7: GUARANTEE g1a
contract: 3
contract counts the guarantees of the entity, all approved after the command; no header line.
BINDING and profiles. For a BINDING the outputs are those of a CSC, with BINDING Nome VERSION v (and AS b)
in place of CSC NAME: approved BINDING Luce VERSION 0.1 (line 3) with D-200, then contract: K with K the
BIND lines approved after the command, and lines still pending approval: K with the lines line N: BIND element. For a
profile: approved PROFILE Segnale VERSION 0.3 (line 2) with D-200, then extensions: K, with K the extensions
of the profile, all approved with it. The other lines of the file remain identical byte for byte.
With --all in a BINDING the form is that of --all in a CSC (below), with in BINDING Nome VERSION v[ AS b] in place of in CSC NAME: the first line counts the lines changed, then line N: BINDING Nome VERSION v[ AS b]
for the header (N is the line of STATUS) and line N: BIND element for every BIND line with its own STATUS
approved by the command, finally contract: K with K the BIND lines of the block. For example:
$ bcdd ratify Luce.csc --csc filo --all D-200
approved with D-200 in BINDING Luce VERSION 0.1 AS filo: 2 lines
line 10: BINDING Luce VERSION 0.1 AS filo
line 12: BIND accesa
contract: 2
With --all in a CSC: the first line counts the lines changed or added (1 line in the singular, otherwise N lines); then one line for each, in file order, line N: CSC NAME for the header (N is the line of
STATUS, also when it has been added) and line N: KEYWORD ID for a contractual line (N is its first line);
then contract: K, with K the GUARANTEEs and ASSUMEs of the CSC approved after the command. Usually no line
remains pending approval and the line lines still pending approval is not printed. The only lines that remain pending approval are those that use
an extension of a profile pending approval (section 7.1, point 0a), which --all cannot approve: then, after
contract, lines still pending approval: K and those lines are printed, as without --all. For example:
$ bcdd ratify R03_righe.csc --all D-130
approved with D-130 in CSC Righe: 3 lines
line 4: CSC Righe
line 8: GUARANTEE g1a
line 11: ASSUME a1
contract: 4
$ bcdd ratify Luce.csc --csc Luce --all D-202
approved with D-202 in CSC Luce: 1 line
line 4: CSC Luce
contract: 3
lines still pending approval: 1
line 15: GUARANTEE g10
12.5 Errors and codes
Every message goes to standard error and ends with LF; standard output remains empty; the file does not
change. ARG, ID, NAME, FILE are the arguments as they were written.
| Case | Message | Code |
|---|---|---|
positional arguments neither 2 nor 3; --csc without a name or repeated; --all repeated, or with 3 positional arguments; --dir without argument, or with the same folder twice; another option that begins with -, including --dir=X |
usage: bcdd ratify FILE [--csc NAME] [--dir FOLDER]... [ID | --all] D-number |
2 |
a --dir folder that does not exist, is not a folder, cannot be read |
as in check (section 10), with the prefix bcdd ratify: |
2 |
| the last positional argument is not a decision | bcdd ratify: invalid decision: ARG (D-number is needed) |
2 |
| the ID is not a word of rule L8 | bcdd ratify: invalid id: ARG |
2 |
the name after --csc is not a Name |
bcdd ratify: invalid name: ARG |
2 |
| file not found, not a file, not readable, not UTF-8 | as in check, with the prefix bcdd ratify: |
2 |
the file does not pass bcdd check --strict |
bcdd ratify: the file does not pass bcdd check --strict (errors: E, unrecognised lines: U): I am not approving |
1 |
no block to approve (only VERIFICATION) |
bcdd ratify: the file contains no block to approve: a VERIFICATION is not approved |
1 |
no CSC or entity and several blocks among BINDING and PROFILE, no --csc |
bcdd ratify: the file contains N blocks to approve: say which with --csc NAME |
2 |
a BINDING or a profile with ID |
bcdd ratify: in a BINDING the header or --all is approved, not a line (or bcdd ratify: in a PROFILE the whole profile is approved, not a line) |
1 |
the BINDING or the profile is already approved |
bcdd ratify: the BINDING NAME VERSION v is already approved (D-mmm): I am changing nothing (or the PROFILE NAME VERSION v) |
1 |
no CSC and several entities, no --csc |
bcdd ratify: the file contains N ENTITYs: say which with --csc NAME |
2 |
several CSCs and no --csc (N counts only the CSCs) |
bcdd ratify: the file contains N CSCs: say which with --csc NAME |
2 |
--csc NAME and no block to approve with that name |
bcdd ratify: no block to approve with the name NAME in the file |
1 |
entity, without ID or --all |
bcdd ratify: the header of the ENTITY NAME is not approved: say a GUARANTEE or --all |
1 |
entity, ID that is not a name of the entity |
bcdd ratify: no GUARANTEE with id ID in the ENTITY NAME |
1 |
entity, ID the name of a part or of a scenario |
bcdd ratify: ID is not a GUARANTEE: in an ENTITY only guarantees are approved |
1 |
entity, --all and no guarantee pending approval |
bcdd ratify: ENTITY NAME has no guarantees still pending approval: I am changing nothing |
1 |
| entity, a boundary not found (step 7) | bcdd ratify: ENTITY NAME, line N: CITATION not found: I am not approving its guarantees; with a reason from the search (section 9.4): … not found (REASON): … |
1 |
| entity, a boundary of another version | bcdd ratify: ENTITY NAME, line N: CITATION found in PATH at line M with VERSION v: I am not approving its guarantees |
1 |
| entity, a boundary in a file with errors | bcdd ratify: ENTITY NAME, line N: CITATION found in PATH at line M, which has E errors: I am not approving its guarantees (1 error for one error) |
1 |
| the CSC is already approved (case c3) | bcdd ratify: the CSC NAME is already approved (D-mmm): I am changing nothing |
1 |
with --all: the header and all lines are already approved |
bcdd ratify: CSC NAME is already entirely part of the contract: I am changing nothing |
1 |
ID is not a name of the CSC |
bcdd ratify: no GUARANTEE or ASSUME with id ID in the CSC NAME |
1 |
ID is a name of the CSC but not of a contractual line nor of a detail of a DEFINE or of a scenario |
bcdd ratify: ID is neither a GUARANTEE nor an ASSUME: only contractual lines and details are approved |
1 |
the line is already approved (case r3; in an entity, a guarantee with its own STATUS RATIFIED BY) |
bcdd ratify: ID is already part of the contract (line N): I am changing nothing |
1 |
| check of the new text failed | bcdd ratify: internal error: the modified text does not pass check; file not touched |
1 |
| errors of the safe write | section 12.6 | 1 |
In the boundary messages CITATION is the line as it is (OFFERS X, USES X VERSION w); PATH as in the
lines of the citations (section 9.4), and in the same file in this file at line M.
Code 2 means “the command could not be executed as it is written”; code 1 “the command
is clear, but the file does not allow it”. It is the same division as in bcdd new.
12.6 The safe write
bcdd ratify writes the file in such a way that it never remains half-written, and that nothing changes beyond what the command
declares:
- the new content is written to a temporary file in the same folder as the file, with a name that begins
with
.and ends with.tmpfollowed by a number; it is then forced to disk; - the temporary file takes the same permissions as the original file;
- immediately before replacing,
bcddrereads the original file: if its bytes are no longer those read at the start of the command, it does not replace it (for example because the person has saved the file from their editor in the meantime); - the temporary file takes the place of the original file with a single system operation, which either succeeds or leaves the file as it was;
- in every error case the temporary file is deleted: nothing remains in the folder.
From the moment it creates the temporary file until the replacement, the command defers Ctrl-C: it finishes the write and then
exits normally. If FILE is a symbolic link, the file it points to is written and the link remains;
if the file has several names (hard links), the command refuses, because replacing it would detach the other
names, which would remain with the old content.
The messages, on standard error, with code 1; the file remains as it was. FILE is the name of the file as it was
written, CAUSE the description of the error given by the system, as in bcdd new:
| Case | Message |
|---|---|
| the temporary file cannot be created or written (folder not writable, disk full) | bcdd ratify: I cannot write FILE: CAUSE |
| the file changed after reading (point 3) | bcdd ratify: FILE changed during the command: nothing written |
| the file has several hard links | bcdd ratify: FILE has more than one hard link: I am not rewriting it |

