From b3f8e832a723f391b971548b203413f1df43a048 Mon Sep 17 00:00:00 2001 From: Nick Shirokov Date: Sun, 19 Jul 2026 18:52:06 +0300 Subject: [PATCH] =?UTF-8?q?fix(db-create):=20=D0=BF=D0=BE=D0=B4=D1=82?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D0=B6=D0=B4=D0=B0=D1=82=D1=8C=20=D1=81=D0=BE?= =?UTF-8?q?=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=201Cv8.1CD=20=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D0=B5=D0=B4=20=D1=80=D0=B0=D0=BF=D0=BE=D1=80=D1=82=D0=BE?= =?UTF-8?q?=D0=BC=20=D0=BE=D0=B1=20=D1=83=D1=81=D0=BF=D0=B5=D1=85=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Код возврата launcher-а сам по себе не доказывает, что файловая ИБ создана: в неблагоприятной среде платформа может вернуть 0, не создав ничего. Добавлен postcondition — для файловой ИБ проверяется наличие ненулевого 1Cv8.1CD (обе ветки: 1cv8 и ibcmd); при его отсутствии — честная ошибка и ненулевой код. Серверная ИБ не проверяется (нет файла для stat). Co-Authored-By: Claude Opus 4.8 --- .../skills/db-create/scripts/db-create.ps1 | 20 +++++++++- .claude/skills/db-create/scripts/db-create.py | 39 ++++++++++++++++--- 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/.claude/skills/db-create/scripts/db-create.ps1 b/.claude/skills/db-create/scripts/db-create.ps1 index f46fff5e..070883ab 100644 --- a/.claude/skills/db-create/scripts/db-create.ps1 +++ b/.claude/skills/db-create/scripts/db-create.ps1 @@ -1,4 +1,4 @@ -# db-create v1.6 — Create 1C information base +# db-create v1.7 — Create 1C information base # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # NB: *nix-раскладку платформы (/opt/1cv8//1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется. <# @@ -138,6 +138,14 @@ function Invoke-IbcmdProcess { } +function Test-FileIbCreated { + # File-infobase postcondition: the platform must have produced a non-empty 1Cv8.1CD. + # Exit code 0 without it (broken/headless env) is a false success — reject it. + param([string]$IbPath) + $f = Join-Path $IbPath "1Cv8.1CD" + return (Test-Path $f) -and ((Get-Item $f -ErrorAction SilentlyContinue).Length -gt 0) +} + $engine = if ((Split-Path $V8Path -Leaf) -match '^ibcmd') { "ibcmd" } else { "1cv8" } # --- Validate connection --- @@ -177,8 +185,12 @@ try { $__ib = Invoke-IbcmdProcess $V8Path $arguments $output = $__ib.Output $exitCode = $__ib.ExitCode + $ibMissing = ($exitCode -eq 0) -and -not (Test-FileIbCreated $InfoBasePath) + if ($ibMissing) { $exitCode = 1 } if ($exitCode -eq 0) { Write-Host "Information base created successfully: $InfoBasePath" -ForegroundColor Green + } elseif ($ibMissing) { + Write-Host "Error: exit code 0 but 1Cv8.1CD is missing or empty at $InfoBasePath — information base was not created" -ForegroundColor Red } else { Write-Host "Error creating information base (code: $exitCode)" -ForegroundColor Red } @@ -221,12 +233,18 @@ try { $exitCode = $process.ExitCode # --- Result --- + # Postcondition (file infobase only): exit 0 without a non-empty 1Cv8.1CD is a false success. + $ibMissing = ($exitCode -eq 0) -and -not ($InfoBaseServer -and $InfoBaseRef) -and -not (Test-FileIbCreated $InfoBasePath) + if ($ibMissing) { $exitCode = 1 } + if ($exitCode -eq 0) { if ($InfoBaseServer -and $InfoBaseRef) { Write-Host "Information base created successfully: $InfoBaseServer/$InfoBaseRef" -ForegroundColor Green } else { Write-Host "Information base created successfully: $InfoBasePath" -ForegroundColor Green } + } elseif ($ibMissing) { + Write-Host "Error: exit code 0 but 1Cv8.1CD is missing or empty at $InfoBasePath — information base was not created" -ForegroundColor Red } else { Write-Host "Error creating information base (code: $exitCode)" -ForegroundColor Red } diff --git a/.claude/skills/db-create/scripts/db-create.py b/.claude/skills/db-create/scripts/db-create.py index eb60ea8d..bbd7c0ff 100644 --- a/.claude/skills/db-create/scripts/db-create.py +++ b/.claude/skills/db-create/scripts/db-create.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# db-create v1.6 — Create 1C information base +# db-create v1.7 — Create 1C information base # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills import argparse @@ -78,6 +78,13 @@ def resolve_v8path(v8path): return v8path +def file_ib_created(ib_path): + """File-infobase postcondition: the platform must have produced a non-empty 1Cv8.1CD. + Exit code 0 without it (broken/headless env) is a false success — reject it.""" + f = os.path.join(ib_path, "1Cv8.1CD") + return os.path.isfile(f) and os.path.getsize(f) > 0 + + IBCMD_NOUSER_HINT = ( "[ibcmd] No -UserName/-Password given; the infobase may require authentication. " "On Windows ibcmd reads credentials from the console (stdin is ignored), so this " @@ -145,15 +152,25 @@ def main(): arguments.append(f"--data={ib_data}") print(f"Running: ibcmd {' '.join(arguments)}") result = run_ibcmd([v8path] + arguments, warn_no_user=False) - if result.returncode == 0: + exit_code = result.returncode + ib_missing = exit_code == 0 and not file_ib_created(args.InfoBasePath) + if ib_missing: + exit_code = 1 + if exit_code == 0: print(f"Information base created successfully: {args.InfoBasePath}") + elif ib_missing: + print( + f"Error: exit code 0 but 1Cv8.1CD is missing or empty at {args.InfoBasePath} " + "— information base was not created", + file=sys.stderr, + ) else: - print(f"Error creating information base (code: {result.returncode})", file=sys.stderr) + print(f"Error creating information base (code: {exit_code})", file=sys.stderr) if result.stdout: print(result.stdout) if result.stderr: print(result.stderr, file=sys.stderr) - sys.exit(result.returncode) + sys.exit(exit_code) # --- Temp dir --- temp_dir = os.path.join(tempfile.gettempdir(), f"db_create_{random.randint(0, 999999)}") @@ -196,11 +213,23 @@ def main(): exit_code = result.returncode # --- Result --- + # Postcondition (file infobase only): exit 0 without a non-empty 1Cv8.1CD is a false success. + is_server = bool(args.InfoBaseServer and args.InfoBaseRef) + ib_missing = exit_code == 0 and not is_server and not file_ib_created(args.InfoBasePath) + if ib_missing: + exit_code = 1 + if exit_code == 0: - if args.InfoBaseServer and args.InfoBaseRef: + if is_server: print(f"Information base created successfully: {args.InfoBaseServer}/{args.InfoBaseRef}") else: print(f"Information base created successfully: {args.InfoBasePath}") + elif ib_missing: + print( + f"Error: exit code 0 but 1Cv8.1CD is missing or empty at {args.InfoBasePath} " + "— information base was not created", + file=sys.stderr, + ) else: print(f"Error creating information base (code: {exit_code})", file=sys.stderr)