semprog.com / SPEC v1.0.1
● NORMATIVE STANDARD VERSION 1.0.1

Semantic Programming Specification

The formal operational standard for intent-driven software orchestration, deterministic structural comment headers, and machine-auditable codebases.

01. Core Principles

Semantic Programming (SemProg) isolates human architectural intent from machine execution layers. By enforcing strict structural commentary boundaries and banning inline noise, any file can be deterministically parsed into either pure plain-text governance documentation or dense executable logic.

PRINCIPLE I
Intent Isolation

Architectural purpose lives exclusively inside standardized multi-tier comment headers.

PRINCIPLE II
Maximum Code Density

Executable code blocks contain zero inline comments, preserving uninterrupted logic flow.

PRINCIPLE III
Zero-Downtime Audit

Compliance state reconciles in memory via .side manifests without runtime overhead.

02. 3-Tier Structural Comment Typology

All SemProg-compliant source files must organize commentary into three strictly scoped hierarchical tiers.

Tier 1: The File Header (@file)

Opening: /**
  • Every source file must begin with a Tier 1 File Header. Where a file format requires a proprietary opening line (such as <?php or a shebang), that line occupies line 1, followed by one blank line and then the Tier 1 header.
  • Exclusively opens with the /** docblock token (never used in Tiers 2 or 3) and closes with */ aligned to the left margin (column 0).
  • Documents file identity (@file), repository path (@location), upstream solution (@solution), global intent (@intent), and Semantic Programming File Header exclusive provenance tags (@created-by, @created-on).

Tier 2: The Function Header (@function)

Opening: /*
  • Precedes every discrete function, method, or procedure declaration, separated from the preceding block by one blank line for sidelint boundary detection.
  • Must utilize standard multiline /* block markers (never /**).
  • Defines tactical identity (@function), purpose (@intent), inputs (@parameters), outputs (@returns), and deterministic logic steps (@workflow).
  • The opening /* and closing */ tokens must align explicitly with the left margin (column 0).

Tier 3: The Section Header (@section)

Opening: /*
  • Isolates complex, conditional, or high-risk logical branches inside a function body.
  • Must be preceded by one blank line so sidelint can detect the section header entry boundary (the only permitted blank line inside a function body).
  • Must utilize standard multiline /* block markers with a @section tag (never /**).
  • The opening /* and closing */ tokens must align with the active indentation margin of the code block.

03. Universal Layout & Wrapping Constraints

The 80-Character Boundary

All textual layout elements within comment matrices must wrap strictly at an 80-character ceiling. This prevents erratic line-wrap anomalies and horizontal drift in terminal auditors such as sidevi.

Zero Inline Comments (Code Density)

Executable code blocks must maintain maximum code density. Scattered comment fragments, trailing notes, and inline double-slash (//) markers are strictly forbidden inside logic layers.

Zero Blank Lines (Vertical Density)

Executable code blocks must contain zero blank lines between statements. The sole permitted blank line inside a function body is the single line preceding a Tier 3 @section header for sidelint boundary detection.

GAI Synthesis & Single-Exit Flow

Humans author and audit structural headers while GAI synthesizes executable logic directly from @workflow steps using single-entry, single-exit state flags and a single return statement.

04. Canonical Code Example

The following reference implementation demonstrates valid Tier 1 (@file), Tier 2 (@function), and Tier 3 (@section) comment blocks paired with zero-inline-comment, zero-blank-line executable code synthesized for GAI entrainment.

ct_validate_purchase_order_format.php 100% COMPLIANT
<?php

/**
 *  @file
 *    - ct_validate_purchase_order_format.php
 *
 *  @location
 *    - /chrontopia/receiving
 *
 *  @solution
 *    - Chrontopia
 *
 *  @intent
 *    - Validates that the supplied purchase order has a valid format.
 *
 *  @created-by
 *    - Graham Leach (graham.r.leach@gmail.com)
 *
 *  @created-on
 *    - 2026-11-14
*/

/*
 *  @function
 *    - ct_validate_purchase_order_format()
 *
 *  @intent
 *    - Checks the format of a supplied Purchase Order number.
 *
 *  @notes
 *    - Chrontopia Purchase Orders are:
 *      - 15 characters in length
 *      - Prefixed with "CT"
 *      - Use YYYYMMDD as a basis
 *      - Serialized thereafter with leading zeros ("001", "002")
 *      - Feature a dash ("-") between the major blocks for readability
 *    Example:
 *      - CT-20261114-001
 *
 *  @parameters
 *    - $purchase_order_number
 *      - Type: String
 *      - Size: 15 characters
 *
 *  @returns
 *    - $purchase_order_number_valid
 *      - TRUE if supplied PO number passes ALL checks
 *      - FALSE if supplied PO number fails ANY ONE check
 *
 *  @workflow
 *    - Set FALSE precondition (assume the PO is NOT in the system)
 *    - Check that the total length is 15 characters
 *    - Check that character 1 is "C"
 *    - Check that character 2 is "T"
 *    - Check that character 3 is "-"
 *    - Check that characters 4 to 11 are all numbers
 *    - Check that characters 4 to 7 are 2026 or later
 *      - Chrontopia was founded 2026
 *    - Check that characters 8 and 9 are months (01-12)
 *    - Check that characters 10 and 11 are days (01-31)
 *      - Remember to check for leap year February 29
 *      - Remember to reconcile month days vs month (irregular)
 *    - Check that character 12 is "-"
 *    - Check that character 13, 14, 15 ranged 001-999
*/
function ct_validate_purchase_order_format($purchase_order_number) {
    $purchase_order_number_valid = FALSE;
    if (is_string($purchase_order_number) && strlen($purchase_order_number) === 15) {

        /*
         *  @section
         *    - Purchase Order Structural Checks
         *
         *  @intent
         *    - Enforce Chrontopia Purchase Order Format Standard
        */
        $first_character  = $purchase_order_number[0];
        $second_character = $purchase_order_number[1];
        $first_separator  = $purchase_order_number[2];
        $second_separator = $purchase_order_number[11];
        $date_block       = substr($purchase_order_number, 3, 8);
        $serial_block     = substr($purchase_order_number, 12, 3);
        if (
            $first_character === 'C' &&
            $second_character === 'T' &&
            $first_separator === '-' &&
            $second_separator === '-' &&
            ctype_digit($date_block) &&
            ctype_digit($serial_block)
        ) {

            /*
             *  @section
             *    - Custom Purchase Order Validation Checks
             *
             *  @intent
             *    - Enforce Chrontopia Purchase Order Format Special Rules
             *
             *  @notes
             *    - Trap:  Founding Year
             *      - Years prior to 2026 are invalid because Chrontopia did
             *        not exist prior to 2026.
             *    - Trap:  Calendar & Leap Year
             *      - checkdate() handles irregular month lengths (30 vs 31)
             *         and leap year Feb 29 automatically.
             *    - Trap:  Zero-Serial
             *      - Although a 3 digit serial number technically allows a 
             *        "000" Purchase Order, the Chrontopia Purchase Order
             *        Standard does not allow it.
             *      - Any "000"-suffixed Purchase Order must be rejected.
            */
            $year          = (int) substr($date_block, 0, 4);
            $month         = (int) substr($date_block, 4, 2);
            $day           = (int) substr($date_block, 6, 2);
            $serial_number = (int) $serial_block;
            $is_valid_founding_year = $year >= 2026;
            $is_valid_calendar_date = checkdate($month, $day, $year);
            $is_valid_serial_range  = $serial_number >= 1 && $serial_number <= 999;
            if ($is_valid_founding_year && $is_valid_calendar_date && $is_valid_serial_range) {
                $purchase_order_number_valid = TRUE;
            }
        }
    }
    return $purchase_order_number_valid;
}

05. .side Manifest Schema

The .side manifest acts as the serialized single source of truth maintained by the sidegig orchestrator. All state reconciliation runs in memory before committing deltas to disk.

Field Type Description
location string Deterministic relative filesystem path from project root.
type enum Asset classification (file, directory, symlink).
exempted boolean Multi-tier audit exemption flag with owner identity & timestamp.
compliance boolean Pass/fail posture against 3-tier header and 80-column rules.
health float Aggregate semantic compliance percentage (0.00 – 100.00).

06. Verification & Auditing Tooling

$ sidegig status

Scans active directories against the .side manifest to evaluate compliance without altering production files.

$ sidevi -H <file>

Isolates Semantic Headers Mode to present clean governance documentation for executive audits.