Compare commits

51 Commits
Author SHA1 Message Date
udo c84fc86e6c W6 2026-06-13 16:19:52 +00:00
udo 5a56d4f39e W5 2026-06-13 15:10:42 +00:00
udo afaa4dd7c0 feat: cut over to WASM backend 2026-06-13 08:42:31 +00:00
udo 577aae076e W3 2026-06-13 02:07:38 +00:00
udo eb8f303f94 docs: remove unsupported second-plane language roadmap 2026-06-12 20:36:57 +00:00
udo 89b5499c8f fix: harden WASM phase 5 harness 2026-06-12 20:13:07 +00:00
udo 961df2d542 phase 5 2026-06-12 19:55:35 +00:00
udo 80285b7fb4 feat: implement WASM phase 1 DValue ABI 2026-06-12 12:42:56 +00:00
udo 7e2faf1472 spike: validate WASM phase 0 2026-06-12 11:40:26 +00:00
udo 7066da3cde refactor: rename DTree to DValue 2026-06-12 11:05:52 +00:00
udo 941f5aea08 feat: add configurable UCE error pages 2026-06-12 08:59:09 +00:00
udo b957a2373b chore: ignore Python cache artifacts 2026-06-11 23:06:03 +00:00
udo 20db669589 fix: stabilize runtime follow-up regressions 2026-06-11 23:03:07 +00:00
udo 7f757654b6 fix: harden UCE runtime and starter 2026-06-11 13:44:24 +00:00
udo 71ddcaf7d4 Consolidate config and base64 helpers 2026-05-21 10:31:21 +00:00
udo 8b37e7ea1e Fix direct HTTP status sanitizer fallback 2026-05-21 10:19:43 +00:00
udo 41e9ca219f Streamline hardening helpers and expand coverage 2026-05-21 10:12:11 +00:00
udo 0d8b74930c Harden HTTP path headers sessions and archives 2026-05-21 09:56:25 +00:00
udo d37517041d Add custom server API and runtime limits 2026-05-21 09:36:23 +00:00
udo 02e153a6a7 Add archive helpers and harden task runtime 2026-05-21 00:00:23 +00:00
udo 9f7625c7fd working on documentation and more API functions 2026-04-29 12:09:37 +00:00
udo cd445f3c9b some cleanup 2026-04-28 12:10:07 +00:00
udo 223cf4c6e1 website with slop placeholders 2026-04-22 13:31:51 +00:00
udo 14ebf10a22 changing doc format and HTML literals 2026-04-22 09:31:00 +00:00
udo f7b066b374 changing doc format and HTML literals 2026-04-22 01:56:46 +00:00
udo 8223dcc6b3 I think I need to change the documentation format 2026-04-22 01:32:05 +00:00
udo b53eb6e4f1 Enhance template parser to handle C++ comments and refactor preprocessing logic
- Updated parser to correctly interpret C++ `//` and `/* ... */` comments within template code.
- Split preprocessing implementation into separate files for better organization.
- Added regression test for comment parsing in templates.
- Adjusted CSS styles for improved layout and readability in documentation.
2026-04-20 21:41:23 +00:00
udo dc05f9faa5 PHP familiarity shortcuts 2026-04-19 21:15:52 +00:00
udo af642c8167 getting closer to full port of web app starter 2026-04-19 19:44:18 +00:00
udo d1167aec3b getting closer to full port of web app starter 2026-04-19 19:09:21 +00:00
udo 2b5586d7df decided in favor of dedicated COMPONENT() macro, updates to documentation 2026-04-19 11:34:03 +00:00
udo be514d63d6 trying to port web app starter from PHP 2026-04-19 09:38:23 +00:00
udo 46d98a092f Enhance WebSocket support: add opcode handling, binary message support, and improve connection validation 2026-04-18 18:41:50 +00:00
udo 86dc93864e Add WebSocket support and enhance chat functionality
- Implement WebSocket handling in the FastCGI server, allowing for real-time communication.
- Introduce functions for managing WebSocket connections, broadcasting messages, and sending to specific connections.
- Create a chat interface in the `websockets.ws.uce` file, including message handling and user notifications.
- Refactor existing code to accommodate WebSocket integration, ensuring compatibility with HTTP requests.
- Update documentation to reflect new features and usage instructions for WebSocket functionality.
2026-04-18 15:10:15 +00:00
udo cd8f07aaa7 Refactor FastCGI server and compiler, enhance HTTP header parsing, and add WebSocket support
- Refactored FastCGIServer class to improve socket handling and added shutdown functionality.
- Updated compiler functions to streamline HTML and text literal processing.
- Enhanced split_kv function to support uppercase keys and added split_http_headers for better HTTP header parsing.
- Introduced new session management functions to validate and handle session IDs.
- Added WebSocket frame parsing and handling in the URI module.
- Created systemd service scripts for easier deployment and management of the UCE FastCGI runtime.
- Added new test cases for header handling, time parsing, and WebSocket functionality.
2026-04-18 14:04:58 +00:00
udo 984453f336 update sigh 2022-12-22 06:01:23 +00:00
udo 392b7224b1 Merge branch 'main' of github.com:ThingamaNet/uce 2022-04-18 23:37:37 +00:00
udo 364d83b199 doc update 2022-04-18 23:37:21 +00:00
Udo Schroeter 21fdeafb6c Basic documentation 2022-02-11 11:44:32 +01:00
Udo Schroeter 9e5b7d39e3 Basic readme 2022-02-11 11:22:04 +01:00
udo defc628204 packaging 2022-02-11 02:35:06 +00:00
udo 6f6919f3f0 backage builder 2022-02-11 01:51:32 +00:00
udo 0a6ebc60f0 precompile on startup 2022-01-31 00:42:16 +00:00
udo 3a9dfba86c fixed bug in #load 2022-01-30 12:45:18 +00:00
udo 5df52146be split_space 2022-01-30 12:19:20 +00:00
udo 17336fe649 Unicode stuff 2022-01-30 12:16:09 +00:00
udo 18ca2368bc VERY basic UTF8 parser 2022-01-28 20:23:14 +00:00
udo 939009f9a1 shell stuff, preprocessor directive 2022-01-21 22:22:14 +00:00
udo 3e8f0f1fa7 initial import 2022-01-21 09:11:17 +00:00
udo c047927b18 initial import 2022-01-21 09:10:38 +00:00
Udo Schroeter ad3d65cdac Initial commit 2022-01-21 09:53:46 +01:00
734 changed files with 375524 additions and 3194 deletions
+21 -35
View File
@@ -1,4 +1,7 @@
# ---> C++
.fuse*
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
@@ -9,8 +12,6 @@
*.gch
*.pch
.fuse*
# Compiled Dynamic libraries
*.so
*.dylib
@@ -18,6 +19,7 @@
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
@@ -29,39 +31,23 @@
*.exe
*.out
*.app
.fuse*
# ---> C
# Object files
*.o
*.ko
*.obj
*.elf
tmp/*
bin/*
pkg/*
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
# Python cache artifacts
__pycache__/
*.py[cod]
*$py.class
.pytest_cache/
.mypy_cache/
.ruff_cache/
.coverage
htmlcov/
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# Debug files
*.dSYM/
work/
# Editor swap artifacts
*.swp
*.swo
+674
View File
@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
+538 -1
View File
@@ -1,3 +1,540 @@
# uce
Udo's C++ Entry Points
## Current State
This is in the early stages of development. Don't use this for anything important (or at all)!
## Overview
UCE is a PHP-inspired server-side runtime that lets you build web pages and handlers in C++ using a small `.uce` preprocessor plus a FastCGI application server.
- `.uce` pages compile to shared objects on demand
- normal HTTP pages expose `RENDER(Request& context)`
- WebSocket pages can additionally expose `WS(Request& context)`
- local CLI/admin/test entrypoints can expose `CLI(Request& context)` and are invoked through the Unix CLI socket
- sub-rendering and components pass structured data through `context.props`
- nginx can forward normal `.uce` requests and ordinary `.ws.uce` page loads to the FastCGI socket, while real WebSocket upgrade requests for `.ws.uce` endpoints go to the built-in HTTP/WebSocket listener
- the nginx-published application tree lives under `site/`
- you can include C++ code as much as you want, but only .uce files called via API functions and entry points will be pre-processed
- the preprocessor has two jobs:
- allow for inline HTML within C++ and the use of templating tags inside of that HTML
- convenience directive and macro parsing so UCE files don't need a lot of boiler plate
The abolition of boilerplate was a major design factor, resulting in a page as small as this:
```uce
RENDER(Request& context)
{
<>hello world</>
}
```
The runtime is still experimental.
## Build
Build the runtime with:
```bash
bash scripts/build_linux.sh
```
The current build expects:
- `clang++`
- `mysql_config`
- PCRE2 development headers and library (`libpcre2-dev` on Debian / Ubuntu)
- standard Linux development headers for `dl`, `pthread`, sockets, and backtrace support
SQLite is vendored under `src/3rdparty/sqlite/` and compiled by `scripts/build_linux.sh`; no system SQLite package is required.
The binary is written to:
```bash
bin/uce_fastcgi.linux.bin
```
## Runtime Model
UCE pages use explicit request handlers instead of implicit globals:
- `RENDER(Request& context)` for normal HTTP rendering
- `WS(Request& context)` for inbound WebSocket messages
- `CLI(Request& context)` for local command-line/admin/test invocations through `CLI_SOCKET_PATH`
Useful related runtime patterns:
- `unit_render(String file_name)` or `unit_render(String file_name, Request& context)` to invoke another page
- `context.cfg` for request-local structured configuration
- `context.props` for invocation-local structured input such as component props
- `context.connection` for broker-owned per-WebSocket-connection state shared across `WS(Request& context)` calls
- `context.params["UCE_CLI"] == "1"` while handling a local CLI socket request
- `context.in` for the current request body, including the current WebSocket message payload inside `WS(Request& context)`
- `context.params["WS_..."]` for direct WebSocket message metadata on the request parameter map
- `context.params`, `context.get`, `context.post`, `context.cookies`, `context.session`, and `context.header` for request/response state
- `context.set_status(code[, reason])` to set the HTTP response status
Useful helpers for that data model include:
- `DValue::get_by_path("a/b/c")` for path-style config traversal without creating missing keys
- `DValue::has("key")` / `key("key")` for non-mutating child lookup, and `get_or_create("key")` when creation is intended
- `DValue::to_u64()`, `to_s64()`, `to_f64()`, `to_bool()`, and `to_stringmap()` for typed reads from structured values
- `json_encode(String)` for emitting JavaScript-safe string literals directly
- `ascii_safe_name(String)` for conservative ASCII identifier normalization
- `path_join(base, child)` for filesystem-style path assembly
- `sqlite_connect()`, `sqlite_query()`, and related helpers for embedded SQLite storage with named prepared parameters
- `zip_create()`, `zip_list()`, `zip_read()`, and `zip_extract()` for minimal ZIP archive workflows
- `gz_compress()` and `gz_uncompress()` for gzip-format byte strings
- `server_start_http()` / `server_stop()` for runtime-managed custom HTTP listeners backed by `SERVE_HTTP` handlers
- `map()`, `filter()`, `list_unique()`, `dv_filter()`, `dv_map()`, `dv_pick()`, and related helpers for route/menu/card data shaping near render code
Named component handlers are also supported:
```cpp
COMPONENT:BODY(Request& context)
{
<>
<p><?= context.props["body"].to_string() ?></p>
</>
}
```
Those are intended for sub-rendering through helpers such as `component("components/card:BODY", props, context)` rather than direct page entry.
Additional lifecycle hooks are also available on ordinary `.uce` units:
- `INIT(Request& context)` runs once when a worker loads that unit's shared object into memory
- `ONCE(Request& context)` runs once per request before the first `RENDER()`, `CLI()`, or `COMPONENT...` entrypoint from that file
CLI units can be invoked locally with the convenience wrapper or directly over HTTP-over-Unix:
```bash
scripts/uce-cli /tests/cli.uce action=echo message=hello
scripts/uce-cli --json '{"action":"echo","message":"hello"}' /tests/cli.uce
curl --unix-socket /run/uce/cli.sock http://localhost/tests/cli.uce
```
For structured CLI commands, prefer JSON POST bodies and read them with `cli_input(context)`.
## Template Output
UCE treats template parsing as one shared code-vs-literal state machine.
- `<>` and `?>` both enter literal output mode
- `</>` and `<?` both return to code mode
- the delimiter pairs are interchangeable, so either style can be used consistently or mixed locally
Inside literal output, UCE supports three inline forms:
- `<? ... ?>` to emit raw C++ statements
- `<?= expression ?>` to print HTML-escaped output
- `<?: expression ?>` to print unescaped output
Use `<?= ... ?>` by default for user-visible text. Use `<?: ... ?>` only for trusted markup or content that has already been escaped.
The parser treats C++ `//` and `/* ... */` comments as comments in both normal code and `<? ... ?>` islands, so quotes or delimiter markers inside comments do not confuse template parsing.
The preprocessing implementation is split between `src/lib/compiler.cpp` and `src/lib/compiler-parser.cpp`. `compiler.cpp` owns unit compilation and cache orchestration, while `compiler-parser.cpp` owns source rewriting and template parsing.
## Components
UCE includes a native component layer built on top of ordinary `.uce` files:
- `component(name[, props[, context]])`
- `component_render(name[, props[, context]])`
- `component_exists(name)`
- `component_resolve(name)`
Component props are passed through `context.props`.
Component names resolve:
1. as the exact file name you supplied
2. as that same name plus `.uce`
3. as those same two forms under `components/`
When you want returned component markup inside a literal block, prefer:
```cpp
<>
<div class="panel"><?: component("components/card", props, context) ?></div>
</>
```
because `<?= ... ?>` HTML-escapes the returned markup. For direct output from C++ code, use `component_render(...)`.
Components expose `COMPONENT(Request& context)` as their default entrypoint and may expose additional named handlers with `COMPONENT:NAME(Request& context)`.
The component helpers call only `COMPONENT...` handlers. A file meant purely for component use can define `COMPONENT()` without defining `RENDER()`, which keeps direct page entry and component entry cleanly separated. Inside a component file, `component(":NAME", props, context)` and `component_render(":NAME", props, context)` target another named component handler in that same file.
If the component file also defines `ONCE(Request& context)`, that hook runs once per request before the file's first component/render entrypoint. If it defines `INIT(Request& context)`, that hook runs once when the worker loads the unit.
## WebSockets
The runtime keeps the socket lifecycle in-process and exposes a low-boilerplate API to page code:
- `ws_message()`
- `ws_connection_id()`
- `ws_scope()`
- `ws_opcode()`
- `ws_is_binary()`
- `ws_connections([scope])`
- `ws_connection_count([scope])`
- `ws_send(message[, binary[, scope]])`
- `ws_send_to(connection_id, message[, binary])`
- `ws_close([connection_id])`
By default, the WebSocket scope is the current page file, so `ws_send()` queues a message for clients connected to that same `.ws.uce` endpoint.
Each live WebSocket connection owns a broker-side `DValue` exposed to page code as `context.connection`. Mutations to that tree persist for the life of the socket and are visible on later `WS(Request& context)` calls for the same client.
The current inbound payload is available directly as `context.in`, and the runtime mirrors message metadata into `context.params` using keys such as `WS_CONNECTION_ID`, `WS_SCOPE`, `WS_CONNECTION_COUNT`, `WS_OPCODE`, `WS_MESSAGE_TYPE`, and `WS_DOCUMENT_URI`.
`ws_message()` may still be used when you want the payload through a helper API. Use `ws_opcode()` / `ws_is_binary()` to inspect the current inbound message type.
Set `binary = true` on `ws_send()` or `ws_send_to()` to queue a binary frame instead of a text frame.
The runtime accepts fragmented messages, validates reserved bits and UTF-8 for text payloads, and delivers both text and binary message frames into `WS(Request& context)`.
## Error Reporting
Unhandled exceptions and recovered fatal request signals return a `500 Internal Server Error` response with a plain-text trace instead of simply dropping the upstream connection and leaving nginx to show a generic `502`.
The demo page `site/test/error-reporting.uce` can be used to exercise:
- uncaught exception handling
- recovered `SIGABRT`
- recovered `SIGSEGV`
The current error page includes:
- request URI
- resolved script path
- generated C++ path when available
- high-level error summary
- source/generated excerpts and raw compiler output paths for template/component/unit failure modes
- signal number and name when applicable
- a native backtrace
Compile failures are also formatted with the source path, generated C++ path, compile-output artifact path, a nearby source/generated excerpt when a line can be identified, and the raw compiler output.
This recovery path currently covers normal request handling. It is not yet the universal recovery path for every runtime subsystem.
## Docs And Tests
The most current user-facing reference lives under `site/doc/`, and the demo pages live under `site/test/`. Developers coming from React, Next, or Remix should start with `site/doc/pages/coming_from_react.txt` / `/doc/index.uce?p=coming_from_react` for the concept map and starter-router notes.
Useful entry points:
- repo files:
- `site/doc/index.uce`
- `site/doc/singlepage.uce`
- `site/test/index.uce`
- published URLs:
- `/doc/index.uce`
- `/doc/singlepage.uce`
- `/test/index.uce`
Representative test pages:
- `site/test/components.uce`
- `site/test/websockets.ws.uce`
- `site/test/error-reporting.uce`
- `site/test/post-multipart.uce`
- `site/test/session.uce`
## Deploy Behind Nginx
The intended production shape is:
- nginx serves static files directly
- nginx forwards `.uce` requests and ordinary `.ws.uce` page loads to the UCE FastCGI Unix socket
- nginx proxies actual WebSocket upgrade requests for `.ws.uce` endpoints to the runtime's built-in HTTP/WebSocket listener
- systemd keeps the runtime built, started, and restarted on failure
The repository ships the pieces used for this:
- `scripts/systemd/uce.service`
- `scripts/systemd/manage-uce-service.sh`
- `etc/uce/settings.cfg`
### 1. Install build and runtime dependencies
On a Debian or Ubuntu host, start with the packages needed to build and run UCE behind nginx:
```bash
apt update
apt install -y nginx clang mariadb-client libmariadb-dev libpcre2-dev build-essential
```
The exact package names may vary by distro. The important requirements are:
- `nginx`
- `clang++`
- `mysql_config`
- PCRE2 development headers and library (`libpcre2-dev` on Debian / Ubuntu)
- normal Linux development headers for threads, sockets, `dl`, and backtrace support
### 2. Put the repo on the server
This README assumes the repository lives at:
```bash
/Code/uce.openfu.com/uce
```
That is what the shipped `scripts/systemd/uce.service` file currently uses as its `WorkingDirectory` and build path. If you deploy somewhere else, update that unit file before enabling the service.
### 3. Configure `/etc/uce/settings.cfg`
The runtime reads its server settings from:
```bash
/etc/uce/settings.cfg
```
The shipped example contains the important filesystem and FastCGI settings:
```ini
BIN_DIRECTORY=/var/cache/uce/work
TMP_UPLOAD_PATH=/var/lib/uce/uploads
SESSION_PATH=/var/lib/uce/sessions
FCGI_SOCKET_PATH=/run/uce/fastcgi.sock
FCGI_PORT=9993
PRECOMPILE_FILES_IN=
SITE_DIRECTORY=site
PROACTIVE_COMPILE_CHECK_INTERVAL=60
WORKER_COUNT=4
MAX_MEMORY=16777216
SESSION_TIME=2592000
```
For nginx deployments, the most important setting is:
- `FCGI_SOCKET_PATH=/run/uce/fastcgi.sock`
That is the Unix socket nginx should use for normal `.uce` requests.
`FCGI_PORT` is optional if nginx is talking to the Unix socket. Leave it set if you also want a TCP FastCGI listener, or remove it if you want the socket to be the only FastCGI entry point.
If you want WebSocket support through nginx, also make sure the built-in HTTP listener is available. The runtime currently defaults `HTTP_PORT` to `8080` even if it is not present in the config file, but it is clearer to set it explicitly:
```ini
HTTP_PORT=8080
```
Proactive compilation settings:
- `SITE_DIRECTORY=site` tells the runtime which tree to scan on startup for `.uce` files when `PRECOMPILE_FILES_IN` is left empty.
- `PRECOMPILE_FILES_IN=` can override that startup scan root with a different absolute or runtime-relative directory.
- `PROACTIVE_COMPILE_CHECK_INTERVAL=60` controls how often the low-priority background compiler rechecks known `.uce` files for stale or missing shared objects.
The runtime keeps a shared known-file registry under `BIN_DIRECTORY` and updates it as request handling discovers new `.uce` files, so proactive recompiles are not limited to the initial startup scan.
Recommended deployment notes:
- keep `HTTP_PORT` bound to localhost only at the firewall or by network policy; nginx should be the public entry point
- keep `BIN_DIRECTORY`, `TMP_UPLOAD_PATH`, and `SESSION_PATH` on writable local storage
- after editing `/etc/uce/settings.cfg`, restart `uce.service`
### 4. Install and enable the systemd service
As root, from the repository root:
```bash
scripts/systemd/manage-uce-service.sh setup
```
That script:
- installs `scripts/systemd/uce.service` as `/etc/systemd/system/uce.service`
- installs `etc/uce/settings.cfg` to `/etc/uce/settings.cfg` if it does not already exist
- reloads systemd
- enables the service at boot
- starts the runtime immediately
Useful follow-up commands:
```bash
scripts/systemd/manage-uce-service.sh status
scripts/systemd/manage-uce-service.sh restart
scripts/systemd/manage-uce-service.sh logs 200
```
The unit currently:
- uses systemd-managed runtime/state/cache roots under:
- `/run/uce`
- `/var/lib/uce`
- `/var/cache/uce`
- prepares:
- `/var/cache/uce/work`
- `/var/lib/uce/uploads`
- `/var/lib/uce/sessions`
- removes any stale `/run/uce/fastcgi.sock`
- rebuilds the runtime before start
- runs the binary from the repo root so `COMPILER_SYS_PATH` resolves correctly
### Debian package build
To build a Debian package from the repository root:
```bash
bash scripts/make_deb.sh 0.1.2
```
That script:
- rebuilds the runtime first
- stages the current runtime tree under `/usr/lib/uce`
- installs `/etc/uce/settings.cfg` as a package conffile
- installs a packaged `uce.service` under `/lib/systemd/system/`
- writes Debian maintainer scripts for systemd reload/enable handling
- follows a more PHP-like/FHS deployment shape with immutable runtime files under `/usr/lib`, config under `/etc`, cache/state under `/var`, and the FastCGI socket under `/run/uce/`
### 5. Configure nginx for `.uce` and `.ws.uce`
You need two nginx paths for `.ws.uce` endpoints:
- FastCGI for ordinary `.uce` requests and plain `.ws.uce` page renders
- HTTP proxying only for actual WebSocket upgrade traffic on `.ws.uce` endpoints
If you use WebSockets, add this `map` in the nginx `http` block:
```nginx
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
```
Then use a server block along these lines:
```nginx
server {
listen 80;
server_name example.com;
root /Code/uce.openfu.com/uce/site;
index index.uce index.html;
location / {
try_files $uri $uri/ =404;
}
location ~ \.uce$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param DOCUMENT_URI $uri;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_pass unix:/run/uce/fastcgi.sock;
}
location ~ \.ws\.uce$ {
error_page 418 = @uce_websocket;
if ($http_upgrade = "websocket") {
return 418;
}
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param DOCUMENT_URI $uri;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_pass unix:/run/uce/fastcgi.sock;
}
location @uce_websocket {
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_pass http://127.0.0.1:8080;
}
}
```
Important details:
- `.ws.uce` must be matched before the more general `.uce` rule
- `fastcgi_pass` should point at the same socket path as `FCGI_SOCKET_PATH`
- `proxy_pass` should point at the runtime's `HTTP_PORT`
- ordinary `GET /page.ws.uce` page renders should stay on FastCGI
- only upgrade requests for `/page.ws.uce` should go through the HTTP/WebSocket listener
- `SCRIPT_FILENAME` should resolve to the actual `.uce` file on disk
- `proxy_http_version 1.1` and the `Upgrade` / `Connection` headers are required for WebSockets
The `location /` block above is intentionally conservative and only serves real files from `site/`. If your app uses a front-controller pattern such as routing everything through `/index.uce`, change that block accordingly.
### 6. Think about document root and private files
Point nginx at `site/`, not the repository root. The repo still contains source, scripts, packaging files, and operational assets that are not meant to be public.
At minimum, explicitly block internal directories that should never be served directly. For example:
```nginx
location ~ ^/(src|scripts|etc|bin|work|dist|pkg)/ {
return 404;
}
```
If nginx is rooted at `site/`, most of those paths will not be reachable anyway, which is the preferred setup.
### 7. Reload nginx and verify the deployment
After writing the nginx config:
```bash
nginx -t
systemctl reload nginx
```
Then verify:
```bash
systemctl status uce.service
curl -i http://127.0.0.1/test/index.uce
curl -i http://127.0.0.1/doc/index.uce
```
If WebSockets are enabled, also verify a `.ws.uce` endpoint through nginx rather than talking to the runtime directly.
### 8. Troubleshooting
Common failure modes:
- `502 Bad Gateway`
Usually means `uce.service` is down, the Unix socket path does not match, or the request crashed before sending a valid response.
- WebSocket upgrade fails
Check that nginx is routing `.ws.uce` to `proxy_pass`, not `fastcgi_pass`, and that `HTTP_PORT` is reachable on localhost.
- Requests compile but immediately crash
Check `journalctl -u uce.service`. Generated units carry an ABI metadata sidecar and should be recompiled automatically after runtime ABI changes, but clearing stale artifacts under `BIN_DIRECTORY` is still a useful last-resort recovery step if the cache has been damaged manually.
- nginx serves raw source or internal files
Tighten the server root and add explicit deny rules for non-public directories.
## Repo Helpers
- `./codesearch <pattern> [rg options...]`
This is a small repo-root wrapper around `rg` that searches from the project root and skips generated/build directories such as `.git/`, `bin/`, `dist/`, and `work/`.
## Reference Notes
For up-to-date usage, prefer:
- the live docs under `site/doc/`
- the declarations in `src/lib/compiler.h`, `src/lib/sys.h`, and `src/lib/functionlib.h`
- the example pages under `site/test/`
## AI Disclosure
This project is largely human-made, with all the typical idiosyncracies of my projects clearly visible. However, OpenAI Codex was used for code review and documentation. Claude Opus was used for UI design work, and I used VS Code's git commit message generator.
+1004
View File
File diff suppressed because it is too large Load Diff
Binary file not shown.
-33
View File
@@ -1,33 +0,0 @@
#!/bin/bash
cd "$(dirname "$0")"
BUILDMODE=${2:-"debug"}
OPT_FLAG="O2"
GF="uce_fastcgi"
if [ "$BUILDMODE" == "debug" ]; then
OPT_FLAG="O0"
fi
echo "Build mode: $BUILDMODE"
mkdir bin > /dev/null 2>&1
mkdir bin/tmp > /dev/null 2>&1
mkdir bin/assets > /dev/null 2>&1
mkdir work > /dev/null 2>&1
COMPILER="clang++"
FLAGS="-g -rdynamic -w -Wall -$OPT_FLAG -std=c++17 -fpermissive -ffast-math"
LIBS="-ldl -lm -lpthread `mysql_config --cflags --libs`"
SRCFLAGS="-D EXEC_NAME=\"$GF\" -D PLATFORM_NAME=\"linux\""
echo "Compliling executable..."
time -p $COMPILER src/linux_fastcgi.cpp $SRCFLAGS $FLAGS $LIBS -o bin/$GF.$BUILDMODE.linux.bin 2>&1
if [ $? -eq 0 ]
then
ls -lh bin/ | grep $GF
exit 0
else
exit 1
fi
Executable
+58
View File
@@ -0,0 +1,58 @@
#!/bin/bash
set -euo pipefail
cd "$(dirname "$0")"
show_help() {
cat <<'EOF'
Usage:
./codesearch <pattern> [rg options...]
Examples:
./codesearch "ws_send"
./codesearch "RENDER\\(Request& context\\)"
./codesearch -tcpp "compiler_invoke"
./codesearch -g '*.uce' "context.call"
Notes:
- This is a thin wrapper around ripgrep (`rg`).
- It searches from the repository root.
- Generated/build directories are excluded by default:
`.git/`, `bin/`, `dist/`, and `work/`.
EOF
}
if [[ $# -eq 0 ]]; then
show_help
exit 1
fi
case "${1:-}" in
-h|--help|help)
show_help
exit 0
;;
esac
if command -v rg >/dev/null 2>&1; then
exec rg \
--line-number \
--column \
--smart-case \
--glob '!.git/**' \
--glob '!bin/**' \
--glob '!dist/**' \
--glob '!work/**' \
"$@"
fi
pattern="$1"
shift || true
echo "ripgrep (rg) is not installed; falling back to grep." >&2
exec grep -RIn \
--exclude-dir=.git \
--exclude-dir=bin \
--exclude-dir=dist \
--exclude-dir=work \
-- "$pattern" .
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
-6
View File
@@ -1,6 +0,0 @@
Output Buffer Functions
ob_clear
ob_get
ob_get_clear
ob_start
-10
View File
@@ -1,10 +0,0 @@
String Functions
filter
first
join
nibble
split
str_to_lower
str_to_upper
trim
-7
View File
@@ -1,7 +0,0 @@
Time and Date Functions
microtime
time
date
gmdate
parse_time
-7
View File
@@ -1,7 +0,0 @@
URI Functions
encode_query
make_session_id
parse_query
uri_decode
uri_encode
-150
View File
@@ -1,150 +0,0 @@
void render_see_section(String name)
{
StringList lines = split(file_get_contents("areas/"+name+".txt"), "\n");
s32 idx = 0;
for(auto line : lines)
{
if(idx == 0)
{
<><h3><?= line ?></h3><ul></>
}
else if(line != "")
{
<><li><a href="index.uce?p=<?= line ?>"><?= line ?><span style="opacity:0.5">()</span></a></li></>
}
idx += 1;
}
<></ul></>
}
RENDER()
{
String page = first(context->get["p"], "index");
<><html>
<head>
<link rel="stylesheet" href='style.css?v=<?= time() ?>'></link>
</head>
<body>
<h1>
<a href="index.uce">UCE Docs</a>:
<?= page ?>
</h1>
<?
if(page == "index")
{
?><div style="display:flex;"><?
?><div style="flex:1"><?
?><h3>All API Functions</h3><?
for(auto file_name : ls("pages/"))
{
String ft = nibble(file_name, ".");
if(ft[1] == '_')
{
String fn = ft;
String pre = nibble(fn, "_");
?>
<div><a href="?p=<?= ft ?>"><?= fn ?></a><span style="opacity:0.5"> : struct</span></div>
<?
}
else
{
?>
<div><a href="?p=<?= ft ?>"><?= ft ?><span style="opacity:0.5">()</span></a></div>
<?
}
}
?></div><?
?><div style="flex:1"><?
for(auto file_name : ls("areas/"))
{
String ft = nibble(file_name, ".");
render_see_section(ft);
}
?></div><?
?></div><?
}
else
{
auto doc = split(file_get_contents("pages/"+page+".txt"), "\n");
String layout_class = "text";
u32 line_idx = 0;
for(auto s : doc)
{
line_idx++;
if(s == "")
{
}
else if(s.substr(0, 1) == ":")
{
layout_class = s.substr(1);
if(line_idx > 1)
{
?></div><?
}
?><div class="<?= layout_class ?>"><?
if(layout_class == "params")
{
?><h3>Parameters</h3><?
}
else if(layout_class == "sig")
{
?><h3>Signature</h3><?
}
else if(layout_class == "pre")
{
layout_class = "sig";
}
else if(layout_class == "desc")
{
?><h3>Description</h3><?
}
else if(layout_class == "see")
{
/*?><h3>Related</h3><?*/
}
else
{
?><h3><?= layout_class ?></h3><?
}
}
else
{
if(s.substr(0, 1) == "-")
{
nibble(s, "-");
?><li><?= (s) ?></li><?
}
else if(layout_class == "params")
{
?><div><b><?= trim(nibble(s, ":")) ?></b> : <?= trim(s) ?></div><?
}
else if(layout_class == "see")
{
if(s[0] == '>')
{
render_see_section(s.substr(1));
}
else
{
?><div><a href="index.uce?p=<?= trim(s) ?>"><?= trim(s) ?><span style="opacity:0.5">()</span></a></div><?
}
}
else
{
?><div><?= (s) ?></div><?
}
}
}
}
?>
</body>
</html></>
}
-63
View File
@@ -1,63 +0,0 @@
:sig
Request* context;
:ServerState* server
Contains the current server state
:StringMap params
All FastCGI server parameters
:StringMap get
The current request's GET variables
:StringMap post
The current request's POST variables
:StringMap cookies
Cookies that have been transmitted by the browser
:StringMap session
The current session
:String session_id
ID of the session cookie
String session_name
Name of the session cookie
:DTree var
Variable user-defined data
:std::vector<UploadedFile> uploaded_files
Files that have been uploaded in the current request
:StringMap header
Headers to be sent back to the browser
:StringList set_cookies;
Cookies that should be sent back to the browser
:u64 random_seed
The current request's "random" noise generator seed
:u64 random_index
The current request's "random" noise generator index position
:MemoryArena* mem
Contains the current request's memory arena
:bool flags.log_request
Whether the request should be logged
:Stats
u32 stats.bytes_written
f64 stats.time_init
f64 stats.time_start
f64 stats.time_end
:invoke(String file_name, [DTree& call_param])
Invokes the UCE file 'file_name'
-12
View File
@@ -1,12 +0,0 @@
:sig
String basename(String fn)
:params
fn : raw filename
return value : the file's name
:desc
Isolates the file name component from a path/file name.
:see
>sys
-125
View File
@@ -1,125 +0,0 @@
:sig
String date(String format = "", u64 timestamp = 0)
:params
format : formatting string specifying the date format
timestamp : optional timestamp value, defaults to current time
return value : a formatted date
:desc
Returns a formatted date. This is based on the Linux date() command. The formatting string supports the following sequences:
:pre
%% a literal %
%a locale's abbreviated weekday name (e.g., Sun)
%A locale's full weekday name (e.g., Sunday)
%b locale's abbreviated month name (e.g., Jan)
%B locale's full month name (e.g., January)
%c locale's date and time (e.g., Thu Mar 3 23:05:25 2005)
%C century; like %Y, except omit last two digits (e.g., 20)
%d day of month (e.g., 01)
%D date; same as %m/%d/%y
%e day of month, space padded; same as %_d
%F full date; like %+4Y-%m-%d
%g last two digits of year of ISO week number (see %G)
%G year of ISO week number (see %V); normally useful only
with %V
%h same as %b
%H hour (00..23)
%I hour (01..12)
%j day of year (001..366)
%k hour, space padded ( 0..23); same as %_H
%l hour, space padded ( 1..12); same as %_I
%m month (01..12)
%M minute (00..59)
%n a newline
%N nanoseconds (000000000..999999999)
%p locale's equivalent of either AM or PM; blank if not known
%P like %p, but lower case
%q quarter of year (1..4)
%r locale's 12-hour clock time (e.g., 11:11:04 PM)
%R 24-hour hour and minute; same as %H:%M
%s seconds since 1970-01-01 00:00:00 UTC
%S second (00..60)
%t a tab
%T time; same as %H:%M:%S
%u day of week (1..7); 1 is Monday
%U week number of year, with Sunday as first day of week
(00..53)
%V ISO week number, with Monday as first day of week (01..53)
%w day of week (0..6); 0 is Sunday
%W week number of year, with Monday as first day of week
(00..53)
%x locale's date representation (e.g., 12/31/99)
%X locale's time representation (e.g., 23:13:48)
%y last two digits of year (00..99)
%Y year
%z +hhmm numeric time zone (e.g., -0400)
%:z +hh:mm numeric time zone (e.g., -04:00)
%::z +hh:mm:ss numeric time zone (e.g., -04:00:00)
%:::z numeric time zone with : to necessary precision (e.g.,
-04, +05:30)
%Z alphabetic time zone abbreviation (e.g., EDT)
By default, date pads numeric fields with zeroes. The following
optional flags may follow '%':
- (hyphen) do not pad the field
_ (underscore) pad with spaces
0 (zero) pad with zeros
+ pad with zeros, and put '+' before future years with >4
digits
^ use upper case if possible
# use opposite case if possible
:see
>time
-12
View File
@@ -1,12 +0,0 @@
:sig
String dirname(String fn)
:params
fn : raw filename
return value : the directory's name
:desc
Isolates the directory name component from a path/file name.
:see
>sys
-13
View File
@@ -1,13 +0,0 @@
:sig
f64 draw_float(f64 from, f64 to)
:params
from : minimum value
to : maximum value
return value : a noise value between 'from' and 'to'
:desc
This function works exactly like generate_float(), but context->random_index is used for the 'index' value and context->random_seed is used for the seed. After this function has been called, the context->random_index is increased by one. At the start of every request, context->random_seed is automatically populated with a new seed value.
:see
>noise
-13
View File
@@ -1,13 +0,0 @@
:sig
u64 draw_int(u64 from, u64 to)
:params
from : minimum value
to : maximum value
return value : a noise value between 'from' and 'to'
:desc
This function works exactly like generate_int(), but context->random_index is used for the 'index' value and context->random_seed is used for the seed. After this function has been called, the context->random_index is increased by one. At the start of every request, context->random_seed is automatically populated with a new seed value.
:see
>noise
-12
View File
@@ -1,12 +0,0 @@
:sig
String encode_query(StringMap map)
:params
q : StringMap containing URL parameters to be encoded
return value : a string with the encoded parameters
:desc
Encodes a StringMap containing URL parameters into a single String.
:see
>uri
-12
View File
@@ -1,12 +0,0 @@
:sig
String expand_path(String path)
:params
path : a relative path
return value : expanded version of the 'path'
:desc
Converts a relative path name into an absolute path, using the current working directory as a base.
:see
>sys
-12
View File
@@ -1,12 +0,0 @@
:sig
void file_append(String file_name, ...val)
:params
file_name : file name of file that should be written to
...val : one or more values that should be written into the file
:desc
Opens or creates a given file and appends data to it.
:see
>sys
-12
View File
@@ -1,12 +0,0 @@
:sig
bool file_exists(String path)
:params
path : the path name to be checked
return value : true if the file exists
:desc
Checks whether the file or path specified by 'path' exists.
:see
>sys
-12
View File
@@ -1,12 +0,0 @@
:sig
String file_get_contents(String file_name)
:params
file_name : file name of file that should be read
return value : String containing the file's contents
:desc
Reads the file identified by 'file_name' and returns it as a String. If the file cannot be read, this function will return an empty string.
:see
>sys
-13
View File
@@ -1,13 +0,0 @@
:sig
time_t file_mtime(String file_name)
:params
file_name : name of the file
return value : Unix time stamp of the file's last modification
:desc
Retrieves the last modification date of 'file_name' as a Unix timestamp.
:see
>sys
>time
-13
View File
@@ -1,13 +0,0 @@
:sig
bool file_put_contents(String file_name, String content)
:params
file_name : file name of file that should be written
content : content that should be written
return value : true if write was successful
:desc
Writes the String 'content' into a file identified by 'file_name'. Any pre-existing content of the file will be overwritten.
:see
>sys
-14
View File
@@ -1,14 +0,0 @@
:sig
StringList filter(StringList items, function<bool (String)> f)
vector<T> filter(vector<T> items, function<bool (T)> f)
:params
items : list of items to be filtered
f : a function that decides which items should be in the new list
return value : a new list
:desc
Returns a list containing the members of 'items' for which 'f' returned boolean true.
:see
>string
-12
View File
@@ -1,12 +0,0 @@
:sig
String first(String... args)
:params
args : a variable number of String arguments
return value : first of the 'args' that was not empty.
:desc
Given a variable number of String parameters, the first() function returns the first of these parameters that was not empty. Leading and trailing whitespace characters are not considered, resulting in a string that contains only whitespace characters being considered empty.
:see
>string
-16
View File
@@ -1,16 +0,0 @@
:sig
f64 generate_float(f64 from, f64 to, u64 index, u64 seed = 0)
:params
from : minimum result
to : maximum result
index : index position to generate number from
seed : seed position to generate number from (defaults to 0)
return value : noise value
:desc
Generates a noise value between 'from' and 'to', given the 'index' and 'seed' numbers.
:see
>noise
-16
View File
@@ -1,16 +0,0 @@
:sig
u64 generate_int(u64 from, u64 to, u64 index, u64 seed = 0)
:params
from : minimum result
to : maximum result
index : index position to generate number from
seed : seed position to generate number from (defaults to 0)
return value : noise value
:desc
Generates a noise value between 'from' and 'to', given the 'index' and 'seed' numbers.
:see
>noise
-13
View File
@@ -1,13 +0,0 @@
:sig
u32 noise01(u64 index, u64 seed = 0)
:params
index : index position
seed : seed set (defaults to 0)
return value : a noise value from 0 to 1
:desc
Generates a noise value in the range from 0 to 1 for the given 'index' and 'seed' values.
:see
>noise
-13
View File
@@ -1,13 +0,0 @@
:sig
u32 noise32(u32 index, u32 seed = 0)
:params
index : index position
seed : seed set (defaults to 0)
return value : a noise value given the 'index' and 'seed' values.
:desc
Generates a noise value for the given 'index' and 'seed' values.
:see
>noise
-13
View File
@@ -1,13 +0,0 @@
:sig
u32 noise64(u64 index, u64 seed = 0)
:params
index : index position
seed : seed set (defaults to 0)
return value : a noise value given the 'index' and 'seed' values.
:desc
Generates a noise value for the given 'index' and 'seed' values.
:see
>noise
-10
View File
@@ -1,10 +0,0 @@
:sig
String sha1(String s, bool as_binary = false)
:params
s : data to be hashed
as_binary : when set to false, returns hash in hexadecimal notation (defaults to false)
return value : the resulting hash value
:desc
Returns the sha1 hash of 's'.
-11
View File
@@ -1,11 +0,0 @@
:sig
String get_cwd()
:params
return value : the current working directory
:desc
Returns the current working directory.
:see
>sys
-125
View File
@@ -1,125 +0,0 @@
:sig
String gmdate(String format = "", u64 timestamp = 0)
:params
format : formatting string specifying the date format
timestamp : optional timestamp value, defaults to current time
return value : a formatted date
:desc
Returns a formatted date in the GMT/UTC timezone. This is based on the Linux date() command. The formatting string supports the following sequences:
:pre
%% a literal %
%a locale's abbreviated weekday name (e.g., Sun)
%A locale's full weekday name (e.g., Sunday)
%b locale's abbreviated month name (e.g., Jan)
%B locale's full month name (e.g., January)
%c locale's date and time (e.g., Thu Mar 3 23:05:25 2005)
%C century; like %Y, except omit last two digits (e.g., 20)
%d day of month (e.g., 01)
%D date; same as %m/%d/%y
%e day of month, space padded; same as %_d
%F full date; like %+4Y-%m-%d
%g last two digits of year of ISO week number (see %G)
%G year of ISO week number (see %V); normally useful only
with %V
%h same as %b
%H hour (00..23)
%I hour (01..12)
%j day of year (001..366)
%k hour, space padded ( 0..23); same as %_H
%l hour, space padded ( 1..12); same as %_I
%m month (01..12)
%M minute (00..59)
%n a newline
%N nanoseconds (000000000..999999999)
%p locale's equivalent of either AM or PM; blank if not known
%P like %p, but lower case
%q quarter of year (1..4)
%r locale's 12-hour clock time (e.g., 11:11:04 PM)
%R 24-hour hour and minute; same as %H:%M
%s seconds since 1970-01-01 00:00:00 UTC
%S second (00..60)
%t a tab
%T time; same as %H:%M:%S
%u day of week (1..7); 1 is Monday
%U week number of year, with Sunday as first day of week
(00..53)
%V ISO week number, with Monday as first day of week (01..53)
%w day of week (0..6); 0 is Sunday
%W week number of year, with Monday as first day of week
(00..53)
%x locale's date representation (e.g., 12/31/99)
%X locale's time representation (e.g., 23:13:48)
%y last two digits of year (00..99)
%Y year
%z +hhmm numeric time zone (e.g., -0400)
%:z +hh:mm numeric time zone (e.g., -04:00)
%::z +hh:mm:ss numeric time zone (e.g., -04:00:00)
%:::z numeric time zone with : to necessary precision (e.g.,
-04, +05:30)
%Z alphabetic time zone abbreviation (e.g., EDT)
By default, date pads numeric fields with zeroes. The following
optional flags may follow '%':
- (hyphen) do not pad the field
_ (underscore) pad with spaces
0 (zero) pad with zeros
+ pad with zeros, and put '+' before future years with >4
digits
^ use upper case if possible
# use opposite case if possible
:see
>time
-13
View File
@@ -1,13 +0,0 @@
:sig
String html_escape(String s)
:params
s : string to be escaped
return value : an HTML-safe escaped version of 's'
:desc
Returns a version of the input string where the following characters have been replace by HTML entities:
- & → &amp
- < → lt;
- > → &gt;
- " → &quot;
-11
View File
@@ -1,11 +0,0 @@
:sig
u64 int_val(String s, u32 base = 10)
:params
s : string to be converted
base : number system base (default 10)
return value : a u64 containing the number (0 if no number could be identified).
:desc
Extracts an integer from a String.
-13
View File
@@ -1,13 +0,0 @@
:sig
String join(StringList l, String delim = "\n")
:params
l : list of strings to be joined
delim : delimiter (defaults to newline character)
return value : a string containing items joined by 'delim'
:desc
Joins the items contained in 'l' into a single String.
:see
>string
-10
View File
@@ -1,10 +0,0 @@
:sig
DTree json_decode(String s)
:params
s : string containing JSON data
return value : a DTree object containing the deserialized JSON data
:desc
Deserializes 's' into a DTree structure.
-10
View File
@@ -1,10 +0,0 @@
:sig
String json_encode(DTree t)
:params
t : DTree object to be serialized
return value : string containing the JSON result
:desc
Serializes a DTree structure 't' into a String in JSON notation.
-15
View File
@@ -1,15 +0,0 @@
:sig
s64 kill(pid_t pid, s64 sig)
:params
pid : PID of the process
sig : signal number
return value : 0 if signal was sent, -1 otherwise
:desc
This is the standard POSIX kill() function, provided here for reference.
Possible signal numbers are: SIGABND, SIGABRT, SIGALRM, SIGBUS, SIGFPE, SIGHUP, SIGILL, SIGINT, SIGKILL, SIGPIPE, SIGPOLL, SIGPROF, SIGQUIT, SIGSEGV, SIGSYS, SIGTERM, SIGTRAP, SIGURG, SIGUSR1, SIGUSR2, SIGVTALRM, SIGXCPU, SIGXFSZ, SIGCHLD, SIGIO, SIGIOERR, SIGWINCH, SIGSTOP, SIGTSTP, SIGTTIN, SIGTTOU, SIGCONT.
:see
>task
-12
View File
@@ -1,12 +0,0 @@
:sig
StringList ls(String path)
:params
path : a filesystem path
return value : list of directory entries
:desc
Returns a list of files and subdirectories within the given 'path'.
:see
>sys
-11
View File
@@ -1,11 +0,0 @@
:sig
String make_session_id()
:params
return value : a new session ID
:desc
Creates a session ID
:see
>session
-13
View File
@@ -1,13 +0,0 @@
:sig
String memcache_command(u64 connection, String command)
:params
connection : connection handle
command : string containing the Memcache command
return value : string containing the Memcache server's response
:desc
Executes a command on an open memcache connection.
:see
>memcache
-13
View File
@@ -1,13 +0,0 @@
:sig
bool memcache_delete(u64 connection, String key)
:params
connection : connection handle
key : key string
return value : true if the operation was successful
:desc
Deletes entry specified by the 'key'.
:see
>memcache
-14
View File
@@ -1,14 +0,0 @@
:sig
String memcache_get(u64 connection, String key, String default_value = "")
:params
connection : connection handle
key : key string
default_value : optional default value
return value : value that was returned by the Memcache server
:desc
Retrieves a value from an existing connection to a Memcache server.
:see
>memcache
-13
View File
@@ -1,13 +0,0 @@
:sig
StringMap memcache_get_multiple(u64 connection, StringList keys)
:params
connection : connection handle
keys : a list of strings containing the keys to be retrieved
return value : a StringMap with the retrieved entries
:desc
Retrieves a bunch of entries all at once.
:see
>memcache
-15
View File
@@ -1,15 +0,0 @@
:sig
bool memcache_set(u64 connection, String key, String value, u64 expires_in = 60*60)
:params
connection : connection handle
key : the entry's key
value : the value to be set
expires_in : optional expiration timeout, defaults to one hour
return value : true if the operation was successful
:desc
Stores a 'value' on the Memcache server.
:see
>memcache
-11
View File
@@ -1,11 +0,0 @@
:sig
f64 microtime()
:params
return value : current Unix timestamp
:desc
Returns a 64 bit float containing the current Unix timestamp with millisecond accuracy or better.
:see
>time
-12
View File
@@ -1,12 +0,0 @@
:sig
bool mkdir(String path)
:params
path : the path name to be created
return value : returns true if the directory was successfully created
:desc
Creates a directory stated by 'path'
:see
>sys
-14
View File
@@ -1,14 +0,0 @@
:sig
MySQL* mysql_connect(String host = "localhost", String username = "root", String password = "")
:params
host : host name of the MySQL server
username : user name
password : password
return value : pointer to the MySQL connection struct
:desc
Establishes a connection to a MySQL server.
:see
>mysql
-11
View File
@@ -1,11 +0,0 @@
:sig
void mysql_disconnect(MySQL* m)
:params
m : pointer to an existing MySQL connection struct
:desc
Closes a connection to a MySQL server.
:see
>mysql
-12
View File
@@ -1,12 +0,0 @@
:sig
String mysql_error(MySQL* m)
:params
m : pointer to a MySQL connection struct
return value : MySQL error message (if present, otherwise empty string)
:desc
Returns the last error message from a connection to a MySQL server.
:see
>mysql
-13
View File
@@ -1,13 +0,0 @@
:sig
String mysql_escape(String raw, char quote_char)
:params
raw : the string to be escaped
quote_char : the character that should be used to wrap the string (pass NULL for no wrapping)
return value : the safe version of the 'raw' string
:desc
Escapes a string such that it can be passed as a safe value into an SQL expression.
:see
>mysql
-12
View File
@@ -1,12 +0,0 @@
:sig
u64 mysql_insert_id(MySQL* m)
:params
m : pointer to an active MySQL connection
return value : the last used automatic row ID
:desc
This retrieves the last row ID that was used for a column with an AUTO_INCREMENT row key.
:see
>mysql
-17
View File
@@ -1,17 +0,0 @@
:sig
DTree mysql_query(MySQL* m, String q, StringMap params)
:params
m : pointer to an active MySQL connection struct
q : a string containing a MySQL query
params : optional, a list of query parameter keys and values
return value : a list of rows returned from executing the query
:desc
Executes a MySQL query and returns the resulting data (if any).
:Examples
(tbd)
:see
>mysql
-13
View File
@@ -1,13 +0,0 @@
:sig
String nibble(String& haystack, String delim)
:params
haystack : string to be nibbled at
delim : delimiter
return value : string before first occurrence of 'delim'
:desc
Returns the part of 'haystack' before the first occurrence of 'delim', removing the corresponding part from 'haystack' (including 'delim'). If the substring 'delim' does not occurr in 'haystack', the entire string is returned and 'haystack' is set to an empty string.
:see
>string
-11
View File
@@ -1,11 +0,0 @@
:sig
void ob_clear()
:params
(none)
:desc
Discard the current output buffer.
:see
>ob
-11
View File
@@ -1,11 +0,0 @@
:sig
String ob_get()
:params
return value : content of the current output buffer
:desc
Returns the contents of the current output buffer.
:see
>ob
-11
View File
@@ -1,11 +0,0 @@
:sig
String ob_get_clear()
:params
return value : content of the current output buffer
:desc
Returns the contents of the current output buffer and then discards the buffer.
:see
>ob
-11
View File
@@ -1,11 +0,0 @@
:sig
void ob_start()
:params
(none)
:desc
Starts a new output buffer. All subsequent output will be directed into this buffer.
:see
>ob
-12
View File
@@ -1,12 +0,0 @@
:sig
StringMap parse_query(String q)
:params
q : string containing URL parameters
return value : a StringMap containing the parameters
:desc
Decodes a string of the format 'a=b&c=d' into a StringMap containing keyed entries.
:see
>uri
-12
View File
@@ -1,12 +0,0 @@
:sig
u64 parse_time(String time_string)
:params
time_string : a string containing a date and/or time in text form
return value : the interpreted 'time_string' as a Unix timestamp
:desc
Attempts to parse the given 'time_string' into a Unix timestamp.
:see
>time
-10
View File
@@ -1,10 +0,0 @@
:sig
void print(...val)
:params
...val : one or more values that should be output
:desc
Appends data to the current request's output stream.
-11
View File
@@ -1,11 +0,0 @@
:sig
void session_destroy(String session_name)
:params
session_name : the name of the session
:desc
Deletes the cookie specified by 'session_name' and clears the data stored under the session ID. This empties the 'context->session_id' and 'context->session' variables.
:see
>session
-17
View File
@@ -1,17 +0,0 @@
:sig
String session_start(String session_name)
:params
return value : the session ID, defaults to "uce-session"
:desc
Starts session or connects to existing session. This function sets a cookie with the name contained in 'session_name' if it does not exist and fills that cookie with a new unique session ID. It then loads the session data for that session ID. Afterwards, the following fields are populated in the 'context' variable:
context->session_id : the current session ID
context->session_name : the current session cookie name
context->session : the current session data. The session data is automatically saved after a request completes.
:see
>session
-11
View File
@@ -1,11 +0,0 @@
:sig
void set_cwd(String path)
:params
path : the new working directory
:desc
Sets a new working directory.
:see
>sys
-12
View File
@@ -1,12 +0,0 @@
:sig
String shell_escape(String raw)
:params
raw : string that should be escaped
return value : escaped version of 'raw'
:desc
Escapes a parameter for shell_exec
:see
>sys
-12
View File
@@ -1,12 +0,0 @@
:sig
String shell_exec(String cmd)
:params
cmd : string that contains the shell command line to be executed
return value : output of the command execution
:desc
Executes a Linux shell command and returns the generated output
:see
>sys
-11
View File
@@ -1,11 +0,0 @@
:sig
void socket_close(u64 sockfd)
:params
sockfd : socket handle
:desc
Closes an existing socket connection.
:see
>socket
-13
View File
@@ -1,13 +0,0 @@
:sig
u64 socket_connect(String host, short port)
:params
host : host name
port : port number
return value : the socket handle
:desc
Opens a socket connection to the given 'host' and 'port'.
:see
>socket
-13
View File
@@ -1,13 +0,0 @@
:sig
bool socket_write(u64 sockfd, String data)
:params
sockfd : socket handle
data : a string containing the data to be written to the socket
return value : true if the write operation was successful
:desc
Writes a string of 'data' to the given socket.
:see
>socket
-13
View File
@@ -1,13 +0,0 @@
:sig
StringList split(String str, String delim = "\n")
:params
str : string to be split
delim : delimiter (defaults to newline character)
return value : a list of strings
:desc
Splits 'str' into multiple strings based on the given delimiter 'delim'.
:see
>string
-14
View File
@@ -1,14 +0,0 @@
:sig
String str_to_lower(String s)
:params
s : the string to be converted
return value : returns a version of 's' where all upper case characters have been changed into lower case
:desc
Returns a lower case version of the input string 's'.
Note: this function is not yet Unicode-aware.
:see
>string
-14
View File
@@ -1,14 +0,0 @@
:sig
String str_to_upper(String s)
:params
s : the string to be converted
return value : returns a version of 's' where all lower case characters have been changed into upper case
:desc
Returns a upper case version of the input string 's'.
Note: this function is not yet Unicode-aware.
:see
>string
-13
View File
@@ -1,13 +0,0 @@
:sig
pid_t task(String key, std::function<void()> exec_func)
:params
key : string uniquely identifying the task
exec_func : function to execute
return value : the process ID of the started (or still running) task
:desc
task() starts the 'exec_func' in a new process and returns that process' ID. If a process with the same 'key' is already running, task will not start a new process but instead just return the PID of the process that is already running.
:see
>task
-12
View File
@@ -1,12 +0,0 @@
:sig
pid_t task_pid(String key)
:params
key : string uniquely identifying the task
return value : the process ID of the task
:desc
Checks whether a process with the given 'key' is running and returns its PID if it is. Returns 0 otherwise.
:see
>task
-11
View File
@@ -1,11 +0,0 @@
:sig
u64 time()
:params
return value : second-accurate current Unix timestamp
:desc
Returns a 64 bit integer containing the current Unix timestamp.
:see
>time
-11
View File
@@ -1,11 +0,0 @@
:sig
void unlink(String file_name)
:params
file_name : name of the file
:desc
Deletes the file identified by 'file_name'.
:see
>sys
-12
View File
@@ -1,12 +0,0 @@
:sig
String var_dump(StringMap t, String prefix = "", String postfix = "\n")
String var_dump(StringList t, String prefix = "", String postfix = "\n")
String var_dump(DTree t, String prefix = "", String postfix = "\n")
:params
t : object to be dumped into a string
return value : string containing a human-friendly representation of 't'
:desc
Returns a string representation of 't' intended for debugging.
-105
View File
@@ -1,105 +0,0 @@
* {
font-family: inherit;
font-size: inherit;
box-sizing: inherit;
color: inherit;
line-height: inherit;
}
h1 {
font-family: monospace;
font-size: 200%;
padding-top: 8px;
padding-bottom: 8px;
}
body {
max-width: 1024px;
margin-left: auto;
margin-right: auto;
padding-left: 16px;
padding-right: 16px;
font-family: Tahoma, Helvetica, Arial;
font-size: 1.2em;
box-sizing: border-box;
background: #139;
color: white;
line-height: 150%;
}
body > * {
background: rgba(255,255,255,0.1);
padding: 32px;
margin: 16px;
}
a {
color: yellow;
}
form > div, label {
display: block;
padding-top: 8px;
padding-bottom: 8px;
}
input, textarea {
background: rgba(0,0,0,0.2);
border: 2px solid rgba(255,255,255,0.2);
}
input[type=submit], button {
padding: 8px;
cursor: pointer;
}
input[type=submit]:hover, button:hover {
color: yellow;
background: rgba(0,0,0,0.5);
}
input[type=text], textarea {
padding: 8px;
width: 100%;
}
input[type=text]:hover, textarea:hover {
background: rgba(0,0,0,0.25);
}
textarea {
height: 20%;
}
pre {
height: 20%;
overflow: auto;
padding: 8px;
border: 2px solid rgba(0,0,0,0.2);
background: rgba(100,100,100,0.15);
font-family: monospace;
white-space: pre-wrap;
}
h3 {
margin: 0;
font-family: monospace;
font-size: 1.4em;
margin-bottom: 0.8em;
opacity: 0.7;
}
.sig {
font-family: monospace;
white-space: pre;
font-size: 120%;
}
.params {
}
.params b {
font-family: monospace;
white-space: pre;
}
@@ -0,0 +1,12 @@
diff --git a/vendor/miniz/miniz_tdef.c b/vendor/miniz/miniz_tdef.c
--- a/vendor/miniz/miniz_tdef.c
+++ b/vendor/miniz/miniz_tdef.c
@@
-static const mz_uint s_tdefl_num_probes[11];
+static const mz_uint s_tdefl_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 };
static int tdefl_flush_block(tdefl_compressor *d, int flush)
@@
-static const mz_uint s_tdefl_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 };
-
/* level may actually range from [0,10] (10 is a "hidden" max level, where we want a bit more compression and it's fine if throughput to fall off a cliff on some files). */
+34
View File
@@ -0,0 +1,34 @@
# SQLite 3.46.1 Vendor Import
Imported the official SQLite amalgamation without local source modifications.
- Version: SQLite 3.46.1
- Upstream archive: https://www.sqlite.org/2024/sqlite-amalgamation-3460100.zip
- Import date: 2026-05-29
- Vendored files:
- `src/3rdparty/sqlite/sqlite3.c`
- `src/3rdparty/sqlite/sqlite3.h`
- `src/3rdparty/sqlite/sqlite3ext.h`
## Checksums
```text
77823cb110929c2bcb0f5d48e4833b5c59a8a6e40cdea3936b99e199dbbe5784 sqlite-amalgamation-3460100.zip
6c35bc5f7f85eac9c49928bacbb02bb694b547aabf69197e058cca245ad80e83 sqlite3.c
89b62c671c5964e137409ce034941b7b05a3af2c9875aba41f47f9483d0c2515 sqlite3.h
b184dd1586d935133d37ad76fa353faf0a1021ff2fdedeedcc3498fff74bbb94 sqlite3ext.h
```
## Runtime compile flags
The amalgamation is included by `src/lib/uce_lib.cpp` with:
```cpp
#define SQLITE_THREADSAFE 1
#define SQLITE_OMIT_LOAD_EXTENSION 1
#define SQLITE_DQS 0
#define SQLITE_DEFAULT_FOREIGN_KEYS 1
#define SQLITE_DEFAULT_WAL_SYNCHRONOUS 1
```
No patch diff is needed because the vendored SQLite files are unmodified.
+147
View File
@@ -0,0 +1,147 @@
# React Developer Affordances Todo
## Objective
Add practical value for developers coming from React frameworks while preserving UCE's server-first C++ model. Defer component syntax/children work, avoid global head/assets/islands in the runtime, and focus on function-library data helpers, diagnostics, docs, examples, demos, and a starter-local router with starter-local asset/island components.
## Success Criteria
- [x] Function library has useful collection/data-shaping helpers with docs and tests.
- [x] Compile/runtime diagnostics are more helpful, especially for generated-code and common preprocessor mistakes.
- [x] Docs include a concise React/Next/Remix orientation guide.
- [x] Starter example uses a centralized hierarchical/file-based router in `index.uce` efficiently.
- [x] Starter-local asset/island affordances live as component handlers in the starter, not global runtime APIs.
- [x] Network tests and relevant build checks pass on `k-uce`.
## Current State
- Status: complete
- Last updated: 2026-05-28
- Source of truth: `/root/mount_ssh/k-uce-root-htdocs-uce`
- Runtime/live target: `k-uce:/Code/uce.openfu.com/uce`; rebuilt and restarted `uce.service` on `k-uce`.
## Goal Tree
Legend: `[ ]` not started, `[~]` in progress, `[x]` done, `[!]` blocked, `[-]` superseded
- [x] G1: Add collection/data helpers to function library
- Why: React-framework developers routinely shape arrays/objects near render code.
- Done when: helpers are declared, implemented, documented, and covered by tests.
- Verify: build plus focused site/network tests.
- [x] G1.1: Identify current `StringList`/`DValue` idioms and choose helper surface.
- [x] G1.2: Implement minimal high-value helpers without broad template complexity.
- [x] G1.3: Add docs and examples for helpers.
- [x] G1.4: Add/extend tests.
- [x] G2: Improve developer diagnostics
- Why: React frameworks win by making failures easy to act on.
- Done when: compile/runtime error output includes actionable context and docs mention debugging flow.
- Verify: intentional broken page surfaces improved message.
- [x] G2.1: Inspect current compiler/runtime error rendering path.
- [x] G2.2: Add source excerpt / generated path / common-hint text where appropriate.
- [x] G2.3: Document diagnostics.
- [x] G3: Add React/Next/Remix orientation docs
- Why: mapping familiar concepts reduces onboarding cost without adding syntax.
- Done when: docs page exists and is linked from docs/README/demo surfaces.
- Verify: docs page renders live.
- [x] G4: Starter-local router and starter affordances
- Why: User specifically wants hierarchical/file-based routing beautifully in starter `index.uce`.
- Done when: starter routes go through a central router in `index.uce`, and starter-local asset/island component handlers exist and are used where sensible.
- Verify: key starter routes render 200.
- [x] G4.1: Inspect current starter routing.
- [x] G4.2: Refactor to clear route table / hierarchical file resolution in `index.uce`.
- [x] G4.3: Add starter-local `COMPONENT:asset` / `COMPONENT:island` style handlers in one unit.
- [x] G4.4: Use them efficiently in starter pages/layout.
- [x] G5: Demos and examples
- Why: Affordances must be visible to developers, not hidden in APIs.
- Done when: docs/demo/tests expose examples.
- Verify: demo URLs return 200 and tests pass.
- [x] G6: Verification and project docs
- Done when: build/test commands are run on `k-uce`, project notes updated, and adversarial review completed.
## Execution Queue
Complete.
## Decisions
- 2026-05-28: Defer component children/slots and JSX-like preprocessor syntax.
- 2026-05-28: Do not add global runtime head/assets/islands APIs; implement asset/island as starter-local components.
- 2026-05-28: Do not add a generic runtime file-based-routing system; demonstrate hierarchical/file routing inside starter `index.uce`.
- 2026-05-28: Keep collection helpers explicit (`list_*`, `dv_*`) instead of overloading generic names such as `map`/`sort`.
## Assumptions
- Current source-of-truth mount is live-editable; runtime validation requires SSH to `k-uce`.
- Existing site tests are the right place for function-library coverage.
## Blockers and Risks
- No current blockers.
- Future risk: if UCE grows a full parser or component-tag syntax, keep this pass's explicit component/router APIs as a stable lower-level fallback.
## Evidence and Verification Log
- 2026-05-28: Created plan after reviewing README, preprocessor docs, and function library headers.
- 2026-05-28: `ssh k-uce 'cd /Code/uce.openfu.com/uce && bash scripts/build_linux.sh'` succeeded.
- 2026-05-28: Restarted `uce.service` on `k-uce`.
- 2026-05-28: `tests/run_network_tests.py --match core` passed.
- 2026-05-28: Manual checks returned `200` for `/examples/uce-starter/index.uce`, `?dashboard`, `?workspace/projects`, `?themes`, `/demo/collections.uce`, `/doc/index.uce?p=coming_from_react`, `/doc/index.uce?p=list_map`, and `/doc/index.uce?p=dv_group_by`.
- 2026-05-28: Full internal network suite passed, 25/25.
- 2026-05-28: Temporary broken `/tests/diagnostic-probe.uce` returned `500` with formatted `UCE compile error` diagnostics; source and cache artifacts were removed afterward.
## Change Log
- 2026-05-28: Created initial goal tree.
- 2026-05-28: Implemented helpers, diagnostics, docs, demo, starter router, starter-local web affordance components, tests, and validation.
## Follow-up Cleanup 2026-05-29
- Removed duplicate route cleanup from `starter_router_candidates()` because `app_make_route()` is the single normalization point for `l_path`.
- Weeded out nearby duplicate/obsolete starter code:
- `starter_router_add_candidate(...)` now owns repeated candidate tree construction.
- Removed unused `app_resolve_view()` / `starter_resolve_view()` after moving routing into starter `index.uce`.
- Removed unused legacy registered asset rendering functions from `lib/app.uce`; registered assets now render through `components/theme/web_affordances.uce`.
- `app_init()` now reuses `app_base_url(context)` instead of repeating base URL derivation.
- `web_affordances.uce` now uses one `starter_render_asset_group(...)` loop for CSS and JS.
- Verification: rebuilt on `k-uce`, restarted `uce.service`, checked key starter routes, and ran `tests/run_network_tests.py --match core` successfully.
## Follow-up Routed Views 2026-05-29
- Changed starter route dispatch from `unit_render(...)` to `component(...)`.
- Converted all routed `site/examples/uce-starter/views/*.uce` files to `COMPONENT(Request& context)` rather than `RENDER(Request& context)` because they are central-router-only views.
- Updated the starter README and verified key starter routes. No service restart was required because only `.uce`/docs changed.
## Follow-up Canonical Starter URLs 2026-05-29
- Canonicalized starter self-links from `/examples/uce-starter/index.uce?...` to `/examples/uce-starter/?...` with `app_canonical_script_url(...)`.
- Updated the starter README to show canonical directory URLs.
- Touched the starter front controller to force the `#load`ed helper change into the cached generated unit.
- Verified canonical/direct starter routes and checked generated self-links. No service restart was required.
## Follow-up Not Found Component 2026-05-29
- Moved `starter_router_render_not_found` markup into `components/basic/notfound.uce`.
- Router now delegates 404 body rendering through `component("components/basic/notfound", props, context)`.
- Verified missing routes return `404` and normal dashboard route returns `200`. No service restart required.
## Follow-up Page Shell Component 2026-05-29
- Moved app page rendering into `themes/page.uce` as a component.
- Removed `app_render_page`, `app_theme_page_component`, and `starter_render_page` from `lib/app.uce`.
- Page template resolution now follows `context.call["app"]["page_type"]`: current theme first, common fallback second.
- Verified representative HTML routes and the JSON page-type fallback. No service restart required.
## Follow-up Deep Starter Context Cleanup 2026-05-29
- Removed repeated `starter_boot(context)` calls; root `index.uce` is the boot point.
- Removed `context.call["starter"]` duplicated state and JSON side-channel state.
- JSON routes now use only `context.call["app"]["page_type"]` plus normal captured output.
- Simplified `themes/page.uce` and `themes/common/page.json.uce` accordingly.
- Replaced `starter_*` alias helper usage with direct `app_*` helpers and removed alias wrappers except `StarterUser`.
- Verified key routes and core tests. No service restart required.
## Follow-up Route Context Flattening 2026-05-29
- Flattened `context.call["app"]["route"]` to `context.call["route"]`.
- Moved former `context.call["app"]["router"]` metadata into `context.call["route"]`.
- Verified representative starter HTML, 404, and JSON routes. No service restart required.
@@ -0,0 +1,104 @@
[
{
"backend": "native",
"target": "template-heavy-doc",
"url": "/doc/singlepage.uce",
"ok": true,
"status": 200,
"samples_ms": [
318.72209906578064,
340.9293442964554,
319.705568253994,
324.0259513258934,
350.93583166599274,
313.20811808109283,
317.0944079756737,
310.312956571579,
307.89367109537125,
308.1864267587662,
311.681292951107,
313.39504569768906,
314.3857270479202,
312.5988021492958,
313.25943768024445,
312.9996135830879,
334.4864323735237,
314.2518773674965,
309.7490146756172,
317.4726217985153
],
"median_ms": 313.8234615325928,
"mean_ms": 318.2647120207548,
"min_ms": 307.89367109537125,
"max_ms": 350.93583166599274,
"note": ""
},
{
"backend": "native",
"target": "sqlite-page",
"url": "/demo/sqlite.uce",
"ok": true,
"status": 200,
"samples_ms": [
3.4144148230552673,
6.088584661483765,
3.463640809059143,
3.498159348964691,
3.5023540258407593,
6.214611232280731,
3.563329577445984,
3.3720433712005615,
3.330707550048828,
3.3808723092079163,
3.322914242744446,
3.3655911684036255,
3.374151885509491,
3.358304500579834,
3.3307820558547974,
3.268897533416748,
3.360658884048462,
3.3061057329177856,
6.233863532543182,
3.432638943195343
],
"median_ms": 3.3775120973587036,
"mean_ms": 3.809131309390068,
"min_ms": 3.268897533416748,
"max_ms": 6.233863532543182,
"note": ""
},
{
"backend": "native",
"target": "component-heavy-starter",
"url": "/examples/uce-starter/?dashboard",
"ok": true,
"status": 200,
"samples_ms": [
74.01428371667862,
40.9795418381691,
40.995217859745026,
41.04568809270859,
40.724173188209534,
41.10313206911087,
40.59913754463196,
41.28593951463699,
41.10439121723175,
40.649913251399994,
42.06441342830658,
42.074643075466156,
43.475523591041565,
41.8255478143692,
41.068583726882935,
41.116394102573395,
41.09777510166168,
42.58237034082413,
41.312023997306824,
70.98117470741272
],
"median_ms": 41.11039265990257,
"mean_ms": 44.50499340891838,
"min_ms": 40.59913754463196,
"max_ms": 74.01428371667862,
"note": ""
}
]
@@ -0,0 +1,19 @@
# Phase 5 native baseline — 2026-06-12
Host: `k-uce` / `uce.openfu.com` via localhost with Host header.
This is a durable informational snapshot. The Phase 5 gate recomputes native medians during paired native/WASM runs; these numbers are not hard-coded budgets.
- Warmup suite: 82/82 passed; excludes `site tests tasks` to avoid perturbing task lifecycle state.
- Measured full network suite: 83/83 passed.
- Measured starter subset: 14/14 passed.
- Static audit default scan: 50 code findings, documentation prose excluded by default.
| target | median ms | mean ms | samples |
|---|---:|---:|---:|
| template-heavy-doc | 313.8 | 318.3 | 20 |
| sqlite-page | 3.4 | 3.8 | 20 |
| component-heavy-starter | 41.1 | 44.5 | 20 |
Raw benchmark JSON: `native-baseline-2026-06-12.json`.
Static audit snapshot: `site-static-audit-2026-06-12.md`.
@@ -0,0 +1,56 @@
# Phase 5 site static-state audit
Findings: 50 code, 0 documentation prose.
| file | line | severity | kind | code | note |
|---|---:|---|---|---|---|
| site/demo/index.uce | 76 | code | background task | `<? if(allow_server_demos) { render_card("task_repeat.uce", "Task Repeat", "Recurring task scheduling"); } ?>` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/demo/once-init.uce | 1 | code | static local/global | `static s64 demo_worker_init_count = 0;` | Check whether state is request-local, immutable, or intentionally persistent; unit statics reset per wasm workspace. |
| site/demo/once-init.uce | 2 | code | static local/global | `static s64 demo_component_hits = 0;` | Check whether state is request-local, immutable, or intentionally persistent; unit statics reset per wasm workspace. |
| site/demo/once-init.uce | 4 | code | init hook | `INIT(Request& context)` | Audit behavior under per-request wasm workspaces; ONCE/INIT may need host-side cache semantics if used for cross-request state. |
| site/demo/once-init.uce | 10 | code | once hook | `ONCE(Request& context)` | Audit behavior under per-request wasm workspaces; ONCE/INIT may need host-side cache semantics if used for cross-request state. |
| site/demo/once-init.uce | 44 | code | once hook | `ONCE() and INIT()` | Audit behavior under per-request wasm workspaces; ONCE/INIT may need host-side cache semantics if used for cross-request state. |
| site/demo/once-init.uce | 44 | code | init hook | `ONCE() and INIT()` | Audit behavior under per-request wasm workspaces; ONCE/INIT may need host-side cache semantics if used for cross-request state. |
| site/demo/once-init.uce | 47 | code | once hook | `This page calls the same named component twice. `ONCE()` should only run once for the request, while `INIT()` should stay stable for the currently loaded worker copy.` | Audit behavior under per-request wasm workspaces; ONCE/INIT may need host-side cache semantics if used for cross-request state. |
| site/demo/once-init.uce | 47 | code | init hook | `This page calls the same named component twice. `ONCE()` should only run once for the request, while `INIT()` should stay stable for the currently loaded worker copy.` | Audit behavior under per-request wasm workspaces; ONCE/INIT may need host-side cache semantics if used for cross-request state. |
| site/demo/task-status.uce | 11 | code | background task | `String task_name = first(context.get["task-name"], "example-task");` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/demo/task-status.uce | 13 | code | background task | `print("Task Name: ", task_name, "\n");` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/demo/task-status.uce | 14 | code | background task | `print("Task ID: ", task_pid(task_name), "\n");` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/demo/task-status.uce | 15 | code | background task | `print("Task Running: ", task_pid(task_name) == 0 ? "no" : "yes", "\n");` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/demo/task.uce | 13 | code | background task | `String task_name = first(context.get["task-name"], "example-task");` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/demo/task.uce | 37 | code | background task | `<input type="text" name="task-name" value="<?= task_name ?>"/>` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/demo/task.uce | 46 | code | background task | `load(document.getElementById('task-status'), 'task-status.uce?task-name=<?= uri_encode(task_name) ?>');` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/demo/task.uce | 56 | code | background task | `print("Task Name: ", task_name, "\n");` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/demo/task.uce | 57 | code | background task | `print("Task ID: ", task_pid(task_name), "\n");` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/demo/task.uce | 58 | code | background task | `print("Task Running: ", task_pid(task_name) == 0 ? "no" : "yes", "\n");` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/demo/task.uce | 71 | code | background task | `print("New Task ID: ", task(task_name, []() {` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/demo/task_repeat.uce | 13 | code | background task | `String task_name = first(context.get["task-name"], "example-task");` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/demo/task_repeat.uce | 37 | code | background task | `<input type="text" name="task-name" value="<?= task_name ?>"/>` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/demo/task_repeat.uce | 46 | code | background task | `load(document.getElementById('task-status'), 'task-status.uce?task-name=<?= uri_encode(task_name) ?>');` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/demo/task_repeat.uce | 56 | code | background task | `print("Task Name: ", task_name, "\n");` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/demo/task_repeat.uce | 57 | code | background task | `print("Task ID: ", task_pid(task_name), "\n");` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/demo/task_repeat.uce | 58 | code | background task | `print("Task Running: ", task_pid(task_name) == 0 ? "no" : "yes", "\n");` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/demo/task_repeat.uce | 71 | code | background task | `print("New Task ID: ", task_repeat(task_name, 5, []() {` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/examples/uce-starter/components/data/widgets.uce | 3 | code | once hook | `ONCE(Request& context)` | Audit behavior under per-request wasm workspaces; ONCE/INIT may need host-side cache semantics if used for cross-request state. |
| site/examples/uce-starter/components/workspace/primitives.uce | 3 | code | once hook | `ONCE(Request& context)` | Audit behavior under per-request wasm workspaces; ONCE/INIT may need host-side cache semantics if used for cross-request state. |
| site/examples/uce-starter/lib/user.class.h | 13 | code | static local/global | `static String session_key()` | Check whether state is request-local, immutable, or intentionally persistent; unit statics reset per wasm workspace. |
| site/examples/uce-starter/lib/user.class.h | 18 | code | static local/global | `static String normalize_email(String email)` | Check whether state is request-local, immutable, or intentionally persistent; unit statics reset per wasm workspace. |
| site/examples/uce-starter/lib/user.class.h | 23 | code | static local/global | `static String hash_id(String raw)` | Check whether state is request-local, immutable, or intentionally persistent; unit statics reset per wasm workspace. |
| site/examples/uce-starter/lib/user.class.h | 45 | code | static local/global | `static String password_hash(String password, String salt)` | Check whether state is request-local, immutable, or intentionally persistent; unit statics reset per wasm workspace. |
| site/examples/uce-starter/lib/user.class.h | 53 | code | static local/global | `static DValue read_json_file(String file_name)` | Check whether state is request-local, immutable, or intentionally persistent; unit statics reset per wasm workspace. |
| site/examples/uce-starter/lib/user.class.h | 64 | code | static local/global | `static bool write_json_file(String file_name, DValue data)` | Check whether state is request-local, immutable, or intentionally persistent; unit statics reset per wasm workspace. |
| site/examples/uce-starter/views/dashboard.uce | 3 | code | once hook | `ONCE(Request& context)` | Audit behavior under per-request wasm workspaces; ONCE/INIT may need host-side cache semantics if used for cross-request state. |
| site/info/index.uce | 269 | code | static local/global | `<li>nginx serves static files directly from `site/`</li>` | Check whether state is request-local, immutable, or intentionally persistent; unit statics reset per wasm workspace. |
| site/tests/preprocessor.uce | 3 | code | once hook | `ONCE(Request& context)` | Audit behavior under per-request wasm workspaces; ONCE/INIT may need host-side cache semantics if used for cross-request state. |
| site/tests/tasks.uce | 25 | code | background task | `pid_t repeat_existing = task_pid("site-tests-repeat");` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/tests/tasks.uce | 27 | code | background task | `task_kill(repeat_existing, 15);` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/tests/tasks.uce | 37 | code | background task | `repeat_pid = task_repeat("site-tests-repeat", 1.0, []() {` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/tests/tasks.uce | 55 | code | background task | `pid_t seen_short_pid = task_pid("site-tests-short");` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/tests/tasks.uce | 56 | code | background task | `pid_t seen_repeat_pid = task_pid("site-tests-repeat");` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/tests/tasks.uce | 57 | code | background task | `pid_t seen_timeout_pid = task_pid("site-tests-timeout");` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/tests/tasks.uce | 58 | code | background task | `pid_t seen_unsafe_key_pid = task_pid("site-tests/../unsafe key");` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/tests/tasks.uce | 59 | code | background task | `int short_alive = seen_short_pid == 0 ? -1 : task_kill(seen_short_pid, 0);` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/tests/tasks.uce | 60 | code | background task | `int repeat_alive = seen_repeat_pid == 0 ? -1 : task_kill(seen_repeat_pid, 0);` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/tests/tasks.uce | 72 | code | background task | `check("task_pid() + task_kill(pid, 0)", short_alive == 0, "kill(0) result=" + std::to_string(short_alive));` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/tests/tasks.uce | 73 | code | background task | `check("task_repeat()", repeat_pid != 0 && seen_repeat_pid != 0, "started=" + std::to_string(repeat_pid) + " seen=" + std::to_string(seen_repeat_pid));` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
| site/tests/tasks.uce | 77 | code | background task | `check("task_kill() rejects negative pid", task_kill(-1, 0) == -1, "kill(-1, 0) rejected");` | Task APIs cross request lifetimes; verify they are host handles, not guest statics. |
+110
View File
@@ -0,0 +1,110 @@
# WASM Phase 1: DValue C ABI and UCEB1
Phase 1 freezes the native DValue ABI that the future WASM core and units use
as their shared structured-value contract. The implementation is in
`src/lib/dvalue.{h,cpp}` and is available in the native runtime before any WASM
backend is enabled.
## Opaque handle
```c
typedef struct DValue uce_dvalue;
```
`uce_dvalue*` is a borrowed pointer owned by the active request/workspace. It
must not be freed by ABI callers and it must not be retained beyond that
workspace lifetime.
## Accessors
```c
uce_dvalue* uce_dv_root(void);
uce_dvalue* uce_dv_get(uce_dvalue* value, const char* key, size_t key_len);
uce_dvalue* uce_dv_find(uce_dvalue* value, const char* key, size_t key_len);
const char* uce_dv_value(uce_dvalue* value, size_t* len_out);
void uce_dv_set_value(uce_dvalue* value, const char* bytes, size_t len);
size_t uce_dv_count(uce_dvalue* value);
int uce_dv_is_list(uce_dvalue* value);
```
- `uce_dv_root()` returns the current native request's `context.call` root.
The WASM core will later map this to the decoded request context root.
- `uce_dv_get()` creates the child if absent. `uce_dv_find()` returns `NULL`
if absent.
- String inputs and outputs are length-delimited and binary-safe.
- `uce_dv_value()` returns a borrowed pointer valid until the next ABI value
call on the same thread.
- Bad `NULL` inputs return `NULL`, zero, or no-op rather than trapping.
## Iteration
```c
typedef struct uce_dv_iter { size_t position; size_t reserved[3]; } uce_dv_iter;
uce_dv_iter uce_dv_iter_begin(uce_dvalue* value);
int uce_dv_iter_next(uce_dvalue* value, uce_dv_iter* iter,
const char** key_out, size_t* key_len_out,
uce_dvalue** child_out);
```
Map iteration follows DValue's native order. List-shaped maps iterate in numeric
index order (`0`, `1`, ...), matching `DValue::each()`, `dv_values()`, and the
serializers. The reserved iterator fields are caller-opaque and must be
zero-preserved by callers that copy the iterator; they provide ABI headroom for
future non-linear keyed-map iteration without changing the struct size.
## UCEB1 wire format
UCEB1 is the membrane/cross-instance binary DValue encoding.
```
document := "UCEB" version node
version := 0x01
node := flags scalar children
flags := u8 bitset; bit0 = list-shaped map
scalar := varuint length, bytes
children := varuint count, count * (key, node)
key := varuint length, bytes
```
Varuint is unsigned LEB128. Strings are byte sequences; the codec does not
assume NUL termination and preserves embedded NUL bytes. The Phase 1 layout stores scalar values as their native string representation
plus child nodes and the list-shape flag. Floating-point values use
`max_digits10` precision so numeric scalars can round-trip through the string
form. Pointer/reference identity is intentionally not part of the wire contract;
pointer nodes encode as an empty scalar rather than leaking process addresses.
An empty non-list map has no wire distinction from an empty scalar in UCEB1 v1.
Documents that contain both scalar bytes and child nodes are reserved for future
use; the v1 decoder accepts the children and ignores the scalar.
## Codec APIs
C++/UCE-visible helpers:
```cpp
String ucb_encode(const DValue& value);
DValue ucb_decode(const String& encoded);
bool ucb_decode(const String& encoded, DValue& out, String* error_out = 0);
```
C ABI helpers:
```c
size_t uce_dv_encode(uce_dvalue* value, char* buf, size_t cap);
uce_dvalue* uce_dv_decode(const char* buf, size_t len);
const char* uce_dv_last_error(void);
```
`uce_dv_encode()` returns the required byte length even when `buf` is `NULL` or
`cap` is zero. `uce_dv_decode()` returns a thread-local decoded root, or `NULL`
with `uce_dv_last_error()` populated. The returned decoded root is valid until
the next `uce_dv_decode()` call on the same thread. Decoding rejects documents
deeper than 1024 nested nodes so malformed input cannot recurse without bound.
## Test coverage
`site/tests/core.uce` covers:
- UCEB1 round-trip for maps, nested values, lists, empty lists, and embedded NUL
scalar bytes.
- C ABI get/find/value/count/list/iteration/encode/decode behavior.
+197
View File
@@ -0,0 +1,197 @@
# Phase 0 findings — toolchain & runtime spike
- **Status: EXIT CRITERION PASSED** (2026-06-12, on k-uce)
- **Runtime selected: Wasmtime** (v45.0.1, C API). WAMR rejected — evidence below.
- Exceptions decision (§11.1, error codes / `-fno-exceptions`) **confirmed viable**:
both the stubs and two real generated units compile with `-fno-exceptions`,
no try/catch blocker anywhere.
The exit criterion ran end-to-end: a core stub (libc/libc++ statically linked,
owns memory/allocator) and a unit stub (PIC, `dylink.0`) were linked **at
runtime** by `loader.cpp` and produced:
```
hello from unit; unit-data-segment-ok; counter=7; mapsum=3; core-string+unit[cb:42][got-func-ok][fn:42]
core_counter (in linear memory): before=7 after=8
PHASE0 EXIT CRITERION: PASS
```
which validates, in one render call: unit data-segment relocation
(`__memory_base`), GOT.mem read **and write** of a core global, `std::string`
/`std::map` in unit code on the core's heap, a heap C++ object created in core
and mutated/read by the unit, function pointers crossing unit→core→unit
through the shared table, GOT.func resolution, and a `std::function` lambda
allocated in the unit and invoked by core. That is the §3.4 contract
("DValue inside the workspace: no serialization, ever") demonstrated at the
ABI level.
## Toolchain pins
| What | Version | Where on k-uce |
|---|---|---|
| wasi-sdk | 33 (clang 22.1.0-wasi-sdk) | `/opt/wasi-sdk` |
| target triple | `wasm32-wasip1` (`wasm32-wasi` is deprecated) | — |
| Wasmtime C API | v45.0.1 (prebuilt x86_64-linux release) | `/opt/wasmtime` |
| WAMR (rejected) | WAMR-2.4.4, built from source | `/opt/wamr` |
| cmake / ninja | 3.31.6 / 1.12.1 (apt) | — |
## Runtime selection: why not WAMR
WAMR was tried first per §9 ("preferred ... use Wasmtime only if blocked").
We are blocked, on the load-bearing requirement itself:
1. **WAMR's wasm-c-api ignores imported memories and tables.** At unit
instantiation it logs `"doesn't support import memories and tables for
now, ignore them"` (`wasm_c_api.c`) and gives the instance its own
memory/table — which silently destroys the shared-workspace model.
2. **Host-side `wasm_table_grow` / `wasm_memory_grow` are explicitly
unsupported** ("Only allow growing a table via the opcode table.grow").
3. Its build banner lists *Import/Export of Mutable Globals* as unsupported —
the dylink ABI imports `__stack_pointer` and every `GOT.*` entry as a
mutable global.
Its multi-module feature is name-based auto-resolution, not host-orchestrated
dylink (no host-computed `__memory_base`/`__table_base`, no GOT). Making WAMR
fit means implementing import binding through the c-api layer and runtime
internals — a runtime-development project, not a patch.
**Wasmtime v45.0.1 passed everything on the first run** through the standard
`wasm.h` C API: host-created funcref table shared by both instances, exported
memory imported by the unit, host-created (mutable) globals, cross-instance
export→import wiring. The remaining §9 criteria also favor it: AOT artifacts
(`.cwasm` precompilation) for the unit cache, epoch interruption for CPU
limits, and built-in copy-on-write memory-image instantiation for the §6 core
snapshot (machinery we'd have had to build ourselves on WAMR).
Trade-off accepted (was already in §10): Rust codebase, heavier to
vendor/patch. Pin the release artifact (lib + headers, checksummed) the way
sqlite is vendored; building from source stays possible but is not the
default path. The C API .so is ~27 MB.
## Module build recipe (what `build_modules.sh` settled on)
Core (non-PIC reactor, owns libc/libc++/allocator):
```
clang++ --target=wasm32-wasip1 -mexec-model=reactor -O1 -fno-exceptions \
core.cpp -o core.wasm \
-Wl,--export-all -Wl,--import-table \
-Wl,--export=__stack_pointer -Wl,--export=__heap_base \
-Wl,--undefined=_ZTVN10__cxxabiv117__class_type_infoE
```
Unit (PIC side module):
```
clang++ --target=wasm32-wasip1 -fPIC -fvisibility=default \
-fvisibility-inlines-hidden -O1 -fno-exceptions -c unit.cpp
wasm-ld -shared --experimental-pic --unresolved-symbols=import-dynamic \
--Bsymbolic unit.o -o unit.wasm --export=<entry>
```
Hard-won flag findings:
1. **`--unresolved-symbols=import-dynamic`** is required for the side-module
link; undefined symbols then become `env.*` function imports and `GOT.*`
globals exactly per the Emscripten dylink ABI.
2. **`-fvisibility-inlines-hidden` is mandatory.** Without it one libc++
vague-linkage lambda (`std::map` tree-emplace internals, missing libc++'s
usual hide-from-ABI attribute) is emitted as *both* an export and an
import of the unit — a self-import the loader cannot satisfy at
instantiation time without lazy-binding trampolines. `--Bsymbolic` alone
did **not** bind it.
3. **Core symbol closure**: `--export-all` only exports what got *linked*.
The unit needed `__cxxabiv1::__class_type_info`'s vtable (RTTI machinery
behind `std::function`), which the core never references — forced in with
`--undefined=`. The production core needs a closure strategy:
`--whole-archive` for libc/libc++/libc++abi, or a curated keep-list. The
loader also implements the complementary fallback (resolve `GOT.mem` of
weak data from the unit's *own* exports post-instantiation, patching the
provisional GOT global).
4. **`--import-table` on the core** + a **host-created table** is the right
shape (see loader notes); `--export-table`/`--growable-table` was the
first attempt and died on WAMR's host-grow limitation, but host-created
stays the better design under Wasmtime too: the loader picks table size
(core's declared minimum + headroom) before any instantiation.
5. `wasm32-wasi` triple is deprecated in wasi-sdk 33 → use `wasm32-wasip1`.
## Loader notes (`loader.cpp`, ~450 lines, standard wasm-c-api)
Sequence proven: instantiate core (45 WASI imports satisfied with named trap
stubs — none was ever called) → parse `dylink.0` (`mem_info`: memsize/align,
tablesize) → `__memory_base` = call core's exported `malloc``__table_base`
= bump pointer starting at core's table-import minimum → build the unit's
import vector (memory/table/`__stack_pointer` shared from core; `env.*`
functions from core exports; `GOT.mem.*` as host mutable i32 globals holding
addresses read from core's exported data-symbol globals) → instantiate →
patch deferred GOT entries → `__wasm_apply_data_relocs``__wasm_call_ctors`
→ call the entry export.
- **Erratum (found in Phase 3): self-resolved `GOT.mem` values must add
`__memory_base`.** A PIC module's exported data symbols are i32 globals
holding offsets *relative to its `__memory_base`*, not absolute addresses —
the linker adds the base when patching deferred GOT entries (there is no
`__wasm_apply_global_relocs` export to do it). Copying the export verbatim
reads/writes core memory at low addresses and renders silently wrong values;
the Phase 3 fixture's `self-got`/`callback` markers exist to catch exactly
this. `GOT.mem` entries resolved from the *core's* exports are absolute
already (the core is non-PIC) and need no adjustment.
- **GOT.func is resolved guest-side**: the core exports a helper returning
`(intptr_t)&func` — taking the address forces a link-time elem entry and a
wasm function pointer *is* its table index. No host-side funcref injection
is needed at all (it was WAMR-unsupported; under Wasmtime it would work but
the guest-side registry is simpler and runtime-agnostic). The production
core should carry a name→funcptr registry (dlsym-shaped) for its API
surface.
- **wasi-libc gotcha**: `_initialize` has a double-init guard ending in
`__builtin_trap()`. WAMR runs `_initialize` automatically at instantiation
(so calling it again traps "unreachable"); Wasmtime does not (so you must
call it). Cost one debugging round; recorded here so it never costs another.
- Export-name `wasm_name_t` may include the trailing NUL in `size` (WAMR
did); trim when indexing exports by name.
## Real generated units (delegated grind — full log in `realunit-report.md`)
`site/demo/collections.uce.cpp` and `hello.uce.cpp` (taken verbatim from the
live unit cache at `/tmp/uce/work/...`) both compile and link as PIC side
modules with `dylink.0`, **no allocator definitions**, with only shim-level
intervention. `collections.wasm`: 42 KB, 52 imports — including exactly the
predicted `GOT.mem.context` for the global `Request*`. Friction points that
become Phase 2 work items:
1. **`types.h` defines global `operator new/delete` in every unit** — must be
gated (`#ifdef`) out of side-module builds; allocator ownership belongs to
the core (§3.2: "the one fatal misconfiguration").
2. **`sys.h` includes `<signal.h>`** → wasi needs `-D_WASI_EMULATED_SIGNAL`
(+ `-lwasi-emulated-signal` in the core) or an `#ifdef __wasm__` carve-out;
signals/fork/exec/sockets in `sys.h` have no wasi equivalent and move
behind hostcalls anyway (§5.1).
3. **Generated units include `uce_lib.h` by absolute path** — the
preprocessor should emit a logical include so the wasm build can supply
its own include order.
4. **Header-inline connector wrappers (MySQL etc.) get pulled into every
unit** regardless of use; the §3.3 membrane split (thin wasm-side shim,
host-side implementation) resolves this and shrinks unit import lists.
5. The real-unit compile used the pre-`-fvisibility-inlines-hidden` flag set
(parallel work); the final unit flag set above should be used from
Phase 2 on.
## Implications for the next phases
- **Phase 1 (DValue C ABI, native)**: unaffected by any of this; proceed as
written.
- **Phase 2 (core module + membrane)**: add the closure strategy
(whole-archive), the GOT.func name→funcptr registry, the `types.h`
allocator gate, the signal emulation define, and the preprocessor include
change. Compile `uce_lib` with the core recipe above.
- **Phase 3 (loader)**: `loader.cpp` here is the skeleton — dylink parsing,
base allocation, GOT resolution, and init sequencing are all proven; what
remains is the registry/dispatch layer, ABI stamping, and multi-unit
placement.
- **Phase 4**: use Wasmtime's epoch interruption for CPU limits and its
memory-image/CoW instantiation for the core snapshot rather than building
either by hand.
## Artifacts (on k-uce, not in git)
- `/tmp/uce/wasm-phase0/{core.wasm,unit.wasm,loader}` — exit-criterion run
- `/tmp/uce/wasm-phase0/realunit/` — real-unit compiles + shim tree + inspector dumps
- `/opt/wasi-sdk`, `/opt/wasmtime`, `/opt/wamr` — toolchains/runtimes
+15
View File
@@ -0,0 +1,15 @@
[Unit]
Description=UCE FastCGI Server
Wants=network.target
After=syslog.target network-online.target
[Service]
Type=simple
ExecStart=/opt/uce/bin/uce_fastcgi.linux.bin
Restart=on-failure
RestartSec=10
KillMode=mixed
[Install]
WantedBy=multi-user.target
+82
View File
@@ -0,0 +1,82 @@
# UCE WORKING DIRECTORIES
BIN_DIRECTORY=/var/cache/uce/work
TMP_UPLOAD_PATH=/var/lib/uce/uploads
SESSION_PATH=/var/lib/uce/sessions
# LISTEN ON SOCKETS
FCGI_SOCKET_PATH=/run/uce/fastcgi.sock
FCGI_PORT=9993
# HTTP-over-Unix command socket for local CLI/control tooling.
# Example: curl --unix-socket /run/uce/cli.sock http://localhost/ping
CLI_SOCKET_PATH=/run/uce/cli.sock
# OPTIONAL PROACTIVE COMPILE ROOT
# Leave empty to scan SITE_DIRECTORY relative to the runtime root.
PRECOMPILE_FILES_IN=
# PUBLIC SITE DIRECTORY USED FOR STARTUP SCAN WHEN PRECOMPILE_FILES_IN IS EMPTY
SITE_DIRECTORY=site
# ENABLE JIT COMPILATION WHEN A PAGE REQUEST HITS A STALE OR MISSING UNIT
JIT_COMPILE_ON_REQUEST=1
# OPTIONAL W2 WEBASSEMBLY SIDE-MODULE COMPILATION BESIDE NATIVE .so UNITS
COMPILE_WASM_UNITS=0
WASM_COMPILE_SCRIPT=scripts/compile_wasm_unit
# DEFAULT PAGE RENDER BACKEND. W5 defaults to the WASM backend with explicit
# native fallbacks for host-owned surfaces that are not membrane APIs yet.
WASM_BACKEND_ENABLED=1
WASM_BACKEND_VERBOSE=0
WASM_CORE_PATH=/Code/uce.openfu.com/uce/bin/wasm/core.wasm
WASM_MEMORY_LIMIT_BYTES=536870912
WASM_EPOCH_DEADLINE_TICKS=200
WASM_EPOCH_PERIOD_MS=50
# ENABLE THE BACKGROUND PROACTIVE COMPILER LOOP
PROACTIVE_COMPILE_ENABLED=1
# AFTER A FAILED COMPILE, UCE NOW REUSES THE PERSISTED COMPILER OUTPUT UNTIL
# THE SOURCE OR COMPILER INPUTS CHANGE. THIS SETTING IS KEPT FOR COMPATIBILITY.
COMPILE_FAILURE_RETRY_SECONDS=10
# PERIODIC KNOWN-.uce RECHECK INTERVAL IN SECONDS
PROACTIVE_COMPILE_CHECK_INTERVAL=60
# SPAWN WORKERS
WORKER_COUNT=4
# MAX MEMORY PER REQUEST
MAX_MEMORY=16777216
# TRANSPORT / DOS LIMITS
TRANSPORT_MAX_CLIENT_CONNECTIONS=256
TRANSPORT_MAX_HTTP_HEADER_BYTES=16384
TRANSPORT_MAX_HTTP_BODY_BYTES=1048576
TRANSPORT_MAX_WEBSOCKET_FRAME_BYTES=1048576
TRANSPORT_MAX_WEBSOCKET_MESSAGE_BYTES=1048576
TRANSPORT_MAX_WEBSOCKET_OUTPUT_BYTES=4194304
TRANSPORT_MAX_RESPONSE_BYTES=8388608
TRANSPORT_HTTP_REQUEST_TIMEOUT_SECONDS=15
TRANSPORT_CONNECTION_IDLE_TIMEOUT_SECONDS=120
# Empty means COMPILER_SYS_PATH for the built-in direct HTTP listener.
HTTP_DOCUMENT_ROOT=
# CUSTOM SERVER LIMITS
CUSTOM_SERVER_MAX_SERVERS=16
CUSTOM_SERVER_MIN_PORT=1024
CUSTOM_SERVER_MAX_PORT=65535
CUSTOM_SERVER_ALLOW_PUBLIC_BIND=0
CUSTOM_SERVER_UNIX_SOCKET_PREFIX=/tmp/uce/custom-servers/
CUSTOM_SERVER_HANDLER_TIMEOUT_SECONDS=30
# Empty means COMPILER_SYS_PATH/SITE_DIRECTORY.
CUSTOM_SERVER_UCE_ROOT=
# ARCHIVE HELPER LIMITS
ARCHIVE_MAX_INPUT_BYTES=67108864
ARCHIVE_MAX_OUTPUT_BYTES=67108864
ARCHIVE_MAX_ZIP_ENTRIES=4096
# LIFETIME OF SESSION COOKIES IN SECONDS
SESSION_TIME=2592000
+31
View File
@@ -0,0 +1,31 @@
#!/bin/bash
# Build the production W1 UCE WASM core from the real runtime carve-out.
# Run on k-uce from any working directory.
set -euo pipefail
cd "$(dirname "$0")/.."
SDK=${WASI_SDK:-/opt/wasi-sdk}
OUT=${UCE_WASM_OUT:-/tmp/uce/wasm-w1}
mkdir -p "$OUT" bin/wasm
if [ ! -x "$SDK/bin/clang++" ]; then
echo "wasi-sdk clang++ not found; set WASI_SDK" >&2
exit 1
fi
"$SDK/bin/clang++" --target=wasm32-wasip1 -mexec-model=reactor \
-O1 -g -std=c++20 -fno-exceptions -fno-rtti \
-D__UCE_WASM_CORE__ \
-I. -Isrc/lib \
src/wasm/core.cpp -o "$OUT/core.wasm" \
-Wl,--export-all \
-Wl,--export=__heap_base \
-Wl,--export=__stack_pointer \
-Wl,--import-table \
-Wl,-z,stack-size=8388608 \
-Wl,--allow-undefined-file=src/wasm/core_hostcalls.syms \
-Wl,--no-entry \
$(sed "s/^/-Wl,--export-if-defined=/" src/wasm/core_libc_exports.syms | tr "\n" " ")
cp "$OUT/core.wasm" bin/wasm/core.wasm
ls -lh "$OUT/core.wasm" bin/wasm/core.wasm
+45
View File
@@ -0,0 +1,45 @@
#!/bin/bash
cd "$(dirname "$0")"
cd ..
BUILDMODE=${2:-"debug"}
OPT_FLAG="O0"
GF="uce_fastcgi"
mkdir bin > /dev/null 2>&1
mkdir bin/tmp > /dev/null 2>&1
mkdir bin/assets > /dev/null 2>&1
mkdir work > /dev/null 2>&1
COMPILER="clang++"
FLAGS="-g -rdynamic -w -Wall -$OPT_FLAG -std=c++20 -fpermissive -ffast-math"
# Wasmtime C API for the W4 wasm backend (src/wasm/backend.cpp).
WASMTIME_HOME=${WASMTIME_HOME:-/opt/wasmtime}
WASM_FLAGS="-I$WASMTIME_HOME/include"
WASM_LIBS="-L$WASMTIME_HOME/lib -Wl,-rpath,$WASMTIME_HOME/lib -lwasmtime"
LIBS="-ldl -lm -lpthread -lpcre2-8 `mysql_config --cflags --libs` $WASM_LIBS"
SRCFLAGS="-D EXEC_NAME=\"$GF\" -D PLATFORM_NAME=\"linux\" $WASM_FLAGS"
echo "Compiling SQLite..."
clang -g -O2 -fPIC \
-DSQLITE_THREADSAFE=1 \
-DSQLITE_OMIT_LOAD_EXTENSION=1 \
-DSQLITE_DQS=0 \
-DSQLITE_DEFAULT_FOREIGN_KEYS=1 \
-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 \
-c src/3rdparty/sqlite/sqlite3.c -o bin/sqlite3.o 2>&1
if [ $? -ne 0 ]; then exit 1; fi
echo "Compiling executable..."
time -p $COMPILER src/linux_fastcgi.cpp bin/sqlite3.o $SRCFLAGS $FLAGS $LIBS -o bin/$GF.linux.bin 2>&1
if [ $? -eq 0 ]
then
ls -lh bin/ | grep $GF
exit 0
else
exit 1
fi
+8 -2
View File
@@ -9,6 +9,8 @@ SRC_FN="$3"
PP_FN="$4"
SO_FN="$5"
LINK_OBJECTS="$6"
#echo "Source Dir: $SRC_DIR"
#echo "Dest Dir: $DEST_DIR"
#echo "Source File: $SRC_FN"
@@ -24,14 +26,18 @@ OPT_FLAG="O0"
COMPILER="clang++"
#COMPILER="g++"
FLAGS="-shared -g -rdynamic -w -Wall -$OPT_FLAG -std=c++17 -fpermissive -ffast-math -fPIC"
FLAGS="-shared -g -rdynamic -w -Wall -$OPT_FLAG -std=c++20 -fpermissive -ffast-math -fPIC -Isrc/lib"
LIBS="-ldl -lm -lpthread "
LIBS="-ldl -lm -lpthread"
SRCFLAGS="-D PLATFORM_NAME=\"linux\""
# echo "Compliling executable..."
$COMPILER "$DEST_DIR/$PP_FN" $SRCFLAGS $FLAGS $LIBS -o "$DEST_DIR/$SO_FN"
# separate .o file
#$COMPILER -c "$DEST_DIR/$PP_FN" $SRCFLAGS $FLAGS $LIBS -o "$DEST_DIR/$PP_FN.o"
#$COMPILER "$DEST_DIR/$PP_FN.o" "$LINK_OBJECTS" $SRCFLAGS $FLAGS $LIBS -o "$DEST_DIR/$SO_FN"
if [ $? -eq 0 ]
then
# ls -lh "$DEST_DIR"
+97
View File
@@ -0,0 +1,97 @@
#!/bin/bash
# Compile a preprocessed UCE unit into a PIC WebAssembly side module.
set -euo pipefail
cd "$(dirname "$0")"
cd ..
SRC_DIR="$1"
DEST_DIR="$2"
SRC_FN="$3"
PP_FN="$4"
WASM_FN="$5"
SDK=${WASI_SDK:-/opt/wasi-sdk}
ABI_VERSION=${UCE_UNIT_ABI_VERSION:-6}
ROOT=$(pwd)
OBJ_FN="$DEST_DIR/$PP_FN.wasm.o"
ABI_TMP="$DEST_DIR/$PP_FN.uce-abi.txt"
PCH_ENABLED=${UCE_WASM_UNIT_PCH:-1}
PCH_DIR=${UCE_WASM_PCH_DIR:-/tmp/uce/wasm-w2/pch}
COMMON_FLAGS=(
--target=wasm32-wasip1
-fPIC -fvisibility=default -fvisibility-inlines-hidden
-O1 -g -std=c++20
# -w as in scripts/compile: warnings are not failures. The server captures
# this script's output and treats any non-empty result as a compile failure
# (then drops the .wasm), so a successful build must be silent.
-w
# must match the core build ABI: units with RTTI/EH enabled import
# typeinfo/unwind symbols the -fno-rtti/-fno-exceptions core cannot provide
-fno-exceptions -fno-rtti
-D__UCE_WASM_UNIT__
-DPLATFORM_NAME=\"wasm32-wasip1\"
)
if [ ! -x "$SDK/bin/clang++" ] || [ ! -x "$SDK/bin/wasm-ld" ] || [ ! -x "$SDK/bin/llvm-objcopy" ]; then
echo "wasi-sdk tools not found; set WASI_SDK" >&2
exit 1
fi
TOOLCHAIN_ID=$(${SDK}/bin/clang++ --version | head -n 1)
HEADER_HASH=$(find src/lib -maxdepth 1 -name '*.h' -type f -print0 | sort -z | xargs -0 sha1sum | sha1sum | cut -c1-16)
FLAGS_HASH=$(printf '%s\0' "${COMMON_FLAGS[@]}" -Isrc/lib | sha1sum | cut -c1-16)
PCH_KEY=$(printf '%s\n%s\n%s\n%s\n' "$ABI_VERSION" "$TOOLCHAIN_ID" "$HEADER_HASH" "$FLAGS_HASH" | sha1sum | cut -c1-16)
PCH_FN="$PCH_DIR/uce_lib-wasm-unit-$PCH_KEY.pch"
mkdir -p "$DEST_DIR" >/dev/null 2>&1
build_pch_if_needed() {
if [ "$PCH_ENABLED" = "0" ]; then
return 0
fi
mkdir -p "$PCH_DIR"
if [ -s "$PCH_FN" ]; then
return 0
fi
"$SDK/bin/clang++" "${COMMON_FLAGS[@]}" \
-Isrc/lib \
-x c++-header src/lib/uce_lib.h -o "$PCH_FN.tmp"
mv "$PCH_FN.tmp" "$PCH_FN"
}
cat > "$ABI_TMP" <<EOF
format=uce-wasm-unit-abi-v1
unit_abi_version=$ABI_VERSION
toolchain=$TOOLCHAIN_ID
source=$SRC_FN
EOF
build_pch_if_needed
PCH_FLAGS=()
if [ "$PCH_ENABLED" != "0" ]; then
PCH_FLAGS=(-include-pch "$PCH_FN")
fi
"$SDK/bin/clang++" "${COMMON_FLAGS[@]}" \
-I"$SRC_DIR" -I"$ROOT/src/lib" \
"${PCH_FLAGS[@]}" \
-c "$DEST_DIR/$PP_FN" -o "$OBJ_FN"
"$SDK/bin/wasm-ld" -shared --experimental-pic \
--unresolved-symbols=import-dynamic \
--Bsymbolic \
"$OBJ_FN" -o "$DEST_DIR/$WASM_FN" \
--export-if-defined=__uce_set_current_request \
--export-if-defined=__uce_render \
--export-if-defined=__uce_component \
--export-if-defined=__uce_websocket \
--export-if-defined=__uce_cli \
--export-if-defined=__uce_serve_http \
--export-if-defined=__uce_once \
--export-if-defined=__uce_init
"$SDK/bin/llvm-objcopy" --add-section=uce.abi="$ABI_TMP" "$DEST_DIR/$WASM_FN"
python3 scripts/wasm/check_unit_wasm.py "$DEST_DIR/$WASM_FN" --abi-version "$ABI_VERSION" --llvm-nm "$SDK/bin/llvm-nm"
rm -f "$OBJ_FN" "$ABI_TMP"
+1
View File
@@ -0,0 +1 @@
/etc/uce/settings.cfg

Some files were not shown because too many files have changed in this diff Show More