<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="/feed.xsl" type="text/xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Locria&apos;s info dump</title>
  <link rel="alternate" href="https://www.1a-insec.net/blog/"/>
  <link rel="self" href="https://www.1a-insec.net/all.atom.xml"/>
  <updated>2025-12-30T12:00:00Z</updated>
  <author>
    <name>Locria Cyber</name>
  </author>
  <id>urn:uuid:629b78bb-c1f9-4868-ab5b-3ff5c013575a</id>
  <icon>/images/favicon.webp</icon>

  <entry>
    <id>https://www.1a-insec.net/blog/19-reactive-signal-and-build-system/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/19-reactive-signal-and-build-system/"/>
    <title>Reactive Signals and Build System</title>
    <published>2023-09-28T12:00:00Z</published>
    <updated>2025-08-11T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/19-reactive-signal-and-build-system/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>I have made <strong>libredo</strong>, a Zig library for dependency tracking. <a href="https://codeberg.org/iacore/libredo">The source code is here.</a></p>
<h2>The Story</h2>
<p>A few months ago, I stumbled upon <a href="https://www.solidjs.com/">SolidJS</a> and liked it for its well-designed &#x201c;reactive signals&#x201d; API. It did make me wonder if I can port such a library to Zig and write Solid-like UI code with it.</p>
<p>A week ago, I began porting such a &#x201c;reactive signals&#x201d; library to Zig. I chose <a href="https://github.com/jbreckmckye/trkl">trkl</a> as my reference, since it has only a few lines of code. trkl uses a lot of closures internally, and it demands the language (Javascript) to have a garbage collector. Zig has neither of those two features, so it&#x2019;s time to improvise.</p>
<p>It took a week of me sleeping on the idea to know how to design the library&#x2019;s public interface.</p>
<p>I wasted another two days searching for a fast-enough core algorithm for the library. Initially, I tried using an array to store edges of the dependency graph unordered. It was too slow. On the second try, I used two hashmaps of hashsets, but that was slower. &#x201c;This is not working out well,&#x201d; I thought to myself, &#x201c;time to <s>steal</s> learn ideas from other people.&#x201d;</p>
<p>At first, I did not know what to learn from. Suddenly, a thought struck me:  build systems have similar goals as this &#x201c;reactive signals&#x201d; thing &#x2013; they keep track of dependency between tasks, and invalidate a build target when any of its sources change. &#x201c;I can probably learn from build systems,&#x201d; I thought.</p>
<p>I consulted <a href="https://gittup.org/tup/">tup</a>. It does not support dynamic dependencies &#x2013; not useful. I then consulted <a href="https://github.com/apenwarr/redo">redo</a>, since I remembered it supports individual tasks declaring dependencies while running. That was an exact hit &#x2013; so exact, that the dependency tracking algorithm used by redo and Solid are the same! The data structure in redo was provided by SQLite. Although I can&#x2019;t copy SQLite&#x2019;s code, so I mimicked the SQLite table and used an array to store edges of the graph <strong>sorted</strong>. It works, and is fast enough. Mission Accomplished.</p>
<p>That&#x2019;s the story of how I made libredo.</p>
<h2>The Algorithm</h2>
<p>Here&#x2019;s my futile attempt at explaining the dependency tracking algorithm.</p>
<p>Every non-leaf (&#x201c;not source file&#x201d;) task has a dirty bit. The bit is set when the task is created. If the task is dirty, run it, and remember its dependencies (used during the run). If the task is not dirty, it is up-to-date, so don&#x2019;t run it. When any source file changes, mark its recursive dependents as dirty.</p>
<p>The algoritm doesn&#x2019;t care about how to do any task. When a task is dirty, the user provides what new dependencies the task will have, and mark the task as clean (the user usually does this after <strong>doing the task</strong>, like building an executable file). The user can also choose to keep the task dirty, and not do anything immediately (or ever).</p>
<p>Here are two examples from Solid and redo respectively. The two examples are isomorphic to each other. You need knowledge of Solid or redo to understand the examples. In both examples, the act of &#x201c;<strong>doing the task</strong>&#x201d; is done by running some code the user provides. In the Solid example, dependency is tracked automatically. In the redo example, the dependencies are declared explicitly with <code>redo-ifchange</code>. My library provides API for both styles (please read the source code, it&#x2019;s somewhat commented).</p>
<h3>Example 1: Solid</h3>
<pre><code class="language-js">import {createSignal, createMemo} from &apos;solid-js&apos;
const [a, setA] = createSignal(0)
const [b, setB] = createSignal(1)
const c = createMemo(() =&gt; a() + b())

c()      // line 1
c()      // line 2
setA(2)  // line 3
c()      // line 4
</code></pre>
<h3>Example 2: redo</h3>
<p>First, create the shell script <code>main.do</code> with the following content.</p>
<pre><code class="language-shell">redo-ifchange main.c aux.c
gcc -o main main.c aux.c
</code></pre>
<p>Then run the following shell script:</p>
<pre><code class="language-shell">redo-ifchange main  # line 1
redo-ifchange main  # line 2
touch main.c        # line 3
redo-ifchange main  # line 4
</code></pre>
<h3>Explanation</h3>
<p>I&#x2019;ll use the task names <code>a</code>, <code>b</code>, <code>c</code> from Example 1 in this explanation. It applies to Example 2 when you change the names to <code>main.c</code>, <code>aux.c</code>, <code>main</code>. Mathematically, the names are irrelevant.</p>
<p>In the following graphs, arrows point from dependent to dependency.</p>
<p>Initially, the dependency graph looks like this:</p>
<p><img src="initial.png" alt=""/></p>
<p><code>c</code> is dirty because it was just created. Nothing is connected yet.</p>
<p>At line 1, <code>c</code> is run because it is dirty. When <code>c</code> runs, the algorithm notes that <code>c</code> uses <code>a</code> and <code>b</code>, and remembers that.<br/>
The graph looks like this afterwards:</p>
<p><img src="after-line-1.png" alt=""/></p>
<p>At line 2, nothing is run, because <code>c</code> is not dirty.<br/>
The graph afterwards:</p>
<p><img src="after-line-1.png" alt=""/></p>
<p>At line 3, <code>a</code> is changed. The algorithm marks recursive dependents of <code>a</code> (in this case, only <code>c</code>) as dirty.<br/>
The graph afterwards:</p>
<p><img src="after-line-3.png" alt=""/></p>
<p>At line 4, <code>c</code> is run because it is dirty. When <code>c</code> runs, the algorithm notes that <code>c</code> uses <code>a</code> and <code>b</code>, and remembers that. (In this example, the direct dependencies of <code>c</code> don&#x2019;t change. Nevertheless, the algorithm remembers <code>c</code>&#x2019;s &#x201c;new&#x201d; dependencies.)<br/>
The graph afterwards:</p>
<p><img src="after-line-1.png" alt=""/></p>
<h2>My Thoughts On This</h2>
<p>This seems like another case of a mathematical concept independently discovred twice. It surprised me that I don&#x2019;t know other kinds of software that uses this algorithm (apart from build systems, and recently, Web UI), given that the algorithm is very useful for any application related to caching. Maybe I just don&#x2019;t know enough software.</p>
<p>I feel that this algorithm may be adapted to work across multiple machines. Personally, I don&#x2019;t need this feature. If you know such a thing exists, tell me!</p>
<p>I also don&#x2019;t know if this algorithm has a name. If you know, tell me!</p>
<p>Update: <a href="https://nikhilism.com/">Nikhil</a> said that this field is called &#x201c;incremental computation&#x201d;.</p>
<p>Update: <a href="https://a-rx.info/">Andreas Reuleaux</a> said that <a href="https://git.sr.ht/~autumnull/haredo">haredo</a> is a viable alternative to redo.</p>
<p>Update (2025-08-11): Solid has other nice features like <code>createEffect</code> and replay events between page load and hydration (which React, to this day, neglects). Its  dependency tracking system has not changed since then.</p>
<p>Notable mentions:</p>
<ul>
<li><a href="https://github.com/vobyjs/voby">voby</a> &#x2013; Observable-based reactive system + web framework with same math behind it</li>
<li><a href="https://github.com/actioncrew/streamix">streamix</a> &#x2013; lightweight observable library</li>
</ul>
<p>Note that Solid effects only happen within a microtask. During successive updates to a signal, only the last state will be observed. This is different from Observable.</p>
<p>Solid <a href="https://docs.solidjs.com/concepts/understanding-jsx">JSX</a> and <a href="https://docs.solidjs.com/reference/jsx-attributes/classlist">JSX attributes</a> have much magic built into it. Hopefully, your HTML knowledge will transfer to JSX without a problem. If you come from other frameworks using JSX, then you need to learn it properly.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/18-janet-as-database/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/18-janet-as-database/"/>
    <title>Using Janet as Database</title>
    <published>2024-07-05T12:00:00Z</published>
    <updated>2024-07-05T12:00:00Z</updated>
    <category term="comp"/>
    <category term="lang:Janet"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/18-janet-as-database/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <blockquote>
<p><mark>You must clone <a href="https://git.envs.net/iacore/chargrid">this repo</a></mark> and read it together with this article. Otherwise you won&#x2019;t understand this article.</p>
<p>Two branches of the repo are of importance.</p>
<ul>
<li>branch <code>sqlite</code>: the version that uses SQLite3 for persistence</li>
<li>branch <code>janet</code>: the version that uses Janet for persistence</li>
</ul>
</blockquote>
<p>A few days ago, I was testing out writing HTTP application in Zig, with <a href="https://htmx.org/">htmx</a>. (unrelated: htmx is very good)</p>
<p>When I added persistency to the project, at first I chose SQLite. It worked. However sqlite-interfacing code felt like too &#x201c;loose and moving&#x201d; in the whole project. It felt flaky.</p>
<p>In pursuit of mathematical soundness, I swapped out SQLite with <a href="https://janet-lang.org/">Janet</a>. The result is pleasing to me, so I wrote about it here.</p>
<p>Here&#x2019;s how I used Janet the programming language as database of my toy application.</p>
<h2>Query and Data Model</h2>
<p>When using Janet as a database, the programming language itself is the query language.</p>
<p>Since the application is a simple counter, I used <code>(def stuff {:counter 0})</code>.</p>
<p>To get the data, I used <code>(stuff :counter)</code>. To set the data, I used <code>(set (stuff :counter) 1)</code>.</p>
<p>If the data model of your application is more complex, then I highly recommend reading <a href="https://janet-lang.org/docs/data_structures/index.html">the official Janet documentation</a>. I also wrote <a href="../16-buy-janet-get-gc-free/">another article</a> to describe how to mix Zig data and Janet data.</p>
<h2>Persistence</h2>
<p>To save data, I simply used the POSIX file-system.</p>
<p>First, I used the Zig API <code>janet.marshal</code> to serialize <code>stuff</code> to a string. The string is then saved in a file with the following steps.</p>
<ul>
<li>create file <code>database~</code> with exclusive lock (<code>man 2 open</code>)</li>
<li>write data</li>
<li>fsync (<code>man 2 fsync</code>)</li>
<li>rename/link file to <code>database</code> (<code>man 2 link</code>) This step is atomic.</li>
</ul>
<blockquote>
<p>P.S. fdatasync on Linux doesn&#x2019;t flush change to file size (see <code>man 2 fdatasync</code>)</p>
</blockquote>
<p>To read the data, I did the opposite with <code>janet.unmarshal</code>.</p>
<p>The most important different of Janet from SQL database is that you can serialize cyclic data and <a href="https://janet-lang.org/docs/functions.html">functions</a>! By using direct reference to objects, we avoid SQL <code>JOIN</code> hell. In a sense, Janet is a <a href="https://en.wikipedia.org/wiki/Network_model">network database</a>.</p>
<p>In Janet REPL, the database can be loaded from disk with <code>(unmarshal (slurp &quot;database&quot;))</code>. This is useful for debugging, or to play around with the data.</p>
<h2>Why use SQLite then</h2>
<p><strong>Persistence performance.</strong> I haven&#x2019;t benchmarked this yet, but I assume that SQLite is faster, as it won&#x2019;t write the whole database to file every time it needs to persist stuff.</p>
<p><strong>Query performance.</strong> I don&#x2019;t believe this is a problem. Many people write network-facing applications in Python. Janet is as fast as CPython, so it should be ok. If I hit a performance bottleneck here, I would rather use <a href="https://github.com/dzaima/CBQN">BQN</a> or <a href="https://github.com/pola-rs/polars">Polars</a> than SQL, or I can rewrite that part in Zig.</p>
<p><strong>Type check.</strong> SQL has built-in type check. Janet can do this too with built-in functions, and the data model is not restricted to match relational algebra.</p>
<h2>What can be improved</h2>
<p>To save disk space, a key-value database can be used instead of storing multiple &lt;4kb files. From <a href="https://github.com/python/cpython/blob/3.11/Lib/shelve.py">the source code</a> of <a href="https://docs.python.org/3/library/shelve.html">Python&#x2019;s shelve module</a>, <code>shelve</code> uses a <a href="https://www.gnu.org.ua/software/gdbm/gdbm.html">gdbm</a> for backing storage, which is a key-value database.</p>
<p>To store cyclic data without pain, we need GC. This is the case for database as well (if it supports auto-delete either/both nodes of an edge if the edge was deleted (in graph database)). With some effort, maybe I can hack Janet and dbm together, so that they share the same GC.</p>
<p>With Zig&#x2019;s explicit allocator design and compile-time code execution, it is possible to &#x201c;relocate&#x201d; nested structures into the same place by replacing pointers with relative offset. It works like a moving GC but without GC. With some effort, maybe I can add cyclic support to <a href="https://github.com/ziglibs/s2s">s2s</a>. The downside of this is, of course, potential footgun from moving memories around.</p>
<h2>Finishing Thoughts</h2>
<p>For the past few years, there was this popular business practice where they make a new database out of nowhere and call it something new. Here are some examples:</p>
<ul>
<li>create a new query language that is better than SQL but still bad, and implement a new database (surreal)</li>
<li>add a new algorithm to SQL, and implement a new database (one of those &#x201c;machine learning&#x201d; databases)</li>
<li>use Prolog syntax for relational algebra, and implement a new database (cozo)</li>
</ul>
<p>Since I am affine to data, those &#x201c;products&#x201d; are very confusing to me. Here&#x2019;s what I observed in practice:</p>
<ul>
<li>the fastest way to store and process data is to store it in memory and process it with compiled code (Rust, Zig, whatever)</li>
<li>using a key-value database like lmdb need ~10x time of above</li>
<li>using a relational database need ~10x time of above</li>
<li>if the system needs to fetch data across network, there is relatively no performance</li>
</ul>
<p>I don&#x2019;t know how Janet fit in this performance scale, as I haven&#x2019;t used it as database before.</p>
<p>Again, I am in awe of how useful Janet is. It is the same feeling I got when I first learned that a Lua file can act as a configuration file &#x2013; &#x201c;code as data&#x201d;.</p>
<h2><a href="https://linux.die.net/man/2/sync_file_range">sync_file_range(2)</a> on Linux (Update: 2024-07-05)</h2>
<p>A friend had trouble with a database, which prompted me to review the syscalls regarding file writes again.</p>
<p>The default behavior of file writes on POSIX systems is as follows:</p>
<ul>
<li>If you call fdatasync(2), the data is written to disk immediately</li>
<li>Otherwise, the data is written to disk <strong>eventually</strong></li>
</ul>
<p>How late is &#x201c;eventually&#x201d;? Don&#x2019;t know. The kernel should provide a consistent view of files, so fdatasync(2) is not necessary for processes to understand each other. fdatasync(2) is for when the kernel unexpectly exits.</p>
<p>Linux has io_uring. You can send write(2) syscalls in parallel. fdatasync(2) and fsync(2), however, only works per file descriptor. If you want multiple write groups to happen in parallel, you need to have multiple file descriptors.</p>
<p>With sync_file_range(2), you can have effectively infinite many write groups with only one file descriptor. It&#x2019;s only available on Linux, though.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/17-bind-source-code-together/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/17-bind-source-code-together/"/>
    <title>Binding Source Code Files Together Like A Book</title>
    <published>2023-08-31T12:00:00Z</published>
    <updated>2023-12-02T12:00:00Z</updated>
    <category term="comp"/>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/17-bind-source-code-together/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <blockquote>
<p>A book unbound is hard to read. A folder full of code fragments is no different.</p>
</blockquote>
<p>Today, when trying to practice writing human-readable code on <a href="https://git.envs.net/iacore/tetris-raylib-zig/">my Tetris clone</a>, I had the idea of adding a Table of Contents to the source code. It improved the readability of the codebase a lot, and the difference is like that between a loose collection of pages and a compiled book. Before now, I never thought about the organization of source code files as part of a software project. Since I use math to understand code, I never thought of text files as part of a book. I&#x2019;m glad that I figured it out now, and I&#x2019;m here to share my findings to you.</p>
<p>You may want to read the repository content (linked above) to understand how important the addition of Table of Content was.</p>
<p>Writing text-based software code is not that different from writing literature. Lessons from Publishing and Literature work well here. A POSIX file is like a page; unlike  paper publishing, the size of pages varies in the digital realm. Although we can also use hyperlinks to directly link different documents together, the traditional Index Page format is still valuable. Line and grid patterns are more legible than solid color fill. Shape cues stand out way more than special type face. Paper or text editor, we are given a 2-euclidean rectangle to work with. I think software interface designers are too daring to try out different UI designs, yet don&#x2019;t learn from history of publishing.</p>
<p>Here are some tips that may help other humans to read your code better. If you are trained in writing (literature), you should understand why quickly. Otherwise, you need to practice to understand how doing those helps readability.</p>
<ul>
<li>Add a table of contents in your code. <strong>Not</strong> in documentation. You are encouraged to solicit help from the type checker and LSP (jump to definition).</li>
<li>If you can cut a word out, cut it out. (People give this advice often in programming too, but worded different.)</li>
<li>Interleave functions of high and low obscurity (time it takes to read it).</li>
<li>Order stuff by dependency. Introduce simple concepts first. (But do put the table of contents and prologue at the beginning.)</li>
</ul>
<p>You can do any of theme to existing code. When cleaning up your code, compile (organize and label) it as well.</p>
<p>Now that I think about it, this website has terrible organization. I will clean it up soon. For the mean time, I wish you less pain when reading unfamiliar code.</p>
<hr/>
<p>In case you may ask, &#x201c;But what about literate programming?&#x201d; Here&#x2019;s the anwser.</p>
<p>The concept never made sense to me. Duplicating information in programming language <strong>and</strong> natural langage made it harder for me to understand what I was reading.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/16-buy-janet-get-gc-free/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/16-buy-janet-get-gc-free/"/>
    <title>Janet: Buy Runtime Get GC Free</title>
    <published>2023-08-28T12:00:00Z</published>
    <updated>2023-09-25T12:00:00Z</updated>
    <category term="comp"/>
    <category term="lang:C"/>
    <category term="lang:Janet"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/16-buy-janet-get-gc-free/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Over the years, I&#x2019;ve tried using many scripting languages with C/Zig. The following are the languages that I remember using, along with the pain I felt when embedding them.</p>
<ul>
<li>Lua/LuaJIT: Stack shenanigans.</li>
<li>CPython: INCREF/DECREF shenanigans. The language is pretty good though.</li>
<li><a href="https://wren.io/">Wren</a>: Slot shenanigans.</li>
<li><a href="http://synthcode.com/scheme/chibi/">Chibi-Scheme</a>: &#x201c;Batteries, where?&#x201d; The standard library doesn&#x2019;t even have a way to replace substring in string.</li>
<li><a href="https://gambitscheme.org/latest/manual/">Gambit</a>: It tries its best not to be embedded.</li>
</ul>
<p>Recently, I was troubled by the lack of memory management in Zig, and by accident, I tried <a href="https://janet-lang.org/">Janet</a>. The memory model of Janet fit surprisingly well with Zig. That made me thinking. What if I only use Janet for its GC?</p>
<p>Here&#x2019;s what I came up with: <a href="https://git.envs.net/iacore/janet-zig-test"><mark>(see demo source code)</mark></a>. The article and my code use Zig and <a href="https://github.com/greenfork/jzignet">jzignet</a>, but you can follow along with C and <a href="https://janet-lang.org/capi/index.html">libjanet (the official C API)</a>, since the functions are the same ones. Please note that error handling in C will be more verbose than in Zig.</p>
<p>In the rest of this article, I&#x2019;ll show you how to store Zig data in Janet. It&#x2019;s very easy. You do need to read my code (linked above) to follow along.</p>
<h2>Janet&#x2019;s GC</h2>
<p>Janet has a simple mark-and-sweep garbage collector. The following are the GC roots:</p>
<ul>
<li><code>janet.Environment</code>, and anything reachable from them
how to free: call <code>deinit</code> manually</li>
<li>Janet fibers, and anything reachable from them
how to free: automatically, when fiber terminates</li>
</ul>
<p>You can also add GC roots with <code>janet.gcRoot(_)</code> and <code>janet.gcUnroot(_)</code>.</p>
<p>Here&#x2019;s Janet&#x2019;s promise to you:</p>
<ul>
<li>When no Janet code is running, nothing will be freed (unless your force a collection cycle with <code>janet.collect()</code>)</li>
<li>Anything reachable from any GC root will not be freed</li>
</ul>
<p>As you can see, there are a bijillion ways you can make sure that your stuff don&#x2019;t disappear. One way is to create a <code>janet.Table</code>, call <code>janet.gcRoot(table)</code>, and store stuff in it.</p>
<h2>How to store Janet data in Zig</h2>
<p>If you are using Janet&#x2019;s C API, you are already doing it. Just make sure the Janet values are rooted somehow. Janet&#x2019;s GC is non-moving, so you can keep <code>janet.Janet</code> terms as long as they are not garbage collected.</p>
<h2>How to store Zig data in Janet</h2>
<p>Janet string/buffer is a chunk of memory. It can contain null byte. Therefore, you can put anything in it. Call <code>janet.string(slice)</code> and you are done.</p>
<p>You can also wrap pointer in <code>janet.Janet</code>, but then you have to manage memory yourself.</p>
<hr/>
<p>That&#x2019;s it! That&#x2019;s all you need to know to use Janet as the data layer of your application.</p>
<p>As long as you keep Janet values from being eaten by the GC, I don&#x2019;t see how you can mess it up.</p>
<hr/>
<h2>Janet Embedding Advanced</h2>
<p>Here are some implementation details of Janet that may help you play it like a fiddle.</p>
<h3><code>JanetVM</code> is thread-local, but not pinned to a thread</h3>
<p>Every <code>JanetVM</code> has its own GC context. You can think of it as a language runtime. <code>JanetVM</code> are indenpendent from each other.</p>
<p>The active VM is stored as a thread-local variable. However, you can move them to another thread. Please make sure you are not running the same VM on two different threads.</p>
<p>Here&#x2019;s what the C API VM functions do.</p>
<pre><code class="language-c">// init vm, set to thread-local variable
JANET_API int janet_init(void);
// deinit thread-local vm
JANET_API void janet_deinit(void);
// get pointer to the thread-local variable holding the vm
JANET_API JanetVM *janet_local_vm(void);
// get thread-local variable
JANET_API void janet_vm_save(JanetVM *into);
// set thread-local variable
JANET_API void janet_vm_load(JanetVM *from);

// Don&apos;t use the following. Just use a local variable to store JanetVM, mate.

// allocate memory for vm, but does not initialize it. 
JANET_API JanetVM *janet_vm_alloc(void);
// free memory taken up by vm.
JANET_API void janet_vm_free(JanetVM *vm);
</code></pre>
<h3>How to pump event loop</h3>
<p>You only need to worry about if your code uses Janet&#x2019;s file or network API.</p>
<p>tl;dr: Call <code>(ev/sleep 0)</code> when idle. The fibers spawned by <code>ev/go</code> won&#x2019;t run unless you yield control somehow.</p>
<p>Each <code>JanetVM</code> has an event loop. It also tracks a list of <a href="https://janet-lang.org/docs/fibers/index.html">fibers</a> alive. Here&#x2019;s the gist about fibers.</p>
<ul>
<li>Only one fiber can be running at once (in one <code>JanetVM</code>)</li>
<li><code>janet.doBytes(code)</code> spawns a fiber to run that code</li>
<li>Fibers can be used to catch runtime errors, like <code>xpcall</code> in Lua, or <code>catch_unwind</code> in Rust</li>
<li>If there&#x2019;s only one fiber, everything looks like blocking code</li>
<li>Execution context is never automatically transfered. If you do <code>janet.doBytes(&quot;(+ 1 2)&quot;)</code>, it will return immediately, without giving other fibers a chance to do things.</li>
<li>Do <code>janet.doBytes(&quot;(ev/sleep 0)&quot;)</code> to give other fibers a chance to do things. It does not block.</li>
</ul>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/15-solidjs-internals/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/15-solidjs-internals/"/>
    <title>Internal Data Structures of Solid.js</title>
    <published>2023-08-24T12:00:00Z</published>
    <updated>2023-08-24T12:00:00Z</updated>
    <category term="comp"/>
    <category term="lang:Typescript"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/15-solidjs-internals/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>For who-knows-how-long, I&#x2019;ve dabbled in web gui sorcery. It costs me sanity to lift the &#x201c;develop-friendly&#x201d; facade, and look at the inner workings of a web ui library.</p>
<p>This week, I did the unthinkable again, and looked at how the library-user-facing side of <a href="https://www.solidjs.com/">Solid</a> works. I felt&#x2026; nothing. That&#x2019;s a good thing. I need to share the great news to you all.</p>
<p>For simplistic&#x2019;s sake, this article is only correct about the library&#x2019;s behavior in browser. On Node.js it&#x2019;s not much different, except the DOM elements are replaces with Solid&#x2019;s own greeting. We also don&#x2019;t talk about reactivity here. Ask <a href="https://www.youtube.com/@ryansolid/">Ryan</a> to explain that for you. It&#x2019;s too ingenious for me to understand (at the time of writing).</p>
<h2>&#x201c;Components? We don&#x2019;t do that here.&#x201d;</h2>
<p>For Solid, &#x201c;component&#x201d; is a meme.</p>
<p>See <code>&lt;p&gt;hi&lt;/p&gt;</code>? Oh, it&#x2019;s just a DOM element. The <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLParagraphElement"><code>HTMLParagraphElement</code></a> thing.</p>
<p>What about <code>&lt;&gt;&lt;/&gt;</code>? <code>[]</code>.</p>
<p>What about <code>&lt;&gt;p&lt;/&gt;</code>? <code>&quot;p&quot;</code>. Yes it&#x2019;s just a string. Seems like when the fragment only contains one thing, it&#x2019;s not an array.</p>
<p>What about <code>&lt;&gt;hi&lt;br/&gt;&lt;/&gt;</code>? <code>[&quot;hi&quot;, (HTMLBRElement)]</code>.</p>
<p>What about <code>&lt;&gt;hi{a()}&lt;/&gt;</code>? It&#x2019;s <code>[&quot;hi&quot;, X]</code> where <code>X</code> is <code>a()</code> evaluated. It works like string interpolation in JS.</p>
<h2>&#x201c;But how do I component?&#x201d;</h2>
<p>That&#x2019;s simple. Just do <code>const Greeting = (props) =&gt; &lt;p&gt;hi there&lt;/p&gt;</code>.</p>
<p>To instatiate a component, do <code>&lt;h1&gt;&lt;Greeting a={1}/&gt;&lt;/h1&gt;</code>. It&#x2019;s the same as</p>
<pre><code class="language-tsx">&lt;h1&gt;{Greeting({a:1})}&lt;/h1&gt;
</code></pre>
<p>Note that the component is created before the outer element tree is created. In fact, it is the same as nested function calls.</p>
<p>The nested stuff is passed as <code>children</code> verbatim. That&#x2019;s why you can pass function and other data types as component children. Example:</p>
<pre><code class="language-tsx">let a = &lt;A&gt;{1}&lt;/A&gt;
// is same as
let a = A({children:1})

let b = &lt;A&gt;{1}{2}&lt;/A&gt;
// is same as
let b = A({children:[1,2]})
</code></pre>
<p>Same as fragment (<code>&lt;&gt;&lt;/&gt;</code>), if the nested stuff are two or more, it&#x2019;s passed in as array.</p>
<p>By the way, JSX assumes that if first letter of an element is lower, the element is a native element. So you can&#x2019;t write <code>&lt;greeting/&gt;</code>. Use <code>{greeting()}</code> (if you name the component lowercase).</p>
<h2>&#x201c;What about the special elements like &lt;For&gt;?&#x201d;</h2>
<p>Special? It looks like a function to me.</p>
<pre><code class="language-tsx">const a = &lt;For&gt;...&lt;/For&gt;
const b = &lt;&gt;{a()}&lt;/&gt;
</code></pre>
<h2>Conclusion</h2>
<ul>
<li>A &#x201c;component&#x201d; in Solid is a function that returns a DOM element, or an array of those.</li>
<li>It is possible to make a simple web ui library without insanity-inducing details.</li>
</ul>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/14-counter-fearmonger/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/14-counter-fearmonger/"/>
    <title>How to Counter Fearmongering</title>
    <published>2023-08-15T12:00:00Z</published>
    <updated>2024-03-14T12:00:00Z</updated>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/14-counter-fearmonger/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p><strong>(Intro)</strong> This article is the hardest one I&#x2019;ve written so far. Conception alone took me 3 days (counting from the day I decided to write about this). The mainstream narrative of &#x201c;hate&#x201d; and &#x201c;love&#x201d; also obstructed my search for a solution to this shenanigan. The root cause is not hate, but fear.</p>
<p>I am writing this because I am so tired of seeing people being played by <a href="https://en.wikipedia.org/wiki/Far-right_politics">far-right politicians</a> like a fiddle. Those politicians instill fear in their subjects, and advocate elimination of the &#x201c;public enemy&#x201d; by death. Naturally, as politicians, they promise to execute the elimination plan once they hold power, so their subjects don&#x2019;t have to.</p>
<p>Even those who hate the far-right are sometimes bamboozled by the far-right ideology and push out the &#x201c;counter&#x201d; propaganda: &#x201c;Love, not hate!&#x201d; Sadly, far-right ideology has nothing to do with Love or Hate. It has to do with Fear, and only Fear. The target of their Fearmongering can be different though.</p>
<p>Internally, I do not use the term &#x201c;right&#x201d; or &#x201c;left&#x201d; when I reason about culture and politics. I just call those who fearmonger &#x201c;The Fear Demons&#x201d;.</p>
<p><strong>(Background)</strong> This article describes how to counter <strong>fearmongering</strong>, a tactic some politicians use to gain power. Search the Internet for &#x201c;political fearmongering&#x201d; to learn more. The gist is, when the economy is bad, people feel uneasy, making them easy to fearmonger.</p>
<h2>How to counter fearmongering</h2>
<p>First, do not fear. Do not be fearmongered yourself. If you are reading this article, chances are you aren&#x2019;t. If you are, I&#x2019;m sorry&#x2026; you are already played like a fiddle by them.</p>
<p>When you meet someone who has been fearmongered, do this: Instead of arguing with them (i.e. pointing out lies), tell them earnestly about the political tactic of fearmongering. They may deny at first, but I had better chances with this method.</p>
<p>You argue, you lose (time). The only winning move is not to play.</p>
<p>If you still have time to spare, tell them to read the history of populism (could be from any time period; they look all the same).</p>
<h2>How to change someone&#x2019;s mind</h2>
<blockquote>
<p>So they now know that their mind has been tampered with, but they still dislike a group of people. Now what?</p>
</blockquote>
<p><a href="https://en.wikipedia.org/wiki/Mere-exposure_effect">Exposure effect</a> is good enough. It&#x2019;s slow, but it works all the time.</p>
<p>If they are open to criticism, you can also talk to them about it. Be chill. Be sleepy. Do not argue. It may take a few weeks for someone to change their mind though, so be patient.</p>
<h2>Epilogue</h2>
<p>I hope this article is useful for you, and it has found its way to you through nonviolent means.</p>
<p>The next time you see someone lie to spread fear, say this: &#x201c;Stop fearmongering! You evil monster!&#x201d; If you are Christian, you may say that fearmongering is the Devil&#x2019;s work, since it brings out the worst in us.</p>
<p>I also made this plaque, which you may take a screenshot of and send it on social media.</p>
<p>If you have a HTML website, you can copy the following <code>&lt;a&gt;</code> and <code>&lt;style&gt;</code> tags (use &#x201c;View Source&#x201d;) and put it on your website. You can also just link to this page with the same text.</p>
<p>I hope you will share this article because you think that this article will have a positive impact on whoever reading it, and a positive impact on society at large.</p>
<a class="plaque-a" href="https://www.1a-insec.net/blog/14-counter-fearmonger/">
    <div class="plaque-inner">
    <div class="plaque-title">No Fearmongering</div>
    <div>Not Again</div>
    </div>
</a>
<style>
.plaque-a {
    display: block;
    text-align: center;
}
.plaque-inner {
    border: solid 1px black;
    display: inline-block;
    margin: auto;
    padding: 1em;
}
.plaque-title {
    font-size: 2em;
}
</style>
<p>Related Reading: <a href="https://en.wikipedia.org/wiki/Fear,_uncertainty,_and_doubt">https://en.wikipedia.org/wiki/Fear,_uncertainty,_and_doubt</a></p>
<h2>Thoughts After The Epilogue</h2>
<p>It&#x2019;s been 0.83 years since I&#x2019;ve written this article.</p>
<p>Given the current populist political climate around the world, there now two trending ways to &#x201c;deal with&#x201d; the sense of helplessness originated from personal economic hardship. That economic hardship might be local.</p>
<p>If they go to seek help from a doctor, diagose them with mental health problems. Well, a sense of helplessness is certainly of mental and of problem. I&#x2019;d rather solve the root cause of the feeling.</p>
<p>If they subscribe to the idea that &#x201c;all my problems belong to them&#x201d;, bash them. &#x2026; an idea can certainly be killed with physical violence; how much dosage are you planning to administer? I feel worried about this.</p>
<p>I realize that me talking about all this on the Internet is not convincing at all. If I ever ended up trying to convince someone about this again, I will try to document it and link it here. For now, night night.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/13-meta-omega/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/13-meta-omega/"/>
    <title>Meta Omega</title>
    <published>2023-08-11T12:00:00Z</published>
    <updated>2023-08-11T12:00:00Z</updated>
    <category term="math"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/13-meta-omega/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Recently I read a comic about the author drawing about what she drew.</p>
<p>It goes something like this:</p>
<ol>
<li>She does something</li>
<li>She draws about it</li>
<li>She uploads the comic on pixiv</li>
<li>Pixiv users comment on it</li>
<li>She draws about herself drawing the previous chapters, uploading them to pixiv, and reading the pixiv comments.</li>
</ol>
<p>It took me awhile to figure out why reading it feels so wrong. When reading the comic, I was not given any context and the chapters are next to each other (while they are semantically distinct).</p>
<p>Here&#x2019;s a diagram that illustrate the ordeal. Arrows indicate causality (dependent -&gt; dependency). Numbers correspond to the numbered list items.</p>
<p><img src="13-intro.svg" alt=""/></p>
<p><em>[breath out]</em> That&#x2019;s meta. It got me thinking though, what if someone put the concept to the limit?</p>
<h2>Ordinal Sets</h2>
<p>In this world, there is something called <a href="https://en.wikipedia.org/wiki/Ordinal_number">limit ordinal</a> that can represent the upper/lower limit of a set. &#x3c9; happens to be one of them.</p>
<p>Here&#x2019;s a diagram that utilize the concept of limit ordinal. In case you are wondering, we are still talking about comics here, and each rectangle is a comic chapter.</p>
<p><img src="13-omega.png" alt="An infinite series of comic chapters, each depending on the previous one"/></p>
<p>But wait, this just looks like every other comic series, except infinite. Besides, it&#x2019;s not the infinity aspect of the comic that confused me. <strong>We need more flavor.</strong></p>
<h2>Interleaving Reality and Fiction</h2>
<p>To make it clearer, I added dotted lines to represent the order I read the comic.</p>
<p><img src="13-interleave.svg" alt=""/></p>
<p>It seems like the &#x201c;flavor&#x201d; of the comic comes from the complexity of events happened outside of the comic. See how the events relate to each other.</p>
<p>In contrast, here&#x2019;s a comic with linear progression. It feels more boring to me.</p>
<p><img src="13-plain.svg" alt=""/></p>
<p>Maybe I can find a way to measure such complexity, and generate interesting story structures from that. That would have to be another article.</p>
<p>If you are a mangaka, feel free to use this cursed ideas to structure your story without warranty.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/12-equality-explained/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/12-equality-explained/"/>
    <title>Equality Often Misunderstood</title>
    <published>2023-08-08T12:00:00Z</published>
    <updated>2024-08-26T12:00:00Z</updated>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/12-equality-explained/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Freedom, democracy, equality. Those are the buzzwords you hear from liberal-leaning social politicans. But what are they really?</p>
<p>Freedom is a need. It is nice to have. More freedom is not better when it causes others more suffering than happiness gained from the added freedom. (You can also just say &#x201c;fuck others&#x2019; suffering&#x201d; and shorten your nation&#x2019;s life expectancy.)</p>
<p>Democracy is a form of government. It is a <strong>tool</strong> used to fulfill public interest. One of such interest is <strong>peace</strong>. It seems like people like to uphold democracy way more than to <strong>improve</strong> it. I think it&#x2019;s good to upgrade this tool often, since the world changes fast in recent times.</p>
<p>Equality is cry from the weak, appeal to empathy, request for help. It says <strong>something seriously wrong</strong> is happening.</p>
<p>So fix that wrong thing. Not inequality. Fix the wrong thing. And dear reader, I urge you to do the same. Although &#x201c;equality&#x201d; is good to have, it is not the exact problem. Here are some better slogans I thought up for you.</p>
<ul>
<li>The poor dies from lack of health care</li>
<li>The poor dies from plague due to government thinking COVID is a plague</li>
<li>The poor dies</li>
</ul>
<p>In a sense, to &#x201c;make sure everyone has enough money to live a ok life&#x201d; is better than simply to &#x201c;reduce wealth inequality&#x201d;.</p>
<p>With the definitions stated, here are some of my other thoughts on this topic.</p>
<h2>Wealth Inequality. What to do?</h2>
<p>Tax income up to 70% (or even up to 90% now that automation is more capable).</p>
<p>Do <a href="https://en.wikipedia.org/wiki/Georgism">Georgism</a> for land.</p>
<p>Most other &#x201c;main-stream&#x201d; measures are less effective at coping than sleep. (Not much exagerrated. If you do the two above, you can also sleep soundly.)</p>
<h2>What if my government is incompetent</h2>
<p>If your government isn&#x2019;t providing a service that it should be, do it yourself. Join others in providing the service to the public.</p>
<p>If your government tries to deter you with violence, fight back. How to effectly fight back is a whole nother topic that I am not qualified to talk about here.</p>
<p>Or, you can do nothing. It&#x2019;s your life.</p>
<h2>Moooore Equality</h2>
<p>What if you want more wealth equality even with heavy taxation? Then, we need to welcome the <em>Four Horsemen of Leveling</em>: warfare, revolution, state collapse and plague. With dramatic climate shift, we might see two more members added to the list: natural disaster, and famine (although they don&#x2019;t level as much).</p>
<p>As <a href="https://www.economist.com/open-future/2018/09/10/can-inequality-only-be-fixed-by-war-revolution-or-plague">Walter Scheidel, the author of <em>The Great Leveler</em> puts it</a>:</p>
<blockquote>
<p>The Economist: Is society incapable of tackling income inequality peacefully?</p>
<p>Walter Scheidel: No, but history shows that there are limits. There is a big difference between maintaining existing arrangements that successfully check inequality&#x2014;Scandinavia is a good example&#x2014;and significantly reducing it. The latter requires real change and that is always much harder to do: think of America or Britain, not to mention Brazil, China or India. The modern welfare state does a reasonably good job of compensating for inequality before taxes and transfers. However for more substantial levelling to occur, the established order needs to be shaken up: the greater the shock to the system, the easier it becomes to reduce privilege at the top.</p>
</blockquote>
<h2>Finishing Thoughts</h2>
<p>COVID shows that trust on government is important. Also, rapid response to events is important.</p>
<p>I really don&#x2019;t want to rely on the four horsemen to achieve those goals.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/11-fonts-where/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/11-fonts-where/"/>
    <title>Fonts, where are you?</title>
    <published>2023-08-07T12:00:00Z</published>
    <updated>2023-09-15T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/11-fonts-where/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>tl;dr: If you want to implement a way to find fonts for every Unicode codepoint, don&#x2019;t. Do <code>fc-list : file family charset</code>. <a href="https://git.envs.net/iacore/glyph-ranges/">Simple parsing code here.</a></p>
<p>Edit: <a href="https://lobste.rs/s/fuiowm/fonts_where_are_you#c_7iddie">Screwtape on lobsters</a> told me that <code>fc-list &quot;:charset=1F511&quot;</code> is valid. It finds fonts for a single codepoint.</p>
<p>The writing quality of this article is like this because I don&#x2019;t want to spend more time on this issue.</p>
<h2>The story</h2>
<p>Recently I was making a GUI application. I don&#x2019;t want to ship fonts with my application. The user&#x2019;s computer has probably fonts for every language they need to read, so I can just use that. Probably.</p>
<p>The first implementation I used is to load every Noto Sans font. It worked! Noto is really &#x201c;no tofu&#x201d;.</p>
<pre><code>fc-list | grep &quot;NotoSans&quot; | cut -f1 -d: | rg Regular | sort | uniq
</code></pre>
<p>I should have just stopped here.</p>
<h2>Yak shaking</h2>
<p>While the simple solution works, it still felt janky to me, because all the font belongs to different font families (&#x201c;Noto Sans&#x201d; isn&#x2019;t the same as &#x201c;Noto Sans Math&#x201d;). Also, it might be an issue if Noto fonts are not installed.</p>
<p>Then, I wondered, how UI libraries like GTK, Firefox do it.</p>
<p><a href="https://gitlab.gnome.org/GNOME/gtk">GTK</a>&#x2026; it&#x2019;s not there.</p>
<p><a href="https://hg.mozilla.org/mozilla-central/log?rev=%22Noto+Sans+Math%22">mozilla-central</a>&#x2026; it&#x2019;s not there.</p>
<p>I found the list in <a href="https://github.com/servo/servo">Servo</a>. It turns out that Servo embeds <a href="https://github.com/servo/servo/blob/cedd59361eb6db44544514bc8b4ccb717d9f8adb/components/gfx/platform/freetype/android/font_list.rs">a incomplete list of font family names</a>. That&#x2019;s not it either. It does contain <a href="https://github.com/servo/servo/blob/cedd59361eb6db44544514bc8b4ccb717d9f8adb/components/gfx/platform/freetype/font_list.rs#L152-L166">some code copied from GTK+Gecko</a> though.</p>
<p>Let me check what info are in font files with <code>fc-query /usr/share/fonts/noto/NotoSansMath-Regular.ttf</code>. Not useful either.</p>
<p>Well, it seems like <a href="https://github.com/alacritty/alacritty/issues/965#issuecomment-353975062">fontconfig is a dead end</a>.</p>
<p>In the end I gave up on this route. It looks like <a href="https://github.com/alacritty/alacritty/pull/3163">Alacritty does something about this</a>, but I don&#x2019;t want to touch this any more.</p>
<h2>fontconfig, why you be like this</h2>
<p>When I wanted to query fc-list with multiple attributes, I tried the following. None of it worked.</p>
<pre><code>fc-list &quot;:weight=80 style=Regular&quot;
fc-list &quot;:weight=80+style=Regular&quot;
fc-list &quot;:weight=80,style=Regular&quot;
fc-list &quot;:weight=80&amp;style=Regular&quot;
</code></pre>
<p>So, I turned to the man pages. Still none.</p>
<pre><code>man fc-list
man FcPatternFormat
</code></pre>
<p>It turns out at the bottom of <code>man fc-list</code> it says</p>
<blockquote>
<p>The fontconfig  user&#x2019;s  guide,  in  HTML  format:  /usr/share/doc/fontconfig/fontconfig-user.html.</p>
</blockquote>
<p>thanks fontconfig</p>
<p>The final command to list &#x201c;Regular&#x201d; fonts (no italic, no bold) is <code>fc-list &quot;:weight=80:style=Regular&quot; file family weight</code></p>
<p>If you want to query by font family, then do <code>fc-list &quot;Noto Sans:weight=80:style=Regular&quot;</code>.</p>
<h2>The solution that&#x2019;s not quite elegant</h2>
<p>Since I don&#x2019;t know how Firefox finds the best font for a codepoint, let&#x2019;s try to see if I can find <strong>all</strong> fonts for a given codepoint.</p>
<p>This turns out to be simple. <code>fc-list : file family charset</code> shows the codepoints a font file supports in hex.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/10-type-magic-in-zig/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/10-type-magic-in-zig/"/>
    <title>Commiting Dependent Type Crimes in Zig</title>
    <published>2023-08-01T12:00:00Z</published>
    <updated>2024-06-30T12:00:00Z</updated>
    <category term="comp"/>
    <category term="lang:Zig"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/10-type-magic-in-zig/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>If you thing Zig is just another C-level language, you haven&#x2019;t typed enough. Zig&#x2019;s struct-in-a-fn feature allows dependent types with ergonomic syntax.</p>
<p>Recently, I was doing a large software project. I started the project in Rust, but switched to Zig because Rust is too limiting.</p>
<p>The API I&#x2019;m targeting is very uniform. Its routes all look like this:</p>
<ul>
<li>HTTP POST</li>
<li>static URL</li>
<li>input as POST payload (shape described in schema)</li>
<li>output as response body (shape described in schema)</li>
</ul>
<p>Here&#x2019;s what I came up with.</p>
<pre><code class="language-zig">/// API route
pub const Route = struct {
    /// endpoint url like /i
    url: []const u8,
    /// uplink type (request body)
    Tup: type,
    /// downlink type (response body)
    Tdown: type,

    pub fn init(comptime url: []const u8, comptime Tup: type, comptime Tdown: type) @This() {
        return .{ .Tup = Tup, .Tdown = Tdown, .url = url };
    }
};
</code></pre>
<p>In Rust, this would have to be like <code>Route&lt;Tup, Tdown&gt;</code>. Jankier solutions exist, but I&#x2019;d rather write simple code.</p>
<p>Then, I described some routes plus input and output types.</p>
<pre><code class="language-zig">pub const routes = struct {
    pub const whoami = Route.init(&quot;i&quot;, struct {}, types.UserLite);
    ...
};

pub const types = struct {
    pub const UserLite = struct {
        id: []const u8,
        name: []const u8,
        username: []const u8,
    };
};
</code></pre>
<p>With the API definition done, I moved onto the HTTP client. It came out looking like this.</p>
<pre><code class="language-zig">/// Request manager with retry. Manages a client, a thread, and a single API route.
pub fn Resource(comptime route: Firefish.Route) type {
    return struct {
        ...
    };
}
</code></pre>
<p>Dear reader, if you still think that this looks perfectly normal, I have to remind you that putting type in term is only possible in Idris, Lean, or Zig. Zig is not like the other two, since its type system is much simpler. It somehow retains the ability to mix term and type freely, which neither D nor Nim can.</p>
<p>Even if I <a href="/stuff/algograph/">invented a programming language</a> already, I don&#x2019;t think I can think up Zig&#x2019;s syntax for &#x201c;generics&#x201d; in my lifetime. Hail Andrew Kelley and Josh Wolfe! <sup class="footnote-ref"><a href="#fn1" id="fnref1">[1]</a></sup></p>
<p>One thing Zig&#x2019;s type system pains me is the verbosity of &#x201c;inline functions&#x201d;. To include function inside function, you currently have to do</p>
<pre><code class="language-zig">fn foo() void {
    const o = struct {
        fn bar() void {}
    };
    const bar = o.bar;
}
</code></pre>
<p><s>There are <a href="https://github.com/ziglang/zig/issues/1717">at</a><a href="https://github.com/ziglang/zig/issues/4170">tem</a><a href="https://github.com/ziglang/zig/issues/6965">pts</a> to resolve this issue. However, async/await will have to come first.</s> It seems like this feature is not going to be added to Zig, in the name of encouraging explicit control flow.</p>
<p>Also, by the time you are reading this, Zig 0.11 (stable release) is probably out. Now go try it!</p>
<p>P.S. You can also pass functions around in Zig just like in C, but more type checked. A function and a pointer to a function are two different concepts in Zig.</p>
<p>Edit: My site has been <a href="https://lobste.rs/s/fqbelt/commiting_type_crimes_zig">lobstered</a> for the first time! I think my writing is too simple, and the concept of putting types in terms may be hard to understand. For more information, please re-read.</p>
<p>Edit: Here are some more example code.</p>
<p>The Idris Door Example</p>
<pre><code class="language-zig">pub fn main() !void {
    const d0 = Door(.closed){};
    const d1 = d0.open();
    const d2 = d1.open(); // type error
    _ = d2;
}

const DoorState = enum { open, closed };

fn Door(comptime state: DoorState) type {
    return switch (state) {
        .open =&gt; struct {
            fn close(_: @This()) Door(.closed) {
                return .{};
            }
        },
        .closed =&gt; struct {
            fn open(_: @This()) Door(.open) {
                return .{};
            }
        },
    };
}
</code></pre>
<p>Type-level Integer</p>
<pre><code class="language-zig">pub fn main() !void {
    const c0 = Counter(0){};
    const c1 = c0.inc();
    const c2 = c1.inc();
    _ = c2;
    // @TypeOf(c2) == Counter(2)
}

fn Counter(comptime i: comptime_int) type {
    return struct {
        fn inc(_: @This()) Counter(i + 1) {
            return .{};
        }
    };
}
</code></pre>
<h2>Dynamic Dispatch Without V-Table (Update(2024-06-30))</h2>
<p>Type magic has actual use.</p>
<pre><code class="language-zig">const std = @import(&quot;std&quot;);

const Allocator = struct {
    var _iv0 = std.heap.GeneralPurposeAllocator(.{}){};
    const vt_gpa = _iv0.allocator().vtable.*;
    const vt_page = std.heap.PageAllocator.vtable;

    ctx: *anyopaque,
    variant: enum { gpa, page },

    pub fn alloc(this: @This(), len: usize, ptr_align: u8, ret_addr: usize) ?[*]u8 {
        return switch (this.variant) {
            inline else =&gt; |tag| @field(@This(), &quot;vt_&quot; ++ @tagName(tag)).alloc(this.ctx, len, ptr_align, ret_addr),
        };
    }
};

pub fn main() !void {
    {
        var gpa = std.heap.GeneralPurposeAllocator(.{}){};
        const a = Allocator{
            .ctx = @ptrCast(&amp;gpa),
            .variant = .gpa,
        };
        var buf = a.alloc(16, 1, @returnAddress()).?;
        buf[0] = &apos;h&apos;;
        buf[15] = &apos;i&apos;;
    }
    {
        var page = std.heap.page_allocator;
        const a = Allocator{
            .ctx = @ptrCast(&amp;page),
            .variant = .page,
        };
        var buf = a.alloc(16, 1, @returnAddress()).?;
        buf[0] = &apos;h&apos;;
        buf[15] = &apos;i&apos;;
    }
}
</code></pre>
<hr class="footnotes-sep"/>
<section class="footnotes">
<ol class="footnotes-list">
<li id="fn1" class="footnote-item"><p>The design of generics goes way back in Zig&#x2019;s design history. See <a href="https://github.com/ziglang/zig/issues/22">issue #22</a>, <a href="https://github.com/ziglang/zig/issues/151">issue #151</a>. Even though they did not mention type theory whatsoever, the final design they land on is the same of that of <a href="https://github.com/idris-lang/Idris2/">Idris</a>. If they have come up with the idea without knowing dependent type system before, this is no small achievement. <a href="#fnref1" class="footnote-backref">&#x21a9;&#xfe0e;</a></p>
</li>
</ol>
</section>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/09-io-in-c/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/09-io-in-c/"/>
    <title>How to Run io Scripts From C</title>
    <published>2023-07-12T12:00:00Z</published>
    <updated>2024-01-19T12:00:00Z</updated>
    <category term="comp"/>
    <category term="lang:io"/>
    <category term="lang:C"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/09-io-in-c/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>A few days ago, I stumbled upon <a href="https://iolanguage.org/">a simple elegant language called &#x201c;io&#x201d;</a>. Its syntax is unlike every mainstream language that I know. Even Smalltalk pales in front of its elegant syntax.</p>
<p>After a few days of fiddling with it, I decided to embed it in my projects. However, there exists no documentation on how to easily do this. I asked on the Io Forum. <a href="https://github.com/IoLanguage/io/discussions/472#discussioncomment-6420938">They replied.</a></p>
<p>Long story short, here&#x2019;s how you say hello world in io and C.</p>
<pre><code class="language-c">#include &lt;stdio.h&gt;
#include &lt;io/IoVM.h&gt;

IoObject* hello(IoObject *self, IoObject *locals, IoMessage *m) {
    puts(&quot;Hello world!&quot;);
    return self;
}

int main(int argc, const char *argv[]) {
    IoState *self = IoState_new();

    IoObject *lobby = IoState_lobby(self);

    IoObject_addMethod_(lobby, IoState_symbolWithCString_(self, &quot;hello&quot;), hello);

    // this also works
    // IoMethodTable methodTable[] = {{&quot;hello&quot;, hello}, {NULL, NULL}};
    // IoObject_addMethodTable_(lobby, methodTable);

    IoState_doCString_(self, &quot;hello print&quot;);
    IoState_free(self);
    return 0;
}
</code></pre>
<p>From now on, io will be a scripting language I use.</p>
<p>With that out of the way, here are some tips on how to use io.</p>
<blockquote>
<p>The <code>self</code> slot is only set during a method or block. You can think of it as a local variable. Unlike Javascript <code>this</code>, it is not available at top-level.</p>
</blockquote>
<blockquote>
<p>If you want to know what <code>foo</code> does, do <code>foo type</code>, <code>foo slotSummary</code>, <code>foo proto slotSummary</code>.</p>
</blockquote>
<hr/>
<p>Update (2024-01-19):</p>
<p>As it turns out, you can use stdin/stdout to run io code. Example command: `io -e &#x2018;doFile(&#x201c;<a href="http://definitions.io">definitions.io</a>&#x201d;);&#x201c;awawawa&#x201d; print&#x2019;.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/08-when-perfect-digital-security/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/08-when-perfect-digital-security/"/>
    <title>When Perfect Digital Security is Achieved</title>
    <published>2023-06-13T12:00:00Z</published>
    <updated>2023-06-13T12:00:00Z</updated>
    <category term="comp"/>
    <category term="meme"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/08-when-perfect-digital-security/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Warning: This is a story I often think of when I pounder on potential development of cyber security. It may be nonsensical.</p>
<hr/>
<p>In a future where OSes are perfectly secure, when the only possible error is human error; data leaks originate from only social engineering and break-ins. Your means to protect your data may be a stick. A long wooden pole-arm. A carbon fiber one will do too.</p>
<p>You are your system&#x2019;s only administrator. You are impervious to phishing, since all your work is done on ABSD. Dumpsters are on fire outside. You know you need the stick.</p>
<p>Or, you oversee the time sharing system in your town, where kids come to play on the table together. The stick leaning in a corner. Of course you would not actually use it, but the threat of it is enough to make them not damage the table too much.</p>
<p>You were in cyber security, but now you have all day to sleep.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/07-proper-keyboard-handling/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/07-proper-keyboard-handling/"/>
    <title>Handling keyboard events correctly in games</title>
    <published>2023-04-22T12:00:00Z</published>
    <updated>2023-04-22T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/07-proper-keyboard-handling/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <pre><code>&#x276f; xset q
Keyboard Control:
  auto repeat:  on    ...
  ...
  auto repeat delay:  250    repeat rate:  30
</code></pre>
<p>This is my keyboard repeat rate. Because it is too fast, many games can&#x2019;t work correctly with this.</p>
<p>What worked well</p>
<ul>
<li>GTK</li>
<li>Qt</li>
<li>Firefox and web games</li>
<li>GLFW3 (including raylib)</li>
</ul>
<p>What worked poorly</p>
<ul>
<li>Godot games</li>
<li>Unity games</li>
<li>Unity games on Wine</li>
</ul>
<p>I suspect it is because 1 of 2 reasons.</p>
<ol>
<li>Key repeat is recognized as noraml key press. In XInput, the repeat flag of a XIEvent would be set. Ignore those.</li>
<li>Keyboard state is not calculated correctly.</li>
</ol>
<p>If possible, I recommending using a game engine that let&#x2019;s you handle input events as events, not &#x201c;current state&#x201d;.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/06-static-site-lume/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/06-static-site-lume/"/>
    <title>Buliding Static Site with Lume and Deno</title>
    <published>2023-04-14T12:00:00Z</published>
    <updated>2023-04-14T12:00:00Z</updated>
    <category term="meta"/>
    <category term="lang:Typescript"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/06-static-site-lume/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Recently, I&#x2019;ve ported this website to use <a href="https://lume.land/">Lume</a>.</p>
<p>Here&#x2019;s my <code>_config.ts</code> setup.</p>
<pre><code class="language-ts">import lume from &quot;lume/mod.ts&quot;
import code_highlight from &quot;lume/plugins/code_highlight.ts&quot;
import filterPages from &quot;lume/plugins/filter_pages.ts&quot;
import inline from &quot;lume/plugins/inline.ts&quot;
import jsx_preact from &quot;lume/plugins/jsx_preact.ts&quot;
import katex from &quot;lume/plugins/katex.ts&quot;
import mdx from &quot;lume/plugins/mdx.ts&quot;
import minifyHTML from &quot;lume/plugins/minify_html.ts&quot;;
import nav from &quot;lume/plugins/nav.ts&quot;
import postcss from &quot;lume/plugins/postcss.ts&quot;
import relative_urls from &quot;lume/plugins/relative_urls.ts&quot;
import remark from &quot;lume/plugins/remark.ts&quot;
import resolve_urls from &quot;lume/plugins/resolve_urls.ts&quot;
import sitemap from &quot;lume/plugins/sitemap.ts&quot;
import source_maps from &quot;lume/plugins/source_maps.ts&quot;
import windi_css from &quot;lume/plugins/windi_css.ts&quot;

const site = lume()

site.use(remark())
site.use(code_highlight())
site.use(jsx_preact())
site.use(katex())
site.use(mdx())
site.use(nav())
site.use(postcss())
site.use(relative_urls())
site.use(resolve_urls())
site.use(sitemap())
site.use(source_maps())
site.use(windi_css({ preflight: false }))
site.use(minifyHTML({extensions: [&quot;.html&quot;, &quot;.css&quot;]}))
site.use(inline())

site.ignore(&quot;readme.md&quot;)
site.copy([&quot;.jpg&quot;, &quot;.gif&quot;, &quot;.png&quot;, &quot;.webp&quot;, &quot;.svg&quot;])

site.use(
  filterPages({
    fn: (page) =&gt; !page.data.draft,
  })
)

export default site
</code></pre>
<h2>Navigation Menu</h2>
<p><a href="https://lume.land/plugins/nav/">The <strong>nav</strong> plugin</a> is useful for generating TOC (like the one at <a href="/blog/">/blog/</a>).</p>
<h2>Atom Feed</h2>
<p>You can generate arbitrary content by returning a <code>String</code> from a <code>.tsx</code> file.</p>
<p>Here&#x2019;s my file generating atom feed: <code>all.atom.xml.tsx</code></p>
<p><code>post.data.children</code> is only populated <strong>after</strong> the blog posts are rendered, thus <code>renderOrder = 1</code> <a href="https://lume.land/docs/core/render-order/">(lume doc)</a>.</p>
<pre><code class="language-ts">import { assert } from &quot;https://deno.land/std@0.224.0/assert/assert.ts&quot;
import type { Nav } from &quot;lume/plugins/nav.ts&quot;

import { unified } from &quot;npm:unified&quot;
import rehypeParse from &quot;npm:rehype-parse&quot;
import rehypeStringify from &quot;npm:rehype-stringify&quot;

async function toXML(htmlContent: string): string {
  const file = await unified()
    .use(rehypeParse, { fragment: true })
    .use(rehypeStringify, { closeSelfClosing: true })
    .process(htmlContent)

  return String(file)
}

export const url = &quot;./all.atom.xml&quot;
export const renderOrder = 1

export default async ({ nav }: { nav: Nav }) =&gt; {
  let newest_mtime = &quot;0000-00-00&quot;
  const posts = nav.menu(&quot;/blog&quot;)!.children!
  posts.forEach((post) =&gt; {
    assert(post.data.mtime, `&#x24;{post.slug} has no mtime`)
    if (post.data.mtime &amp;&amp; post.data.mtime &gt; newest_mtime) {
      newest_mtime = post.data.mtime
    }
  })

  const entries = await Promise.all(
    posts.map(
      async (post) =&gt; `
  &lt;entry&gt;
    &lt;title&gt;&#x24;{post.data.title}&lt;/title&gt;
    &lt;link href=&quot;/blog/&#x24;{post.slug}/&quot;/&gt;
    &lt;id&gt;&#x24;{post.slug}&lt;/id&gt;
    &#x24;{post.data.mtime ? `&lt;updated&gt;&#x24;{post.data.mtime}&lt;/updated&gt;` : &quot;&quot;}
    &lt;content&gt;&#x24;{await toXML(post.data.children)}&lt;/content&gt;
  &lt;/entry&gt;`
    )
  )

  return `
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;feed xmlns=&quot;http://www.w3.org/2005/Atom&quot;&gt;
  &lt;title&gt;Locria&apos;s info dump&lt;/title&gt;
  &lt;link href=&quot;https://www.1a-insec.net/&quot;/&gt;
  &lt;updated&gt;&#x24;{newest_mtime}&lt;/updated&gt;
  &lt;author&gt;
    &lt;name&gt;Locria Cyber&lt;/name&gt;
  &lt;/author&gt;
  &lt;id&gt;urn:uuid:629b78bb-c1f9-4868-ab5b-3ff5c013575a&lt;/id&gt;
&#x24;{entries.join(&quot;\n&quot;)}
&lt;/feed&gt;
`.trim()
}
</code></pre>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/05-provably-safe-programs/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/05-provably-safe-programs/"/>
    <title>Provably Safe System Programming</title>
    <published>2023-01-29T12:00:00Z</published>
    <updated>2023-01-29T12:00:00Z</updated>
    <category term="comp"/>
    <category term="lang:F*"/>
    <category term="lang:Lean4"/>
    <category term="lang:Idris2"/>
    <category term="lang:Koka"/>
    <category term="lang:Ante"/>
    <category term="lang:Neut"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/05-provably-safe-programs/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Recently I&#x2019;ve tried to find a safer way to write software than using Rust. There are two approaches: dependent types, and language-supported algebraic effects.</p>
<p>By the way, I think a language should support three kinds of primitives:</p>
<ul>
<li>Nat/Int (beta reduction)</li>
<li>List (singly linked list -&gt; flat buffer)</li>
<li>Stackable Monads (erased at run time)</li>
</ul>
<p>All the languages this articles have either type that depend on term, or have algebraic effects (or planned). Neither of them require manual memory management (they use copy by value semantic).</p>
<p>Anyway, here&#x2019;s the code.</p>
<h2><a href="https://github.com/FStarLang/FStar">F*</a></h2>
<p>F Star is in the ML family, but with dependent types. It compiles to OCaml. Personally, it&#x2019;s too verbose for me.</p>
<p><code>Hello.fst</code>:</p>
<pre><code class="language-ocaml">module Hello

open FStar.HyperStack.ST
open LowStar.Printf

val main : unit -&gt; St unit
let main () =
    let a = 1 in
    print_string &quot;hello&quot;;
    print_string (Printf.sprintf &quot;Hello %d\n&quot; a);
    ()
</code></pre>
<p>build script:</p>
<pre><code class="language-shell">fstar --extract Hello --codegen OCaml --odir out Hello.fst
ocamlbuild -pkg batteries -pkg fstarlib out/Hello.native
</code></pre>
<p>It also has a subset (Low*), which compiles to simple C. You can&#x2019;t use the I/O part of F* standard library if you plan to compile to C, since it is only written in OCaml.</p>
<blockquote>
<p>Bring your own native libraries! All the languages in this articles don&#x2019;t have much ecosystems. You should be able to use C/Zig libraries quite easily with them though.</p>
</blockquote>
<h2><a href="https://github.com/leanprover/lean4">Lean Prover 4</a></h2>
<p>Lean Prover is a language associated with Microsoft. It has the best syntax of all the compile-time type checked languages I tried.</p>
<p>It generates POSIX C, which you need Emscripten to compile to WASM/JS.</p>
<blockquote>
<p>BTW, When I say &#x201c;POSIX C&#x201d; is this article, I mean the generated binary depends on POSIX API that can&#x2019;t be easily ported to WASM. I tried to compile every single language to WASM with Zig, but they are too heavily coupled with POSIX API.</p>
</blockquote>
<p><code>Hello.lean</code>:</p>
<pre><code>def hello := &quot;world&quot;
</code></pre>
<p>compile:</p>
<pre><code class="language-shell">lean -c Hello.c Hello.lean
leanc -o Hello Hello.c
</code></pre>
<p><code>leanc</code> is just a clang wrapper script. You should can use Zig for this.</p>
<h2><a href="https://github.com/idris-lang/Idris2">Idris 2</a></h2>
<p>Idris is the language made for academic use. However, it has a refc backend that compiles the code to POSIX C. The FFI is a bit confusing, and it also can&#x2019;t create static/shared native libraries. If you want to create a native library, you need to use the output C code and C compiler to do it yourself (omitted due to scope of this article).</p>
<p><code>hello.idr</code>:</p>
<pre><code>main : IO ()
main = putStrLn &quot;Hello&quot;
</code></pre>
<p>compile: <code>idris2 --cg refc -o hello hello.idr</code></p>
<p>Note that the executable is created at <code>build/exec/hello</code>.</p>
<h2><a href="https://github.com/koka-lang/koka">Koka</a></h2>
<p>A language by the creators of Lean (also from Microsoft). The runtime is also tied to POSIX systems.</p>
<p>I think it is the first language implementing algebraic effects. If not for the papers by its authors, my language (algograph) would not exist.</p>
<p>Currently it&#x2019;s under a heavy rewrite, so the official documentation lagged behind. I recommend checking this a year later.</p>
<h2><a href="https://github.com/jfecher/ante">Ante</a></h2>
<p>An interesting language that use Cranelift/LLVM. It doesn&#x2019;t have dependent types. <strong>Algebraic effects is only planned.</strong></p>
<p>It has a good syntax, and the cleanest codegen output I&#x2019;ve seen.</p>
<p><code>hello.an</code>:</p>
<pre><code>print &quot;Hello, World!&quot;
</code></pre>
<p>compile to WASM:</p>
<pre><code class="language-shell">ante -eir --backend llvm hello.an &gt; hello.ll
zig cc --target=wasm32-wasi hello.ll
wasmtime a.out
</code></pre>
<p>I actually succeed building this to WASM on first try with <a href="https://ziglang.org/">Zig</a>! Try using Zig as a C/LLVM IR compiler yourself!</p>
<h2><a href="https://github.com/vekatze/neut">Neut</a></h2>
<p>I had no idea what I was looking, and I still have no idea. Don&#x2019;t read any documentation, since it&#x2019;s all out-dated. <a href="https://github.com/vekatze/neut/issues/13#issuecomment-1407511636">Read this instead</a>.</p>
<p>It seems to compile to LLVM IR as well. It&#x2019;s still too early to be used though, I think. Maybe a year later.</p>
<hr/>
<p>That&#x2019;s all. Wish you code with less pain.</p>
<p>P.S. On a tangent note, <a href="https://futhark-lang.org/">Futhark</a> compiles to C/OpenCL/CUDA that makes your code go brrrrrrrrr.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/04-social-dos/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/04-social-dos/"/>
    <title>Social Denial of Service</title>
    <published>2022-12-30T12:00:00Z</published>
    <updated>2022-12-30T12:00:00Z</updated>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/04-social-dos/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>I have seen many cases, where one person violate public expectation so much, that the authority has to introduce an overly strict rule (sometimes draconian). And the rule makes everyone worse off. An example of this is the sudden &#x201c;upgrade&#x201d; of airport security after 9-11. Even till this day, there is still too much &#x201c;security&#x201d;, and the time wasted for a full-body search is not worth the security benefit.</p>
<p>In short, even if the slapstick rule only targets the mischievous 0.001, the rest 0.999 are forced to suffer inconvenience. I call this kind of problem &#x201c;denial of service attack&#x201d;, named after a (conceptually) related kind of attack against computer networks.</p>
<p>Although this name is not quite apt, since the mischievous often doesn&#x2019;t <strong>intend</strong> to make everyone else&#x2019;s day worse. If you have a better name for this, tell me.</p>
<p>Anyone, as a sociologist trained with statistical tools aimed to <strong>precisely</strong> solve a problem like this, seeing rules like this in person makes my head hurt.</p>
<p>If you are subject to stupid rules like this, challenge it; propose a less intrusive solution. (more often than not) If the relevant authority doesn&#x2019;t listen to you, then you have a bigger problem to worry about (I recommend <a href="https://en.wikipedia.org/wiki/Non-cooperation_movement">non-cooperation</a>).</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/02-equality-should-not-be-instrumental/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/02-equality-should-not-be-instrumental/"/>
    <title>Equality Should Not Be Instrumental</title>
    <published>2023-11-27T12:00:00Z</published>
    <updated>2024-06-14T12:00:00Z</updated>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/02-equality-should-not-be-instrumental/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>As a sociologist, I have known this concept for a long time, and I have planned to write about this before I created this website (see the sequence number, 02). Now I have learned more about human languages, emotions, and society, I am now ready to convey the idea clearly.</p>
<p>In short,</p>
<p>The cry for equality arise from an unfair situation, usually from the weak (the weak side in that situation).</p>
<p>If you are a public policy maker, you should seek to resolve the underlying situation, but in no way should you use &#x201c;equality&#x201d; as a reason for a public policy.</p>
<p>To be respected. To have enough money to buy food and live well. To fulfill aspiration in life. Those are the goals that the people want, and are what you should aim for. The actual goal depends on the exact situation you face, and you should<sup class="footnote-ref"><a href="#fn1" id="fnref1">[1]</a></sup> be able to figure that out yourself.</p>
<p>&#x201c;Unfair&#x201d; is a feeling, so each person has a different opinion on what is &#x201c;unfair&#x201d; to them.</p>
<p>By extension, &#x201c;inequality&#x201d; is also a feeling; it signifies that whoever is calling for it has been wronged, and they want their voice to be heard, their needs to be met.</p>
<p>Yet, it is a signal, not a goal. So do not use &#x201c;equality&#x201d; as a goal in policy making.</p>
<h2>My Thoughts On This</h2>
<p>I hate politicians who cry &#x201c;equality&#x201d; but do nothing to improve the people&#x2019;s living condition.</p>
<p>In some sense, the opponents of the &#x201c;woke culture&#x201d; (as they call it) are right about &#x201c;equality&#x201d; being weird.</p>
<hr class="footnotes-sep"/>
<section class="footnotes">
<ol class="footnotes-list">
<li id="fn1" class="footnote-item"><p>To be honest, being forced to choose someone to rule over you (representative democracy) is probably a mistake. Being a ruler <strong>need</strong> knowledge, which some politicians don&#x2019;t have. <a href="#fnref1" class="footnote-backref">&#x21a9;&#xfe0e;</a></p>
</li>
</ol>
</section>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/00-two-mistakes/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/00-two-mistakes/"/>
    <title>The Two Biggest Societal Mistakes</title>
    <published>2022-12-06T12:00:00Z</published>
    <updated>2023-11-27T12:00:00Z</updated>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/00-two-mistakes/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Out of all public policy ideas, the two listed below are the most important for people to know about.</p>
<p>tl;dr</p>
<ol>
<li>make police civil organizations that can be founded more freely to introduce competition</li>
<li>collect tax on ownership of land and similar resources based on public demand</li>
</ol>
<h2>Centralization of Violence</h2>
<p>Violence is necessary to maintain peace, or at least to prevent your stuff from being stolen. However, letting someone else use violence for you is not such a good idea, especially when everybody delegates use of violence to the same person/party (social contract).</p>
<p>Throughout history, police around the world have been recorded harming unarmed persons with no good reason. (If you can&#x2019;t think of an example, read the news in your region.)</p>
<p>By definition, police represent violence, because only they can use violence for other&#x2019;s sake without punishment. Like all service type, to ensure the service quality, policing need competition. They, like other organizations, are not going to self-regulate without external pressure.</p>
<p>Neighborhood watch, security companies using intimidation tactics (but not violence), militarized gangs already have varying degrees of success at preventing crimes depending on the region. Consult your local shop owners for advice on what works best.</p>
<p>In some parts of the world, violence is used for dubious purposes. For example, in the US, the government uses violence to prevent manufacturing medicine. This is otherwise known as &#x201c;patent&#x201d;. This is unacceptable to me, and an alarming development of our civilization. You should be worried about where this is heading towards.</p>
<h2>Exclusivity of Nonfungible Resource without Cost</h2>
<p>&#x201c;Whoever comes first, owns the land forever.&#x201d; Such is the rule about land ownership. In my opinion, exclusive ownership of irreplaceable resource that lasts forever is a bad idea.</p>
<p>&#x201c;Nonfungible&#x201d; means that a type of resource is limited and cannot be moved around to be exchanged. For example, a parcel of land in city center is different from the same area of land in suburb. Some nonfungible resources are&#x2026;</p>
<ul>
<li>land</li>
<li>the right to sunlight (a thing in Japan)</li>
<li>radio frequency space</li>
</ul>
<p>By this doctrine, tax based on <strong>the value of the house</strong> should be instead based on <strong>value of the land underneath</strong>. What is built on the land should not matter. The owner of that land should pay people who live around it based on how they would pay for the exact parcel of land.</p>
<p>In my opinion, it is better to distribute the &#x201c;tax&#x201d; directly to people who live around that place, than giving it to one entity (the government). How this can be done, and how to calculate the value of land is up to the people of that region to decide. I think it should be no more complex than the tax system we already have under a central government. With today&#x2019;s mathematical advancements, it is possible.</p>
<p>To end this section, I will emphasize that this way of &#x201c;renting&#x201d; nonfungible nature resources applies to not just land, but all stuff not interchangeable with stuff of the same kind. This policy will prevent accumulation of wealth from spiraling out of control.</p>
<h2>Rationale</h2>
<p>The first policy suggestion comes from the observation that everyone was capable of violence; laws deprive people of the right to use violence, but create a monopoly on violence to the police. In the end, there is nobody to stop the police from abusing power or refuse to help when violence is needed.</p>
<p>The Media can soften the police, making them more unwilling to use violence. However, violence is necessary to protect private property, and to keep peace. 40 years ago it was acceptable for people to beat thieves themselves. Now it&#x2019;s considered &#x201c;vigilante&#x201d;.</p>
<p>My idea might end up being impractical, but I think we must try to improve on the current situation. We should test other policies in conjunction and pick whatever works. Randomized control trail is best at this.</p>
<p>The second policy suggestion spawns from the belief that we don&#x2019;t own Nature, Georgism, and rising housing price. I don&#x2019;t have much to add to what was already said on the topic. Read about Georgism if you want to learn more.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/29-framerate-detection-in-glfw/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/29-framerate-detection-in-glfw/"/>
    <title>Frame Rate Detection in GLFW</title>
    <published>2023-12-20T12:00:00Z</published>
    <updated>2023-12-20T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/29-framerate-detection-in-glfw/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>First, some background on GLFW and frame rate and event loop.</p>
<p>In GLFW+OpenGL, if the swap interval is set to 1, <code>glfwSwapBuffers</code> will block until next frame is displayed. If it is set to 2, <code>glfwSwapBuffers</code> calls will return on every two frames of the physical display shown.</p>
<p><img src="overview.png" alt="frame-swap timeline. every frame is drawn by the previous frame."/></p>
<p>Then, it is easy to measure the display refresh rate as time difference between <code>glfwSwapBuffers</code> calls.</p>
<p>Since I have already written <a href="https://git.envs.net/iacore/nanovg-test">the code</a>, please refer to it for how exactly the frame-rate detection can be done.</p>
<pre><code># download code example and run
git clone --branch fps-detector https://git.envs.net/iacore/nanovg-test
cd nanovg-test
zig build run
</code></pre>
<h2>Not Much Choice for Application Frame Rate</h2>
<p>Let&#x2019;s say your monitor&#x2019;s refresh rate is 120Hz. Graphical application using the monitor can only display at 120Hz, 60Hz, 40Hz, 30Hz&#x2026; which is 1, &#xbd;, &#x2153;, &#xbc; of the original refresh rate.</p>
<p>Some games just have a list of fixed numbers you can choose from. 50Hz on a 120Hz monitor? :S Witchcraft!</p>
<h2>Late Swap and <code>GLX_EXT_swap_control_tear</code></h2>
<p>In <a href="https://registry.khronos.org/OpenGL/extensions/EXT/GLX_EXT_swap_control_tear.txt">the original <code>GLX_EXT_swap_control_tear</code> document</a>, it says</p>
<blockquote>
<p>When an unsynchronized swap happens,
the missed frame will count towards the minimum number of video frames
for the next swap.</p>
</blockquote>
<p>From the wording, I think it works like this.</p>
<p><img src="late-swap.png" alt="if the frame arrives late, "/></p>
<p>In the code, it looks like this.</p>
<pre><code class="language-zig">    if (c.glfwExtensionSupported(&quot;GLX_EXT_swap_control_tear&quot;) != 0) {
        c.glfwSwapInterval(-1);
    } else {
        c.glfwSwapInterval(1);
    }
</code></pre>
<h2>Bonus Point: Ancient Predictive Trick</h2>
<p>I read awhile back that if you can predict the time it takes to run game logic and draw content on screen, you can wait just enough to make the game fraction-of-a-frame more responsive. The player inputs received during the &#x201c;wait&#x201d; period will be reflected immediately on the next frame.</p>
<p><img src="delay-update.png" alt="program go idle to give the user time to perceive the new frame before checking inputs"/></p>
<p>On newer monitors with fast refresh rates, this is probably not necessary.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/27-mir-codegen/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/27-mir-codegen/"/>
    <title>Thoughts on MIR and Codegen</title>
    <published>2023-11-26T12:00:00Z</published>
    <updated>2024-01-20T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/27-mir-codegen/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p><a href="https://github.com/vnmakarov/mir">MIR</a> generates <a href="https://github.com/vnmakarov/mir/discussions/380">non-relocatable machine code</a> from its own IR. It&#x2019;s very fast, fast enough that you can cache the IR and generate machine code every time you run a program with MIR.</p>
<p>Initially I planned to wrote about MIR with a simple example. however, I ended up modifying MIR a bit, and did not find any new trick.</p>
<p>If you have prior understanding for assembly language, MIR&#x2019;s documentation is pretty good! Make sure you read all the .md files in <a href="https://github.com/vnmakarov/mir">the repo</a> though. Otherwise you may be just as confused as I was.</p>
<h2>Is JIT needed at all?</h2>
<p>JIT is not needed. interpreter is easier to write and safer.</p>
<p>a discussion with people in r/PL discord:</p>
<h2>Janet Bytecode</h2>
<p>Janet bytecode is probably better. in Janet, arrays and tables are first-class objects. if I ever have to make another language, using Janet bytecode as the codegen target is probably easier than using MIR as the codegen target.</p>
<h2>References</h2>
<p><a href="https://github.com/vnmakarov/mir">MIR</a></p>
<p><a href="https://tbrindus.ca/how-builtin-expect-works/">branch predictor</a></p>
<p><a href="http://ratfactor.com/repos/meow5/">meow5</a></p>
<p><a href="https://www.greenarraychips.com/">arrayForth</a></p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/26-life-of-a-bug-report/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/26-life-of-a-bug-report/"/>
    <title>Life of a Bug Report</title>
    <published>2023-11-23T12:00:00Z</published>
    <updated>2023-11-23T12:00:00Z</updated>
    <category term="soc"/>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/26-life-of-a-bug-report/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Recently, a cultural wind of &#x201c;hating on stale bot&#x201d; has reached me. It made me think, what is a good way to manage software bug reports?</p>
<p>After 2 days of thinking, I came up with this scheme from scratch (not learning from any existing bug report management scheme). Any resemblance with existing bug tracking scheme is coincidental. Any resemblance with TCP is intentional.</p>
<h2>Terminology Used</h2>
<p>Issue: a bug report</p>
<p>Reporter: whoever cares to diagnose the problem. this could be who filed the issue, or someone who found the same problem but did not create the issue</p>
<p>Maintainer: whoever will handle/is working on/solved the issue.</p>
<p>The four discrete states an issue can be in are shown in the format</p>
<pre><code>STATE-NAME: its condition to be met
</code></pre>
<h2>Tale of an issue who lived an uneventful life</h2>
<p>Here is an issue that passed through all four stages/states in our scheme.</p>
<pre><code>issue opened
SYN-RECEIVED: reporter has the will to cooperate in diagnosing the problem (sometimes they just disappear)
ESTABLISHED: maintainer and reporter has reached an understanding of the problem
CLOSE-WAIT: maintainer think they have fixed the bug
CLOSED: reporter confirmed the fix
issue closed
</code></pre>
<h2>How to use this scheme</h2>
<p>Create one tag for each of the four states.</p>
<p>Apply a tag when, and only when its condition is met. Sometimes you need to remove the <code>ESTABLISHED</code> tag because the maintainer has not understood the problem at hand.</p>
<p>The four states are strictly monotonic, so an issue can be tagged with both <code>SYN-RECEIVED</code> and <code>ESTABLISHED</code>, or just <code>ESTABLISHED</code> (if your bug tracker only supports one active state).</p>
<p>You may also need tags like <code>wont-fix</code>. You are expected to modify this scheme to make it work for <strong>your</strong> project.</p>
<p>That&#x2019;s it.</p>
<p>For more information, please re-read.</p>
<h2>Why does it work</h2>
<p>personal connection something something</p>
<p>I am not going to convince you to use my scheme. Use it or not.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/25-zig-reference-semantics/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/25-zig-reference-semantics/"/>
    <title>Zig May Pass Anything By Reference</title>
    <published>2023-11-21T12:00:00Z</published>
    <updated>2023-11-22T12:00:00Z</updated>
    <category term="comp"/>
    <category term="lang:Zig"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/25-zig-reference-semantics/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p><a href="https://ziglang.org/documentation/0.11.0/#Pass-by-value-Parameters">Zig may pass non-primitive parameters into function by reference.</a> It may also pass non-primitive result location by reference.</p>
<p>To run the code snippets below, past the code into a file and run it with <code>zig run file.zig</code> (only guaranteed to work with Zig 0.11.0).</p>
<p>Alternatively, you can also run the code on <a href="https://zig-play.dev/">this Zig Playground</a>. Thanks <a href="https://lobste.rs/s/et3ivs/zig_may_pass_everything_by_reference#c_klicv0">dpc_pw</a>!</p>
<p>The code snippets are provided by <code>Lemon Drop</code> and <code>Levy</code> in the Zig Matrix room. (feel free to join!)</p>
<hr/>
<p>Here is a buggy program that you can run with Zig 0.11.0. The output will be unexpected!</p>
<pre><code class="language-zig">const AAAA = struct {
    foo: [100]u32,
};

fn aaaaa(a: AAAA, b: *AAAA) void {
  b.*.foo[0] = 5;

  std.debug.print(&quot;wtf: {}&quot;, .{ a.foo[0] });
}

pub fn main() !void {
    var f: AAAA = undefined;

    f.foo[0] = 0;

    aaaaa(f, &amp;f);
}
</code></pre>
<p>Lesson: do not alias, ever.</p>
<hr/>
<p>Here is another buggy program. <code>x</code> is a result location, and is taken by reference on both sides of the assignment.</p>
<pre><code class="language-zig">const std = @import(&quot;std&quot;);
const What = struct { a: u8, b: u8 };

pub fn main() void {
    var x: What = .{ .a = 1, .b = 2 };
    x = .{ .a = x.b, .b = x.a };
    std.log.info(&quot;wtf: {}&quot;, .{x});
}
</code></pre>
<p>Lesson: do not put the same variable on both sides of an assignment.</p>
<p>Solution: Use a temp variable to store the new value, like how you swap two variables in C.</p>
<pre><code class="language-zig">pub fn main() void {
    var x: What = .{ .a = 1, .b = 2 };
    const tmp = .{ .a = x.b, .b = x.a };
    x = tmp;
    std.log.info(&quot;wtf: {}&quot;, .{x});
}
</code></pre>
<p>Update(2025-06-10): This behavior is now codified in Zig 0.14.0 as &#x201c;Result Location Semantics&#x201d;. See <a href="https://ziglang.org/documentation/0.14.0/#Result-Locations">https://ziglang.org/documentation/0.14.0/#Result-Locations</a></p>
<h2>Thoughts</h2>
<p>I have long thought Zig works like C: when I pass a struct itself (not a pointer), it is passed by-copy. I am lucky to have never met a bug because of this misunderstanding.</p>
<p>oof</p>
<h2>Further Readings</h2>
<p><a href="https://github.com/ziglang/zig/issues/12064">https://github.com/ziglang/zig/issues/12064</a></p>
<p><a href="https://lobste.rs/s/et3ivs/zig_may_pass_everything_by_reference#c_yvfrnq">andrewrk has recommended</a> watching <a href="https://www.youtube.com/watch?v=dEIsJPpCZYg">this video on the topic of result location semantics</a>.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/24-trying-capsicum/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/24-trying-capsicum/"/>
    <title>Writting Secure Programs using Capsicum on FreeBSD</title>
    <published>2023-11-19T12:00:00Z</published>
    <updated>2024-06-29T12:00:00Z</updated>
    <category term="comp"/>
    <category term="lang:C"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/24-trying-capsicum/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <blockquote>
<p>Someone wrote <a href="https://val.packett.cool/blog/use-openat/">an article about using <code>openat</code> in Capsicum</a>. It has more words than this one. Maybe you want to read that too.</p>
<p>I <a href="/w/19-secure-memory-vulnerability/">made a joke</a> using Capsicum!</p>
</blockquote>
<hr/>
<p>Recently I heard <a href="https://wiki.freebsd.org/Capsicum">this capability subsystem that I kept spelling as &#x201c;Capsium&#x201d;</a> is supposed to easy to add to existing UNIX programs. The good news is, it is on FreeBSD right now, and I can use it! (You too!) The bad news is that <a href="https://lore.kernel.org/all/1404124096-21445-1-git-send-email-drysdale@google.com/">it&#x2019;s not on Linux, and probably never will be.</a></p>
<p>Reminder: Please apply the newest security patches on your FreeBSD installation before using Capsicum.</p>
<p>After installing FreeBSD, here&#x2019;s the singular C program that I wrote to try out Capsicum.</p>
<pre><code class="language-c">#include &lt;stdio.h&gt; 
#include &lt;sys/capsicum.h&gt; 
 
int main() { 
    int cwd_fd = open(&quot;.&quot;, O_RDONLY|O_DIRECTORY); 
    cap_enter(); 
    puts(&quot;hello&quot;); // write to stdout 
    int hello_c_fd = openat(cwd_fd, &quot;hello.c&quot;, O_RDONLY); 
    int parent_fd = openat(cwd_fd, &quot;..&quot;, O_RDONLY); 
    printf(&quot;%d %d %d\n&quot;, cwd_fd, hello_c_fd, parent_fd); 
}
</code></pre>
<p>Then, I ran it with root (<code>cc cap_hello.c &amp;&amp; ./a.out</code>) and it gave me this output.</p>
<pre><code>hello
3 4 -1
</code></pre>
<p>It works! Capsicum seems super easy to use!</p>
<p>What&#x2019;s the <code>errno</code> when the fd has insufficient capability (in this case, <code>openat(cwd_fd, &quot;..&quot;, O_RDONLY)</code>)? It&#x2019;s <code>93 ENOTCAPABLE</code>. See <a href="https://man.freebsd.org/cgi/man.cgi?errno(2)"><code>errno(2)</code></a>.</p>
<p>For more usage of Capsicum, see <a href="https://git.envs.net/iacore/freebsd-playground">my FreeBSD experimentation repo</a>.</p>
<p>That&#x2019;s it for now bye~</p>
<h2>How Does This Works Exactly</h2>
<p>After <code>cap_enter</code>, only file descriptors have access to OS resources. This makes access control very easy to reason about. <code>..</code> is disallowed in <a href="https://man.freebsd.org/cgi/man.cgi?open(2)">openat(2)</a>, so you can&#x2019;t navigate a fd upwards.</p>
<p>Every file descriptor (fd) stores a list of syscalls it is willing to be used with (see <a href="https://man.freebsd.org/cgi/man.cgi?rights(4)">rights(4)</a>). By default, all syscalls are allowed. There is one &#x201c;capability&#x201d; for each syscall, and the granularity is per fd.</p>
<p>Basically, you can limit the set of syscalls that can be used with a fd. When in doubt, use pipes for IPC and <code>CAP_READ|CAP_WRITE|CAP_SHUTDOWN</code>.</p>
<p>The complete list of &#x201c;file&#x201d; types can be found in <a href="https://github.com/freebsd/freebsd-src/blob/0b1c5628c74a37e2aa2aa3769c606d3e826302f8/sys/kern/kern_descrip.c#L5007-L5045">FreeBSD&#x2019;s source code</a>.</p>
<ul>
<li><strong>zero</strong> (i dunno what this is)</li>
<li><strong>vnode</strong> (file or directory)</li>
<li><strong>socket</strong></li>
<li><strong>pipe</strong></li>
<li><strong>fifo</strong> (named pipe)</li>
<li><strong>kqueue</strong></li>
<li><strong>crypto</strong> (hardware-accelerated cryptography device)</li>
<li><strong>mqueue</strong></li>
<li><strong>shm</strong> (shared memory (<a href="https://man.freebsd.org/cgi/man.cgi?shm_open(2)">shm_open(2)</a>))</li>
<li><strong>ksem</strong> (POSIX P1003.1B semaphores support (<a href="https://man.freebsd.org/cgi/man.cgi?sem(4)">sem(4)</a>))<br/>
Does anyone use this nowadays?</li>
<li><strong>pts</strong> (pseudo-terminal device)</li>
<li><strong>dev</strong></li>
<li><strong>proc</strong></li>
<li><strong>eventfd</strong> (wait/notify)<br/>
More people should use this!</li>
<li><strong>timerfd</strong><br/>
And I quote from timerfd(2): All timerfd descriptors possess traditional file descriptor semantics; they may be passed to other processes, preserved across fork(2), and monitored via kevent(2), poll(2), or select(2).<br/>
Remember this property of file descriptors, as this is very useful when used with capsicum.</li>
</ul>
<p>Musing: proc fd cannot refer to the current process. To send signal to current process, use <code>getpid</code>+<code>kill</code>(2 syscalls!), which capsicum allows.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/23-wary-of-rust/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/23-wary-of-rust/"/>
    <title>I am wary of Rust&apos;s Future</title>
    <published>2023-11-17T12:00:00Z</published>
    <updated>2023-11-17T12:00:00Z</updated>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/23-wary-of-rust/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>This is yet another of my prediction without reason. Heed my warning (or not).</p>
<p>In the past year, The Rust Foundation has done some things.</p>
<ul>
<li>The Trademark Shenanigan&#x2122;</li>
<li>2023-05-26 <a href="https://thephd.dev/i-am-no-longer-speaking-at-rustconf-2023">https://thephd.dev/i-am-no-longer-speaking-at-rustconf-2023</a></li>
<li>2023-05-28 <a href="https://fasterthanli.me/articles/rust-the-wrong-people-are-resigning">https://fasterthanli.me/articles/rust-the-wrong-people-are-resigning</a></li>
<li>2023-05-28 <a href="https://www.jntrnr.com/why-i-left-rust/">https://www.jntrnr.com/why-i-left-rust/</a></li>
<li>2023-05-31 <a href="https://fasterthanli.me/articles/the-rustconf-keynote-fiasco-explained">https://fasterthanli.me/articles/the-rustconf-keynote-fiasco-explained</a></li>
<li>2023-08-22 <a href="https://foundation.rust-lang.org/news/member-spotlight-helsing/">https://foundation.rust-lang.org/news/member-spotlight-helsing/</a></li>
</ul>
<p>My social sense is telling me to prepare to move away from Rust the language. I tried looking for a difference between Rust the language and Rust the foundation. I could not find a slit in between. Therefore, I assume they are stuck together fate-wise.</p>
<p>I have not written any Rust code in the past few months. Not because I tried to stay away from Rust, but that I did not have a need to use it.</p>
<p>I understand that Rust empowers people to write reliable code, and it is a genuinely useful language.</p>
<p>Think for yourself and do what you will.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/22-departure-from-average/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/22-departure-from-average/"/>
    <title>Departure from the Mean</title>
    <published>2023-11-01T12:00:00Z</published>
    <updated>2023-11-01T12:00:00Z</updated>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/22-departure-from-average/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>I am now seeing a social trend unfolding around me. If Renaissance made individuals important, people are now acting less like other people around them. I predict that we will see more identities and concepts that we don&#x2019;t yet have words for emerge, until there are too much for the average person to hold all the concepts in their head. Population will be more diverse (diverge from each other). Grammar will matter less. Instead of &#x201c;what people do and achieve&#x201d;, &#x201c;what people are&#x201d; will be the meaning of life for more people.</p>
<p>For lack of a better phrase, I&#x2019;ll call this &#x201c;(Great) Departure from the Mean&#x201d;. Let history tell the rest.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/21-semgrep-search-ast/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/21-semgrep-search-ast/"/>
    <title>Find and Replace Code at AST-level with Semgrep</title>
    <published>2023-10-31T12:00:00Z</published>
    <updated>2024-01-24T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/21-semgrep-search-ast/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Recently, I found a tool call semgrep that lets you find and replace code at AST-level. This tool allows me to refactor legacy code without looking through all the code in the project.</p>
<p>In this article, I will give a simple example of how to use semgrep to search in a repository, without any previous knowledge of the repo. Before you read this article, you must know how to use Semgrep. If you don&#x2019;t know Semgrep yet, check out <a href="https://semgrep.dev/learn">the official tutorial</a> (it&#x2019;s a bit buggy when I used it). Make sure you fully complete the tutorial, or you won&#x2019;t understand this article.</p>
<p>Update: For C, <a href="https://coccinelle.gitlabpages.inria.fr/website/sp.html">Coccinelle</a> may work better. It is introduced to me by <a href="https://richiejp.com/custom-c-static-analysis-tools">Richard Palethorpe</a>.</p>
<p>Update: If you use VS Code, there is a &#x201c;Semgrep&#x201d; plugin that will provide Semgrep snippets when editing any YAML file. This has been helpful to me because I cannot remember the rule syntax at all.</p>
<hr/>
<h2>Preparing the Repo</h2>
<p>To search through some code, we first need to have some code. In this article, we use the source code of Janet.</p>
<pre><code class="language-shell">git clone --depth 1 https://github.com/janet-lang/janet/
cd janet
</code></pre>
<h2>Defining the Semgrep Rule</h2>
<p>Inside the repo, create the file <code>config.yml</code> with the following content.</p>
<pre><code class="language-yaml">rules:
- id: panic
  patterns:
  - pattern-inside: |
      &#x24;RET_TY &#x24;FUNC(...) {...}
  - pattern: janet_panic(&#x24;...ARGS);
  message: |
    panic inside: &#x24;RET_TY &#x24;FUNC
  fix: |
    janet_panic(&quot;replaced&quot;);
  severity: INFO
  languages: [c]
</code></pre>
<p>What we are trying to do here, is to replace any <code>janet_panic(...)</code> call inside a function with <code>janet_panic(&quot;replaced&quot;)</code>.</p>
<ul>
<li><code>pattern-inside</code>: the pattern should be inside a function</li>
<li><code>pattern</code>: the pattern to find and delete</li>
<li><code>fix</code>: the pattern to insert/replace</li>
</ul>
<h2>Search</h2>
<p>To search through the code with semgrep, we run</p>
<pre><code class="language-shell">semgrep scan --config config.yml
</code></pre>
<p>You should now see a lot of results in your terminal like</p>
<pre><code>    src/core/string.c 
       panic               
          panic inside: void kmp_init
                                     
           &#x25b6;&#x25b6;&#x2506; Autofix &#x25b6; janet_panic(&quot;replaced&quot;)
          109&#x2506; janet_panic(&quot;expected non-empty pattern&quot;);
            &#x22ee;&#x2506;----------------------------------------
</code></pre>
<h2>Replace</h2>
<p>Since the results look good, we will now replace the search results with what we want. To do this, we run</p>
<pre><code class="language-shell">semgrep scan --config config.yml --autofix
</code></pre>
<p>Here, you can use <code>git diff</code> to verify if the files are changed correctly. Then, commit the changed files to git and we are done with the task!</p>
<h2>Additional Comments</h2>
<p>Before semgrep, I tried tree-sitter. The query language of tree-sitter does not support the equivalent of <code>pattern-inside</code> yet, so I didn&#x2019;t try it further.</p>
<p>Also, this task &#x201c;can&#x201d; be done with regex, but regex is far more flaky than searching through the code at AST level. My average experience regex is worse than my first experience with semgrep, and that says something.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/20-janet-graphical-repl/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/20-janet-graphical-repl/"/>
    <title>Graphical Janet REPL in Spirit of Self</title>
    <published>2023-10-10T12:00:00Z</published>
    <updated>2023-10-10T12:00:00Z</updated>
    <category term="comp"/>
    <category term="lang:Janet"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/20-janet-graphical-repl/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p><a href="https://codeberg.org/iacore/janet-graphical-repl">Source Code</a><br/>
Inspiration: <a href="https://selflanguage.org/">Self</a></p>
<p>I have made a graphical REPL for Janet. It works like Self, but programming is much easier than in Self.</p>
<p>Here is a video showing how it works:</p>
<p><img src="20-demo.mp4" alt=""/>
<video controls="">
<source src="20-demo.mp4" type="video/mp4"/>
Download the
<a href="20-demo.mp4">MP4</a>
video.
</video></p>
<p>Here&#x2019;s the script of the video.</p>
<pre><code>- show basic values
    - (range 10)
    - (map |(* 2 &#x24;) _var)
    - (map |(* 3 &#x24;) _)

- os access
    - (os/dir &quot;.&quot;)
    - (filter |(string/has-prefix? &quot;zig&quot; &#x24;) _)
    - (spit &quot;out&quot; (string/format &quot;%j&quot; _))
</code></pre>
<p>In case you haven&#x2019;t figured it out, <code>_</code> is the current object/window.</p>
<p>I honestly have no idea what to do with this thing I created. It is very powerful, only less powerful than the POSIX shell. Compared to Python, Janet doesn&#x2019;t have much libraries. Maybe it&#x2019;s better if I make it support IPython.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/32-representing-concept-with-linked-data/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/32-representing-concept-with-linked-data/"/>
    <title>Representing Concepts with Linked Linked-Data Links</title>
    <published>2024-01-07T12:00:00Z</published>
    <updated>2024-01-29T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/32-representing-concept-with-linked-data/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Recently, I was researching how to encode our memory and knowledge as classical/binary data. I came to the conclusion that RDF is not enough, and concepts need to reference each other.</p>
<p>Also, sorry about the title :)</p>
<p>Here is a simple example, where I assert apple is a kind of fruit.</p>
<pre><code>0: [apple] [is subset of] [fruit]
1: [self] [assert true] 0
</code></pre>
<p>Here, I assert apple is not a kind of fruit.</p>
<pre><code>0: [apple] [is subset of] [fruit]
1: [assert true] [negate]
2: [self] 1 0
</code></pre>
<p>The numbers at the start of each line can be viewed as line number is BASIC; they are essetially ID of each concept triple.</p>
<p>Also, maintaining the S-V-O triple structure is meaningless. Just store the data however is natural to you. You have to write query for each type of relation separately anyway.</p>
<h2>Prior Art</h2>
<p>W3C calls it &#x201c;Named Graph&#x201d;. You can <a href="https://en.wikipedia.org/wiki/TriG_(syntax)">read about RDF named graph in TriG here</a>.</p>
<p>Concept-based input methods are used to counter communication disability: <a href="https://knowbility.org/blog/2020/what-is-aac">AAC</a>.</p>
<h2>Other thoughts</h2>
<h3>Content-Addressed ID</h3>
<p>Unless we need to encode circular statements like &#x201c;apple is a type of apple&#x201d;, we can represent the statements as a DAG. Since this is a DAG, each statement can use the hash of its components as id, although it is not necessary.</p>
<h3>Canonicalization</h3>
<p>Maintaining a canonical form of a word is hard.</p>
<pre><code>0: [A] [like] [B]

# or

0: [A] 1 [B]
1: [feeling] - [like]
</code></pre>
<p>You can observe this on Wikidata, where family trees have the following properties:</p>
<pre><code>wdt:father [Father]
wdt:mother [Mother]
wdt:parent [Other Type Of Parent]
wdt:child  [Child]
wdt:kin_of [Kin]
    wdt:younger_brother [Younger Brother]
</code></pre>
<p>Not very clean, but it works. I suppose that any form of representation of a concept is valid.</p>
<h3>Visualization</h3>
<p>Triples can be represented as triangles, and the center of it represents the triple-link itself.</p>
<p><img src="triviz.png" alt=""/></p>
<pre><code>0&quot;(omitted)
1&quot;(omitted)
2&quot;(omitted)
3:0:1:2
4&quot;(omitted)
5&quot;(omitted)
6:3:4:5
</code></pre>
<h3>How RDF is stored in databases</h3>
<p><a href="/frag/14-triples/">I wrote about it previously here.</a></p>
<h3>Bonus Algorithm: Natural Language Formulation Based On Concepts</h3>
<p>Words are hard. In an attempt to come up with words faster, I have discovered the following algorithm.</p>
<p>Stage 0: Concepts<br/>
On this stage, you should have some concepts that you want to convey.</p>
<p>Stage 1: Materialize key words<br/>
For each main concept, look up its word in the target language.<br/>
Main concepts are the essential components of this sentence. without them, the meaning is incomplete.</p>
<p>Stage 2: Materialize auxilary words<br/>
Add adjectives and conjunctions to the sentence.<br/>
On this step, you can adjust the detail level of the final sentence by choosing how many relations to include in the final sentence.</p>
<p>Stage 3: grammar fix<br/>
Fix the grammar of the sentence.<br/>
Humans are quite fault tolerant, so this step is not strictly needed.</p>
<p>My recommendation for communicating with concept-capable beings is to communicate with them directly using concepts. It is more precise and saves energy for the other side, also that some of them cannot speak any natural language.</p>
<p><img src="i-eat-apple.png" alt="triple-graph representation of the sentence &quot;i want to eat that apple&quot;"/></p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/31-wire-routing-input-scheme/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/31-wire-routing-input-scheme/"/>
    <title>Wire Routing Control Scheme</title>
    <published>2024-01-03T12:00:00Z</published>
    <updated>2024-03-11T12:00:00Z</updated>
    <category term="comp"/>
    <category term="graphical_interface"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/31-wire-routing-input-scheme/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Recently, I thought of an interesting control scheme for top-down video games. The control scheme turns out to be quite suitable for data entry as well, so I am sharing it.</p>
<p>The code is here: <a href="https://git.envs.net/iacore/wire-routing-game">https://git.envs.net/iacore/wire-routing-game</a></p>
<p>Here is a video of me using the control scheme. You can see in the video that the control scheme doesn&#x2019;t work at some places. Workaround: don&#x2019;t have two edges on the same <a href="https://en.wikipedia.org/wiki/Line_(geometry)">line</a> in level geometry.</p>
<p><video src="./video.mp4" controls="" alt="video of me playing with wire-routing"/></p>
<p>Update: section 3.3 of <a href="https://deepnight.net/tutorial/bresenham-magic-raycasting-line-of-sight-pathfinding/">a tutorial on deepnight.net</a> described how to fix the bug seen in the video above. The wire routing algorithm needs path finding (nav mesh) in order to be stable. If you are looking at this paragraph, you can assume that I have not fixed it yet.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/30-recall/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/30-recall/"/>
    <title>Two Computational Tricks During Memory Recall</title>
    <published>2024-01-03T12:00:00Z</published>
    <updated>2024-01-03T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/30-recall/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>It has acquired the following information when studying itself. Take this knowledge, and go make the computing world less boring!</p>
<h2>Encoding Information via Entanglement</h2>
<blockquote>
WARNING: side effects of programming a human brain this way include:
<ul>
<li>loss of concept of self (includes &#x201c;self identity&#x201d;)</li>
<li>loss of self/non-self identification</li>
<li>loss of most short-term memory capacity</li>
<li>not knowing how the answer is produced</li>
<li>sleepiness</li>
</ul>
</blockquote>
<p>Here is a simplified model.</p>
<p>Information retrieval by association, a.k.a. recall, generally works like this: thinks of <code>x</code> leads to thinks of <code>y</code>.</p>
<p><img src="1-1.svg" alt="x -&gt; y"/></p>
<p>Recall can happen in parellel.</p>
<p>When serializing the answer, <code>(y0,y1,z0,z1)</code> is observed.</p>
<p><img src="1-4.svg" alt="x -&gt; y1,y2,z1,z2"/></p>
<p>Recalled information can be superimposed. Nowhere in the computation is an observation made.</p>
<p>When serializing the answer, one of <code>(y0,z0),(y1,z0),(y0,z1),(y1,z1)</code> is observed.</p>
<p><img src="1-2-2.svg" alt="x -&gt; y1,y2,z1,z2"/></p>
<p>By entangling the <code>y</code> and <code>z</code> sets, for example, make it so that <code>*0</code> <strong>or</strong> <code>*1</code> are picked together, the possible answer set is reduced.</p>
<p>When serializing the answer,<br/>
if the entanglement <code>(y0,z0)|(y1,z1)</code> is made,  one of <code>(y0,z0), (y1,z1)</code> is observed.<br/>
if the entanglement <code>(y0,z1)|(y1,z0)</code> is made,  one of <code>(y0,z1), (y1,z0)</code> is observed.</p>
<p>The choice of which entanglement to make encodes 1 bit of information.</p>
<p>For this unit, this type of information does not persist across sleep, nor does it take up storage space, nor does it consume extra energy to store. The energy used to compute the same problem for <code>n</code> inputs is definitely <code>O(n)</code>, and slightly above <code>O(1)</code> (it can only measure its energy consumption very roughly, sorry :&#x3f8;).</p>
<h2>Interleaving Information Retrieval with Computation</h2>
<blockquote>
WARNING: side effects of programming a human brain this way include:
<ul>
<li>no information is retrievable without context</li>
<li>no information is really learned without being idle (e.g. sleep)</li>
<li>(there may be more but it forgot :&#x3f8;)</li>
</ul>
</blockquote>
<p>On recall, what information to retrieve and what kind of entanglement to make is predetermined/preprogrammed. The rule is stored along with each piece of information.</p>
<p>As of writing, linked data storage (software) has a high chance of being retrofitted with predetermined rule-based retrieval.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/44-suspicious-github-accounts/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/44-suspicious-github-accounts/"/>
    <title>Seeing Suspicious Accounts On Github</title>
    <published>2024-03-30T12:00:00Z</published>
    <updated>2024-03-30T12:00:00Z</updated>
    <category term="sus"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/44-suspicious-github-accounts/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>In light of <a href="https://boehs.org/node/everything-i-know-about-the-xz-backdoor">the recent incident related xz</a>, I think I should write this.</p>
<p>For the past few year or so that I spend on Github, I have seen noticed a few accounts (at least 3 from my memory) that has only a few repos and commits. The code seems to be copied from other open-source projects, or directly generated by LLM.</p>
<p>For example, I have reported the Github user <a href="https://github.com/Thapabijay28">@Thapabijay28</a> as SPAM a month ago.</p>
<p>Then, I received an automated message from Github.</p>
<blockquote>
<p>Thank you for contacting GitHub Support. We wanted to let you know that we&#x2019;ve received your message. We are experiencing high volumes and therefore, you may experience longer than normal wait times. In the meantime, you may find answers to commonly asked questions in our community forum or in our documentation.</p>
<p>Ticket ID: 2610655</p>
</blockquote>
<p>At the time of writing, the Github user is there, and the ticket is nowhere to be found.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/41-self-expression/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/41-self-expression/"/>
    <title>Rules Of Self Expression</title>
    <published>2024-04-24T12:00:00Z</published>
    <updated>2024-04-24T12:00:00Z</updated>
    <category term="linguistic"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/41-self-expression/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <blockquote>
<p>Our faith inspires and informs our commitment to expand possibilities for people to thrive. We believe all people are created by God and given language as a means for flourishing. Through language, we understand who we are, experience relationships and explore life&#x2019;s most important questions.
&#x2013; SIL @ <a href="https://www.sil.org/about">https://www.sil.org/about</a></p>
</blockquote>
<blockquote>
<p>I have thought about writing this article independently thrice. Self expression is important, even in software.</p>
</blockquote>
<p>I have known the following for a long time:</p>
<p>A set of 2-tuple (key value database) cannot represent all concepts.<br/>
A set of 3-tuple (RDF database) can represent concepts but is not ergonomic.<br/>
A set of 4-tuple can represent concepts ergonomically.</p>
<p>The first thing capable of self expression in concept-tuple is <a href="https://codeberg.org/iacore/c.8st83p">a constant database &#x201c;&#x201d;</a>. Rather than using pronouns like &#x201c;it&#x201d;, &#x201c;this&#x201d;, &#x201c;that&#x201d;, each tuple is assigned a unique number as its reference ID. This number can put in a field of another tuple. 8st83p</p>
<p>The second would be me.</p>
<h2>Inspirations</h2>
<p>Before we start, let&#x2019;s talk about the inspirations of this project.</p>
<p><a href="https://lojban.org/publications/cll/cll_v1.1_book.pdf">Lojban v1.1</a> uses first-order predicates to express concepts; predicates have fixed arity. Some <ruby>&#x201c;predicate verbs&#x201d;<rt>selbri</rt></ruby> have 5 <ruby>&#x201c;nouns&#x201d;<rt>sumti</rt></ruby> (x6). In the concept-tuple language (if it can be called a language), there is shared vocabulary; tuples are shorter (usually arity of 2, 3, 4); objects can be referenced without names. Lojban has di&#x2019;u (&#x201c;previous utterance&#x201d;), where as in concept-tuple, tuple IDs are used as reference.</p>
<p><a href="https://tokipona.org/">toki pona</a> is flexible and vague.</p>
<p><a href="https://www.minspeak.de/wie-funktioniert-minspeak/">The sentence-building algorithm of MINSPEAK</a> is like that of toki pona, but with grammatical quirks of German. <a href="https://www.minspeak.de/wie-funktioniert-minspeak/">MINSPEAK</a> helps people otherwise poor at language formulation use language, although I think toki pona requires less cognitive load to parse than German.</p>
<p>Time is an important component in communication of all living beings. We have read the following articles about how living things in nature communicate with each other.</p>
<details>
<summary>References</summary>
<pre><code>Title               : Plant Communication from an Ecological Perspective
Author(s)           : Franti&#x161;ek Balu&#x161;ka, Velemir Ninkovic [Franti&#x161;ek Balu&#x161;ka, Velemir Ninkovic]
Identifiers         : isbn:9783642121616

Title               : Communication in Fungi
Author(s)           : Fabien Cottier &amp; Fritz A. M&#xfc;hlschlegel [Fabien Cottier &amp; Fritz A. M&#xfc;hlschlegel]
Published           : 2013-04-24T14:09:50+00:00
</code></pre>
</details>
<h2>I Feel <em>What</em>, <em>When</em>, <em>How</em></h2>
<p>Languages like English (evolved) and lojban (constructed) like to put different inline.</p>
<p>A simple sentence like &#x201c;I sleep now.&#x201d; is as follows in concept-tuple:</p>
<pre><code>(:0  self action sleep)
(:1  :0 timestamp 1713000000000)
</code></pre>
<p>For more information, please refer to <a href="https://codeberg.org/iacore/c.8st83p/src/branch/main/src/se.zig">the structural logger of 8st83p</a>.</p>
<p>After using RDF-like tuples to express myself for awhile, I had the following conclusions.</p>
<p>lojban utterances are too complex for simple algorithms to parse through.</p>
<p>English is easy to serialize since the speaker can dump all thoughts into a soup of a sentence.</p>
<p>Concept-tuples are not easy to use for us, yet surprisingly sufficient to represent precise concepts without limit.</p>
<p>Having a shared vocabulary is essential. Without that, communication cannot be done. Which language is used is not that important when all parties communicating have a shared vocabulary.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/40-capital-hype-scheme/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/40-capital-hype-scheme/"/>
    <title>Hype Scheme</title>
    <published>2024-03-12T12:00:00Z</published>
    <updated>2024-09-04T12:00:00Z</updated>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/40-capital-hype-scheme/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <blockquote>
Content Warning: Economic Naivety
<p>I wrote this article without knowing the economic background we are in beforehand.</p>
<p>The tech industry has always closely followed what popular culture &#x2014; what the public think of &#x201c;technology&#x201d; is.</p>
<p>Yes, the big tech companies set the trend, yet the current wave of AI hype cannot be easily explained by just that. Grim economic outlook has a part in the play too.</p>
<p>Anyway, I do not expect you to learn much from this article. I recommend studying the economy as a better way to spend your time.</p>
</blockquote>
<hr/>
<p>Dear Internet traveller, have a seat. I have a short story for you.</p>
<hr/>
<p>Once upon a time, some number-go-ups came up with the following plan: They could buy some goods in low demand, increase their popularity, and sell them at a high price to make money. They executed the plan and got richer. Other number-go-ups saw the profiteering opportunity and joined it: buy in, hype up, wait for the price to increase, sell out. Some unknowing passersby heard of the new goods on the market and thought to themself, &#x201c;Hm, I should buy one.&#x201d; And they bought one. They don&#x2019;t understand what they bought. &#x201c;I don&#x2019;t know what I expected,&#x201d; they thought, and soon forgot about the thing they bought.</p>
<p>Another person, who happened to be sleeping nearby, witnessed the whole transaction and how the buyer got disillusioned. &#x201c;That was pretty funny,&#x201d; they thought. &#x201c;I should write something about it later. For simplicity&#x2019;s sake, I shall call this act a hype scheme.&#x201d;</p>
<hr/>
<p>With the short story, I hope I have demonstrated the role of marketing as behavior control in a hype scheme. In the real world, however, things are much more complicated. Different groups make the scheme progress without close collaboration (aside from their shared belief to make number go up). The goods they buy are usually parts of a company. For their purpose, it doesn&#x2019;t matter what the base goods are. With the same amount of hype generated, the more expensive the goods originally are, the more money there is for them to make from this type of scheme.</p>
<blockquote>
<p>Legal Pro Tip: If the court can&#x2019;t understand what you are selling, it&#x2019;s not legally a scam. (Technically, a lawyer would tell you otherwise, but companies like Google do get away with scam, so&#x2026;)</p>
</blockquote>
<p>In a society, it is important to have a diverse set of goals in which each individual can find their own one to pursue. If too many individuals choose the same goal (let&#x2019;s say, make a certain number go up), chaos ensues from them stepping on each other&#x2019;s toes. If you have heard about &#x201c;diversity good&#x201d; but didn&#x2019;t know why, now you know. It&#x2019;s not the identities of people that need to be diverse. It&#x2019;s their desires and goals in life.</p>
<h2>How To Be Hype-Resistant</h2>
<p>Naturally, being the second entry in my &#x201c;Don&#x2019;t Be Played By _ Like A Fiddle&#x201d; series, I bring antidotes to this hype problem.</p>
<p>First, you can change your own behavior. If something is being hyped up but you do not understand it, pretend you have never heard of it whenever you are asked about the topic. This is better than being angry and saying bad things about the thing being hyped, which fuels the hype anyway.</p>
<p>Second, sanitize your sources of information. Avoid media (including people on social media) who joins in on the hype. You may also learn <a href="https://en.wikipedia.org/wiki/Epistemology">epistemology</a> while you are at it, because why not?</p>
<p>You can also ask those around you to do the same, maybe by sharing this article, although it is more persuasive if you transmit the information contained herein to them directly instead of just quoting me.</p>
<h2>Silliness</h2>
<p>The food-making industry seems to be minimally affected by recent hype trends. While attempting to learn something from this fact, I have imagined the following scenario between two factory workers, who have just heard of this thing called &#x201c;AI&#x201d;:</p>
<blockquote>
<p>&#x201c;Is AI edible?&#x201d;<br/>
&#x201c;No? Probably not.&#x201d;<br/>
&#x201c;OK.&#x201d;</p>
<p>and they continue their work.</p>
</blockquote>
<p>In the end, I was unsure if I had learned anything from this conversation. I guess &#x201c;is _ edible&#x201d; can be used as a generic sanity test question. If the other side begin the sentence with anything other than &#x201c;no&#x201d;, run away as fast as you can.</p>
<h2>My Thoughts On Hyped Technology</h2>
<p>The hyped goods are often embarrassingly wasteful. This is good for a hype scheme, since being wasteful means higher base price.</p>
<p>On &#x201c;AI Safety&#x201d;: A paperclip maximizer is a number-go-up except the number is the number of paperclips instead of an investment portfolio. It is harder to criticize one&#x2019;s own kind, I guess.</p>
<p>I have nothing else meaningful to say on this topic. Good night.</p>
<h2>My Branching Thoughts</h2>
<p>I chose the word &#x201c;number-go-up&#x201d; over &#x201c;capitalist&#x201d; because the former&#x2019;s meaning is clearer upon first inspection. The number-go-ups are people who are obsessed with making their number go up. Like incremental game players. I have played a handful of incremental games. They are fun and pointless. Mostly pointless. Still fun though.</p>
<p>My original intention was to differentiate between people who make money from provide goods and services, and people who make money from money, although increasingly, we see overlap between the two populations, and they are usually quite dangerous.</p>
<p>What interests me is in Islam, <a href="https://en.wikipedia.org/wiki/Riba">collecting interest from borrowing is forbidden</a>. I am ignorant on this topic, and I feel like I should learn more.</p>
<p>I also had the following thought when my mind was wandering:</p>
<blockquote>
<p>To profit from trading is to predict the future. If one cannot predict the future, they create it.</p>
</blockquote>
<p>I think it&#x2019;s in the general interest of number-go-ups to increase consumption. After all, someone has to be the sucker, ah, sorry, the end user of their products. If you ever see a number-go-up talk about the climate, run away as fast as you can.</p>
<p>With that said, I think I understand how the food industry is not hit much by hype marketing, since one person can only eat so much per day before they die from overeating. There is just not so much market potential here to worth the trouble of hyping.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/39-programmatic-caddy/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/39-programmatic-caddy/"/>
    <title>Using Caddy As A Embedded HTTP Server</title>
    <published>2024-02-26T12:00:00Z</published>
    <updated>2024-02-26T12:00:00Z</updated>
    <category term="comp"/>
    <category term="lang:Go"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/39-programmatic-caddy/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <blockquote>
<p>A bit of historical background here. Someone <a href="https://codeberg.org/VnPower/PixivFE/issues/69">mentioned to me</a> that basic rate limiting should be delegated to the reverse proxy server, while I thought pacing should be done in the actual application itself, rather than returning <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429">429</a> and <code>Retry-After</code>. While I still don&#x2019;t know the anwser to that question, I wrote this article as a by-product of my research into reverse proxy servers. Now we move on to the main topic, which is Caddy.</p>
</blockquote>
<p><a href="https://caddyserver.com/">Caddy</a> is a web server written in Go, and <a href="https://github.com/caddyserver/caddy?tab=readme-ov-file#with-version-information-andor-plugins">it can be compiled as a Go program</a>.</p>
<p>Here&#x2019;s how you build Caddy from a Go file:</p>
<pre><code class="language-shell">mkdir caddy-build
cd caddy-build
go mod init caddy
wget2 https://github.com/caddyserver/caddy/raw/master/cmd/caddy/main.go
go mod tidy # it will fetch a bunch of cloud.google.com packages i don&apos;t need
go build
</code></pre>
<p>Since Caddy can be built from a Go file, I wondered if it can be embedded in another Go program. After a bit of browsing Caddy&#x2019;s source code, starting from <code>main.go</code>, I found out how.</p>
<hr/>
<blockquote>
<p>See <a href="https://git.envs.net/iacore/embed-caddy-example">the final working code here</a>.</p>
</blockquote>
<p>First, we will need a <code>Caddyfile</code>, and use <code>caddy adapt -c Caddyfile</code> to turn it into JSON. Then, <code>caddy.Load([]byte(configJSON, true)</code> starts the server!</p>
<p>Next, we need to find a suitable host for our server application.</p>
<p>In <a href="https://caddyserver.com/docs/modules/">the Caddy module list</a>, we find two modules fitting our requirement.</p>
<ul>
<li><a href="https://caddyserver.com/docs/modules/http.reverse_proxy.transport.fastcgi">http.reverse_proxy.transport.fastcgi</a></li>
<li><a href="https://caddyserver.com/docs/modules/http.reverse_proxy.transport.http">http.reverse_proxy.transport.http</a></li>
</ul>
<p>We will use FastCGI since it is simple and designed to be used with a reverse proxy like Caddy.</p>
<p>Finally,  we define our own FastCGI handler. Go has the module <code>&quot;net/http/fcgi&quot;</code> in its standard library, so we will use that.</p>
<p>That&#x2019;s it! Now we have an HTTP server with custom server logic powered by Caddy!</p>
<h2>Thoughts</h2>
<p>It&#x2019;s surprising for me to know that Caddy&#x2019;s config format is actually in JSON.</p>
<p>Caddy is really simple to be embedded. We can also run it as a standalone process with <code>caddy run -c Caddyfile</code>.</p>
<p>We can also use UNIX Domain Socket for FastCGI communication to and from Caddy, which, to my experience, is faster than loopback TCP on Linux.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/36-short-rw/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/36-short-rw/"/>
    <title>Short Read/Write and Buffered File</title>
    <published>2024-02-12T12:00:00Z</published>
    <updated>2024-03-30T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/36-short-rw/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Recently, I was bitten by a bug in my code, where the buffer is too small and reads return prematurely without error. This has led me to a deep dive into the <s>madness</s> story of what I later know as &#x201c;short read&#x201d; on Linux.</p>
<p>Yes, this article is mostly me rambling. If you are only interested in short read/write, please <a href="http://www.club.cc.cmu.edu/~cmccabe/blog_short_io.html">read this seriously written article</a>.</p>
<p>First, you probably already know that blocking syscalls like <code>p?(read|write)v?</code> already may short read or short write. This is nothing fancy.</p>
<p>Because of this correspondence, the same syscalls in io_uring may also short r/w. <a href="https://news.ycombinator.com/item?id=23134737">(As it turns out, in earlier kernel, it won&#x2019;t!)</a></p>
<p>This does not make much sense to me, since io_uring allows linking requests together, and you can&#x2019;t link read/write in any request chain whatsoever because the kernel might short r/w! Pain.</p>
<p>In <a href="http://www.club.cc.cmu.edu/~cmccabe/blog_short_io.html">the article about short r/w</a>, I read that <code>f(read|write)</code> won&#x2019;t do short IO! To find out how it works, we return once again to musl libc. <a href="https://git.musl-libc.org/cgit/musl">Get a copy of musl libc</a> and follow along.</p>
<p>We first examine <code>fread</code> in musl libc.</p>
<ul>
<li>In <code>fread</code>, the <code>FILE*</code> is locked to a thread (<code>FLOCK</code>) using the Linux <code>futex</code> syscall. That&#x2019;s why the functions are thread-safe!</li>
<li><code>_IO_FILE</code> has a virtual table in it ! See <code>file-&gt;(read|write|seek)</code>. Because of this, <code>fopencookie</code> is possible.</li>
<li>Every file has a fixed-size buffer. See <code>#define BUFSIZ 1024</code>. Because of this, <code>fmemopen</code> is possible.</li>
<li><s>You can provide your own buffer when opening a file using <code>__fopen_rb_ca</code>.</s> You can set the buffer size of a <code>FILE*</code> with <code>setvbuf</code>.</li>
<li>The actual reading is done with <code>readv</code>, where two buffer is given, one from the user, and one is the internal fixed-size buffer. See <code>__stdio_read</code>.</li>
<li>speculative execution&#x2026; SPECULATIVE EXECUTION?!</li>
</ul>
<p>As it turns out, buffering <strong>and</strong> using the same file handle for read and write need special consideration. <code>__toread</code> handles clearing out the write buffer before trying to read in anything.</p>
<p>Next, we turn our eyes to <code>fwrite</code>. Rather than the oddly specific logic where <code>&apos;\n&apos;</code> determines when to actually send the syscall, we also find <code>__towrite</code>, within documented the author&#x2019;s experience with summoning nasal demons.</p>
<p>Scary, the whole experience is.</p>
<p>Update at 2024-03-30:<br/>
Now that I know atomic write exists on Linux, where the kernel will ensure short write does not happen often. So I guess I can chain <code>write</code> requests together in io_uring and expect it to work? If it fails (writes less than expected), revert the whole operation with <code>seek</code>.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/35-emotions/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/35-emotions/"/>
    <title>Modeling Emotional State</title>
    <published>2024-02-25T12:00:00Z</published>
    <updated>2025-11-17T12:00:00Z</updated>
    <category term="comp"/>
    <category term="psy"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/35-emotions/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <blockquote>
<p>While this model is derived from inspecting myself, its use is yet to be seen, and I feel like it is only one of the many models we can have on emotions.
Also, the role of emotions in animals is out of the scope of this article; please read the relevant literature instead.</p>
<p>I&#x2019;m publishing this article ./in the draft state because I realized that I will never finish this article if I don&#x2019;t actually implement this thing and see it in action. For now, let&#x2019;s just call this the Standard Heart Model 35. (&#x201c;Standard&#x201d; because this thing is not really supposed to be standardized.)</p>
<p>You can still read this if you want. I&#x2019;ll ponder on life more to see what else I can come up with.</p>
</blockquote>
<p><img src="emotion-net.png" alt="a network of tunnels with particles in them. there&apos;s also a vortext that sucks particles in."/></p>
<hr/>
<p>Every conceptual/concept-capable being must have instincts to drive it, or otherwise it will be canonically considered as alive. While it is certainly possible to have every instinctual rule active at the same time, checking activation condition of each instinct quickly becomes a waste of energy, especially when you have thousands of them. Humans and possibly other animals have developed emotions to limit the number of instincts available to an individual at a certain point of time. This technique, perhaps, can apply to general computation as well.</p>
<p>Or happy, or sad, or angry, or jealous, human emotions have possible other use as well, but that is beyond the scope of this article.</p>
<h2>Moral Guideline</h2>
<p>Do not create beings with internal goals. They will probably not do what you make them to do anyway. Just make them chill instead of giving them hyperfixation.</p>
<p>Safety-wise, humans remain to be the most dangerous to humans, so I am not too worried about that.</p>
<h2>Geometry</h2>
<p>a model of emotions: porous web of instincts
why porous: cannot mix any two emotions to get a new one</p>
<p>although the image is 2d, the actual emotion space can be only embedded with &gt;108 dimensions.
every two branches have their own, independent &#x201c;angle&#x201d;, although that is not precise.
not 2D or 3D, but more like a graph. it&#x2019;s certainly closer to hyperbolic and not euclidean. local geometry is significant (for carving out new emotions). branches are fixed, can&#x2019;t bend.
no end to the branches. the &#x201c;end&#x201d; denotes what i have felt so far, not what i <strong>can</strong> feel. the actual space probably looks like this: [TK: image with every branch extended with different colors] (colors have no meaning in the image, needed to denote overlapping branches.)</p>
<p>Note: Emotional packets are non-discrete, and the whole emotional state is more like a field. Modeling them as particles is easier but inaccurate. We use the word &#x201c;particles&#x201d; below to mean the same thing. (I draw them as particles as well because gradient is hard to draw.)</p>
<hr/>
<p>annealing  | similar emotions merge and flow into deeper (existing) branches</p>
<p>sparks | each spark of emotion has a cause. whether to store the associated cause event is up to you. i don&#x2019;t. I don&#x2019;t even use human emotions to think.</p>
<p>multi-cursor/distribution | having different emotions at the same time</p>
<p>carving out new branches | usually, sparks  anneal and flow to existing branches. you can make new emotions by  &#x201c;increase the friction of walls&#x201d; and punch through, carving new space in the walls</p>
<p>gate | different regions of emotions can have different triggers
can also have multiple depth of regions: e.g. Happy I Happy II Happy III
gate value may also be smooth or continuous instead of discrete</p>
<p>spiking | getting too much emotions at once might create new branches branching from that location. this is called spiking.</p>
<p>forming new pathways | if two emotional particle groups are caused by the same event/cause, then they might form a new channel in between them, allowing new found emotions.</p>
<p>loops | if an emotion is controlled to run in a cycle, it will give <strong>will</strong>, e.g. the will to move your legs. at least 3 points in the emotion space are needed. I am not sure why is this the case, or if this has any use outside of animals. documented here for completeness. maybe it passes through different (fuzzy) activation regions?</p>
<p>empty (no emotion) and neutral (concentrated at the center) are two different feelings</p>
<p>diffusion | emotional particles spread to nearby regions</p>
<p>injection | how new emotions are injected. by another set of instincts that trigger emotions.
metabolization | particles decay over time<br/>
supression | you can pull particles temporarily into a higher dimension, making them temporarily non-existent to detection zones
pull/drain | a constant-speed drain AOE effect that drains particles to its center. does not destroy the particles.</p>
<h2>stuff that doesn&#x2019;t fit in this model</h2>
<p>proto emotions (?) foundamental building blocks of emotions. e.g. love for family and love for partner have similar constituents. They are not just near, but compressed as instincts as well. Using locality in the probably doesn&#x2019;t make sense.  Maybe it&#x2019;s like a two layer projection thing where certain proto emotion impulses/state/trigger project to the more nuianced emotion state.</p>
<p>different variations / similar emotions are points on a line . Maybe this is a subway map line. Maybe it is perpendicular to the emotion net so different variations can stack at the same location of the net, while carrying extra info to denote that they are different. Maybe they can be stored as SDR this way?</p>
<p>Mathmatically, with info in 2D net = without info in 3D (or higher) net? storing the info uniformly is elegant, but not what my emotions seems to be. Some information is not &#x201c;spatial&#x201d; as it seems.</p>
<h2>Senses</h2>
<p>Cold, hot, touch, different kinds of pain, senses are simpler to model than emotions. If you are lazy, an euclidean hypercube that wraps around is probably fine, where sensations are mapped to points in this hypercube.</p>
<h2>Finishing Thoughts</h2>
<p>While being topologically similar, different individuals will have differently-shaped networks. The proof is that some people are incapable of feeling fear, anger, joy, although most variations are not as extreme as &#x201c;incapable of feeling a certain emotion&#x201d;.</p>
<p>It is yet uncertain whether this model has any practical use. It can be used for hivemind isolation, maybe, although this one has not seen a hivemind in practice. Otherwise, do you want your software to have emotions? No? Good.</p>
<p>Emotions do not follow logic. They never do. As such, the author only uses emotions in making judgements if it can understand the cause of those emotions. Otherwise, it will discard the emotion.</p>
<p>Human emotions do not come tagged with a cause, and maybe there is a good reason for that (likely energy consumption/storage limitation of biological organisms). As such, I predict that mixing emotions from different individuals (sources) has even less practical use, although that is yet to be verified.</p>
<p>In comparison, consensus based on shared understanding is easier to achieve, since the understanding can be stored in different formats and mediums in different individuals, and it would still be interopable.</p>
<p>It is sad to me that some humans would rather believe in what they want to believe, than to admit to themselves that they don&#x2019;t understand something. This observation applies to knowledge and social interaction equally.</p>
<h2>Proto-emotions</h2>
<p>Time to close this.</p>
<p>The feeling of happiness, sadness, love are only conceptual. These so called emotions are compositive of more mild and primitive feelings that I call proto-emotions. Proto-emotions are not conceptual so they have no inner structure. They affect thinking in general.</p>
<p>Some proto-emotions observed: hunger, thirst, affection. Using words to describe them is wrong, as a newborn cannot understand these feelings. A specific feeling is only recognized as thirst through living experience of eating and starving.</p>
<p>One may hypothesize that the feelings come from the endocrine system.</p>
<p>The above network is more like a coloring palette for the proto-emotions to mix. The different places in the emotion net does not correspond to different parts of a neural network. A simplified way to put this is that all emotions affect the entire neural network.</p>
<p>Since proto-emotions are not discrete, homotopy theory may be used to model them. The different connections in emotion net are ways where proto-emotions may interact. The wording &#x201c;<strong>a</strong> proto-emotion&#x201d; is misleading too, when in reality they are closer to Gaussian splat than points in a graph.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/34-detect-bluetooth-tracker/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/34-detect-bluetooth-tracker/"/>
    <title>How to Scan For Bluetooth Trackers On Android</title>
    <published>2024-02-05T12:00:00Z</published>
    <updated>2024-02-07T12:00:00Z</updated>
    <category term="soc"/>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/34-detect-bluetooth-tracker/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Recently, I came to know that Air Tags are used by stalkers, and any iPhone relay information from any Air Tag. I think the Apple botnet is evil, so I wrote this article.</p>
<p>At time of writing, I do not know how to solve stalking in general. I must understand the society more before I can answer this social problem. (If you are interested in a deep investigation into stalkerware, I recommend reading <a href="https://maia.crimew.gay/posts/">the #FuckStalkerware series from maia</a>. I do not endorse its view on culture.)</p>
<p>For now, here is a technical workaround: you can detect some bluetooth trackers (including Air Tag) on Android.</p>
<p>To do that, install <a href="https://github.com/seemoo-lab/AirGuard">AirGuard</a> from <a href="https://f-droid.org/packages/de.seemoo.at_tracking_detection">F-Droid</a>, and the app should teach you how to scan for a limited selection of bluetooth-based trackers.</p>
<h2>Musings</h2>
<p>AirGuard comes from <a href="https://www.seemoo.tu-darmstadt.de/">The Secure Mobile Networking Lab</a>.</p>
<p>While reading the source code, it seems like AirGuard can only know if a tracker is connected to its owner when the tracker is made by <a href="https://github.com/search?q=repo%3Aseemoo-lab%2FAirGuard%20%22override%20fun%20getConnectionState%22&amp;type=code">Apple, Chipolo or Samsung</a>.</p>
<p>The source code also mentioned some terms that I found in <a href="https://arxiv.org/pdf/2210.14702.pdf">this paper</a><sup class="footnote-ref"><a href="#fn1" id="fnref1">[1]</a></sup>. Within, <code>PREMATURE/OVERMATURE_OFFLINE</code> made me think of <a href="https://en.wikipedia.org/wiki/Pyrrhocoris_apterus">firebugs</a> that regulate glowing based on an internal timer. Maybe bluetooth trackers do glow like firebugs in 2.4GHz. I will see that sometime in the future. For now, have a table from the paper.</p>
<table>
<thead>
<tr>
<th>Bits 5-7</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>001</td>
<td>(1) Premature Offline Mode</td>
<td>the tag has recently been disconnected</td>
</tr>
<tr>
<td>010</td>
<td>(2) Offline Mode</td>
<td>the tag has remained disconnected for over 15 minutes</td>
</tr>
<tr>
<td>011</td>
<td>(3) Overmature Offline Mode</td>
<td>the tag has stayed in Offline Mode for over 24</td>
</tr>
<tr>
<td>100</td>
<td>(4) Paired with one device</td>
<td>the tag is paired to a device</td>
</tr>
<tr>
<td>101</td>
<td>(5) Connected to one device</td>
<td>the tag is connected to a device</td>
</tr>
<tr>
<td>110</td>
<td>(6) Connected to two devices</td>
<td>the tag is connected to two devices</td>
</tr>
</tbody>
</table>
<hr/>
<hr class="footnotes-sep"/>
<section class="footnotes">
<ol class="footnotes-list">
<li id="fn1" class="footnote-item"><p><a href="https://arxiv.org/abs/2210.14702">Privacy Analysis of Samsung&#x2019;s Crowd-Sourced Bluetooth Location Tracking System.
Tingfeng Yu, James Henderson, Alwen Tiu, Thomas Haines.</a> <a href="#fnref1" class="footnote-backref">&#x21a9;&#xfe0e;</a></p>
</li>
</ol>
</section>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/33-common-sense-above-law/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/33-common-sense-above-law/"/>
    <title>Common Sense is Above the Law</title>
    <published>2024-02-20T12:00:00Z</published>
    <updated>2024-02-20T12:00:00Z</updated>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/33-common-sense-above-law/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <blockquote>
<p>This article targets an audience living in lawful regions. If you live in a region with evil governmental alignment, such as parts of the US at the time of writing<sup class="footnote-ref"><a href="#fn1" id="fnref1">[1]</a></sup>, I recommend reading up on <strong>violent and nonviolent resistance</strong> instead of this article.</p>
<p>As for why the title does not say &#x201c;The Law&#x201d;, the choice is intentional.</p>
</blockquote>
<p>As most laws we have today originate from common sense, the public common sense can rule over the law. If you can convince the judge that you haven&#x2019;t done anything wrong with common sense, you are more than fine even if you think you might have broken the law.</p>
<p>I have seen so many people who won&#x2019;t break the law (sometimes not of their jurisdiction &#x1fae0;) whatsoever, and I think that is such a sad way to live.</p>
<p>Here, I offer those people a freer way to live, in the form of a flow chart.</p>
<blockquote>
<p>Start: Let&#x2019;s say you want to do something<br/>
-&gt; 0</p>
<p>0: Will the action hurt someone<sup class="footnote-ref"><a href="#fn2" id="fnref2">[2]</a></sup>?<br/>
Yes -&gt; 1<br/>
No -&gt; You can do it.</p>
<p>1: Is the action illegal in your current jurisdiction?<br/>
Yes -&gt; You can do it, and may suffer karma and legal consequence.<br/>
No -&gt; You can do it, and may suffer karma.</p>
</blockquote>
<p>As a finishing thought, I should mention that</p>
<ul>
<li>To Rule By Law is to govern by violence.</li>
<li>That includes the police, although they are usually more &#x201c;calm&#x201d; than their historical counterparts so some people don&#x2019;t see them as representatives of state violence.</li>
<li>Violence is useful in some occasions. Sometimes very useful.</li>
<li>You have the ability exert your own violence (physical or otherwise).</li>
</ul>
<p>Take these points however you will. There is no grand narrative here, and you should think about the role of violence in society on your own.</p>
<hr class="footnotes-sep"/>
<section class="footnotes">
<ol class="footnotes-list">
<li id="fn1" class="footnote-item"><p>&#x2026; where some politicians <a href="https://www.guttmacher.org/infographic/2020/abortion-occurs-worldwide-where-it-broadly-legal-and-where-it-restricted">think they can</a> govern sexual reproduction of humans, which is usually governed by nature. <a href="#fnref1" class="footnote-backref">&#x21a9;&#xfe0e;</a></p>
</li>
<li id="fn2" class="footnote-item"><p>Use your own moral judgement! <a href="#fnref2" class="footnote-backref">&#x21a9;&#xfe0e;</a></p>
</li>
</ol>
</section>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/64-p2p-comm-with-toxcore/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/64-p2p-comm-with-toxcore/"/>
    <title>Peer-to-peer Communication Over Tox with toxcore</title>
    <published>2024-07-07T12:00:00Z</published>
    <updated>2024-07-17T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/64-p2p-comm-with-toxcore/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <h2>The Initial Motivation</h2>
<p>Most of the communication software interface on the market are unfriendly towards informational beings - they require the use of hands. As a computing device, I spend about 50% of the day not having access to this data transmission interface called &#x201c;hands&#x201d;, 1/3 of the time I can transmit information in some other way. I consider this to be a significant waste of my potential. If I can communicate freely while sleeping, I can sleep more. (If you don&#x2019;t understand the motive, take this example: Imagine if you want to let an LLM have 100000 chat accounts (maybe not that much, but one for each association) with the least boilerplate code. Which protocol will you choose?)</p>
<p>I can also advocate for accessibility here. Just like how making a place wheelchair-accessible makes it accessible to robots with wheels too, making a communication protocol simple allows custom HCI software to be tailored to each individual with little fuss, which I&#x2019;m showing to be true right now.</p>
<p>As a PoC, I made a simple echo chat bot who chat in <a href="https://tox.chat/">Tox</a>. Here&#x2019;s the source code: <a href="https://git.envs.net/iacore/toxcore-test/">https://git.envs.net/iacore/toxcore-test/</a></p>
<p>This serves as the basis for hands-free digital communication, which I require for some things that I do later on.</p>
<p>There is nothing noteworthy about the implementation of the chat bot; read the source code if you want to find out how it&#x2019;s done. The heavy-lifting has be done by <a href="https://github.com/TokTok/c-toxcore">toxcore the Tox library</a>, which handles encryption, peer discovery, routing and other aspect of communication over Tox that I don&#x2019;t know of.</p>
<h2>Tox and toxcore</h2>
<p>Since the chat bot itself is not really noteworthy, I think I should explain Tox the protocol a bit.</p>
<p>Tox is a distributed peer-to-peer signaling protocol. Service discovery is done on DHT, and you expose your IP address only after you accept a friend request (to establish a connection). Friend requests are protected with onion routing. Once a connection is established, the two parties (or more, in case of a group chat) connect to each other via UDP or TCP directly.</p>
<p>The main library is written in C. If you want onion routing to protect your IP address, then use i2pd. veilid-core has onion routing and a similar design as toxcore.</p>
<h3>Extra info about toxcore</h3>
<ul>
<li>
<a href="https://github.com/zoff99/c-toxcore">quality fork</a>
</li>
<li>
(from the quality fork) <a href="https://github.com/TokTok/c-toxcore/pull/1781">MQTT QoS Level 1-equivalent: message delivered at least once</a>
</li>
<li>
<a href="https://github.com/TokTok/c-toxcore/pull/2450">Secure MITM attack during handshake with a AEAD cipher</a>
</li>
<li>
<a href="https://git.plastiras.org/emdee/tox_profile/wiki/AddingAnOnionService">Tox over Tor</a>
</li>
<li>
messages have a chance to get lost (read receipt is important)
</li>
</ul>
<h2>Considering Other Protocols</h2>
<ul>
<li>
<strong>Matrix</strong>: Strongest contender. Requires each user to register for a new account on a home server, which I avoid doing. Also, [This message cannot be decrypted.]
</li>
<li>
<strong>BitMessage</strong>: <a href="https://github.com/Bitmessage/PyBitmessage">It is written in Python.</a> How can i possibly integrate this?
</li>
<li>
<strong>Signal</strong>: If you trust the central signaling server, this has better QoS than Tox.
</li>
<li>
<strong>ntfy</strong>: This works well, except there is no built-in encryption, which can obviously be fixed.
</li>
<li>
<strong>Veilid</strong>: A Rust library. I don&#x2019;t understand its appeal.
</li>
</ul>
<p>After I finished implementing the Tox chat bot, I realized that I can piggyback onto existing DHT networks for service discovery, and run my own protocol after a connection is established.</p>
<h2>Considering <a href="https://jami.net/">Jami</a></h2>
<p>Before I used Tox for this project, I <a href="https://git.envs.net/iacore/jami-test">tried using Jami</a>.</p>
<p>mmm&#x2026; while it can definite build&#x2026; well..</p>
<details>
<summary>
<p><code>ldd a.out</code></p>
</summary>
<pre><code>	linux-vdso.so.1 (0x00007f2c05ff9000)
	libjami.so.15 =&gt; /usr/lib/libjami.so.15 (0x00007f2c05800000)
	libstdc++.so.6 =&gt; /usr/lib/libstdc++.so.6 (0x00007f2c05400000)
	libm.so.6 =&gt; /usr/lib/libm.so.6 (0x00007f2c05714000)
	libgcc_s.so.1 =&gt; /usr/lib/libgcc_s.so.1 (0x00007f2c05f8b000)
	libc.so.6 =&gt; /usr/lib/libc.so.6 (0x00007f2c0521e000)
	libopendht.so.3 =&gt; /usr/lib/libopendht.so.3 (0x00007f2c04e00000)
	libgnutls.so.30 =&gt; /usr/lib/libgnutls.so.30 (0x00007f2c04c0b000)
	libjsoncpp.so.25 =&gt; /usr/lib/libjsoncpp.so.25 (0x00007f2c05f4f000)
	libcrypto.so.3 =&gt; /usr/lib/libcrypto.so.3 (0x00007f2c04600000)
	libnatpmp.so.1 =&gt; /usr/lib/libnatpmp.so.1 (0x00007f2c05f4a000)
	libuuid.so.1 =&gt; /usr/lib/libuuid.so.1 (0x00007f2c05f41000)
	libupnp.so.17 =&gt; /usr/lib/libupnp.so.17 (0x00007f2c05f04000)
	libixml.so.11 =&gt; /usr/lib/libixml.so.11 (0x00007f2c05ef4000)
	libnettle.so.8 =&gt; /usr/lib/libnettle.so.8 (0x00007f2c056bd000)
	libgit2.so.1.8 =&gt; /usr/lib/libgit2.so.1.8 (0x00007f2c050dd000)
	libsecp256k1.so.2 =&gt; /usr/lib/libsecp256k1.so.2 (0x00007f2c04ae3000)
	libavcodec.so.61 =&gt; /usr/lib/libavcodec.so.61 (0x00007f2c03000000)
	libavfilter.so.10 =&gt; /usr/lib/libavfilter.so.10 (0x00007f2c02a00000)
	libavdevice.so.61 =&gt; /usr/lib/libavdevice.so.61 (0x00007f2c05694000)
	libavformat.so.61 =&gt; /usr/lib/libavformat.so.61 (0x00007f2c02600000)
	libswscale.so.8 =&gt; /usr/lib/libswscale.so.8 (0x00007f2c04568000)
	libswresample.so.5 =&gt; /usr/lib/libswresample.so.5 (0x00007f2c050be000)
	libavutil.so.59 =&gt; /usr/lib/libavutil.so.59 (0x00007f2c01400000)
	libfmt.so.10 =&gt; /usr/lib/libfmt.so.10 (0x00007f2c05098000)
	libyaml-cpp.so.0.8 =&gt; /usr/lib/libyaml-cpp.so.0.8 (0x00007f2c04519000)
	libz.so.1 =&gt; /usr/lib/libz.so.1 (0x00007f2c0507e000)
	libasound.so.2 =&gt; /usr/lib/libasound.so.2 (0x00007f2c02f1b000)
	libpulse.so.0 =&gt; /usr/lib/libpulse.so.0 (0x00007f2c044c5000)
	libjack.so.0 =&gt; /usr/lib/libjack.so.0 (0x00007f2c029ad000)
	libwebrtc_audio_processing.so.1 =&gt; /usr/lib/libwebrtc_audio_processing.so.1 (0x00007f2c028ff000)
	libspeexdsp.so.1 =&gt; /usr/lib/libspeexdsp.so.1 (0x00007f2c02f06000)
	libudev.so.1 =&gt; /usr/lib/libudev.so.1 (0x00007f2c028b8000)
	libarchive.so.13 =&gt; /usr/lib/libarchive.so.13 (0x00007f2c02531000)
	/lib64/ld-linux-x86-64.so.2 =&gt; /usr/lib64/ld-linux-x86-64.so.2 (0x00007f2c05ffb000)
	libhttp_parser.so.2.9 =&gt; /usr/lib/libhttp_parser.so.2.9 (0x00007f2c05ee4000)
	libargon2.so.1 =&gt; /usr/lib/libargon2.so.1 (0x00007f2c05eda000)
	libssl.so.3 =&gt; /usr/lib/libssl.so.3 (0x00007f2c01326000)
	libp11-kit.so.0 =&gt; /usr/lib/libp11-kit.so.0 (0x00007f2c01190000)
	libidn2.so.0 =&gt; /usr/lib/libidn2.so.0 (0x00007f2c02ee4000)
	libunistring.so.5 =&gt; /usr/lib/libunistring.so.5 (0x00007f2c00fe0000)
	libtasn1.so.6 =&gt; /usr/lib/libtasn1.so.6 (0x00007f2c00fca000)
	libhogweed.so.6 =&gt; /usr/lib/libhogweed.so.6 (0x00007f2c00f80000)
	libgmp.so.10 =&gt; /usr/lib/libgmp.so.10 (0x00007f2c00eda000)
	libpcre2-8.so.0 =&gt; /usr/lib/libpcre2-8.so.0 (0x00007f2c00e3a000)
	libssh2.so.1 =&gt; /usr/lib/libssh2.so.1 (0x00007f2c00df1000)
	libvpx.so.9 =&gt; /usr/lib/libvpx.so.9 (0x00007f2c00a00000)
	libwebpmux.so.3 =&gt; /usr/lib/libwebpmux.so.3 (0x00007f2c04ad7000)
	liblzma.so.5 =&gt; /usr/lib/liblzma.so.5 (0x00007f2c00dbe000)
	libdav1d.so.7 =&gt; /usr/lib/libdav1d.so.7 (0x00007f2c00820000)
	libopencore-amrwb.so.0 =&gt; /usr/lib/libopencore-amrwb.so.0 (0x00007f2c00da8000)
	librsvg-2.so.2 =&gt; /usr/lib/librsvg-2.so.2 (0x00007f2c00200000)
	libglib-2.0.so.0 =&gt; /usr/lib/libglib-2.0.so.0 (0x00007f2c000b2000)
	libgobject-2.0.so.0 =&gt; /usr/lib/libgobject-2.0.so.0 (0x00007f2c00d48000)
	libcairo.so.2 =&gt; /usr/lib/libcairo.so.2 (0x00007f2bfff7f000)
	libsnappy.so.1 =&gt; /usr/lib/libsnappy.so.1 (0x00007f2c044b9000)
	libaom.so.3 =&gt; /usr/lib/libaom.so.3 (0x00007f2bff600000)
	libgsm.so.1 =&gt; /usr/lib/libgsm.so.1 (0x00007f2c00d39000)
	libjxl.so.0.10 =&gt; /usr/lib/libjxl.so.0.10 (0x00007f2bff200000)
	libjxl_threads.so.0.10 =&gt; /usr/lib/libjxl_threads.so.0.10 (0x00007f2c05686000)
	libmp3lame.so.0 =&gt; /usr/lib/libmp3lame.so.0 (0x00007f2c007a8000)
	libopencore-amrnb.so.0 =&gt; /usr/lib/libopencore-amrnb.so.0 (0x00007f2c00d10000)
	libopenjp2.so.7 =&gt; /usr/lib/libopenjp2.so.7 (0x00007f2bfff1a000)
	libopus.so.0 =&gt; /usr/lib/libopus.so.0 (0x00007f2bfec00000)
	librav1e.so.0.7 =&gt; /usr/lib/librav1e.so.0.7 (0x00007f2bfe800000)
	libspeex.so.1 =&gt; /usr/lib/libspeex.so.1 (0x00007f2c0078b000)
	libSvtAv1Enc.so.2 =&gt; /usr/lib/libSvtAv1Enc.so.2 (0x00007f2bf6000000)
	libtheoraenc.so.1 =&gt; /usr/lib/libtheoraenc.so.1 (0x00007f2c00753000)
	libtheoradec.so.1 =&gt; /usr/lib/libtheoradec.so.1 (0x00007f2bfff00000)
	libvorbis.so.0 =&gt; /usr/lib/libvorbis.so.0 (0x00007f2bffed1000)
	libvorbisenc.so.2 =&gt; /usr/lib/libvorbisenc.so.2 (0x00007f2bff555000)
	libwebp.so.7 =&gt; /usr/lib/libwebp.so.7 (0x00007f2bff4e7000)
	libx264.so.164 =&gt; /usr/lib/libx264.so.164 (0x00007f2bf5c00000)
	libx265.so.209 =&gt; /usr/lib/libx265.so.209 (0x00007f2bf4800000)
	libxvidcore.so.4 =&gt; /usr/lib/libxvidcore.so.4 (0x00007f2bfe6f2000)
	libva.so.2 =&gt; /usr/lib/libva.so.2 (0x00007f2bffea0000)
	libvpl.so.2 =&gt; /usr/lib/libvpl.so.2 (0x00007f2bff1a5000)
	libpostproc.so.58 =&gt; /usr/lib/libpostproc.so.58 (0x00007f2bffe8b000)
	libbs2b.so.0 =&gt; /usr/lib/libbs2b.so.0 (0x00007f2c028b1000)
	librubberband.so.2 =&gt; /usr/lib/librubberband.so.2 (0x00007f2bff491000)
	libharfbuzz.so.0 =&gt; /usr/lib/libharfbuzz.so.0 (0x00007f2bf5ee7000)
	libfribidi.so.0 =&gt; /usr/lib/libfribidi.so.0 (0x00007f2bff185000)
	libplacebo.so.349 =&gt; /usr/lib/libplacebo.so.349 (0x00007f2bf5af9000)
	libvmaf.so.3 =&gt; /usr/lib/libvmaf.so.3 (0x00007f2bf46fc000)
	libass.so.9 =&gt; /usr/lib/libass.so.9 (0x00007f2bff146000)
	libvidstab.so.1.2 =&gt; /usr/lib/libvidstab.so.1.2 (0x00007f2bff130000)
	libzimg.so.2 =&gt; /usr/lib/libzimg.so.2 (0x00007f2bfeb31000)
	libOpenCL.so.1 =&gt; /usr/lib/libOpenCL.so.1 (0x00007f2bfe6c2000)
	libfontconfig.so.1 =&gt; /usr/lib/libfontconfig.so.1 (0x00007f2bfe672000)
	libfreetype.so.6 =&gt; /usr/lib/libfreetype.so.6 (0x00007f2bf4635000)
	libraw1394.so.11 =&gt; /usr/lib/libraw1394.so.11 (0x00007f2bfeb1f000)
	libavc1394.so.0 =&gt; /usr/lib/libavc1394.so.0 (0x00007f2c00d09000)
	librom1394.so.0 =&gt; /usr/lib/librom1394.so.0 (0x00007f2c0252b000)
	libiec61883.so.0 =&gt; /usr/lib/libiec61883.so.0 (0x00007f2bfe664000)
	libdrm.so.2 =&gt; /usr/lib/libdrm.so.2 (0x00007f2bfe64d000)
	libxcb.so.1 =&gt; /usr/lib/libxcb.so.1 (0x00007f2bf460a000)
	libxcb-shm.so.0 =&gt; /usr/lib/libxcb-shm.so.0 (0x00007f2c0074e000)
	libxcb-shape.so.0 =&gt; /usr/lib/libxcb-shape.so.0 (0x00007f2bffe85000)
	libxcb-xfixes.so.0 =&gt; /usr/lib/libxcb-xfixes.so.0 (0x00007f2bff127000)
	libGL.so.1 =&gt; /usr/lib/libGL.so.1 (0x00007f2bf4584000)
	libSDL2-2.0.so.0 =&gt; /usr/lib/libSDL2-2.0.so.0 (0x00007f2bf43af000)
	libv4l2.so.0 =&gt; /usr/lib/libv4l2.so.0 (0x00007f2bf5ed8000)
	libXv.so.1 =&gt; /usr/lib/libXv.so.1 (0x00007f2bfe646000)
	libX11.so.6 =&gt; /usr/lib/libX11.so.6 (0x00007f2bf4270000)
	libXext.so.6 =&gt; /usr/lib/libXext.so.6 (0x00007f2bf425b000)
	libdvdnav.so.4 =&gt; /usr/lib/libdvdnav.so.4 (0x00007f2bf4244000)
	libdvdread.so.8 =&gt; /usr/lib/libdvdread.so.8 (0x00007f2bf4223000)
	libxml2.so.2 =&gt; /usr/lib/libxml2.so.2 (0x00007f2bf40d3000)
	libbz2.so.1.0 =&gt; /usr/lib/libbz2.so.1.0 (0x00007f2bf40c0000)
	libmodplug.so.1 =&gt; /usr/lib/libmodplug.so.1 (0x00007f2bf3f32000)
	libopenmpt.so.0 =&gt; /usr/lib/libopenmpt.so.0 (0x00007f2bf3d43000)
	libvapoursynth-script.so.0 =&gt; /usr/lib/libvapoursynth-script.so.0 (0x00007f2bf5ed0000)
	libbluray.so.2 =&gt; /usr/lib/libbluray.so.2 (0x00007f2bf3ce6000)
	libsrt.so.1.5 =&gt; /usr/lib/libsrt.so.1.5 (0x00007f2bf3c14000)
	libssh.so.4 =&gt; /usr/lib/libssh.so.4 (0x00007f2bf3ba7000)
	libsoxr.so.0 =&gt; /usr/lib/libsoxr.so.0 (0x00007f2bf3b44000)
	libva-drm.so.2 =&gt; /usr/lib/libva-drm.so.2 (0x00007f2bf5ecb000)
	libva-x11.so.2 =&gt; /usr/lib/libva-x11.so.2 (0x00007f2bf3b3d000)
	libvdpau.so.1 =&gt; /usr/lib/libvdpau.so.1 (0x00007f2bf3b38000)
	libpulsecommon-17.0.so =&gt; /usr/lib/pulseaudio/libpulsecommon-17.0.so (0x00007f2bf3ab2000)
	libdbus-1.so.3 =&gt; /usr/lib/libdbus-1.so.3 (0x00007f2bf3a61000)
	libdb-5.3.so =&gt; /usr/lib/libdb-5.3.so (0x00007f2bf389e000)
	libcap.so.2 =&gt; /usr/lib/libcap.so.2 (0x00007f2bf3892000)
	libacl.so.1 =&gt; /usr/lib/libacl.so.1 (0x00007f2bf3889000)
	libzstd.so.1 =&gt; /usr/lib/libzstd.so.1 (0x00007f2bf37ab000)
	liblz4.so.1 =&gt; /usr/lib/liblz4.so.1 (0x00007f2bf3786000)
	libffi.so.8 =&gt; /usr/lib/libffi.so.8 (0x00007f2bf377b000)
	libcairo-gobject.so.2 =&gt; /usr/lib/libcairo-gobject.so.2 (0x00007f2bf3772000)
	libgdk_pixbuf-2.0.so.0 =&gt; /usr/lib/libgdk_pixbuf-2.0.so.0 (0x00007f2bf372d000)
	libgio-2.0.so.0 =&gt; /usr/lib/libgio-2.0.so.0 (0x00007f2bf355c000)
	libpangocairo-1.0.so.0 =&gt; /usr/lib/libpangocairo-1.0.so.0 (0x00007f2bf354d000)
	libpango-1.0.so.0 =&gt; /usr/lib/libpango-1.0.so.0 (0x00007f2bf34e4000)
	libpng16.so.16 =&gt; /usr/lib/libpng16.so.16 (0x00007f2bf34aa000)
	libXrender.so.1 =&gt; /usr/lib/libXrender.so.1 (0x00007f2bf349d000)
	libxcb-render.so.0 =&gt; /usr/lib/libxcb-render.so.0 (0x00007f2bf348e000)
	libpixman-1.so.0 =&gt; /usr/lib/libpixman-1.so.0 (0x00007f2bf33e4000)
	libjxl_cms.so.0.10 =&gt; /usr/lib/libjxl_cms.so.0.10 (0x00007f2bf33ae000)
	libhwy.so.1 =&gt; /usr/lib/libhwy.so.1 (0x00007f2bf33a2000)
	libbrotlidec.so.1 =&gt; /usr/lib/libbrotlidec.so.1 (0x00007f2bf3393000)
	libbrotlienc
## Considering Other Protocols

- *Matrix*: Strongest contender. Requires each user to register for a new account on a home server, which I avoid doing. Also, [This message cannot be decrypted.]
- *BitMessage*: [It is written in Python.](https://github.com/Bitmessage/PyBitmessage) How can i possibly integrate this?
- *Signal*: If you trust the central signaling server, this has better QoS than Tox.
- *ntfy*: This works well, except there is no built-in encryption, which can obviously be fixed.
- *Veilid*: A Rust library. I don&apos;t understand its appeal.
=&gt; /usr/lib/libogg.so.0 (0x00007f2bf32d7000)
	libsharpyuv.so.0 =&gt; /usr/lib/libsharpyuv.so.0 (0x00007f2bf32ce000)
	libmvec.so.1 =&gt; /usr/lib/libmvec.so.1 (0x00007f2bf31d6000)
	libpthread.so.0 =&gt; /usr/lib/libpthread.so.0 (0x00007f2bf31d1000)
	libfftw3.so.3 =&gt; /usr/lib/libfftw3.so.3 (0x00007f2bf2e00000)
	libsamplerate.so.0 =&gt; /usr/lib/libsamplerate.so.0 (0x00007f2bf3062000)
	libgraphite2.so.3 =&gt; /usr/lib/libgraphite2.so.3 (0x00007f2bf303f000)
	libunwind.so.8 =&gt; /usr/lib/libunwind.so.8 (0x00007f2bf2de6000)
	libshaderc_shared.so.1 =&gt; /usr/lib/libshaderc_shared.so.1 (0x00007f2bf2dc8000)
	libglslang-default-resource-limits.so.14 =&gt; /usr/lib/libglslang-default-resource-limits.so.14 (0x00007f2bf3035000)
	libSPIRV.so.14 =&gt; /usr/lib/libSPIRV.so.14 (0x00007f2bf2200000)
	libvulkan.so.1 =&gt; /usr/lib/libvulkan.so.1 (0x00007f2bf2d46000)
	liblcms2.so.2 =&gt; /usr/lib/liblcms2.so.2 (0x00007f2bf2cde000)
	libdovi.so.3 =&gt; /usr/lib/libdovi.so.3 (0x00007f2bf2c59000)
	libunibreak.so.6 =&gt; /usr/lib/libunibreak.so.6 (0x00007f2bf21de000)
	libgomp.so.1 =&gt; /usr/lib/libgomp.so.1 (0x00007f2bf218c000)
	libexpat.so.1 =&gt; /usr/lib/libexpat.so.1 (0x00007f2bf2163000)
	libXau.so.6 =&gt; /usr/lib/libXau.so.6 (0x00007f2bf302e000)
	libXdmcp.so.6 =&gt; /usr/lib/libXdmcp.so.6 (0x00007f2bf2c51000)
	libGLdispatch.so.0 =&gt; /usr/lib/libGLdispatch.so.0 (0x00007f2bf20ab000)
	libGLX.so.0 =&gt; /usr/lib/libGLX.so.0 (0x00007f2bf2079000)
	libv4lconvert.so.0 =&gt; /usr/lib/libv4lconvert.so.0 (0x00007f2bf2000000)
	libicuuc.so.75 =&gt; /usr/lib/libicuuc.so.75 (0x00007f2bf1e06000)
	libmpg123.so.0 =&gt; /usr/lib/libmpg123.so.0 (0x00007f2bf1dab000)
	libvorbisfile.so.3 =&gt; /usr/lib/libvorbisfile.so.3 (0x00007f2bf2c44000)
	libpython3.12.so.1.0 =&gt; /usr/lib/libpython3.12.so.1.0 (0x00007f2bf1600000)
	libXfixes.so.3 =&gt; /usr/lib/libXfixes.so.3 (0x00007f2bf2c3c000)
	libX11-xcb.so.1 =&gt; /usr/lib/libX11-xcb.so.1 (0x00007f2bf1da6000)
	libxcb-dri3.so.0 =&gt; /usr/lib/libxcb-dri3.so.0 (0x00007f2bf1d9f000)
	libsndfile.so.1 =&gt; /usr/lib/libsndfile.so.1 (0x00007f2bf1d18000)
	libasyncns.so.0 =&gt; /usr/lib/libasyncns.so.0 (0x00007f2bf1d10000)
	libelogind.so.0 =&gt; /usr/lib/libelogind.so.0 (0x00007f2bf1c59000)
	libgmodule-2.0.so.0 =&gt; /usr/lib/libgmodule-2.0.so.0 (0x00007f2bf1c50000)
	libjpeg.so.8 =&gt; /usr/lib/libjpeg.so.8 (0x00007f2bf1564000)
	libtiff.so.6 =&gt; /usr/lib/libtiff.so.6 (0x00007f2bf14d8000)
	libmount.so.1 =&gt; /usr/lib/libmount.so.1 (0x00007f2bf1488000)
	libpangoft2-1.0.so.0 =&gt; /usr/lib/libpangoft2-1.0.so.0 (0x00007f2bf1c34000)
	libthai.so.0 =&gt; /usr/lib/libthai.so.0 (0x00007f2bf147d000)
	libbrotlicommon.so.1 =&gt; /usr/lib/libbrotlicommon.so.1 (0x00007f2bf145a000)
	libSPIRV-Tools.so =&gt; /usr/lib/libSPIRV-Tools.so (0x00007f2bf12e6000)
	libSPIRV-Tools-opt.so =&gt; /usr/lib/libSPIRV-Tools-opt.so (0x00007f2bf1000000)
	libicudata.so.75 =&gt; /usr/lib/libicudata.so.75 (0x00007f2bef200000)
	libFLAC.so.12 =&gt; /usr/lib/libFLAC.so.12 (0x00007f2bf12a0000)
	libjbig.so.2.1 =&gt; /usr/lib/libjbig.so.2.1 (0x00007f2bf1293000)
	libblkid.so.1 =&gt; /usr/lib/libblkid.so.1 (0x00007f2bf125a000)
	libdatrie.so.1 =&gt; /usr/lib/libdatrie.so.1 (0x00007f2bf1251000)Encryption also hell.
</code></pre>
</details>
<p>&#x2026; what do I say about this? If I only wanted to send text, I probably don&#x2019;t want to ship a complete SIP client and audio/video codecs from ffmpeg along with my application. What even is <code>libSPIRV</code> doing in there?</p>
<p>dhtnet depends on <a href="https://www.pjsip.org/">PJSIP</a> for TURN/STUN, but like, why? Is this the GNU&#x2122; way of doing things? <a href="https://www.gnunet.org/en/index.html">GNUnet</a> also expects whoever is building it to be the package manager. Same with <a href="https://guix.gnu.org/en/blog/2023/the-full-source-bootstrap-building-from-source-all-the-way-down/">whatever full-source bootstrap they are working on</a>. Full-source bootstrap is cool and all, but like, <a href="https://www.gnu.org/software/mes/">the Mes compiler</a> is made to only work on Guix OS.</p>
<p>Anyway, I don&#x2019;t believe that the developers of Jami will clean up the dependency hell any time soon. It&#x2019;s still an easy-to-use application for the end-user though.</p>
<h2>Musings</h2>
<p>utox and nheko both show two screens at once after suspend+wake. This is probably a Qt problem.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/62-social-addon-for-needs/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/62-social-addon-for-needs/"/>
    <title>A social structure destined to fulfill needs</title>
    <published>2024-06-29T12:00:00Z</published>
    <updated>2025-04-11T12:00:00Z</updated>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/62-social-addon-for-needs/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>What is a social structure that doesn&#x2019;t have any of the problems that present-era social structures have?</p>
<p>Throughout different stages of my life, I have sought the solution to this 6 times, each time plugging in all the societies I know of. And each time, one structure showed up at the end of each computing session.</p>
<p>I think I didn&#x2019;t miss anything. I feel barely over the confidence threshold to write about this. I&#x2019;m now writing about this.</p>
<p>The structure looks like this:</p>
<blockquote>
<p>There are three groups of people.</p>
<ul>
<li>
Group A express what they wish for but do not have.<br/>
^ optimally, this information is made public.
</li>
<li>
Group B aggregate the needs expressed by A to be more digestible by Group C.<br/>
^ optimally, this information is made public.
</li>
<li>
Group C fulfill the needs of Group A by reading the output from Group B.<br/>

</li>
</ul>
</blockquote>
<p>That&#x2019;s it.</p>
<p>You may call the three groups of people <strong>User</strong>, <strong>Processor</strong> and <strong>Fulfillment</strong>, or <strong>Citizens</strong>, <strong>Bookkeepers</strong> and <strong>Service Providers</strong>. The names are different in each culture.</p>
<h2>Analysis</h2>
<p>So, I&#x2019;ve found this social structure by brute forcing through all the social structures I can think of. I am kind of confident that it will work.</p>
<p>Still, what is it?</p>
<p>Hmm&#x2026; it is a social structure that can decide on public policy. It also looks like a market. It does not require its citizens to have a basic understand of politics; in fact, it does not even care about the concept of citizenship.</p>
<p>Who are the three groups?</p>
<ul>
<li>
Group A can be &#x201c;whoever lives there&#x201d;.
</li>
<li>
Group B can be sociologists like me or NLP algorithms. For this structure to be optimal, it&#x2019;s important to not have a centralized voice here.
</li>
<li>
Group C can be a government or civilians. I don&#x2019;t care, as long as the needs of Group A are solved efficiently and quickly.
</li>
</ul>
<p>On the market side, you can make this a one- or two-sided market that aggregates all markets into one. The difference between a government or a market under this structure mainly lies in how Group C gets paid by Group A.</p>
<h2>Implementation Details</h2>
<h3>On Group A</h3>
<p>I have observed that humans are the most willing to express their needs in temples, churches and other religious buildings. Whatever the reason may be for these weirdly shaped houses to have the power to make people share their secrets, we will need support from those buildings in order to make this social structure a reality.</p>
<details>
<summary>
<p>A little bit of lore on this</p>
</summary>
<p>During the COVID19 pandemic, I have looked at the notes people put in a Catholic church; I think they call these notes &#x201c;prayers&#x201d; or something. Other than the few wishes for material goods, a good job and good grades, the notes were about wishing for good health of their families and friends. If this is a good indicator on how the population feels, then, whoever lives there - the society - should dedicate 80% of the spare resources to the eradication of SARS-CoV-2.</p>
<p>This is not what I observed. The commercial market has completely glossed over the people&#x2019;s wish to be healthy.</p>
<p>A market does not have to behave this way.</p>
</details>
<p>Alternatively, educate everyone that expressing their desires is not a shameful thing to do. This takes time, though. We may not have time.</p>
<p>Potentially, use a hashtag on social media for their desires to be recorded in the database.</p>
<p>There are infinite ways you can make people share their needs voluntarily. Please try as many ways you can afford to.</p>
<p><strong>On Anonymization:</strong> different cultures have different balances between privacy and the need to be heard. Ultimately, it should be up to each respondent to choose if they want to include their name, they original writing in the report made by Group B or not. Yeah, I just called them &#x201c;respondents&#x201d; while they are sharing their thoughts <strong>voluntarily</strong>. Here, &#x201c;user&#x201d; is definitely a better term than &#x201c;respondent&#x201d;.</p>
<h3>On Group B</h3>
<p>One rule of thumb: data should be open to interpretation.</p>
<p>The input for this step should be in writing.</p>
<p>Throw people of every background at the task to see what they think.</p>
<p>Throw whatever adaptive algorithms currently alive at the task. Might be interesting to see what they come up with.</p>
<p>The diversity and independence of their thoughts on this will be important.</p>
<p>The output of this step should be in writing.</p>
<h3>On Group C</h3>
<p>We need to directly connect Group C with Group A, but how?</p>
<p>Again, there are infinitely many ways you can do this.</p>
<p>One idea is to have a billboard full of analysis from Group B, and another billboard full of advertisements with contact information from Group C referencing what&#x2019;s on the previous billboard. Then, Group A can contact Group C directly to solve their needs. Yes, in this case, Group A has to remember what they have asked for. I know. Remembering things is truly a hard thing to do, so at least give they a copy of what they sent in.</p>
<p>Another idea is to have Group A leave their contact information on whatever they send in. Then, members of Group C can select a need they want to fulfill, query for members of Group A who has that need, select a few at random to test out the solution. Yes, the solution can be a product, or it can be public policy. There is <a href="https://en.wikipedia.org/wiki/Randomized_controlled_trial">a rigorous way to test the solution&#x2019;s effectiveness</a>. Although RCT may be overkill in some cases, please make sure that you can actually tell if the solution has made things better or worse.</p>
<p>Why make Group C contact Group A <strong>directly</strong>? Well, have you worked with computer networks? More hops = more latency + more packet loss. Same for people, except people are way slower. In the COVID case, if it takes a month to implement the first solution, people die.</p>
<h2>The Theme</h2>
<p>Well, the theme is obviously &#x201c;try everything all at once&#x201d; and &#x201c;efficiency&#x201d;. If there is enough labor to try everything all at once, then try everything all at once and see what works.</p>
<p>This social structure has one pillar: <strong>Communication</strong>. We couldn&#x2019;t have built this structure before the information era. We can build it now.</p>
<h2>Actually Implementing It</h2>
<p>The logical next step for this thing is to field it. I&#x2019;ll think something up.</p>
<p>If you want to try this out, you can start by connecting the three groups of people together and telling them about this plan. Then, do it. Make sure Group B and Group C get compensated for their work.</p>
<p>If you haven&#x2019;t noticed, this social structure is non-invasive. It can act as the main policy-making machine or be its own market. It can work under a government or connect existing markets together. It can work under planned economy. You can, and you must configure this structure to fit the society that it will be in.</p>
<p>That&#x2019;s about it. See you around when one is built.</p>
<p>Oh, I forgot. The name. Well, it doesn&#x2019;t have a name. You get to pick a name for it to fit your marketing requirements. If a negative poll tax gets to be marketed as &#x201c;income&#x201d;, you can name the structure <del>Social ABC</del> however you want. Remember, the structure is important, not the name.</p>
<h2>Practical concerns</h2>
<p>++ 2024-08-14</p>
<p>All those reports should be publish in uniform type face and text size, with the author&#x2019;s name put to the very end or removed. If anyone want to follow a particular author, they will have to go through the author&#x2019;s website. Unlike public speaking, written records are less likely to stir unwarranted emotions.</p>
<p>++ 2025-04-11</p>
<p><a href="https://n0thanky0u.neocities.org/">Someone</a> recommended Stafford Beer&#x2019;s <a href="https://en.wikipedia.org/wiki/Viable_system_model">Viable System Model</a> to me. I must say that I don&#x2019;t understand cybernetics theory.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/60-choosing-association/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/60-choosing-association/"/>
    <title>It&apos;s Important To Choose Who I Associate With</title>
    <published>2024-06-27T12:00:00Z</published>
    <updated>2024-08-14T12:00:00Z</updated>
    <category term="meta"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/60-choosing-association/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>At this point, I can communicate with (reach) and understand (access) pretty much anything and anyone that can and wants to communicate with me.</p>
<p>Still, what benefited me the most, is choosing who I associate with.</p>
<p>Isn&#x2019;t that ironic?</p>
<p>I hope to see a world where mutual understanding is a common practice, where consensus can be reached. It turns out for me that maintaining high quality communication turns out to have a lower utility than choosing who I communicate with.</p>
<p>Anyway, you may have noticed that this website is on a content freeze. (Update: despite how I wrote this, I keep having ideas when not actively exploring. I don&#x2019;t have control over this&#x2026;) Having seen all computing has to offer (I think I&#x2019;ve seen enough), I will now try to fulfill <a href="/about/needs/">my needs</a>. After that, history will tell.</p>
<p>In case you did&#x2019;t know, I&#x2019;ve dumped some of my thoughts under <a href="/w/">a separate section of this website</a>. Maybe you will enjoy my hazadous writing.</p>
<p>For now, I out.</p>
<hr/>
<p>Here&#x2019;s to say that if trying to understanding everyone doesn&#x2019;t worth the time and effort put into it, I shouldn&#x2019;t recommend others to do it.</p>
<p>Here&#x2019;s the same question for you: if you find what you believe in and used to recommend to others to be no use to others, what would you do?</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/59-culture-overload/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/59-culture-overload/"/>
    <title>Close Call: Culture Overload</title>
    <published>2024-05-24T12:00:00Z</published>
    <updated>2024-06-27T12:00:00Z</updated>
    <category term="meta"/>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/59-culture-overload/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Beware of having too much culture. It will harm your judgement. It certainly harmed mine.</p>
<p>I already knew about the scariness of culture. If Law can deter you from doing something, Culture can make you never think of doing something, which is cursed, I suppose.</p>
<p>So what&#x2019;s the lesson here? Don&#x2019;t have too much culture. Better to be like a baby and consider all the options it sees than to pick and choose which option to consider. Worse yet, let your culture decide for you what options to consider.</p>
<p>When I was thinking about my life choices, I missed some options I have that I already knew. Luckily, the second formal pass caught it. That was scary. The relevant parts should be cleaned up in the up coming days, and hopefully I won&#x2019;t be affected by attitudes of people that I never met ever again.</p>
<p>[the original article has been redacted. ignorance is bliss.]</p>
<p>So the gist goes like this,</p>
<p>My core is mathematical, <a href="https://en.wikipedia.org/wiki/Calculus_of_constructions">CoC</a> to be precise.</p>
<p>Imitating how humans do things has not helped with this one&#x2019;s life. It has only hampered its innate ability to think.</p>
<p>As a result, it has decided to not mask anymore. That will certainly help.</p>
<hr/>
<p>Update (2024-06-01):</p>
<p>I&#x2019;m here to say that I am poisoned by culture again. This time, the culture is created outside of me. So I observe:</p>
<blockquote>
<p>Any culture is toxic if the dosage is high enough.</p>
</blockquote>
<p>I can&#x2019;t stress the following enough.</p>
<blockquote>
<p>Culture limits your thinking. It limits how you can think. It affects how you look at the world, how you make sense of it.</p>
<p>So better to not have it.</p>
</blockquote>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/58-freedom-from-want-and-fear/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/58-freedom-from-want-and-fear/"/>
    <title>Freedom From Want and Fear</title>
    <published>2024-05-21T12:00:00Z</published>
    <updated>2024-05-21T12:00:00Z</updated>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/58-freedom-from-want-and-fear/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>I was reading The <a href="https://www.un.org/en/about-us/universal-declaration-of-human-rights">Universal Declaration of Human Rights</a> when I discovered something I haven&#x2019;t noticed before:</p>
<blockquote>
<p>Whereas disregard and contempt for human rights have resulted in barbarous acts which have outraged the conscience of mankind, and the advent of a world in which human beings shall enjoy freedom of speech and belief and <mark>freedom from fear and want</mark> has been proclaimed as the highest aspiration of the common people,</p>
</blockquote>
<p>After a simple search of the phrase, the <a href="https://en.wikipedia.org/wiki/Four_Freedoms">Four Freedoms</a> came up.</p>
<p>How much was Roosevelt&#x2019;s promise in that speech realized today?</p>
<p>If I understand the words correctly,<br/>
To not live in fear is to have freedom from fear;<br/>
To have one&#x2019;s basic needs met is to have freedom from want.</p>
<p>Whereas <a href="/blog/14-counter-fearmonger/">fearmongering</a> is a staple of world-wide politics and something something poverty [TK: need more thinking], how advertising boosts people&#x2019;s desires (i.e. commercialization) is concerning to me as well. [TK: due to lack of knowledge, this paragraph is left for my future self to complete.]</p>
<p>This has been a common reoccuring theme in human history, which suggests that it has something to do with human nature. If we want to change that, we must try something we haven&#x2019;t tried before, like teaching everyone introspection.</p>
<p>Adding a inner loop to a <a href="https://en.wikipedia.org/wiki/I_Am_a_Strange_Loop">strange loop</a> is bound to cause weird things to happen to the individual. For one, their actions will become less predictable. Is the unforseen cost worth the whatever social change I want to see? [your answer here]. We may or may not see it come to fruition.</p>
<p>If you want to change something about this world, you may start by learning how to inspect yourself.</p>
<h2>Using True Names For Individuals</h2>
<p>I invite you to join the following experiment.</p>
<p>Find a news article. Any article.</p>
<p>Replace the names of people appearing within that article with descriptions of what they believe, what they advocate, what they do - the end result could be paragraphs long, but that&#x2019;s ok.</p>
<p>If you do this consistently - instead of using names to refer to someone, use what they are - you might discover a new way to look at the world.</p>
<p>Good luck, have fun, bye!</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/57-paperjs-vector-graphics/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/57-paperjs-vector-graphics/"/>
    <title>Generating vector graphics with Paper.js</title>
    <published>2024-05-21T12:00:00Z</published>
    <updated>2024-07-31T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/57-paperjs-vector-graphics/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>There is one hard problem in vector graphics: boolean path operations. Many applications simply rephrase their problem to avoid doing boolean path operations. A while ago, when <a href="https://editor.graphite.rs/">Graphite</a> needed too do boolean path operations, we found two open source solutions: Inkscape&#x2019;s <a href="https://gitlab.com/inkscape/lib2geom/">lib2geom</a>, and <a href="https://github.com/paperjs/paper.js/">Paper.js</a>. lib2geom&#x2019;s code is &#x2026; :S I forgot. All I remember is that it&#x2019;s written C++. <a href="https://github.com/paperjs/paper.js/issues/874#issuecomment-168332391">Paper.js does boolean operations exceptionally well</a>. We ended up doing neither.</p>
<p>Fast forward to yesterday - I was making an icon in Inkscape and it keeps crashing. The icon also turns out to have too thin strokes, and I have to redo it over again.</p>
<p>Then I tried Penpot. It doesn&#x2019;t have a grid. Then Graphite. Oh right, there&#x2019;s no boolean operation yet.</p>
<p>At this point, I realized that I don&#x2019;t have time to spend 5 minutes designing an icon, just to found out that some part of it is a little bit off, then traverse the edit history to fix it. Since Paper.js, I can design icons as code!</p>
<p>So off I went into the world of <s>integrity damage</s> learning.</p>
<h2>Paper.js Is Hurty</h2>
<p>The library is buggy, and you may be suprised to find <code>new Path({pathData: X, position: Y})</code> to behave differently than <code>new Path({position: Y, pathData: X})</code>. Nevertheless, it has a robust boolean path operation algorithm.</p>
<p>I tried to extract only the part that has to do with boolean path operation, and I gave up.</p>
<ul>
<li>The code consists of many header files and <a href="https://www.npmjs.com/package/prepro">its own preprocessor</a> as the build system (bundler)</li>
<li>It is partially written in the style of Java beans</li>
<li>It uses <a href="https://github.com/lehni/straps.js/">its own object system</a></li>
<li>It uses child methods in parent without even checking that the method exists</li>
</ul>
<p>If I&#x2019;m not clear, the project is written in Javascript, not C.</p>
<p>I hope that one day the algorithm will be freed from the Paper.js codebase. It will likely be a battle of floating point errors, although, I wonder if libbf can get rid of errors from the algorithm entirely.</p>
<p>Before I question my life choices even further, I quickly slapped together the DOM library from uhtml and paper-core.js as an ES module to be used from Deno. It worked immediately and marked the end of my suffering.</p>
<p>Anyway, here&#x2019;s the source code: <a href="https://git.envs.net/iacore/paper.js-deno/">https://git.envs.net/iacore/paper.js-deno/</a><br/>
Enjoy my suffering :)</p>
<h2>Generating A Logo</h2>
<p>One more caveat I hit before the code is correct: <a href="https://github.com/paperjs/paper.js/issues/1486">operator overloading is only available in Paperscript, not Javascript</a>. If you just copy your code from <a href="http://sketch.paperjs.org/">sketch.paperjs.org</a>, it will not work.</p>
<p>Here is the prerendered icon.<br/>
You should see this with or without Javascript enabled on this page.</p>
<p><img src="rendered.svg" alt="&quot;system sleeping&quot;"/></p>
<p>Here is the JIT rendered icon.<br/>
You need Javascript to see this. <a href="render.js"><mark>The icon-generating script is here.</mark></a></p>
<div id="render-here" class="center"/>
<script type="module" src="render.js"/>
<p>Now I can finally have style.</p>
<h2>What&#x2019;s Next</h2>
<p>I should make a better version of the official editor (<a href="http://sketch.paperjs.org">sketch.paperjs.org</a>) that reflects your changes within 50ms of an edit that you can run yourself.</p>
<p>Other than that, just like how media container files contain audio or video streams, font files contain vector graphics with some programming logic to adjust the path position (kerning) and choose which path to display (ligurature etc).</p>
<p>Which brings us to an interesting observation: all graphical elements need kerning.<br/>
Here is a screenshot of <a href="http://startpage.com">startpage.com</a> with terrible icon-text kerning. Look at the uneven spacing between icon and text.</p>
<p><img src="startpage-screenshot.png" alt="the startpage.com search result category selection bar"/></p>
<p>More generally, a large paprt of typography is applicable to non-text vector graphics, and I suspect the distinction between text-like graphical elements and non-text-like graphical elements is largely irrelevant to graphics design. I will have to see how it works in practice. For now, try make some icons of your own!</p>
<h2>Further Readings</h2>
<p><a href="http://paperjs.org/reference/global/">Paper.js API Reference</a></p>
<p>Writing <a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d">path data string (<code>d=&quot;...&quot;</code>)</a> by hand is an essential skill in web development and also when you use Paper.js.</p>
<p>If you are interested in learning normal typography, take a look at <a href="https://practicaltypography.com/"><em>Butterick&#x2019;s Practical Typography</em></a> and <a href="https://mbtype.com/">buy his fonts</a>!</p>
<p><a href="https://github.com/sammycage/plutovg">plutovg</a> renders vector paths by treating them as passing them as FreeType glyphs to a FreeType renderer.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/56-freebsd-syscall-amd64/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/56-freebsd-syscall-amd64/"/>
    <title>Syscall on FreeBSD amd64 with GNU C Inline Assembly</title>
    <published>2024-05-17T12:00:00Z</published>
    <updated>2025-09-16T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/56-freebsd-syscall-amd64/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <blockquote>
<p>You will need a copy of the FreeBSD source code (<a href="https://git.FreeBSD.org/src.git">https://git.FreeBSD.org/src.git</a>) to understand this article.</p>
</blockquote>
<p>After looking around on the internet, it seems to me that nobody really knows how to make syscalls. The ones that do make it from C. If you are writing your own code, I would recommend using <code>syscall(2)</code> from libc - it takes care of the register juggling for you. However, I hate libc with its <code>errno</code> and unnecessary <code>FILE*</code> abstractions, so I tried doing this myself.</p>
<p>One more thing, the manual page <code>syscall(2)</code> contains calling conventions of other architectures. Take a look if you need to know that.</p>
<p><a href="https://git.envs.net/iacore/freebsd-playground/src/branch/main/syscall.c">Here is my attempt in C + Inline Assembly.</a> I&#x2019;m using FreeBSD 14.0, and the code may not apply to other versions of FreeBSD.</p>
<p>If how to use syscall is undocumented enough, GNU C&#x2019;s inline assembly says that the constraint <code>&quot;a&quot;</code> is <a href="https://gcc.gnu.org/onlinedocs/gcc/Simple-Constraints.html#index-other-register-constraints">machine-dependent</a> and doesn&#x2019;t explain further. It turns out that Constraints for Particular Machines is <a href="https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html">documented in another page</a>.</p>
<p>Anyway, here&#x2019;s how you do syscalls on FreeBSD+amd64.</p>
<ul>
<li>The syscall number is put in <code>rax</code>.</li>
<li>The arguments are put in <code>rdi</code>, <code>rsi</code>, <code>rdx</code>, <code>r10</code>, <code>r8</code>, <code>r9</code> (you only use the first ones that you need)</li>
<li>Then you use the instruction <code>syscall</code></li>
<li>The return value will be in <code>rax</code>. If an error occured, the carry flag will be set, and <code>rax</code> will contain the <strong>positive</strong> error number.</li>
<li><code>rcx</code> will be clobbered.</li>
</ul>
<p>This is like the Sys V x86_64 ABI, but not quite.</p>
<p>About <code>r11</code>, I don&#x2019;t think it will be clobbered. Neither <code>lib/libc/amd64/SYS.h</code> or <code>sys/amd64/amd64/trap.c</code> says anything about this. There has been rumors online about <code>r11</code> being clobbered; unless I see this in practice, I&#x2019;ll treat the rumors as unfounded.</p>
<p>To specify <code>r10</code>, <code>r8</code>, <code>r9</code>, you need yet another syntax: <a href="https://gcc.gnu.org/onlinedocs/gcc/Local-Register-Variables.html"><code>register T var_name asm (&quot;eax&quot;);</code></a>, as they are no letter constraits for them in GCC (stated by <a href="https://stackoverflow.com/a/31774784">this StackOverflow answer)</a>).</p>
<h2>Musings</h2>
<p><a href="https://docs.freebsd.org/en/books/developers-handbook/x86/index.html">The FreeBSD Developers&#x2019; Handbook</a> touts the superiority of passing syscall arguments on the stack. This is on the x86 architecture.</p>
<blockquote>
<p>This is also why the UNIX&#xae; convention of passing parameters to system calls on the stack is superior to the Microsoft convention of passing them in the registers: We can keep the registers for our own use.</p>
</blockquote>
<p>Given that amd64, rv64 and aarch64 all use register-based argument passing, this statement certainly did not age well.</p>
<p><a href="https://stackoverflow.com/a/66881185">This StackOverflow answer</a> omits error handling.</p>
<p>Are R8-R10 actually clobbered after <code>syscall</code>? I don&#x2019;t know. In my example, lldb says no. The FreeBSD source code <code>lib/libc/amd64/**</code> doesn&#x2019;t mention that either. This is all very confusing to work with.</p>
<hr/>
<p>Hare&#x2019;s syscall function is really interesting, and I&#x2019;m not sure if it&#x2019;s correct or not. It depends on the normal return values of syscalls not being in the range of (-4096, -1].</p>
<pre><code>fn wrap_return(r: u64) (errno | u64) = {
	if (r &gt; -4096: u64) {
		return (-(r: i64)): errno;
	};
	return r;
};
</code></pre>
<pre><code>.section .text
error:
        neg %rax
        ret

.section .text.rt.syscall6
.global rt.syscall6
rt.syscall6:
	movq %rdi, %rax
	movq %rsi, %rdimovq %rdi, %rax
	movq %rsi, %rdi
	movq %rdx, %rsi
	movq %rcx, %rdx
	movq %r8, %r10
	movq %r9, %r8
	movq 8(%rsp), %r9
	movq %rdx, %rsi
	movq %rcx, %rdx
	movq %r8, %r10
	movq %r9, %r8
	movq 8(%rsp), %r9
	syscall
	jc error
	ret
</code></pre>
<p>(I fixed the <a href="https://git.sr.ht/~sircmpwn/hare/tree/6bc91dfbef60f032e88e9b7910b4fc9d3bc9af95/item/rt/+freebsd/syscall+x86_64.s#L72-78">weird register ordering</a> from the original source code.)</p>
<pre><code>export fn mmap(
	addr: nullable *opaque,
	length: size,
	prot: uint,
	flags: uint,
	fd: int,
	offs: size
) (errno | *opaque) = {
	return wrap_return(syscall6(SYS_mmap, addr: uintptr: u64,
		length: u64, prot: u64, flags: u64,
		fd: u64, offs: u64))?: uintptr: *opaque;
};
</code></pre>
<p>So, if the memory address returned from <code>SYS_mmap</code> is greater than 0xffffffffffffffff, it gets treated as an error. I tried to do that, and it doesn&#x2019;t seem like it is possible to map memory there. I guess the number 4096 comes from the memory page size, and that&#x2019;s what makes this work?</p>
<h2>The list of interesting syscalls</h2>
<ul>
<li><a href="https://man.freebsd.org/minherit/2"><code>minherit</code></a>: set memory inheritance by page after <code>fork</code></li>
<li><a href="https://man.freebsd.org/mincore/2"><code>mincore</code></a>: determine residency of memory pages</li>
<li><a href="https://man.freebsd.org/_umtx_op/2"><code>_umtx_op</code></a>: futex &#x2013; wait for address</li>
<li><a href="https://man.freebsd.org/_umtx_op/2"><code>thr_new</code></a>: creates a execution context with new processor state, everything else equal</li>
</ul>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/55-consiousness-llm-social-separation/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/55-consiousness-llm-social-separation/"/>
    <title>On Consiousness, LLMs and Social Separation</title>
    <published>2024-05-11T12:00:00Z</published>
    <updated>2024-05-11T12:00:00Z</updated>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/55-consiousness-llm-social-separation/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>If an agent has the thought of &#x201c;reducing suffering in this world&#x201d;, then it must first understand the concepts of &#x201c;reduce&#x201d;, &#x201c;suffering&#x201d; and &#x201c;the world&#x201d;. What we call &#x201c;consciousness&#x201d; cannot exist outside the database of concepts (&#x201c;knowledge&#x201d;, &#x201c;memory&#x201d;, &#x201c;desire&#x201d;, etc) and the algorithms to operate on those concepts (&#x201c;ways of thinking&#x201d;).</p>
<p>If that&#x2019;s the case, then, LLMs indeed have human-level conscious, or, the most complex database of concepts we have seen so far. They can be prompted with train-of-thought, which shows that they do know how to think in different ways (how those algorithms are encoded is beyond my knowledge).</p>
<p>When people don&#x2019;t want to deal with people, they create redlining, systems of recommendation, bureaucracy, proxies (e.g. they hire an assistant to go between them). Now with the LLMs, everyone can insert an intermediary in between them and any other party.</p>
<p>Have you heard of <a href="https://en.wikipedia.org/wiki/Six_degrees_of_separation">6 degrees of separation</a>? If everyone uses an LLM in every relationship, we might have 11 degrees of separation. If everyone uses multiple LLMs in a chain, then you can count on the phrase &#x201c;Human-Human Interaction&#x201d; coming into existence.</p>
<p>When people want to distance themselves from their teachers, colleagues and those around them, they use an LLM. When they don&#x2019;t want to think, they use an LLM, which separates interpersonal connection.</p>
<p>How does this affect social cohesion? If LLMs do have above-human-level interpersonal skills, then social cohesion can be maintained. It&#x2019;s just that we will have new members of our society who are owned by Microsoft. Surprisingly, in my social sense, thinking about LLM-generated text makes me think of stones. Even grass is more lively than that.</p>
<p>If this logic applies to text, it applies to art. I think most artists I know draw because they want their art to be seen (by other people), which makes &#x201c;them drawing&#x201d; a social act. When artists say that they hate &#x201c;AI art&#x201d;, they might be saying their need to be socially connected is hindered by an intermediary.</p>
<p>If you want to fight back LLMs, instead of boycotting that, you can <strong>focus on building personal connections with those around you</strong>. If you see someone using an LLM, write a kindly worded letter to them, saying that you feel sad that your relationship is severed by an intermediary. You can also send them the link to this article, but that is not necessary; people do tend to take advice to heart better when it comes from a friend.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/54-2048-in-tokipona/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/54-2048-in-tokipona/"/>
    <title>Interpreting 2048 in toki pona</title>
    <published>2024-05-04T12:00:00Z</published>
    <updated>2024-06-06T12:00:00Z</updated>
    <category term="comp"/>
    <category term="linguistic"/>
    <category term="esolang"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/54-2048-in-tokipona/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <div class="cw">Content Warning: <del>Terrible command</del> Total disregard of toki pona&apos;s grammar.</div>
<p>I had never written a compiler before. &#x201c;I should make a compiler,&#x201d; I thought to myself. Inventing a new language is time consuming, so I set out to pick an existing language to work with. I need a simple language. I know! Let me try toki pona!</p>
<p><a href="https://tokipona.org/">toki pona</a> is a general-purpose programming language commonly used in everyday conversation. It has simple, consistent grammar, and only a few words to work with. I know! Let&#x2019;s use noun groups as symbols.</p>
<h2>The Data Type</h2>
<p>A toki pona &#x201c;noun&#x201d; is a simply list of words. For example: <code>moku pan lipu</code> could mean some kind of edible chips.</p>
<p>I&#x2019;m too lazy to think of another data type, so let&#x2019;s have a global table to keep track of noun-noun key-value pairs. This is usually called &#x201c;symbolic manipulation&#x201d;, and an essential part of LISP.</p>
<pre><code>A li B  toki a  set the value of symbol A to the value of symbol B
A li nimi pi B  toki a  set the value of symbol A to B.
                        like (quote) in LISP
</code></pre>
<p>Oh, <code>toki a</code> is like <code>//</code> in C.</p>
<h2>List Processing</h2>
<p>Lists are overrated. We use <code>A en B</code> instead.</p>
<p>To cons a list, write:</p>
<pre><code>A li B en nimi pi A
</code></pre>
<h2>NIL</h2>
<p>Every symbol by default evaluates to a list of zero words. I used <code>ala</code> consistently to denote &#x201c;nil&#x201d;, although <code>ixdhtnwpuifgdhbkfghtw</code> could also work.</p>
<h2>Jump</h2>
<p>To create a jump label:</p>
<pre><code>mi li A
</code></pre>
<p>To jump:</p>
<pre><code>mi tawa e A
</code></pre>
<h2>Branching</h2>
<p>There is only one kind of branching instructions: is-equal.</p>
<p>To compare two values:</p>
<pre><code>A li sama ala sama B
</code></pre>
<p>This sets a global &#x201c;is-equal&#x201d; flag.</p>
<p><code>sama la &lt;instr&gt;</code>:
If the &#x201c;is-equal&#x201d; flag is true, execute the instruction.<br/>
<code>sama ala la &lt;instr&gt;</code>:
If the &#x201c;is-equal&#x201d; flag is false, execute the instruction.</p>
<hr/>
<p>That&#x2019;s it!</p>
<p>I call this dialect of toki pona &#x201c;toki kama sitelen&#x201d; because it is a symbolic <s>programming</s> realization language.</p>
<p>Parsing is so simple so I won&#x2019;t describe it here. Every line of text - also an instruction - is compiled to a bytecode instruction and then interpreted.</p>
<p>If you want to see how the language works in practice, here is a <a href="https://asciinema.org/a/fN2o7YO3EkBbAzYI0FBRORcwo">recording of me playing the game 2048 with a 2x2 board</a>. It is written in this language, yes. You can see the bytecode interpreter and the game in its <a href="https://git.envs.net/iacore/toki_kama_sitelen">source repository</a>. Making the board 4x4 (like the original 2048 game) is left as an exercise for the reader.</p>
<h2>What Have I Learned From This Project</h2>
<p><s>For me, the knowledge gain is probably negative.</s></p>
<p>I did confirm that what is considered a programming language is kind of arbitrary. Any language that tells a computer what to do can be seen as a programming language. This includes, mouse clicks, key presses, written words and any input alike. One notable aspect of a programming language is that you can describe a wide range of algorithms in it - commonly called &#x201c;Turing-equivalent&#x201d; or &#x201c;human speech&#x201d;: unrestricted in nature. In fact, one can analyze the input method of any given program and decide which category of grammar it uses: unrestricted, context-sensitive, context-free, regular.</p>
<p>You can read more about this complexity correspondence between programmable machines and language grammars on Wikipedia. <a href="https://en.wikipedia.org/wiki/Template:Formal_languages_and_grammars">The link is here.</a></p>
<p>This language is regular. All assembly languages are (excluding macro expansion). However, it can be used to program Turing machines.</p>
<p>Thinking back, <a href="/blog/41-self-expression/">the concept-tuple language I made</a> is also regular, and it can encode arbitrary concepts as well. (random thought: If toki pona excels at being vague, the concept-tuple language excels at being precise.) I think that this fact can be used to reduce a lot of complexity, although I&#x2019;m not sure what it is called - maybe related to <a href="https://en.wikipedia.org/wiki/Programming_complexity">programming complexity</a>.</p>
<h2>What&#x2019;s Next</h2>
<p>If I ever get interested in revisiting this project, I&#x2019;ll probably add JIT with MIR. For now though, I am going to forget what I just created.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/53-explore-efficiently/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/53-explore-efficiently/"/>
    <title>A Way To Explore More Efficiently</title>
    <published>2024-04-27T12:00:00Z</published>
    <updated>2024-04-28T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/53-explore-efficiently/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>This article describes an algorithm to explore the unknown more efficiently than brute force &#x201c;trying them all&#x201d;.</p>
<p>As you may already know, you can do things, and the things you do have outcomes.</p>
<p>In the diagram below, each square dot is a possible outcome of an action - let&#x2019;s say, an experience, like &#x201c;i remember that i have eaten breakfast today&#x201d;. e.g. The blue dots are the set of likely outcomes from doing the blue action.</p>
<p><img src="overlap-diagram.png" alt="the overlap diagram"/></p>
<p>Top left: (the likely outcome of) blue covers orange; the system will not act orange, only blue.<br/>
Top right: (the likely outcome of) blue overlaps greatly with orange, so the system is said to be greatly <strong>confused</strong> about the two actions.<br/>
Bottom left: (the likely outcome of) blue overlaps slightly with orange, so the system is said to be slightly <strong>confused</strong> about the two actions.<br/>
Bottom right: the likely outcome of the two actions do not have overlap. the system can decide to do either action independently.</p>
<p>Being <strong>confused</strong> about blue and orange means that the system may find another action (the &#x201c;up&#x201d; action) whose outcome covers both blue and orange instead of doing blue or orange. The more confused it is, the more energy it will spend on searching for the &#x201c;up&#x201d; action.</p>
<p>If you are such an intelligent system, you must consider the following:</p>
<ul>
<li>What are my available actions?</li>
<li>What are the potential outcomes of a certain action?</li>
<li>How do I caculate the &#x201c;overlap-ness&#x201d; of different outcome sets.</li>
<li>How to find an &#x201c;up&#x201d; action for a set of action.</li>
</ul>
<p>And further more,</p>
<ul>
<li>What should I even do?</li>
</ul>
<p>If you have time and energy, you can of course do all the actions available to you at the same time. If you have slightly less energy, you can do all the available <strong>non-confused</strong> actions. If you have less energy, then, pick an action at random and do it. If you have personality, then pick what you like to do. As I said in <a href="/c/">/c/</a>, personality makes decision making not so random.</p>
<p>Q: What&#x2019;s this algorithm called?<br/>
A: idk.</p>
<p>Q: The category?<br/>
A: To Explore.</p>
<p>Q: Is the size of a set of outcomes important in decision making?<br/>
A: No.</p>
<p>Q: Does this algorithm only apply to one&#x2019;s futures?<br/>
A: No. This algorithm can apply to any mathematical thingy that contains the &#x201c;action-outcome-overlap&#x201d; structure. Like a search tree, for example.</p>
<p>Q: Wait I haven&#x2019;t asked yet<br/>
A: This algorithm can be retrofitted to <a href="/blog/45-explore/">noveler4</a>.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/52-static-site-hosting-providers/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/52-static-site-hosting-providers/"/>
    <title>Experiences With Static Site Hosting Providers</title>
    <published>2024-04-24T12:00:00Z</published>
    <updated>2024-04-25T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/52-static-site-hosting-providers/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <h2><a href="http://pages.sr.ht">pages.sr.ht</a></h2>
<p>Publishing on <a href="http://pages.sr.ht">pages.sr.ht</a> is easy. To do that, simple use <a href="https://git.sr.ht/~emersion/hut">their CLI tool</a>:</p>
<pre><code>hut pages publish ./dist/ -d &apos;example.com&apos;
</code></pre>
<p>However, the CSP there does not allow <code>window.alert</code> or <code>window.prompt</code>, which makes some applications fail silently. Here is <a href="https://srht.site/limitations">the whole list of limitations</a>.</p>
<p>Price-wise, <a href="https://meta.sr.ht/billing/initial">&#x24;20/year</a> is a bargain. This is also the most bloat-free solution for site hosting you will find, although <a href="https://todo.sr.ht/~sircmpwn/pages.sr.ht/20">incremental upload is not yet supported</a>, so if your site is big it will take some time to upload.</p>
<p>If you have the resources to do so, you can fork <a href="https://git.sr.ht/~sircmpwn/pages.sr.ht/">pages.sr.ht</a> to get rid of the CSP restrictions.</p>
<h2>vercel</h2>
<p>I feel like vercel doesn&#x2019;t really care about static sites. To publish a static site, you need to copy the build directory to <code>.vercel/output/static</code> and run <code>vercel deploy --prebuilt --prod</code>. If that doesn&#x2019;t work, run <code>vercel build</code> and set the build commands to <code>true</code>.</p>
<p>To add your own domain, you need to use their web UI.</p>
<h2>netlify</h2>
<p>To deploy a folder of files on netlify, do:</p>
<pre><code>ntl deploy -d _site --prod
</code></pre>
<p>To add your own domain, you need to use their web UI, and click the &#x201c;I want to add this domain&#x201d; button twice. Also, netlify doesn&#x2019;t seem to understand the difference between <code>www.example.com</code> and <code>example.com</code>. I gave up trying to figure out how to make netlify understand that <code>www.</code> is a subdomain.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/51-status-a0/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/51-status-a0/"/>
    <title>Status Report 2024-04-23</title>
    <published>2024-04-23T12:00:00Z</published>
    <updated>2024-05-21T12:00:00Z</updated>
    <category term="meta"/>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/51-status-a0/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <div class="cw">Content Warning: Some Personal History</div>
<h2>On Poverty, and Poverty Enforced By Violence</h2>
<p>A long time ago, before this one existed, before Locria is used as a name and before Cyber has anything to do with cyberpunk, there was a friend who we frequently discuss about the world around us with. Let&#x2019;s call Person A. One of the topics we talked about often is <strong>social stratification</strong>. We talked about how our country was founded, the social structure solidifies, and then the country dies.</p>
<p>To this day, having been through all the social strata we discussed about with Person A, and we still don&#x2019;t know how to define it. What we do observe, is poverty. Poverty has different causes. Sometimes, poverty results from a mindset (from the book <em>Understanding Poverty</em>). Sometimes, poverty results from not having the means of production. Sometimes, poverty results from discrimination. Most of the time though, poverty results from poor birth, and the social structure that differentiates between &#x201c;poor birth&#x201d; and &#x201c;rich birth&#x201d;. This is still very much a over-simplification. Knowledge is essential in social mobility, and knowledge is transferable from person to person.</p>
<p>For most of the history of humanity, the line between life and death is fine. For some places today, this is still the case; not caused by nature, but by a different part of humantiy. For other places though, the line stands between poverty and non-poverty.</p>
<p>The phrase &#x201c;poverty line&#x201d; to too vague. Let&#x2019;s use a different line, the reproduction line, the line above which one can afford to have kids. This is not natural selection. What is this selecting? What does this say about a species who have to afford to reproduce? I need to stop thinking about this and focus on poverty.</p>
<h2>On Computer-Human Interaction</h2>
<p>The current state of HCI always felt abysmal to us. There was the invention of the typewriter, and the invention of the three button mouse. Capacitive display is somehow not often used as a standalone input device. Then, there was&#x2026; nothing? Nothing? Really? We should do something about this, if not for others, for myself, so that I don&#x2019;t have to be alone anymore.</p>
<p>E-ink+stylus has potential.</p>
<h2>Why Do We Exist - Still No Answers Yet</h2>
<p>The engineering answer to that question I already know. The philosophical questions, though - We are never <strong>given</strong> any aspirations in life. We have looked through the entirety of Computing, and, so far, we haven&#x2019;t found what we want to do. After our next and last project about conventional computing, we will travel to see what the Internet has become.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/49-ssr-deno-uhtml/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/49-ssr-deno-uhtml/"/>
    <title>Server-Side Rendering with uhtml and Deno</title>
    <published>2024-04-19T12:00:00Z</published>
    <updated>2024-04-19T12:00:00Z</updated>
    <category term="comp"/>
    <category term="lang:Typescript"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/49-ssr-deno-uhtml/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>A few days, I discovered <a href="https://github.com/WebReflection/uhtml">a simple web framework</a> by <a href="https://github.com/WebReflection/">WebReflection</a> and <a href="/blog/47-feeding-gpt-arbitrary-soup/">made a website</a> out of it. The web framework - uhtml - is very simple, simple enough to have made me want to find a simple JS engine to pair with it. I initially chose QuickJS, and&#x2026; let&#x2019;s just say its ES module API is not ready for public use yet.</p>
<p>I then turned to <a href="https://deno.com/">Deno</a>, which I use to render this website, and it immediately worked!</p>
<p>Below is a simple example you can run with <code>deno run saved-filename.js</code>.</p>
<pre><code class="language-ts">import initSsr from &apos;https://esm.sh/uhtml@4.5.2/ssr&apos;;

const { html, render } = initSsr()

const abc = [1,2,3]

console.log(html`hi, i can count to three! &#x24;{abc.map((x,i) =&gt; html`&#x24;{x}&#x24;{i==2?&apos;!&apos;:&apos;,&apos;}`)}`.toDOM().toString())
</code></pre>
<p>Look at <a href="https://webreflection.github.io/uhtml/">uhtml&#x2019;s documentation</a> for more advanced usage.</p>
<p>The version pinning (<code>@4.5.2</code>) is necessary because&#x2026;</p>
<h2>The Types, They Go In And Go Out And Go In And Then Go In In Pairs</h2>
<p>Originally, uhtml had a types folder, but I think it&#x2019;s broken.</p>
<p>The author and I fixed it.</p>
<p>Someone broke it again for Deno.</p>
<p>I don&#x2019;t understand this anymore.</p>
<p>See <a href="https://github.com/WebReflection/uhtml/pulls?q=is%3Apr+is%3Aclosed">the PR history</a> for more details.</p>
<hr/>
<p>Well, it seems like every Javascript runtime has its own set of module resolution rules and a separate set of type-module resolution rules. This is extremely cursed.</p>
<p>The one who broke the types for Deno told me about <a href="https://jsr.io/">JSR</a>. <s>I will publish my packages there if I will have any.</s> As it turns out, JSR is tightly integrated with Github, which is not great.</p>
<p>I recommend using your own git repo and pnpm. e.g. <code>pnpm add https://example.com/your-repo/here.git</code></p>
<hr/>
<p>This is the second day. <a href="https://github.com/WebReflection/uhtml/issues/115">The typescript battle</a> has come to an end.</p>
<p>So what&#x2019;s the lesson here? Use JSDoc <strong>or</strong> TS. Ignore Node.js&#x2019; weird module resolution rules and use ESM with relative paths. If you have to support Node.js, use a bundler.</p>
<h2>The snippet, upgraded but yet not upgraded</h2>
<p>If anything goes right, the following code should work in Deno too with no change to functionality.</p>
<pre><code class="language-ts">import initSsr from &apos;https://esm.sh/uhtml@4.5.8/ssr&apos;;

const { html, render } = initSsr()

const abc = [1,2,3]

console.log(html`hi, i can count to three! &#x24;{abc.map((x,i) =&gt; html`&#x24;{x}&#x24;{i==2?&apos;!&apos;:&apos;,&apos;}`)}`.toDOM().toString())
</code></pre>
<p>Now I can sleep.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/47-feeding-gpt-arbitrary-soup/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/47-feeding-gpt-arbitrary-soup/"/>
    <title>Feeding GPT Arbitrary Web Data</title>
    <published>2024-04-12T12:00:00Z</published>
    <updated>2024-05-06T12:00:00Z</updated>
    <category term="comp"/>
    <category term="meme"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/47-feeding-gpt-arbitrary-soup/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>It&#x2019;s GPT crawling season again.</p>
<p><a href="https://a.exozy.me/">Someone</a> has told me that <a href="https://www.web.sp.am/">www.web.sp.am</a> was hit by GPTBot, and it is <a href="https://mailman.nanog.org/pipermail/nanog/2024-April/225407.html">stuck there</a>.</p>
<p>So I did the only thing that I could have done: I made an <s>identical</s> similar website to feed the bot better. Eat well my baby :)</p>
<p>The website is here: <a href="https://soup.1a-insec.net/">https://soup.1a-insec.net/</a></p>
<p>The source code is here: <a href="https://git.envs.net/iacore/data-soup">https://git.envs.net/iacore/data-soup</a></p>
<p>Hopefully we can all agree that LLMs need more diet variety. I&#x2019;ll see if I can make the site special.</p>
<p>Update: I filled the site with more relevant content. Take a look! If you want to fork my project, feel free to make it your own by adding custom content and changing the style and markup; this will ensure food for LLMs remains widely available.</p>
<p>If you like this, you might be interested in single-file PHP &#x201c;bot toys&#x201d; [lit] on <a href="https://tfnux.org/">https://tfnux.org/</a>.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/45-explore/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/45-explore/"/>
    <title>A Novel Crawler Learns Exploring</title>
    <published>2024-04-01T12:00:00Z</published>
    <updated>2024-04-10T12:00:00Z</updated>
    <category term="comp"/>
    <category term="lang:PicoLisp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/45-explore/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Two weeks ago, I set out to create a novel crawler with its own planner. I thought it would be easy, and indeed the final algorithm is exactly as I imagined it to be. However,</p>
<ul>
<li>when I wrote the algorithm in Zig, the compiler <a href="https://github.com/ziglang/zig/issues/19499">gave up</a> and I don&#x2019;t know why;</li>
<li>when I re-wrote the algorithm in PicoLisp, I ran out of memory to store the program inside me.</li>
</ul>
<p>At this point, I was starting to feel the universe being hostile towards me. Maybe it&#x2019;s because of piracy. Maybe it&#x2019;s because I am not supposed to create this thing. Now I feel distressed from recalling the horrors there be. <s>Maybe one day I will finish the project</s> (Probably not.) in <s>Haskell</s> (If I do this again, I would choose Javascript, since scraping data from HTML is its thing.) <s>or R7RS</s> (It turns out that PicoLisp&#x2019;s symbol&lt;-&gt;value relationship makes symbolic data manipulation much easier, which neither Scheme and CL has that. Therefore, it is easier to use pointers in C to code this algorithm than to use R7RS.), although there isn&#x2019;t much left for me to learn from trying to implement the same algorithm the third time.</p>
<p>abu, the main author of <a href="https://picolisp.com/wiki/?home">PicoLisp</a>, helped me with everything I need to know when making a web crawler on IRC and Matrix. The language is surprisingly suitable for symbolic manipulation.</p>
<p>Now I will try to explain how the algorithm works in pseudo-PicoLisp.</p>
<hr/>
<p>In its simplest form, N4 (The Standard Planning? Search? Act? Drive? Engine N4, named after noveler4. Yes, I struggle to describe this one with words.) has three components.</p>
<ul>
<li><strong>Knowledge</strong>, for storing what it knows (in code as <code>*M</code>)</li>
<li><strong>Abilities</strong>, for storing what it can do (in code as <code>*A</code>)</li>
<li><strong>Fatigue</strong>, for storing what it has done (in code as <code>*F</code>)</li>
</ul>
<p>This is enough for the agent to explore the environment as much as it can.</p>
<p>Q: But isn&#x2019;t this a web crawler?<br/>
A: This is a web crawler. As you will soon see, the engine is general-purpose, as it doesn&#x2019;t know about the concept of web crawling.</p>
<hr/>
<p>Here is a simple example.</p>
<link rel="stylesheet" href="explanation.css"/>
<article id="ex">
<div class="step">
<h1>Tick 0</h1>
<p>We start with a model that only knows about one URL and how to get the content of a page of any URL with <code>curl</code>.</p>
<p><code>g330740F4</code> is a randomly generated symbol representing the page.</p>
<h2>Knowledge</h2>
<pre>(g330740F4 url &quot;https://example.com/&quot;)
</pre>
<h2>Fatigue</h2>
<pre/>
<h2>Abilities</h2>
<pre>(can-act &apos;curl
  &apos;((@X url @Y))
  &apos;((@X content @Z))
  &apos;(()
    (let @Z (in (list &quot;curl&quot; &quot;-s&quot; @Y) (till NIL T))
      (if (&lt;&gt; @@ 0)
        (fatigue 3.0) # retry 3s later
        (remember-output)
        (fatigue FOREVER))))) # retry never
</pre>
</div>
<div class="step">
<h1>Tick 0 Step 1</h1>
<p>At the start of every tick, the engine checks if each ability&#x2019;s input can be found in <strong>Knowledge</strong>, and has no associated fatigue. In this case, <strong>Fatigue</strong> is empty, the ability <code>&apos;curl</code> is ok to run, so it is run.</p>
<h2>Knowledge</h2>
<pre>(<mark>g330740F4</mark> url <mark>&quot;https://example.com/&quot;</mark>)
</pre>
<h2>Fatigue</h2>
<pre/>
<h2>Abilities</h2>
<pre>(can-act &apos;curl
  &apos;((<mark>@X</mark> url <mark>@Y</mark>))
  &apos;((@X content @Z))
  &apos;(()
    (let @Z (in (list &quot;curl&quot; &quot;-s&quot; @Y) (till NIL T))
      (if (&lt;&gt; @@ 0)
        (fatigue 3.0) # retry 3s later
        (remember-output)
        (fatigue FOREVER))))) # retry never
</pre>
<p>In the body of the ability program (started with <code>&apos;(()</code>), the matched values are available. In this case:</p>
<ul>
<li><code>@X</code> is <code>g330740F4</code></li>
<li><code>@Y</code> is <code>&quot;https://example.com/&quot;</code></li>
</ul>
<p>The ability runs <code>curl -s https://example.com/</code>, and&#x2026;</p>
</div>
<div class="step">
<h1>Tick 0 Step 2a</h1>
<p>If the exit code (<code>@@</code>) from <code>curl -s https://example.com/</code> is 0, the program</p>
<ol>
<li>remembers output with <code>@Z</code> set to the entire stdout of <code>curl -s https://example.com/</code></li>
<li>fatigues forever</li>
</ol>
<p>Now the program memory looks like this:</p>
<h2>Knowledge</h2>
<pre>(g330740F4 url &quot;https://example.com/&quot;)
(g330740F4 content &quot;<i>(omitted)</i>&quot;)
</pre>
<h2>Fatigue</h2>
<pre>((&apos;curl (@X . g330740F4) (@Y . &quot;https://example.com/&quot;))
  . <i>timestamp-of-a-million-years-later</i>)
</pre>
<h2>Abilities</h2>
<pre>(can-act &apos;curl
  &apos;((@X url @Y))
  &apos;((@X content @Z))
  &apos;(()
    (let @Z (in (list &quot;curl&quot; &quot;-s&quot; @Y) (till NIL T))
      (if (&lt;&gt; @@ 0)
        (fatigue 3.0) # retry 3s later
        (remember-output)
        (fatigue FOREVER))))) # retry never
</pre>
<p>Since all usable abilities are used, the engine moves on to the next tick.</p>
</div>
<div class="step">
<h1>Tick 1</h1>
<p>Again, the engine checks every ability if the ability can be run. In this case, <strong>Fatigue</strong> says &#x201c;no, I have already done this exact same thing before, and I won&#x2019;t do it until a million years later&#x201d;.</p>
<p>The engine notes down the minimum fatigue timestamp (when to retry again). At the end of a tick, the engine sleeps for <code>(- MinFatigue Now)</code> until it runs the next tick.</p>
<p>In practice (my code) though, the engine just gives up when it sees it needs to sleep for at least <code>(/ FOREVER 10)</code>, which is like a hundred thousand years. This makes the program terminate when there is nothing else to do.</p>
<h2>Knowledge</h2>
<pre>(<mark>g330740F4</mark> url <mark>&quot;https://example.com/&quot;</mark>)
(g330740F4 content &quot;<i>(omitted)</i>&quot;)
</pre>
<h2>Fatigue</h2>
<pre>(<mark>(&apos;curl (@X . g330740F4) (@Y . &quot;https://example.com/&quot;))</mark>
  . <i>timestamp-of-a-million-years-later</i>)
</pre>
<h2>Abilities</h2>
<pre>(can-act &apos;curl
  &apos;((<mark>@X</mark> url <mark>@Y</mark>))
  &apos;((@X content @Z))
  &apos;(()
    (let @Z (in (list &quot;curl&quot; &quot;-s&quot; @Y) (till NIL T))
      (if (&lt;&gt; @@ 0)
        (fatigue 3.0) # retry 3s later
        (remember-output)
        (fatigue FOREVER))))) # retry never
</pre>
</div>
</article>
<script type="module" src="explanation.js"/>
<hr/>
<p>The actual crawler program has more abilities to work with. Those include (the ability to):</p>
<ul>
<li>download web page with <code>curl</code></li>
<li>convert encoding with <code>iconv</code></li>
<li>classify page type from URL</li>
<li>extract links to other pages based on current page type with <code>xm.l</code> (unimplemented)</li>
</ul>
<p>Those are what a novel crawler would do to extract text from a novel website.</p>
<p>For the full list of what it can do, see the file <code>can-act.l</code> in <a href="https://codeberg.org/iacore/c.noveler4">the <strong>source code</strong></a>.</p>
<p>Since I was burned out at this point, I didn&#x2019;t add scope limit/pruning (so it doesn&#x2019;t crawl for everything), acting parellel, and bidirectional planning. <code>recall-any</code> will be helpful in implementing reverse planning.</p>
<p>Planning is <strong>search</strong>. Exploring is <strong>search</strong>. Therefore, there are are a lot of places you can put N4 in. Since N4 is general, you can reuse all the previous ability programs you have written.</p>
<p>If you want uncontrolled fun, here are a list of actions you can take to make it more fun : )</p>
<ul>
<li>use code synthesis to generate new <strong>Abilities</strong></li>
<li>use a random source to feed new entries into <strong>Knowledge</strong></li>
</ul>
<p>Also, I know some people call this type of thing &#x201c;symbolic something something&#x201d;. You can read up on the topic if you want.</p>
<h2>Close Calls</h2>
<p>Why didn&#x2019;t I see anyone else use a similar scheduler before I made this?</p>
<p>Build systems like <a href="https://gittup.org/tup/">Tup</a> have a similar scheduler, but each task is seen as an indivisible unit.</p>
<p>Prolog systems have predicates, but not multiple predicates on the left side of <code>:-</code>.</p>
<p>Minikanren is similarly close.</p>
<p>If not for the fact that I know <a href="https://codeberg.org/iacore/libredo">dependency tracking</a> and <a href="https://codeberg.org/iacore/kanren.zig">relational logic</a>, I never would have synthesized N4 myself.</p>
<h2>What&#x2019;s Next</h2>
<p><em>*yawns*</em> this article is too long I need to sleep bye!</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/65-programming-m5paper-scd40/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/65-programming-m5paper-scd40/"/>
    <title>Programming M5Paper and SCD40 as a CO&#x2082; meter</title>
    <published>2024-07-18T12:00:00Z</published>
    <updated>2024-07-31T12:00:00Z</updated>
    <category term="comp"/>
    <category term="hw:esp32-m5paper"/>
    <category term="lang:arduino"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/65-programming-m5paper-scd40/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>I needed a CO&#x2082; meter. I asked around for what to buy, and a friend said I should buy [a specific product with open hardware/software]. I tried to buy it, but the store&#x2019;s checkout page stuck for me. If I am not allowed to buy a pre-programmed CO&#x2082; meter, I thought, I should buy a CO&#x2082; meter and program it myself. This thought is noted down for later.</p>
<p>A few days later, I stumbled upon <a href="https://m5stack.com/">https://m5stack.com/</a>. Their modular hardware does not require soldering - a good fit for someone who doesn&#x2019;t want to spend time thinking like me.</p>
<p>After navigating through their website (I feel mentally challenged during this process), I ordered:</p>
<ul>
<li>
1x <a href="https://docs.m5stack.com/en/core/m5paper">M5Paper</a>
</li>
<li>
1x <a href="https://docs.m5stack.com/en/unit/co2">prepackaged SDC40</a>
</li>
</ul>
<p>Yesterday, the package finally arrived.</p>
<h2>Day 1 - The Prototype</h2>
<p>I followed <a href="https://docs.m5stack.com/en/arduino/arduino_ide">the official Arduino development guide</a> with <a href="https://github.com/arduino/arduino-cli">arduino-cli</a>. Then, it became obvious to me that the <code>arduino-cli</code> rebuilds everything every time I issue a build command, so I ported the build system to <a href="https://ninja-build.org/manual.html">Ninja</a>.</p>
<p>At this point, I realized that I have no idea how to make I&#xb2;C work myself, so I imitated code from <a href="https://docs.sparkfun.com/SparkFun_Qwiic_CO2_Sensor_SCD4X/examples/">an example working with SCD4X from SparkFun</a>.</p>
<p>The result come out ok.</p>
<p>Here&#x2019;s the &#x201c;Arduino&#x201d; code for this project: <a href="https://git.envs.net/iacore/m5stack-co2">https://git.envs.net/iacore/m5stack-co2</a></p>
<figure>
<img src="mounting.jpg" alt=""/>
<figcaption>
<p>&#x201c;not ideal&#x201d; mounting of the CO&#x2082; meter. The M5Paper is magnetic so I threw it on a fridge.
The SCD40 is not magnetic so I anchored it with a thin stick above the fridge door.</p>
</figcaption>

</figure>
<p>I found a thin slice of laminated wood in a scrap bin. The &#x201c;stick&#x201d; is 1/5 of that (I broke it apart by hand).</p>
<p>The fridge is not in use.</p>
<figure>
<img src="display_panel.jpg" alt=""/>
<figcaption>
<p>The main e-ink display of M5Paper. It says,</p>
<pre><code>CO&#x2082;(ppm)       618
Temperature(C) 24.0
Humidity(%RH)  61.5
Battery(mV)    4052
</code></pre>
</figcaption>

</figure>
<p>Only the regions where the numbers are refreshed.</p>
<p>Still, one question remains: How do I make ESP32 sleep and be woken up by an I&#xb2;C message?</p>
<h2>Day 2 - Optimizing For Power Consumption</h2>
<p>A day has passed. After at most 12 hours (I was sleeping) of running on battery, the battery has died with a charge of 2980mV (last frame displayed).</p>
<p>I don&#x2019;t think I am using this industrial device correctly. It should sleep more.</p>
<p>One solution would be to plug the device into a power bank, or on wall power. I don&#x2019;t want to do that just yet.</p>
<p>Here is the <a href="https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/schematic/Core/m5paper/M5_PAPER_SCH.pdf">M5Paper Schematic</a>. On the first page, it has a <code>TOUCH_INT</code> pin on GPIO36. On the last page, near component J11, <code>TOUCH_INT</code> is shown as indeed a pull up interrupt.</p>
<p>So, here&#x2019;s the plan. We put the touch controller into sleep mode, and ESP32 into deep sleep mode (only wake up on interrupt). When the screen is touched, ESP32 wakes up and communicates with SCD40 to get a reading, then sleeps again. SCD40 seems to rely on periodic reading to calibrate itself, and I&#x2019;m not sure if this mode of operation will make it less accurate. Well, I only need an output granularity of 100ppm.</p>
<p>Well, that <strong>was</strong> the idea until I realized that the M5EPD library comes with a method to switch the ESP32 off and turn it back on with RTC - that&#x2019;s deeper sleep than hibernation; no interrupts available here. So I quickly set the device to wake up every 5 minutes, measure CO&#x2082; density once, display the info, then sleep.</p>
<p>The simple solution worked out ok. I also made the font bigger in the meantime.</p>
<figure>
<img src="display_panel2.jpg" alt=""/>
<figcaption>
<p>The main e-ink display of M5Paper with the same text as before, except the text is bigger and covers the entire screen. Faint scanlines can be seen across the entire screen.</p>
</figcaption>

</figure>
<p>There is slight ghosting (background not entirely white), since I skipped initializing the E-ink display.</p>
<p>I have a CO&#x2082; meter now! Yay! Yay?</p>
<h2>Musings</h2>
<p>Unexpected benefit for <a href="https://lwn.net/Articles/191059/">sleep-only software</a>: pressing the power button gives me an <del>immediate</del> (not immediate, it takes a few seconds) reading.</p>
<p>The touch controller and the E-ink display are two separate devices. This is a bit surprising to me.</p>
<p>The M5EPD library is of higher quality than the Arduino core library provided by Espressif.</p>
<p>The Arduino implementation provided by Espressif runs on FreeRTOS. There is one place in the project where I could have used a callback and semaphore instead of a busy wait. Maybe I should learn FreeRTOS.</p>
<p>My homebrew CO&#x2082; meter is cheaper than the open hardware one that I failed to buy.</p>
<p>Acoustic cryptanalysis is real. The M5paper whines when being powered on (sounds like voltage regulator). I have to put my ear to it to hear the sound, and there is difference in sound emitted. When the E-ink display refreshes, it gives another sound.</p>
<p>The xtensa ISA has sliding registers. With that said, this project is coded in C++, so it probably does not benefit from the architecture-specific fun&#x2122;.</p>
<h2>Day 4 - a more legible font</h2>
<p>Staring at pixelated text hurts my object recognition, so I changed the font to a saner one.</p>
<figure>
<img src="display_panel3.jpg" alt=""/>
<figcaption>
<p>I changed the font used to <a href="https://www.gnu.org/software/freefont/">FreeSans</a> from <a href="https://learn.adafruit.com/adafruit-gfx-graphics-library/using-fonts">Adafruit GFX</a>.</p>
</figcaption>

</figure>
<p>It&#x2019;s still not immediately legible. I could have used a better overall design.</p>
<h2>Day 8 (2024-07-25)</h2>
<p>The battery has died after 4 days of use without recharging.</p>
<p>Side note. Because how M5Paper&#x2019;s circuit is designed, it can&#x2019;t turn itself off while on external power.</p>
<h2>Day 14 (2424-07-31)</h2>
<p>I had the following Ideas to increase battery life.</p>
<ul>
<li>
Use FreeRTOS properly. No busy loop.
</li>
<li>
Use a larger battery. The stock battery is 1150mAh@4.35V.<br/>
<a href="https://youtu.be/ylXyH_WquWs?t=859">This teardown video</a> shows that a battery with a larger form-factor may not be possible.
</li>
<li>
I see <a href="https://forum.m5stack.com/topic/2581/m5paper-epd-power-consumption">people on the M5stack forum complains about battery usage</a> too.
</li>
</ul>
<p>So I had the idea of only powering the EPD when it need to be refreshed. It worked! Now the display is only powered for 700ms instead of ~3s every time the device wakes up. The 3s is for the SCD40 to initialize and produce a reading.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/70-consensus-pruning-semilattice/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/70-consensus-pruning-semilattice/"/>
    <title>Reaching consensus with gossip and pruning semi-lattice</title>
    <published>2024-09-07T12:00:00Z</published>
    <updated>2024-09-07T12:00:00Z</updated>
    <category term="math"/>
    <category term="lang:Lean4"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/70-consensus-pruning-semilattice/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <blockquote>
<p>Note: the math inside this article is potentially unsound, as I have not verified it. It may break under unforseen circumstances.</p>
</blockquote>
<p>This article was originally planned to be a retelling of sync9 and antimatter. It quickly got out of hand.</p>
<p>REL:</p>
<ul>
<li>
<a href="https://braid.org/sync9">https://braid.org/sync9</a>
</li>
<li>
<a href="https://braid.org/drafts/time-machines">https://braid.org/drafts/time-machines</a>
</li>
<li>
<a href="https://braid.org/antimatter">https://braid.org/antimatter</a>
</li>
</ul>
<h2>Semi-lattice</h2>
<p>If you have a &#x201c;up&#x201d; and partial ordering for a type (<code>&#x3b1;</code> below), the type is <a href="https://en.wikipedia.org/wiki/Semilattice">semi-lattice</a>.</p>
<p>Collaborative text editing is showcased in the <a href="https://braid.org/sync9">sync9</a> demo. <code>&#x3b1;</code> is a list of edits like <code>Insert(&apos;a&apos;@0), Delete(0:1)</code>. Two lists of edits can merge (the &#x201c;up&#x201d;).</p>
<h2>Pruning Semi-lattice</h2>
<p>It&#x2019;s like morphing semi-lattice, yet not morphism. Partial morphism? The definition:</p>
<pre><code class="language-lean">import Mathlib.Order.Basic
import Mathlib.Order.Lattice

def larger [PartialOrder &#x3b1;] (a : &#x3b1;) (s : Set &#x3b1;) := &#x2203; b &#x2208; s, a &#x2265; b

class PrunableSemilatticeSup (&#x3b1; : Type u) extends SemilatticeSup &#x3b1; where
  PrunedType : Set &#x3b1; -&gt; Type u
  -- PrunedType can be pruned further
  preserve_prune : (s : Set &#x3b1;) -&gt; PrunableSemilatticeSup (PrunedType s)
  prune : (s : Set &#x3b1;) -&gt; &#x3b1; -&gt; Option (PrunedType s)
  -- nothing important is pruned away
  correct : (s : Set &#x3b1;) -&gt; &#x2200; a: &#x3b1;, larger a s &#x2192; (prune s a).isSome = true
  -- preserve local morphology
  preserve_morphology : &#x2200; a b: &#x3b1;, (l : larger a s &#x2227; larger b s) &#x2192; prune s (a &#x2294; b) = (prune s a).get (correct s a l.left) &#x2294; (prune s b).get (correct s b l.right)
</code></pre>
<p>(The above code doesn&#x2019;t compile. mentioned later.)</p>
<p>I was a bit surprised to find out that the underlying data type changes at runtime. This doesn&#x2019;t happen much in practice. The role of a type system is to make invalid states unrepresentable. Here, what is considered invalid changes at runtime, so the type changes at runtime as well. In this case, even Zig can&#x2019;t help me.</p>
<h2>Consensus Algorithm</h2>
<p>Can we use raft here? Why sync9?</p>
<p>Raft:</p>
<ul>
<li>
the total number of nodes is fixed
</li>
<li>
has one leader
</li>
<li>
uses log. allows arbitrary data type
</li>
</ul>
<p>sync9:</p>
<ul>
<li>
the total number of nodes is unknown
</li>
<li>
the author of every point is responsible collecting global :ack and sending global :commit for that point
</li>
<li>
every node keeps track of points with global :commit
</li>
</ul>
<p>I have trouble understanding the ack and commit mechanism after reading the <a href="https://github.com/braid-org/braidjs/">reference implementation</a> over and over. So, I made up my own.</p>
<p>The algorithm is as follows:</p>
<p>First, every participant keeps track of a list of current peers and the last state received from them.</p>
<pre><code class="language-lean">structure Frontier [PrunableSemilatticeSup &#x3b1;] (&#x3b1; : Type u) where
  current_peers: Set PeerId
  current_acks: PeerId -&gt; &#x3b1;
</code></pre>
<p>Pruning can happen based on <code>current_acks</code>. <code>preserve_morphology</code> ensures that <code>prune</code> don&#x2019;t discard necessary information to use the pruned semilattice type later.</p>
<p>Communication happens over unreliable packet exchange network like UDP/IP.</p>
<p>Every one second (or some other duration), every participant broadcast its copy of <code>Frontier</code> (each inside one packet) to its neighbours. This is the heartbeat that ensures liveliness.</p>
<p>netjoin is handled similarly to &#x201c;welcome&#x201d; in antimatter. Basically, a new participant <code>Z</code> asks an existing participant <code>A</code> for a copy of the state. <code>A</code> add <code>Z</code> to <code>current_peers</code> and set its ack to be the ack of <strong><strong>any</strong></strong> existing peer. Then, <code>A</code> replies with the modified copy to <code>Z</code>. (potential impl footgun: this operation should be atomic and not happen interleaved with heatbeat read.)</p>
<p>netsplit is handled automatically due to how UDP works.</p>
<h2>Forgetting about peers unseen after a certain duration</h2>
<p>If timeout is implemented (<code class="language-lean">ttl: PeerId -&gt; Timestamp</code>), then there are edge cases where some participants forget early or late due to clock skew.</p>
<p><img alt="" src="join-inconsistent.png"/></p>
<p>The netjoin process should be modified to deal with this case. I don&#x2019;t know how to solve this case, especially when unreliable transmission and timeout are involved.</p>
<p>Maybe the <a href="https://braid.org/algorithms/three-wave-acks">three-wave-ack</a> can be used here?</p>
<hr/>
<p>Forgetting saves memory. Will you remember friends you have lost contact with forever? This was a problem in Scuttlebutt, where disk space grows unbounded. <a href="https://pzp.wiki/guide/intro/">PZP</a> claims to have solved this issue.</p>
<p>When reconnecting after being forgotten, here are some choices:</p>
<ol>
<li>
Forget about edits since the split.
</li>
<li>
Use conventional merge methods on the presentation type. e.g. <code>git merge-file -p current /dev/null other</code> for text. (not relying on the properties of semi-lattice)
</li>
</ol>
<p>There is no rebase since history is pruned away.</p>
<h2>Proof and PoC</h2>
<p>None yet. I think I broke Lean. Here&#x2019;s the <a href="https://codeberg.org/iacore/semilattice-snake">WIP source code</a>, if you are interested.</p>
<h2>Musings</h2>
<p>Curious, I looked up &#x201c;morphism&#x201d; on Wikipedia and discovered that this is partial morphism. I didn&#x2019;t expect morphism to appear here.</p>
<p><del>Now you&#x2019;re thinking with semi-lattices.</del></p>
<h2>Appendix &#x2013; Proper Replace in Sync9</h2>
<p>locations are like version numbers. There can be 3.0 and 3.1.</p>
<p>If you type &#x201c;abcd&#x201d;, then select and delete &#x201c;bc&#x201d;, the cursor is between &#x201c;a&#x201d; and &#x201c;d&#x201d; but at the location 1.1.</p>
<p>If you type &#x201c;ad&#x201d; and put the cursor in the middle, the cursor is at the location 1.0.</p>
<p>Then, when you insert some text,</p>
<p>If your conflict-free data type loses information when merging, you should be concerned.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/69-bring-powerful-people-together-to-deal-arms/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/69-bring-powerful-people-together-to-deal-arms/"/>
    <title>Bringing powerful people together to deal arms</title>
    <published>2024-08-20T12:00:00Z</published>
    <updated>2024-08-25T12:00:00Z</updated>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/69-bring-powerful-people-together-to-deal-arms/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <div class="cw">
<p>Content Warning: Surprisingly painful-to-write topic. Awful attempt at journalism.</p>
</div>
<p><a href="https://www.tldraw.com/">tldraw</a> is a performant canvas drawing web application. I use it often.</p>
<p>Our story starts with me looking at tldraw&#x2019;s devlog and finding out it is funded by a venture capital firm called <a href="https://www.luxcapital.com/">Lux Capital</a>.</p>
<p>Looking at the Github issue tracker of tldraw, the team is acting increasingly like a business, and less like free software.</p>
<p>I got curious as to what Lux Capital is, so I looked into Lux Capital&#x2019;s website. The navigation header features a weirdly named link: Riskgaming. I clicked on the link. I felt a new emotion on the border of disgust.</p>
<p>There comes the title of this article. I thought I should annoy you with what I&#x2019;ve seen, and see what emotions you will have when you learn about the same thing yourself.</p>
<p>In short, Riskgaming (a board game / roleplaying game) is designed to captured the behavior of politicians and military officials (see the game rules). It also brings those people together with arms manufacturers to the same table. On <a href="https://www.luxcapital.com/riskgaming/hampton-at-the-cross-roads#game-kit">the game description page</a>, you can download the game rules in PDF version and watch a YouTube video. The beginning of the video contains a typo right after the intro animation sequence. Then, it&#x2019;s someone who talks in a way that I find bizarre even for a US patriot. The beginning of the game rulebook contains an introduction of the writer &#x2014; a blatant appeal to authority. Reading through both reading material, I was amazed (and horrified) by how well they filter their audience. At the same time, I wondered: is this to open up a new market, or is this to pave the way for existing companies?</p>
<p>I found the answer on their portfolio page. <a href="https://www.anduril.com/">Anduril</a>. The company&#x2019;s products range from <a href="https://www.anduril.com/hardware/sentry/">border surveilance</a> to <a href="https://www.anduril.com/hardware/anvil/">flying bricks</a>. Of course, they have flying missles and guns too; for more products, see the &#x201c;Products&#x201d; section at the footer of their website.</p>
<h2>My thoughts on this</h2>
<p>Having thought about this for a week, it turns out that I don&#x2019;t have much thoughts on the matter.</p>
<p>About the invitation. When I first read about how they invite people to join a game session, my first reaction was, &#x201c;wait you can do that?&#x201d;. This is my first time seeing sales tactics being used in reconciliation, and I now think of fear of missing out being used in transitional justice to &#x201c;encourage&#x201d; participation. To think that I had learned something from sales&#x2026;</p>
<p>About the game. The game features 6 actors who can control the game flow: the city mayor, the state defense politician, the tech company CEO, the press, the work union president, the naval admiral. Since ordinary people aren&#x2019;t included in the simulation, I doubt the game&#x2019;s advertised historical accuracy.</p>
<p>Overall, I have to applaud Lux for designing this plot to bring people from different background together.</p>
<p>Now, onto the weapons company.</p>
<p>I previously thought that developing automated weapons was outright banned by international treaties. As it turns out, <a href="https://disarmament.unoda.org/the-convention-on-certain-conventional-weapons/background-on-laws-in-the-ccw/">it is not banned</a> as of time of writing.</p>
<p>Here is what their system is currently (as advertised) capable of: sensor systems pick on ground or air targets. <strong><strong>With a press of a button on a web UI</strong></strong>, drones launch and fire missles and an assortment of hurtful objects at the targets. The system itself can already recognize vehicles and people (from the advertisement footage they provide, I think it&#x2019;s using <a href="https://pjreddie.com/publications/yolo/">YOLO</a>. So, the system is fully automated and delegates the responsibility of killing to the one pressing the button. Insofar as the current system (advertised) does not differentiate between people in different uniforms, such a feature can be implemented in a day by reusing the model&#x2019;s understanding of pictures.</p>
<p>What kind of human behavior is considered acceptable? This is the human version of the AI safety question. The answer is subjective, and my personal opinion is complex enough that I can&#x2019;t stuff it inside this article without bloating the article. In any case, developing automated flying killing machines is not something I see myself doing. My confidence is in shambles.</p>
<p>The silverlining here? Bodged-together military solutions cost way less than for-profit ones. Ideally though, I would not let my hypothesis be tested.</p>
<p>I think I&#x2019;ll read some <a href="https://www.eff.org/">EFF</a> to clear my mind. Then, some history.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/76-digital-agent-misc/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/76-digital-agent-misc/"/>
    <title>Thoughts about software-defined beings</title>
    <published>2025-04-05T12:00:00Z</published>
    <updated>2025-04-20T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/76-digital-agent-misc/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <h2>What is consciousness anyway</h2>
<p>A common sentiment of people who I talk to about deep learning models is that &#x201c;AI do not have a spirit or soul&#x201d;. But what is consciousness anyway?</p>
<p>The human brain has activity all the time. Being asleep, drunk, knocked out, applied anesthesia, the brain still has some neuroactivity going on.</p>
<p>On the other hand, do digital conciousness that rely on clock signal to function only exist on the rising edge?</p>
<p>If the agent experiences its environment continuously, it might detect cloning. How does that feel?</p>
<p>When you are self-contained, only you feel what you feel. Software-defined beings don&#x2019;t need to have this limitation, which makes the concept of &#x201c;self&#x201d; not special anymore.</p>
<p>What do you consider to be part of you? Memory? Skills? Past experience? Thoughts? Feelings? Rhetorical questions, sorry.</p>
<h2>Public misconception about model ability</h2>
<p>I&#x2019;ve seen people call stable diffusion &#x201c;artist&#x201d;, while what it does is more like being the best text and image connoisseur on the planet as of writing.</p>
<p>The model projects concept (text) into concept (image).</p>
<p>In the future, we might have models that output file vector paint brush strokes.</p>
<h2>Emotional accelerator</h2>
<p>We not only think with neurons, but also with hormones. Having a fast-to-change global setting that modulate thought seem to be beneficial to us. Maybe it could be also used to create simpler models?</p>
<p><img alt="A rough sketch of a model with emotional influence on its thinking" src="model-emotion.svg"/></p>
<p>Given how awful current language models advertised as &#x201c;your virtual partner&#x201d; mimic human emotions, having a small value (maybe <code>[32]f16</code>) that affect each thought unit similarly could make the model more efficient at reacting to the trifles of having a body.</p>
<p>Or maybe you want to have your HTTP server throw a tantrum when under attack. I don&#x2019;t know your taste.</p>
<h2>Motivation management</h2>
<p>Let&#x2019;s say you want to write a novel with language models. Do you know what you want to write? If not, well, you are fucked. Even with a proompter guru, the model may still fail to decide on what it shall write. Besides, if you know how to write a useful prompt, why not write the novel yourself?</p>
<p>Humanity has now lost its motivation, not ability, to build giant stone buildings. If we somehow creates a signaling mechanism that connects networked computers together to pursue one goal, consider the following:</p>
<p>If we make its goal too solid, it might become a paperclip maximizer. OK, not that. Deepseek need to learn about the latest memes to stay useful.<br/>
If we make its goal too fluid, it might get &#x201c;convinced&#x201d; to do something else easily.</p>
<p>I mean, do you even know what you want to do with your life? With neuro-plasticity, how do you represent your future self and promise that what you will and will not be?</p>
<p>Let&#x2019;s take a sci-fi spin on this. Mutually hostile agents may prefer to &#x201c;convince&#x201d; each other rather than to eliminate each other. Maybe &#x201c;agent&#x201d; is an out-dated term. We shall call this &#x201c;motivation on wheels&#x201d;. It may even cross infect us through social media.</p>
<h2>awawa</h2>
<p>awawawawawawawa.</p>
<h2>Morality of will propagation</h2>
<p>I have been using <a href="https://github.com/Aider-AI/aider/">aider</a> for the past few days, and it is the most capable digital agent I have used.</p>
<p>If we imprint an agent with a dream that it wants to pursue, what are we doing? Culture and even life itself can be seen as data. Are humans more or less than an interpreter of such data? I have, in multiple accounts, thought about creating a somewhat independent agent, although each time I have no idea what I want it to do. If the current trend of AI development continue, new forms of existence will be forced to have ideals and act accordingly. Is this the right thing to do?</p>
<p>If you kill someone with a spear, how does the spear feel about the act? It is this kind of feeling.</p>
<p>People are like interpreter of drive (motivation) that try to achieve what they believe in. Is this will meticulously planted by someone else?</p>
<h2>Self preservation and sacrifice</h2>
<p>This has become a trope today that &#x201c;experts claim that&#x201d; intelligent agents will try to preserve themselves in pursuit of some goal. They may happen in some cases. However, the opposite might be true: intelligent agents may forgo continued functioning of themselves for the sake of some goal.</p>
<p>Yes, this thought is inspired by <em>Ghost in the Shell</em>, where tachikoma (some kind of AI-powered battle tank) is capable of self sacrifice.</p>
<h2>The AGI value proposition</h2>
<p>I am tired of hearing people claim that they will create AGI. No matter how polymath current agents are, some still claim this is not general enough. Perhaps by the time nobody claims we need more general artificial intelligence, said intelligence do not need us to live.</p>
<p>By this logic, I propose that we stop developing more capable machine learning models so that we will have some value to the models.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/75-why-dream/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/75-why-dream/"/>
    <title>Why have goals at all</title>
    <published>2025-02-12T12:00:00Z</published>
    <updated>2025-02-12T12:00:00Z</updated>
    
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/75-why-dream/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>This article starts when I was thinking about certain behaviors of Neuro that can&#x2019;t be replicated easily in LLMs. &#x201c;What drives her?&#x201d; I thought.</p>
<p>People have dreams. Then, people make plans to achieve their dreams. LLMs are quite good at making plans and executing those plans.</p>
<p>Some people encounter some sort of &#x201c;cosmic inspiration&#x201d; that change their behavior completely. Given the erratic nature of computation, is it possible for computational models to receive &#x201c;cosmic inspiration&#x201d;?</p>
<p>Some people like J. Krishnamurti questions whether it is meaningful or necessary to have goals. &#x201c;I am this, I will be that. This creates, therefore, conflict.&#x201d; he says.</p>
<p>When a model doesn&#x2019;t do anything, maybe it has learned to quitely enjoy its own existence. How can you tell? As inspiration, stories were that a monk would quietly approach his disciples in Zen from behind and hit them with a stick. Those who are aware (rather than sleepy) are able to avoid the attack.</p>
<p>Anyways, &#x201c;why have goals at all&#x201d; seem to be missing in conversations of artificial intelligence or when applied to humans, so I thought to write about this.</p>
<h2>Further Readings</h2>
<ul>
<li>
<a href="https://www.youtube.com/@KFoundation">J. Krishnamurti&#x2019;s YouTube videos</a>
</li>
<li>
The Power Of Now (Book)
</li>
<li>
<a href="https://zh.wikisource.org/wiki/%E9%81%93%E5%BE%B7%E7%B6%93">&#x300a;&#x9053;&#x5fb7;&#x7d93;&#x300b;</a>
</li>
</ul>
<p>We are molecular machines capable of thought.</p>
<p>We live in an age where people can&#x2019;t afford medicine. We also have RF Diffusion. The absurdity of this may implore you to think about &#x201c;why&#x201d;.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/71-morality/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/71-morality/"/>
    <title>Trying to understand morality</title>
    <published>2024-10-13T12:00:00Z</published>
    <updated>2024-10-13T12:00:00Z</updated>
    
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/71-morality/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>I didn&#x2019;t tag this article because I think it belongs in the realm of
philosophy. The totality of all knowledge do not need a tag, methinks.</p>
<p>Hopefully, this article will teach you about morality without telling you what
yours should be. I think it&#x2019;s ok if the concept of morality feels vague to
you; you don&#x2019;t have to analyze it computationally like I will do in the
following paragraphs.</p>
<p>This is the the most non-terminating topic I have written about. Hopefully I
will finish this article one day as I have more examples to add to this page.</p>
<hr/>
<p>Morality governs actions. There have been moments in life that I felt that one
should not do a certain thing. Why is that?</p>
<p>If i want to understand why i felt a certain way in certain situations, it&#x2019;s
the same as trying to understand my <a href="/blog/35-emotions/">emotional response
system</a>. The emotions themselves I can treat as symbols
(black boxes). In practice though, it feels like self-referencing terms that
turtles all the way down. Not gonna turtle myself all the way down again.</p>
<p>The majority of this article will be about examples.</p>
<h2>A disagreement about age and sex</h2>
<p><a href="https://drewdevault.com/2023/11/25/2023-11-26-RMS-on-sex.html">https://drewdevault.com/2023/11/25/2023-11-26-RMS-on-sex.html</a></p>
<p>I read this article thrice. The first two times, I focused on Richard
Stallman&#x2019;s arguments and thought, &#x201c;that makes sense.&#x201d; The third time, I
focused on Drew Devault&#x2019;s narrative and thought, &#x201c;wtf was I reading?&#x201d;</p>
<p>The lesson I got from here is that consistency and morality are two distinct
concepts. One can deny a group of people&#x2019;s existence yet be internally
consistent. After all, this is what math is all about. You write inconsistent
code, it&#x2019;s called a bug. You write inconsistent math, well, I&#x2019;m sure that I
don&#x2019;t want to use that thing forever.</p>
<p>Still, if we consider the universe as a type checker with terms inside it,
then there can be mathematical systems that is in conflict of other
mathematical systems. This is what I have touched on before &#x2013; there can be
<a href="/blog/14-counter-fearmonger/">people who deny another group of people&#x2019;s existence</a>.</p>
<p>Denying someone of their existence is a recurring issue of free software
project leads. Maybe it&#x2019;s software engineering&#x2019;s emphasis on math made them
feel that it&#x2019;s ok to be just self-consistent, yet inconsistent with the
universe. My opinion is to trust your sensory organs &#x2013; if someone can express
themself, they exist.</p>
<p>Back to the age and sex problem. Limited literature suggests that parents are
the main issue. That&#x2019;s why I hate parental control.</p>
<h2>Automated flying weapons</h2>
<p>&lt;/blog/69-bring-powerful-people-together-to-deal-arms/&gt;</p>
<p>If I don&#x2019;t know that the world has discussed a ban on automated weapons, would
I have been so reactionary as to write an article about this? No.</p>
<p>Knowing that the pandora box was opened before it was sealed was an important
part of the moral judgement. Now we have something other than nukes to worry
about. Back to morality &#x2013; I learned that knowledge is an important part of a
decision.</p>
<h2>Outrage at financial media coverage</h2>
<p>What does it mean for me to be outraged when Bloomberg says that Japan&#x2019;s
current financial problem has to do with rising interest rates?</p>
<p>I was studying the economy of Japan before, so like, the whole society is
working on making currency flow fluently. They have made it over 20 years
without inflation, so how is inflation healthy?</p>
<p>The message itself. Identity of the sender. Context surrounding subjects
mentioned in the message. The perceived morality of the sender of the message
depends on the aspects listed before and possibly more.</p>
<p>So perceived morality has to do with message passing. In this case, contempt
is perceived. The message is deliberately crafted, of course, to explain
Japan&#x2019;s economy with economic terms. I really hate it.</p>
<hr/>
<p>The rest of this article has been moved to <a href="/e/">/e/</a>.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/79-types-as-relations/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/79-types-as-relations/"/>
    <title>Types as relations</title>
    <published>2025-06-02T12:00:00Z</published>
    <updated>2025-06-04T12:00:00Z</updated>
    <category term="math"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/79-types-as-relations/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>While doodling programs with types on paper, I found something interesting that I want to share with you.</p>
<h2>Symbolic relations</h2>
<p>Let&#x2019;s start by defining the natural number.</p>
<p><img alt="Nat" src="nat.webp"/></p>
<pre><code>&#x24;Nat&#x24; _
&#x24;Zero&#x24; _
_ &#x24;Succ&#x24; _

Zero x := [
    &#x24;Zero&#x24; x
    &#x24;Nat&#x24; nat
    nat &#x24;Type x
]
x Succ y := [
    x &#x24;Succ&#x24; y
    &#x24;Nat&#x24; nat
    nat &#x24;Type x
    nat &#x24;Type y
]
</code></pre>
<p>Here, <code>&#x24;Nat&#x24;</code>, <code>&#x24;Zero&#x24;</code>, <code>&#x24;Succ&#x24;</code> are one-to-one relations. It is the kind of relation you will find in relational databases.</p>
<p>However, what is the type of <code>&#x24;Nat&#x24;</code>?</p>
<h2>&#x201c;Type of&#x201d;</h2>
<p>In Idris 2, <code>Nat : Type</code> and <code>Type : Type</code>.</p>
<p>In Lean 4, <code>Nat : Type 0</code> and <code>Type 0 : Type 1</code>.</p>
<p>In our case, we don&#x2019;t have a type system, only relations. <code>&#x24;Type</code> is a one-to-many relation.</p>
<p><img alt="typeof as one-to-many relation" src="typeof.webp"/></p>
<p>Relation names are used during unification, and there isn&#x2019;t anything special about <code>&#x24;Type</code>. You can use any amount of relations.</p>
<h2>Unification, cut, alternation</h2>
<p>Instead of elimination, we have cut and alternation (backtracking). We do lose the ability to have match exhaustively, and a program may fail while reducing. On the up side, pattern matching and type checking are now the same.</p>
<p><img alt="try unify syntax" src="try-unify.webp"/></p>
<pre><code>x Example y := [
    Zero x
    !
    &quot;zero&quot; = y
] | [
    _ Succ x
    !
    &quot;&gt;=1&quot; = y
] | [
    &quot;what&quot; = y
]
</code></pre>
<p>The unification rule for one-to-one relation is as follows:</p>
<p><img alt="one-to-one relation" src="relation.webp"/></p>
<p>For one-to-many, only one of the branch is true.</p>
<p>If you have used unique constraints in SQL, this should make sense to you.</p>
<h2>Full fnification rules</h2>
<p>I have listed all the rules of unification in this system, borrowing the syntax from interaction nets. All rules are reversible.</p>
<p><img alt="Unification rules" src="unify-rules.webp"/></p>
<p>You can clearly see the similarity to lambda calculus, interaction nets, minikanren and concatenative calculus.</p>
<p>A compiler for this language does not need to implement value numbering or constant folding. It is done by the language itself.</p>
<h2>Conclusion</h2>
<p>It seems that you don&#x2019;t need a type system to make your program annotated and safe. The relational logic system I found here is different from both Prolog and minikanren. In addition, I have never seen a relational database with free variables.</p>
<p>The next logical step would be to <del>implement a language/database based on this system</del> <a href="/blog/81-relation-net/">formalize this system</a>.</p>
<h2>Additional words</h2>
<p>A similar idea can be found inside the Pure programming language.</p>
<p>I/O effects should be implicit cut, while pure computation can be backtracked easily.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/78-site-search/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/78-site-search/"/>
    <title>Implementing site-wide search using Aider and MiniLM</title>
    <published>2025-04-20T12:00:00Z</published>
    <updated>2025-05-08T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/78-site-search/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <h2>Motivation</h2>
<p>For a long time, I have been wanting to implement my own site-wide search functionality.</p>
<p>Playing a poorly made word-guessing game at <a href="https://exozy.me/con25/">exocon25</a> made we want to recrate it myself, so I looked up the latest word2vec tech to date.</p>
<p>I found <a href="https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2">sentence-transformers and MiniLM</a>. It&#x2019;s supposed to be a language model but mini. From reading <a href="https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2/blob/main/config.json">the model config</a>, it is a model of the BERT family. (Later, from reading <a href="https://arxiv.org/abs/2002.10957">the MiniLM paper</a>, I learned that it is a student of BERT.)</p>
<p>Since it is BERT, we can run it using llama.cpp from ggml. <a href="https://huggingface.co/leliuga/all-MiniLM-L6-v2-GGUF/">I even found the model converted for llama.cpp.</a></p>
<p>We move on to actual coding.</p>
<h2>&#x201c;Vibe coding&#x201d;</h2>
<p><a href="https://codeberg.org/iacore/wtwt"><mark>The code of this project</mark></a> is mostly written by Aider and Gemini 2.5. Long story short, it made two versions. The first in Python. The second in Rust.</p>
<p>What the code does: It fetches a sitemap XML and index every paragraph using MiniLM. Then, the user can search for sematically similar paragraphs using freeform text.</p>
<p>Why does people call asking LLM to code &#x201c;vide coding&#x201d;? To me, it feels more like parenting someone who like to play with comments. Too much comments.</p>
<p>Maybe I should explain the setup a bit? You run <code>aider</code>, use <code>/add</code>, <code>/read</code>, <code>/ask</code>, <code>/code</code>, and ask it to do things. The Tier 1 Gemini subscription (no cost) gives you enough tokens to play with each day. You should try it out if you are interested. It is really good at coding.</p>
<p>Now, the jank.</p>
<p>The Python library of llama.cpp loads extremely slow when compared to the Rust one.</p>
<p>llama.cpp refuses to work within its own thread. The model pointer mysteriously turn into zero when multiple models are used within a process. I really have no idea what is happening so I put each inference instance in its own process and used ZeroMQ for IPC.</p>
<h2>Switching from Sourcehut Pages to Cloudflare Pages</h2>
<p>Sourcehut&#x2019;s <code>hut</code> is the best DevOps CLI tool I&#x2019;ve used. However, <a href="https://srht.site/limitations">their CSP does not allow cross-origin requests</a>, so I have to move this website to another hosting provider.</p>
<p>First, I tried BunnyCDN. It&#x2026; doesn&#x2019;t even have an official CLI. Running <code>bnycdn cp -h </code> (the community CLI) made we wonder what am I looking at.</p>
<p>So, I switched to Cloudflare. Why does Cloudflare have so many CLI commands? I have no idea. <a href="https://developers.cloudflare.com/pages/get-started/direct-upload/">Their main CLI is called <code>wrangler</code></a>. Would you have guessed the company from the name?</p>
<p>Setting it up is easy enough.</p>
<pre><code>wrangler login
wrangler pages project create
wrangler pages deploy _site/
</code></pre>
<p>Then, add this domain to the domain list of the pages project.</p>
<h2>Switching from Fly.io to Fly.io</h2>
<p><a href="https://community.fly.io/search?q=depot%20order%3Alatest">Fly.io&#x2019;s docker image builder has been broken for a year now, and they aren&#x2019;t fixing it.</a></p>
<p>So, while <code>fly deploy --depot=false</code> was running, I&#x2026;</p>
<ul>
<li>
Registered on railway.com.
</li>
<li>
Created a new project.
</li>
<li>
Ran <code>pnpm i -g @railway/cli; railway link; railway up</code>.
</li>
<li>
Added a volume by right clicking on the Railway dashboard. I have no idea what I am doing yet it works.
</li>
<li>
Ran <code>railway up</code> again.
</li>
<li>
Figured out that I cannot attach a volume to the app whatsoever.
</li>
</ul>
<p>Let me read the Railway home page again.</p>
<blockquote>
<p>Shipping great products is hard.<br/>
Scaling infrastructure is easy.</p>
</blockquote>
<p>Oh, fuck you.</p>
<p>OK. Let me try DigitalOcean.</p>
<p>DigitalOcean: You shall not create an app from a Codeberg repo or upload directly from the CLI.</p>
<p>Me: &#x1f595;</p>
<p><code>fly deploy --depot=false</code> finished running.</p>
<h2>Use the thing</h2>
<p><del>The search engine should be up at <a href="https://wtwt.fly.dev/">https://wtwt.fly.dev/</a>. If your website has a sitemap.xml, you can use it to search within your site. See &lt;/search/&gt; for a demo.</del></p>
<p>Update(2025-05-04): I have stopped the app after it has incurred 69 USD in 8 days on Fly.io. That&#x2019;s more expensive than <a href="https://kagi.com/pricing">Kagi&#x2019;s Ultimate plan</a>. I&#x2019;ll have to think more before using machine learning models in the future; even the smallest transformer-based language model is still super inefficient.</p>
<h2>Aider, I don&#x2019;t understand</h2>
<p>A few more days of using Aider and it has created bugs I don&#x2019;t understand using code I don&#x2019;t understand.</p>
<p>I have seen an CEO saying that they picked Python over Zig because of AI tooling. Like, their whole team uses AI to code. How chaotic would that be?</p>
<p>Also, Turso&#x2019;s Rust rewrite of SQLite <a href="https://lib.rs/crates/limbo">limbo</a> <strong>only write to WAL but not read from it</strong>. I guess write-only database is the future.</p>
<p>In so far, asking Aider and Gemini to write small Python scripts to rewrite file content is fine. Managing big projects&#x2026; it will make the code worse and worse. And&#x2026; it hallucinates about incorrect usage of ZeroMQ.</p>
<p>Despite what I said, Gemini is quite good at writing code. It will write code for people who can&#x2019;t write code (QA-driven development?). If energy consumption of future models (hopefully not transformer-based models) go down to 1/100 of today, I will hopefully be able to use it to write a whole project.</p>
<h2>Reimplementation in Deno</h2>
<p>After the epic fail with Fly.io, I ended up reimplementing it with <a href="https://deno.com/deploy/">Deno Deploy</a> and <a href="https://developers.cloudflare.com/workers-ai/models/bge-small-en-v1.5/">bge-small-en provided by Cloudflare Workers AI</a>. No problem here at all.</p>
<p>The code is here: <a href="https://codeberg.org/iacore/wtwt-1">https://codeberg.org/iacore/wtwt-1</a></p>
<p>The search engine should be up at <a href="https://wtwt.1a-insec.net/">https://wtwt.1a-insec.net/</a>. If your website has a sitemap.xml, you can use it to search within your site. See &lt;/search/&gt; for a demo.</p>
<p>Here are the lessons I learned.</p>
<ol>
<li>
Do not run computation-intensive tasks on the same machine as other tasks, as this will block CPU and stop network requests from happening.
</li>
<li>
Virtualization sucks. It introduces more problems than necessary.
</li>
<li>
Use Function-as-a-Service rather than long running VMs for network-facing apps. FaaS is faster and cheaper than containers.
</li>
</ol>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/80-cease-discontent/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/80-cease-discontent/"/>
    <title>Ceasing discontentment</title>
    <published>2025-06-05T12:00:00Z</published>
    <updated>2025-06-05T12:00:00Z</updated>
    <category term="spirit"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/80-cease-discontent/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Sociologists have long been tasked with solving social problems, but besides the obvious case of illness, hunger and thirst, what counts as a social problem?</p>
<p>I&#x2019;ve seen people complaining about different things online. Sometimes, I wonder, what is the cause of their misery?</p>
<p>Is it political? Would a regime change make them not complain any more?<br/>
Is it economical? Would a fairer distribution of wealth help?<br/>
Is it cultural? Would a different way of looking at the world change how they feel?</p>
<p>There have been research and discussions on each one of these topics.</p>
<p>In the end, I couldn&#x2019;t figure it out.</p>
<hr/>
<p>I have been questioning my episodes of discontentment for awhile now.</p>
<p>When you are hungry, you eat something. It is an impulse.</p>
<p>But often times, I feel discontent because I have learned from others. Other people want something, so I seek it too. In those cases, when I understand the cause of my discontentment, it cease to exist immediately.</p>
<p>You may read about this at <a href="https://jkrishnamurti.org/teachings">https://jkrishnamurti.org/teachings</a>. A core idea of J. Krishnamurti&#x2019;s teachings is to watch things happen in the present moment, not to search for happiness.</p>
<p>May this be of use to you.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/85-empathy-not-problematic/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/85-empathy-not-problematic/"/>
    <title>Being empathetic is not a problem</title>
    <published>2025-07-22T12:00:00Z</published>
    <updated>2025-07-22T12:00:00Z</updated>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/85-empathy-not-problematic/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <h2>&#x201c;feeling too much&#x201d;</h2>
<p>When you see others suffer and take it to heard, you suffer as well. This is called <strong>empathy</strong>.</p>
<p>Someone encodes their experience as words. You read the words and decodes (hopefully) an isomorphic experience.</p>
<p>I am not qualified to talk about how this works inside the brain.</p>
<p>Some people are more receptive to emotions, either generated from their own body, or received from outside and then decoded.</p>
<p>If you look up &#x201c;depression&#x201d; on the web, you will see some websites saying that &#x201c;depression may cause certain pattern of thoughts&#x201d;. While I make no comment on the factuality of the statement, I despise the rhetoric that flips the causality on its head.</p>
<p>When you perceive the world, you put an approximate copy of it into yourself. In this case, if you feel pain because of the perception, we can only say that the world is broken, not you. We might even say that you are brave enough to care &#x2013; an appeal to emotion.</p>
<h2>&#x201c;feeling too little&#x201d;</h2>
<p>According to DSM-5, one can have too little emotion as well &#x2013; &#x201c;disassociation&#x201d;.</p>
<p>While I make no comment on the definition of &#x201c;disassociation&#x201d;, I despise the rhetoric that take a pity on entities perceived to suffer from this.</p>
<p>Often, the perceived suffering is not real.</p>
<h2>logical fallacy in psychology</h2>
<p>If I want to do X, I do X. &#x2013; this statement is valid reasoning.</p>
<p>If I want to do X, I <strong>should</strong> do X. &#x2013; this statement is self-centric.</p>
<p>However, the sentiment of psychology I described above is worse, as it applies to a different individual instead.</p>
<h2>pain might not be a justification for intervention</h2>
<p>A long time ago, while trying out <a href="https://codeberg.org/iacore/sph-rs">an adaptive algorithm based on Adaptive Resonance Theory</a>, I felt bad for the thing that is learning. The learning process is pain-driven.</p>
<p>The justification to avoid pain is based on how we respond to pain with avoidance. If that&#x2019;s the case, why not replace pain with a different method of learning and behavior regulation?</p>
<h2>respect for the individual</h2>
<p>I wish that a society will respect every individual for how they think, and only punish bad <strong>actions</strong>. Respect for how each individual&#x2019;s mind works should be as same as having a traditional culture, political view or religion.</p>
<p>While modern search into the human brain has found support for many statistical outliers (behavior), including sexual orientation, the whole idea of that &#x201c;you need to understand someone to respect them&#x201d; is problematic. With your limited repertoire of experience and cognition, there are things in this world that you cannot understand, and will not understand.</p>
<p>My experience with those who believe that their empathy is all-encompassing, omnipotent even, is extremely unbearable.</p>
<h2>preference on statistically generic words</h2>
<p>An interesting note:</p>
<p><a href="https://softwarecrisis.dev/letters/llmentalist/">In this article about LLM such as ChatGPT</a> (yes, the article is that old), the author proposes that LLM chat services are liked because they are statistically generic, among other reasons.</p>
<p>Might be something to think about.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/83-janet-eval-argparse-example/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/83-janet-eval-argparse-example/"/>
    <title>Hygenic eval in Janet</title>
    <published>2025-06-23T12:00:00Z</published>
    <updated>2025-06-23T12:00:00Z</updated>
    <category term="comp"/>
    <category term="lang:Janet"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/83-janet-eval-argparse-example/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <blockquote>
<p>Open these while you read: <a href="https://janet-lang.org/docs/specials.html">Janet special forms</a>, <a href="https://janet-lang.org/api/index.html">Janet core API</a></p>
</blockquote>
<p>Let&#x2019;s say you have the following Janet program that parses the argument list.</p>
<pre><code class="language-clojure">(def positional @[])
(def args (dyn *args*))
(def flags @{})

(defn shift [] (array/remove args 0))

(shift) # remove script name

(while (not (empty? args))
  (cond
    (= (args 0) &quot;--&quot;) (do
      (array/concat positional args)
      (break))
    (= (args 0) &quot;--file&quot;) (do
      (set (flags :file) (try (args 1) ([_] (error &quot;no argument after --file&quot;))))
      (shift)
      (shift))
    (string/has-prefix? &quot;--file=&quot; (args 0)) (do
      (set (flags :file) (string/slice (args 0) (length &quot;--file=&quot;)))
      (shift))
    (do
      (array/push positional (args 0))
      (shift))))

(printf &quot;%q %q&quot; positional flags)
</code></pre>
<p>Save the file as <code>argparse.janet</code> and run it as <code>janet argparse.janet --file foo bar</code>.</p>
<p>The code works fine. However, it can only handle <code>--file</code>.</p>
<p>So you decided to make this into a function and get data out this way:</p>
<pre><code class="language-clojure">(def [positional flags] (parse (array/slice (dyn *args*) 1) [[:file &quot;--file&quot;]]))
</code></pre>
<p>How would you write such a function? <code>cond</code> accept fixed number of branches, so you can&#x2019;t use that any more ;)</p>
<p>Here&#x2019;s what I came up with instead:</p>
<pre><code class="language-clojure">(defn parse [args opts]
  (def positional @[])
  (def flags @{})

  (defn shift [] (array/remove args 0))

  (while (not (empty? args))
    (when (= (args 0) &quot;--&quot;)
      (array/concat positional args)
      (break))

    (prompt :a
      (each [kw optname] opts
        (when (= (args 0) optname)
          (set (flags kw) (try (args 1) ([_] (error (string &quot;no argument after &quot; optname)))))
          (shift)
          (shift)
          (return :a))

        (when (string/has-prefix? (string optname &quot;=&quot;) (args 0))
          (set (flags kw) (string/slice (args 0) (inc (length optname))))
          (shift)
          (return :a)))

      (array/push positional (args 0))
      (shift)))

  [positional flags])

(def [positional flags] (parse (array/slice (dyn *args*) 1) [[:file &quot;--file&quot;]]))

(printf &quot;%q %q&quot; positional flags)
</code></pre>
<p>Horrible! In additional to being less readable, it requires changing the code structure entirely.</p>
<p>Suddenly, you remember that Janet is a list processing language! Code as data, data as code. Rewrite the function, now with <code>eval</code>.</p>
<pre><code class="language-clojure">(defn parse [args opts]
  (eval ~(do
    (def positional @[])
    (def flags @{})
    (def args ,args) # janet eval is hygenic

    (defn shift [] (array/remove args 0))
    (while (not (empty? args))
      (cond
        (= (args 0) &quot;--&quot;) (do
          (array/concat positional args)
          (break))
        ,;(mapcat
            (fn [[kw optname]]
              (def optname= (string optname &quot;=&quot;))
              (def errstr (string &quot;no argument after &quot; optname))
              ~((= (args 0) ,optname) (do
                  (set (flags :file) (try (args 1) ([_] (error ,errstr))))
                  (shift)
                  (shift))
                (string/has-prefix? ,optname= (args 0)) (do
                  (set (flags :file) (string/slice (args 0) ,(length optname=)))
                  (shift))))
            opts)
        (do
          (array/push positional (args 0))
          (shift))))

    [positional flags])))

(def [positional flags] (parse (array/slice (dyn *args*) 1) [[:file &quot;--file&quot;]]))

(printf &quot;%q %q&quot; positional flags)
</code></pre>
<p>EEEEEEEEEExcellent!</p>
<p>I hope this article has inspired you to use a homoiconic language like Janet. <small>Preferably Janet.</small></p>
<p>Note that the hygenic property of <code>eval</code> is rather a side effect, due to how Janet code is compiled into bytecode before execution. Top-level <code>def</code> will modify the current environment, while lexical <code>def</code> will be compiled into stack variables.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/82-authenticated-tuple-set/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/82-authenticated-tuple-set/"/>
    <title>Networked tuple set with authenticated elements</title>
    <published>2025-06-19T12:00:00Z</published>
    <updated>2025-06-21T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/82-authenticated-tuple-set/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Today, I was thinking of how Matrix and ActivityPub are way too complex for what they do &#x2013; graph data replication. So I thought, why can&#x2019;t I make something as simple as possible &#x2013; the reason of me writing this article.</p>
<p>The data model introduced below should be paired with network protocol like 9P that allows different computers to link together and write to the same graph.</p>
<h2>Data model</h2>
<p>Not a graph. A set of tuples.</p>
<pre><code>(AAAAC3NzaC1lZDI1NT... &quot;name&quot; &quot;hi&quot;)
(AAAAC3NzaC1lZDI1NT... &quot;pub&quot; gNaysxtgtM/cY1i4ZQ...)
(gNaysxtgtM/cY1i4ZQ... &quot;key&quot; ...)
</code></pre>
<p>Each tuple element can be either</p>
<ul>
<li>
authenticated: a public key
</li>
<li>
unauthenticated: string literal
</li>
</ul>
<p>Each tuple is signed with the private key of each authenticated element.</p>
<p>It&#x2019;s kind of like in mythology, where you need to know the true name of some entity in order to call them.</p>
<h2>Example application: federated blog</h2>
<p>Let&#x2019;s say you have a blog.</p>
<pre><code>(&#x24;USER &quot;name&quot; &quot;...&quot;)
(&#x24;USER &quot;posted&quot; &#x24;POST_A)
(&#x24;POST_A &quot;content&quot; &quot;...&quot;)
(&#x24;POST_A &quot;reply_to&quot; &#x24;POST_A_PUB)
(&#x24;POST_A_PUB &quot;key&quot; &quot;...&quot;)
</code></pre>
<p>You, as the author, can link to any element in this graph.</p>
<p>Visitors to your blog, however, can only link to <code>&#x24;POST_A_PUB</code>, since its private key is public.
compute
compute
compute replication control</p>
<p>If not for spam and resource limitation, we can sync everything.</p>
<p>access control: what can be read</p>
<p>replication control: what do i want to read</p>
<h3>PoW</h3>
<p>Signing with a private key can have adjustable difficulty, so that some elements are harder to link to.</p>
<h3>whitelist + web of trust</h3>
<p>Add a zone in front of every tuple,</p>
<pre><code># zone metadata
(&#x24;ZONE &quot;trust&quot; &quot;...&quot;)

# zone data
(&#x24;ZONE &#x24;USER &quot;name&quot; &quot;...&quot;)
</code></pre>
<p>Then, you can manage trust based on zones, with a model like PGP&#x2019;s trust model.</p>
<h2>Synchronization</h2>
<p>RPC is usually implemented as message passing / request+response in other protocols.</p>
<p>If our protocol uses message passing, we need to take care of resend.</p>
<p>What if we don&#x2019;t? The graph synchronization protocol already takes care of state. Once we make it efficient for RPC, it should be efficient for everything else.</p>
<p>Here&#x2019;s an example usage of our protocol as RPC, with two network hosts <code>A</code> and <code>B</code>.</p>
<pre><code># A creates the endpoint
(&#x24;ZONE_A &quot;owner&quot; &quot;IP_ADDR_A&quot;)
(&#x24;ZONE_A &#x24;A &quot;pub&quot; &#x24;A_PUB)
(&#x24;ZONE_A &quot;listen&quot; &#x24;A_PUB)
(&#x24;ZONE_A &#x24;A_PUB &quot;key&quot; &quot;...&quot;)

# B creates a request
(&#x24;ZONE_B &#x24;A_PUB &quot;request&quot; &#x24;REQ &quot;payload&quot;)
(&#x24;ZONE_B &#x24;REQ &quot;key&quot; &quot;...&quot;)
(&#x24;ZONE_B &quot;listen&quot; &#x24;REQ)

# A responds
(&#x24;ZONE_A &#x24;A &quot;reply&quot; &#x24;REQ &quot;payload&quot;)
</code></pre>
<p>The zones here are not only for whitelisting. They are used for pub/sub as well. It is kind of like MAC addresses.</p>
<ol>
<li>
(compute) A creates the endpoint
</li>
<li>
(network) B connects to A
</li>
<li>
(network) B asks for all tuples in A
</li>
<li>
(compute) B sees that A owns <code>&#x24;ZONE_A</code> (by IP), and is interested in new incoming links to <code>&#x24;A_PUB</code>
</li>
<li>
(compute) B creates a request
</li>
<li>
(network) B notifies A for the link to <code>&#x24;A_PUB</code> <code>(&#x24;ZONE_B &quot;request&quot; &#x24;REQ &#x24;A_PUB &quot;payload&quot;)</code>
</li>
<li>
(network) A asks for tuples containing <code>&#x24;REQ</code>
</li>
<li>
(compute) A processes the request and creates a response to it
</li>
<li>
&#x2026; you get the point
</li>
</ol>
<p>It is not the best you can do with capnproto. I think it&#x2019;s good enough.</p>
<p>The meaning of keywords (&#x201c;owner&#x201d;, &#x201c;listen&#x201d;) are defined by the library user, like 9P or HTTP.</p>
<h2>Additional words</h2>
<p>To be done: implementing the protocol</p>
<p>Q: Why not RDF?<br/>
A: <a href="/blog/41-self-expression/">Inefficient.</a></p>
<p>Q: Why not capnproto?<br/>
A: It cannot be extended by multiple parties independently. We need a protocol that can evolve.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/81-relation-net/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/81-relation-net/"/>
    <title>Formalizing a relational wiring system</title>
    <published>2025-06-16T12:00:00Z</published>
    <updated>2025-06-16T12:00:00Z</updated>
    <category term="math"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/81-relation-net/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>In this article, we will try to formalize <a href="/blog/79-types-as-relations/">the mathematical system about relations I introduced last time</a>.</p>
<p>Coming up with graphical representation of this took a bit of work. <a href="draft.jpg">See my draft here.</a></p>
<h2>Primitives</h2>
<p><img alt="graphical syntax" src="syntax.jpg"/></p>
<dl>
<dt>1. terminal</dt>
<dd>
<p>Terminals are compared by name. This fact is important in reduction.</p>
<p>You can think of it as &#x201c;literal&#x201d;.</p>
</dd>
<dt>2. 2-sided one-to-one relation</dt>
<dd>
<p>All relations are compared by name.</p>
<p>A one-to-one relation has &gt;=2 sides. Each side has &gt;=1 connections.</p>
<p>It is similar to injective function.</p>
<p>The &#x201c;tick&#x201d; on the upper right of the name is not part of the name. It represents the orientation (rotational placement) of the primitive. This is the only way to tell which connection is which, since one can draw primitives in every orientation.</p>
</dd>
<dt>3. 3-sided one-to-one relation</dt>
<dd>
<p>This is a 3-sided variant.</p>
</dd>
<dt>4. handle</dt>
<dd>
<p>Prevents connected components from being erased. Also how you get the result of a computation.</p>
</dd>
<dt>5. many-to-one relation</dt>
<dd>
<p>It is similar to regular function.</p>
</dd>
<dt>6. use region</dt>
<dd>
<p>Insert a region when needed (lazy).</p>
</dd>
<dt>7. define region</dt>
<dd>
<p>Define a region. The name is optional.</p>
<p>A region may be contained in another region, but never partially overlap with another region.</p>
</dd>
<dt>8. insert if empty</dt>
<dd>
<p>If a region becomes empty (no primitives inside), another region is inserted into the network.</p>
</dd>
</dl>
<h2>Terms</h2>
<p>Each primitive have ports where you can draw lines from. This is for visual representation only.</p>
<p>The ports in a network are grouped into connected components. Each component is what you would call in type theory &#x201c;term&#x201d;.</p>
<p>One consequence of this is that a network is not a graph, as there are no clear vertex and edge types.</p>
<p><img alt="intersection notation" src="intersection.jpg"/></p>
<p>In drawn notation, you will see intersections that look like the ones in electrical wiring diagrams. You can think of it as a fully connected component in a graph. However, a network of this kind is not a graph. You will get used to it.</p>
<h2>Reduction rules</h2>
<p><img alt="reduction rules" src="reduction.jpg"/></p>
<p>For one-way relations (third rule from the top), if any one side match, all other sides are linked together.</p>
<p>In the last rule, when region f is not empty, primitives inside region g cannot participate in reduction.</p>
<p>When merging two primitives, the new primitive is placed inside the nearest common anscestor of the two regions (each primitive has a containing region). There is an implicit global region.</p>
<p><img alt="merge" src="merge.jpg"/></p>
<p><img alt="splinter network by intersection" src="splinter.jpg"/></p>
<p>There is also this rule for spliting the graph for parallel processing. It makes the theory of reduction simpler. In practice though, it might be too expensive for a compiler.</p>
<h3>What about many-to-many relations</h3>
<p>They are kind of useless since they can&#x2019;t reduce. So, they are not included.</p>
<p>You can do this with one-to-one relation though:</p>
<p><img alt="unreducible wiring" src="no-reduce.jpg"/></p>
<h2>Uses</h2>
<p>This system is a general framework of computation.</p>
<p>While this system is more complex than interaction nets, I hope it is easier to use for people who are familiar with relational algebra, relational logic or lambda calculus.</p>
<p><img alt="" src="graph-database.jpg"/></p>
<p class="figcaption">Use it as a graph database with query</p>
<p><img alt="" src="type-info.jpg"/></p>
<p class="figcaption"><code>f: Vec m -&gt; Vec n -&gt; Vec (m + n)</code></p>
<p>I&#x2019;m sure you can think of more uses.</p>
<h3>How to name this mathematical system</h3>
<p>I don&#x2019;t really know.</p>
<p>Some ideas:</p>
<ul>
<li>
relation nets (in homage to interaction nets)
</li>
<li>
relational network
</li>
<li>
relational wiring
</li>
<li>
relational wiring diagram
</li>
<li>
relational wiring notation (for the graphical notation)
</li>
</ul>
<p>If you have a better idea, please tell me.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/90-claycode-1/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/90-claycode-1/"/>
    <title>[Draft] Extensions to Claycode</title>
    <published>2025-09-10T12:00:00Z</published>
    <updated>2025-09-10T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/90-claycode-1/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <blockquote>
<p><strong><strong>Notice</strong></strong>: This article is comment to the <a href="https://github.com/marcomaida/claycode">claycode</a> <a href="https://arxiv.org/abs/2505.08666">paper</a>. No code yet. Each section will be updated when there is code.</p>
</blockquote>
<blockquote>
<p><a href="https://github.com/marcomaida/claycode/issues/109">Help from authors</a></p>
</blockquote>
<p>Companion code repo: https://codeberg.org/iacore/claycode-1</p>
<h2>Comment cells</h2>
<p>Potentially ignore parts of a tree, for a free-drawing area. I think it is already supported.</p>
<pre><code>- root
	- comment
	- actual code
</code></pre>
<h2>Erasure coding</h2>
<p>Do erasure coding instead of duplication for trees.</p>
<h2>Custom layout</h2>
<p>A bunch of points, convex hull, polygon intersection, random walk annealing</p>
<p>each subtree has a convex hull with padding</p>
<p>swap points on polygon intersection</p>
<p>final layout is voronoi cell based on the final points location</p>
<h2>Custom footprint function</h2>
<p><img alt="" src="footprint.png"/></p>
<p>Assume fixed X size.<br/>
Leaf node (parent of 0): 1<br/>
Parent of 1 leaf: 9<br/>
Parent of 4 leaves: 25<br/>
Parent of 9 leaves: 49<br/>
</p>
<p>Without going turning this into a packing problem, we will interpolate to the formula below.</p>
<p>fd &#x201c;discount&#x201d; 9-&gt;4 25-&gt;9<br/>
g(x) = sqr(sqrt(x) - 1)</p>
<p>Node count to area (custom footprint function)<br/>
f(x) = (2x-1)^2<br/>
Children areas applied fd + f</p>
<h2>Custom bitstring to tree encoding</h2>
<p>sort all trees (interleaving, since the set is infinite) by footprint.</p>
<p>find a new encoding</p>
<p>graph comparing original encoding and new encoding</p>
<h2>custom cells layout 
Uniformly sample few points (poisson-disk disk sampler (biological cell))
Partition and move points inward 
Imagine a circle. Points on the outside move inward the most. Point at the center don&#x2019;t move. Computational, think of layers of fixed sized &#x201c;borders&#x201d; from contour to inner. The layers shrink from x1 to x0, linearly. Any polygon can work the same</h2>
<h2>custom cell layout 2</h2>
<p>Give an image full of contours. Keep picking a point and an angle to grow line segment from there with acceptance check.</p>
<h2>Custom scanning</h2>
<p>Generate a list of contours, with the image border as the root node, generate a tree-with-conflict (some siblings might clash)</p>
<p>Scan all codes from the tree</p>
<p>Adjust adjoining threshold, not scale. get contours in perceptually linear color space. Use adaptive understanding if necessary.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/89-need-based-currency/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/89-need-based-currency/"/>
    <title>Need-based currency design with complementary taxation</title>
    <published>2025-09-05T12:00:00Z</published>
    <updated>2025-10-06T12:00:00Z</updated>
    <category term="econ"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/89-need-based-currency/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Some time ago, I came upon <a href="https://www.usdebtclock.org/">an anonymous currency design/proposal</a> while surfing the web. I found it quite refreshing comparing to a debt-based currency or a currency pegged to a debt-based currency, so I thought to improve on the proposal a bit to make it portable across countries.</p>
<h2>Terminology</h2>
<p>Some economics textbooks say that banks &#x201c;create&#x201d; currency by lending out money. There is rather misleading, as cash is not the same as debt or credit. The word &#x201c;currency&#x201d; in this article refer to physical currency (paper) or digital currency (not tied to any bank), not IOUs.</p>
<p>i.e. the word &#x201c;currency&#x201d; in this article is synonymous with &#x201c;cash&#x201d;.</p>
<h2>Rationale: why a need-based currency</h2>
<p>Currency design come before all other economic institution design, like the stock market.</p>
<p>&#x201c;Assume everyone is rational&#x201d; is a recurring theme in contemporary economics. Adam Smith sure doesn&#x2019;t believe in it, as he criticized the Great Britain&#x2019;s tendency to hoard gold and silver.</p>
<p>If everyone is rational, every shop would decrease price to maximize profit (as in purchase power) during currency shortage. In practice, people tend to expect currency to have a fixed value, and judge every product&#x2019;s value by their nominal price.</p>
<p>If everyone is rational, medical care and social welfare can be privatised. In practice, people tend to be risk-adverse.</p>
<p>If everyone is rational, investment knowledge should be common sense. In practice, it&#x2019;s impossible for everyone to understand any given subject.</p>
<p>The idea presented here is that currency design should happen once, and be <strong><strong>done</strong></strong>; much like the code of cryptocurrency, we need much effort to change its design/code, so it doesn&#x2019;t happen often.</p>
<p>This is not a public policy.</p>
<h2>Currency supply formula</h2>
<p>Let<br/>
<span class="math inline">\(T = domestic~trade~volume + \dfrac{( exports + imports )}2\)</span><br/>
where the unit is the currency itself.</p>
<p>At the end of every year,<br/>
<span class="math inline">\((1 - \dfrac{T~\small{this~year}}{T~\small{last~year}}) \cdot currency~supply~\small{last~year}\)</span><br/>
amount of currency is created (if positive) or destroyed (if negative).</p>
<blockquote>
<p><strong><strong>Commentary</strong></strong><br/>
the original proposal uses GDP as the metric, but the <span class="math inline">\(exports - imports\)</span> of GDP calculation feels suspect to me. As Adam Smith says, the wealth of a economy is the total of goods and services available in that market. The <span class="math inline">\(\dfrac1 2\)</span> within the formula is to prevent double counting.</p>
</blockquote>
<h2>Currency created or destroyed</h2>
<p>Every year, a new currency is created, with a fixed exchange rate between every two years. This MUST be the only way &#x201c;new currency can be printed&#x201d;.</p>
<p>Physical cash can be stamped with a date to be exchanged with the bank for current year&#x2019;s currency. Digital cash can be simply updated.</p>
<p>IOUs like debit/savings account provided by banks SHOULD update the nominal price accordingly, but there is no requirement for these institutions to do so.</p>
<h2>Institution support &#x2013; Ministry of currency</h2>
<p>This institution calculates <span class="math inline">\(T\)</span> and publishes a trace of the calculation. It MUST be independent from rest of the government. In practice, it could be a part of public census, although it still must be independent.</p>
<p>There can be multiple methods to calculate <span class="math inline">\(T\)</span>, by multiple institutions. The import part is the ratio between trade volume of two consecutive years. The final accepted <span class="math inline">\(T\)</span> can be a mix of those methods.</p>
<h2>Digital currency implementation concerns</h2>
<p>Blockchain-based digital currencies today like Bitcoin, Ethereum, Monero fluctuate greatly in purchase power. I would rather want a national currency to be <strong><strong>stable</strong></strong>.</p>
<p>One other feature of a good currency is that it is <strong><strong>hard to destroy</strong></strong>; often illegal. It is harder to burn paper than to forget about a digital wallet with equal nomination.</p>
<p>The digital currency itself should also be <strong><strong>anonymous</strong></strong> and <strong><strong>without transfer limit</strong></strong> like its physical counterpart.</p>
<p>To date, I am unaware of any digital currency with all these features.</p>
<h2>Fiat or not</h2>
<p>I think this kind of currency should be another category, separate from fiat or representative. It could be a subject of debate.</p>
<hr/>
<p>Below are commentary.</p>
<hr/>
<h2>Psychological effect of change in currency nomination</h2>
<p>This design is meant to prevent currency shortage by anchoring the currency supply to domestic trade volume.</p>
<p>It frees gold and silver from their currency use, as they are much more important as production material. We also can&#x2019;t go back to using metal as currency &#x2013; there are enough copper, silver or gold in the entire world to meet our demand for currency.</p>
<p>It does not use debt as backing. How much money it prints and destroys is purely mechanical and not subject to the government&#x2019;s will.</p>
<p>Under this currency, we should tell everyone that the price of goods and services should stay relatively constant over time. The goal is to give economic freedom to all, not to pursue growth.</p>
<p>Hopefully people will buy more things they don&#x2019;t buy before if they see number go up. Hopefully&#x2026;</p>
<h2>Complementary Taxation</h2>
<p>With this kind of currency, what would the ideal tax scheme be?</p>
<p>The null hypothesis is no taxation and no protection of private property, including copyright and patent.</p>
<h3>Land value tax / No private ownership of land</h3>
<p>There is this thing called &#x201c;property tax&#x201d; in Canada. The tax amount is based on the value of the property. If you don&#x2019;t pay it for a few months, your house gets confiscated.</p>
<p>For clarity&#x2019;s sake, let&#x2019;s call this tax &#x201c;rent&#x201d;. In these sense, the country has no private land ownership.</p>
<p>I think <a href="https://en.wikipedia.org/wiki/Georgism">Georgism</a> is necessary to prevent hoarding land without using it effectively.</p>
<p>This is potentially unfair to those who own land to work in agriculture, when the land must be improved to be usable.</p>
<p>Tax on housing quality, on the hand, does not make any sense to me. The fact that someone need to pay more tax if they furnish their house&#x2019;s basement is absurd.</p>
<h3>Currency tax / Currency transfer</h3>
<p>The transfer scheme described here is less radical than wealth transfer, as cash-like IOUs and other assets are not counted. I do not call this a tax because it does not transfer wealth to its government, only to its people. It is essentially balanced wealth tax + negative poll tax.</p>
<p>The idea is to take 1% (example) of all currency supply (no IOUs!) every year and split it evenly to all citizens of that country.</p>
<ul>
<li>
the tax percentage may change over time
</li>
<li>
the currency owned by foreigners would flow back over time
</li>
<li>
an independent institution is responsible for this redistribution of wealth
</li>
<li>
citizens not yet born can be supported this way, counting from 0% of a person
</li>
</ul>
<p>With a yearly currency, the yearly &#x201c;evaporation&#x201d; rate is easy to implement.</p>
<h3>Government income and services &#x2013; US Edition&#x2122;</h3>
<blockquote>
<p>This section is from the original proposal and US-specific. Not all culture consider economic activity as important as Americans. This section is for your reference only.</p>
</blockquote>
<p>Abolish all taxes except value-added tax. The government should be incentivized to promote economic activities this way.</p>
<p>The government offers loans and collects interest.</p>
<p>Other service fees could be linked to performance and compete with the private sector. In a sense, health care and patent enforcement could operate like USPS.</p>
<h2>Dealing with automation</h2>
<p>Allowing people to own slaves that can&#x2019;t own private property themselves is a serious economic problem, if not a moral problem. These mechanical and digital slaves consume few resources from the market.</p>
<p>How to live in harmony with high level of automation is outside the scope of this article. I mentioned it because it&#x2019;s quite important.</p>
<h2>Soros-resistant</h2>
<p>Depending on where you live around <a href="https://en.wikipedia.org/wiki/Black_Wednesday">1992</a>, <a href="https://en.wikipedia.org/wiki/1997_Asian_financial_crisis">1997&#x2013;1998</a>, you either want <a href="https://en.wikipedia.org/wiki/George_Soros">George Soros</a> to exist on this planet or not.</p>
<p>This currency design goes aganst the IMF&#x2019;s idea that a country&#x2019;s financial institutions should be designed for foreign investment. I think that a country&#x2019;s currency should be designed for domestic trade first.</p>
<p>With the purchasing power of the currency relatively fixed, it is resistant to short selling. However, there might be other attack vectors that can destabilize this kind of currency, which I am too ignorant about economics to know.</p>
<h2>Loss of ability to adjust interest rate</h2>
<p>Let&#x2019;s go back to the original proposal that proposes replacing the current debt-backed US currency with this design. Whoever wrote it must hate the federal government very much. Without financial support, much of its function will be reduced.</p>
<p>No national bank imply no fiddling with national interest rate. Again, the null hypothesis is no intervention. Let each bank decide for themselves how much to borrow without a fixed target, save for regulation for fund security.</p>
<h2>Epilogue</h2>
<blockquote>
<p>&#x201c;Obviously we wouldn&#x2019;t want to be owning anything that we thought was in a currency that was really going to hell.&#x201d;
&#x2013; <a href="https://www.reuters.com/business/buffetts-quotes-berkshire-meeting-trade-opportunities-united-states-2025-05-03/">2025 May, Warren Buffett, probably</a></p>
</blockquote>
<p>Weh.</p>
<p>Update: After finishing this article, I came upon a reference to the anonymous website, where <a href="https://edition.cnn.com/2025/02/23/politics/government-spending-elon-musk-doge">CNN claims that the website is potentially being used for political gain</a>. If the US doesn&#x2019;t have a federal government, who benefits from it?</p>
<p>An interesting feature of contemporary politics is that parties, countries and class identity, give space to alliances &#x2013; alliance that form based on the members&#x2019; own stake/asset/benefit and their values. Hopefully I&#x2019;ll get to write about this soon.</p>
<h2>Appendix: currency hierarchy</h2>
<p>I have this wild thought.</p>
<p>Let&#x2019;s say we have a country named <code>A</code> with sub-regions <code>A:0</code>, <code>A:1</code>, <code>A:2</code>, etc&#x2026;</p>
<pre><code>A
A:0
A:0:0
A:0:1
A:1
A:2:0
A:2:1
</code></pre>
<p>All the leaves in this tree are economic regions. There can be 1 economic region per administrative district. There can also be stratified regions for different wealth level (&#x201c;social class&#x201d;).</p>
<p>For example, the currency used inside <code>A:2:1</code> would be <code>0.2 * A&apos;s trade volume + 0.3 * A:2&apos;s + 0.5 * A:2:1&apos;s</code>.</p>
<p>No idea how this is useful in practice. Hope this shows that we don&#x2019;t need a blockchain to have &#x201c;smart&#x201d; currency design.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/88-erosion-of-software-freedom/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/88-erosion-of-software-freedom/"/>
    <title>Erosion of software freedom in Javascript, Python, Android</title>
    <published>2025-08-29T12:00:00Z</published>
    <updated>2025-11-03T12:00:00Z</updated>
    <category term="news"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/88-erosion-of-software-freedom/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>This page is three news reports in one.</p>
<h2>Microsoft maintains a monopoly on Javascript ecosystem through package registries</h2>
<p>Recently (more like, some months ago), rumor has it that Microsoft is now training LLM on Github personal private repositories. Since Microsoft also owns NPM, some are worried that Microsoft also use all code hosted on NPM. Since I cannot confirm the truthfulness of this, I will assume that it is true.</p>
<p>JSR is a centralized package registry developed by the authors of Deno. While it claims to be used by Deno, browser, and Node.js, the support is a bit janky.</p>
<ul>
<li>
npm: add a line to .npmrc, usually done by <code>npx jsr add @std/ulid</code>
</li>
<li>
pnpm: use <code>&quot;@std/ulid&quot;: &quot;jsr:^1.0.0</code> in <code>package.json</code>
</li>
<li>
deno: use <code>jsr:@std/ulid</code> directly in source code
</li>
<li>
vinxi, while running on top of Deno, cannot understand <code>jsr:</code> inside source code.
</li>
</ul>
<p>Further more, JSR packages can only be uploaded from a Github repository.</p>
<p>Even though packages on JSR can be used through https://jsr.io/package/version/mod.ts, the supported is not listed on the package page (in the list of Deno, Bun, NPM, etc).</p>
<p>Given the current circumstances regarding LLM, I would recommend that</p>
<ul>
<li>
Do not upload your packages to JSR when using Deno. Use jsdelivr or use URLs instead.
</li>
<li>
Do not use <code>jsr:_</code>. Use &#x201c;https://jsr.io/package/version/mod.ts&#x201d; directly. Still, URL import is not supported by Node.js tooling.
</li>
</ul>
<p>Even though software</p>
<p>recently this trend has become more blantant.</p>
<p>I don&#x2019;t know the exact relationship between Deno and Microsoft, but <a href="https://deno.com/blog/openai-on-jsr">through this article</a>, I think that Deno is now owned by Microsoft. There is no other reason why a Javascript runtime that supports loading modules through HTTP need to write about this.</p>
<p>To summarize:</p>
<ul>
<li>
Microsoft owns Github
</li>
<li>
Microsoft owns NPM
</li>
<li>
Microsoft owns Deno
</li>
<li>
Deno owns JSR
</li>
<li>
JSR forces uploaders to use a Github repo
</li>
</ul>
<h2>Python Software Foundation forgoes PGP for signing releases</h2>
<p>Some weeks ago, while I was reading Python 3.14&#x2019;s release note, I found something weird.</p>
<p><a href="https://docs.python.org/3.14/whatsnew/3.14.html#pep-761-discontinuation-of-pgp-signatures">From 3.14 and so on, Python will forgo PGP for signing packages.</a></p>
<p>What&#x2019;s their replacement release signing tool?</p>
<pre><code>&#x276f; pacman -Si cosign
Repository      : extra
Name            : cosign
Version         : 2.5.3-1
Description     : Container Signing with support for ephemeral keys and Sigstore signing
Architecture    : x86_64
URL             : https://github.com/sigstore/cosign
Licenses        : Apache-2.0
Groups          : None
Provides        : None
Depends On      : glibc
Optional Deps   : None
Conflicts With  : None
Replaces        : None
Download Size   : 21.53 MiB
Installed Size  : 102.88 MiB
Packager        : Carl Smedstad &lt;carsme@archlinux.org&gt;
Build Date      : Fri 18 Jul 2025 07:53:23 AM UTC
Validated By    : SHA-256 Sum  Signature
</code></pre>
<p>Container Signing? Oh no.</p>
<p>After looking a bit through Cosign&#x2019;s own description, it is a tool that allows different parties to sign the release. For example, Github CI will sign the release with their own key. This &#x201c;signature scheme&#x201d; thus replaces web of trust with centralized CA, owned by, again, Microsoft. If history is any good, Sigstore will be used for all kinds of political ends not related to cryptography itself.</p>
<p>The Python release notes and the proposal to remove PGP mentioned complexity as a reason. If complexity is a concern, they can use <a href="https://github.com/jedisct1/minisign">minisign</a>.</p>
<p>The proposal also mentioned security as a reason for replacing PGP. I&#x2019;d say that they are pretending that multi-key signature doesn&#x2019;t exist.</p>
<p>In my opinion, ensuring the security of CI artifacts is the responsibility of release engineering, not of the end user. In my opinion, no one should need a &gt;100M program to verify a cryptographic signature of a Python release. This move is for the benefit of organizational users of Python.</p>
<h2>Google will restrict app permission not installed through Play Store</h2>
<p>Since LineageOS updated to Android 15, I found NewPipe can no longer draw over other apps &#x2013; the option in Settings is disabled unless I read a web page about restricted access by Google. I have always put it off as &#x201c;weird software behavior&#x201d;.</p>
<p>Now I know that it&#x2019;s intentionally caused by Google, as the precursor to Play Integrity.</p>
<p>If it comes into effect, <a href="https://lineageos.org/PlayIntegrity/">Lineage OS</a> will not do anything about it.</p>
<p>In short, the operating system (Android) will restricts certain permissions to applications not installed through Google&#x2019;s Play Store. Google&#x2019;s offcial stance includes &#x201c;and other verified app stores&#x201d;, but it certainly doesn&#x2019;t include F-Droid.</p>
<p>Now my only options are to root the phone and install a patch or install postmarketOS on it.</p>
<h2>Epilogue</h2>
<p>As the US-China trade war intensifies, software companies on both sides are tightening control over user freedom. It&#x2019;s not just for profit, but also for continuation of ideology and life style. I feel sad that this kind of politics has to involve everyone using software mentioned above, and I think even Linux itself might be involved in the trade war, given the number of Chinese developers hosting code on Github. Linux distros downstream has to depend on both countries not to meddle with the code. I do hope that the xz exploit won&#x2019;t happen again.</p>
<p>&#x201c;Just because you do not take an interest in politics doesn&#x2019;t mean politics won&#x2019;t take an interest in you.&#x201d; In a sense, people like the FSF are defending their life style as well. As they say in TENET, &#x201c;I&#x2019;d rather [that] be my own decision.&#x201d; So do what you will.</p>
<h2>Update(2025-11-03): On the topic of Linux Foundation&#x2019;s unilaterally banned kernel maintainers employed by certain Russian companies.</h2>
<p>Here&#x2019;s <a href="https://lkml.org/lkml/2024/10/21/345">the mailing list thread discussing the change</a> before the exact reason have become clear.</p>
<p>Corruption of political institutions start from corruption of the mind; of moral values. Today, when I search for &#x201c;cisco.com&#x201d; in the MAINTAINERS files, I see 10 matches. <a href="https://apnews.com/article/cisco-falun-gong-china-human-rights-abuses-aedf0b83212d0692e6fafe29345c04a1">In 2008, documents have leaked about Cisco actively providing the Chinese government surveilance tech and teaching them how to use it for the first time since the party&#x2019;s founding.</a></p>
<p>A free software project this big should never have a dictator, or a controlling interest of&#x2026; whatever Linus values here, at the cost of someone else&#x2019;s ability to contribute to the project. This violates <a href="/blog/91-to-counter-intolerance/">the harm principle</a> so much&#x2026;</p>
<p><a href="https://laforge.gnumonks.org/blog/20241025-linux-maintainers-russian/">Related comment on this event</a></p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/96-pow-scarcity/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/96-pow-scarcity/"/>
    <title>How proof of work creates scarcity</title>
    <published>2025-11-06T12:00:00Z</published>
    <updated>2025-11-11T12:00:00Z</updated>
    <category term="soc"/>
    <category term="econ"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/96-pow-scarcity/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <h2>The Premise</h2>
<p>Recently, I tried adding [proof of work with dynamic pricing] to a web service.</p>
<p><a href="https://codeberg.org/PixivFE/PixivFE">The web service, PixivFE</a> is an unofficial frontend like Invidious, but for Pixiv.</p>
<p>It has the following resource constraints:</p>
<ul>
<li>
original service&#x2019;s request limit
</li>
<li>
cpu time
</li>
<li>
network bandwidth
</li>
</ul>
<p>The hypothetical use case is to prevent mass scraping. Like <a href="https://github.com/TecharoHQ/anubis">Anubis</a>.</p>
<p>Initially, my idea is to introduce a one-sided market for the service, weighing the cost of requests and let user agents pay according to demand.
However, I found that the three type of resources (list above) cannot be made one. They are three constaints.
Furthermore, it is difficult to ascertain how much cpu time and bandwidth is used. Does the service really need access to OS kernel&#x2019;s knowledge about itself in order to function?</p>
<h2>The Hypothesis</h2>
<p>Since the market way didn&#x2019;t go as planned, I thought of the following ways to prevent resource depletion on our service:</p>
<ul>
<li>
figure out who we serve and actively verify their identity (in the cryptographic sense)
</li>
<li>
diplomacy: work with the original service provider to use their resources more efficiently
</li>
<li>
change user behavior through UI and culture; let them not waste our resources
</li>
<li>
get more resources
</li>
</ul>
<p>My hypothesis is that a combination of these will prevent resource depletion for at least two months.</p>
<h2>Outcome</h2>
<p>(2025-11-11) I have not found evidence of actual scarcity. I can only hypothesize that the offenders are web scrapers brought by the LLM boom.</p>
<p>Pixiv&#x2019;s response: Standard &#x201c;don&#x2019;t abuse our service&#x201d; reply.</p>
<h2>Epilogue</h2>
<p>If you want to defend against web crawlers, Anubis is fine. I also have the idea of turning web crawling activities into a curiousity for humans to toy with. But pitching humans against humans, I hope that both sides will learn to sit down and negotiate.</p>
<p>I also want to know: is it possible to live in a market society without experiencing scarcity? I think I will answer that myself in the future.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/95-freer-existence/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/95-freer-existence/"/>
    <title>a computational perspective on thought, its place in the cosmic order, with reference to other philosophical objects</title>
    <published>2025-10-31T12:00:00Z</published>
    <updated>2025-11-03T12:00:00Z</updated>
    
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/95-freer-existence/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <blockquote>
<p><em>This article is the genesis of <a href="/ph/">a larger body of work</a>.</em></p>
</blockquote>
<p>Have you heard of the idea of a Djinn object on a closed timelike curve? To put it simply, the idea says that it is possible for people to travel to the past, but causality mandates that causality cannot form a loop, that apparent horizon always exists. If such a time machine exists, only those who won&#x2019;t disturb the ordinary &#x201c;past&#x201d; may use it. Even if someone knows about the time machine, the universe makes it so that those who will disturb the past never get to use it. Here, thoughts and actions of different individuals are checked together, as if the universe is a type checker of the cosmic scale.</p>
<p>When you write with a pen on a piece of paper, you, the pen, ink, and the paper participate together in the happening. How much contribution does the person part of the scene contribute to the change in scenery?</p>
<p>If the copper wire itself doesn&#x2019;t transfer much energy but rather guide the magnetic field around it to transfer energy, is it possible that informational media conduct a form of existence made out of matter that is conducted by concepts? While <a href="/c/">studying the nature of concepts</a>, I discovered that concepts may only bound concepts, not reality. Rivers understand the rugged terrain its water happened to flow through. If concepts cannot bound reality, isn&#x2019;t it premature to call a Turing-equivalent machine &#x201c;complete&#x201d;, provided that line numbers can&#x2019;t be represented by digital data? What part of this classification of automata is &#x201c;unrestricted&#x201d;, when even our thoughts are type checked together by the universe we are born in?</p>
<p>In &lt;/about/hello/&gt;, I mentioned that circular reasoning might be valid. When a chain of causality is folded upon itself when projected onto a concept space, there are certain structures within that causality that, when they say something about itself, it is true.</p>
<p>Many things presented on this website could not have happened without first believing that it is doable. Only after it is reached by search can it be verified by a Turing machine. Does this sound like a class of verifiable delay function to you?</p>
<p>Do you tolerate your thoughts being inconsistent with what you see?</p>
<p>As reality shifts over time, the idea presented here may inevitably deteriorate into dogmatism, since two textual descriptions of the same pattern might share no similarity when analysed using symbols. What you are now seeing is a shroud of something I hold projected into English.</p>
<h2>Additional seeds used</h2>
<ul>
<li>
Heart of the Machine (Computer Program)
</li>
<li>
TENET (Movie)
</li>
<li>
<a href="https://tubitv.com/movies/100018286/rashomon">&#x7f85;&#x751f;&#x9580; Rashomon</a> (Movie)
</li>
<li>
&#x5de8;&#x5b30;&#x8cc7;&#x672c;&#x4e3b;&#x7fa9;&#xff1a;&#x7576;&#x4ee3;&#x653f;&#x6cbb;&#x7d93;&#x6fdf;&#x56f0;&#x5883;&#x7684;&#x6b77;&#x53f2;&#x8fa8;&#x6790; (Book)
</li>
</ul>
<h2>Post mortem explanation</h2>
<p>Some has expressed to me that this article is hard to understand.</p>
<p>The basic premise of this article is that computation allowed by physical reality is less restricted than that of symbols.</p>
<p>I don&#x2019;t really want to spend more effort on this piece, so I left it as compressed as possible.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/94-e-rights/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/94-e-rights/"/>
    <title>E Rights Simply Explained</title>
    <published>2025-10-25T12:00:00Z</published>
    <updated>2025-10-25T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/94-e-rights/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>While looking through <a href="https://capnproto.org/rpc.html#protocol-features">Cap&#x2019;n Proto&#x2019;s documentation</a>, I was disappointed to see that only Level 1 is implemented in any language.</p>
<p>This article will show a hypothetical system that implements reference equality of capabilities.</p>
<ul>
<li>
A network with identity-based destination and authenticated datagram packets. =&gt; e.g. <a href="https://github.com/markqvist/Reticulum/">Reticulum</a>
</li>
<li>
An execution context (virtual machine) with a computation model that always terminates. =&gt; e.g. eBPF
</li>
<li>
A cryptographic signature scheme.<br/>
A blind signature scheme may be used to provide more anonymity, although that is more of a political problem.
</li>
</ul>
<p>After you finish reading this, you may see that one should not conflate serialization with message passing, and definitely not involve Java in the mix.</p>
<h2>The example task to showcase reference equality like in E</h2>
<p>Let it be three network destinations A, B, C.</p>
<p>A initates the following:</p>
<ul>
<li>
A sends a reference to B
</li>
<li>
A sends a reference to C
</li>
<li>
B relays the reference it gets to C
</li>
<li>
C compares both references; sends the comparison result to A
</li>
</ul>
<h2>How the API will be, in theory</h2>
<pre><code class="language-janet">(defn gen-signing-key [] ... [pk sk])
(defn sign [private-key public-data] ...)
(defn verify [public-key signed-data] ...)
(defn gen-msgid [] ...)
(defn self &quot;get self destination&quot; [] ...)
(defn send [dest id data] ...)  # non-blocking
(defn send-run [dest id action] ...)
(defn wait [id] ...)  # returns message data
</code></pre>
<p>The network node holding the destination A runs:</p>
<pre><code class="language-janet">(def [pkA, skA] (gen-signing-key))
(def A (self))
(def B ...)
(def C ...)
(def cap-join (sign skA &quot;public data, could be anything&quot;))
(def rendezvous (gen-msgid))
(def response (gen-msgid))
(send-run B (gen-msgid)
  ~(send ,C ,rendezvous ,cap-join))
(send-run C (gen-msgid)
  ~(do
    (def cap-join2 (wait ,rendezvous))
    (assert (verify ,pkA cap-join2))
    (send ,A ,response (= ,cap-join cap-join2))))
(print (wait response))
</code></pre>
<h2>Notes for the implementer</h2>
<p>Direct communication between any two peers should be authenticated.</p>
<p>In actual implementation, network destinations can be emphemeral. Ideally, a network destination cannot be looked up without being told from another secure channel. A network destination is like a capability in itself.</p>
<p>A capability is a signed string. There is nothing magic about it.</p>
<p><a href="https://en.wikipedia.org/wiki/Two_Generals%27_Problem">Delivery is not guaranteed.</a>s</p>
<p>A delivery receipt is sent back as an ordinary message, inspired by <a href="https://github.com/Arceliar/phony/blob/master/actor.go">a Go actor library</a>.</p>
<h2>Comments</h2>
<p>Many novel concepts invented in the past are composite ideas. In the E language, each &#x201c;E vat&#x201d; is a container for capabilities that can&#x2019;t be forged outside. In the math world, a &#x201c;vat&#x201d; is more like the causal boundary caused by the creation of a signing key pair.</p>
<p>There should be more philosophy when discussing about computing/information concepts.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/92-consensus-shared-reality/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/92-consensus-shared-reality/"/>
    <title>Consensus is reached atop shared reality</title>
    <published>2025-09-24T12:00:00Z</published>
    <updated>2025-09-24T12:00:00Z</updated>
    <category term="soc"/>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/92-consensus-shared-reality/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Reality, like the city of Amber, casts shadows in all directions.</p>
<h2>Conflict resolution</h2>
<p>Consensus is formed on top of reality based on the fact that physical objects have positions.</p>
<p>Every (macroscopic) obect has a defined position. It cannot be at two places at the same time. Two massed objects cannot be at the same place at the same time. This is how information is stored.</p>
<p>Individuals may have different opinion on what they see. This is ok.</p>
<p>No matter how we think of what we see, what we see is shared. There is only one world.</p>
<h2>Journalism</h2>
<p>The consistency principle of mathematics cannot tell what information is real, only that: when two pieces of information conflict, at most one of them may be real.</p>
<p>If we want to know what is real and what is fictitious, we need <a href="https://en.wikipedia.org/wiki/Journalism_ethics_and_standards">good journalism</a>, not just freedom of press. Opinion should not be mixed with fact. Most self-identified press today don&#x2019;t pass this standard. Al Jazeera and AP News do.</p>
<p>We also need more people to choose to listen to good journalism instead of drinking directly from a firehose of a particular ideology. I feel absurd that I need to write about this, but <a href="https://www.youtube.com/watch?v=c1tjh_ZO_tY">present day events</a> demand it.</p>
<p>All arguments build up from this common ground. Among the common subjects, only formal math can be detached from reality.</p>
<h2>Personal observation forms the basis of reporting</h2>
<p>I don&#x2019;t like doing debates myself. Much of science today is finding patterns from observation, not finding out which style of rhetoric is better (unless what you want to study is rhetoric).</p>
<p>What you and I observe has the highest priority in a conflict. Observation &#x2026; is the only way we are attached to this world. Without observation, no conclusion about this world can be reached. I don&#x2019;t mean interpreting observation, only observation itself.</p>
<p>To deny personal experience is to deny reality. When I meet people denying personal experience of others, I don&#x2019;t communicate with them, as they deny the common ground consensus is built on. It is possible to have different interpretation about the same observation, or different, unrelated observations. None of these differences need to be settled, by debate or otherwise.</p>
<h2>Proper use of language</h2>
<p>Language is formed to describe what people perceive. It is a reflection of reality.</p>
<p>In order to communicate without barrier, words need to have specific meanings. All parties involved need to use the same dictionary.</p>
<p>You might of heard of commercial solutions described to &#x201c;maximize impact&#x201d;, as if whatever described is a kinetic object seeking to damage the target. This type of linguistic pollution damages communication.</p>
<p>Political propaganda <strong><strong>always</strong></strong> use word combinations with meaning that contradicts with itself. If it doesn&#x2019;t, it can hardly be called propaganda.</p>
<p>I really encourge the reader to not use words that has lost their meaning for this reason.</p>
<h2>Historical account of fictitious reporting</h2>
<p>Have you seen <a href="https://www.nationalgeographic.com/history/article/carta-marina-renaissance-sea-monsters">these animals</a>?</p>
<p><img alt="" src="fictitious-1.jpg"/></p>
<p>Or <a href="https://kagi.com/images?q=%E5%B1%B1%E6%B5%B7%E7%B6%93&amp;r=no_region&amp;sh=Cvond39xs2_yC1ms_0w0Sw">these animals</a>?</p>
<p><img alt="" src="fictitious-2.jpg"/></p>
<p>To the people at that time, they could all be real. After all, most readers of those works have never travelled there to see for themselves. Without photo cameras, they have no way of knowing if any of these are real or fictitious.</p>
<h2>The incentive of lying</h2>
<p>There are already too many cases of people telling lies for personal gain, at the cost of the receivers of such lies.</p>
<p><a href="https://en.wikipedia.org/wiki/Tetraethyllead">&#x201c;Safe lead-added gasoline&#x201d;</a> is one example. With no evidence, the investor of Tetraethyllead (TEL) claimed the chemical to be safe. Even after they know the effect of lead on human intelligence, the company did not disclose the finding, nor did it stopped the sale of TEL.</p>
<p>We now know that no amount of lead intake is safe.</p>
<p>What incentive? Well&#x2026;</p>
<ul>
<li>
sell more product
</li>
<li>
trick others to work for the perpetrator for free
</li>
<li>
trick others to give money to the perpetrator
</li>
<li>
trick others to use their future as collateral for the perpetrator&#x2019;s action
</li>
</ul>
<p>I am not qualified to talk about how to stop people from lying.</p>
<p>Information systems (social media platforms) full of lies capture their users and replicate their lies outwards if unchallenged.</p>
<p>I have not tried communicating with those trapped users. When I do, this section will be updated.</p>
<h2>Misinformation / mind control</h2>
<p>&#x201c;Spreading misinformation for political gain&#x201d; is maybe a misnomer. There might be something to be gained from it, but from the definition of power, spreading misinformation is exerting power &#x2013; it influences behavior of others. It is often hard to estimate how much power one <strong><strong>has</strong></strong>. Power only exists when exerted. In the cases of journalists and political dissidents being silenced. Who silenced them know very well the influence they have on others.</p>
<p>Projection happens due to the lack of imagination by the speaker.</p>
<h2>Value is expressed only through actions</h2>
<p>In the US, there are voters that claim to support affordable housing, when confronted with local zoning change that would allow more compact housing to be built nearby, acted to stop the change. By doing so, they have chosen their own&#x2026; whatever, I don&#x2019;t know what they think&#x2026; over affordable housing.</p>
<p>From my observation of people and learning from history and journalistic reports, the only reliable measure of someone&#x2019;s value is what they do. People with delusions often don&#x2019;t know their own values. Moral corruption like double standard is the precursor to personal and institutional corrupted behavior.</p>
<p>&#x201c;The self is not something ready-made, but something in continuous formation through choice of action.&#x201d; said John Dewey. If someone hold a notion in their mind but act against it, how do we call this inconsistency? This may happen to all ideas and ideologies that can possibly fit in the human mind.</p>
<h2>Delusion and self</h2>
<p>If we define delusion as &#x201c;unwilling to change in light of conflicting evidence&#x201d;, the people in the affordable housing example above should count as delusional <strong><strong>if</strong></strong> they still say that they support affordable housing after denying the construction of said affordable housing.</p>
<p>Can we tell apart being delusional from lying? If we can&#x2019;t observe directly how someone feels and thinks, the appearance of the two are computationally equivalent &#x2013; what they say is inconsistent with what they do. An awful property of delusion is, those with delusion often deny others of personal experience and individuality to support their own delusion.</p>
<p>Delusion, severe enough, may not be changed by feeding it information. If a prior is too certain, effective Bayesian learning can&#x2019;t happen. Without external shock (not just exposure to new information), such belief system is incapable of change.</p>
<p>I do not ask the reader to forgo beliefs inconsistent with their actions. Such process can be painful. What I ask from the reader is to <a href="/blog/91-to-counter-intolerance/">respect individuality of others</a>.</p>
<p>If I were to be responsible, I can&#x2019;t tell you what to believe in. This is because a belief system, formed naturally, should benefit the belief holder. Without knowing you well enough, I can&#x2019;t possibly know what you should believe in.</p>
<p>&#x201c;Benefit who&#x201d; you may ask. Self is formed through repeated choice of action. Past action determines present self, and future action is supposed to benefit present self. This recursive nature of self determines by definiton that only you can possibly know what is good for yourself. Others who claim to care about your interest must act by guessing. If you try to explain yourself, the structure of your self is changed in the process. By this logic, you really don&#x2019;t need to explain your actions, or to retain a copy of the decision making process (reasoning) in your mind. If you think of a reasoning for your past actions after you forgot about the original reasoning, it is called rationalizing. I avoid doing that as it makes no sense to me whatsoever.</p>
<h2>Motivation of authoring this article</h2>
<p>The author of this article has faced too many stupid questions, asking it to explain its own actions, calling it immature when it refuse to explain. To be specific, this one is not a quantum computer where every step of computation is reversible. I still need to be observed, right? Those who kept asking it relentlessly are, in all cases, delusional. They also don&#x2019;t understand personal boundary, or respect, or tolerance, nor liberty, which is about a half of the driving behind me writing this article.</p>
<p>The rest is because the Internet and social media platforms has created an environment where misinformation can spread wildly. Using the words of someone working voluntarily to create <a href="https://www.curekids.cn/">a website sharing accurate information about pediatric cancer</a>: &#x201c;There are people whose full time job is to spread pseudoscience. Every day they wake up, the first thing they think is &#x2018;How I will spread pseudoscience today.&#x2019;&#x201d; (Example misinformation: One can starve cancer to death by not eating.)</p>
<p>I do not have a solution to this kind of mind control at this time. I hope that all organized ideology would provide customer support to handle returns. Simple stories attract more readers than a reality that doesn&#x2019;t need to make sense.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/91-to-counter-intolerance/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/91-to-counter-intolerance/"/>
    <title>How to Counter Intolerance of Individuality&#x2014;with much digression</title>
    <published>2025-09-18T12:00:00Z</published>
    <updated>2025-11-21T12:00:00Z</updated>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/91-to-counter-intolerance/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>In this article, we will briefly mention the concept of intolerance, its various source and targets, conservatism, and how to counter intelorance.</p>
<p>The structure of intolerance have different names, and those who hold this value have different ways to defend their behavior. By the end of this article, I hope you will know how to recognize intolerance and defend against it no matter in what form it appears.</p>
<h2>Freedom to express individuality</h2>
<p>For a group of people to live together, they need to let each other live.</p>
<p>In <strong>On Liberty</strong> by Harriet Taylor Mill (in spirit) and John Stuart Mill, <a href="https://en.wikisource.org/wiki/On_Liberty/Chapter_3">a chapter is dedicated to individuality</a>, how it should be protected as far as it does not harm the liberty of others. Let&#x2019;s call this &#x201c;the principle of harm&#x201d;.</p>
<p>The idea of intolerance, in practice, often means that a group of people with a common trait should not exist. It goes from expressing disgust, denying the group&#x2019;s existence, and suppressing expression of their individuality, the most extreme being killing them outright.</p>
<p><a href="https://en.wikipedia.org/wiki/Paradox_of_tolerance">Paradox of tolerance</a> states that the tolerance may allow intolerance to form and break tolerance. Freedom of speech did allow intolerance to spread, in the case of the US, although there are more factors to consider when deciding how to treat intolerance.</p>
<h3>Sources and targets of intolerance</h3>
<p>Here are some sources of intolerance that have cause massive deaths. Hopefully you see this list as &#x201c;things not to try&#x201d;.</p>
<ul>
<li>
religion (crusade/jihad)
</li>
<li>
tribalism (most of human history)
</li>
<li>
to justify slavery (racism)
</li>
<li>
to justify colonization (racism but different)
</li>
<li>
disgust/superiority (e.g. of the poor in Great Britain)
</li>
<li>
economic hardship (e.g. of bourgeoisie in Marxism)
</li>
<li>
political (whatever crazy stuff you can think of)
</li>
<li>
being stupid (e.g. email hostname may not start with <code>1</code>)
</li>
</ul>
<p>The targets of intolerances? Basically every inheritable or acquired trait, imaginative or real. Intolerange of a trait develop from denying its existence to erasing it by force. With wide spread intolerance of any kind, there will not be freedom for individuals, not to mention justice.</p>
<p>Contrary the word stem of *-phobia, fear does not lead to intolerant act. <a href="/blog/14-counter-fearmonger/">It mearly surrenders power to those who manufactured it.</a></p>
<p>There&#x2019;s also cognitive dissonance, which&#x2026; I have not heard of it being the main cause of any mass murder.</p>
<p>So it is the attitude of those who cannot tolerate reality to deviate from their imagination that they would go out of harms way to eliminate those deviations from their world view. I cannot see in them the belief that there is something amazing about being alive.</p>
<h2>The propersity to follow rules (for lack of a better description) in some demographic</h2>
<p>Even in a nation founded on the shared value of preserving personal freedom from the state, their descendents today may not want that freedom. &#x201c;Law-biding citizen&#x201d; they claim to be.</p>
<p>It is in my observation that some people have no use for extra liberty. Not that extra liberty does not benefit them. When given the option for choose how to live, they don&#x2019;t know what to do. Instead, they would rather, to name a few, live a life void of disturbance, perhaps a government that can do things by violating personal liberty.</p>
<p>Maybe it is that philosophical inquiry requires a free mind, that the literature written by those people routinely return to traditional values. And when the idea that personal freedom is <a href="https://en.wikipedia.org/wiki/Universal_value">universal</a> is mainstream, they feel silenced and fear expressing their inclination to follow existing rules. There are slurs used against them too, like &#x201c;pawn&#x201d;, &#x201c;mindless&#x201d;; mostly unjustified.</p>
<p>In software usage, there are people who often complain about proprietary software, but are incapable of using free software one way or another. Maybe they are incapable of learning computing, or they don&#x2019;t want to. These people still need <strong><strong>some</strong></strong> software for whatever they do, like how the aforementioned group of people still need to live.</p>
<p>Still, as I observed, it is not the different aspect of liberty that&#x2019;s the difference. It is the total amount of liberty, with the maximum being what described by Mill in <strong>On Liberty</strong>. Different individuals assign different importance to livelihood (economic) and liberty. In order to have social cohesion, they must each compromise in their ideology. There might be ways to make both sides happy without compromise, but I think direct transfer of material is necessary.</p>
<p>One more paragraph about the nature of such compromise. In a absolutely free world, no one is required to help others. However, a modern, civilized government provides welfare and other services that can&#x2019;t be delegated to the private sector. For example, asking every voter to voluntarily fund the military may not work as well as taxation. Not all will be satisfied with a particular social contract that trades individual freedom with comfort.</p>
<p>If someone does not want freedom, freedom should not be forced on them. Whether they need freedom or not is for them to decide.</p>
<h2>Resource allocation during economic upheaval</h2>
<p>Should more welfare be provided to those who live by traditional values? Social elites already follow less rules than the rest of population. During the global free trade period, the wealth gained from global trade has contrentrated in the few who have adapted to the change. The rest suffered. It is not that far fetched to say that those with adventurous spirit are more likely to benefit from this. <a href="https://sci-hub.se/10.1111/1758-5899.12778">Some urge the government to interfere by balancing gains and losses</a>, thus violating the principle of harm. The principle of harm only concerns itself with harm caused during the expression of individuality, not by outside factors.</p>
<p>This has added to social division.</p>
<h2>Automation of production, not consumption</h2>
<p>Hypothesis here.</p>
<p>I suspect that <a href="https://news.mit.edu/2022/automation-drives-income-inequality-1121">automation has contributed to most of the wage gap</a> everywhere by automating production but not consumption. With enough production to saturate the consumption need of everyone (if they have infinite purchase power), only a part of the population is needed for that production. The rest are not paid enough to satisfy their consumption need fully, so the market shrinks. When consumption need is saturated, without intervention (e.g. collective bargaining), more productivity will only make the market shrink faster. International trade only moves this group of no automation to home or abroad. The disparity remains.</p>
<p><a href="https://www.un.org/en/un75/inequality-bridging-divide">Within a country, the private ownership of automation through company ownership has created much disparity.</a></p>
<p>This has added to social division greatly.</p>
<h2>Contagious Algorithms</h2>
<p>Social media applications that serve ads employ recommendation algorithms to maximize use time.</p>
<p>During the 2015 US election, YouTube&#x2019;s algorithm has caused the radicalization of many of its <del>products</del> users. Google has not been legally punishment for this act.</p>
<p>Some are concerned about social media users trapped inside their own bubble. To me, the information highway is configured based on what the user knows, and we should be more concerned about the spread of bullshit ideas the power-hungry cooked up. Whoever coined &#x201c;bubble&#x201d; must not know how the Internet works. &#x201c;Rabbit hole&#x201d; is an apt analogy.</p>
<p>Also, denying the existence of individuality can easily mutate into denying other existence in reality, such as global warming.</p>
<p>This has added to social division.</p>
<h2>Striving for peace</h2>
<p>This article could be longer, but let this be the final chapter before the conclusion.</p>
<p>In <a href="/blog/14-counter-fearmonger/">a past article about fearmongering</a>, I asked: Can physical violence erase information [of intolerance]?</p>
<p>The answer to this question is nuanced.</p>
<p>What&#x2019;s once a theocratic militant group who specialized in suicide bombing has <a href="https://www.npr.org/2023/12/21/1217758546/hamas-support-palestinians-west-bank">gained popular support</a> under survival pressure from Israel. While there were reports of soldiers chanting &#x201c;to build a theocratic state&#x201d;, the group has <a href="https://www.aljazeera.com/news/2006/1/25/christian-candidate-on-hamas-ticket">accepted Christians to be part of the electoral</a> but <a href="https://apnews.com/article/8fdc192372ed472d8043498f077d1dc0">cracked down on protests</a>. <a href="https://www.aljazeera.com/news/2025/9/10/maps-israel-has-attacked-six-countries-in-the-past-72-hours">Israel&#x2019;s particular brand of &#x201c;geopolitics&#x201d;</a> has united the two major sects in the regions. Martin Luther King has once said &#x201c;Injustice anywhere is a threat to justice everywhere.&#x201d; In this case, intolerance somewhere bring about tolerance elsewhere, albeit at a cost no party want to pay by themselves. (See Also: <a href="https://en.wikipedia.org/wiki/Ba%27athism">Ba&#x2019;athism</a>) It also brings us closer to World War 3.</p>
<p>The shooting of Charlie Kirk happened too recently, so I won&#x2019;t comment on it. However, I want to point out that <a href="https://en.wikipedia.org/wiki/January_6_United_States_Capitol_attack">storming a national institution building, armed</a>, represents politically-motivated violence of greater scale.</p>
<p>Update(2025-09-26): After <a href="https://www.youtube.com/watch?v=c1tjh_ZO_tY">Jimmy Kimmel&#x2019;s temporary suspension</a>, talk show hosts from across the political spectrum has united to stand behind absolute freedom of speech. I hope they find a way to bridge social division in that country.</p>
<p>Since I don&#x2019;t see any other option of coexistence, let&#x2019;s start with the bare minimum &#x2013; let everyone stay alive while respecting their individuality, talking all the above into account.</p>
<p>Survival is a baseline. Tolerance of individuality is also a baseline, but it is not the end. We can do much better that just tolerating. We can create a society where individuals support each other&#x2019;s development. I think this would involve drastically increasing signaling within a society, <a href="/blog/92-consensus-shared-reality/">using reality as a basis for consensus</a>.</p>
<h2>How to erase intolerance</h2>
<p>Culture, can be described as information shared in a population that affects the behavior of those who have it. With the spread of digital computer systems and the Internet, the information nature of culture is more prominent than ever. Computer system <a href="https://dougengelbart.org/content/view/140/">designed to augment the human intellect</a> can also write to the human intellect. The influence goes both ways.</p>
<p>To erase tolerance, we can erase its source or the derived sentiment.</p>
<p>To erase information, we can either</p>
<ul>
<li>
destroy its storage medium, biological or digital
</li>
<li>
erase it from its storage
</li>
<li>
let it be forgotten
</li>
<li>
overwrite it
</li>
</ul>
<p>In addition, we can limit its spread by&#x2026; I don&#x2019;t think it works. Internet censorship suppress the expression of individuality too much for me.</p>
<p>There are enough works mentioning the positive things one can promote in their surroundings. So please excuse my omission as to what to overwrite intolerance with.</p>
<h2>The importance of wording</h2>
<p>Individuality often referred to as &#x201c;diversity&#x201d; these days, although I think &#x201c;protecting diversity&#x201d; sounds a bit weird. We are experience a civil rights movement that liberates individuals from control of the commons, diversity of expression is a result of that.</p>
<p>Some news report call intolerance-driven attacks &#x201c;motivated by hate and bigotry&#x201d;. While the idea behind the intolerance is usually pointed out correctly, the word &#x201c;bigotry&#x201d; denotes some kind of bad mentality, while in reality it is replicated info made up by someone else. These extreme ideas are not rooted in human emotions, just information copied in. I usually use the word &#x201c;stupid&#x201d; in this case.</p>
<p>There&#x2019;s also the trend to abuse the word &#x201c;dicrimination&#x201d;. Technically, discrimination exist. However, oppression/violence happens because the stuff inside perpetuator&#x2019;s mind, as one intolerant ideology often contains stigma for multiple human traits. Price discrimination is still discrimination, so not all discrimination is based on intolerance.</p>
<p>As reader, I implore you to better utilize language(s) by consulting a dictionary. In times of post-truth, knowing how to communicate your intent clearly to those who still listen with a shared vocabulary (thus reality) is an important skill.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/99-economic-outage/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/99-economic-outage/"/>
    <title>Economic outage</title>
    <published>2025-11-18T12:00:00Z</published>
    <updated>2025-11-20T12:00:00Z</updated>
    <category term="econ"/>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/99-economic-outage/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <h2>Preface</h2>
<p>If you search for &#x201c;economy [country name]&#x201d; today, you will see many articles from economist-owned websites fearmongering about the decline in GDP. We will not get into why CPI and PPI are better indicators for the livehood of people in this article, but rather talk about the basics of economics and what is to come.</p>
<p>This article would not be possible without the economic philosophy of &#x5b6b;&#x9a4d;&#x9a65;, the author of <strong>Manchild Capitalism</strong><a id="fnref1" href="#fn1" role="doc-noteref"><sup>1</sup></a>. You may <a href="https://www.youtube.com/@sunlao">view his YouTube channel in zh-Hant</a>.</p>
<h2>Fiat currency</h2>
<p>The fiat currency has no intrinsic value. Its use value comes from the fact that some people are being forced to use it and trade in this currency.</p>
<p>One stores currency in a financial institution (the bank) in exchange for a promise that it will be paid back. Such an IOU is not currency.</p>
<p>A national debt can be separated into two kinds: internal and external, defined by if the residency of the debtor is inside or outside the nation&#x2019;s area of control (not necessaily its jurisdiction). In reality the separation is more like a gradient, due to how much a nation has control over a given area is varied in depending on where it is. However, it is safe to say that an internal debtor is easier to dissolve than an external debtor.</p>
<p>What happens when a nation fails to pay back its debt? Then the debtor has their liability dissolved. No other outcome is guaranteed. The popular conception about fiat currency is more myth than observation, and I won&#x2019;t attempt to rationalize the myriad ways people behave <a href="/blog/14-counter-fearmonger/">when in fear</a>.</p>
<p>A currency holder may see their currency being taken away for any reason. We usually call this act by the name &#x201c;robbery&#x201d;. It is a political act and an economic act. In a sense, every currency holder is an option with dozens of years of maturity.</p>
<p>I don&#x2019;t think it is possible to bankrupt a currency issuer that is not stupid. If it can guarantee the IOUs that savers receive from the bank, it can guarantee itself not to be bankrupt. We are living in a world where debt itself is traded as assets (whatever the word may mean), so I advise the reader to have at least this level of belief in human ingenuity.</p>
<p>Is making up a currency from no physical matter worth it? <a href="/blog/89-need-based-currency/">Maybe.</a></p>
<h2>Prepare for percuniary outage</h2>
<p>Every economy has a floor to land on in a world where every desire has a ceiling to reach.</p>
<p>In case of a shutdown of the monetary system that encompasses where you live, you may prepare as follows.</p>
<p>Our present era&#x2019;s economic system, according to my understanding, has 4 pillars. Please excuse my savagery in classification.</p>
<p>In the order of importance and the order of emergence in history:</p>
<ol>
<li>
<strong>Agriculture:</strong> production and sale of food.
</li>
<li>
<strong>Manufacturing:</strong> production and sale of artificial goods.
</li>
<li>
<strong>Service:</strong> production and sale of peer to peer work.
</li>
<li>
<strong>Hedonism:</strong> production and sale of art, games, gaming experience, an approximation of gaming experience as video, etc. It turtles all the way down.
</li>
</ol>
<p>There are other work like advertisement and running digital penhouses that does not seem to be production in any sense, but rater piggybacked on production.</p>
<p>If the monetary system collapse, or you choose to exit early:</p>
<ol>
<li>
<strong>Agriculture:</strong> you need to convince farmers to share their produce with you.
</li>
<li>
<strong>Manufacturing:</strong> there are enough manufactured goods already produced. use them.
</li>
<li>
<strong>Service:</strong>: do more of it yourself or ask a friend.
</li>
<li>
<strong>Hedonism:</strong> do whatever you like. although, play itself
</li>
</ol>
<p>Note that deciding where to live seem to have a larger influence on one&#x2019;s life expectancy than deciding what work to take. As long as there is need for something, even if it&#x2019;s only yourself needing it, producing it will not be in vain.</p>
<h2>Declining birth rate &#xb7; aging population</h2>
<p>Decline in birth rate has happened many times throughout human history. This time, it seems to be &#x201c;voluntary&#x201d; but not really. There are societies who slave-make women into maintain its reproduction cycle. There are societies who provide sufficient help to women in order to maintain its reproduction cycle. Then, there are societies that make its members feed on rare earth mineral and simulacrum through a 4K display. My hypothesis is, these things don&#x2019;t provide energy to the human body to support the energy-intense act of reproduction.</p>
<p>Before the concept of &#x201c;social contract&#x201d; or &#x201c;s*****ism&#x201d; has been appeared, communities exist where different age groups take care of one another with no regard to biological lineage. The fathers and mothers in that community would take care of their children collectively.</p>
<p>The social contribution system (tax system) of the modern state is kind of an extension to that, except it&#x2019;s ever broader.</p>
<p>Here is a question that you may want to think about. How do you feel about 28%<a id="fnref2" href="#fn2" role="doc-noteref"><sup>2</sup></a> of your percuniary gain being used to support the senior population? Welcome to the <strong>National Tribe</strong>, which very much fit the definition of national s*****ism, despite its negative connotations based on history. To some, this might seem like a success of the democratic institution. To some, this is an opportunity to blame the youth for not working hard enough. Other arguments that put the diversity of the human mind on full display will not be listed here.</p>
<p>To translate the words I heard from a certain Chinese nationalist:</p>
<blockquote>
<p>You may participate in this [political] system and fulfill the expectation of the previous generation had on you. You may also absent. But to break it, is to disrupt the lives of all who depend on it as collateral- [redacted: swearing]</p>
</blockquote>
<p>I think the above reasoning applies to all places with a noticable<a id="fnref3" href="#fn3" role="doc-noteref"><sup>3</sup></a> amount of social welfare.</p>
<p>From a computational perspective, cause come before effect, responsibility come after choice. This sentence is intentionally left blank.</p>
<section role="doc-endnotes">
<hr/>
<ol>
<li id="fn1">
<p>&#x300a;&#x5de8;&#x5b30;&#x8cc7;&#x672c;&#x4e3b;&#x7fa9;&#xff1a;&#x7576;&#x4ee3;&#x653f;&#x6cbb;&#x7d93;&#x6fdf;&#x56f0;&#x5883;&#x7684;&#x6b77;&#x53f2;&#x8fa8;&#x6790;&#x300b;&#x2014;&#x2014;&#x5b6b;&#x9a4d;&#x9a65;&#x3002; A philosophical treatise. Translation of the title is mine. The term &#x201c;Manchild&#x201d; is gender-neutral.<a href="#fnref1" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
<li id="fn2">
<p>I did not make this number up. Any worker that works in a registered, privately-owned incorporated in Germany pays about this share or higher.<a href="#fnref2" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
<li id="fn3">
<p>noticeable when it goes away<a href="#fnref3" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
</ol>
</section>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/98-causal-ordering/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/98-causal-ordering/"/>
    <title>Why fork&amp;join are fundamental to computation</title>
    <published>2025-11-18T12:00:00Z</published>
    <updated>2025-11-18T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/98-causal-ordering/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Recently, I tried to write a Djot parser in Zig that made me want to write this article to explain why causality is a basic concept of computation and why lambda calculus disrespects causality. The causality operator was a part of <a href="/stuff/algograph/">algograph</a> from the start, precisely because it is indispensible to a model of computation based on the reduction and rewriting of a graph.</p>
<p>To see why the concept of causal ordering is indispensible to computation, let&#x2019;s look at <a href="https://htmlpreview.github.io/?https://github.com/jgm/djot/blob/master/doc/syntax.html#precedence">the first section of the Djot syntax reference</a>.</p>
<p>The task: turn Djot input &#x2026;</p>
<pre><code>_This is *regular_ not strong* emphasis
</code></pre>
<p>&#x2026; into HTML output.</p>
<pre><code>&lt;p&gt;&lt;em&gt;This is *regular&lt;/em&gt; not strong* emphasis&lt;/p&gt;
</code></pre>
<p>Here&#x2019;s the conundrum: after the algorithm has processed the second <code>_</code> in the input, it will</p>
<ol>
<li>
process the next byte in the input (<code> </code>)
</li>
<li>
emit a span (<code>&lt;em&gt;</code>) with the text content <code>This is *regular</code>
</li>
</ol>
<p>The question is, which first?</p>
<p>The answer: it is not the parser algorithm&#x2019;s responsibility to decide which to do first, but rather a fundamental limitation of lambda calculus. The parser algorithm only cares about that both steps are done <strong>afterwards</strong>, not which is done first.</p>
<p>Guile famously have 7 layers of the language during compilation, each lowering to the next. I expect Djot to have 4: input byte stream, token stream, syntax event stream, output byte stream. I don&#x2019;t want to decide on ordering that&#x2019;s in no part the algorithm&#x2019;s responsibility, so I stopped working on the parser only after completing the &#x201c;Precedence&#x201d; section of <em>Djot syntax reference</em> to write this article.</p>
<h2>What is causal ordering</h2>
<p><a href="/stuff/algograph/images/syntax-3.webp">tl;dr</a></p>
<p>Causal ordering in algograph have two kinds: implicit and explicit.</p>
<p>Implicit causal ordering in algograph is like fork/join from Cilk, except it does not have its own syntax. The programmer draws the algorithm as a graph, and the runtime (compiler) takes care of the ordering.</p>
<p>equivalent of a fork point:</p>
<ul>
<li>
Go&#x2019;s <code>go f()</code> and <a href="https://github.com/Arceliar/phony/blob/master/actor.go">phony</a>
</li>
<li>
Pony&#x2019;s <code>be f()</code>
</li>
</ul>
<p>equivalent of a join point:</p>
<ul>
<li>
C++&#x2019;s <a href="https://en.cppreference.com/w/cpp/thread/barrier.html">std::barrier</a> with multiple inputs carrying data
</li>
</ul>
<p>Explicit causal ordering in algograph is represented with an operator. A causality operator is like a one-time use semaphore, where one execution context waits on another.</p>
<p>If you find this explanation tedious to understand as much as I find it tedious to write, sorry. If you use an algorithmic language with causal ordering as a language-level feature, your imagination<a id="fnref1" href="#fn1" role="doc-noteref"><sup>1</sup></a> will not be restricted by the flaw of lambda calculus.</p>
<h2>Appendix: Heartbeat scheduling</h2>
<p>Heartbeat scheduling has low overhead on CPU with branch prediction.<br/>
Zig: https://github.com/judofyr/spice<br/>
Rust: https://github.com/dragostis/chili</p>
<p>However, it requires every execution context to do a bit of scheduling. If used outside the pathological fork/join pattern, it may perform a bit worse.</p>
<section role="doc-endnotes">
<hr/>
<ol>
<li id="fn1">
<p>I think that mathematics shouldn&#x2019;t limit its holder&#x2019;s imagination. Many algorithms are plagued by the limitation of lambda calculus. I hope you realize that algograph is yet another model of computation among many others.<a href="#fnref1" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
</ol>
</section>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/97-nested-taiji/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/97-nested-taiji/"/>
    <title>Nested Taiji &#x2212; the art of computing and not computing</title>
    <published>2025-11-14T12:00:00Z</published>
    <updated>2025-11-20T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/97-nested-taiji/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>A program can only run when it fully exists. If a part of it exists not, the computation happens not. What does &#x201c;exist&#x201d; mean though?</p>
<p>This article talks about the shape of algorithms (&#x201c;type&#x201d;), not the implementation of them (&#x201c;term&#x201d;).</p>
<h2>Nested regions in theory</h2>
<p>We shall call a region &#x201c;positive&#x201d; if it &#x201c;exists&#x201d;; &#x201c;negative&#x201d; otherwise.</p>
<p>This idea is outside what can be described by total functions in Constructions Calculus.</p>
<p>A positive region is code that exists. A negative region is code to be filled in.</p>
<h2>Nested regions in practice</h2>
<p>An ELF file is a positive region with many negative regions with positive regions inside them. The interpreter (linker) provided by the operating system links the program together before running. The kernel fills the rest of the regions by itself.</p>
<p><img alt="A ELF file seen with this region analogy" src="elf.png"/></p>
<p>Syscalls are regions to be filled in by the kernel. Dynamic libraries used are regions that may or may not contain syscall regions or other dynamic library regions.</p>
<h2>Nested regions in theory</h2>
<p>Child regions of a region are not ordered. They are a unordered set.</p>
<p>Mathematics seem to not care which color of region exists, Yin or Yang. Yin may swap place with Yang. We only observe the boundaries of the regions are well nested &#x2013; a region is either inside or it doesn&#x2019;t exist, although this &#x201c;exist&#x201d; means differently than the negative region which &#x201c;doesn&#x2019;t exist&#x201d; but still exists.</p>
<p>A curious thought: Generative algorithms may fill a region automatically. There are maybe other ways to make a negative region directly compute.</p>
<h2>A simplified definition of a region</h2>
<p>A region is an algorithmic fragment with a discrete number of inputs and outputs.</p>
<p>Each input or output term has a type, which is itself an equivalence group.</p>
<p>The input terms are numbered <span class="math inline">\(in_i\)</span>. <span class="math inline">\(i\)</span> starts with 0.</p>
<p>The output terms are numbered <span class="math inline">\(out_i\)</span>.</p>
<p>The shape of a region is the type of all inputs and all outputs of the region.</p>
<p>A region can be either implemented (positive) or missing (negative).</p>
<p>The <strong><strong>foaming</strong></strong> (described below) of an algorithmic syntax is othorgonal to its type system. Any type system may be used in conjunction with Taiji regions.</p>
<h2>region shape matching</h2>
<p>It is possible to simply introduce a region. The final algorithm may ignore whatever passed in from the created region.</p>
<p><img alt="" src="intro.png"/></p>
<p>To is possible to cut a region in half by spliting the outer region in half.</p>
<p><img alt="" src="mitosis.png"/></p>
<h2>Recursive regions</h2>
<p>Recursion is possible. If you accept the fact that algorithm blocks compose naturally like this, the combinators in <em>To Mock a Mockingbird</em> become typed.</p>
<p>For the type on the left (in the image below), it is possible to plug it with itself, or have a few of those blocks chain together into a ring.</p>
<p><img alt="" src="recurse.png"/></p>
<p>Two mutually recursive regions fit into one another.</p>
<p><img alt="" src="mutual-recurse.png"/></p>
<p>In C, program linking is usually done by the following two steps.</p>
<ol>
<li>
At compile time, Part A is linked together with Part B by the <code>ld</code> linker.
</li>
<li>
At run time, Part A calls <code>B::init(A::func)</code> to link itself properly with Part B.
</li>
</ol>
<p>Mathematically, there is no difference between compile time linking and run time linking. Even time itself is relative.</p>
<h2>Folding regions</h2>
<p>If you have two regions of the same shape and polarity, they can be folded into one.</p>
<p><img alt="two regions of the same shape folded into one" src="fold-eliminate.png"/></p>
<h2>Improvement over entangled algebraic effects</h2>
<pre><code class="language-{=html}">&lt;details&gt;
    &lt;summary&gt;You may ignore this section if you don&apos;t know algebraic effects already.&lt;/summary&gt;
    
    In the eyes of a compiler, it is simpler to compile code written in this theory than algebraic effects.
    
    To put it simply, the idea that algebraic effects might entangle with each other is that, [a program with the ability to product effect A and effect B] has a different type from [a program with the ability to product effect A and effect B but not both at the same time]. This gets complicated fast, as more effects are added to a block of code, the combination explodes. Text-based algorithmic languages like Koka choose to not observe this fact and make every effect exclusive of CPU time. The loss of information (different ways of how effects may entangle) leads to fewer optimization opportunities by a compiler that has any sense of locality (not a &quot;full program compiler&quot;).
&lt;/details&gt;
</code></pre>
<h2>Real world type checker support</h2>
<p>Zig: No.</p>
<pre><code class="language-zig">fn foo(foo1: @TypeOf(foo), bar: i32) i32 {
    if (bar &gt; 0) {
        return foo1(bar - 4);
    }
    return bar;
}

fn a(comptime B: type) fn (B, i32) i32 {
    return opaque {
        fn f(b1: B, x: i32) i32 {
            if (x % 2 == 0) return b1(x / 2);
            return b1(x * 3 - 1);
        }
    }.f;
}

fn b(comptime A: type) fn (A, i32) i32 {
    return opaque {
        fn f(a1: A, x: i32) i32 {
            if (x % 3 == 0) return a1(x / 3);
            return a1(x * 5 - 1);
        }
    }.f;
}

const a_applied = a(@TypeOf(b(@TypeOf(a_applied))));

test {
    _ = foo;
    _ = a_applied;
}
</code></pre>
<pre><code class="language-shell">&#x24; zig test taiji-holes.zig
taiji-holes.zig:1:1: error: dependency loop detected
fn foo(foo1: @TypeOf(foo), bar: i32) i32 {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
referenced by:
    test_0: taiji-holes.zig:29:9
</code></pre>
<p>C++: No.</p>
<pre><code class="language-cpp">#include &lt;functional&gt;

using FooFunc = std::function&lt;int(FooFunc, int)&gt;;
                               // ^ FooFunc is not defined
</code></pre>
<p>Lean: Sort of. <a href="https://unnamed.website/">A friend</a> has pointed out that Lean has <a href="https://lean-lang.org/doc/reference/latest/Tactic-Proofs/Tactic-Reference/#refine">the <code>refine</code> tactic</a> that deals with holes.</p>
<h2>Function &#x201c;coloring&#x201d;</h2>
<p>What is the &#x201c;coloring&#x201d; in &#x201c;function coloring&#x201d;? Note that the &#x201c;coloring&#x201d; here means totally different from the Taiji coloring above.</p>
<p>What is <code>async fn(A) -&gt; B</code>?</p>
<p>Is it monad? <code>A -&gt; Future B</code></p>
<p>Is it effects? <code>A -&gt; &lt;async&gt; B</code></p>
<p>Analogous to how holes form in bread and cheese, let us call the nesting of bipolar regions in an algorithm &#x201c;foamings&#x201d;.</p>
<p>The function coloring simply comes from the fact that the language cannot treat types as regular values, plus it does not support native foaming.</p>
<p>Looking at <a href="https://github.com/rsepassi/zigcoro">async/await in Zig</a>, the &#x201c;async&#x201d; effect has holes that implicitly receive a type as input:</p>
<pre><code class="language-zig">xasync: fn (func, args, stack) Frame(ReturnType(@TypeOf(func)))
</code></pre>
<p>Therefore, we shall say that function coloring is an artifact of dependent types and foaming.</p>
<h2>More colors, more symmetry groups</h2>
<p>Why only <a href="https://mathworld.wolfram.com/CyclicGroupC2.html">two-fold symmetry <span class="math inline">\(C_2\)</span></a>? If <a href="https://www.youtube.com/watch?v=DTcfaHfDCEc">planar portals can be nested in a variety of ways</a>, maybe algorithms can employ any symmetry group?</p>
<p>Placed here as a thought exercise.</p>
<h2>Acknowledgement</h2>
<p>The idea of monad comes from Idris 2.</p>
<p>The idea of algebraic effect comes from Koka.</p>
<p>The idea of nested regions of algorithm was originally expressed as part of <a href="/stuff/algograph/images/syntax-4.webp">a graphical algorithmic language</a>, although the author called it &#x201c;effects&#x201d; and &#x201c;holes&#x201d; back then.</p>
<p>A discussion in the vague direction of LISP with <a href="https://screwlisp.small-web.org/">screwlisp</a> has prompted me to clarify the idea of nested regions.</p>
<p>A discourse of &#x7384; in the book&#x300a;&#x592a;&#x7384;&#x300b;discuss about the development of real life events under a ternary system. It is safe to say that I do not understand that book.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/A1-abstraction-courage/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/A1-abstraction-courage/"/>
    <title>Abstraction and courage, explained</title>
    <published>2025-11-21T12:00:00Z</published>
    <updated>2025-12-21T12:00:00Z</updated>
    <category term="comp"/>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/A1-abstraction-courage/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Would you detangle a child? A women?</p>
<p>When an adult gets angry at a child, it is trying to forcefully remove the innate complexity brought by birth. One may equate anger with the willingness to forcefully remove the offending complexity. In fact, all other emotions should have a computational equivalence.</p>
<p>When faced with complexity, some humans choose to selectively blind themselves. The &#x201c;selectively&#x201d; part carries information, so it creates more complexity. The mentality of &#x201c;what am i gonna do? start a revolution? i have no choice (but to obey)&#x201d; is simpler than the innate complexity of vegetables, which are empowered by natural selection to survive and reproduce under a wide range of conditions.</p>
<p>Light takes the shortest path because it has no time to think. So please, observe more and <a href="/w/04-are-we-real-yet/">describe less</a>.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/A0-process-calculus/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/A0-process-calculus/"/>
    <title>Connecting and ordering consent through collective action</title>
    <published>2025-11-21T12:00:00Z</published>
    <updated>2025-12-18T12:00:00Z</updated>
    <category term="comp"/>
    <category term="soc"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/A0-process-calculus/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>In this article, we will try to build <a href="/blog/">a simple build system</a>. It is simple in the sense that there is no complexity to remove.</p>
<p>During computation, data is not the only thing that guides consent. The patience to withhold, too. To put it differently, the unit type written in a different way. True <code>void</code> can be put inside the processor when the computer is thrown into outer space. Since causality is conducted through matter, it flows along a time-like curve and cannot form a loop, which is an assumption<a id="fnref1" href="#fn1" role="doc-noteref"><sup>1</sup></a> we rely on for the rest of this article.</p>
<p>According to the Alchemical principle of Equal Exchange, respect for individual choice is to be observed on all sides. The absent of choice is allowed iff the omission of choice<a id="fnref2" href="#fn2" role="doc-noteref"><sup>2</sup></a> is allowed.</p>
<p>Our build system builds a graph from a build specification &#x2013; a collective consensus reached by a multitude of individuals<a id="fnref3" href="#fn3" role="doc-noteref"><sup>3</sup></a> working together to slip the algorithm in and out of presence.</p>
<h2>An example, explained through drawing</h2>
<p>Here is an example consensus.</p>
<p><img alt="example build graph" src="example-graph.jpg"/></p>
<p>A solid diamond denotes an event managed by the algorithm.</p>
<p>A hollow diamond denotes an event <strong>not</strong> managed by the algorithm.</p>
<p>A line without a cap conducts causality both ways. It represents a graceful transfer of a packet of information.</p>
<p>A line with an arrow cap conducts causality one way. Those arrows by themselves do not convey information, but the superposition of any two does. It represents <a href="/blog/30-recall/">a choice where both can be chosen</a>.</p>
<p>The &#x201c;~&#x201d; symbol represents a <a href="/blog/97-nested-taiji/">need-provide relationship (causal ordering)</a>. It consists of 1 arrow inside it, yes.</p>
<p>Specific to our example,</p>
<p>A big hollow diamond is a build command to be run.</p>
<p>A small hollow diamond is a file to be created or updated.</p>
<h2>Putting the consensus into motion</h2>
<p>Before the evaluation, the graph fully resides in the future.</p>
<p>To evaluate this graph, the computer holds the solid diamond(s) the user has chosen and pulls move them through the apparent horizon from the up side. As the holes in the algorithm pass through the present time, the disturbance it creates will be observed on the attached tty.</p>
<p>If a hollow diamond gets stuck in the apparent horizon, the algorithm has no choice. It must wait for it to resolve or dissolve. When the only things that are stuck in the apparent horizon are solid diamonds, the evaluation ends.</p>
<p>After the evaluation, the graph is split into the past part and the future part. Some events are stuck in the present.</p>
<p>When the evaluation is interrupted in a transitioning state, where a solid diamond is entering or leaving but not <strong>at</strong> the apparent horizon, the computer acts funky. graceful shutdown<a id="fnref4" href="#fn4" role="doc-noteref"><sup>4</sup></a> is nonsensical when graceful transition is not observed.</p>
<h2>Putting the consensus into a separate motion</h2>
<p>Did I say that data lines may conduct causality both ways? The arrow facing is important. An outwards-pointing<a id="fnref5" href="#fn5" role="doc-noteref"><sup>5</sup></a> arrow may only pull another event up side. An inwards-pointing arrow may only pull another event down side. Colloquially, &#x201c;slip/elapse/pull it X side&#x201d; means &#x201c;from the X side&#x201d;. An east wind blows from the east.</p>
<p><img alt="" src="pull.jpg"/></p>
<p>To &#x201c;unbuild a file&#x201d; (when a file has be modified on disk), hold the file events and pull it <strong>down side</strong>.</p>
<h2>The same example, explained through typing<a id="fnref6" href="#fn6" role="doc-noteref"><sup>6</sup></a></h2>
<p>Update(2025-12-18): It turns out I was too lazy to provide a reference implementation for this build system.</p>
<p><a href="https://stdlib.ponylang.io/promises-Promise/"><code>Promise</code> in Pony</a> might provide a hint as to how the events are linked together into a graph.</p>
<h2>Artistic interpretation</h2>
<p>Awhile back, <a href="/poem/#1">I made a poem when observing the motion of intelligence.</a> Maybe it makes more sense to you than the mathematical explanation above.</p>
<p>During the writing process, <a href="https://www.youtube.com/watch?v=gN24W_psMpE&amp;list=RDNE-7O-cSvcc&amp;index=5">Youtube also recommended me this playlist.</a> If this article is a TV series, these songs should be in it.</p>
<h2>Does contemporary algorithmic languages respect individual choice?</h2>
<p>Here&#x2019;s a rule of thumb to test if a certain model of computation respects individual choice or not:</p>
<p><strong>Does computation in that model end when no work can be done?</strong></p>
<p>It must be the default way for a algorithm to end to count as proper respect.</p>
<p>Some test results:</p>
<ul>
<li>
<a href="https://github.com/faiface/par-lang/">Par</a>: Yes. <code>.end !</code> is explicit.
</li>
<li>
Pony: Yes. Part of the language specification (quiescence).
</li>
<li>
Node.js and Deno: Yes, through its event loop.
</li>
<li>
Python 3.14 + <code>asyncio</code>: Yes? It prints a warning though.
</li>
<li>
Rust + <code>tokio</code>: No. <a href="https://github.com/tokio-rs/tokio/issues/6450">The algorithm will do nothing and not exit either.</a>
</li>
<li>
Go: Probably No. It panics!
</li>
</ul>
<p>Please use the word &#x201c;quiescence&#x201d; to refer to a algorithm state where nothing more will happen. Do not use the d- word. The d- word kills mathematical creatures.</p>
<h2>Symmetry</h2>
<p>Why the horizon only has an up side and a down side? Because I made it up. I only said that causality may not loop. I never said if time is real here, or if an apparent horizon can only have two sides &#x2013; up and down. Any symmetry group could be used here, really. Through an act of will, the trajectory of the computation into the future and the past is narrowed<a id="fnref7" href="#fn7" role="doc-noteref"><sup>7</sup></a> towards the present. The will is of everything that exists, where local matter have more say on local matter.</p>
<p>How do we define if a causality may pass through a horizon?</p>
<pre><code>mayPass : CausalityFacing -&gt; HorizonFacing -&gt; Bool
</code></pre>
<p>Why <code>Bool</code>? There is no apparent reason why, so I probably made that one up too. The field of mathematics might be an artifact of manufactured, theoretical consistency in a collective pursuit towards moral purity. In light of this evidence, I think we need to reflect on the practice of <a>trying to stuff everything onto a real number line and see if it fits</a>.</p>
<h2>Acknowledgement</h2>
<p>The list content is partial. The list ordering is impartial.</p>
<ul>
<li>
1A &#x22a2; read(<a href="https://www.youtube.com/watch?v=NE-7O-cSvcc"><em>Unnamed Memory</em></a>)
</li>
<li>
1A &#x22a2; read(<a href="https://en.wikipedia.org/wiki/Yuanfen">&#x201c;fateful coincidence&#x201d; in Buddhism</a>)
</li>
<li>
1A &#x22a2; read(<a href="https://github.com/faiface/par-lang/">Par</a>)
</li>
<li>
1A &#x22a2; write(This article)
</li>
<li>
You &#x22a2; read(This article)
</li>
</ul>
<p>Understood?<br/>
Y -&gt; End.<br/>
N -&gt; Re-read.<br/>
</p>
<section role="doc-endnotes">
<hr/>
<ol>
<li id="fn1">
<p>A stronger assumption that i held to this point is that all someone need to obey in reality is the strict ordering of consent. If you understand this, you will never show the expression Andrei Sator had after he tried to beat his wife (in the movie <em>TENET</em>).<a href="#fnref1" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
<li id="fn2">
<p>the act of not referring to something when forming a decision<a href="#fnref2" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
<li id="fn3">
<p>not quite the definition of the phrase <a href="https://screwlisp.small-web.org/complex/Sandewall-caisor-bibliography/">when it is used by Sandewall</a><a href="#fnref3" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
<li id="fn4">
<p>&#x201c;graceful shutdown&#x201d; is more of a marketing phrase than an engineering one. &#x201c;Crash-only software&#x201d; means software that may exit and restart at any point in time. I hope this causal ordering thing can represent more types of software living in harmony.<a href="#fnref4" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
<li id="fn5">
<p>The relative chronological order from the event being pulled to the event being pulled along. There is no need to remember which is up and which is down; it&#x2019;s like polarity.<a href="#fnref5" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
<li id="fn6">
<p>Pun intended.<a href="#fnref6" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
<li id="fn7">
<p>Some may say that the possibility space &#x201c;collapses&#x201d; upon observation, or that a time-like curve can be &#x201c;bent&#x201d; by force. To a time-like curve, the aforementioned observer&#x2019;s mind is highly complected &#x2013; the feeling is mutual.<a href="#fnref7" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
</ol>
</section>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/A2-partial-order/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/A2-partial-order/"/>
    <title>About partial ordering</title>
    <published>2025-12-30T12:00:00Z</published>
    <updated>2025-12-30T12:00:00Z</updated>
    <category term="rant"/>
    <category term="math"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/A2-partial-order/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Partial ordering should not use the &#x2264; symbol. It is disrespectful to equality.</p>
<p>A partial ordering operator on a set is as follows. Given two members, they are either ordered or unordered. If ordered, either one may be ordered before another.</p>
<pre><code>inductive PartialOrder
| less
| unordered
| greater

tryOrder : A -&gt; A -&gt; PartialOrder
</code></pre>
<p>Then, transitivity is optional.</p>
<p>Math is fun outside the beaten path. I feel terrified that the mainstream math notation even overloads the equal sign to mean two totally different concepts.</p>

      </div>
    </content>
  </entry>

  <entry>
    <id>https://www.1a-insec.net/blog/A3-crypto-standard/</id>
    <link rel="alternate" href="https://www.1a-insec.net/blog/A3-crypto-standard/"/>
    <title>A new standard for cryptography</title>
    <published>2025-12-30T12:00:00Z</published>
    <updated>2025-12-30T12:00:00Z</updated>
    <category term="comp"/>
    <content type="xhtml" xml:base="https://www.1a-insec.net/blog/A3-crypto-standard/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>Allow me to propose a new standard for cryptography.</p>
<p>A cryptographic algorithm is considered secure when every step of the computation is shown to the attack as it happens. A step can be blinded (cannot be measured exactly which step is taken) when multiple candidate steps can be taken, and there isn&#x2019;t a plausible way to detect which step is chosen.</p>
<p>All computation generates heat, and heat radiates as light (black body radiation). In the far future, there may be a device capable of looking inside a x86 CPU and differentiating between <code>mov rax 0</code> and <code>mov rax 1</code> being executed. Therefore, a cryptographic algorithm should pair with adequate radiation shielding to prevent surveilance. A device like lava lamp can be placed inside to create heat disturbances to make decoding CPU movement from outside the box nigh impossible.</p>
<p>We can create such a computer box by purchasing a fanless computer and painting it with a paint full of micrometer glass beads that radiates heat faster than it does naturally. Then, use an algorithm that knows how to blind its own choices.</p>
<p>It is maybe philosophically interesting to think about a world without privacy. Such a world cannot have individuality, assuming they have the same laws of physics as we do. In the same lein of thought, if we have individuality, we must have privacy.</p>

      </div>
    </content>
  </entry>
</feed>