Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .agents/skills/formpdf-harness/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: "Does PDF work with formpdf through its MCP server. Use whenever th
license: Apache-2.0
metadata:
author: formpdf
version: "0.62.0"
version: "0.63.0"
---

# formpdf harness
Expand Down
2 changes: 1 addition & 1 deletion .agents/skills/formpdf-skillset/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: "Guides development of the formpdf codebase: its FastAPI engine, va
license: Apache-2.0
metadata:
author: formpdf
version: "0.62.0"
version: "0.63.0"
---

# formpdf skillset
Expand Down
2 changes: 1 addition & 1 deletion .claude/skills/formpdf-harness/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: "Does PDF work with formpdf through its MCP server. Use whenever th
license: Apache-2.0
metadata:
author: formpdf
version: "0.62.0"
version: "0.63.0"
---

# formpdf harness
Expand Down
2 changes: 1 addition & 1 deletion .claude/skills/formpdf-skillset/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: "Guides development of the formpdf codebase: its FastAPI engine, va
license: Apache-2.0
metadata:
author: formpdf
version: "0.62.0"
version: "0.63.0"
---

# formpdf skillset
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</p>

<p align="center">
<img alt="version 0.62.0" src="https://img.shields.io/badge/version-0.62.0-eef0f4?style=flat-square">
<img alt="version 0.63.0" src="https://img.shields.io/badge/version-0.63.0-eef0f4?style=flat-square">
<img alt="Python" src="https://img.shields.io/badge/python-3.12%2B-3776ab?style=flat-square&logo=python&logoColor=white">
<img alt="TypeScript" src="https://img.shields.io/badge/typescript-vite-3178c6?style=flat-square">
<img alt="macOS, Windows, Linux" src="https://img.shields.io/badge/macOS%20%C2%B7%20Windows%20%C2%B7%20Linux-native-2f7bf5?style=flat-square">
Expand Down
30 changes: 30 additions & 0 deletions backend/HASHOUT_LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -841,3 +841,33 @@ Where the tab's tools entry goes. Antigravity reads its MCP servers from a file,
`DOCK.tabs` lists `antigravity`, and `agents/manifest.json` was written again by `agents sync`.

Run with a stand-in `agy` only: status reported it (`finding: runs`, version, `signedIn: null`); a tab opened through the real route and its stream showed the stand-in's banner with the token set; the folder file gained `formpdf_tab` beside an entry and a key that were there, mode 0600, and after close held exactly what it held before; the token then counted for nothing; without the stand-in the route answered 404 with the finder's sentence. The install target was run in two scratch homes (a file with another entry; only the older file). Not run: a real `agy`, Windows, macOS. Nobody here has seen a real Antigravity install or whether it accepts this entry.

## 130. Each Antigravity tab has a folder of its own · _v0.63.0, logged 2026-11-19 (services/agent_programs.py antigravity_folder, antigravity_folder_gone, open_tab; tests/test_dock_contract.py)

kind: fix · logged: v0.63.0 · 2026-11-19

Entry 129 put every Antigravity tab's `formpdf_tab` entry into the one agent folder. A second Antigravity tab (the dock's "new tab" asks with `fresh`) then wrote over the first tab's entry, so the first tab's program read the second tab's token, and closing either left the other without an entry it could trust. Each Antigravity tab now starts in `agent-tabs/antigravity/<12 hex>` under the data folder, made mode 0700 for that tab, and its entry is written there. Codex and Cursor tabs still start in the agent folder; nothing is written into the agent folder for Antigravity any more.

At close the entry is taken out as before (only while it carries that tab's token), then the file is removed when it holds nothing but the empty server list, and `.agents` and the tab's folder are removed when they are empty. A folder the program wrote something into is kept with what it wrote. A folder that cannot be made is refused with a sentence (400) before any token is issued.

Left as it was: a tab's folder is not swept at the next start when the engine was ended with the tab open; the token in such a file counts for nothing after the engine stops, because tokens live in memory only. The agent folder setting (Preferences, Agents) no longer decides where Antigravity starts.

Run with a stand-in `agy` through the real routes: two tabs open at once had different folders, each with its own `formpdf_tab` and token (file 0600, folder 0700), and the stand-in's own log showed each started in its folder with its token; closing the first ended its token and removed its folder while the second's file and token were unchanged; closing the second removed its file and kept the folder that held a file of the person's. Not seen: the refusal for a folder that cannot be made (the checks here run as root, which can always make it). The test that read the entry from the agent folder was replaced by one for two tabs, because that behaviour is gone.

## 131. The engine holds its data folder, leaves when its app is gone, and keeps a log · _v0.63.0, logged 2026-11-19 (core/startup.py new; core/runtime.py new: start_logging, stop_logging, claim, release; formpdf_engine.py watch_shell, run, serve, main; main.py lifespan; tests/test_startup.py)

kind: fix · logged: v0.63.0 · 2026-11-19

The family's Windows start and stop pattern, engine side, as FormTools 0.10.0 has it. A tester's engine in another app died at start on Windows, engines were left behind after a quit, and a failed start said nothing.

`core/startup.py` is FormTools's file at its `origin/main`, copied with `git show` and changed only in the five names at its top (`APP`, `NAMES`, `SHELL_ENV` = `FORMPDF_SHELL_PID`, `ALONE_ENV` = `FORMPDF_NO_SHELL`, `ERRORS_NAME`). `PLACES` is unchanged: formpdf's engine is installed beside the app's own program in all three layouts, which `.` covers.

What the entry does now when it serves, in this order (`--selfcheck` is decided before any of it and is unchanged): makes the data folder and starts the log, and a folder that cannot be made is one sentence on standard error and exit code 5; points an absent standard error at `Logs/formpdf-engine-errors.log`; a frozen engine started with no app (no `FORMPDF_SHELL_PID`, no `FORMPDF_NO_SHELL=1`) opens the app found beside it and returns 0, or says it is a part of FormPDF and returns 4, with no lock and no port; takes `engine.lock` in the data folder by the family's rules, and when another engine holds it says "formpdf is already running on <folder> (engine process N)." in the log and on standard error and returns 2; watches the process named in `FORMPDF_SHELL_PID` and leaves within about two seconds of its end; then the window key line and the server as before. An error that ends the engine is written to the log before it is raised.

New for formpdf, because it had neither: a lock and a log file. Before this, two engines started through the entry could serve one data folder, and the engine's lines went only to its standard output. The log is `Logs/formpdf-engine.log` in the data folder (1 MB, three older files kept). It starts in the entry before the lock is asked for; uvicorn's own log setup then removes the handler from its loggers, so the web app's startup calls `start_logging` again, which finds the handler and puts it back. An engine started as `uvicorn app.main:app` (development, the tests, CI) gets the log the same way and takes no lock. The handler goes on `formpdf`, `uvicorn` and `uvicorn.access` only: `uvicorn.error` hands its lines up to `uvicorn`, and with the handler on both every line was written twice (seen, then fixed).

`runtime.release` removes `engine.lock` and the discovery file `engine.json` when they name this process. It runs when the shell is gone, at SIGTERM (uvicorn shuts down first and raises the signal again, which reaches the entry's handler) and when the server returns.

Kept from before: nothing watched a parent in formpdf, so an engine with no `FORMPDF_SHELL_PID` watches nothing. Not done: when the engine leaves because its shell is gone it does not close its terminal tabs one by one (their programs end with the engine's terminals), so an Antigravity tab's folder from entry 130 stays. A released engine (0.62.0 and older) wrote no lock, so one left running is not seen and not ended by this engine; it does not hold the folder either, and the new engine starts beside it on its own port.

Run on Linux with stand-ins (`sleep` as the shell, a shell script as the app): the three closed-stream starts served, with descriptors 0, 1 and 2 on the null device and the errors file present when standard error was absent; a second engine with another live shell exited 2 with the sentence while the first kept serving, and so did an engine with no shell; the engine exited 0 within one second of its shell's end and the lock and `engine.json` were gone; a stopped holder whose shell had ended was replaced after the five seconds (its exit 137); locks holding `not json at all`, `[1, 2]`, `{"pid": "x"}`, nothing, and an unrelated live process were replaced and that process still ran; an unusable data folder gave the sentence and 5; started alone as "frozen" (`sys.frozen` set) it opened the stand-in app in the Windows, macOS, Linux package and resource-folder layouts with no lock and no port, and with no app near it said the sentence and returned 4. Then `tests/test_startup.py`, FormTools's file with formpdf's names plus three tests for what formpdf's entry adds (the refusal as a whole command, the folder sentence, one log line per event). Not run: Windows, macOS, a really frozen engine. Every Windows branch of `startup.py` has never run anywhere.
2 changes: 1 addition & 1 deletion backend/app/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.62.0"
__version__ = "0.63.0"
69 changes: 69 additions & 0 deletions backend/app/core/runtime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import json
import logging
import os
from logging.handlers import RotatingFileHandler
from pathlib import Path

from app.core import startup

LOG_NAME = "formpdf-engine.log"
LOG_FOLDER = "Logs"
LOCK_NAME = startup.LOCK_NAME
DISCOVERY_NAME = "engine.json"
LOG_BYTES = 1_048_576
LOG_KEEP = 3
HANDLER = "formpdf-file"
LOGGERS = ("formpdf", "uvicorn", "uvicorn.access")
FORMAT = "%(asctime)s %(levelname)s %(name)s %(message)s"


AlreadyRunning = startup.Busy


def start_logging(data: Path) -> Path:
folder = data / LOG_FOLDER
folder.mkdir(parents=True, exist_ok=True)
path = folder / LOG_NAME
for held in logging.getLogger("formpdf").handlers:
if held.get_name() == HANDLER and getattr(held, "baseFilename", "") == os.path.abspath(path):
for name in LOGGERS:
if held not in logging.getLogger(name).handlers:
logging.getLogger(name).addHandler(held)
return path
stop_logging()
handler = RotatingFileHandler(path, maxBytes=LOG_BYTES, backupCount=LOG_KEEP, encoding="utf-8")
handler.setFormatter(logging.Formatter(FORMAT))
handler.set_name(HANDLER)
for name in LOGGERS:
logger = logging.getLogger(name)
logger.addHandler(handler)
if name == "formpdf":
logger.setLevel(logging.INFO)
logging.getLogger("formpdf").info("engine started, pid %s, data folder %s", os.getpid(), data)
return path


def stop_logging() -> None:
for name in LOGGERS:
logger = logging.getLogger(name)
for handler in list(logger.handlers):
if handler.get_name() == HANDLER:
logger.removeHandler(handler)
handler.close()


def claim(data: Path) -> Path:
lock, replaced = startup.claim(data, startup.shell_pid())
if replaced:
logging.getLogger("formpdf").warning("an engine left running without its app was stopped (process %s)", replaced)
return lock


def release(data: Path) -> None:
for name in (LOCK_NAME, DISCOVERY_NAME):
path = data / name
try:
if int(json.loads(path.read_text(encoding="utf-8")).get("pid", 0)) == os.getpid():
path.unlink()
except (OSError, ValueError, TypeError, AttributeError):
pass
Loading
Loading