Propose COBOL COMMAREA write length guards

Proprietary

Guard a direct character MOVE into an incoming COMMAREA under an explicit policy that only received bytes are writable. Require exact caller and ordinary COPY snapshots, a complete admitted entry interval and an approved existing terminal exit. Derive the required count from the destination offset and its full width, including MOVE padding. Require an admitted short entry to reach the original write. Preserve that conditional finding when an unresolved exit or layout prevents an edit. Propose a guard only when every arrival has an unchanged actual count and at least one accepted arrival remains. Insert a typed IF sentence before an ordinary single-MOVE sentence on its own fixed-format line. Preserve every original byte outside the guard. Reprove the changed program at the same MOVE. Require exactly the original accepted arrivals and no short or unknown arrivals. Keep native counts above 9999, aliases, unknown effects, alternate entries, NEXT SENTENCE, unsupported layouts and incomplete source unresolved. The contract establishes the intended writable extent and exit suitability. The proof does not establish allocation size, caller execution or a runtime crash. Application-team review remains required. Do not truncate writes or add retries, commits, rollbacks, ABEND or new error routines. Preserve known received counts after a supported incoming-area MOVE or plain character DISPLAY only when they cover its complete read extent. Keep paths with an earlier short read unknown. They cannot authorize a later guard insertion. Successful output remains unproven.

io.moderne.mainframe.security.ProposeCommareaWriteLengthGuard

Required

Exact repository-relative source path covered by the approved contract.

Exact program ID. Retain quotes for a literal ID. Literal contents match case exactly.

Lowercase SHA-256 of the complete UTF-8 source text without a byte order mark. The approved entry and exit contract must cover this exact snapshot.

JSON object mapping every ordinary data COPY name to its approved lowercase SHA-256.

Explicit approval of RECEIVED_BYTES_ONLY at this site. Bytes beyond the actual received count must not be written, even when more storage might be allocated.

One-based MOVE line selected by the approved source contract.

Exact outermost-first dotted declaration name of the incoming LINKAGE area.

Exact outermost-first dotted declaration name of the actual received byte count at normal entry. Its storage must be separate from the area.

Smallest admitted incoming byte count. Every integer through the maximum must be admitted by the approved contract.

Largest admitted byte count. Must be at most 32767 and no larger than the declared incoming record. The complete interval must fit the existing numeric proof.

Existing paragraph approved for insufficient received lengths at this exact site. An optional IN or OF section qualifier is supported. The contract must establish that this path preserves required cleanup, messages and transaction behavior.

Provenance of the approved entry and exit contract. The recipe records this input and does not fetch or infer the contract.

mod run . --recipe=io.moderne.mainframe.security.ProposeCommareaWriteLengthGuard \ -P sourcePath=security/cbl/VSWGPAD.cbl \ -P programName=VSWGPAD \ -P sourceSha256=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef \ -P copybookSnapshots='{}' \ -P writableExtentPolicy=RECEIVED_BYTES_ONLY \ -P writeLine=15 \ -P commarea=DFHCOMMAREA \ -P receivedLength=DFHEIBLK.EIBCALEN \ -P minimumLength=0 \ -P maximumLength=16 \ -P approvedExit='LENGTH-ERROR IN ERROR-HANDLERS' \ -P contractSource='mainframe-fixtures/README.md fictional incoming-area contract'

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.