Stage D batch 6: mama_forth_words.c group 4 -- identity/crypto words (FABRIC-3.md §XXXII.6)
Build / build-amd64-iso (push) Canceled after 0s
Build / build-aarch64-iso (push) Canceled after 0s
Build / build-riscv64-img (push) Canceled after 0s

MINT + mint_pop_string()/ZUSE-ELIGIBILITY-ADD/ZUSE-ELIGIBLE?/
ELEVATE-PUBKEY-UNPACK, 10 sites. mint_pop_string() gained a field_name
parameter so its diagnostics name which of MINT's four string
arguments failed (phone/email/username/full_name), rather than a
generic message that would leave the operator guessing. Diagnostic
placement matched each function's own sibling convention where one
exists (ZUSE-ELIGIBILITY-ADD), log_message() default otherwise.

Three-arch clean qemu acceptance passed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BWpNjdwPtFLuVLaAq44L9K
This commit is contained in:
Robert Allan James
2026-09-15 19:53:47 -04:00
co-authored by Claude Sonnet 5
parent 8b5300fc4f
commit 90c86c6006
10 changed files with 27201 additions and 11 deletions
+41 -10
View File
@@ -1036,16 +1036,37 @@ static void mama_word_vm_heat(VM *vm)
*/
/* Pop one ( caddr u ) string pair and copy it, NUL-terminated, into
* dst (capacity dst_cap). Returns 0 on success, -1 on underflow/bounds/
* unmapped-address failure (vm->error is set in that case). */
static int mint_pop_string(VM *vm, char *dst, size_t dst_cap)
* unmapped-address failure (vm->error is set in that case). field_name
* names which MINT argument this call is popping, for a precise
* diagnostic (FABRIC-3.md §XXXII.6) -- this helper is called four times
* with different fields, so a generic message would leave the operator
* guessing which one actually failed. */
static int mint_pop_string(VM *vm, char *dst, size_t dst_cap, const char *field_name)
{
if (vm->dsp < 1) { vm->error = 1; return -1; }
if (vm->dsp < 1) {
console_puts("MINT: expects S\" ");
console_puts(field_name);
console_println("\" -- nothing on the stack");
vm->error = 1;
return -1;
}
cell_t u = vm_pop(vm);
cell_t caddr = vm_pop(vm);
if (u < 0 || (size_t)u >= dst_cap) { vm->error = 1; return -1; }
if (u < 0 || (size_t)u >= dst_cap) {
console_puts("MINT: ");
console_puts(field_name);
console_println(" too long or negative length");
vm->error = 1;
return -1;
}
if (u > 0) {
const uint8_t *p = vm_ptr(vm, (vaddr_t)caddr);
if (!p) { vm->error = 1; return -1; }
if (!p) {
console_puts("MINT: invalid address on the stack for ");
console_println(field_name);
vm->error = 1;
return -1;
}
memcpy(dst, p, (size_t)u);
}
dst[u] = '\0';
@@ -1072,12 +1093,16 @@ static void mama_word_mint(VM *vm)
char full_name[USER_IDENTITY_FULL_NAME_MAX];
/* Stack order: fname pushed first, restrict? last -- pop in reverse. */
if (vm->dsp < 0) { vm->error = 1; return; }
if (vm->dsp < 0) {
console_println("MINT: expects a restrict? flag on top of the stack");
vm->error = 1;
return;
}
cell_t restrict_flag = vm_pop(vm);
if (mint_pop_string(vm, phone, sizeof(phone)) != 0) return;
if (mint_pop_string(vm, email, sizeof(email)) != 0) return;
if (mint_pop_string(vm, username, sizeof(username)) != 0) return;
if (mint_pop_string(vm, full_name, sizeof(full_name)) != 0) return;
if (mint_pop_string(vm, phone, sizeof(phone), "phone") != 0) return;
if (mint_pop_string(vm, email, sizeof(email), "email") != 0) return;
if (mint_pop_string(vm, username, sizeof(username), "username") != 0) return;
if (mint_pop_string(vm, full_name, sizeof(full_name), "full_name") != 0) return;
struct blkio_dev *dev = sk_repl_get_attached_blk_dev();
if (!dev) {
@@ -1139,6 +1164,7 @@ static void mama_word_mint(VM *vm)
static void mama_word_zuse_eligibility_add(VM *vm)
{
if (vm->dsp < 0) {
console_println("ZUSE-ELIGIBILITY-ADD: stack underflow");
vm->error = 1;
vm_push(vm, 0);
return;
@@ -1146,6 +1172,7 @@ static void mama_word_zuse_eligibility_add(VM *vm)
cell_t caddr = vm_pop(vm);
const uint8_t *pubkey = vm_ptr(vm, (vaddr_t)caddr);
if (!pubkey) {
console_println("ZUSE-ELIGIBILITY-ADD: invalid address on the stack");
vm->error = 1;
vm_push(vm, 0);
return;
@@ -1170,6 +1197,7 @@ static void mama_word_zuse_eligibility_add(VM *vm)
static void mama_word_zuse_eligible_query(VM *vm)
{
if (vm->dsp < 0) {
log_message(LOG_ERROR, "ZUSE-ELIGIBLE?: stack underflow");
vm->error = 1;
vm_push(vm, 0);
return;
@@ -1177,6 +1205,7 @@ static void mama_word_zuse_eligible_query(VM *vm)
cell_t caddr = vm_pop(vm);
const uint8_t *pubkey = vm_ptr(vm, (vaddr_t)caddr);
if (!pubkey) {
log_message(LOG_ERROR, "ZUSE-ELIGIBLE?: invalid address on the stack");
vm->error = 1;
vm_push(vm, 0);
return;
@@ -1229,6 +1258,7 @@ static void mama_word_name_to_xt(VM *vm)
static void mama_word_elevate_pubkey_unpack(VM *vm)
{
if (vm->dsp < 4) {
log_message(LOG_ERROR, "ELEVATE-PUBKEY-UNPACK: stack underflow");
vm->error = 1;
return;
}
@@ -1238,6 +1268,7 @@ static void mama_word_elevate_pubkey_unpack(VM *vm)
uint8_t *buf = vm_ptr(vm, (vaddr_t)buf_addr);
if (!buf) {
log_message(LOG_ERROR, "ELEVATE-PUBKEY-UNPACK: invalid address on the stack");
vm->error = 1;
return;
}