Files
hammer/recipes/hammer-edit.toml
sergioandClaude Opus 4.8 d99ed58850 harkaq: revertir busybox (era runtime base, rompía builds) + coordinar el §3 con Fable 5
DOS ERRORES MÍOS, uno de dirección y otro técnico, los dos en la cosecha automática:

1. DIRECCIÓN: declaró `busybox` como dep en 29 recetas — cuando la Etapa C lo está
   ELIMINANDO (USERLAND_COMPONENTS=[uutils,findutils,…], ya cerrada; joyas-reusables
   §5 lo confirma: "uutils… Ubuntu 25.10 los envía como default"). Estaba cimentando
   la deuda que el roadmap borra.
2. TÉCNICO: busybox YA está en el runtime base de harkaq (`ro /bin/busybox`, `ro
   /bin/sh` — el sandbox corre `sh -c` y /bin/sh→/bin/busybox). Es CONTRATO, no dep.
   Declararlo apila el busybox de hammer sobre el de Alpine y ROMPE el build:
   binutils daba "cannot run C compiled programs" en las DOS máquinas. Verificado:
   sin busybox declarado, binutils construye (b3:f4507dcd…). Y la cadena se explica:
   binutils roto ⇒ zlib (que lo declara) tampoco construía.

Auditoría de la cosecha (diff real, no la línea completa del +): añadió sólo 5 deps
distintas — make ×73, busybox ×29, perl ×8, pkgconf ×5, binutils ×1. Sólo busybox
estaba mal; las otras 4 son deps reales medidas. busybox revertido de 30 recetas
(queda sólo en busybox.toml, pre-existente).

Es el mismo error que ya me habían señalado con otro disfraz: MEDIR BIEN Y ACCIONAR
MAL. harkaq midió correcto (el build toca /bin/busybox: es el shell); la acción
correcta no era declararlo sino reconocerlo como contrato.

+ COORDINACIÓN del §3 con Fable 5 (mismo diseño, tareas repartidas):
  - Su lección casper queda CONFIRMADA y REFORZADA: la clausura de build no sólo le
    FALTAN las clases del mundo (offline) — también le SOBRA casi todo (headers, gcc).
    Medido: htop (estático, 0 NEEDED) no toca NADA al correr ⇒ política = su binario.
  - Su "la clase viaja como campo de la ConcesionCapacidad, sin formato nuevo" se
    cumple LITERALMENTE: lo firmado es format::Permisos = u32 bitmask en 36 bytes
    canónicos (Ring 0) ⇒ las clases SON los bits. La cripto no se toca.
  - Diseño unificado: frontera (clases, u32, declaradas) + detalle (paths, Landlock,
    medidos). D3 rige en ambos.
  - Reparto: clases→Fable 5; medición/harness→Opus. CONTACTO: runtime-policy.sh ahora
    emite la CLASE detectada (/etc/resolv.conf→dns, /etc/ssl/certs→tls-certs, …), no
    sólo el path: la medición alimenta la tabla, la tabla decide el bit.
  - Consumidor esperando: plan-jaula-juegos F1 (Steam que no puede leer ~/.ssh).

+ juez.sh (§10): nombre único por corrida (con uno fijo pega en caché ⇒ falso
  "sin evidencia"). Fue el juez quien destapó todo esto en su primera corrida real.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-16 23:14:19 -04:00

139 lines
5.7 KiB
TOML

# hammer-edit — editor de código REAL para el distro: Adwaita + GtkSourceView, abrir/guardar/guardar-como
# (GtkFileDialog), resaltado por extensión, números de línea, apertura de archivos desde la CLI. Link 100%
# estático (gtk4+libadwaita+gtksourceview). No es una demo: es una app instalable y usable.
name = "hammer-edit"
version = "1.0.0"
[source]
tarball = "https://download.gnome.org/sources/gtksourceview/5.16/gtksourceview-5.16.0.tar.xz"
sha256 = "ab35d420102f3e8b055dd3b8642d3a48209f888189e6254d0ffb4b6a7e8c3566"
[build]
compiler = "zig-cc"
target = "x86_64-linux-musl"
link = "static"
[build.phases]
configure = "true"
compile = '''
cat > hammer_edit.c <<'CEOF'
#include <adwaita.h>
#include <gtksourceview/gtksource.h>
#include <string.h>
typedef struct { GtkWindow *win; GtkSourceBuffer *buf; GFile *file; } App;
static void set_title(App *a) {
char *name = a->file ? g_file_get_basename(a->file) : g_strdup("Sin título");
char *full = g_strdup_printf("%s — hammer-edit", name);
gtk_window_set_title(a->win, full);
g_free(name); g_free(full);
}
static void load_file(App *a, GFile *file) {
char *contents; gsize len;
if (!g_file_load_contents(file, NULL, &contents, &len, NULL, NULL)) return;
gtk_text_buffer_set_text(GTK_TEXT_BUFFER(a->buf), contents, len);
g_free(contents);
g_set_object(&a->file, file);
GtkSourceLanguageManager *lm = gtk_source_language_manager_get_default();
char *base = g_file_get_basename(file);
GtkSourceLanguage *lang = gtk_source_language_manager_guess_language(lm, base, NULL);
gtk_source_buffer_set_language(a->buf, lang);
g_free(base);
set_title(a);
}
static void open_cb(GObject *src, GAsyncResult *res, gpointer ud) {
App *a = ud;
GFile *file = gtk_file_dialog_open_finish(GTK_FILE_DIALOG(src), res, NULL);
if (file) { load_file(a, file); g_object_unref(file); }
}
static void on_open(GtkButton *b, gpointer ud) {
App *a = ud;
GtkFileDialog *d = gtk_file_dialog_new();
gtk_file_dialog_open(d, a->win, NULL, open_cb, a);
g_object_unref(d);
}
static void save_to(App *a, GFile *file) {
GtkTextIter s, e;
gtk_text_buffer_get_bounds(GTK_TEXT_BUFFER(a->buf), &s, &e);
char *text = gtk_text_buffer_get_text(GTK_TEXT_BUFFER(a->buf), &s, &e, FALSE);
g_file_replace_contents(file, text, strlen(text), NULL, FALSE,
G_FILE_CREATE_NONE, NULL, NULL, NULL);
g_free(text);
g_set_object(&a->file, file);
set_title(a);
}
static void save_cb(GObject *src, GAsyncResult *res, gpointer ud) {
App *a = ud;
GFile *file = gtk_file_dialog_save_finish(GTK_FILE_DIALOG(src), res, NULL);
if (file) { save_to(a, file); g_object_unref(file); }
}
static void on_save(GtkButton *b, gpointer ud) {
App *a = ud;
if (a->file) { save_to(a, a->file); return; }
GtkFileDialog *d = gtk_file_dialog_new();
gtk_file_dialog_save(d, a->win, NULL, save_cb, a);
g_object_unref(d);
}
static App *build_window(GtkApplication *app) {
App *a = g_new0(App, 1);
GtkWidget *win = adw_application_window_new(app);
a->win = GTK_WINDOW(win);
gtk_window_set_default_size(a->win, 820, 580);
GtkWidget *tv = adw_toolbar_view_new();
GtkWidget *hb = adw_header_bar_new();
GtkWidget *ob = gtk_button_new_from_icon_name("document-open-symbolic");
GtkWidget *sb = gtk_button_new_from_icon_name("document-save-symbolic");
gtk_widget_set_tooltip_text(ob, "Abrir");
gtk_widget_set_tooltip_text(sb, "Guardar");
g_signal_connect(ob, "clicked", G_CALLBACK(on_open), a);
g_signal_connect(sb, "clicked", G_CALLBACK(on_save), a);
adw_header_bar_pack_start(ADW_HEADER_BAR(hb), ob);
adw_header_bar_pack_end(ADW_HEADER_BAR(hb), sb);
adw_toolbar_view_add_top_bar(ADW_TOOLBAR_VIEW(tv), hb);
a->buf = gtk_source_buffer_new(NULL);
gtk_source_buffer_set_highlight_syntax(a->buf, TRUE);
GtkWidget *view = gtk_source_view_new_with_buffer(a->buf);
gtk_source_view_set_show_line_numbers(GTK_SOURCE_VIEW(view), TRUE);
gtk_source_view_set_highlight_current_line(GTK_SOURCE_VIEW(view), TRUE);
gtk_source_view_set_auto_indent(GTK_SOURCE_VIEW(view), TRUE);
gtk_widget_add_css_class(view, "monospace");
GtkWidget *sc = gtk_scrolled_window_new();
gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sc), view);
adw_toolbar_view_set_content(ADW_TOOLBAR_VIEW(tv), sc);
adw_application_window_set_content(ADW_APPLICATION_WINDOW(win), tv);
set_title(a);
return a;
}
static void activate(GApplication *app, gpointer ud) {
App *a = build_window(GTK_APPLICATION(app));
gtk_window_present(a->win);
}
static void open_files(GApplication *app, GFile **files, gint n, const char *hint, gpointer ud) {
App *a = build_window(GTK_APPLICATION(app));
if (n > 0) load_file(a, files[0]);
gtk_window_present(a->win);
}
int main(int argc, char **argv) {
AdwApplication *app = adw_application_new("org.hammer.edit", G_APPLICATION_HANDLES_OPEN);
g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
g_signal_connect(app, "open", G_CALLBACK(open_files), NULL);
int status = g_application_run(G_APPLICATION(app), argc, argv);
g_object_unref(app);
return status;
}
CEOF
export PKG_CONFIG_PATH=/usr/lib/pkgconfig
zig cc -mcpu=baseline -static hammer_edit.c -o hammer-edit $(pkg-config --cflags --libs --static gtksourceview-5 libadwaita-1 harfbuzz-subset epoxy xkbcommon wayland-client wayland-egl libtiff-4 libjpeg cairo-script-interpreter)
'''
install = "mkdir -p /out/usr/bin && cp hammer-edit /out/usr/bin/hammer-edit"
[deps]
build = ["pkgconf", "gtksourceview", "libadwaita", "appstream", "libyaml", "curl", "openssl", "libxmlb", "libxml2", "zstd", "gtk4", "pango", "gdk-pixbuf", "cairo", "graphene", "glib", "harfbuzz", "fribidi", "fontconfig", "freetype", "pixman", "libpng", "expat", "libjpeg-turbo", "libtiff", "libepoxy", "wayland", "libxkbcommon", "libdrm", "pcre2", "libffi", "zlib", "mesa"]